@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 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, children: _jsx(ConfigProvider, { context: { componentSize: size }, children: _jsx(FormContext.Provider, { value: {
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 _asyncValidationSubscription?;
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
- const observables = forkJoin(presentValidators.map((fn) => fn(control)));
30
- observables.subscribe({
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, "_asyncValidationSubscription", {
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._asyncValidationSubscription) {
316
- this._asyncValidationSubscription.unsubscribe();
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
- this._asyncValidationSubscription = from(this.asyncValidator(this)).subscribe((errors) => {
320
+ let abort = false;
321
+ this._abortAsyncValidation = () => {
322
+ abort = true;
323
+ };
324
+ this.asyncValidator(this).then((errors) => {
325
325
  var _a, _b;
326
- this._hasOwnPendingAsyncValidator = false;
327
- // This will trigger the recalculation of the validation status, which depends on
328
- // the state of the asynchronous validation (whether it is in progress or not). So, it is
329
- // necessary that we have updated the `_hasOwnPendingAsyncValidator` boolean flag first.
330
- this.setErrors(errors);
331
- (_b = (_a = this.root)._emitChange) === null || _b === void 0 ? void 0 : _b.call(_a);
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
  }
@@ -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 ob = fromEvent([pageScrollRef, ...updatePosition.containerRefs].map((ref) => ref.current).filter((el) => el), 'scroll', { passive: true }).subscribe({
50
- next: () => {
51
- updatePosition.fn();
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
- ob.unsubscribe();
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.4",
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.4",
30
- "@laser-ui/utils": "0.1.4",
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": "eb0e7cedff3b277b90e724eddc6850c3b623d7b2"
48
+ "gitHead": "da66a982fe29f71012ff6d0141ee90366da93ad2"
49
49
  }