@servicetitan/docs-uikit 36.1.1-beta.1 → 36.2.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/BREAKING_CHANGES.mdx +2 -2
- package/docs/ai-marketplace.mdx +93 -0
- package/docs/eslint-config.mdx +78 -0
- package/docs/eslint-plugin.mdx +172 -0
- package/docs/install.mdx +70 -5
- package/docs/launchdarkly-service.mdx +49 -4
- package/docs/lazy-module.mdx +1 -1
- package/docs/microfrontends/hosting.mdx +4 -6
- package/docs/microfrontends/sharing-dependencies.mdx +17 -15
- package/docs/startup/build.mdx +310 -0
- package/docs/startup/clean.mdx +1 -1
- package/docs/startup/review.mdx +15 -11
- package/docs/startup/start.mdx +73 -0
- package/docs/startup/startup.mdx +5 -40
- package/package.json +3 -2
- package/docs/startup/build/build.mdx +0 -199
- package/docs/startup/build/vite.mdx +0 -255
- package/docs/startup/build/webpack.mdx +0 -117
- package/docs/startup/start/start.mdx +0 -48
- package/docs/startup/start/vite.mdx +0 -90
- package/docs/startup/start/webpack.mdx +0 -39
|
@@ -8,7 +8,7 @@ sidebar_position: 0
|
|
|
8
8
|
### [@servicetitan/startup](./startup/)
|
|
9
9
|
|
|
10
10
|
- `mfe-publish` now throws an error instead of silently succeeding when the branch is not configured for publishing (without `--force`).
|
|
11
|
-
If your CI workflow calls `mfe-publish` on an
|
|
11
|
+
If your CI workflow calls `mfe-publish` on an unrecognized branch, either add the branch to the `web-component.branches` configuration in `package.json`, or pass `--force` to bypass the check.
|
|
12
12
|
|
|
13
13
|
## v35.0.0
|
|
14
14
|
|
|
@@ -46,7 +46,7 @@ This breaking change affects local development, even if you do not update the `@
|
|
|
46
46
|
|
|
47
47
|
Removed support for hard-coded npm tokens in `.npmrc` files. The new `startup install` removes hard-coded authentication tokens from project `.npmrc` files and, in development environments, automatically adds a token to npm's per-user configuration that grants access to ServiceTitan's private packages.
|
|
48
48
|
|
|
49
|
-
Projects that previously relied on hard-coded tokens must update their Github and Teamcity workflows to instead use the organization secret as described in the [startup install documentation](./install#configuring-npm-token-in-ci):
|
|
49
|
+
Projects that previously relied on hard-coded tokens must update their Github and Teamcity workflows to instead use the organization secret as described in the [startup install documentation](./startup/install#configuring-npm-token-in-ci):
|
|
50
50
|
|
|
51
51
|
- Option 1: Inject the organization secret into `.npmrc`.
|
|
52
52
|
- Option 2: Configure `.npmrc` to get the organization secret from an environment variable.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: AI Marketplace
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import Tabs from '@theme/Tabs';
|
|
6
|
+
import TabItem from '@theme/TabItem';
|
|
7
|
+
|
|
8
|
+
The uikit AI Marketplace distributes AI skills to ServiceTitan repositories via the [Claude Code Plugin System](https://code.claude.com/docs/en/plugin-marketplaces).
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
<Tabs
|
|
13
|
+
defaultValue="claude-code"
|
|
14
|
+
values={[
|
|
15
|
+
{ label: 'Claude Code', value: 'claude-code' },
|
|
16
|
+
{ label: 'Cursor', value: 'cursor' },
|
|
17
|
+
{ label: 'Codex & other agents', value: 'codex' },
|
|
18
|
+
]}
|
|
19
|
+
>
|
|
20
|
+
<TabItem value="claude-code">
|
|
21
|
+
|
|
22
|
+
### Manual install
|
|
23
|
+
|
|
24
|
+
From within Claude Code:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
/plugin marketplace add servicetitan/uikit
|
|
28
|
+
/plugin install uikit@uikit-marketplace
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Or from the terminal:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
claude plugin marketplace add servicetitan/uikit
|
|
35
|
+
claude plugin install uikit@uikit-marketplace
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Auto-discovery
|
|
39
|
+
|
|
40
|
+
Add to your repo's `.claude/settings.json` to auto-install on Claude Code startup:
|
|
41
|
+
|
|
42
|
+
```json title=".claude/settings.json"
|
|
43
|
+
{
|
|
44
|
+
"extraKnownMarketplaces": {
|
|
45
|
+
"uikit-marketplace": {
|
|
46
|
+
"source": { "source": "github", "repo": "servicetitan/uikit" }
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"enabledPlugins": { "uikit@uikit-marketplace": true }
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
</TabItem>
|
|
54
|
+
<TabItem value="cursor">
|
|
55
|
+
|
|
56
|
+
Cursor auto-imports Claude Code plugins when the **"Include third-party Plugins, Skills, and other configs"** toggle is enabled under **Cursor Settings > Rules, Skills, Subagents**.
|
|
57
|
+
|
|
58
|
+
Once the Claude Code plugin is installed on your machine (see Claude Code tab), Cursor picks up the skills automatically. No separate install needed.
|
|
59
|
+
|
|
60
|
+
Alternatively, see `Codex & other agents` tab on how to install plugins and skills without Claude Code.
|
|
61
|
+
|
|
62
|
+
</TabItem>
|
|
63
|
+
<TabItem value="codex">
|
|
64
|
+
|
|
65
|
+
Install the full plugin (skills, hooks, agents, etc.) via `npx plugins`:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npx plugins add servicetitan/uikit
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Or install individual skills via `npx skills`:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npx skills add servicetitan/uikit --skill spell-check
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
These work for any agent that supports the [Open Plugin](https://open-plugins.com/) or [Agent Skills](https://agentskills.io/) standards.
|
|
78
|
+
|
|
79
|
+
</TabItem>
|
|
80
|
+
</Tabs>
|
|
81
|
+
|
|
82
|
+
## Available Plugins
|
|
83
|
+
|
|
84
|
+
### `uikit`
|
|
85
|
+
|
|
86
|
+
Shared uikit skills for ServiceTitan repos.
|
|
87
|
+
|
|
88
|
+
#### Skills
|
|
89
|
+
|
|
90
|
+
| Name | Description |
|
|
91
|
+
| :------------------ | :------------------------------------------------------------------------------------------------------- |
|
|
92
|
+
| `spell-check` | Check for spelling errors in code changes |
|
|
93
|
+
| `switching-to-pnpm` | Migrate a project from npm to pnpm (see [migration guide](/docs/frontend/switching-to-pnpm)) |
|
package/docs/eslint-config.mdx
CHANGED
|
@@ -18,8 +18,12 @@ title: ESLint & Stylelint configurations
|
|
|
18
18
|
|
|
19
19
|
### ESLint
|
|
20
20
|
|
|
21
|
+
The ESLint config bundles rules from ESLint core, `eslint-plugin-import`, `eslint-plugin-react`, `eslint-plugin-react-hooks`, `typescript-eslint`, and Prettier, along with the ServiceTitan rules from `@servicetitan/eslint-plugin`. Pick the entry point that matches your repo layout.
|
|
22
|
+
|
|
21
23
|
#### In the Lerna project
|
|
22
24
|
|
|
25
|
+
Use `mono` in a workspace-based monorepo. It discovers every workspace package at lint time and wires up `import/no-extraneous-dependencies` for each one, so imports are checked against both the package's own `package.json` and the repo root.
|
|
26
|
+
|
|
23
27
|
```js title="eslint.config.js"
|
|
24
28
|
import { defineConfig } from 'eslint/config';
|
|
25
29
|
import mono from '@servicetitan/eslint-config/mono';
|
|
@@ -29,6 +33,8 @@ export default defineConfig(mono);
|
|
|
29
33
|
|
|
30
34
|
#### Without Lerna
|
|
31
35
|
|
|
36
|
+
Use `single` in a standalone project. It points the TypeScript parser at `./tsconfig.json` and skips the per-package dependency check.
|
|
37
|
+
|
|
32
38
|
```js title="eslint.config.js"
|
|
33
39
|
import { defineConfig } from 'eslint/config';
|
|
34
40
|
import single from '@servicetitan/eslint-config/single';
|
|
@@ -36,8 +42,80 @@ import single from '@servicetitan/eslint-config/single';
|
|
|
36
42
|
export default defineConfig(single);
|
|
37
43
|
```
|
|
38
44
|
|
|
45
|
+
### QA lint rules
|
|
46
|
+
|
|
47
|
+
The `qa` config adds lint rules that help keep user interfaces testable by automated suites. Apply it to component and feature files; test files themselves do not need it.
|
|
48
|
+
|
|
49
|
+
`qa` accepts a single optional options object of type `Omit<Linter.Config, 'name' \| 'plugins'>`.
|
|
50
|
+
|
|
51
|
+
#### Common options
|
|
52
|
+
|
|
53
|
+
The options object accepts any property from the ESLint [Linter.Config](https://eslint.org/docs/latest/use/configure/configuration-files#configuration-objects) type. The properties below are the ones you are most likely to set.
|
|
54
|
+
|
|
55
|
+
| Name | Type | Description |
|
|
56
|
+
| :-------- | :--------- | :---------------------------------------------------------------------- |
|
|
57
|
+
| `files` | `string[]` | (optional) Glob patterns for files to lint. Defaults to `['**/*.tsx']`. |
|
|
58
|
+
| `rules` | `object` | (optional) Rule overrides, merged with the default rules. |
|
|
59
|
+
| `ignores` | `string[]` | (optional) Glob patterns for files to exclude. |
|
|
60
|
+
|
|
61
|
+
#### Rules
|
|
62
|
+
|
|
63
|
+
##### `@servicetitan/qa/require-qa-attr`
|
|
64
|
+
|
|
65
|
+
Automated test suites such as Cypress target interactive elements through dedicated selector attributes like `data-cy`. When these attributes are missing, tests have to rely on brittle selectors (class names, text content, DOM position) that break whenever surrounding markup changes.
|
|
66
|
+
|
|
67
|
+
This rule requires a QA selector attribute on interactive elements so tests can target them reliably as the UI evolves. It reports an error in three cases.
|
|
68
|
+
|
|
69
|
+
**1. Interactive Anvil2 components.** The rule tracks imports from `@servicetitan/anvil2` and `@servicetitan/anvil2/beta`, then flags any of these components when rendered without a QA attribute. Aliased imports (for example, `Button as Btn`) resolve to the original export name before the check runs.
|
|
70
|
+
|
|
71
|
+
| Category | Components |
|
|
72
|
+
| :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
73
|
+
| Form inputs | `Checkbox`, `Radio`, `Switch`, `TextField`, `Textarea`, `NumberField`, `SearchField`, `TimeField`, `DateField`, `DateFieldRange`, `DateFieldSingle`, `DateFieldYearless`, `Calendar`, `Pagination` |
|
|
74
|
+
| Selection | `SelectCard`, `SegmentedControl`, `DaysOfTheWeek`, `SelectTrigger`, `Combobox.SearchField`, `Combobox.SelectTrigger` |
|
|
75
|
+
| Actions | `Button`, `ButtonToggle`, `Link`, `Toolbar.Button`, `Toolbar.ButtonToggle`, `Toolbar.ButtonLink`, `Toolbar.Select` |
|
|
76
|
+
| Navigation | `SideNavLink`, `SideNavCollapsible`, `SideNav.Link`, `SideNav.Collapsible`, `BreadcrumbsLink`, `Breadcrumbs.Link`, `Stepper.PrevButton`, `Stepper.NextButton`, `Stepper.Step` |
|
|
77
|
+
| Overlays, menus | `Menu`, `Menu.Item`, `Popover.Button`, `Popover.Close`, `Tab.Button`, `EditCard`, `Chip` |
|
|
78
|
+
|
|
79
|
+
**2. Direct children of `Tooltip.Trigger` or `Popover.Trigger`.** The trigger forwards interactions to its child, so the attribute belongs on the child element rather than the trigger itself.
|
|
80
|
+
|
|
81
|
+
**3. Any JSX element with an `onClick` handler.** This catches custom interactive elements that fall outside the Anvil2 component list, including native elements such as `div` or `span` that receive click handlers.
|
|
82
|
+
|
|
83
|
+
The rule skips elements that use JSX spread (`{...props}`), since the QA attribute or `onClick` handler may come from the spread object.
|
|
84
|
+
|
|
85
|
+
###### Options
|
|
86
|
+
|
|
87
|
+
| Name | Type | Default | Description |
|
|
88
|
+
| :----------- | :--------- | :----------- | :------------------------------------------------------------------------------------- |
|
|
89
|
+
| `attributes` | `string[]` | `['data-cy']` | Acceptable attribute names. At least one must be present on the flagged element. |
|
|
90
|
+
|
|
91
|
+
The example below shows two ways to enable the rule. The first call uses the defaults and requires `data-cy`. The second call passes a `rules` override so the rule accepts `data-testid` instead, which is useful for projects that already use a different attribute convention.
|
|
92
|
+
|
|
93
|
+
```js title="eslint.config.js"
|
|
94
|
+
import { defineConfig } from 'eslint/config';
|
|
95
|
+
import mono from '@servicetitan/eslint-config/mono';
|
|
96
|
+
import qa from '@servicetitan/eslint-config/qa';
|
|
97
|
+
|
|
98
|
+
// Default usage requires data-cy
|
|
99
|
+
export default defineConfig([mono, qa()]);
|
|
100
|
+
|
|
101
|
+
// Accept data-testid in place of data-cy
|
|
102
|
+
export default defineConfig([
|
|
103
|
+
mono,
|
|
104
|
+
qa({
|
|
105
|
+
rules: {
|
|
106
|
+
'@servicetitan/qa/require-qa-attr': ['error', { attributes: ['data-testid'] }],
|
|
107
|
+
},
|
|
108
|
+
}),
|
|
109
|
+
]);
|
|
110
|
+
```
|
|
111
|
+
|
|
39
112
|
### Stylelint
|
|
40
113
|
|
|
114
|
+
The Stylelint config extends [`stylelint-config-standard`](https://github.com/stylelint/stylelint-config-standard) and [`stylelint-prettier`](https://github.com/prettier/stylelint-prettier), applies the matching standard extensions for `.scss` and `.less` files, and adds two ServiceTitan rules:
|
|
115
|
+
|
|
116
|
+
- `@servicetitan/function-url-no-absolute` rejects absolute paths inside `url()` values.
|
|
117
|
+
- `@servicetitan/use-tokens` requires design tokens from `@servicetitan/tokens` for colors, spacing, border radii, font families and weights, line heights, opacities, type scales, and z-indexes, instead of raw values.
|
|
118
|
+
|
|
41
119
|
```json title=".stylelintrc.json"
|
|
42
120
|
{
|
|
43
121
|
"extends": ["@servicetitan/stylelint-config"]
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ESLint plugins
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
#### [CHANGELOG (@servicetitan/eslint-plugin)](https://github.com/servicetitan/uikit/blob/master/packages/eslint-plugin/CHANGELOG.md)
|
|
6
|
+
|
|
7
|
+
`@servicetitan/eslint-plugin` contains custom ESLint rules for React, MobX, TypeScript, and testing best practices used across ServiceTitan frontend projects.
|
|
8
|
+
Rules are included in `@servicetitan/eslint-config` by default (except the QA rules), but can also be used separately if you want to apply them selectively.
|
|
9
|
+
|
|
10
|
+
## Rules
|
|
11
|
+
|
|
12
|
+
### Base rules
|
|
13
|
+
|
|
14
|
+
#### `@servicetitan/no-async-in-foreach`
|
|
15
|
+
|
|
16
|
+
Disallows passing async callbacks to `Array.forEach`. Async callbacks in `forEach` cause unhandled promise rejections because `forEach` ignores the returned promise. Use `reduce` for sequential execution or `Promise.all` with `.map` for parallel execution instead.
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
// Bad
|
|
20
|
+
items.forEach(async item => {
|
|
21
|
+
await doSomething(item);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Good
|
|
25
|
+
await items.reduce(async (promise, item) => {
|
|
26
|
+
await promise;
|
|
27
|
+
await doSomething(item);
|
|
28
|
+
}, Promise.resolve());
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
#### `@servicetitan/use-declare-with-decorators`
|
|
32
|
+
|
|
33
|
+
Requires the `declare` keyword when using `@injectDependency` or `@koObservableToMobx` decorators on class fields. Without `declare`, TypeScript emits a class field initializer that overwrites the decorator's effect.
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
// Bad
|
|
37
|
+
class MyService {
|
|
38
|
+
@injectDependency(OtherService)
|
|
39
|
+
private otherService: OtherService;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Good
|
|
43
|
+
class MyService {
|
|
44
|
+
@injectDependency(OtherService)
|
|
45
|
+
declare private otherService: OtherService;
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
### MobX rules
|
|
52
|
+
|
|
53
|
+
#### `@servicetitan/mobx/no-abstract-decorators`
|
|
54
|
+
|
|
55
|
+
Disallows MobX decorators (`@observable`, `@action`, `@computed`, `@override`) on abstract class fields or methods. Abstract members have no implementation, so MobX decorators have no effect on them.
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
// Bad
|
|
59
|
+
abstract class BaseStore {
|
|
60
|
+
@observable abstract count: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Good
|
|
64
|
+
abstract class BaseStore {
|
|
65
|
+
abstract count: number;
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### `@servicetitan/mobx/use-makeObservable-with-decorators`
|
|
70
|
+
|
|
71
|
+
Requires a `makeObservable(this)` call in the constructor when a class uses MobX decorators. Without it, decorators are not activated at runtime.
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
// Bad
|
|
75
|
+
class CounterStore {
|
|
76
|
+
@observable count = 0;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Good
|
|
80
|
+
class CounterStore {
|
|
81
|
+
@observable count = 0;
|
|
82
|
+
|
|
83
|
+
constructor() {
|
|
84
|
+
makeObservable(this);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
### React rules
|
|
92
|
+
|
|
93
|
+
#### `@servicetitan/react/destructure-default-import`
|
|
94
|
+
|
|
95
|
+
Disallows importing the React default export (`import React from 'react'` or `import * as React from 'react'`). With modern JSX transform, the default import is unnecessary. Import only what you need.
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
// Bad
|
|
99
|
+
import React from 'react';
|
|
100
|
+
import * as React from 'react';
|
|
101
|
+
|
|
102
|
+
// Good
|
|
103
|
+
import { useState, useEffect } from 'react';
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
#### `@servicetitan/react/no-qualified-type`
|
|
107
|
+
|
|
108
|
+
Disallows using React types via the qualified name `React.XXX` in type annotations. Import specific types from `react` instead.
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
// Bad
|
|
112
|
+
const MyComponent: React.FC = () => null;
|
|
113
|
+
const ref: React.RefObject<HTMLDivElement> = createRef();
|
|
114
|
+
|
|
115
|
+
// Good
|
|
116
|
+
import { FC, RefObject } from 'react';
|
|
117
|
+
const MyComponent: FC = () => null;
|
|
118
|
+
const ref: RefObject<HTMLDivElement> = createRef();
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
### QA rules
|
|
124
|
+
|
|
125
|
+
#### `@servicetitan/qa/require-qa-attr`
|
|
126
|
+
|
|
127
|
+
Requires a QA selector attribute on interactive Anvil2 components and any JSX element with an `onClick` handler, so automated tests can reliably select them.
|
|
128
|
+
|
|
129
|
+
The rule tracks imports from `@servicetitan/anvil2` and `@servicetitan/anvil2/beta`. Elements with JSX spread attributes are skipped (the attribute may come from the spread).
|
|
130
|
+
|
|
131
|
+
By default the rule expects `data-cy`. Use the `attributes` option to accept a different attribute or a list of alternatives (the rule passes if any one is present):
|
|
132
|
+
|
|
133
|
+
```js
|
|
134
|
+
'@servicetitan/qa/require-qa-attr': ['error', { attributes: ['data-testid'] }]
|
|
135
|
+
// or accept either:
|
|
136
|
+
'@servicetitan/qa/require-qa-attr': ['error', { attributes: ['data-cy', 'data-testid'] }]
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Components that always require a QA selector attribute** (when imported from Anvil2):
|
|
140
|
+
|
|
141
|
+
| Category | Components |
|
|
142
|
+
| :----------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
143
|
+
| Form inputs | `Checkbox`, `Radio`, `Switch`, `TextField`, `Textarea`, `NumberField`, `SearchField`, `TimeField`, `DateField`, `DateFieldRange`, `DateFieldSingle`, `DateFieldYearless`, `Calendar`, `Pagination` |
|
|
144
|
+
| Selection | `SelectCard`, `SegmentedControl`, `DaysOfTheWeek`, `SelectTrigger` |
|
|
145
|
+
| Actions | `Button`, `ButtonToggle`, `Link` |
|
|
146
|
+
| Complex | `Menu`, `EditCard`, `Chip` |
|
|
147
|
+
| Standalone | `SideNavLink`, `SideNavCollapsible`, `BreadcrumbsLink` |
|
|
148
|
+
| Member expressions | `Popover.Button`, `Popover.Close`, `Menu.Item`, `Tab.Button`, `SideNav.Link`, `SideNav.Collapsible`, `Breadcrumbs.Link`, `Stepper.PrevButton`, `Stepper.NextButton`, `Stepper.Step`, `Toolbar.Button`, `Toolbar.ButtonToggle`, `Toolbar.ButtonLink`, `Toolbar.Select`, `Combobox.SearchField`, `Combobox.SelectTrigger` |
|
|
149
|
+
|
|
150
|
+
**Trigger children**: The direct child of `Tooltip.Trigger` or `Popover.Trigger` must also have a QA selector attribute, because automated tests interact with the child element.
|
|
151
|
+
|
|
152
|
+
**`onClick` fallback**: Any JSX element (including native DOM elements) with an `onClick` prop must have a QA selector attribute.
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
// Bad
|
|
156
|
+
import { Button, Tooltip } from '@servicetitan/anvil2';
|
|
157
|
+
|
|
158
|
+
<Button onClick={save} />
|
|
159
|
+
<Tooltip.Trigger>
|
|
160
|
+
<span>Hover me</span>
|
|
161
|
+
</Tooltip.Trigger>
|
|
162
|
+
<div onClick={handleClick} />
|
|
163
|
+
|
|
164
|
+
// Good
|
|
165
|
+
import { Button, Tooltip } from '@servicetitan/anvil2';
|
|
166
|
+
|
|
167
|
+
<Button data-cy="save-button" onClick={save} />
|
|
168
|
+
<Tooltip.Trigger>
|
|
169
|
+
<span data-cy="tooltip-trigger">Hover me</span>
|
|
170
|
+
</Tooltip.Trigger>
|
|
171
|
+
<div data-cy="clickable-area" onClick={handleClick} />
|
|
172
|
+
```
|
package/docs/install.mdx
CHANGED
|
@@ -7,7 +7,7 @@ import TabItem from '@theme/TabItem';
|
|
|
7
7
|
|
|
8
8
|
#### [CHANGELOG (@servicetitan/install)](https://github.com/servicetitan/uikit/blob/master/packages/install/CHANGELOG.md)
|
|
9
9
|
|
|
10
|
-
`@servicetitan/install` is a lightweight wrapper
|
|
10
|
+
`@servicetitan/install` is a lightweight wrapper that automatically configures access to private ServiceTitan packages and installs dependencies using your project's package manager. Use it instead of running your package manager directly to guarantee that all packages are installed correctly and any necessary pre- and post-installation steps are performed.
|
|
11
11
|
|
|
12
12
|
```sh
|
|
13
13
|
npx --yes @servicetitan/install
|
|
@@ -22,12 +22,73 @@ The dedicated `@servicetitan/install` package performs a single task and runs qu
|
|
|
22
22
|
And because it has no runtime dependencies, also eliminates risks from third-party changes.
|
|
23
23
|
:::
|
|
24
24
|
|
|
25
|
+
## Package Manager Support
|
|
26
|
+
|
|
27
|
+
`@servicetitan/install` supports both **npm** and **pnpm**. It reads the `cli.packageManager` field in your project's `package.json` to determine which package manager to use. When the field is absent, it defaults to npm.
|
|
28
|
+
|
|
29
|
+
```json title="package.json"
|
|
30
|
+
{
|
|
31
|
+
"cli": {
|
|
32
|
+
"packageManager": "pnpm"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
:::note
|
|
38
|
+
The `npx --yes @servicetitan/install` command works regardless of which package manager your project uses. `npx` is only used to download and run the install CLI itself; the actual dependency installation uses whichever package manager is configured.
|
|
39
|
+
:::
|
|
40
|
+
|
|
41
|
+
### pnpm support
|
|
42
|
+
|
|
43
|
+
✨ New in **[INSERT-VERSION-HERE]** ✨
|
|
44
|
+
|
|
45
|
+
`@servicetitan/startup` includes experimental pnpm support. See the [Switching to pnpm](/docs/frontend/switching-to-pnpm) migration guide to get started.
|
|
46
|
+
|
|
47
|
+
:::caution
|
|
48
|
+
pnpm support is experimental. It has been validated against several internal repos but may require adjustments for your project. Please report any issues you encounter.
|
|
49
|
+
:::
|
|
50
|
+
|
|
25
51
|
## Options
|
|
26
52
|
|
|
27
|
-
| Option
|
|
28
|
-
|
|
|
29
|
-
| `--
|
|
30
|
-
| `--
|
|
53
|
+
| Option | Description |
|
|
54
|
+
| :------------------- | :--------------------------------------------------------------------------------------------------------------------- |
|
|
55
|
+
| `--allow-scripts` | Additional packages allowed to run install scripts. Accepts a comma-separated list or can be specified multiple times. |
|
|
56
|
+
| `--no-allow-scripts` | Disable all install scripts, including the default allowlist. |
|
|
57
|
+
| `--no-token` | Only install dependencies. Don't configure the npm authentication token. |
|
|
58
|
+
| `--token` | Only configure the npm authentication token. Don't install dependencies. |
|
|
59
|
+
| `--fix` | Update the lock file without installing packages. |
|
|
60
|
+
|
|
61
|
+
## Install Script Protection (Preview)
|
|
62
|
+
|
|
63
|
+
In npm projects `@servicetitan/install` runs all install scripts by default. A future release will flip this default to block untrusted packages from running any install script (`preinstall`, `install`, and `postinstall`), protecting against supply chain attacks. To help teams prepare, `@servicetitan/install` warns about installed packages with untrusted install scripts:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
WARNING: The following packages have untrusted install scripts.
|
|
67
|
+
Review and add trusted packages to --allow-scripts:
|
|
68
|
+
- some-package@1.2.3
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
:::caution
|
|
72
|
+
Audit each package in the warning. Verify it is trustworthy or remove the dependency.
|
|
73
|
+
:::
|
|
74
|
+
|
|
75
|
+
:::tip
|
|
76
|
+
Not sure what an install script does? Ask Claude: "What does the install script for _X_ do?". Claude reads the package source and summarizes the behavior, so you can decide whether to trust it.
|
|
77
|
+
:::
|
|
78
|
+
|
|
79
|
+
To disable all install scripts, including the default allowlist, use `--no-allow-scripts`:
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
npx --yes @servicetitan/install --no-allow-scripts
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
:::tip
|
|
86
|
+
`@servicetitan/install` checks for untrusted install scripts when the lockfile changes. If you see the warning after adding a new dependency, verify the package is trustworthy or remove it.
|
|
87
|
+
:::
|
|
88
|
+
|
|
89
|
+
### Pnpm projects
|
|
90
|
+
|
|
91
|
+
pnpm blocks install scripts by default and emits a "Ignored build scripts" warning for packages whose scripts were skipped and must be approved.
|
|
31
92
|
|
|
32
93
|
## Configuring NPM Token in Development
|
|
33
94
|
|
|
@@ -79,6 +140,10 @@ RUN npm run build
|
|
|
79
140
|
</TabItem>
|
|
80
141
|
</Tabs>
|
|
81
142
|
|
|
143
|
+
:::tip
|
|
144
|
+
This step uses `npm config set` regardless of your project's package manager. Npm and pnpm read the same configuration for registry authentication.
|
|
145
|
+
:::
|
|
146
|
+
|
|
82
147
|
### Option 2: Use environment variable
|
|
83
148
|
|
|
84
149
|
:::caution
|
|
@@ -41,6 +41,8 @@ and automatically [provides a store](#use-flags-in-mobx-store) that allows flag
|
|
|
41
41
|
| `context` | `object` | (Optional) Context for targeting rules. Defaults to anonymous user. Use LaunchDarkly's [`identify`](https://docs.launchdarkly.com/sdk/features/identify) method to change the context after initialization. |
|
|
42
42
|
| `waitForInitialization` | `boolean` | (Optional) Whether or not to wait until flags values are available before rendering children. Defaults to `true`. |
|
|
43
43
|
|
|
44
|
+
To configure additional [`LDOptions`](https://launchdarkly.github.io/js-client-sdk/interfaces/LDOptions.html) (for example, inspectors that forward flag evaluations to Datadog RUM), pass them to [`LDServiceProvider`](#ldserviceprovider) at the host level. They apply to every nested `LDProvider`.
|
|
45
|
+
|
|
44
46
|
:::caution
|
|
45
47
|
When a `context` is provided, only the initial value takes affect. Subsequent calls with the same client-side ID reuse the client that was created with the initial context.
|
|
46
48
|
|
|
@@ -142,9 +144,10 @@ export const HostApp: FC = () => {
|
|
|
142
144
|
|
|
143
145
|
#### Props
|
|
144
146
|
|
|
145
|
-
| Name | Type | Description
|
|
146
|
-
| :------------ | :-------------- |
|
|
147
|
-
| `application` | `LDApplication`
|
|
147
|
+
| Name | Type | Description |
|
|
148
|
+
| :------------ | :-------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
149
|
+
| `application` | `LDApplication` | (Optional) Application and version details to provide to LaunchDarkly. |
|
|
150
|
+
| `options` | `Omit<LDOptions, 'application'>` | (Optional) Default [`LDOptions`](https://launchdarkly.github.io/js-client-sdk/interfaces/LDOptions.html) applied to every [`LDProvider`](#ldprovider) within the host. Set [`application`](#application) via the dedicated prop. |
|
|
148
151
|
|
|
149
152
|
#### LDApplication
|
|
150
153
|
|
|
@@ -158,7 +161,7 @@ export interface LDApplication {
|
|
|
158
161
|
Use `application` to make the application id and version available for flag evaluations in LaunchDarkly. Every LaunchDarkly client created by [LDProvider](#ldprovider) (within the host and within MFEs) will automatically pass through the application metadata to LaunchDarkly.
|
|
159
162
|
|
|
160
163
|
:::caution
|
|
161
|
-
`LDServiceProvider` should not be used in MFEs. If an MFE does use `LDServiceProvider`, the host's `application`
|
|
164
|
+
`LDServiceProvider` should not be used in MFEs. If an MFE does use `LDServiceProvider`, the host's `application` and `options` override the MFE's.
|
|
162
165
|
:::
|
|
163
166
|
|
|
164
167
|
#### Example
|
|
@@ -177,6 +180,7 @@ The `LDService` interface enables [headless bundles](./microfrontends/developing
|
|
|
177
180
|
export interface LDService {
|
|
178
181
|
getClient: (config: ClientConfig) => LDClient;
|
|
179
182
|
application?: LDApplication;
|
|
183
|
+
options?: Omit<LDOptions, 'application'>;
|
|
180
184
|
}
|
|
181
185
|
|
|
182
186
|
export interface ClientConfig {
|
|
@@ -200,6 +204,10 @@ Returns an `LDClient` instance configured with the following parameters.
|
|
|
200
204
|
|
|
201
205
|
Optional [LDApplication](#ldapplication) that was passed to [LDServiceProvider](#ldserviceprovider).
|
|
202
206
|
|
|
207
|
+
#### options
|
|
208
|
+
|
|
209
|
+
Optional default `LDOptions` (excluding `application`) that were passed to [LDServiceProvider](#ldserviceprovider). Applied to every [LDProvider](#ldprovider) within the host.
|
|
210
|
+
|
|
203
211
|
### FeatureFlagStore
|
|
204
212
|
|
|
205
213
|
`LDProvider` automatically provides a `FeatureFlagStore` that allows you to access
|
|
@@ -271,6 +279,43 @@ Render component when flag is on, and render other component when flag is turned
|
|
|
271
279
|
<WithFeatureFlag flagKey={flagKey} on={() => 'Flag is ON'} off={() => 'Flag is OFF'} />
|
|
272
280
|
```
|
|
273
281
|
|
|
282
|
+
### createDatadogInspector
|
|
283
|
+
|
|
284
|
+
`createDatadogInspector` creates an inspector that forwards feature flag evaluations to Datadog RUM via [`datadogRum.addFeatureFlagEvaluation`](https://docs.datadoghq.com/real_user_monitoring/feature_flag_tracking/?tab=browserrum). Register it once at the host via [`LDServiceProvider`](#ldserviceprovider)'s `options.inspectors`; every nested `LDProvider` picks it up automatically.
|
|
285
|
+
|
|
286
|
+
This helper requires `@datadog/browser-rum` as a peer dependency. It is available as a subpath import so it is only loaded when used:
|
|
287
|
+
|
|
288
|
+
```tsx
|
|
289
|
+
import { createDatadogInspector } from '@servicetitan/launchdarkly-service/datadog-rum';
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
#### Options
|
|
293
|
+
|
|
294
|
+
| Name | Type | Description |
|
|
295
|
+
| :----- | :------- | :--------------------------------------------------------------------------------------------------- |
|
|
296
|
+
| `name` | `string` | (Optional) Inspector name reported in LaunchDarkly logs. Defaults to `datadog-feature-flag-tracking`. |
|
|
297
|
+
|
|
298
|
+
#### Example
|
|
299
|
+
|
|
300
|
+
```tsx title="host-app.tsx"
|
|
301
|
+
import { LDServiceProvider } from '@servicetitan/launchdarkly-service';
|
|
302
|
+
import { createDatadogInspector } from '@servicetitan/launchdarkly-service/datadog-rum';
|
|
303
|
+
import { FC, StrictMode } from 'react';
|
|
304
|
+
|
|
305
|
+
const datadogInspector = createDatadogInspector();
|
|
306
|
+
|
|
307
|
+
export const HostApp: FC = () => (
|
|
308
|
+
<StrictMode>
|
|
309
|
+
<LDServiceProvider
|
|
310
|
+
application={{ id: 'app', version: '71' }}
|
|
311
|
+
options={{ inspectors: [datadogInspector] }}
|
|
312
|
+
>
|
|
313
|
+
{...}
|
|
314
|
+
</LDServiceProvider>
|
|
315
|
+
</StrictMode>
|
|
316
|
+
);
|
|
317
|
+
```
|
|
318
|
+
|
|
274
319
|
## Examples
|
|
275
320
|
|
|
276
321
|
### Using flag values in React component
|
package/docs/lazy-module.mdx
CHANGED
|
@@ -42,7 +42,7 @@ export const DispatchModule: React.FC = () => <LazyDispatch />;
|
|
|
42
42
|
| :----------------------- | :---------------------------------------- | :----------------------------------------------------------------- | :------------------------------------------------------------- |
|
|
43
43
|
| `loader` | `() => Promise<React.ComponentType<any>>` | Function doing dynamic import of a module | Yes |
|
|
44
44
|
| `name` | `string` | Module name | Yes |
|
|
45
|
-
| `loadingComponent` | `React.ComponentType<any>` | Component to display while loading is in progress
|
|
45
|
+
| `loadingComponent` | `React.ComponentType<any>` | Component to display while loading is in progress | No, defaults to `DefaultLoading` |
|
|
46
46
|
| `loadingErrorComponent` | `React.ComponentType<any>` | Component to display if module loading fails | No, defaults to `DefaultLoadingError` |
|
|
47
47
|
| `errorFallbackComponent` | `React.ComponentType<any>` | Component to pass to `@servicetitan/error-boundary` module wrapper | No, uses default component from `@servicetitan/error-boundary` |
|
|
48
48
|
|
|
@@ -6,7 +6,7 @@ A host is an application, or MFE, that uses [`Loader`](../web-components/loader)
|
|
|
6
6
|
|
|
7
7
|
## Configuration
|
|
8
8
|
|
|
9
|
-
Set `cli.expose-shared-dependencies` to `true` in the application's `package.json`.
|
|
9
|
+
Set `cli.webpack.expose-shared-dependencies` to `true` in the application's `package.json`.
|
|
10
10
|
|
|
11
11
|
:::caution
|
|
12
12
|
`expose-shared-dependencies` only applies to applications. MFEs that load other MFEs do not need this setting or any additional configuration.
|
|
@@ -15,15 +15,13 @@ Set `cli.expose-shared-dependencies` to `true` in the application's `package.jso
|
|
|
15
15
|
```json title="package.json"
|
|
16
16
|
{
|
|
17
17
|
"cli": {
|
|
18
|
-
"
|
|
18
|
+
"webpack": {
|
|
19
|
+
"expose-shared-dependencies": true
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
```
|
|
22
24
|
|
|
23
|
-
:::note
|
|
24
|
-
In versions before **[INSERT-VERSION-HERE]**, this setting was under `cli.webpack.expose-shared-dependencies`. The old location still works for backward compatibility.
|
|
25
|
-
:::
|
|
26
|
-
|
|
27
25
|
### Design system
|
|
28
26
|
|
|
29
27
|
If the host uses `@servicetitan/design-system` remove all imports of design system styles from the code; `startup` handles that automatically. Alternatively, to customize the design system styles, move the imports to a file named `design-system.css` in the root directory of the application's source folder (the `rootDir` in `tsconfig.json`). E.g.,
|