@openmrs/esm-react-utils 6.3.1-pre.3124 → 6.3.1-pre.3127

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.
@@ -1,3 +1,3 @@
1
- [0] Successfully compiled: 52 files with swc (136.52ms)
1
+ [0] Successfully compiled: 52 files with swc (143.82ms)
2
2
  [0] swc --strip-leading-paths src -d dist exited with code 0
3
3
  [1] tsc --project tsconfig.build.json exited with code 0
@@ -20,7 +20,7 @@ export interface ExtensionSlotBaseProps {
20
20
  * has children, you must pass the state through the `state` param of the
21
21
  * `Extension` component.
22
22
  */
23
- state?: Record<string | number | symbol, unknown>;
23
+ state?: Record<string | symbol | number, unknown>;
24
24
  }
25
25
  export interface ExtensionSlotProps extends ExtensionSlotBaseProps, Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
26
26
  children?: React.ReactNode | ((extension: AssignedExtension, state?: Record<string, unknown>) => React.ReactNode);
@@ -1,4 +1,4 @@
1
- export interface OpenmrsAppContextProps<T extends Record<string | symbol | number, unknown> = Record<string | symbol | number, any>> {
1
+ export interface OpenmrsAppContextProps<T extends NonNullable<object> = NonNullable<object>> {
2
2
  /** the namespace that this component defines */
3
3
  namespace: string;
4
4
  /** used to control the value associated with the namespace */
@@ -17,4 +17,4 @@ export interface OpenmrsAppContextProps<T extends Record<string | symbol | numbe
17
17
  * context component, the `OpenmrsAppContext` is inherently global in scope. That means that _all applications_
18
18
  * will see the values that you set for the namespace if they load the value of the namespace.
19
19
  */
20
- export declare function OpenmrsAppContext<T extends Record<string | symbol | number, unknown> = Record<string | symbol | number, any>>({ namespace, value }: OpenmrsAppContextProps<T>): null;
20
+ export declare function OpenmrsAppContext<T extends NonNullable<object> = NonNullable<object>>({ namespace, value, }: OpenmrsAppContextProps<T>): null;
@@ -18,4 +18,4 @@
18
18
  * @typeParam T The type of the value stored in the namespace
19
19
  * @param namespace The namespace to load properties from
20
20
  */
21
- export declare function useAppContext<T extends Record<string | symbol | number, unknown> = Record<string | symbol | number, any>>(namespace: string): Readonly<T> | undefined;
21
+ export declare function useAppContext<T extends NonNullable<object> = NonNullable<object>>(namespace: string): Readonly<T> | undefined;
@@ -29,4 +29,4 @@
29
29
  * the namespace value.
30
30
  * @returns A function which can be used to update the state associated with the namespace
31
31
  */
32
- export declare function useDefineAppContext<T extends Record<string | symbol | number, unknown> = Record<string | symbol | number, any>>(namespace: string, value?: T): (update: (state: T) => T) => void;
32
+ export declare function useDefineAppContext<T extends NonNullable<object> = NonNullable<object>>(namespace: string, value?: T): (update: (state: T) => T) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-react-utils",
3
- "version": "6.3.1-pre.3124",
3
+ "version": "6.3.1-pre.3127",
4
4
  "license": "MPL-2.0",
5
5
  "description": "React utilities for OpenMRS.",
6
6
  "type": "module",
@@ -78,17 +78,17 @@
78
78
  "swr": "2.x"
79
79
  },
80
80
  "devDependencies": {
81
- "@openmrs/esm-api": "6.3.1-pre.3124",
82
- "@openmrs/esm-config": "6.3.1-pre.3124",
83
- "@openmrs/esm-context": "6.3.1-pre.3124",
84
- "@openmrs/esm-emr-api": "6.3.1-pre.3124",
85
- "@openmrs/esm-error-handling": "6.3.1-pre.3124",
86
- "@openmrs/esm-extensions": "6.3.1-pre.3124",
87
- "@openmrs/esm-feature-flags": "6.3.1-pre.3124",
88
- "@openmrs/esm-globals": "6.3.1-pre.3124",
89
- "@openmrs/esm-navigation": "6.3.1-pre.3124",
90
- "@openmrs/esm-state": "6.3.1-pre.3124",
91
- "@openmrs/esm-utils": "6.3.1-pre.3124",
81
+ "@openmrs/esm-api": "6.3.1-pre.3127",
82
+ "@openmrs/esm-config": "6.3.1-pre.3127",
83
+ "@openmrs/esm-context": "6.3.1-pre.3127",
84
+ "@openmrs/esm-emr-api": "6.3.1-pre.3127",
85
+ "@openmrs/esm-error-handling": "6.3.1-pre.3127",
86
+ "@openmrs/esm-extensions": "6.3.1-pre.3127",
87
+ "@openmrs/esm-feature-flags": "6.3.1-pre.3127",
88
+ "@openmrs/esm-globals": "6.3.1-pre.3127",
89
+ "@openmrs/esm-navigation": "6.3.1-pre.3127",
90
+ "@openmrs/esm-state": "6.3.1-pre.3127",
91
+ "@openmrs/esm-utils": "6.3.1-pre.3127",
92
92
  "@swc/cli": "^0.7.7",
93
93
  "@swc/core": "^1.11.29",
94
94
  "concurrently": "^9.1.2",
@@ -24,7 +24,7 @@ export interface ExtensionSlotBaseProps {
24
24
  * has children, you must pass the state through the `state` param of the
25
25
  * `Extension` component.
26
26
  */
27
- state?: Record<string | number | symbol, unknown>;
27
+ state?: Record<string | symbol | number, unknown>;
28
28
  }
29
29
 
30
30
  export interface ExtensionSlotProps
@@ -1,9 +1,7 @@
1
1
  /** @module @category Context */
2
2
  import { useDefineAppContext } from './useDefineAppContext';
3
3
 
4
- export interface OpenmrsAppContextProps<
5
- T extends Record<string | symbol | number, unknown> = Record<string | symbol | number, any>,
6
- > {
4
+ export interface OpenmrsAppContextProps<T extends NonNullable<object> = NonNullable<object>> {
7
5
  /** the namespace that this component defines */
8
6
  namespace: string;
9
7
  /** used to control the value associated with the namespace */
@@ -23,9 +21,10 @@ export interface OpenmrsAppContextProps<
23
21
  * context component, the `OpenmrsAppContext` is inherently global in scope. That means that _all applications_
24
22
  * will see the values that you set for the namespace if they load the value of the namespace.
25
23
  */
26
- export function OpenmrsAppContext<
27
- T extends Record<string | symbol | number, unknown> = Record<string | symbol | number, any>,
28
- >({ namespace, value }: OpenmrsAppContextProps<T>) {
24
+ export function OpenmrsAppContext<T extends NonNullable<object> = NonNullable<object>>({
25
+ namespace,
26
+ value,
27
+ }: OpenmrsAppContextProps<T>) {
29
28
  useDefineAppContext<T>(namespace, value);
30
29
 
31
30
  return null;
@@ -23,9 +23,9 @@ import { shallowEqual } from '@openmrs/esm-utils';
23
23
  * @typeParam T The type of the value stored in the namespace
24
24
  * @param namespace The namespace to load properties from
25
25
  */
26
- export function useAppContext<
27
- T extends Record<string | symbol | number, unknown> = Record<string | symbol | number, any>,
28
- >(namespace: string): Readonly<T> | undefined;
26
+ export function useAppContext<T extends NonNullable<object> = NonNullable<object>>(
27
+ namespace: string,
28
+ ): Readonly<T> | undefined;
29
29
 
30
30
  /**
31
31
  * This hook is used to access a namespace within the overall AppContext, so that a component can
@@ -49,10 +49,7 @@ export function useAppContext<
49
49
  * @param namespace The namespace to load properties from
50
50
  * @param selector An optional function which extracts the relevant part of the state
51
51
  */
52
- export function useAppContext<
53
- T extends Record<string | symbol | number, unknown> = Record<string | symbol | number, any>,
54
- U = T,
55
- >(
52
+ export function useAppContext<T extends NonNullable<object> = NonNullable<object>, U = T>(
56
53
  namespace: string,
57
54
  selector: (state: Readonly<T> | null) => Readonly<U> = (state) => (state ?? {}) as Readonly<U>,
58
55
  ): Readonly<U> | undefined {
@@ -34,9 +34,7 @@ import { shallowEqual } from '@openmrs/esm-utils';
34
34
  * the namespace value.
35
35
  * @returns A function which can be used to update the state associated with the namespace
36
36
  */
37
- export function useDefineAppContext<
38
- T extends Record<string | symbol | number, unknown> = Record<string | symbol | number, any>,
39
- >(namespace: string, value?: T) {
37
+ export function useDefineAppContext<T extends NonNullable<object> = NonNullable<object>>(namespace: string, value?: T) {
40
38
  const previousValue = useRef<T>(value ?? ({} as T));
41
39
  const updateFunction = useRef((update: (state: T) => T) => updateContext<T>(namespace, update));
42
40