@laser-ui/components 0.1.4 → 0.1.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 +10 -0
- package/form/Form.js +10 -1
- package/form/model/abstract-control.d.ts +1 -1
- package/form/model/abstract-control.js +18 -16
- package/internal/popup/Popup.js +9 -6
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
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.1.6](https://github.com/laser-ui/laser-ui/compare/v0.1.5...v0.1.6) (2023-10-13)
|
|
6
|
+
|
|
7
|
+
**Note:** Version bump only for package @laser-ui/components
|
|
8
|
+
|
|
9
|
+
## [0.1.5](https://github.com/laser-ui/laser-ui/compare/v0.1.4...v0.1.5) (2023-10-09)
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
- **components:** fix form `enter` ([ebbe78b](https://github.com/laser-ui/laser-ui/commit/ebbe78b2afc3ee3f257847f143ee23fe12fd17fa))
|
|
14
|
+
|
|
5
15
|
## [0.1.4](https://github.com/laser-ui/laser-ui/compare/v0.1.3...v0.1.4) (2023-09-18)
|
|
6
16
|
|
|
7
17
|
### Bug Fixes
|
package/form/Form.js
CHANGED
|
@@ -23,7 +23,16 @@ export const Form = (props) => {
|
|
|
23
23
|
return (_jsx("form", Object.assign({}, restProps, mergeCS(styled('form', `form--${size}`), {
|
|
24
24
|
className: restProps.className,
|
|
25
25
|
style: restProps.style,
|
|
26
|
-
}), { ref: formRef,
|
|
26
|
+
}), { ref: formRef, onSubmit: (e) => {
|
|
27
|
+
var _a;
|
|
28
|
+
(_a = restProps.onSubmit) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
29
|
+
e.preventDefault();
|
|
30
|
+
e.stopPropagation();
|
|
31
|
+
}, onReset: (e) => {
|
|
32
|
+
var _a;
|
|
33
|
+
(_a = restProps.onReset) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
}, children: _jsx(ConfigProvider, { context: { componentSize: size }, children: _jsx(FormContext.Provider, { value: {
|
|
27
36
|
vertical,
|
|
28
37
|
labelWidth: labelWidth !== null && labelWidth !== void 0 ? labelWidth : (vertical ? undefined : 'auto'),
|
|
29
38
|
labelColon: labelColon !== null && labelColon !== void 0 ? labelColon : !vertical,
|
|
@@ -5,7 +5,7 @@ export declare abstract class AbstractControl<V = any> {
|
|
|
5
5
|
private _pristine;
|
|
6
6
|
private _errors;
|
|
7
7
|
private _hasOwnPendingAsyncValidator;
|
|
8
|
-
private
|
|
8
|
+
private _abortAsyncValidation?;
|
|
9
9
|
private _composedValidatorFn;
|
|
10
10
|
private _composedAsyncValidatorFn;
|
|
11
11
|
private _rawValidators;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { isArray } from 'lodash';
|
|
2
|
-
import { forkJoin, from } from 'rxjs';
|
|
3
2
|
import { DISABLED, INVALID, PENDING, VALID } from './vars';
|
|
4
3
|
function mergeErrors(arrayOfErrors) {
|
|
5
4
|
const res = {};
|
|
@@ -26,11 +25,8 @@ function composeAsyncValidators(validators) {
|
|
|
26
25
|
}
|
|
27
26
|
return function (control) {
|
|
28
27
|
return new Promise((resolve) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
next: (errors) => {
|
|
32
|
-
resolve(mergeErrors(errors));
|
|
33
|
-
},
|
|
28
|
+
Promise.all(presentValidators.map((fn) => fn(control))).then((errors) => {
|
|
29
|
+
resolve(mergeErrors(errors));
|
|
34
30
|
});
|
|
35
31
|
});
|
|
36
32
|
};
|
|
@@ -84,7 +80,7 @@ export class AbstractControl {
|
|
|
84
80
|
writable: true,
|
|
85
81
|
value: false
|
|
86
82
|
});
|
|
87
|
-
Object.defineProperty(this, "
|
|
83
|
+
Object.defineProperty(this, "_abortAsyncValidation", {
|
|
88
84
|
enumerable: true,
|
|
89
85
|
configurable: true,
|
|
90
86
|
writable: true,
|
|
@@ -312,8 +308,8 @@ export class AbstractControl {
|
|
|
312
308
|
return this.validator ? this.validator(this) : null;
|
|
313
309
|
}
|
|
314
310
|
_cancelExistingSubscription() {
|
|
315
|
-
if (this.
|
|
316
|
-
this.
|
|
311
|
+
if (this._abortAsyncValidation) {
|
|
312
|
+
this._abortAsyncValidation();
|
|
317
313
|
this._hasOwnPendingAsyncValidator = false;
|
|
318
314
|
}
|
|
319
315
|
}
|
|
@@ -321,14 +317,20 @@ export class AbstractControl {
|
|
|
321
317
|
if (this.asyncValidator) {
|
|
322
318
|
this._status = PENDING;
|
|
323
319
|
this._hasOwnPendingAsyncValidator = true;
|
|
324
|
-
|
|
320
|
+
let abort = false;
|
|
321
|
+
this._abortAsyncValidation = () => {
|
|
322
|
+
abort = true;
|
|
323
|
+
};
|
|
324
|
+
this.asyncValidator(this).then((errors) => {
|
|
325
325
|
var _a, _b;
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
326
|
+
if (!abort) {
|
|
327
|
+
this._hasOwnPendingAsyncValidator = false;
|
|
328
|
+
// This will trigger the recalculation of the validation status, which depends on
|
|
329
|
+
// the state of the asynchronous validation (whether it is in progress or not). So, it is
|
|
330
|
+
// necessary that we have updated the `_hasOwnPendingAsyncValidator` boolean flag first.
|
|
331
|
+
this.setErrors(errors);
|
|
332
|
+
(_b = (_a = this.root)._emitChange) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
333
|
+
}
|
|
332
334
|
});
|
|
333
335
|
}
|
|
334
336
|
}
|
package/internal/popup/Popup.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useAsync, useEvent, useRefExtra, useResize } from '@laser-ui/hooks';
|
|
2
2
|
import { isUndefined } from 'lodash';
|
|
3
3
|
import { cloneElement, useEffect, useRef } from 'react';
|
|
4
|
-
import { fromEvent } from 'rxjs';
|
|
5
4
|
import { useLayout, useListenGlobalScrolling } from '../../hooks';
|
|
6
5
|
export function Popup(props) {
|
|
7
6
|
const { children, visible: visibleProp, trigger, disabled = false, mouseEnterDelay = 150, mouseLeaveDelay = 200, updatePosition, onVisibleChange, } = props;
|
|
@@ -46,13 +45,17 @@ export function Popup(props) {
|
|
|
46
45
|
const listenGlobalScrolling = useListenGlobalScrolling(updatePosition.fn, disabled || !visibleProp);
|
|
47
46
|
useEffect(() => {
|
|
48
47
|
if (!disabled && visibleProp && !listenGlobalScrolling) {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
const els = [pageScrollRef, ...updatePosition.containerRefs].map((ref) => ref.current).filter((el) => el);
|
|
49
|
+
const listener = () => {
|
|
50
|
+
updatePosition.fn();
|
|
51
|
+
};
|
|
52
|
+
els.forEach((el) => {
|
|
53
|
+
el.addEventListener('scroll', listener, { passive: true });
|
|
53
54
|
});
|
|
54
55
|
return () => {
|
|
55
|
-
|
|
56
|
+
els.forEach((el) => {
|
|
57
|
+
el.removeEventListener('scroll', listener);
|
|
58
|
+
});
|
|
56
59
|
};
|
|
57
60
|
}
|
|
58
61
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@laser-ui/components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "React components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui",
|
|
@@ -26,24 +26,24 @@
|
|
|
26
26
|
"module": "./index.js",
|
|
27
27
|
"types": "./index.d.ts",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@laser-ui/hooks": "0.1.
|
|
30
|
-
"@laser-ui/utils": "0.1.
|
|
29
|
+
"@laser-ui/hooks": "0.1.6",
|
|
30
|
+
"@laser-ui/utils": "0.1.6",
|
|
31
31
|
"@material-design-icons/svg": "^0.14.12",
|
|
32
32
|
"jss": "^10.10.0",
|
|
33
33
|
"jss-preset-default": "^10.10.0",
|
|
34
34
|
"lodash": "^4.17.21",
|
|
35
|
-
"rcl-store": "^2.1.0"
|
|
36
|
-
"rxjs": "^7.8.1"
|
|
35
|
+
"rcl-store": "^2.1.0"
|
|
37
36
|
},
|
|
38
37
|
"peerDependencies": {
|
|
39
38
|
"dayjs": "^1.11.0",
|
|
40
39
|
"immer": ">=2.0.0",
|
|
41
40
|
"react": "^18.0.0",
|
|
42
|
-
"react-dom": "^18.0.0"
|
|
41
|
+
"react-dom": "^18.0.0",
|
|
42
|
+
"tslib": "^2.0.0"
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public",
|
|
46
46
|
"directory": "../../dist/libs/components"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "da66a982fe29f71012ff6d0141ee90366da93ad2"
|
|
49
49
|
}
|