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.
- package/dist/components/avatar/group.cjs +4 -5
- package/dist/components/avatar/group.mjs +5 -6
- package/dist/components/countdown/countdown.cjs +25 -6
- package/dist/components/countdown/countdown.d.ts +1 -1
- package/dist/components/countdown/countdown.mjs +25 -6
- package/dist/components/form/field/field.cjs +8 -3
- package/dist/components/form/field/field.mjs +9 -4
- package/dist/components/form/item.cjs +16 -5
- package/dist/components/form/item.d.ts +2 -2
- package/dist/components/form/item.mjs +16 -5
- package/dist/components/otp-input/hooks.cjs +1 -4
- package/dist/components/otp-input/hooks.mjs +2 -5
- package/dist/components/otp-input/otp-input.cjs +5 -3
- package/dist/components/otp-input/otp-input.d.ts +1 -1
- package/dist/components/otp-input/otp-input.mjs +6 -4
- package/dist/components/popconfirm/popconfirm.cjs +26 -19
- package/dist/components/popconfirm/popconfirm.mjs +28 -21
- package/dist/components/popover/hooks.cjs +28 -0
- package/dist/components/popover/hooks.d.ts +11 -0
- package/dist/components/popover/hooks.mjs +30 -3
- package/dist/components/popover/popover.cjs +54 -26
- package/dist/components/popover/popover.d.ts +2 -2
- package/dist/components/popover/popover.mjs +57 -29
- package/dist/components/theme/hooks.cjs +8 -10
- package/dist/components/theme/hooks.d.ts +0 -3
- package/dist/components/theme/hooks.mjs +8 -10
- package/dist/locale/locales/en_US.cjs +8 -3
- package/dist/locale/locales/en_US.mjs +8 -3
- package/dist/locale/locales/zh_CN.cjs +8 -3
- package/dist/locale/locales/zh_CN.mjs +8 -3
- package/dist/types/countdown.d.ts +1 -1
- package/dist/types/locale.d.ts +3 -0
- package/dist/types/otp-input.d.ts +2 -1
- package/dist/types/popover.d.ts +2 -3
- package/package.json +8 -8
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PopperRef } from "musae/types/popper";
|
|
2
|
+
import { TriggerBy } from "../../types/popover";
|
|
2
3
|
type UsedIsOpen = [
|
|
3
4
|
boolean,
|
|
4
5
|
{
|
|
@@ -13,4 +14,14 @@ type UsedIsOpen = [
|
|
|
13
14
|
* open state
|
|
14
15
|
*/
|
|
15
16
|
export declare const useIsOpen: (popperRef: React.RefObject<PopperRef>) => UsedIsOpen;
|
|
17
|
+
/**
|
|
18
|
+
* @description
|
|
19
|
+
* used triggers
|
|
20
|
+
*/
|
|
21
|
+
export declare const useTriggerBy: (triggerBy: TriggerBy | TriggerBy[]) => {
|
|
22
|
+
isHoverable: boolean;
|
|
23
|
+
isFocusable: boolean;
|
|
24
|
+
isClickable: boolean;
|
|
25
|
+
isContextMenuable: boolean;
|
|
26
|
+
};
|
|
16
27
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _regeneratorRuntime from '@babel/runtime/helpers/regeneratorRuntime';
|
|
2
2
|
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
3
3
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
|
-
import { useEvent } from '@aiszlab/relax';
|
|
4
|
+
import { useEvent, toArray } from '@aiszlab/relax';
|
|
5
5
|
import { useLazyBoolean } from '../../hooks/use-lazy-boolean.mjs';
|
|
6
|
-
import { useCallback } from 'react';
|
|
6
|
+
import { useCallback, useMemo } from 'react';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @description
|
|
@@ -60,5 +60,32 @@ 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 = useMemo(function () {
|
|
69
|
+
return new Set(toArray(triggerBy));
|
|
70
|
+
}, [triggerBy]);
|
|
71
|
+
var isHoverable = useMemo(function () {
|
|
72
|
+
return _triggerBy.has("hover");
|
|
73
|
+
}, [_triggerBy]);
|
|
74
|
+
var isFocusable = useMemo(function () {
|
|
75
|
+
return _triggerBy.has("focus");
|
|
76
|
+
}, [_triggerBy]);
|
|
77
|
+
var isClickable = useMemo(function () {
|
|
78
|
+
return _triggerBy.has("click");
|
|
79
|
+
}, [_triggerBy]);
|
|
80
|
+
var isContextMenuable = 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
|
-
export { useIsOpen };
|
|
91
|
+
export { useIsOpen, useTriggerBy };
|
|
@@ -68,11 +68,12 @@ var Popover = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
|
68
68
|
turnOff = _useIsOpen2$.turnOff,
|
|
69
69
|
toggle = _useIsOpen2$.toggle,
|
|
70
70
|
disappear = _useIsOpen2$.disappear;
|
|
71
|
-
var triggerBy = React.useMemo(function () {
|
|
72
|
-
return new Set(relax.toArray(_triggerBy));
|
|
73
|
-
}, [_triggerBy]);
|
|
74
71
|
var classNames = useClassNames.useClassNames(componentToken.ComponentToken.Popover);
|
|
75
|
-
var
|
|
72
|
+
var _useTriggerBy = hooks.useTriggerBy(_triggerBy),
|
|
73
|
+
isClickable = _useTriggerBy.isClickable,
|
|
74
|
+
isContextMenuable = _useTriggerBy.isContextMenuable,
|
|
75
|
+
isFocusable = _useTriggerBy.isFocusable,
|
|
76
|
+
isHoverable = _useTriggerBy.isHoverable;
|
|
76
77
|
var onClick = relax.useEvent(function (event) {
|
|
77
78
|
event.stopPropagation();
|
|
78
79
|
toggle();
|
|
@@ -81,34 +82,61 @@ var Popover = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
|
81
82
|
event.preventDefault();
|
|
82
83
|
toggle();
|
|
83
84
|
});
|
|
85
|
+
// hover enter callback
|
|
86
|
+
var onHoverEnter = React.useCallback(function (event) {
|
|
87
|
+
var _children$props$onMou, _children$props, _children$props$onPoi, _children$props2;
|
|
88
|
+
turnOn();
|
|
89
|
+
if (! /*#__PURE__*/React.isValidElement(_children)) return;
|
|
90
|
+
(_children$props$onMou = (_children$props = _children.props).onMouseEnter) === null || _children$props$onMou === void 0 || _children$props$onMou.call(_children$props, event);
|
|
91
|
+
(_children$props$onPoi = (_children$props2 = _children.props).onPointerEnter) === null || _children$props$onPoi === void 0 || _children$props$onPoi.call(_children$props2, event);
|
|
92
|
+
}, [_children, turnOn]);
|
|
93
|
+
// hover leave callback
|
|
94
|
+
var onHoverLeave = React.useCallback(function (event) {
|
|
95
|
+
var _children$props$onMou2, _children$props3, _children$props$onPoi2, _children$props4;
|
|
96
|
+
turnOff();
|
|
97
|
+
if (! /*#__PURE__*/React.isValidElement(_children)) return;
|
|
98
|
+
(_children$props$onMou2 = (_children$props3 = _children.props).onMouseLeave) === null || _children$props$onMou2 === void 0 || _children$props$onMou2.call(_children$props3, event);
|
|
99
|
+
(_children$props$onPoi2 = (_children$props4 = _children.props).onPointerLeave) === null || _children$props$onPoi2 === void 0 || _children$props$onPoi2.call(_children$props4, event);
|
|
100
|
+
}, [_children, turnOff]);
|
|
84
101
|
var _useHover = relax.useHover({
|
|
85
|
-
onEnter:
|
|
86
|
-
|
|
87
|
-
},
|
|
88
|
-
onLeave: function onLeave(event) {
|
|
89
|
-
return relax.chain(_children.props.onMouseLeave, _children.props.onPointerLeave, disappear)(event);
|
|
90
|
-
}
|
|
102
|
+
onEnter: onHoverEnter,
|
|
103
|
+
onLeave: onHoverLeave
|
|
91
104
|
}),
|
|
92
105
|
_useHover2 = _slicedToArray(_useHover, 2),
|
|
93
106
|
hoverProps = _useHover2[1];
|
|
107
|
+
var onFocus = React.useCallback(function (event) {
|
|
108
|
+
var _children$props$onFoc, _children$props5;
|
|
109
|
+
turnOn();
|
|
110
|
+
if (! /*#__PURE__*/React.isValidElement(_children)) return;
|
|
111
|
+
(_children$props$onFoc = (_children$props5 = _children.props).onFocus) === null || _children$props$onFoc === void 0 || _children$props$onFoc.call(_children$props5, event);
|
|
112
|
+
}, [_children, turnOn]);
|
|
113
|
+
var onBlur = React.useCallback(function (event) {
|
|
114
|
+
var _children$props$onBlu, _children$props6;
|
|
115
|
+
turnOff();
|
|
116
|
+
if (! /*#__PURE__*/React.isValidElement(_children)) return;
|
|
117
|
+
(_children$props$onBlu = (_children$props6 = _children.props).onBlur) === null || _children$props$onBlu === void 0 || _children$props$onBlu.call(_children$props6, event);
|
|
118
|
+
}, [_children, turnOff]);
|
|
94
119
|
var _useFocus = relax.useFocus({
|
|
95
|
-
onFocus:
|
|
96
|
-
|
|
97
|
-
},
|
|
98
|
-
onBlur: function onBlur(event) {
|
|
99
|
-
return relax.chain(_children.props.onBlur, disappear)(event);
|
|
100
|
-
}
|
|
120
|
+
onFocus: onFocus,
|
|
121
|
+
onBlur: onBlur
|
|
101
122
|
}),
|
|
102
123
|
_useFocus2 = _slicedToArray(_useFocus, 2),
|
|
103
124
|
focusProps = _useFocus2[1];
|
|
104
|
-
//
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
125
|
+
// valid elment, inject handlers
|
|
126
|
+
// else add `div` wrapper
|
|
127
|
+
var children = React.useMemo(function () {
|
|
128
|
+
var props = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
129
|
+
ref: _ref
|
|
130
|
+
}, isHoverable && hoverProps), isFocusable && focusProps), isClickable && {
|
|
131
|
+
onClick: onClick
|
|
132
|
+
}), isContextMenuable && {
|
|
133
|
+
onContextMenu: onContextMenu
|
|
134
|
+
});
|
|
135
|
+
if (/*#__PURE__*/React.isValidElement(_children)) {
|
|
136
|
+
return /*#__PURE__*/React.cloneElement(_children, props);
|
|
137
|
+
}
|
|
138
|
+
return /*#__PURE__*/React.createElement("div", _objectSpread({}, props), _children);
|
|
139
|
+
}, [_children, focusProps, hoverProps, isClickable, isContextMenuable, isFocusable, isHoverable, onClick, onContextMenu]);
|
|
112
140
|
var enterPopper = React.useCallback(function () {
|
|
113
141
|
turnOn();
|
|
114
142
|
}, [turnOn]);
|
|
@@ -117,7 +145,7 @@ var Popover = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
|
117
145
|
}, [disappear]);
|
|
118
146
|
relax.useClickAway(function () {
|
|
119
147
|
turnOff();
|
|
120
|
-
}, [popperRef,
|
|
148
|
+
}, [popperRef, isClickable && _ref]);
|
|
121
149
|
React.useImperativeHandle(ref, function () {
|
|
122
150
|
return {
|
|
123
151
|
close: turnOff
|
|
@@ -132,7 +160,7 @@ var Popover = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
|
132
160
|
trigger: _ref.current,
|
|
133
161
|
open: isOpen,
|
|
134
162
|
arrow: arrow
|
|
135
|
-
},
|
|
163
|
+
}, isHoverable && {
|
|
136
164
|
onPointerEnter: enterPopper,
|
|
137
165
|
onPointerLeave: leavePopper
|
|
138
166
|
}), {}, {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { ChildProps, PopoverRef } from "musae/types/popover";
|
|
3
3
|
declare const Popover: React.ForwardRefExoticComponent<import("../../types/element").ComponentProps & {
|
|
4
|
-
children: React.ReactElement<ChildProps<HTMLElement>, string | React.JSXElementConstructor<any
|
|
4
|
+
children: number | boolean | React.ReactElement<ChildProps<HTMLElement>, string | React.JSXElementConstructor<any>> | null | undefined;
|
|
5
5
|
title?: React.ReactNode;
|
|
6
6
|
content: React.ReactNode;
|
|
7
|
-
triggerBy?: ("
|
|
7
|
+
triggerBy?: import("musae/types/popover").TriggerBy | import("musae/types/popover").TriggerBy[];
|
|
8
8
|
placement?: import("@floating-ui/dom").Placement;
|
|
9
9
|
padding?: boolean | number;
|
|
10
10
|
arrow?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
2
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
|
-
import {
|
|
4
|
-
import React, { forwardRef, useRef, useMemo, cloneElement,
|
|
3
|
+
import { useEvent, useHover, useFocus, useClickAway, clsx } from '@aiszlab/relax';
|
|
4
|
+
import React, { forwardRef, useRef, useCallback, isValidElement, useMemo, cloneElement, useImperativeHandle } from 'react';
|
|
5
5
|
import Popper from '../popper/popper.mjs';
|
|
6
6
|
import _stylex from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.5/node_modules/@stylexjs/stylex/lib/es/stylex.mjs';
|
|
7
7
|
import { spacing } from '../theme/tokens.stylex.mjs';
|
|
@@ -9,7 +9,7 @@ import { typography } from '../theme/theme.mjs';
|
|
|
9
9
|
import { useClassNames } from '../../hooks/use-class-names.mjs';
|
|
10
10
|
import { PopoverClassToken } from '../../utils/class-name.mjs';
|
|
11
11
|
import { ComponentToken } from '../../utils/component-token.mjs';
|
|
12
|
-
import { useIsOpen } from './hooks.mjs';
|
|
12
|
+
import { useIsOpen, useTriggerBy } from './hooks.mjs';
|
|
13
13
|
|
|
14
14
|
var styles = {
|
|
15
15
|
popover: {
|
|
@@ -66,11 +66,12 @@ var Popover = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
66
66
|
turnOff = _useIsOpen2$.turnOff,
|
|
67
67
|
toggle = _useIsOpen2$.toggle,
|
|
68
68
|
disappear = _useIsOpen2$.disappear;
|
|
69
|
-
var triggerBy = useMemo(function () {
|
|
70
|
-
return new Set(toArray(_triggerBy));
|
|
71
|
-
}, [_triggerBy]);
|
|
72
69
|
var classNames = useClassNames(ComponentToken.Popover);
|
|
73
|
-
var
|
|
70
|
+
var _useTriggerBy = useTriggerBy(_triggerBy),
|
|
71
|
+
isClickable = _useTriggerBy.isClickable,
|
|
72
|
+
isContextMenuable = _useTriggerBy.isContextMenuable,
|
|
73
|
+
isFocusable = _useTriggerBy.isFocusable,
|
|
74
|
+
isHoverable = _useTriggerBy.isHoverable;
|
|
74
75
|
var onClick = useEvent(function (event) {
|
|
75
76
|
event.stopPropagation();
|
|
76
77
|
toggle();
|
|
@@ -79,34 +80,61 @@ var Popover = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
79
80
|
event.preventDefault();
|
|
80
81
|
toggle();
|
|
81
82
|
});
|
|
83
|
+
// hover enter callback
|
|
84
|
+
var onHoverEnter = useCallback(function (event) {
|
|
85
|
+
var _children$props$onMou, _children$props, _children$props$onPoi, _children$props2;
|
|
86
|
+
turnOn();
|
|
87
|
+
if (! /*#__PURE__*/isValidElement(_children)) return;
|
|
88
|
+
(_children$props$onMou = (_children$props = _children.props).onMouseEnter) === null || _children$props$onMou === void 0 || _children$props$onMou.call(_children$props, event);
|
|
89
|
+
(_children$props$onPoi = (_children$props2 = _children.props).onPointerEnter) === null || _children$props$onPoi === void 0 || _children$props$onPoi.call(_children$props2, event);
|
|
90
|
+
}, [_children, turnOn]);
|
|
91
|
+
// hover leave callback
|
|
92
|
+
var onHoverLeave = useCallback(function (event) {
|
|
93
|
+
var _children$props$onMou2, _children$props3, _children$props$onPoi2, _children$props4;
|
|
94
|
+
turnOff();
|
|
95
|
+
if (! /*#__PURE__*/isValidElement(_children)) return;
|
|
96
|
+
(_children$props$onMou2 = (_children$props3 = _children.props).onMouseLeave) === null || _children$props$onMou2 === void 0 || _children$props$onMou2.call(_children$props3, event);
|
|
97
|
+
(_children$props$onPoi2 = (_children$props4 = _children.props).onPointerLeave) === null || _children$props$onPoi2 === void 0 || _children$props$onPoi2.call(_children$props4, event);
|
|
98
|
+
}, [_children, turnOff]);
|
|
82
99
|
var _useHover = useHover({
|
|
83
|
-
onEnter:
|
|
84
|
-
|
|
85
|
-
},
|
|
86
|
-
onLeave: function onLeave(event) {
|
|
87
|
-
return chain(_children.props.onMouseLeave, _children.props.onPointerLeave, disappear)(event);
|
|
88
|
-
}
|
|
100
|
+
onEnter: onHoverEnter,
|
|
101
|
+
onLeave: onHoverLeave
|
|
89
102
|
}),
|
|
90
103
|
_useHover2 = _slicedToArray(_useHover, 2),
|
|
91
104
|
hoverProps = _useHover2[1];
|
|
105
|
+
var onFocus = useCallback(function (event) {
|
|
106
|
+
var _children$props$onFoc, _children$props5;
|
|
107
|
+
turnOn();
|
|
108
|
+
if (! /*#__PURE__*/isValidElement(_children)) return;
|
|
109
|
+
(_children$props$onFoc = (_children$props5 = _children.props).onFocus) === null || _children$props$onFoc === void 0 || _children$props$onFoc.call(_children$props5, event);
|
|
110
|
+
}, [_children, turnOn]);
|
|
111
|
+
var onBlur = useCallback(function (event) {
|
|
112
|
+
var _children$props$onBlu, _children$props6;
|
|
113
|
+
turnOff();
|
|
114
|
+
if (! /*#__PURE__*/isValidElement(_children)) return;
|
|
115
|
+
(_children$props$onBlu = (_children$props6 = _children.props).onBlur) === null || _children$props$onBlu === void 0 || _children$props$onBlu.call(_children$props6, event);
|
|
116
|
+
}, [_children, turnOff]);
|
|
92
117
|
var _useFocus = useFocus({
|
|
93
|
-
onFocus:
|
|
94
|
-
|
|
95
|
-
},
|
|
96
|
-
onBlur: function onBlur(event) {
|
|
97
|
-
return chain(_children.props.onBlur, disappear)(event);
|
|
98
|
-
}
|
|
118
|
+
onFocus: onFocus,
|
|
119
|
+
onBlur: onBlur
|
|
99
120
|
}),
|
|
100
121
|
_useFocus2 = _slicedToArray(_useFocus, 2),
|
|
101
122
|
focusProps = _useFocus2[1];
|
|
102
|
-
//
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
123
|
+
// valid elment, inject handlers
|
|
124
|
+
// else add `div` wrapper
|
|
125
|
+
var children = useMemo(function () {
|
|
126
|
+
var props = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
127
|
+
ref: _ref
|
|
128
|
+
}, isHoverable && hoverProps), isFocusable && focusProps), isClickable && {
|
|
129
|
+
onClick: onClick
|
|
130
|
+
}), isContextMenuable && {
|
|
131
|
+
onContextMenu: onContextMenu
|
|
132
|
+
});
|
|
133
|
+
if (/*#__PURE__*/isValidElement(_children)) {
|
|
134
|
+
return /*#__PURE__*/cloneElement(_children, props);
|
|
135
|
+
}
|
|
136
|
+
return /*#__PURE__*/React.createElement("div", _objectSpread({}, props), _children);
|
|
137
|
+
}, [_children, focusProps, hoverProps, isClickable, isContextMenuable, isFocusable, isHoverable, onClick, onContextMenu]);
|
|
110
138
|
var enterPopper = useCallback(function () {
|
|
111
139
|
turnOn();
|
|
112
140
|
}, [turnOn]);
|
|
@@ -115,7 +143,7 @@ var Popover = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
115
143
|
}, [disappear]);
|
|
116
144
|
useClickAway(function () {
|
|
117
145
|
turnOff();
|
|
118
|
-
}, [popperRef,
|
|
146
|
+
}, [popperRef, isClickable && _ref]);
|
|
119
147
|
useImperativeHandle(ref, function () {
|
|
120
148
|
return {
|
|
121
149
|
close: turnOff
|
|
@@ -130,7 +158,7 @@ var Popover = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
130
158
|
trigger: _ref.current,
|
|
131
159
|
open: isOpen,
|
|
132
160
|
arrow: arrow
|
|
133
|
-
},
|
|
161
|
+
}, isHoverable && {
|
|
134
162
|
onPointerEnter: enterPopper,
|
|
135
163
|
onPointerLeave: leavePopper
|
|
136
164
|
}), {}, {
|
|
@@ -133,9 +133,6 @@ var useTheme = function useTheme() {
|
|
|
133
133
|
* @description
|
|
134
134
|
* inject css names and styles into html element
|
|
135
135
|
* for animations
|
|
136
|
-
*
|
|
137
|
-
* u may ask: why add a single hook for this?
|
|
138
|
-
* i will answer: because i want to keep the code clean.
|
|
139
136
|
*/
|
|
140
137
|
var useSwitchable = function useSwitchable(_ref) {
|
|
141
138
|
var theme = _ref.theme;
|
|
@@ -159,11 +156,12 @@ var useSwitchable = function useSwitchable(_ref) {
|
|
|
159
156
|
className: "musaex-ntwwlm musaex-jitcrl musaex-19v9tfi"
|
|
160
157
|
}
|
|
161
158
|
};
|
|
162
|
-
var repaint = relax.useEvent(function (
|
|
159
|
+
var repaint = relax.useEvent(function (nextMode) {
|
|
163
160
|
var _document$documentEle, _document$documentEle2;
|
|
164
|
-
var _isDark =
|
|
165
|
-
|
|
166
|
-
(_document$
|
|
161
|
+
var _isDark = nextMode === "dark";
|
|
162
|
+
var _usingMode = _isDark ? "light" : "dark";
|
|
163
|
+
(_document$documentEle = document.documentElement.classList).remove.apply(_document$documentEle, _toConsumableArray(styles.toClassList(styled[_usingMode].className)));
|
|
164
|
+
(_document$documentEle2 = document.documentElement.classList).add.apply(_document$documentEle2, _toConsumableArray(styles.toClassList(styled[nextMode].className)));
|
|
167
165
|
document.documentElement.style.backgroundColor = _isDark ? theme.palette.neutral[0] : theme.palette.neutral[100];
|
|
168
166
|
});
|
|
169
167
|
relax.useMounted(function () {
|
|
@@ -179,16 +177,16 @@ var useSwitchable = function useSwitchable(_ref) {
|
|
|
179
177
|
});
|
|
180
178
|
// dark, light mode switch
|
|
181
179
|
var toggle = relax.useEvent(function (event) {
|
|
182
|
-
var
|
|
180
|
+
var _toMode = isDark ? "light" : "dark";
|
|
183
181
|
// dom not support animation
|
|
184
182
|
if (!relax.isFunction(document.startViewTransition)) {
|
|
185
183
|
var _trigger$current;
|
|
186
|
-
(_trigger$current = trigger.current) === null || _trigger$current === void 0 || _trigger$current.next(
|
|
184
|
+
(_trigger$current = trigger.current) === null || _trigger$current === void 0 || _trigger$current.next(_toMode);
|
|
187
185
|
return;
|
|
188
186
|
}
|
|
189
187
|
var animation = document.startViewTransition(function () {
|
|
190
188
|
var _trigger$current2;
|
|
191
|
-
(_trigger$current2 = trigger.current) === null || _trigger$current2 === void 0 || _trigger$current2.next(
|
|
189
|
+
(_trigger$current2 = trigger.current) === null || _trigger$current2 === void 0 || _trigger$current2.next(_toMode);
|
|
192
190
|
});
|
|
193
191
|
animation.ready.then(function () {
|
|
194
192
|
var _event$clientX, _event$clientY;
|
|
@@ -20,9 +20,6 @@ export declare const useTheme: () => ContextValue;
|
|
|
20
20
|
* @description
|
|
21
21
|
* inject css names and styles into html element
|
|
22
22
|
* for animations
|
|
23
|
-
*
|
|
24
|
-
* u may ask: why add a single hook for this?
|
|
25
|
-
* i will answer: because i want to keep the code clean.
|
|
26
23
|
*/
|
|
27
24
|
export declare const useSwitchable: ({ theme }: {
|
|
28
25
|
theme: Theme;
|
|
@@ -133,9 +133,6 @@ var useTheme = function useTheme() {
|
|
|
133
133
|
* @description
|
|
134
134
|
* inject css names and styles into html element
|
|
135
135
|
* for animations
|
|
136
|
-
*
|
|
137
|
-
* u may ask: why add a single hook for this?
|
|
138
|
-
* i will answer: because i want to keep the code clean.
|
|
139
136
|
*/
|
|
140
137
|
var useSwitchable = function useSwitchable(_ref) {
|
|
141
138
|
var theme = _ref.theme;
|
|
@@ -159,11 +156,12 @@ var useSwitchable = function useSwitchable(_ref) {
|
|
|
159
156
|
className: "musaex-ntwwlm musaex-jitcrl musaex-19v9tfi"
|
|
160
157
|
}
|
|
161
158
|
};
|
|
162
|
-
var repaint = useEvent(function (
|
|
159
|
+
var repaint = useEvent(function (nextMode) {
|
|
163
160
|
var _document$documentEle, _document$documentEle2;
|
|
164
|
-
var _isDark =
|
|
165
|
-
|
|
166
|
-
(_document$
|
|
161
|
+
var _isDark = nextMode === "dark";
|
|
162
|
+
var _usingMode = _isDark ? "light" : "dark";
|
|
163
|
+
(_document$documentEle = document.documentElement.classList).remove.apply(_document$documentEle, _toConsumableArray(toClassList(styled[_usingMode].className)));
|
|
164
|
+
(_document$documentEle2 = document.documentElement.classList).add.apply(_document$documentEle2, _toConsumableArray(toClassList(styled[nextMode].className)));
|
|
167
165
|
document.documentElement.style.backgroundColor = _isDark ? theme.palette.neutral[0] : theme.palette.neutral[100];
|
|
168
166
|
});
|
|
169
167
|
useMounted(function () {
|
|
@@ -179,16 +177,16 @@ var useSwitchable = function useSwitchable(_ref) {
|
|
|
179
177
|
});
|
|
180
178
|
// dark, light mode switch
|
|
181
179
|
var toggle = useEvent(function (event) {
|
|
182
|
-
var
|
|
180
|
+
var _toMode = isDark ? "light" : "dark";
|
|
183
181
|
// dom not support animation
|
|
184
182
|
if (!isFunction(document.startViewTransition)) {
|
|
185
183
|
var _trigger$current;
|
|
186
|
-
(_trigger$current = trigger.current) === null || _trigger$current === void 0 || _trigger$current.next(
|
|
184
|
+
(_trigger$current = trigger.current) === null || _trigger$current === void 0 || _trigger$current.next(_toMode);
|
|
187
185
|
return;
|
|
188
186
|
}
|
|
189
187
|
var animation = document.startViewTransition(function () {
|
|
190
188
|
var _trigger$current2;
|
|
191
|
-
(_trigger$current2 = trigger.current) === null || _trigger$current2 === void 0 || _trigger$current2.next(
|
|
189
|
+
(_trigger$current2 = trigger.current) === null || _trigger$current2 === void 0 || _trigger$current2.next(_toMode);
|
|
192
190
|
});
|
|
193
191
|
animation.ready.then(function () {
|
|
194
192
|
var _event$clientX, _event$clientY;
|
|
@@ -3,9 +3,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3
3
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
4
|
var componentToken = require('../../utils/component-token.cjs');
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _en_US;
|
|
7
|
+
var en_US = (_en_US = {
|
|
7
8
|
locale: "en_US"
|
|
8
|
-
}, componentToken.ComponentToken.Dialog, {
|
|
9
|
+
}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_en_US, componentToken.ComponentToken.Dialog, {
|
|
9
10
|
confirm: "Confirm",
|
|
10
11
|
cancel: "Cancel"
|
|
11
12
|
}), componentToken.ComponentToken.Empty, {
|
|
@@ -33,6 +34,10 @@ var en_US = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_def
|
|
|
33
34
|
confirm: "Confirm"
|
|
34
35
|
}), componentToken.ComponentToken.Upload, {
|
|
35
36
|
upload: "Upload"
|
|
36
|
-
})
|
|
37
|
+
}), _defineProperty(_en_US, componentToken.ComponentToken.Form, {
|
|
38
|
+
required: function required(name) {
|
|
39
|
+
return "".concat(name, " is required");
|
|
40
|
+
}
|
|
41
|
+
}));
|
|
37
42
|
|
|
38
43
|
exports.default = en_US;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import { ComponentToken } from '../../utils/component-token.mjs';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _en_US;
|
|
5
|
+
var en_US = (_en_US = {
|
|
5
6
|
locale: "en_US"
|
|
6
|
-
}, ComponentToken.Dialog, {
|
|
7
|
+
}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_en_US, ComponentToken.Dialog, {
|
|
7
8
|
confirm: "Confirm",
|
|
8
9
|
cancel: "Cancel"
|
|
9
10
|
}), ComponentToken.Empty, {
|
|
@@ -31,6 +32,10 @@ var en_US = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_def
|
|
|
31
32
|
confirm: "Confirm"
|
|
32
33
|
}), ComponentToken.Upload, {
|
|
33
34
|
upload: "Upload"
|
|
34
|
-
})
|
|
35
|
+
}), _defineProperty(_en_US, ComponentToken.Form, {
|
|
36
|
+
required: function required(name) {
|
|
37
|
+
return "".concat(name, " is required");
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
35
40
|
|
|
36
41
|
export { en_US as default };
|
|
@@ -3,9 +3,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3
3
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
4
|
var componentToken = require('../../utils/component-token.cjs');
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _zh_CN;
|
|
7
|
+
var zh_CN = (_zh_CN = {
|
|
7
8
|
locale: "zh_CN"
|
|
8
|
-
}, componentToken.ComponentToken.Dialog, {
|
|
9
|
+
}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_zh_CN, componentToken.ComponentToken.Dialog, {
|
|
9
10
|
confirm: "确认",
|
|
10
11
|
cancel: "取消"
|
|
11
12
|
}), componentToken.ComponentToken.Empty, {
|
|
@@ -33,6 +34,10 @@ var zh_CN = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_def
|
|
|
33
34
|
confirm: "确认"
|
|
34
35
|
}), componentToken.ComponentToken.Upload, {
|
|
35
36
|
upload: "上传"
|
|
36
|
-
})
|
|
37
|
+
}), _defineProperty(_zh_CN, componentToken.ComponentToken.Form, {
|
|
38
|
+
required: function required(name) {
|
|
39
|
+
return "".concat(name, " \u662F\u5FC5\u586B\u9879");
|
|
40
|
+
}
|
|
41
|
+
}));
|
|
37
42
|
|
|
38
43
|
exports.default = zh_CN;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import { ComponentToken } from '../../utils/component-token.mjs';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _zh_CN;
|
|
5
|
+
var zh_CN = (_zh_CN = {
|
|
5
6
|
locale: "zh_CN"
|
|
6
|
-
}, ComponentToken.Dialog, {
|
|
7
|
+
}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_zh_CN, ComponentToken.Dialog, {
|
|
7
8
|
confirm: "确认",
|
|
8
9
|
cancel: "取消"
|
|
9
10
|
}), ComponentToken.Empty, {
|
|
@@ -31,6 +32,10 @@ var zh_CN = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_def
|
|
|
31
32
|
confirm: "确认"
|
|
32
33
|
}), ComponentToken.Upload, {
|
|
33
34
|
upload: "上传"
|
|
34
|
-
})
|
|
35
|
+
}), _defineProperty(_zh_CN, ComponentToken.Form, {
|
|
36
|
+
required: function required(name) {
|
|
37
|
+
return "".concat(name, " \u662F\u5FC5\u586B\u9879");
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
35
40
|
|
|
36
41
|
export { zh_CN as default };
|
|
@@ -4,7 +4,7 @@ import { ButtonProps } from "./button";
|
|
|
4
4
|
* @description
|
|
5
5
|
* countdown props
|
|
6
6
|
*/
|
|
7
|
-
export type CountdownProps = Pick<ButtonProps, "children" | "disabled" | "variant" | "color" | "size" | "shape" | "ripple"> & ComponentProps & {
|
|
7
|
+
export type CountdownProps = Pick<ButtonProps, "children" | "disabled" | "variant" | "color" | "size" | "shape" | "ripple" | "onClick"> & ComponentProps & {
|
|
8
8
|
/**
|
|
9
9
|
* @description
|
|
10
10
|
* count total after every trigger
|
package/dist/types/locale.d.ts
CHANGED
package/dist/types/popover.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { DOMAttributes, ReactElement, ReactNode, RefAttributes } from "reac
|
|
|
2
2
|
import type { ComponentProps } from "musae/types/element";
|
|
3
3
|
import type { Placement } from "@floating-ui/dom";
|
|
4
4
|
export type ChildProps<T> = Pick<DOMAttributes<T>, "onMouseEnter" | "onMouseLeave" | "onPointerEnter" | "onPointerLeave" | "onClick" | "onContextMenu" | "onFocus" | "onBlur"> & RefAttributes<T>;
|
|
5
|
-
type TriggerBy = "hover" | "focus" | "click" | "contextMenu";
|
|
5
|
+
export type TriggerBy = "hover" | "focus" | "click" | "contextMenu";
|
|
6
6
|
/**
|
|
7
7
|
* @description
|
|
8
8
|
* popover props
|
|
@@ -13,7 +13,7 @@ export type PopoverProps<P extends ChildProps<T>, T extends HTMLElement> = Compo
|
|
|
13
13
|
* a trigger element.
|
|
14
14
|
* @requires
|
|
15
15
|
*/
|
|
16
|
-
children: ReactElement<P
|
|
16
|
+
children: ReactElement<P> | Exclude<ReactNode, ReactElement | Iterable<ReactNode>>;
|
|
17
17
|
/**
|
|
18
18
|
* @description
|
|
19
19
|
* title
|
|
@@ -65,4 +65,3 @@ export type PopoverRef = {
|
|
|
65
65
|
*/
|
|
66
66
|
close: () => Promise<void>;
|
|
67
67
|
};
|
|
68
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "musae",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"description": "musae-ui",
|
|
5
5
|
"author": "tutu@fantufantu.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"@dnd-kit/modifiers": "^7.0.0",
|
|
61
61
|
"@floating-ui/dom": "^1.6.11",
|
|
62
62
|
"@lexical/code": "^0.18.0",
|
|
63
|
+
"@lexical/headless": "^0.18.0",
|
|
63
64
|
"@lexical/link": "^0.18.0",
|
|
64
65
|
"@lexical/list": "^0.18.0",
|
|
65
66
|
"@lexical/markdown": "^0.18.0",
|
|
@@ -69,16 +70,16 @@
|
|
|
69
70
|
"@lexical/utils": "^0.18.0",
|
|
70
71
|
"@tanstack/react-table": "^8.20.5",
|
|
71
72
|
"dayjs": "^1.11.13",
|
|
72
|
-
"framer-motion": "^11.11.
|
|
73
|
+
"framer-motion": "^11.11.7",
|
|
73
74
|
"lexical": "^0.18.0",
|
|
74
75
|
"react-hook-form": "^7.53.0",
|
|
75
76
|
"rxjs": "^7.8.1"
|
|
76
77
|
},
|
|
77
78
|
"devDependencies": {
|
|
78
79
|
"@aiszlab/jarvis": "^1.0.2",
|
|
79
|
-
"@babel/core": "^7.25.
|
|
80
|
+
"@babel/core": "^7.25.8",
|
|
80
81
|
"@babel/plugin-transform-runtime": "^7.25.7",
|
|
81
|
-
"@babel/preset-env": "^7.25.
|
|
82
|
+
"@babel/preset-env": "^7.25.8",
|
|
82
83
|
"@babel/preset-react": "^7.25.7",
|
|
83
84
|
"@babel/preset-typescript": "^7.25.7",
|
|
84
85
|
"@rollup/plugin-babel": "^6.0.4",
|
|
@@ -91,9 +92,8 @@
|
|
|
91
92
|
"@testing-library/jest-dom": "^6.5.0",
|
|
92
93
|
"@testing-library/react": "^16.0.1",
|
|
93
94
|
"@testing-library/user-event": "^14.5.2",
|
|
94
|
-
"@types/dom-view-transitions": "^1.0.5",
|
|
95
95
|
"@types/jest": "^29.5.13",
|
|
96
|
-
"@types/node": "^22.7.
|
|
96
|
+
"@types/node": "^22.7.5",
|
|
97
97
|
"@types/react": "^18.3.11",
|
|
98
98
|
"@types/react-dom": "^18.3.0",
|
|
99
99
|
"babel-jest": "^29.7.0",
|
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
"react": "^18.3.1",
|
|
106
106
|
"react-dom": "^18.3.1",
|
|
107
107
|
"rollup": "^4.24.0",
|
|
108
|
-
"typescript": "^5.6.
|
|
109
|
-
"zx": "^8.1.
|
|
108
|
+
"typescript": "^5.6.3",
|
|
109
|
+
"zx": "^8.1.9"
|
|
110
110
|
},
|
|
111
111
|
"peerDependencies": {
|
|
112
112
|
"react": "^18",
|