@laser-ui/components 1.0.1 → 1.0.2
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/badge/Badge.js +1 -1
- package/date-picker/DatePicker.js +2 -2
- package/form/model/form-group.d.ts +1 -1
- package/package.json +2 -2
- package/root/vars.d.ts +1 -1
- package/textarea/Textarea.js +27 -44
- package/time-picker/TimePicker.js +2 -2
- package/LICENSE +0 -21
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
|
+
## [1.0.2](https://github.com/laser-ui/laser-ui/compare/v1.0.1...v1.0.2) (2024-07-20)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- **components:** fix `Textarea` auto rows ([df91d01](https://github.com/laser-ui/laser-ui/commit/df91d01000137f7a93f0f59407c9f1d738e67d85))
|
|
10
|
+
|
|
5
11
|
## [1.0.1](https://github.com/laser-ui/laser-ui/compare/v1.0.0...v1.0.1) (2024-07-12)
|
|
6
12
|
|
|
7
13
|
### Bug Fixes
|
package/badge/Badge.js
CHANGED
|
@@ -17,7 +17,7 @@ export const Badge = (props) => {
|
|
|
17
17
|
valueDown: false,
|
|
18
18
|
});
|
|
19
19
|
const show = showZero || valueProp > 0;
|
|
20
|
-
const value = show ? valueProp : (_a = dataRef.current.saveValue) !== null && _a !== void 0 ? _a : 0;
|
|
20
|
+
const value = show ? valueProp : ((_a = dataRef.current.saveValue) !== null && _a !== void 0 ? _a : 0);
|
|
21
21
|
dataRef.current.saveValue = value;
|
|
22
22
|
const nums = (value > max ? max : value)
|
|
23
23
|
.toString()
|
|
@@ -67,7 +67,7 @@ export const DatePicker = forwardRef((props, ref) => {
|
|
|
67
67
|
dataRef.current.latestFocused = 'end';
|
|
68
68
|
}
|
|
69
69
|
const [_value, _changeValue] = useControlled(defaultModel !== null && defaultModel !== void 0 ? defaultModel : null, model, onModelChange, (a, b) => deepCompareDate(a, b, format), formControl === null || formControl === void 0 ? void 0 : formControl.control);
|
|
70
|
-
let [valueLeft, valueRight = null] = range ? (_a = _value) !== null && _a !== void 0 ? _a : [null, null] : [_value, null];
|
|
70
|
+
let [valueLeft, valueRight = null] = range ? ((_a = _value) !== null && _a !== void 0 ? _a : [null, null]) : [_value, null];
|
|
71
71
|
if (range) {
|
|
72
72
|
if (isNull(_value)) {
|
|
73
73
|
[valueLeft, valueRight] = dataRef.current.rangeDate;
|
|
@@ -114,7 +114,7 @@ export const DatePicker = forwardRef((props, ref) => {
|
|
|
114
114
|
forceUpdate();
|
|
115
115
|
};
|
|
116
116
|
const [placeholderLeft = t('DatePicker', range ? 'Start date' : 'Select date'), placeholderRight = t('DatePicker', 'End date')] = range
|
|
117
|
-
? (_b = placeholder) !== null && _b !== void 0 ? _b : []
|
|
117
|
+
? ((_b = placeholder) !== null && _b !== void 0 ? _b : [])
|
|
118
118
|
: [placeholder];
|
|
119
119
|
const { size, disabled } = useScopedProps({ size: sizeProp, disabled: disabledProp || (formControl === null || formControl === void 0 ? void 0 : formControl.control.disabled) });
|
|
120
120
|
const maxZIndex = useMaxIndex(visible);
|
|
@@ -3,7 +3,7 @@ import { AbstractControl } from './abstract-control';
|
|
|
3
3
|
type Mutable<T> = {
|
|
4
4
|
-readonly [P in keyof T]: T[P];
|
|
5
5
|
};
|
|
6
|
-
type GetFormControlPropertyFromArray<T, A> = Mutable<A> extends [infer K, ...infer R] ? K extends keyof T ? GetFormControlPropertyFromArray<T[K], R> : any : T;
|
|
6
|
+
type GetFormControlPropertyFromArray<T, A> = Mutable<A> extends [infer K, ...infer R] ? (K extends keyof T ? GetFormControlPropertyFromArray<T[K], R> : any) : T;
|
|
7
7
|
type GetFormControlProperty<T, S> = S extends `${infer K}.${infer R}` ? K extends keyof T ? GetFormControlProperty<T[K], R> : any : S extends keyof T ? T[S] : any;
|
|
8
8
|
type GetFormGroupT<C extends FormGroup<any>> = C extends FormGroup<infer T> ? T : unknown;
|
|
9
9
|
type GetFormGroupValue<T extends {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@laser-ui/components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
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": "55a7ca519ecde41b605f3ec922e3b7d79eca8bae"
|
|
44
44
|
}
|
package/root/vars.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { Lang } from '../types';
|
|
|
4
4
|
import resources from '../resources.json';
|
|
5
5
|
export declare const Store: import("rcl-store").Store<{
|
|
6
6
|
dialogs: DialogInstance<any>[];
|
|
7
|
-
}
|
|
7
|
+
}>;
|
|
8
8
|
export declare const ROOT_DATA: {
|
|
9
9
|
clickEvent?: {
|
|
10
10
|
time: number;
|
package/textarea/Textarea.js
CHANGED
|
@@ -4,63 +4,46 @@ import { useForkRef } from '@laser-ui/hooks';
|
|
|
4
4
|
import { isFunction, isNumber, isUndefined } from 'lodash';
|
|
5
5
|
import { forwardRef, useEffect, useRef } from 'react';
|
|
6
6
|
import { CLASSES } from './vars';
|
|
7
|
-
import { useComponentProps, useControlled, useDesign,
|
|
7
|
+
import { useComponentProps, useControlled, useDesign, useScopedProps, useStyled } from '../hooks';
|
|
8
8
|
import { mergeCS } from '../utils';
|
|
9
9
|
export const Textarea = forwardRef((props, ref) => {
|
|
10
10
|
const _a = useComponentProps('Textarea', props), { styleOverrides, styleProvider, formControl, model, defaultModel, autoRows = false, resizable = true, showCount = false, size: sizeProp, onModelChange } = _a, restProps = __rest(_a, ["styleOverrides", "styleProvider", "formControl", "model", "defaultModel", "autoRows", "resizable", "showCount", "size", "onModelChange"]);
|
|
11
11
|
const styled = useStyled(CLASSES, { textarea: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.textarea }, styleOverrides);
|
|
12
|
-
const sheet = useJSS();
|
|
13
12
|
const textareaRef = useRef(null);
|
|
14
13
|
const combineTextareaRef = useForkRef(textareaRef, ref);
|
|
15
14
|
const [value, changeValue] = useControlled(defaultModel !== null && defaultModel !== void 0 ? defaultModel : '', model, onModelChange, undefined, formControl === null || formControl === void 0 ? void 0 : formControl.control);
|
|
16
15
|
const { size, disabled } = useScopedProps({ size: sizeProp, disabled: restProps.disabled || (formControl === null || formControl === void 0 ? void 0 : formControl.control.disabled) });
|
|
17
16
|
useEffect(() => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const n = Math.round(textareaRef.current.scrollHeight / lineHeight);
|
|
28
|
-
if (isNumber(restProps.rows)) {
|
|
29
|
-
textareaRef.current.rows = restProps.rows;
|
|
17
|
+
const textareaEl = textareaRef.current;
|
|
18
|
+
if (textareaEl && autoRows !== false) {
|
|
19
|
+
const cssText = textareaEl.style.cssText;
|
|
20
|
+
const rows = textareaEl.rows;
|
|
21
|
+
if (autoRows === true) {
|
|
22
|
+
textareaEl.style.cssText = cssText + 'overflow:hidden;height:0px;min-height:unset;';
|
|
23
|
+
const height = textareaEl.scrollHeight + (textareaEl.offsetHeight - textareaEl.clientHeight);
|
|
24
|
+
textareaEl.style.cssText = cssText;
|
|
25
|
+
textareaEl.style.height = height + 'px';
|
|
30
26
|
}
|
|
31
27
|
else {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
height = n * lineHeight;
|
|
41
|
-
overflow = 'hidden';
|
|
42
|
-
if (autoRows !== true) {
|
|
43
|
-
if (isNumber(autoRows.minRows)) {
|
|
44
|
-
minHeight = autoRows.minRows * lineHeight;
|
|
45
|
-
}
|
|
46
|
-
if (isNumber(autoRows.maxRows)) {
|
|
47
|
-
maxHeight = autoRows.maxRows * lineHeight;
|
|
48
|
-
if (autoRows.maxRows < n) {
|
|
49
|
-
overflow = undefined;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
28
|
+
textareaEl.style.cssText = cssText + 'overflow:hidden;height:0px;padding:0px;min-height:unset;';
|
|
29
|
+
const rowsHeight = textareaEl.scrollHeight + (textareaEl.offsetHeight - textareaEl.clientHeight);
|
|
30
|
+
textareaEl.rows = 1;
|
|
31
|
+
textareaEl.style.cssText = cssText + 'overflow:hidden;padding:0px;height:unset;min-height:unset;';
|
|
32
|
+
const rowHeight = textareaEl.clientHeight;
|
|
33
|
+
let n = Math.round(rowsHeight / rowHeight);
|
|
34
|
+
if (isNumber(autoRows.minRows) && n < autoRows.minRows) {
|
|
35
|
+
n = autoRows.minRows;
|
|
52
36
|
}
|
|
37
|
+
if (isNumber(autoRows.maxRows) && n > autoRows.maxRows) {
|
|
38
|
+
n = autoRows.maxRows;
|
|
39
|
+
}
|
|
40
|
+
textareaEl.rows = n;
|
|
41
|
+
textareaEl.style.cssText = cssText + 'height:unset;min-height:unset;';
|
|
53
42
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
height: isUndefined(height) ? undefined : height + outerSize,
|
|
59
|
-
overflow: isUndefined(overflow) ? undefined : 'hidden',
|
|
60
|
-
minHeight: isUndefined(minHeight) ? undefined : minHeight + outerSize,
|
|
61
|
-
maxHeight: isUndefined(maxHeight) ? undefined : maxHeight + outerSize,
|
|
62
|
-
});
|
|
63
|
-
textareaRef.current.classList.toggle(sheet.classes.rows, true);
|
|
43
|
+
return () => {
|
|
44
|
+
textareaEl.style.cssText = cssText;
|
|
45
|
+
textareaEl.rows = rows;
|
|
46
|
+
};
|
|
64
47
|
}
|
|
65
48
|
});
|
|
66
49
|
const designProps = useDesign({ form: formControl });
|
|
@@ -54,7 +54,7 @@ export const TimePicker = forwardRef((props, ref) => {
|
|
|
54
54
|
dataRef.current.latestFocused = 'end';
|
|
55
55
|
}
|
|
56
56
|
const [_value, _changeValue] = useControlled(defaultModel !== null && defaultModel !== void 0 ? defaultModel : null, model, onModelChange, (a, b) => deepCompareDate(a, b, format), formControl === null || formControl === void 0 ? void 0 : formControl.control);
|
|
57
|
-
let [valueLeft, valueRight = null] = range ? (_a = _value) !== null && _a !== void 0 ? _a : [null, null] : [_value, null];
|
|
57
|
+
let [valueLeft, valueRight = null] = range ? ((_a = _value) !== null && _a !== void 0 ? _a : [null, null]) : [_value, null];
|
|
58
58
|
if (range) {
|
|
59
59
|
if (isNull(_value)) {
|
|
60
60
|
[valueLeft, valueRight] = dataRef.current.rangeDate;
|
|
@@ -101,7 +101,7 @@ export const TimePicker = forwardRef((props, ref) => {
|
|
|
101
101
|
forceUpdate();
|
|
102
102
|
};
|
|
103
103
|
const [placeholderLeft = t('TimePicker', range ? 'Start time' : 'Select time'), placeholderRight = t('TimePicker', 'End time')] = range
|
|
104
|
-
? (_b = placeholder) !== null && _b !== void 0 ? _b : []
|
|
104
|
+
? ((_b = placeholder) !== null && _b !== void 0 ? _b : [])
|
|
105
105
|
: [placeholder];
|
|
106
106
|
const { size, disabled } = useScopedProps({ size: sizeProp, disabled: disabledProp || (formControl === null || formControl === void 0 ? void 0 : formControl.control.disabled) });
|
|
107
107
|
const maxZIndex = useMaxIndex(visible);
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 Xie Jay
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|