@servicetitan/docs-anvil-uikit-contrib 25.0.1-canary.0 → 25.4.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/README.md +61 -0
- package/docs/form-state.mdx +0 -2
- package/docs/notifications-center.mdx +58 -56
- package/docs/table.mdx +3 -1
- package/package.json +4 -3
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# `@servicetitan/docs-anvil-uikit-contrib`
|
|
2
|
+
|
|
3
|
+
This package contains documentation for Frontend Community packages, published at https://docs.st.dev.
|
|
4
|
+
|
|
5
|
+
<!---
|
|
6
|
+
## Preview changes locally
|
|
7
|
+
|
|
8
|
+
To preview changes use the local `docusaurus` project. See the `docusaurus` README for instructions.
|
|
9
|
+
-->
|
|
10
|
+
|
|
11
|
+
## Preview changes in situ
|
|
12
|
+
|
|
13
|
+
Use `yalc` to preview changes within the entire ServiceTitan Engineering documentation.
|
|
14
|
+
|
|
15
|
+
1. Install the `yalc` package globally
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
$ npm i yalc -g
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
2. Build the `anvil-uikit-contrib` packages
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
$ cd <path-to-anvil-uikit-contrib>
|
|
25
|
+
$ npm run build
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
3. Run `yalc publish` in the `docs` package folder to publish the package locally
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
$ cd .\packages\docs
|
|
32
|
+
$ yalc publish
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
4. Run `yalc add @servicetitan/docs-anvil-uikit-contrib` in the servicetitan `docs` repo to use the locally published package
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
$ cd <path-to-servicetitan-docs>
|
|
39
|
+
$ yalc add @servicetitan/docs-anvil-uikit-contrib
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
5. Update dependencies and start Docusaurus
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
$ npm i
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
6. Start Docusaurus
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
$ npm start
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
This opens the documentation in a browser window.
|
|
55
|
+
|
|
56
|
+
To see further changes without having to restart the server, run `yalc push` in the anvil-uikit-contrib `docs` package folder
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
$ cd <path-to-anvil-uikit-contrib>/packages/docs
|
|
60
|
+
$ yalc push
|
|
61
|
+
```
|
package/docs/form-state.mdx
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
ServerCustomExample,
|
|
19
19
|
} from '@servicetitan/notifications/dist/demo';
|
|
20
20
|
|
|
21
|
-
import { CodeDemo } from '@site/src/components/code-demo';
|
|
21
|
+
import { CodeDemo, DemoCodeBlock } from '@site/src/components/code-demo';
|
|
22
22
|
|
|
23
23
|
There're a lot of cases when a user should be notified in the result of various events. It could be from a simple one-time notification about the result of the network request to informing about the state of a complex long-running process launched on the worker.
|
|
24
24
|
|
|
@@ -92,40 +92,42 @@ Notification Center will automatically show notifications to the user sent from
|
|
|
92
92
|
|
|
93
93
|
Most of the cases could be easily covered with default notification type and `DefaultPayload` container, it's also the preferable way.
|
|
94
94
|
|
|
95
|
-
export const defaultServerCode =
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
95
|
+
export const defaultServerCode = `
|
|
96
|
+
IUserNotifier notification;
|
|
97
|
+
|
|
98
|
+
var payload = new DefaultPayload {
|
|
99
|
+
Title = "Server Notification",
|
|
100
|
+
Message = "Task was pushed into queue."
|
|
101
|
+
};
|
|
102
|
+
notification = await notificationCenter.CreateNotifierAsync(
|
|
103
|
+
GetUserId(),
|
|
104
|
+
initialPayload: payload
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
await Task.Delay(2000);
|
|
108
|
+
|
|
109
|
+
payload.Message = "Task is running.";
|
|
110
|
+
await notification.OnChangePayload(
|
|
111
|
+
payload,
|
|
112
|
+
UserNotificationStatus.InProgress
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
for (int progress = 0; progress < 100; progress += 5) {
|
|
116
|
+
payload.Progress = progress;
|
|
117
|
+
await notification.OnChangePayload(payload);
|
|
118
|
+
|
|
119
|
+
await Task.Delay(250);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
payload.Message = "Task was successfully completed.";
|
|
123
|
+
payload.Progress = null;
|
|
124
|
+
await notification.OnChangePayload(
|
|
125
|
+
payload,
|
|
126
|
+
UserNotificationStatus.Success
|
|
127
|
+
);
|
|
128
|
+
`
|
|
129
|
+
.replace(/\n\s{4}/g, '\n')
|
|
130
|
+
.trim();
|
|
129
131
|
|
|
130
132
|
<Tabs
|
|
131
133
|
defaultValue="example"
|
|
@@ -138,7 +140,7 @@ export const defaultServerCode =
|
|
|
138
140
|
<ServerDefaultExample />
|
|
139
141
|
</TabItem>
|
|
140
142
|
<TabItem value="server">
|
|
141
|
-
<CodeBlock
|
|
143
|
+
<CodeBlock language="csharp">{defaultServerCode}</CodeBlock>
|
|
142
144
|
</TabItem>
|
|
143
145
|
</Tabs>
|
|
144
146
|
|
|
@@ -148,22 +150,24 @@ But if you need to show something more specific, then you can create a custom no
|
|
|
148
150
|
|
|
149
151
|
**_It's required to register all your custom renderers in the `custom-notifications.ts` file on the module level, which should be imported in your module file._**
|
|
150
152
|
|
|
151
|
-
export const customServerCode =
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
153
|
+
export const customServerCode = `
|
|
154
|
+
public class CustomPayload : INotificationPayload
|
|
155
|
+
{
|
|
156
|
+
public string Username { get; set; }
|
|
157
|
+
public string Message { get; set; }
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
await notificationCenter.CreateNotifierAsync(
|
|
161
|
+
GetUserId(),
|
|
162
|
+
"CustomServerNotification",
|
|
163
|
+
initialPayload: new CustomPayload {
|
|
164
|
+
Username = "Jane",
|
|
165
|
+
Message = "Hello, your order completed."
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
`
|
|
169
|
+
.replace(/\n\s{4}/g, '\n')
|
|
170
|
+
.trim();
|
|
167
171
|
|
|
168
172
|
<Tabs
|
|
169
173
|
defaultValue="example"
|
|
@@ -177,12 +181,10 @@ export const customServerCode =
|
|
|
177
181
|
<ServerCustomExample />
|
|
178
182
|
</TabItem>
|
|
179
183
|
<TabItem value="client">
|
|
180
|
-
<
|
|
181
|
-
{require('@servicetitan/notifications/src/demo/server-custom-preview.tsx?raw')}
|
|
182
|
-
</CodeBlock>
|
|
184
|
+
<DemoCodeBlock srcPath="notifications/src/demo/server-custom-preview.tsx" />
|
|
183
185
|
</TabItem>
|
|
184
186
|
<TabItem value="server">
|
|
185
|
-
<CodeBlock
|
|
187
|
+
<CodeBlock language="csharp">{customServerCode}</CodeBlock>
|
|
186
188
|
</TabItem>
|
|
187
189
|
</Tabs>
|
|
188
190
|
|
package/docs/table.mdx
CHANGED
|
@@ -170,7 +170,7 @@ export interface TableProps<T, TId extends IdType = any, P = never, PId extends
|
|
|
170
170
|
|
|
171
171
|
Simple example with some out of the box functionality.
|
|
172
172
|
|
|
173
|
-
<CodeDemo example={TableExample} srcPath="table/src/demo/overview/table.tsx" />
|
|
173
|
+
<CodeDemo example={TableExample} srcPath="table/src/demo/overview/table.tsx" theme="light" />
|
|
174
174
|
|
|
175
175
|
_This example consists of several files, the full code can be found [here](https://github.com/servicetitan/uikit/tree/master/packages/table/src/demo/overview)._
|
|
176
176
|
|
|
@@ -181,6 +181,7 @@ Table rows can expand and show additional content related to the open row. Anoth
|
|
|
181
181
|
<CodeDemo
|
|
182
182
|
example={TableMasterDetailExample}
|
|
183
183
|
srcPath="table/src/demo/master-detail/table-master-detail.tsx"
|
|
184
|
+
theme="light"
|
|
184
185
|
/>
|
|
185
186
|
|
|
186
187
|
_This example consists of several files, the full code can be found [here](https://github.com/servicetitan/uikit/tree/master/packages/table/src/demo/master-detail)._
|
|
@@ -192,6 +193,7 @@ Table State can be exported to restore it later. In the example below, we can sw
|
|
|
192
193
|
<CodeDemo
|
|
193
194
|
example={TableStateCachingExample}
|
|
194
195
|
srcPath="table/src/demo/state-caching/state-caching-table.tsx"
|
|
196
|
+
theme="light"
|
|
195
197
|
/>
|
|
196
198
|
|
|
197
199
|
_This example consists of several files, the full code can be found [here](https://github.com/servicetitan/uikit/tree/master/packages/table/src/demo/state-caching)._
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/docs-anvil-uikit-contrib",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.4.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/servicetitan/anvil-uikit-contrib.git",
|
|
8
|
-
"directory": "
|
|
8
|
+
"directory": "docusaurus"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"docs"
|
|
@@ -15,5 +15,6 @@
|
|
|
15
15
|
},
|
|
16
16
|
"cli": {
|
|
17
17
|
"webpack": false
|
|
18
|
-
}
|
|
18
|
+
},
|
|
19
|
+
"gitHead": "7811e93c496c0ff26beb0f80475024718c1fc680"
|
|
19
20
|
}
|