musae 1.3.1-beta.6 → 1.3.1-beta.7
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/cascader/cascader.cjs +0 -1
- package/dist/components/cascader/cascader.mjs +0 -1
- package/dist/components/date-picker/date-picker.cjs +0 -1
- package/dist/components/date-picker/date-picker.mjs +0 -1
- package/dist/components/date-range-picker/date-range-picker.cjs +0 -1
- package/dist/components/date-range-picker/date-range-picker.mjs +0 -1
- package/dist/components/input/__test__/input-appearance.test.d.ts +1 -0
- package/dist/components/input/__test__/style-contract.test.d.ts +1 -0
- package/dist/components/input/hooks.cjs +0 -22
- package/dist/components/input/hooks.d.ts +1 -12
- package/dist/components/input/hooks.mjs +1 -22
- package/dist/components/input/input.cjs +13 -16
- package/dist/components/input/input.mjs +14 -17
- package/dist/components/input/styles.stylex.cjs +10 -0
- package/dist/components/input/styles.stylex.d.ts +8 -0
- package/dist/components/input/styles.stylex.mjs +10 -0
- package/dist/components/password-input/__test__/password-input.test.d.ts +1 -0
- package/dist/components/password-input/password-input.cjs +1 -0
- package/dist/components/password-input/password-input.mjs +1 -0
- package/dist/components/portal/__test__/portal.test.d.ts +1 -0
- package/dist/components/search/__test__/hooks.test.d.ts +1 -0
- package/dist/components/search/__test__/style-contract.test.d.ts +1 -0
- package/dist/components/search/bar.cjs +87 -0
- package/dist/components/search/bar.d.ts +19 -0
- package/dist/components/search/bar.mjs +83 -0
- package/dist/components/search/context.cjs +15 -0
- package/dist/components/search/context.d.ts +15 -0
- package/dist/components/search/context.mjs +15 -0
- package/dist/components/search/hooks.cjs +50 -0
- package/dist/components/search/hooks.d.ts +12 -0
- package/dist/components/search/hooks.mjs +47 -0
- package/dist/components/search/index.d.ts +1 -1
- package/dist/components/search/result-list.cjs +86 -0
- package/dist/components/search/result-list.d.ts +16 -0
- package/dist/components/search/result-list.mjs +82 -0
- package/dist/components/search/search.cjs +164 -44
- package/dist/components/search/search.d.ts +11 -1
- package/dist/components/search/search.mjs +166 -46
- package/dist/components/search/styles.cjs +160 -42
- package/dist/components/search/styles.d.ts +136 -41
- package/dist/components/search/styles.mjs +160 -42
- package/dist/components/search/view.cjs +109 -0
- package/dist/components/search/view.d.ts +23 -0
- package/dist/components/search/view.mjs +105 -0
- package/dist/components/select/selector.cjs +0 -1
- package/dist/components/select/selector.d.ts +1 -1
- package/dist/components/select/selector.mjs +0 -1
- package/dist/components/theme/tokens.stylex.cjs +8 -0
- package/dist/components/theme/tokens.stylex.d.ts +14 -0
- package/dist/components/theme/tokens.stylex.mjs +8 -1
- package/dist/components/time-picker/time-picker.cjs +0 -1
- package/dist/components/time-picker/time-picker.mjs +0 -1
- package/dist/index.d.ts +1 -0
- package/dist/styles.css +64 -56
- package/dist/types/input.d.ts +31 -28
- package/dist/types/search.d.ts +84 -1
- package/dist/types/select.d.ts +2 -2
- package/dist/utils/react.cjs +2 -2
- package/dist/utils/react.d.ts +2 -2
- package/dist/utils/react.mjs +2 -2
- package/package.json +1 -1
|
@@ -53,7 +53,6 @@ var DatePicker = function DatePicker(props) {
|
|
|
53
53
|
value: (_value$format = value === null || value === void 0 ? void 0 : value.format("YYYY-MM-DD")) !== null && _value$format !== void 0 ? _value$format : "",
|
|
54
54
|
onBlur: close,
|
|
55
55
|
onClick: toggle,
|
|
56
|
-
onInputorClick: toggle,
|
|
57
56
|
readOnly: true
|
|
58
57
|
});
|
|
59
58
|
});
|
|
@@ -49,7 +49,6 @@ var DatePicker = function DatePicker(props$1) {
|
|
|
49
49
|
value: (_value$format = value === null || value === void 0 ? void 0 : value.format("YYYY-MM-DD")) !== null && _value$format !== void 0 ? _value$format : "",
|
|
50
50
|
onBlur: close,
|
|
51
51
|
onClick: toggle,
|
|
52
|
-
onInputorClick: toggle,
|
|
53
52
|
readOnly: true
|
|
54
53
|
});
|
|
55
54
|
});
|
|
@@ -59,7 +59,6 @@ var DateRangePicker = function DateRangePicker(_ref) {
|
|
|
59
59
|
value: (_from$format = from === null || from === void 0 ? void 0 : from.format("YYYY-MM-DD")) !== null && _from$format !== void 0 ? _from$format : "",
|
|
60
60
|
onBlur: close,
|
|
61
61
|
onClick: toggle,
|
|
62
|
-
onInputorClick: toggle,
|
|
63
62
|
readOnly: true,
|
|
64
63
|
trailing: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(swapHoriz.default, {
|
|
65
64
|
className: classNames.separator
|
|
@@ -55,7 +55,6 @@ var DateRangePicker = function DateRangePicker(_ref) {
|
|
|
55
55
|
value: (_from$format = from === null || from === void 0 ? void 0 : from.format("YYYY-MM-DD")) !== null && _from$format !== void 0 ? _from$format : "",
|
|
56
56
|
onBlur: close,
|
|
57
57
|
onClick: toggle,
|
|
58
|
-
onInputorClick: toggle,
|
|
59
58
|
readOnly: true,
|
|
60
59
|
trailing: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IconSwapHoriz, {
|
|
61
60
|
className: classNames.separator
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var relax = require('@aiszlab/relax');
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* @description
|
|
@@ -38,26 +37,5 @@ var useInputEvents = function useInputEvents(_ref) {
|
|
|
38
37
|
click: click
|
|
39
38
|
};
|
|
40
39
|
};
|
|
41
|
-
/**
|
|
42
|
-
* @description
|
|
43
|
-
* inputor events
|
|
44
|
-
*/
|
|
45
|
-
var useInputorEvents = function useInputorEvents(_ref2) {
|
|
46
|
-
var inputRef = _ref2.inputRef,
|
|
47
|
-
onClick = _ref2.onClick;
|
|
48
|
-
// click
|
|
49
|
-
var click = React.useCallback(function (event) {
|
|
50
|
-
var _inputRef$current;
|
|
51
|
-
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
|
|
52
|
-
if (relax.isFunction(onClick)) {
|
|
53
|
-
event.stopPropagation();
|
|
54
|
-
onClick(event);
|
|
55
|
-
}
|
|
56
|
-
}, [inputRef, onClick]);
|
|
57
|
-
return {
|
|
58
|
-
click: click
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
40
|
|
|
62
41
|
exports.useInputEvents = useInputEvents;
|
|
63
|
-
exports.useInputorEvents = useInputorEvents;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { type ChangeEventHandler, type Dispatch, type FocusEventHandler, type MouseEventHandler, type SetStateAction
|
|
1
|
+
import { type ChangeEventHandler, type Dispatch, type FocusEventHandler, type MouseEventHandler, type SetStateAction } from "react";
|
|
2
2
|
import type { InputProps } from "../../types/input";
|
|
3
|
-
import type { Nullable } from "@aiszlab/relax/types";
|
|
4
3
|
/**
|
|
5
4
|
* @description
|
|
6
5
|
* use events for input
|
|
@@ -13,13 +12,3 @@ export declare const useInputEvents: ({ setValue, onBlur, onChange, onClick, onF
|
|
|
13
12
|
change: ChangeEventHandler<HTMLInputElement>;
|
|
14
13
|
click: MouseEventHandler<HTMLInputElement>;
|
|
15
14
|
};
|
|
16
|
-
/**
|
|
17
|
-
* @description
|
|
18
|
-
* inputor events
|
|
19
|
-
*/
|
|
20
|
-
export declare const useInputorEvents: ({ inputRef, onClick, }: {
|
|
21
|
-
inputRef: RefObject<Nullable<HTMLInputElement>>;
|
|
22
|
-
onClick?: InputProps["onInputorClick"];
|
|
23
|
-
}) => {
|
|
24
|
-
click: MouseEventHandler<HTMLDivElement>;
|
|
25
|
-
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
|
-
import { isFunction } from '@aiszlab/relax';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* @description
|
|
@@ -36,25 +35,5 @@ var useInputEvents = function useInputEvents(_ref) {
|
|
|
36
35
|
click: click
|
|
37
36
|
};
|
|
38
37
|
};
|
|
39
|
-
/**
|
|
40
|
-
* @description
|
|
41
|
-
* inputor events
|
|
42
|
-
*/
|
|
43
|
-
var useInputorEvents = function useInputorEvents(_ref2) {
|
|
44
|
-
var inputRef = _ref2.inputRef,
|
|
45
|
-
onClick = _ref2.onClick;
|
|
46
|
-
// click
|
|
47
|
-
var click = useCallback(function (event) {
|
|
48
|
-
var _inputRef$current;
|
|
49
|
-
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
|
|
50
|
-
if (isFunction(onClick)) {
|
|
51
|
-
event.stopPropagation();
|
|
52
|
-
onClick(event);
|
|
53
|
-
}
|
|
54
|
-
}, [inputRef, onClick]);
|
|
55
|
-
return {
|
|
56
|
-
click: click
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
38
|
|
|
60
|
-
export { useInputEvents
|
|
39
|
+
export { useInputEvents };
|
|
@@ -18,7 +18,7 @@ var context = require('./context.cjs');
|
|
|
18
18
|
var theme = require('../theme/theme.cjs');
|
|
19
19
|
var useThemeColorVars = require('../../hooks/use-theme-color-vars.cjs');
|
|
20
20
|
|
|
21
|
-
var _excluded = ["className", "style", "type", "invalid", "disabled", "maxLength", "value", "onBlur", "onChange", "onClick", "onFocus", "leading", "trailing", "
|
|
21
|
+
var _excluded = ["className", "style", "type", "variant", "shaped", "invalid", "disabled", "maxLength", "value", "onBlur", "onChange", "onClick", "onFocus", "leading", "trailing", "label"];
|
|
22
22
|
/**
|
|
23
23
|
* @author murukal
|
|
24
24
|
* @zh 输入组件
|
|
@@ -27,7 +27,10 @@ var _excluded = ["className", "style", "type", "invalid", "disabled", "maxLength
|
|
|
27
27
|
var Input = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
28
28
|
var className$1 = _ref.className,
|
|
29
29
|
style = _ref.style,
|
|
30
|
-
type = _ref.type
|
|
30
|
+
type = _ref.type;
|
|
31
|
+
_ref.variant;
|
|
32
|
+
var _ref$shaped = _ref.shaped,
|
|
33
|
+
shaped = _ref$shaped === void 0 ? false : _ref$shaped,
|
|
31
34
|
_ref$invalid = _ref.invalid,
|
|
32
35
|
invalid = _ref$invalid === void 0 ? false : _ref$invalid,
|
|
33
36
|
disabled = _ref.disabled,
|
|
@@ -39,17 +42,17 @@ var Input = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
39
42
|
onFocus = _ref.onFocus,
|
|
40
43
|
leading = _ref.leading,
|
|
41
44
|
trailing = _ref.trailing,
|
|
42
|
-
onInputorClick = _ref.onInputorClick,
|
|
43
45
|
label = _ref.label,
|
|
44
46
|
inputProps = _objectWithoutProperties(_ref, _excluded);
|
|
45
47
|
var inputorRef = React.useRef(null);
|
|
46
48
|
var inputRef = React.useRef(null);
|
|
47
49
|
var classNames = useClassNames.useClassNames(context.CLASS_NAMES);
|
|
48
50
|
var hasPlaceholder = !!inputProps.placeholder;
|
|
51
|
+
var hasLabel = !!label;
|
|
49
52
|
var _useIdentity = relax.useIdentity(),
|
|
50
53
|
_useIdentity2 = _slicedToArray(_useIdentity, 1),
|
|
51
54
|
id = _useIdentity2[0];
|
|
52
|
-
var _themeColorVars = useThemeColorVars.useThemeColorVars(["primary", "outline", "error", "on-surface-variant", ["on-surface", tokens_stylex.OPACITY.thickest], ["on-surface", tokens_stylex.OPACITY.medium], ["on-surface", tokens_stylex.OPACITY.thin]]);
|
|
55
|
+
var _themeColorVars = useThemeColorVars.useThemeColorVars(["primary", "outline", "error", "surface-container-high", "on-surface-variant", ["on-surface", tokens_stylex.OPACITY.thickest], ["on-surface", tokens_stylex.OPACITY.medium], ["on-surface", tokens_stylex.OPACITY.thin]]);
|
|
53
56
|
// controlled value
|
|
54
57
|
var _useControlledState = relax.useControlledState(valueInProps, {
|
|
55
58
|
defaultState: ""
|
|
@@ -90,11 +93,6 @@ var Input = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
90
93
|
onClick: onClick,
|
|
91
94
|
onFocus: onFocus
|
|
92
95
|
});
|
|
93
|
-
// inputor events
|
|
94
|
-
var inputorEvents = hooks.useInputorEvents({
|
|
95
|
-
inputRef: inputRef,
|
|
96
|
-
onClick: disabled ? undefined : onInputorClick
|
|
97
|
-
});
|
|
98
96
|
// is focused
|
|
99
97
|
var _useFocus = relax.useFocus({
|
|
100
98
|
onBlur: inputEvents.blur,
|
|
@@ -109,16 +107,15 @@ var Input = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
109
107
|
leading: stylex.props(styles_stylex.default.leading.base),
|
|
110
108
|
trailing: stylex.props(styles_stylex.default.trailing.base),
|
|
111
109
|
outline: stylex.props(styles_stylex.default.outline.base),
|
|
112
|
-
outlineLeading: stylex.props(styles_stylex.default.outlineLeading.base, disabled && styles_stylex.default.outlineLeading.disabled, invalid && styles_stylex.default.outlineLeading.invalid),
|
|
113
|
-
outlineNotch: stylex.props(styles_stylex.default.outlineNotch.base, theme.$body.small,
|
|
114
|
-
outlineTrailing: stylex.props(styles_stylex.default.outlineTrailing.base, disabled && styles_stylex.default.outlineTrailing.disabled, invalid && styles_stylex.default.outlineTrailing.invalid),
|
|
110
|
+
outlineLeading: stylex.props(styles_stylex.default.outlineLeading.base, disabled && styles_stylex.default.outlineLeading.disabled, invalid && styles_stylex.default.outlineLeading.invalid, shaped && styles_stylex.default.outlineLeading.shaped),
|
|
111
|
+
outlineNotch: stylex.props(styles_stylex.default.outlineNotch.base, theme.$body.small, hasLabel && styles_stylex.default.outlineNotch.withLabel, hasLabel && hasPlaceholder && styles_stylex.default.outlineNotch.withLabelAndPlaceholder, disabled && styles_stylex.default.outlineNotch.disabled, invalid && styles_stylex.default.outlineNotch.invalid),
|
|
112
|
+
outlineTrailing: stylex.props(styles_stylex.default.outlineTrailing.base, disabled && styles_stylex.default.outlineTrailing.disabled, invalid && styles_stylex.default.outlineTrailing.invalid, shaped && styles_stylex.default.outlineTrailing.shaped),
|
|
115
113
|
floatingLabel: stylex.props(styles_stylex.default.floatingLabel.base, hasPlaceholder && styles_stylex.default.floatingLabel.placeholder, disabled && styles_stylex.default.floatingLabel.disabled, invalid && styles_stylex.default.floatingLabel.invalid)
|
|
116
114
|
};
|
|
117
115
|
return /*#__PURE__*/React.createElement("div", _objectSpread({
|
|
118
116
|
ref: inputorRef,
|
|
119
117
|
className: className.stringify(classNames.inputor, _defineProperty(_defineProperty({}, classNames.focused, isFocused), classNames.invalid, !!invalid), className$1, styled.root.className),
|
|
120
|
-
style: _objectSpread(_objectSpread(_objectSpread({}, styled.root.style), style), _themeColorVars)
|
|
121
|
-
onClick: inputorEvents.click
|
|
118
|
+
style: _objectSpread(_objectSpread(_objectSpread({}, styled.root.style), style), _themeColorVars)
|
|
122
119
|
}, !disabled && {
|
|
123
120
|
tabIndex: -1
|
|
124
121
|
}), !!leading && (/*#__PURE__*/React.createElement("div", {
|
|
@@ -145,10 +142,10 @@ var Input = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
145
142
|
}), /*#__PURE__*/React.createElement("div", {
|
|
146
143
|
className: className.stringify(classNames.outlineNotch, styled.outlineNotch.className),
|
|
147
144
|
style: styled.outlineNotch.style
|
|
148
|
-
}, /*#__PURE__*/React.createElement("label", {
|
|
145
|
+
}, hasLabel && (/*#__PURE__*/React.createElement("label", {
|
|
149
146
|
htmlFor: id,
|
|
150
147
|
className: className.stringify(styled.floatingLabel.className)
|
|
151
|
-
}, label)), /*#__PURE__*/React.createElement("div", {
|
|
148
|
+
}, label))), /*#__PURE__*/React.createElement("div", {
|
|
152
149
|
className: className.stringify(classNames.outlineTrailing, styled.outlineTrailing.className),
|
|
153
150
|
style: styled.outlineTrailing.style
|
|
154
151
|
})), !!trailing && (/*#__PURE__*/React.createElement("div", {
|
|
@@ -4,7 +4,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
|
4
4
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
5
5
|
import styles, { textFieldMarker } from './styles.stylex.mjs';
|
|
6
6
|
import React, { forwardRef, useRef, useImperativeHandle } from 'react';
|
|
7
|
-
import { useInputEvents
|
|
7
|
+
import { useInputEvents } from './hooks.mjs';
|
|
8
8
|
import { useIdentity, useControlledState, useFocus } from '@aiszlab/relax';
|
|
9
9
|
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.19.0/node_modules/@stylexjs/stylex/lib/es/stylex.mjs';
|
|
10
10
|
import { OPACITY } from '../theme/tokens.stylex.mjs';
|
|
@@ -14,7 +14,7 @@ import { CLASS_NAMES } from './context.mjs';
|
|
|
14
14
|
import { $body } from '../theme/theme.mjs';
|
|
15
15
|
import { useThemeColorVars } from '../../hooks/use-theme-color-vars.mjs';
|
|
16
16
|
|
|
17
|
-
var _excluded = ["className", "style", "type", "invalid", "disabled", "maxLength", "value", "onBlur", "onChange", "onClick", "onFocus", "leading", "trailing", "
|
|
17
|
+
var _excluded = ["className", "style", "type", "variant", "shaped", "invalid", "disabled", "maxLength", "value", "onBlur", "onChange", "onClick", "onFocus", "leading", "trailing", "label"];
|
|
18
18
|
/**
|
|
19
19
|
* @author murukal
|
|
20
20
|
* @zh 输入组件
|
|
@@ -23,7 +23,10 @@ var _excluded = ["className", "style", "type", "invalid", "disabled", "maxLength
|
|
|
23
23
|
var Input = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
24
24
|
var className = _ref.className,
|
|
25
25
|
style = _ref.style,
|
|
26
|
-
type = _ref.type
|
|
26
|
+
type = _ref.type;
|
|
27
|
+
_ref.variant;
|
|
28
|
+
var _ref$shaped = _ref.shaped,
|
|
29
|
+
shaped = _ref$shaped === void 0 ? false : _ref$shaped,
|
|
27
30
|
_ref$invalid = _ref.invalid,
|
|
28
31
|
invalid = _ref$invalid === void 0 ? false : _ref$invalid,
|
|
29
32
|
disabled = _ref.disabled,
|
|
@@ -35,17 +38,17 @@ var Input = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
35
38
|
onFocus = _ref.onFocus,
|
|
36
39
|
leading = _ref.leading,
|
|
37
40
|
trailing = _ref.trailing,
|
|
38
|
-
onInputorClick = _ref.onInputorClick,
|
|
39
41
|
label = _ref.label,
|
|
40
42
|
inputProps = _objectWithoutProperties(_ref, _excluded);
|
|
41
43
|
var inputorRef = useRef(null);
|
|
42
44
|
var inputRef = useRef(null);
|
|
43
45
|
var classNames = useClassNames(CLASS_NAMES);
|
|
44
46
|
var hasPlaceholder = !!inputProps.placeholder;
|
|
47
|
+
var hasLabel = !!label;
|
|
45
48
|
var _useIdentity = useIdentity(),
|
|
46
49
|
_useIdentity2 = _slicedToArray(_useIdentity, 1),
|
|
47
50
|
id = _useIdentity2[0];
|
|
48
|
-
var _themeColorVars = useThemeColorVars(["primary", "outline", "error", "on-surface-variant", ["on-surface", OPACITY.thickest], ["on-surface", OPACITY.medium], ["on-surface", OPACITY.thin]]);
|
|
51
|
+
var _themeColorVars = useThemeColorVars(["primary", "outline", "error", "surface-container-high", "on-surface-variant", ["on-surface", OPACITY.thickest], ["on-surface", OPACITY.medium], ["on-surface", OPACITY.thin]]);
|
|
49
52
|
// controlled value
|
|
50
53
|
var _useControlledState = useControlledState(valueInProps, {
|
|
51
54
|
defaultState: ""
|
|
@@ -86,11 +89,6 @@ var Input = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
86
89
|
onClick: onClick,
|
|
87
90
|
onFocus: onFocus
|
|
88
91
|
});
|
|
89
|
-
// inputor events
|
|
90
|
-
var inputorEvents = useInputorEvents({
|
|
91
|
-
inputRef: inputRef,
|
|
92
|
-
onClick: disabled ? undefined : onInputorClick
|
|
93
|
-
});
|
|
94
92
|
// is focused
|
|
95
93
|
var _useFocus = useFocus({
|
|
96
94
|
onBlur: inputEvents.blur,
|
|
@@ -105,16 +103,15 @@ var Input = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
105
103
|
leading: props(styles.leading.base),
|
|
106
104
|
trailing: props(styles.trailing.base),
|
|
107
105
|
outline: props(styles.outline.base),
|
|
108
|
-
outlineLeading: props(styles.outlineLeading.base, disabled && styles.outlineLeading.disabled, invalid && styles.outlineLeading.invalid),
|
|
109
|
-
outlineNotch: props(styles.outlineNotch.base, $body.small,
|
|
110
|
-
outlineTrailing: props(styles.outlineTrailing.base, disabled && styles.outlineTrailing.disabled, invalid && styles.outlineTrailing.invalid),
|
|
106
|
+
outlineLeading: props(styles.outlineLeading.base, disabled && styles.outlineLeading.disabled, invalid && styles.outlineLeading.invalid, shaped && styles.outlineLeading.shaped),
|
|
107
|
+
outlineNotch: props(styles.outlineNotch.base, $body.small, hasLabel && styles.outlineNotch.withLabel, hasLabel && hasPlaceholder && styles.outlineNotch.withLabelAndPlaceholder, disabled && styles.outlineNotch.disabled, invalid && styles.outlineNotch.invalid),
|
|
108
|
+
outlineTrailing: props(styles.outlineTrailing.base, disabled && styles.outlineTrailing.disabled, invalid && styles.outlineTrailing.invalid, shaped && styles.outlineTrailing.shaped),
|
|
111
109
|
floatingLabel: props(styles.floatingLabel.base, hasPlaceholder && styles.floatingLabel.placeholder, disabled && styles.floatingLabel.disabled, invalid && styles.floatingLabel.invalid)
|
|
112
110
|
};
|
|
113
111
|
return /*#__PURE__*/React.createElement("div", _objectSpread({
|
|
114
112
|
ref: inputorRef,
|
|
115
113
|
className: stringify(classNames.inputor, _defineProperty(_defineProperty({}, classNames.focused, isFocused), classNames.invalid, !!invalid), className, styled.root.className),
|
|
116
|
-
style: _objectSpread(_objectSpread(_objectSpread({}, styled.root.style), style), _themeColorVars)
|
|
117
|
-
onClick: inputorEvents.click
|
|
114
|
+
style: _objectSpread(_objectSpread(_objectSpread({}, styled.root.style), style), _themeColorVars)
|
|
118
115
|
}, !disabled && {
|
|
119
116
|
tabIndex: -1
|
|
120
117
|
}), !!leading && (/*#__PURE__*/React.createElement("div", {
|
|
@@ -141,10 +138,10 @@ var Input = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
141
138
|
}), /*#__PURE__*/React.createElement("div", {
|
|
142
139
|
className: stringify(classNames.outlineNotch, styled.outlineNotch.className),
|
|
143
140
|
style: styled.outlineNotch.style
|
|
144
|
-
}, /*#__PURE__*/React.createElement("label", {
|
|
141
|
+
}, hasLabel && (/*#__PURE__*/React.createElement("label", {
|
|
145
142
|
htmlFor: id,
|
|
146
143
|
className: stringify(styled.floatingLabel.className)
|
|
147
|
-
}, label)), /*#__PURE__*/React.createElement("div", {
|
|
144
|
+
}, label))), /*#__PURE__*/React.createElement("div", {
|
|
148
145
|
className: stringify(classNames.outlineTrailing, styled.outlineTrailing.className),
|
|
149
146
|
style: styled.outlineTrailing.style
|
|
150
147
|
})), !!trailing && (/*#__PURE__*/React.createElement("div", {
|
|
@@ -113,6 +113,11 @@ var outlineLeading = {
|
|
|
113
113
|
kVAM5u: "musaex-1ofxpqo",
|
|
114
114
|
k6qhrQ: "musaex-7rzjjb",
|
|
115
115
|
$$css: true
|
|
116
|
+
},
|
|
117
|
+
shaped: {
|
|
118
|
+
krdFHd: "musaex-16hqlox",
|
|
119
|
+
kVL7Gh: "musaex-e8lclw",
|
|
120
|
+
$$css: true
|
|
116
121
|
}
|
|
117
122
|
};
|
|
118
123
|
var outlineTrailing = {
|
|
@@ -142,6 +147,11 @@ var outlineTrailing = {
|
|
|
142
147
|
kVAM5u: "musaex-1ofxpqo",
|
|
143
148
|
k6qhrQ: "musaex-7rzjjb",
|
|
144
149
|
$$css: true
|
|
150
|
+
},
|
|
151
|
+
shaped: {
|
|
152
|
+
kfmiAY: "musaex-ortkii",
|
|
153
|
+
kT0f0o: "musaex-1ogpvgu",
|
|
154
|
+
$$css: true
|
|
145
155
|
}
|
|
146
156
|
};
|
|
147
157
|
var outlineNotch = {
|
|
@@ -106,6 +106,10 @@ declare const styles: {
|
|
|
106
106
|
}>;
|
|
107
107
|
readonly borderColor: import("@stylexjs/stylex").StyleXClassNameFor<"borderColor", "var(--color-error)">;
|
|
108
108
|
}>;
|
|
109
|
+
readonly shaped: Readonly<{
|
|
110
|
+
readonly borderStartStartRadius: import("@stylexjs/stylex").StyleXClassNameFor<"borderStartStartRadius", string>;
|
|
111
|
+
readonly borderEndStartRadius: import("@stylexjs/stylex").StyleXClassNameFor<"borderEndStartRadius", string>;
|
|
112
|
+
}>;
|
|
109
113
|
}>;
|
|
110
114
|
outlineNotch: Readonly<{
|
|
111
115
|
readonly base: Readonly<{
|
|
@@ -174,6 +178,10 @@ declare const styles: {
|
|
|
174
178
|
}>;
|
|
175
179
|
readonly borderColor: import("@stylexjs/stylex").StyleXClassNameFor<"borderColor", "var(--color-error)">;
|
|
176
180
|
}>;
|
|
181
|
+
readonly shaped: Readonly<{
|
|
182
|
+
readonly borderStartEndRadius: import("@stylexjs/stylex").StyleXClassNameFor<"borderStartEndRadius", string>;
|
|
183
|
+
readonly borderEndEndRadius: import("@stylexjs/stylex").StyleXClassNameFor<"borderEndEndRadius", string>;
|
|
184
|
+
}>;
|
|
177
185
|
}>;
|
|
178
186
|
floatingLabel: Readonly<{
|
|
179
187
|
readonly base: Readonly<{
|
|
@@ -109,6 +109,11 @@ var outlineLeading = {
|
|
|
109
109
|
kVAM5u: "musaex-1ofxpqo",
|
|
110
110
|
k6qhrQ: "musaex-7rzjjb",
|
|
111
111
|
$$css: true
|
|
112
|
+
},
|
|
113
|
+
shaped: {
|
|
114
|
+
krdFHd: "musaex-16hqlox",
|
|
115
|
+
kVL7Gh: "musaex-e8lclw",
|
|
116
|
+
$$css: true
|
|
112
117
|
}
|
|
113
118
|
};
|
|
114
119
|
var outlineTrailing = {
|
|
@@ -138,6 +143,11 @@ var outlineTrailing = {
|
|
|
138
143
|
kVAM5u: "musaex-1ofxpqo",
|
|
139
144
|
k6qhrQ: "musaex-7rzjjb",
|
|
140
145
|
$$css: true
|
|
146
|
+
},
|
|
147
|
+
shaped: {
|
|
148
|
+
kfmiAY: "musaex-ortkii",
|
|
149
|
+
kT0f0o: "musaex-1ogpvgu",
|
|
150
|
+
$$css: true
|
|
141
151
|
}
|
|
142
152
|
};
|
|
143
153
|
var outlineNotch = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
@@ -39,6 +39,7 @@ var PasswordInput = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
39
39
|
ref: ref,
|
|
40
40
|
type: isVisible ? "text" : "password",
|
|
41
41
|
trailing: /*#__PURE__*/React.createElement(isVisible ? visibilityOff.default : visibility.default, _objectSpread({
|
|
42
|
+
role: "button",
|
|
42
43
|
onClick: toggle,
|
|
43
44
|
onMouseDown: function onMouseDown(event) {
|
|
44
45
|
return event.preventDefault();
|
|
@@ -35,6 +35,7 @@ var PasswordInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
35
35
|
ref: ref,
|
|
36
36
|
type: isVisible ? "text" : "password",
|
|
37
37
|
trailing: /*#__PURE__*/createElement(isVisible ? IconVisibilityOff : IconVisibility, _objectSpread({
|
|
38
|
+
role: "button",
|
|
38
39
|
onClick: toggle,
|
|
39
40
|
onMouseDown: function onMouseDown(event) {
|
|
40
41
|
return event.preventDefault();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var button = require('../button/button.cjs');
|
|
6
|
+
var search = require('../icon/icons/action/search.cjs');
|
|
7
|
+
var input = require('../input/input.cjs');
|
|
8
|
+
var theme = require('../theme/theme.cjs');
|
|
9
|
+
var stylex = require('../../node_modules/.pnpm/@stylexjs_stylex@0.19.0/node_modules/@stylexjs/stylex/lib/es/stylex.cjs');
|
|
10
|
+
var className = require('@aiszlab/relax/class-name');
|
|
11
|
+
var React = require('react');
|
|
12
|
+
var useClassNames = require('../../hooks/use-class-names.cjs');
|
|
13
|
+
var context = require('./context.cjs');
|
|
14
|
+
var styles = require('./styles.cjs');
|
|
15
|
+
var close = require('../icon/icons/navigation/close.cjs');
|
|
16
|
+
|
|
17
|
+
var SearchBar = function SearchBar(_ref) {
|
|
18
|
+
var clearable = _ref.clearable,
|
|
19
|
+
disabled = _ref.disabled,
|
|
20
|
+
leading = _ref.leading,
|
|
21
|
+
placeholder = _ref.placeholder,
|
|
22
|
+
searchButton = _ref.searchButton,
|
|
23
|
+
trailing = _ref.trailing,
|
|
24
|
+
inputRef = _ref.inputRef,
|
|
25
|
+
value = _ref.value,
|
|
26
|
+
onChange = _ref.onChange,
|
|
27
|
+
onClear = _ref.onClear,
|
|
28
|
+
onFocus = _ref.onFocus,
|
|
29
|
+
onKeyDown = _ref.onKeyDown,
|
|
30
|
+
onSearch = _ref.onSearch;
|
|
31
|
+
var classNames = useClassNames.useClassNames(context.CLASS_NAMES);
|
|
32
|
+
var hasValue = value.length > 0;
|
|
33
|
+
var styled = {
|
|
34
|
+
input: stylex.props(theme.$body.large),
|
|
35
|
+
leading: stylex.props(styles.default.leading.base),
|
|
36
|
+
trailing: stylex.props(styles.default.trailing.base),
|
|
37
|
+
clear: stylex.props(styles.default.clear.base),
|
|
38
|
+
searchButton: stylex.props(styles.default.searchButton.base)
|
|
39
|
+
};
|
|
40
|
+
var clearAction = hasValue && clearable && !disabled && (/*#__PURE__*/React.createElement("button", {
|
|
41
|
+
type: "button",
|
|
42
|
+
className: className.stringify(classNames.searchClear, styled.clear.className),
|
|
43
|
+
style: styled.clear.style,
|
|
44
|
+
onClick: function onClick(event) {
|
|
45
|
+
event.stopPropagation();
|
|
46
|
+
onClear();
|
|
47
|
+
},
|
|
48
|
+
"aria-label": "Clear search"
|
|
49
|
+
}, /*#__PURE__*/React.createElement(close.default, {
|
|
50
|
+
size: 24
|
|
51
|
+
})));
|
|
52
|
+
var searchButtonAction = searchButton && (/*#__PURE__*/React.createElement(button.Button, {
|
|
53
|
+
className: className.stringify(classNames.searchButton, styled.searchButton.className),
|
|
54
|
+
style: styled.searchButton.style,
|
|
55
|
+
onClick: function onClick(event) {
|
|
56
|
+
event.stopPropagation();
|
|
57
|
+
onSearch();
|
|
58
|
+
},
|
|
59
|
+
disabled: disabled
|
|
60
|
+
}, searchButton));
|
|
61
|
+
var hasConsumerTrailing = !!trailing;
|
|
62
|
+
var hasTrailing = !!clearAction || hasConsumerTrailing || !!searchButtonAction;
|
|
63
|
+
return /*#__PURE__*/React.createElement(input.default, {
|
|
64
|
+
ref: inputRef,
|
|
65
|
+
className: className.stringify(classNames.searchInput, styled.input.className),
|
|
66
|
+
variant: "filled",
|
|
67
|
+
shaped: true,
|
|
68
|
+
value: value,
|
|
69
|
+
placeholder: placeholder,
|
|
70
|
+
disabled: disabled,
|
|
71
|
+
onChange: onChange,
|
|
72
|
+
onFocus: onFocus,
|
|
73
|
+
onKeyDown: onKeyDown,
|
|
74
|
+
leading: /*#__PURE__*/React.createElement("span", {
|
|
75
|
+
className: className.stringify(classNames.searchLeading, styled.leading.className),
|
|
76
|
+
style: styled.leading.style
|
|
77
|
+
}, leading !== null && leading !== void 0 ? leading : /*#__PURE__*/React.createElement(search.default, {
|
|
78
|
+
size: 24
|
|
79
|
+
})),
|
|
80
|
+
trailing: hasTrailing ? (/*#__PURE__*/React.createElement("span", {
|
|
81
|
+
className: className.stringify(classNames.searchTrailing, styled.trailing.className),
|
|
82
|
+
style: styled.trailing.style
|
|
83
|
+
}, clearAction, trailing, searchButtonAction)) : undefined
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
exports.default = SearchBar;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { FocusEventHandler, KeyboardEventHandler, Ref } from "react";
|
|
3
|
+
import type { InputRef } from "../../types/input";
|
|
4
|
+
import type { SearchProps } from "../../types/search";
|
|
5
|
+
/**
|
|
6
|
+
* @zh 私有 Search Bar 属性
|
|
7
|
+
* @en Private Search Bar props
|
|
8
|
+
*/
|
|
9
|
+
export type SearchBarProps = Pick<SearchProps, "clearable" | "disabled" | "leading" | "placeholder" | "searchButton" | "trailing"> & {
|
|
10
|
+
inputRef: Ref<InputRef>;
|
|
11
|
+
value: string;
|
|
12
|
+
onChange: (value: string) => void;
|
|
13
|
+
onClear: () => void;
|
|
14
|
+
onFocus: FocusEventHandler<HTMLInputElement>;
|
|
15
|
+
onKeyDown: KeyboardEventHandler<HTMLInputElement>;
|
|
16
|
+
onSearch: () => void;
|
|
17
|
+
};
|
|
18
|
+
declare const SearchBar: ({ clearable, disabled, leading, placeholder, searchButton, trailing, inputRef, value, onChange, onClear, onFocus, onKeyDown, onSearch, }: SearchBarProps) => React.JSX.Element;
|
|
19
|
+
export default SearchBar;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Button } from '../button/button.mjs';
|
|
2
|
+
import IconSearch from '../icon/icons/action/search.mjs';
|
|
3
|
+
import Input from '../input/input.mjs';
|
|
4
|
+
import { $body } from '../theme/theme.mjs';
|
|
5
|
+
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.19.0/node_modules/@stylexjs/stylex/lib/es/stylex.mjs';
|
|
6
|
+
import { stringify } from '@aiszlab/relax/class-name';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { useClassNames } from '../../hooks/use-class-names.mjs';
|
|
9
|
+
import { CLASS_NAMES } from './context.mjs';
|
|
10
|
+
import styles from './styles.mjs';
|
|
11
|
+
import IconClose from '../icon/icons/navigation/close.mjs';
|
|
12
|
+
|
|
13
|
+
var SearchBar = function SearchBar(_ref) {
|
|
14
|
+
var clearable = _ref.clearable,
|
|
15
|
+
disabled = _ref.disabled,
|
|
16
|
+
leading = _ref.leading,
|
|
17
|
+
placeholder = _ref.placeholder,
|
|
18
|
+
searchButton = _ref.searchButton,
|
|
19
|
+
trailing = _ref.trailing,
|
|
20
|
+
inputRef = _ref.inputRef,
|
|
21
|
+
value = _ref.value,
|
|
22
|
+
onChange = _ref.onChange,
|
|
23
|
+
onClear = _ref.onClear,
|
|
24
|
+
onFocus = _ref.onFocus,
|
|
25
|
+
onKeyDown = _ref.onKeyDown,
|
|
26
|
+
onSearch = _ref.onSearch;
|
|
27
|
+
var classNames = useClassNames(CLASS_NAMES);
|
|
28
|
+
var hasValue = value.length > 0;
|
|
29
|
+
var styled = {
|
|
30
|
+
input: props($body.large),
|
|
31
|
+
leading: props(styles.leading.base),
|
|
32
|
+
trailing: props(styles.trailing.base),
|
|
33
|
+
clear: props(styles.clear.base),
|
|
34
|
+
searchButton: props(styles.searchButton.base)
|
|
35
|
+
};
|
|
36
|
+
var clearAction = hasValue && clearable && !disabled && (/*#__PURE__*/React.createElement("button", {
|
|
37
|
+
type: "button",
|
|
38
|
+
className: stringify(classNames.searchClear, styled.clear.className),
|
|
39
|
+
style: styled.clear.style,
|
|
40
|
+
onClick: function onClick(event) {
|
|
41
|
+
event.stopPropagation();
|
|
42
|
+
onClear();
|
|
43
|
+
},
|
|
44
|
+
"aria-label": "Clear search"
|
|
45
|
+
}, /*#__PURE__*/React.createElement(IconClose, {
|
|
46
|
+
size: 24
|
|
47
|
+
})));
|
|
48
|
+
var searchButtonAction = searchButton && (/*#__PURE__*/React.createElement(Button, {
|
|
49
|
+
className: stringify(classNames.searchButton, styled.searchButton.className),
|
|
50
|
+
style: styled.searchButton.style,
|
|
51
|
+
onClick: function onClick(event) {
|
|
52
|
+
event.stopPropagation();
|
|
53
|
+
onSearch();
|
|
54
|
+
},
|
|
55
|
+
disabled: disabled
|
|
56
|
+
}, searchButton));
|
|
57
|
+
var hasConsumerTrailing = !!trailing;
|
|
58
|
+
var hasTrailing = !!clearAction || hasConsumerTrailing || !!searchButtonAction;
|
|
59
|
+
return /*#__PURE__*/React.createElement(Input, {
|
|
60
|
+
ref: inputRef,
|
|
61
|
+
className: stringify(classNames.searchInput, styled.input.className),
|
|
62
|
+
variant: "filled",
|
|
63
|
+
shaped: true,
|
|
64
|
+
value: value,
|
|
65
|
+
placeholder: placeholder,
|
|
66
|
+
disabled: disabled,
|
|
67
|
+
onChange: onChange,
|
|
68
|
+
onFocus: onFocus,
|
|
69
|
+
onKeyDown: onKeyDown,
|
|
70
|
+
leading: /*#__PURE__*/React.createElement("span", {
|
|
71
|
+
className: stringify(classNames.searchLeading, styled.leading.className),
|
|
72
|
+
style: styled.leading.style
|
|
73
|
+
}, leading !== null && leading !== void 0 ? leading : /*#__PURE__*/React.createElement(IconSearch, {
|
|
74
|
+
size: 24
|
|
75
|
+
})),
|
|
76
|
+
trailing: hasTrailing ? (/*#__PURE__*/React.createElement("span", {
|
|
77
|
+
className: stringify(classNames.searchTrailing, styled.trailing.className),
|
|
78
|
+
style: styled.trailing.style
|
|
79
|
+
}, clearAction, trailing, searchButtonAction)) : undefined
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export { SearchBar as default };
|