@laser-ui/components 2.0.1 → 2.0.3

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
+ ## [2.0.3](https://github.com/laser-ui/laser-ui/compare/v2.0.2...v2.0.3) (2024-12-25)
6
+
7
+ ### Bug Fixes
8
+
9
+ - **components:** fix form emit change ([37e7c2b](https://github.com/laser-ui/laser-ui/commit/37e7c2bb37d70190d4d86c021977bcf3cb936134))
10
+
11
+ ## [2.0.2](https://github.com/laser-ui/laser-ui/compare/v2.0.1...v2.0.2) (2024-12-19)
12
+
13
+ **Note:** Version bump only for package @laser-ui/components
14
+
5
15
  ## [2.0.1](https://github.com/laser-ui/laser-ui/compare/v2.0.0...v2.0.1) (2024-12-17)
6
16
 
7
17
  **Note:** Version bump only for package @laser-ui/components
package/form/FormItem.js CHANGED
@@ -43,7 +43,9 @@ export function FormItem(props) {
43
43
  throw new Error(`Cant find '${controlName}', please check if name exists!`);
44
44
  }
45
45
  formControl._emitChange = () => {
46
- formControl._emitChange = true;
46
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
47
+ formControl._emitChange = () => { };
48
+ formControl._emitChanged = true;
47
49
  };
48
50
  obj[controlName] = {
49
51
  control: formControl,
@@ -58,7 +60,7 @@ export function FormItem(props) {
58
60
  useEffect(() => {
59
61
  const clear = [];
60
62
  for (const { control } of Object.values(formControlProviders)) {
61
- if (control._emitChange === true) {
63
+ if (control._emitChanged === true) {
62
64
  forceUpdate();
63
65
  }
64
66
  control._emitChange = forceUpdate;
package/form/hooks.js CHANGED
@@ -40,7 +40,9 @@ export function useForm(initForm, deps) {
40
40
  const [form, setForm] = useState(() => {
41
41
  const form = initForm();
42
42
  form._emitChange = () => {
43
- form._emitChange = true;
43
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
44
+ form._emitChange = () => { };
45
+ form._emitChanged = true;
44
46
  };
45
47
  return form;
46
48
  });
@@ -58,7 +60,7 @@ export function useForm(initForm, deps) {
58
60
  forceUpdate();
59
61
  });
60
62
  useEffect(() => {
61
- if (form._emitChange === true) {
63
+ if (form._emitChanged === true) {
62
64
  forceUpdate();
63
65
  }
64
66
  form._emitChange = emitChange;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laser-ui/components",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "React components.",
5
5
  "keywords": [
6
6
  "ui",
@@ -26,9 +26,8 @@
26
26
  "module": "./index.js",
27
27
  "types": "./index.d.ts",
28
28
  "dependencies": {
29
- "@material-design-icons/svg": "^0.14.12",
30
- "lodash": "^4.17.21",
31
- "rcl-store": "^2.1.0"
29
+ "@material-design-icons/svg": "^0.14.13",
30
+ "lodash": "^4.17.21"
32
31
  },
33
32
  "peerDependencies": {
34
33
  "dayjs": "^1.11.0",
@@ -38,5 +37,5 @@
38
37
  "access": "public",
39
38
  "directory": "../../dist/libs/components"
40
39
  },
41
- "gitHead": "5198c1835aa2a718c200cf61181fb372e3f54ed1"
40
+ "gitHead": "c7123f02baa424b48320c60861b29c7a55312ced"
42
41
  }
package/root/Root.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import { jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEvent, useRefExtra } from '@laser-ui/hooks';
3
3
  import { isString, set } from 'lodash';
4
- import { useStore } from 'rcl-store';
5
4
  import { useEffect, useMemo } from 'react';
6
- import { ROOT_DATA, RootContext, Store } from './vars';
5
+ import { useDialogs } from './dialog-service';
6
+ import { ROOT_DATA, RootContext } from './vars';
7
7
  import dayjs from '../dayjs';
8
8
  import resources from '../resources.json';
9
9
  export function Root(props) {
10
10
  const { context: contextProp, children } = props;
11
11
  const windowRef = useRefExtra(() => window);
12
- const [{ dialogs }] = useStore(Store, ['dialogs']);
12
+ const dialogs = useDialogs();
13
13
  useEffect(() => {
14
14
  const handleResize = () => {
15
15
  ROOT_DATA.windowSize = { width: window.innerWidth, height: window.innerHeight };
@@ -1,2 +1,4 @@
1
+ import type { DialogInstance } from '../dialog-service';
1
2
  import { DialogService as InternalDialogService } from '../dialog-service';
3
+ export declare function useDialogs(): DialogInstance<any>[];
2
4
  export declare const DialogService: InternalDialogService;
@@ -1,5 +1,22 @@
1
- import { Store } from './vars';
1
+ import { useSyncExternalStore } from 'react';
2
2
  import { DialogService as InternalDialogService } from '../dialog-service';
3
- export const DialogService = new InternalDialogService((dialogs) => {
4
- Store.set('dialogs', dialogs);
3
+ let dialogs = [];
4
+ let listeners = [];
5
+ function subscribe(onChange) {
6
+ listeners = listeners.concat([onChange]);
7
+ return () => {
8
+ listeners = listeners.filter((f) => f !== onChange);
9
+ };
10
+ }
11
+ function getSnapshot() {
12
+ return dialogs;
13
+ }
14
+ export function useDialogs() {
15
+ return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
16
+ }
17
+ export const DialogService = new InternalDialogService((val) => {
18
+ dialogs = val;
19
+ for (const listener of listeners) {
20
+ listener();
21
+ }
5
22
  });
package/root/vars.d.ts CHANGED
@@ -1,10 +1,6 @@
1
1
  /// <reference types="react" />
2
- import type { DialogInstance } from '../dialog-service';
3
2
  import type { Lang } from '../types';
4
3
  import resources from '../resources.json';
5
- export declare const Store: import("rcl-store").Store<{
6
- dialogs: DialogInstance<any>[];
7
- }>;
8
4
  export declare const ROOT_DATA: {
9
5
  clickEvent?: {
10
6
  time: number;
package/root/vars.js CHANGED
@@ -1,9 +1,5 @@
1
- import { createStore } from 'rcl-store';
2
1
  import { createContext } from 'react';
3
2
  import resources from '../resources.json';
4
- export const Store = createStore({
5
- dialogs: [],
6
- });
7
3
  export const ROOT_DATA = {
8
4
  windowSize: typeof window !== 'undefined' ? { width: window.innerWidth, height: window.innerHeight } : { width: 0, height: 0 },
9
5
  };