@servicetitan/docs-anvil-uikit-contrib 40.3.0 → 41.1.0
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/docs/intl/API/create-intl.mdx +41 -0
- package/docs/intl/index.mdx +6 -0
- package/package.json +2 -2
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: createIntl
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
`createIntl` creates the imperative internationalization API without requiring React context.
|
|
6
|
+
|
|
7
|
+
Use this API in plain JavaScript, service classes, workers, or other non-React code where the React [`useIntl`](./use-intl.mdx) hook and providers are not available.
|
|
8
|
+
|
|
9
|
+
## Import
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { createIntl } from '@servicetitan/intl/core';
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The `/core` entrypoint does not require `react`, `react-dom`, or `react-intl` to be installed.
|
|
16
|
+
|
|
17
|
+
## Basic Usage
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { createIntl } from '@servicetitan/intl/core';
|
|
21
|
+
|
|
22
|
+
const intl = createIntl({
|
|
23
|
+
currency: 'USD',
|
|
24
|
+
locale: 'en-US',
|
|
25
|
+
timeZone: 'America/Los_Angeles',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
intl.formatNumber(1234.56); // '1,234.56'
|
|
29
|
+
intl.formatCurrency(1234.56); // '$1,234.56'
|
|
30
|
+
intl.formatDate(new Date('2026-01-09T21:00:00.000Z'));
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Available Functions
|
|
34
|
+
|
|
35
|
+
The returned `intl` object provides the same imperative formatter API used by [`useIntl`](./use-intl.mdx), including standard Format.js formatting functions and ServiceTitan custom formatters.
|
|
36
|
+
|
|
37
|
+
See [`useIntl`](./use-intl.mdx#available-functions) for the full list of available functions and properties.
|
|
38
|
+
|
|
39
|
+
## React Usage
|
|
40
|
+
|
|
41
|
+
Inside React components, prefer [`useIntl`](./use-intl.mdx) or the formatted components from `@servicetitan/intl`. Use `createIntl` when there is no React context or when you are intentionally formatting outside React.
|
package/docs/intl/index.mdx
CHANGED
|
@@ -19,6 +19,12 @@ This library has `peerDependencies` for:
|
|
|
19
19
|
- `"@servicetitan/react-ioc": ">=22.0.0"`
|
|
20
20
|
- `"react-intl": ">=7.1.11"`
|
|
21
21
|
|
|
22
|
+
:::tip
|
|
23
|
+
|
|
24
|
+
For non-React JavaScript usage, import [`createIntl`](./API/create-intl.mdx) from `@servicetitan/intl/core`. Consumers that only need imperative formatting can use this entrypoint without installing `react`, `react-dom`, or `react-intl`.
|
|
25
|
+
|
|
26
|
+
:::
|
|
27
|
+
|
|
22
28
|
### Provider
|
|
23
29
|
|
|
24
30
|
Wrap your application with [`<IntlProvider>`](./API/intl-provider.mdx) or [`<MobxIntlProvider>`](./API/mobx-intl-provider.mdx), providing `locale`, `timeZone`, and `currency` through the `config` prop:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/docs-anvil-uikit-contrib",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "41.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"cli": {
|
|
38
38
|
"webpack": false
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "8f8350c50fa1bbe118b418b9022105bd84d68efa"
|
|
41
41
|
}
|