@servicetitan/docs-anvil-uikit-contrib 37.0.3 → 38.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.
@@ -0,0 +1,11 @@
1
+ ---
2
+ title: BREAKING CHANGES
3
+ sidebar_position: 0
4
+ ---
5
+
6
+ ### [@servicetitan/intl](./intl/) v6.0.0
7
+
8
+ Renamed [timezone formats](./intl/time#available-formats) to clarify that the timezone is added to the formatted output:
9
+
10
+ - `shortTimeZone` -> `shortWithTimeZone`
11
+ - `mediumTimeZone` -> `mediumWithTimeZone`
@@ -5,7 +5,7 @@ title: useIntl
5
5
  The `useIntl` hook is the primary way to access direct internationalization functions in your React components. It provides access to all formatting functions and locale information needed for internationalization.
6
6
 
7
7
  :::note
8
- If using [`react-intl` Formatted components](https://formatjs.github.io/docs/react-intl/components)--such as those described in [Dates](../dates.mdx) and [Plurals](../plurals.mdx) documentation--you do not need to use the `useIntl` hook directly.
8
+ If using [`react-intl` Formatted components](https://formatjs.github.io/docs/react-intl/components)--such as those described in [Date](../date) and [Plural](../plural) documentation--you do not need to use the `useIntl` hook directly.
9
9
  :::
10
10
 
11
11
  ## Overview
@@ -37,19 +37,20 @@ The [`intl`](https://formatjs.github.io/docs/react-intl/api#intlshape) object re
37
37
 
38
38
  ### Standard Formatting Functions
39
39
 
40
- - [`formatDate()`](../dates.mdx) - Format dates
40
+ - [`formatDate()`](../date) - Format date
41
41
  - [`formatDisplayName()`](https://formatjs.github.io/docs/react-intl/api/#formatdisplayname) - Format display names for locales, currencies, etc.
42
- - [`formatList()`](https://formatjs.github.io/docs/react-intl/api/#formatlist) - Format lists of items
43
- - [`formatMessage()`](https://formatjs.github.io/docs/react-intl/api/#formatmessage) - Format messages with interpolation (note: translating messages is not yet configured within ServiceTitan)
44
- - [`formatNumber()`](../numbers.mdx) - Format numbers and currency
42
+ - [`formatList()`](https://formatjs.github.io/docs/react-intl/api/#formatlist) - Format list of items
43
+ - [`formatMessage()`](https://formatjs.github.io/docs/react-intl/api/#formatmessage) - Format message with interpolation (note: translating messages is not yet configured within ServiceTitan)
44
+ - [`formatNumber()`](../number) - Format number and currency
45
45
  - [`formatPlural()`](https://formatjs.github.io/docs/react-intl/api/#formatplural) - Handle pluralization
46
46
  - [`formatRelativeTime()`](https://formatjs.github.io/docs/react-intl/api/#formatrelativetime) - Format relative time (e.g., "2 hours ago")
47
- - [`formatTime()`](https://formatjs.github.io/docs/react-intl/api/#formattime) - Format times
47
+ - [`formatTime()`](../time) - Format time
48
48
 
49
49
  ### Custom ServiceTitan Formatters
50
50
 
51
- - [`formatCurrency()`](../currency.mdx) - Format currency
52
- - [`formatPluralMessage()`](../plurals.mdx#formatpluralmessage) - Provide a number and messages associated with plural forms, and receive the appropriate message for the current locale and plural form
51
+ - [`formatCurrency()`](../currency) - Format currency
52
+ - [`formatDateTime()`](../date-time) - Format combined date and time
53
+ - [`formatPluralMessage()`](../plural#formatpluralmessage) - Provide a number and messages associated with plural forms, and receive the appropriate message for the current locale and plural form
53
54
 
54
55
  ### Properties
55
56
 
@@ -2,11 +2,10 @@
2
2
  title: Currency
3
3
  ---
4
4
 
5
- import {
6
- FormattedCurrencyMiniDemo
7
- } from '@servicetitan/intl/demo';
5
+ import { FormattedCurrencyMiniDemo } from '@servicetitan/intl/demo';
8
6
  import { DemoExample } from '@site/src/components/code-demo';
9
7
  import Tabs from '@theme/Tabs';
8
+ import TabItem from '@theme/TabItem';
10
9
 
11
10
  Numbers can be formatted as currency either by using the `FormattedCurrency` component from `@servicetitan/intl`, or via the `formatCurrency()` function as part of the `intl` object, which can be retrieved via the [`useIntl()`](./API/use-intl.mdx) hook or through the [`IntlStore`](./API/intlstore.mdx) store.
12
11
 
@@ -36,7 +35,7 @@ function CurrencyExample() {
36
35
  <FormattedCurrency value={1234.56} currency="EUR" />
37
36
  </>
38
37
  );
39
- };
38
+ }
40
39
  ```
41
40
 
42
41
  ### formatCurrency
@@ -64,7 +63,7 @@ function CurrencyExample() {
64
63
  {intl.formatCurrency(1234.56, { style: 'currency', currency: 'EUR' })}
65
64
  </>
66
65
  );
67
- };
66
+ }
68
67
  ```
69
68
 
70
69
  </TabItem>
@@ -0,0 +1,114 @@
1
+ ---
2
+ title: Date and Time
3
+ ---
4
+
5
+ import { FormattedDateTimeMiniDemo } from '@servicetitan/intl/demo';
6
+ import { DemoExample } from '@site/src/components/code-demo';
7
+ import Tabs from '@theme/Tabs';
8
+ import TabItem from '@theme/TabItem';
9
+
10
+ Use `FormattedDateTime` and `formatDateTime` to format a date value as a combined date and time.
11
+
12
+ ## Available Formats
13
+
14
+ The following standard ServiceTitan formats are available (examples are in `en-US` locale).
15
+
16
+ | Format | Description | Example |
17
+ | :------------------ | :-------------------------------------------------------------------------- | :------------------------------- |
18
+ | `short` | Short date and short time. This is the default when no format is specified. | `01/09/2025, 4:00 PM` |
19
+ | `shortWithTimeZone` | Short date and short time, with timezone | `01/09/2025, 4:00 PM EST` |
20
+ | `long` | Long date and short time | `January 9, 2025 at 4:00 PM` |
21
+ | `longWithTimeZone` | Long date and short time, with timezone | `January 9, 2025 at 4:00 PM EST` |
22
+
23
+ ## Usage
24
+
25
+ ### FormattedDateTime
26
+
27
+ ```tsx
28
+ import { FormattedDateTime } from '@servicetitan/intl';
29
+
30
+ function DateTimeExample() {
31
+ const date = new Date('2025-01-09T16:00:00-05:00');
32
+
33
+ return (
34
+ <>
35
+ <FormattedDateTime value={date} /> {/* 01/09/2025, 4:00 PM */}
36
+ <FormattedDateTime value={date} format="short" /> {/* 01/09/2025, 4:00 PM */}
37
+ <FormattedDateTime value={date} format="shortWithTimeZone" /> {/* 01/09/2025, 4:00 PM EST */}
38
+ <FormattedDateTime value={date} format="long" /> {/* January 9, 2025 at 4:00 PM */}
39
+ <FormattedDateTime value={date} format="longWithTimeZone" /> {/* January 9, 2025 at 4:00 PM EST */}
40
+ </>
41
+ );
42
+ }
43
+ ```
44
+
45
+ ### formatDateTime
46
+
47
+ <Tabs
48
+ defaultValue="hook"
49
+ values={[
50
+ { label: 'React Hook', value: 'hook' },
51
+ { label: 'MobX Store', value: 'store'}
52
+ ]}
53
+ >
54
+ <TabItem value="hook">
55
+
56
+ ```tsx
57
+ import { useIntl } from '@servicetitan/intl';
58
+
59
+ function DateTimeExample() {
60
+ const { formatDateTime } = useIntl();
61
+ const date = new Date('2025-01-09T16:00:00-05:00');
62
+
63
+ return (
64
+ <>
65
+ {formatDateTime(date)} {/* 01/09/2025, 4:00 PM */}
66
+ {formatDateTime(date, { format: 'short' })} {/* 01/09/2025, 4:00 PM */}
67
+ {formatDateTime(date, { format: 'shortWithTimeZone' })} {/* 01/09/2025, 4:00 PM EST */}
68
+ {formatDateTime(date, { format: 'long' })} {/* January 9, 2025 at 4:00 PM */}
69
+ {formatDateTime(date, { format: 'longWithTimeZone' })} {/* January 9, 2025 at 4:00 PM EST */}
70
+ </>
71
+ );
72
+ }
73
+ ```
74
+
75
+ </TabItem>
76
+ <TabItem value="store">
77
+
78
+ ```tsx
79
+ import { inject, injectable } from '@servicetitan/react-ioc';
80
+ import { IntlStore } from '@servicetitan/intl/mobx';
81
+
82
+ @injectable()
83
+ class MyStore {
84
+ constructor(@inject(IntlStore) private readonly intlStore: IntlStore) {}
85
+
86
+ formatDateTime() {
87
+ const date = new Date('2025-01-09T16:00:00-05:00');
88
+ const { formatDateTime } = this.intlStore.intl;
89
+ return [
90
+ formatDateTime(date), // 01/09/2025, 4:00 PM
91
+ formatDateTime(date, { format: 'short' }), // 01/09/2025, 4:00 PM
92
+ formatDateTime(date, { format: 'shortWithTimeZone' }), // 01/09/2025, 4:00 PM EST
93
+ formatDateTime(date, { format: 'long' }), // January 9, 2025 at 4:00 PM
94
+ formatDateTime(date, { format: 'longWithTimeZone' }), // January 9, 2025 at 4:00 PM EST
95
+ ];
96
+ }
97
+ }
98
+ ```
99
+
100
+ </TabItem>
101
+ </Tabs>
102
+
103
+ ### Further customization
104
+
105
+ To customize the formatting, pass `FormattedDateTime` and `formatDateTime` the same [options](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat#using_options) as the native `Intl.DateTimeFormat` API. For example,
106
+
107
+ ```ts
108
+ const date = new Date('2025-01-09T16:00:00-05:00');
109
+ formatDateTime(date, { format: 'long', weekday: 'short' }); // Thu, January 9, 2025 at 4:00 PM
110
+ ```
111
+
112
+ ## Demo
113
+
114
+ <DemoExample example={FormattedDateTimeMiniDemo} />
@@ -1,17 +1,16 @@
1
1
  ---
2
- title: Dates
2
+ title: Date
3
3
  ---
4
4
 
5
- import {
6
- FormattedDateMiniDemo
7
- } from '@servicetitan/intl/demo';
5
+ import { FormattedDateMiniDemo } from '@servicetitan/intl/demo';
8
6
  import { DemoExample } from '@site/src/components/code-demo';
9
7
  import Tabs from '@theme/Tabs';
8
+ import TabItem from '@theme/TabItem';
10
9
 
11
10
  Dates can be formatted either by using the [`FormattedDate`](#formatteddate) component from `@servicetitan/intl`, or via the [`formatDate`](#formatdate) function as part of the `intl` object, which can be retrieved via the [`useIntl`](./API/use-intl.mdx) hook or through the [`IntlStore`](./API/intlstore.mdx) store.
12
11
 
13
12
  :::note
14
- `FormattedDate` is a wrapper around `react-intl`'s `FormattedDate` component, but defaults the `format` to *short*. Make sure you import it from `@servicetitan/intl`, not `react-intl`.
13
+ `FormattedDate` is a wrapper around `react-intl`'s `FormattedDate` component, but defaults the `format` to _short_. Make sure you import it from `@servicetitan/intl`, not `react-intl`.
15
14
  :::
16
15
 
17
16
  ## Available Formats
@@ -2,10 +2,9 @@
2
2
  title: Intl (Internationalization)
3
3
  ---
4
4
 
5
- import Tabs from '@theme/Tabs';
6
- import TabItem from '@theme/TabItem';
5
+ #### [CHANGELOG (@servicetitan/intl)](https://github.com/servicetitan/anvil-uikit-contrib/blob/master/packages/intl/CHANGELOG.md)
7
6
 
8
- `@servicetitan/intl` is a solution for helping setup internationalization in React projects (with optional MobX store) that is a light wrapper around [`Format.js`](https://formatjs.github.io/) and [`react-intl`](https://formatjs.github.io/docs/react-intl/). This library creates an internationalization API with a provided *locale*, *timeZone*, and *currency*, and provides that API to `react-intl` to be used within React context, as well as a store to be used within MobX.
7
+ `@servicetitan/intl` is a solution for helping setup internationalization in React projects (with optional MobX store) that is a light wrapper around [`Format.js`](https://formatjs.github.io/) and [`react-intl`](https://formatjs.github.io/docs/react-intl/). This library creates an internationalization API with a provided _locale_, _timeZone_, and _currency_, and provides that API to `react-intl` to be used within React context, as well as a store to be used within MobX.
9
8
 
10
9
  ## Setup
11
10
 
@@ -16,8 +15,9 @@ npm install @servicetitan/intl
16
15
  ```
17
16
 
18
17
  This library has `peerDependencies` for:
19
- - `"@servicetitan/react-ioc": ">=22.0.0"`
20
- - `"react-intl": ">=7.1.11"`
18
+
19
+ - `"@servicetitan/react-ioc": ">=22.0.0"`
20
+ - `"react-intl": ">=7.1.11"`
21
21
 
22
22
  ### Provider
23
23
 
@@ -73,11 +73,12 @@ If you are instead implementing an MFE but would use the same monolith data, you
73
73
 
74
74
  `Format.js` and `react-intl` provide many components and utilities for handling internationalization, including caching and wrapping most of the [native `Intl` formatters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl). The following APIs are particularly useful to us at this stage:
75
75
 
76
- - [Formatting currency](./currency.mdx)
77
- - [Formatting dates](./dates.mdx)
78
- - [Formatting numbers](./numbers.mdx)
79
- - [Formatting times](./times.mdx)
80
- - [Plurals](./plurals.mdx)
76
+ - [Currency](./currency)
77
+ - [Date](./date)
78
+ - [Date and time](./date-time)
79
+ - [Number](./number)
80
+ - [Time](./time)
81
+ - [Plural](./plural)
81
82
 
82
83
  :::note
83
84
  Translating messages is not yet supported, as we currently have no need for it. But using `@servicetitan/intl` ensures the framework is in place for when we do begin translating messages.
@@ -117,7 +118,7 @@ export class UserService {
117
118
 
118
119
  return {
119
120
  joinDate: intl.formatDate(user.joinDate),
120
- balance: intl.formatCurrency(user.balance)
121
+ balance: intl.formatCurrency(user.balance),
121
122
  };
122
123
  }
123
124
  }
@@ -1,12 +1,11 @@
1
1
  ---
2
- title: Numbers
2
+ title: Number
3
3
  ---
4
4
 
5
- import {
6
- FormattedNumberMiniDemo
7
- } from '@servicetitan/intl/demo';
5
+ import { FormattedNumberMiniDemo } from '@servicetitan/intl/demo';
8
6
  import { DemoExample } from '@site/src/components/code-demo';
9
7
  import Tabs from '@theme/Tabs';
8
+ import TabItem from '@theme/TabItem';
10
9
 
11
10
  Numbers can be formatted either by using the `FormattedNumber` component from `@servicetitan/intl`, or via the `formatNumber()` function as part of the `intl` object, which can be retrieved via the [`useIntl()`](./API/use-intl.mdx) hook or through the [`IntlStore`](./API/intlstore.mdx) store.
12
11
 
@@ -1,12 +1,11 @@
1
1
  ---
2
- title: Plurals
2
+ title: Plural
3
3
  ---
4
4
 
5
- import {
6
- FormattedPluralMiniDemo
7
- } from '@servicetitan/intl/demo';
5
+ import { FormattedPluralMiniDemo } from '@servicetitan/intl/demo';
8
6
  import { DemoExample } from '@site/src/components/code-demo';
9
7
  import Tabs from '@theme/Tabs';
8
+ import TabItem from '@theme/TabItem';
10
9
 
11
10
  Plurals can be formatted by using the `FormattedPlural` component from `@servicetitan/intl`, or via the `formatPluralMessage()` function as part of the `intl` object, which can be retrieved via the [`useIntl()`](./API/use-intl.mdx) hook or through the [`IntlStore`](./API/intlstore.mdx) store.
12
11
 
@@ -32,11 +31,11 @@ import { FormattedPlural } from '@servicetitan/intl';
32
31
 
33
32
  `formatPluralMessage` is a custom formatter which accepts a number value, an object of messages keyed by plural forms, and [`Intl.PluralRules` options](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/PluralRules#options). It returns the message corresponding to the plural form of the value for the current locale.
34
33
 
35
- | Name | Type | Description |
36
- | :--------- | :-------------------- | :--------------------------------------------------- |
37
- | `value` | `number` | The number value to determine the plural form. |
38
- | `messages` | `PluralMessages` | An object containing messages keyed by plural forms. |
39
- | `options?` | `FormatPluralOptions` | [Options to customize the pluralization behavior](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/PluralRules#options). Defaults to using "cardinal".
34
+ | Name | Type | Description |
35
+ | :--------- | :-------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
36
+ | `value` | `number` | The number value to determine the plural form. |
37
+ | `messages` | `PluralMessages` | An object containing messages keyed by plural forms. |
38
+ | `options?` | `FormatPluralOptions` | [Options to customize the pluralization behavior](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/PluralRules#options). Defaults to using "cardinal". |
40
39
 
41
40
  <Tabs
42
41
  defaultValue="hooks"
@@ -78,7 +77,6 @@ class MyStore {
78
77
  </TabItem>
79
78
  </Tabs>
80
79
 
81
-
82
80
  ### Demo
83
81
 
84
82
  <DemoExample example={FormattedPluralMiniDemo} />
@@ -1,12 +1,11 @@
1
1
  ---
2
- title: Times
2
+ title: Time
3
3
  ---
4
4
 
5
- import {
6
- FormattedTimeMiniDemo
7
- } from '@servicetitan/intl/demo';
5
+ import { FormattedTimeMiniDemo } from '@servicetitan/intl/demo';
8
6
  import { DemoExample } from '@site/src/components/code-demo';
9
7
  import Tabs from '@theme/Tabs';
8
+ import TabItem from '@theme/TabItem';
10
9
 
11
10
  Times can be formatted either by using the [`FormattedTime`](#formattedtime) component from `@servicetitan/intl`, or via the [`formatTime`](#formattime) function as part of the `intl` object, which can be retrieved via the [`useIntl`](./API/use-intl.mdx) hook or through the [`IntlStore`](./API/intlstore.mdx) store.
12
11
 
@@ -19,10 +18,10 @@ The example results that follow use a locale of 'en-US' and time zone of 'Americ
19
18
  :::
20
19
 
21
20
  - `short` results in `4:00 PM` (default)
22
- - `shortTimezone` results in `4:00 PM EDT`
23
- - `utc` results in `08:00 PM UTC` (forces UTC timezone and adds leading zero)
21
+ - `shortWithTimeZone` results in `4:00 PM EDT`
24
22
  - `medium` results in `4:00:00 PM`
25
- - `mediumTimeZone` results in `4:00:00 PM EDT`
23
+ - `mediumWithTimeZone` results in `4:00:00 PM EDT`
24
+ - `utc` results in `08:00 PM UTC` (forces UTC timezone and adds leading zero)
26
25
 
27
26
  ## Usage
28
27
 
@@ -38,10 +37,10 @@ function TimeExample() {
38
37
  <>
39
38
  <FormattedTime value={time} /> {/* "4:00 PM" */}
40
39
  <FormattedTime value={time} format="short" /> {/* "4:00 PM" */}
41
- <FormattedTime value={time} format="shortTimeZone" /> {/* "4:00 PM EDT" */}
40
+ <FormattedTime value={time} format="shortWithTimeZone" /> {/* "4:00 PM EDT" */}
42
41
  <FormattedTime value={time} format="utc" /> {/* "08:00 PM" UTC*/}
43
42
  <FormattedTime value={time} format="medium" /> {/* "4:00:00 PM" */}
44
- <FormattedTime value={time} format="mediumTimeZone" /> {/* "4:00:00 PM EDT" */}
43
+ <FormattedTime value={time} format="mediumWithTimeZone" /> {/* "4:00:00 PM EDT" */}
45
44
  </>
46
45
  );
47
46
  }
@@ -0,0 +1,23 @@
1
+ ---
2
+ title: Secrets
3
+ ---
4
+
5
+ `@servicetitan/secrets` provides a centralized way to manage and distribute shared frontend secrets (API keys, tokens, etc.) across ServiceTitan's applications.
6
+
7
+ ## Quick Start
8
+
9
+ Import secrets directly from the package:
10
+
11
+ ```ts
12
+ import { arcgisApiKey } from '@servicetitan/secrets';
13
+
14
+ const mapClient = new ArcGisClient(arcgisApiKey);
15
+ ```
16
+
17
+ ## Managing Secrets
18
+
19
+ For detailed instructions on adding, updating, and managing secrets, see the [package README](https://github.com/servicetitan/anvil-uikit-contrib/blob/master/packages/secrets/README.md).
20
+
21
+ ## Frontend Secrets Only
22
+
23
+ This package is designed for **frontend secrets only** - secrets that are safe to be public and checked into version control (e.g., read-only API keys, analytics tokens). Never store private keys, database credentials, or backend-only secrets here.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/docs-anvil-uikit-contrib",
3
- "version": "37.0.3",
3
+ "version": "38.1.0",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,5 +16,5 @@
16
16
  "cli": {
17
17
  "webpack": false
18
18
  },
19
- "gitHead": "adf2c3ae6e37a646304d21b6701d358a52f8f2e7"
19
+ "gitHead": "a44925e37020acb2153c7e10215a31cd22d054c1"
20
20
  }