@laser-ui/components 0.6.5 → 0.6.6
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/CHANGELOG.md +6 -0
- package/base-input/BaseInput.d.ts +3 -0
- package/base-input/BaseInput.js +27 -0
- package/base-input/index.d.ts +2 -0
- package/base-input/index.js +1 -0
- package/base-input/types.d.ts +5 -0
- package/base-input/types.js +1 -0
- package/cascader/Cascader.js +5 -5
- package/date-picker/DatePicker.js +5 -4
- package/input/Input.js +3 -2
- package/input/InputNumber.js +15 -14
- package/package.json +2 -2
- package/select/Select.js +5 -5
- package/time-picker/TimePicker.js +5 -4
- package/tree-select/TreeSelect.js +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [0.6.6](https://github.com/laser-ui/laser-ui/compare/v0.6.5...v0.6.6) (2024-06-14)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- **components:** emit change after IME composition ends ([1f80404](https://github.com/laser-ui/laser-ui/commit/1f80404d037c74bd125ca0415c79f0542b6b4ce1))
|
|
10
|
+
|
|
5
11
|
## [0.6.5](https://github.com/laser-ui/laser-ui/compare/v0.6.4...v0.6.5) (2024-06-11)
|
|
6
12
|
|
|
7
13
|
### Bug Fixes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { isString } from 'lodash';
|
|
4
|
+
import { forwardRef, useState } from 'react';
|
|
5
|
+
export const BaseInput = forwardRef((props, ref) => {
|
|
6
|
+
const { value, onValueChange } = props, restProps = __rest(props, ["value", "onValueChange"]);
|
|
7
|
+
const [composing, setComposing] = useState();
|
|
8
|
+
return (_jsx("input", Object.assign({}, restProps, { ref: ref, value: isString(composing) ? composing : value, onCompositionStart: (e) => {
|
|
9
|
+
var _a;
|
|
10
|
+
(_a = restProps.onCompositionStart) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
11
|
+
setComposing(e.currentTarget.value);
|
|
12
|
+
}, onCompositionEnd: (e) => {
|
|
13
|
+
var _a;
|
|
14
|
+
(_a = restProps.onCompositionEnd) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
15
|
+
setComposing(undefined);
|
|
16
|
+
onValueChange(e.currentTarget.value);
|
|
17
|
+
}, onChange: (e) => {
|
|
18
|
+
var _a;
|
|
19
|
+
(_a = restProps.onChange) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
20
|
+
if (isString(composing)) {
|
|
21
|
+
setComposing(e.currentTarget.value);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
onValueChange(e.currentTarget.value);
|
|
25
|
+
}
|
|
26
|
+
} })));
|
|
27
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BaseInput } from './BaseInput';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/cascader/Cascader.js
CHANGED
|
@@ -11,6 +11,7 @@ import { createElement, forwardRef, useId, useImperativeHandle, useMemo, useRef,
|
|
|
11
11
|
import { CascaderPanel } from './internal/CascaderPanel';
|
|
12
12
|
import { CascaderSearchPanel } from './internal/CascaderSearchPanel';
|
|
13
13
|
import { CLASSES } from './vars';
|
|
14
|
+
import { BaseInput } from '../base-input';
|
|
14
15
|
import { Dropdown } from '../dropdown';
|
|
15
16
|
import { useComponentProps, useControlled, useDesign, useFocusVisible, useJSS, useLayout, useListenGlobalScrolling, useMaxIndex, useNamespace, useScopedProps, useStyled, useTranslation, } from '../hooks';
|
|
16
17
|
import { Icon } from '../icon';
|
|
@@ -217,7 +218,7 @@ function CascaderFC(props, ref) {
|
|
|
217
218
|
const scrollCallback = useRef();
|
|
218
219
|
const inputable = searchable && visible;
|
|
219
220
|
const clearable = clearableProp && hasSelected && !visible && !loading && !disabled;
|
|
220
|
-
const inputNode = focusVisibleWrapper(createElement(searchable ?
|
|
221
|
+
const inputNode = focusVisibleWrapper(createElement(searchable ? BaseInput : 'div', Object.assign(Object.assign(Object.assign(Object.assign({}, mergeCS(styled('cascader__search'), {
|
|
221
222
|
style: {
|
|
222
223
|
opacity: inputable ? undefined : 0,
|
|
223
224
|
zIndex: inputable ? undefined : -1,
|
|
@@ -338,16 +339,15 @@ function CascaderFC(props, ref) {
|
|
|
338
339
|
}
|
|
339
340
|
}
|
|
340
341
|
}
|
|
341
|
-
}, onChange: (e) => {
|
|
342
|
-
if (searchable) {
|
|
343
|
-
changeSearchValue(e.currentTarget.value);
|
|
344
|
-
}
|
|
345
342
|
} }), searchable
|
|
346
343
|
? {
|
|
347
344
|
type: 'text',
|
|
348
345
|
value: searchValue,
|
|
349
346
|
autoComplete: 'off',
|
|
350
347
|
disabled,
|
|
348
|
+
onValueChange: (val) => {
|
|
349
|
+
changeSearchValue(val);
|
|
350
|
+
},
|
|
351
351
|
}
|
|
352
352
|
: {})));
|
|
353
353
|
const [selectedNode, suffixNode, selectedLabel] = (() => {
|
|
@@ -9,6 +9,7 @@ import { isArray, isBoolean, isNull, isUndefined } from 'lodash';
|
|
|
9
9
|
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
10
10
|
import { DatePickerPanel } from './internal/DatePickerPanel';
|
|
11
11
|
import { CLASSES } from './vars';
|
|
12
|
+
import { BaseInput } from '../base-input';
|
|
12
13
|
import { Button } from '../button';
|
|
13
14
|
import dayjs from '../dayjs';
|
|
14
15
|
import { useComponentProps, useControlled, useDesign, useJSS, useLayout, useListenGlobalScrolling, useMaxIndex, useNamespace, useScopedProps, useStyled, useTranslation, } from '../hooks';
|
|
@@ -203,11 +204,11 @@ export const DatePicker = forwardRef((props, ref) => {
|
|
|
203
204
|
const index = isLeft ? 0 : 1;
|
|
204
205
|
const value = isLeft ? valueLeft : valueRight;
|
|
205
206
|
const render = inputRender === null || inputRender === void 0 ? void 0 : inputRender[index];
|
|
206
|
-
const node = (_jsx(
|
|
207
|
+
const node = (_jsx(BaseInput, Object.assign({}, styled('date-picker__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { ref: isLeft ? combineInputLeftRef : combineInputRightRef, type: "text", autoComplete: "off", value: inputValue[index], size: 22, placeholder: isLeft ? placeholderLeft : placeholderRight, disabled: disabled, onValueChange: (val) => {
|
|
207
208
|
forceUpdate();
|
|
208
|
-
dataRef.current.inputValue[index] =
|
|
209
|
-
if (dayjs(
|
|
210
|
-
const date = dayjs(
|
|
209
|
+
dataRef.current.inputValue[index] = val;
|
|
210
|
+
if (dayjs(val, format, true).isValid()) {
|
|
211
|
+
const date = dayjs(val, format).toDate();
|
|
211
212
|
changeValue(date);
|
|
212
213
|
updatePanel(date);
|
|
213
214
|
}
|
package/input/Input.js
CHANGED
|
@@ -8,6 +8,7 @@ import VisibilityOffOutlined from '@material-design-icons/svg/outlined/visibilit
|
|
|
8
8
|
import { useRef } from 'react';
|
|
9
9
|
import { InputNumber } from './InputNumber';
|
|
10
10
|
import { CLASSES } from './vars';
|
|
11
|
+
import { BaseInput } from '../base-input';
|
|
11
12
|
import { useComponentProps, useControlled, useDesign, useScopedProps, useStyled, useTranslation } from '../hooks';
|
|
12
13
|
import { Icon } from '../icon';
|
|
13
14
|
import { mergeCS } from '../utils';
|
|
@@ -26,8 +27,8 @@ export const Input = (props) => {
|
|
|
26
27
|
}
|
|
27
28
|
};
|
|
28
29
|
const designProps = useDesign({ compose: { disabled }, form: formControl });
|
|
29
|
-
const inputNode = (_jsx(
|
|
30
|
-
changeValue(
|
|
30
|
+
const inputNode = (_jsx(BaseInput, Object.assign({}, styled('input__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { ref: combineInputRef, value: value, type: type === 'password' ? (password ? 'password' : 'text') : type, placeholder: placeholder, disabled: disabled, onValueChange: (val) => {
|
|
31
|
+
changeValue(val);
|
|
31
32
|
} })));
|
|
32
33
|
return (_jsxs("div", Object.assign({}, restProps, mergeCS(styled('input', `input--${size}`, {
|
|
33
34
|
'input.is-disabled': disabled,
|
package/input/InputNumber.js
CHANGED
|
@@ -8,6 +8,7 @@ import KeyboardArrowUpOutlined from '@material-design-icons/svg/outlined/keyboar
|
|
|
8
8
|
import { isNull, isUndefined } from 'lodash';
|
|
9
9
|
import { useRef } from 'react';
|
|
10
10
|
import { CLASSES } from './vars';
|
|
11
|
+
import { BaseInput } from '../base-input';
|
|
11
12
|
import { useComponentProps, useControlled, useDesign, useScopedProps, useStyled, useTranslation } from '../hooks';
|
|
12
13
|
import { Icon } from '../icon';
|
|
13
14
|
import { mergeCS } from '../utils';
|
|
@@ -68,16 +69,16 @@ export function InputNumber(props) {
|
|
|
68
69
|
}
|
|
69
70
|
};
|
|
70
71
|
const designProps = useDesign({ compose: { disabled }, form: formControl });
|
|
71
|
-
const inputNode = (_jsx(
|
|
72
|
+
const inputNode = (_jsx(BaseInput, Object.assign({}, styled('input__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { ref: combineInputRef, value: inputValue, max: max, min: min, step: step, type: "number", placeholder: placeholder, disabled: disabled, onValueChange: (val) => {
|
|
72
73
|
forceUpdate();
|
|
73
|
-
dataRef.current.inputValue =
|
|
74
|
-
if (
|
|
74
|
+
dataRef.current.inputValue = val;
|
|
75
|
+
if (val.length === 0) {
|
|
75
76
|
changeValue(null);
|
|
76
77
|
}
|
|
77
78
|
else {
|
|
78
|
-
const
|
|
79
|
-
if ((isUndefined(max) ||
|
|
80
|
-
changeValue(
|
|
79
|
+
const num = Number(val);
|
|
80
|
+
if ((isUndefined(max) || num <= max) && (isUndefined(min) || num >= min) && (!integer || Number.isInteger(num))) {
|
|
81
|
+
changeValue(num);
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
}, onFocus: () => {
|
|
@@ -89,17 +90,17 @@ export function InputNumber(props) {
|
|
|
89
90
|
changeValue(null);
|
|
90
91
|
}
|
|
91
92
|
else {
|
|
92
|
-
let
|
|
93
|
-
if (!isUndefined(max) &&
|
|
94
|
-
|
|
93
|
+
let num = Number(inputValue);
|
|
94
|
+
if (!isUndefined(max) && num > max) {
|
|
95
|
+
num = max;
|
|
95
96
|
}
|
|
96
|
-
if (!isUndefined(min) &&
|
|
97
|
-
|
|
97
|
+
if (!isUndefined(min) && num < min) {
|
|
98
|
+
num = min;
|
|
98
99
|
}
|
|
99
|
-
if (integer && !Number.isInteger(
|
|
100
|
-
|
|
100
|
+
if (integer && !Number.isInteger(num)) {
|
|
101
|
+
num = Math.round(num);
|
|
101
102
|
}
|
|
102
|
-
changeValue(
|
|
103
|
+
changeValue(num);
|
|
103
104
|
}
|
|
104
105
|
} })));
|
|
105
106
|
return (_jsxs("div", Object.assign({}, restProps, mergeCS(styled('input', `input--${size}`, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@laser-ui/components",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
4
4
|
"description": "React components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"access": "public",
|
|
41
41
|
"directory": "../../dist/libs/components"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "406794ec6f5881cb567aa6c702beb109998ea997"
|
|
44
44
|
}
|
package/select/Select.js
CHANGED
|
@@ -11,6 +11,7 @@ import SearchOutlined from '@material-design-icons/svg/outlined/search.svg?react
|
|
|
11
11
|
import { isNull, isNumber, isUndefined } from 'lodash';
|
|
12
12
|
import { createElement, forwardRef, useCallback, useId, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
13
13
|
import { CLASSES, IS_CREATED } from './vars';
|
|
14
|
+
import { BaseInput } from '../base-input';
|
|
14
15
|
import { Checkbox } from '../checkbox';
|
|
15
16
|
import { Dropdown } from '../dropdown';
|
|
16
17
|
import { Empty } from '../empty';
|
|
@@ -232,7 +233,7 @@ function SelectFC(props, ref) {
|
|
|
232
233
|
const scrollCallback = useRef();
|
|
233
234
|
const inputable = searchable && visible;
|
|
234
235
|
const clearable = clearableProp && hasSelected && !visible && !loading && !disabled;
|
|
235
|
-
const inputNode = focusVisibleWrapper(createElement(searchable ?
|
|
236
|
+
const inputNode = focusVisibleWrapper(createElement(searchable ? BaseInput : 'div', Object.assign(Object.assign(Object.assign(Object.assign({}, mergeCS(styled('select__search'), {
|
|
236
237
|
style: {
|
|
237
238
|
opacity: inputable ? undefined : 0,
|
|
238
239
|
zIndex: inputable ? undefined : -1,
|
|
@@ -352,16 +353,15 @@ function SelectFC(props, ref) {
|
|
|
352
353
|
}
|
|
353
354
|
}
|
|
354
355
|
}
|
|
355
|
-
}, onChange: (e) => {
|
|
356
|
-
if (searchable) {
|
|
357
|
-
changeSearchValue(e.currentTarget.value);
|
|
358
|
-
}
|
|
359
356
|
} }), searchable
|
|
360
357
|
? {
|
|
361
358
|
type: 'text',
|
|
362
359
|
value: searchValue,
|
|
363
360
|
autoComplete: 'off',
|
|
364
361
|
disabled,
|
|
362
|
+
onValueChange: (val) => {
|
|
363
|
+
changeSearchValue(val);
|
|
364
|
+
},
|
|
365
365
|
}
|
|
366
366
|
: {})));
|
|
367
367
|
const [selectedNode, suffixNode, selectedLabel] = (() => {
|
|
@@ -9,6 +9,7 @@ import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
|
9
9
|
import { TimePickerPanel } from './internal/TimePickerPanel';
|
|
10
10
|
import { deepCompareDate, orderTime } from './utils';
|
|
11
11
|
import { CLASSES } from './vars';
|
|
12
|
+
import { BaseInput } from '../base-input';
|
|
12
13
|
import { Button } from '../button';
|
|
13
14
|
import dayjs from '../dayjs';
|
|
14
15
|
import { useComponentProps, useControlled, useDesign, useJSS, useLayout, useListenGlobalScrolling, useMaxIndex, useNamespace, useScopedProps, useStyled, useTranslation, } from '../hooks';
|
|
@@ -191,12 +192,12 @@ export const TimePicker = forwardRef((props, ref) => {
|
|
|
191
192
|
const index = isLeft ? 0 : 1;
|
|
192
193
|
const value = isLeft ? valueLeft : valueRight;
|
|
193
194
|
const render = inputRender === null || inputRender === void 0 ? void 0 : inputRender[index];
|
|
194
|
-
const node = (_jsx(
|
|
195
|
+
const node = (_jsx(BaseInput, Object.assign({}, styled('time-picker__input'), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria, { ref: isLeft ? combineInputLeftRef : combineInputRightRef, type: "text", autoComplete: "off", value: inputValue[index], size: 10, placeholder: isLeft ? placeholderLeft : placeholderRight, disabled: disabled, onValueChange: (val) => {
|
|
195
196
|
var _a;
|
|
196
197
|
forceUpdate();
|
|
197
|
-
dataRef.current.inputValue[index] =
|
|
198
|
-
if (dayjs(
|
|
199
|
-
const date = dayjs(
|
|
198
|
+
dataRef.current.inputValue[index] = val;
|
|
199
|
+
if (dayjs(val, format, true).isValid()) {
|
|
200
|
+
const date = dayjs(val, format).toDate();
|
|
200
201
|
changeValue(date);
|
|
201
202
|
(_a = panelRef.current) === null || _a === void 0 ? void 0 : _a.call(panelRef, date);
|
|
202
203
|
}
|
|
@@ -10,6 +10,7 @@ import { isNull, isNumber, isUndefined } from 'lodash';
|
|
|
10
10
|
import { createElement, forwardRef, useId, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
11
11
|
import { TreeSelectSearchPanel } from './internal/TreeSelectSearchPanel';
|
|
12
12
|
import { CLASSES } from './vars';
|
|
13
|
+
import { BaseInput } from '../base-input';
|
|
13
14
|
import { Dropdown } from '../dropdown';
|
|
14
15
|
import { useComponentProps, useControlled, useDesign, useFocusVisible, useJSS, useLayout, useListenGlobalScrolling, useMaxIndex, useNamespace, useScopedProps, useStyled, useTranslation, } from '../hooks';
|
|
15
16
|
import { Icon } from '../icon';
|
|
@@ -237,7 +238,7 @@ function TreeSelectFC(props, ref) {
|
|
|
237
238
|
const scrollCallback = useRef();
|
|
238
239
|
const inputable = searchable && visible;
|
|
239
240
|
const clearable = clearableProp && hasSelected && !visible && !loading && !disabled;
|
|
240
|
-
const inputNode = focusVisibleWrapper(createElement(searchable ?
|
|
241
|
+
const inputNode = focusVisibleWrapper(createElement(searchable ? BaseInput : 'div', Object.assign(Object.assign(Object.assign(Object.assign({}, mergeCS(styled('tree-select__search'), {
|
|
241
242
|
style: {
|
|
242
243
|
opacity: inputable ? undefined : 0,
|
|
243
244
|
zIndex: inputable ? undefined : -1,
|
|
@@ -358,16 +359,15 @@ function TreeSelectFC(props, ref) {
|
|
|
358
359
|
}
|
|
359
360
|
}
|
|
360
361
|
}
|
|
361
|
-
}, onChange: (e) => {
|
|
362
|
-
if (searchable) {
|
|
363
|
-
changeSearchValue(e.currentTarget.value);
|
|
364
|
-
}
|
|
365
362
|
} }), searchable
|
|
366
363
|
? {
|
|
367
364
|
type: 'text',
|
|
368
365
|
value: searchValue,
|
|
369
366
|
autoComplete: 'off',
|
|
370
367
|
disabled,
|
|
368
|
+
onValueChange: (val) => {
|
|
369
|
+
changeSearchValue(val);
|
|
370
|
+
},
|
|
371
371
|
}
|
|
372
372
|
: {})));
|
|
373
373
|
const [selectedNode, suffixNode, selectedLabel] = (() => {
|