@openmrs/esm-framework 10.0.1-pre.5141 → 10.0.1-pre.5154

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: 3 files with swc (149.33ms)
1
+ [0] Successfully compiled: 3 files with swc (122.27ms)
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
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **clearCurrentUser**(): `void`
6
6
 
7
- Defined in: [packages/framework/esm-api/src/current-user.ts:230](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/current-user.ts#L230)
7
+ Defined in: [packages/framework/esm-api/src/current-user.ts:234](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/current-user.ts#L234)
8
8
 
9
9
  Clears the current user session from the session store, setting the session
10
10
  to an unauthenticated state. This is typically called during logout to reset
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **getLocale**(): `string`
6
6
 
7
- Defined in: [packages/framework/esm-utils/src/get-locale.ts:5](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-utils/src/get-locale.ts#L5)
7
+ Defined in: [packages/framework/esm-utils/src/get-locale.ts:7](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-utils/src/get-locale.ts#L7)
8
8
 
9
9
  Returns the current locale of the application.
10
10
 
@@ -0,0 +1,37 @@
1
+ [O3 Framework](../API.md) / getLocaleDisplayName
2
+
3
+ # Function: getLocaleDisplayName()
4
+
5
+ > **getLocaleDisplayName**(`locale`): `string`
6
+
7
+ Defined in: [packages/framework/esm-utils/src/language-tag.ts:54](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-utils/src/language-tag.ts#L54)
8
+
9
+ Returns the name of a locale as written in that locale, so `fr` becomes "français" and `sw_KE`
10
+ becomes "Kiswahili (Kenya)". Falls back to the identifier itself for anything `Intl` cannot
11
+ resolve, so the result is always safe to render.
12
+
13
+ The name is CLDR's middle-of-sentence form. When presenting it as a standalone label, capitalize
14
+ only the first character: lowercasing the remainder corrupts names carrying internal capitals,
15
+ turning "American English" into "American english".
16
+
17
+ ## Parameters
18
+
19
+ ### locale
20
+
21
+ An OpenMRS locale identifier, e.g. `sw_KE`.
22
+
23
+ `undefined` | `null` | `string`
24
+
25
+ ## Returns
26
+
27
+ `string`
28
+
29
+ The locale's name in its own language, `locale` itself if it cannot be resolved, or an
30
+ empty string if no locale was given.
31
+
32
+ ## Example
33
+
34
+ ```ts
35
+ getLocaleDisplayName('fr'); // => 'français'
36
+ getLocaleDisplayName('sw_KE'); // => 'Kiswahili (Kenya)'
37
+ ```
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **getLoggedInUser**(): `Promise`\<[`LoggedInUser`](../interfaces/LoggedInUser.md)\>
6
6
 
7
- Defined in: [packages/framework/esm-api/src/current-user.ts:287](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/current-user.ts#L287)
7
+ Defined in: [packages/framework/esm-api/src/current-user.ts:291](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/current-user.ts#L291)
8
8
 
9
9
  Returns a Promise that resolves with the currently logged-in user object.
10
10
  If the user is already loaded in the session store, the Promise resolves immediately.
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **getSessionLocation**(): `Promise`\<`undefined` \| [`SessionLocation`](../interfaces/SessionLocation.md)\>
6
6
 
7
- Defined in: [packages/framework/esm-api/src/current-user.ts:325](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/current-user.ts#L325)
7
+ Defined in: [packages/framework/esm-api/src/current-user.ts:329](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/current-user.ts#L329)
8
8
 
9
9
  Returns a Promise that resolves with the current session location, if one is set.
10
10
  The session location represents the physical location where the user is currently
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **matchLocale**(`requested`, `available`, `fallback?`): `undefined` \| `string`
6
6
 
7
- Defined in: [packages/framework/esm-utils/src/match-locale.ts:53](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-utils/src/match-locale.ts#L53)
7
+ Defined in: [packages/framework/esm-utils/src/match-locale.ts:35](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-utils/src/match-locale.ts#L35)
8
8
 
9
9
  Resolves a requested locale against a list of available locales using the
10
10
  BCP 47 lookup algorithm (RFC 4647, §3.4).
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **refetchCurrentUser**(`username?`, `password?`): `Promise`\<[`SessionStore`](../type-aliases/SessionStore.md)\>
6
6
 
7
- Defined in: [packages/framework/esm-api/src/current-user.ts:204](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/current-user.ts#L204)
7
+ Defined in: [packages/framework/esm-api/src/current-user.ts:208](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/current-user.ts#L208)
8
8
 
9
9
  The `refetchCurrentUser` function causes a network request to redownload
10
10
  the user. All subscribers to the current user will be notified of the
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **setSessionLocation**(`locationUuid`, `abortController`): `Promise`\<`any`\>
6
6
 
7
- Defined in: [packages/framework/esm-api/src/current-user.ts:351](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/current-user.ts#L351)
7
+ Defined in: [packages/framework/esm-api/src/current-user.ts:355](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/current-user.ts#L355)
8
8
 
9
9
  Sets the session location for the current user. The session location represents
10
10
  the physical location where the user is working (e.g., a clinic or ward).
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **setUserProperties**(`userUuid`, `userProperties`, `abortController?`): `Promise`\<[`SessionStore`](../type-aliases/SessionStore.md)\>
6
6
 
7
- Defined in: [packages/framework/esm-api/src/current-user.ts:387](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/current-user.ts#L387)
7
+ Defined in: [packages/framework/esm-api/src/current-user.ts:391](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/current-user.ts#L391)
8
8
 
9
9
  Updates the user properties for a specific user. User properties are key-value
10
10
  pairs that store user-specific settings and preferences. After updating the
@@ -0,0 +1,44 @@
1
+ [O3 Framework](../API.md) / toLanguageTag
2
+
3
+ # Function: toLanguageTag()
4
+
5
+ > **toLanguageTag**(`locale`): `undefined` \| `string`
6
+
7
+ Defined in: [packages/framework/esm-utils/src/language-tag.ts:25](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-utils/src/language-tag.ts#L25)
8
+
9
+ Converts an OpenMRS locale identifier into a canonical BCP 47 language tag.
10
+
11
+ OpenMRS locale identifiers are not always language tags. User properties such as
12
+ `defaultLocale` store Java's `Locale#toString()` form (`en_US`, `sw_KE`) verbatim, some backends
13
+ serialize session locales the same way, and some installs configure POSIX-style variants
14
+ (`uz@Latn`). The `Intl` constructors throw `RangeError` rather than degrading when handed any of
15
+ them, so convert before passing an OpenMRS locale to `Intl`.
16
+
17
+ Both `_` and `@` are treated as subtag separators, which covers the `@Latn` script modifier.
18
+ Other POSIX modifiers have no BCP 47 equivalent and parse as whatever their length implies
19
+ (`de@euro` becomes the script subtag `de-Euro`), so they are converted rather than rejected.
20
+
21
+ ## Parameters
22
+
23
+ ### locale
24
+
25
+ An OpenMRS locale identifier, e.g. `sw_KE`. Locale data reaching this function
26
+ comes from the REST session and from configuration, so anything that is not a string is
27
+ treated as an unresolvable locale rather than an error.
28
+
29
+ `undefined` | `null` | `string`
30
+
31
+ ## Returns
32
+
33
+ `undefined` \| `string`
34
+
35
+ The canonical language tag, or `undefined` if `locale` is not a structurally valid tag.
36
+
37
+ ## Example
38
+
39
+ ```ts
40
+ toLanguageTag('sw_KE'); // => 'sw-KE'
41
+ toLanguageTag('uz@Latn'); // => 'uz-Latn'
42
+ toLanguageTag('en_us'); // => 'en-US'
43
+ toLanguageTag('not a locale'); // => undefined
44
+ ```
@@ -4,7 +4,7 @@
4
4
 
5
5
  > **userHasAccess**(`requiredPrivilege`, `user`): `boolean`
6
6
 
7
- Defined in: [packages/framework/esm-api/src/current-user.ts:255](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/current-user.ts#L255)
7
+ Defined in: [packages/framework/esm-api/src/current-user.ts:259](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/current-user.ts#L259)
8
8
 
9
9
  Checks whether the given user has access based on the required privilege(s).
10
10
  A user has access if they have the required privilege(s) or if they are a
package/mock-jest.tsx CHANGED
@@ -28,6 +28,8 @@ export {
28
28
  ageAsDuration,
29
29
  isOmrsDateToday,
30
30
  matchLocale,
31
+ toLanguageTag,
32
+ getLocaleDisplayName,
31
33
  } from '@openmrs/esm-utils';
32
34
 
33
35
  /* esm-globals */
package/mock.tsx CHANGED
@@ -29,6 +29,8 @@ export {
29
29
  ageAsDuration,
30
30
  isOmrsDateToday,
31
31
  matchLocale,
32
+ toLanguageTag,
33
+ getLocaleDisplayName,
32
34
  } from '@openmrs/esm-utils';
33
35
 
34
36
  /* esm-globals */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-framework",
3
- "version": "10.0.1-pre.5141",
3
+ "version": "10.0.1-pre.5154",
4
4
  "license": "MPL-2.0",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
@@ -59,24 +59,24 @@
59
59
  "access": "public"
60
60
  },
61
61
  "dependencies": {
62
- "@openmrs/esm-api": "10.0.1-pre.5141",
63
- "@openmrs/esm-config": "10.0.1-pre.5141",
64
- "@openmrs/esm-context": "10.0.1-pre.5141",
65
- "@openmrs/esm-dynamic-loading": "10.0.1-pre.5141",
66
- "@openmrs/esm-emr-api": "10.0.1-pre.5141",
67
- "@openmrs/esm-error-handling": "10.0.1-pre.5141",
68
- "@openmrs/esm-expression-evaluator": "10.0.1-pre.5141",
69
- "@openmrs/esm-extensions": "10.0.1-pre.5141",
70
- "@openmrs/esm-feature-flags": "10.0.1-pre.5141",
71
- "@openmrs/esm-globals": "10.0.1-pre.5141",
72
- "@openmrs/esm-navigation": "10.0.1-pre.5141",
73
- "@openmrs/esm-offline": "10.0.1-pre.5141",
74
- "@openmrs/esm-react-utils": "10.0.1-pre.5141",
75
- "@openmrs/esm-routes": "10.0.1-pre.5141",
76
- "@openmrs/esm-state": "10.0.1-pre.5141",
77
- "@openmrs/esm-styleguide": "10.0.1-pre.5141",
78
- "@openmrs/esm-translations": "10.0.1-pre.5141",
79
- "@openmrs/esm-utils": "10.0.1-pre.5141"
62
+ "@openmrs/esm-api": "10.0.1-pre.5154",
63
+ "@openmrs/esm-config": "10.0.1-pre.5154",
64
+ "@openmrs/esm-context": "10.0.1-pre.5154",
65
+ "@openmrs/esm-dynamic-loading": "10.0.1-pre.5154",
66
+ "@openmrs/esm-emr-api": "10.0.1-pre.5154",
67
+ "@openmrs/esm-error-handling": "10.0.1-pre.5154",
68
+ "@openmrs/esm-expression-evaluator": "10.0.1-pre.5154",
69
+ "@openmrs/esm-extensions": "10.0.1-pre.5154",
70
+ "@openmrs/esm-feature-flags": "10.0.1-pre.5154",
71
+ "@openmrs/esm-globals": "10.0.1-pre.5154",
72
+ "@openmrs/esm-navigation": "10.0.1-pre.5154",
73
+ "@openmrs/esm-offline": "10.0.1-pre.5154",
74
+ "@openmrs/esm-react-utils": "10.0.1-pre.5154",
75
+ "@openmrs/esm-routes": "10.0.1-pre.5154",
76
+ "@openmrs/esm-state": "10.0.1-pre.5154",
77
+ "@openmrs/esm-styleguide": "10.0.1-pre.5154",
78
+ "@openmrs/esm-translations": "10.0.1-pre.5154",
79
+ "@openmrs/esm-utils": "10.0.1-pre.5154"
80
80
  },
81
81
  "peerDependencies": {
82
82
  "dayjs": "1.x",
@@ -89,7 +89,7 @@
89
89
  "swr": "2.x"
90
90
  },
91
91
  "devDependencies": {
92
- "@openmrs/typedoc-plugin-file-categories": "10.0.1-pre.5141",
92
+ "@openmrs/typedoc-plugin-file-categories": "10.0.1-pre.5154",
93
93
  "@swc/cli": "0.8.1",
94
94
  "@swc/core": "1.15.21",
95
95
  "@vitest/coverage-v8": "^4.1.2",