@nocobase/plugin-flow-engine 2.1.0-alpha.9 → 2.1.0-beta.10

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.
Files changed (51) hide show
  1. package/dist/ai/docs/runjs/context/block-model.md +35 -35
  2. package/dist/ai/docs/runjs/context/collection-field.md +51 -53
  3. package/dist/ai/docs/runjs/context/collection.md +39 -39
  4. package/dist/ai/docs/runjs/context/data-source-manager.md +30 -40
  5. package/dist/ai/docs/runjs/context/data-source.md +44 -52
  6. package/dist/ai/docs/runjs/context/element.md +38 -44
  7. package/dist/ai/docs/runjs/context/exit-all.md +35 -37
  8. package/dist/ai/docs/runjs/context/exit.md +35 -38
  9. package/dist/ai/docs/runjs/context/filter-manager.md +30 -36
  10. package/dist/ai/docs/runjs/context/form.md +57 -57
  11. package/dist/ai/docs/runjs/context/get-model.md +21 -22
  12. package/dist/ai/docs/runjs/context/get-value.md +19 -20
  13. package/dist/ai/docs/runjs/context/get-var.md +55 -61
  14. package/dist/ai/docs/runjs/context/i18n.md +14 -17
  15. package/dist/ai/docs/runjs/context/import-async.md +45 -333
  16. package/dist/ai/docs/runjs/context/init-resource.md +20 -20
  17. package/dist/ai/docs/runjs/context/libs.md +31 -31
  18. package/dist/ai/docs/runjs/context/location.md +31 -34
  19. package/dist/ai/docs/runjs/context/logger.md +40 -41
  20. package/dist/ai/docs/runjs/context/make-resource.md +26 -27
  21. package/dist/ai/docs/runjs/context/message.md +41 -42
  22. package/dist/ai/docs/runjs/context/modal.md +44 -44
  23. package/dist/ai/docs/runjs/context/model.md +33 -36
  24. package/dist/ai/docs/runjs/context/notification.md +40 -41
  25. package/dist/ai/docs/runjs/context/off.md +14 -14
  26. package/dist/ai/docs/runjs/context/on.md +29 -30
  27. package/dist/ai/docs/runjs/context/open-view.md +40 -40
  28. package/dist/ai/docs/runjs/context/render.md +32 -37
  29. package/dist/ai/docs/runjs/context/request.md +45 -46
  30. package/dist/ai/docs/runjs/context/require-async.md +25 -28
  31. package/dist/ai/docs/runjs/context/resource.md +34 -34
  32. package/dist/ai/docs/runjs/context/route.md +34 -36
  33. package/dist/ai/docs/runjs/context/router.md +31 -43
  34. package/dist/ai/docs/runjs/context/set-value.md +17 -18
  35. package/dist/ai/docs/runjs/context/t.md +17 -20
  36. package/dist/ai/docs/runjs/context/view.md +46 -49
  37. package/dist/ai/docs/runjs/document.md +0 -1
  38. package/dist/ai/docs/runjs/import-modules.md +32 -32
  39. package/dist/ai/docs/runjs/index.md +13 -13
  40. package/dist/ai/docs/runjs/jsx.md +19 -19
  41. package/dist/ai/docs/runjs/model/form-block-model.md +3 -1
  42. package/dist/ai/docs/runjs/render.md +15 -15
  43. package/dist/ai/docs/runjs/resource/api-resource.md +53 -53
  44. package/dist/ai/docs/runjs/resource/multi-record-resource.md +64 -64
  45. package/dist/ai/docs/runjs/resource/single-record-resource.md +55 -55
  46. package/dist/ai/docs/runjs/resource/sql-resource.md +57 -57
  47. package/dist/ai/docs/runjs/window.md +5 -5
  48. package/dist/externalVersion.js +10 -10
  49. package/dist/node_modules/ses/package.json +1 -1
  50. package/dist/node_modules/zod/package.json +1 -1
  51. package/package.json +2 -2
@@ -1,39 +1,39 @@
1
1
  # ctx.resource
2
2
 
3
- The **FlowResource** instance in the current context, used to access and operate on data. In most blocks (Forms, Tables, Details, etc.) and pop-up scenarios, the runtime environment pre-binds `ctx.resource`. In scenarios like JSBlock where there is no resource by default, you must first call [ctx.initResource()](./init-resource.md) to initialize it before using it via `ctx.resource`.
3
+ The **FlowResource** instance in the current context; used to access and operate on data. In most blocks (form, table, detail, etc.) and popups, the runtime binds `ctx.resource`; in JSBlock and similar contexts that have no resource by default, call [ctx.initResource()](./init-resource.md) first, then use `ctx.resource`.
4
4
 
5
- ## Applicable Scenarios
5
+ ## Use Cases
6
6
 
7
- `ctx.resource` can be used in any RunJS scenario that requires access to structured data (lists, single records, custom APIs, SQL). Forms, Tables, Detail blocks, and pop-ups are typically pre-bound. For JSBlock, JSField, JSItem, JSColumn, etc., if data loading is required, you can call `ctx.initResource(type)` first and then access `ctx.resource`.
7
+ Use whenever RunJS needs structured data (list, single record, custom API, SQL). Form, table, detail blocks and popups usually have it bound; in JSBlock, JSField, JSItem, JSColumn, etc., call `ctx.initResource(type)` first if you need to load data.
8
8
 
9
- ## Type Definition
9
+ ## Type
10
10
 
11
11
  ```ts
12
12
  resource: FlowResource | undefined;
13
13
  ```
14
14
 
15
- - In contexts with pre-binding, `ctx.resource` is the corresponding resource instance.
16
- - In scenarios like JSBlock where there is no resource by default, it is `undefined` until `ctx.initResource(type)` is called.
15
+ - When the context has a bound resource, `ctx.resource` is that instance.
16
+ - In JSBlock etc. it is `undefined` by default; after `ctx.initResource(type)` it is set.
17
17
 
18
- ## Common Methods
18
+ ## Common methods
19
19
 
20
- Methods exposed by different resource types (MultiRecordResource, SingleRecordResource, APIResource, SQLResource) vary slightly. Below are the universal or commonly used methods:
20
+ Different resource types (MultiRecordResource, SingleRecordResource, APIResource, SQLResource) expose slightly different APIs; common ones:
21
21
 
22
22
  | Method | Description |
23
- |------|------|
24
- | `getData()` | Get current data (list or single record) |
23
+ |--------|-------------|
24
+ | `getData()` | Current data (list or single record) |
25
25
  | `setData(value)` | Set local data |
26
- | `refresh()` | Initiate a request with current parameters to refresh data |
27
- | `setResourceName(name)` | Set resource name (e.g., `'users'`, `'users.tags'`) |
28
- | `setFilterByTk(tk)` | Set primary key filter (for single record `get`, etc.) |
29
- | `runAction(actionName, options)` | Call any resource action (e.g., `create`, `update`) |
30
- | `on(event, callback)` / `off(event, callback)` | Subscribe/unsubscribe to events (e.g., `refresh`, `saved`) |
26
+ | `refresh()` | Refetch with current params |
27
+ | `setResourceName(name)` | Set resource name (e.g. `'users'`, `'users.tags'`) |
28
+ | `setFilterByTk(tk)` | Set primary key filter (single get, etc.) |
29
+ | `runAction(actionName, options)` | Call any resource action (e.g. `create`, `update`) |
30
+ | `on(event, callback)` / `off(event, callback)` | Subscribe/unsubscribe (e.g. `refresh`, `saved`) |
31
31
 
32
- **MultiRecordResource Specific**: `getSelectedRows()`, `destroySelectedRows()`, `setPage()`, `next()`, `previous()`, etc.
32
+ **MultiRecordResource**: `getSelectedRows()`, `destroySelectedRows()`, `setPage()`, `next()`, `previous()`, etc.
33
33
 
34
34
  ## Examples
35
35
 
36
- ### List Data (Requires initResource first)
36
+ ### List (after initResource)
37
37
 
38
38
  ```js
39
39
  ctx.initResource('MultiRecordResource');
@@ -42,7 +42,7 @@ await ctx.resource.refresh();
42
42
  const rows = ctx.resource.getData();
43
43
  ```
44
44
 
45
- ### Table Scenario (Pre-bound)
45
+ ### Table (pre-bound)
46
46
 
47
47
  ```js
48
48
  const rows = ctx.resource?.getSelectedRows?.() || [];
@@ -54,7 +54,7 @@ await ctx.resource.destroySelectedRows();
54
54
  ctx.message.success(ctx.t('Deleted'));
55
55
  ```
56
56
 
57
- ### Single Record
57
+ ### Single record
58
58
 
59
59
  ```js
60
60
  ctx.initResource('SingleRecordResource');
@@ -64,29 +64,29 @@ await ctx.resource.refresh();
64
64
  const record = ctx.resource.getData();
65
65
  ```
66
66
 
67
- ### Calling a Custom Action
67
+ ### Custom action
68
68
 
69
69
  ```js
70
- await ctx.resource.runAction('create', { data: { name: 'John Doe' } });
70
+ await ctx.resource.runAction('create', { data: { name: 'John' } });
71
71
  ```
72
72
 
73
- ## Relationship with ctx.initResource / ctx.makeResource
73
+ ## Relation to ctx.initResource / ctx.makeResource
74
74
 
75
- - **ctx.initResource(type)**: If `ctx.resource` does not exist, it creates and binds one; if it already exists, it returns the existing instance. This ensures `ctx.resource` is available.
76
- - **ctx.makeResource(type)**: Creates a new resource instance and returns it, but does **not** write it to `ctx.resource`. This is suitable for scenarios requiring multiple independent resources or temporary usage.
77
- - **ctx.resource**: Accesses the resource already bound to the current context. Most blocks/pop-ups are pre-bound; otherwise, it is `undefined` and requires `ctx.initResource`.
75
+ - **ctx.initResource(type)**: Creates and binds if missing; otherwise returns existing. Ensures `ctx.resource` is set.
76
+ - **ctx.makeResource(type)**: Creates a new instance and returns it; **does not** set `ctx.resource`. Use when you need multiple resources or a temporary one.
77
+ - **ctx.resource**: The bound resource in the current context. Most blocks/popups have it; when not bound it is `undefined` and you must call `ctx.initResource` first.
78
78
 
79
79
  ## Notes
80
80
 
81
- - It is recommended to perform a null check before use: `ctx.resource?.refresh()`, especially in scenarios like JSBlock where pre-binding might not exist.
82
- - After initialization, you must call `setResourceName(name)` to specify the collection before loading data via `refresh()`.
83
- - For the full API of each Resource type, see the links below.
81
+ - Prefer null checks: `ctx.resource?.refresh()`, especially in JSBlock and similar contexts.
82
+ - After init, call `setResourceName(name)` then `refresh()` to load data.
83
+ - See the resource type docs for full API.
84
84
 
85
85
  ## Related
86
86
 
87
- - [ctx.initResource()](./init-resource.md) - Initialize and bind a resource to the current context
88
- - [ctx.makeResource()](./make-resource.md) - Create a new resource instance without binding it to `ctx.resource`
89
- - [MultiRecordResource](../resource/multi-record-resource.md) - Multiple records/Lists
90
- - [SingleRecordResource](../resource/single-record-resource.md) - Single record
91
- - [APIResource](../resource/api-resource.md) - General API resource
92
- - [SQLResource](../resource/sql-resource.md) - SQL query resource
87
+ - [ctx.initResource()](./init-resource.md): init and bind resource
88
+ - [ctx.makeResource()](./make-resource.md): create resource without binding
89
+ - [MultiRecordResource](../resource/multi-record-resource.md)
90
+ - [SingleRecordResource](../resource/single-record-resource.md)
91
+ - [APIResource](../resource/api-resource.md)
92
+ - [SQLResource](../resource/sql-resource.md)
@@ -1,76 +1,74 @@
1
1
  # ctx.route
2
2
 
3
- The current route matching information, corresponding to the `route` concept in React Router. It is used to retrieve the current matching route configuration, parameters, and more. It is typically used in conjunction with `ctx.router` and `ctx.location`.
3
+ Current route match info, corresponding to React Router’s route; used to get the matched route config, params, etc. Use with `ctx.router` and `ctx.location`.
4
4
 
5
5
  ## Use Cases
6
6
 
7
7
  | Scenario | Description |
8
- |------|------|
9
- | **JSBlock / JSField** | Perform conditional rendering or display the current page identifier based on `route.pathname` or `route.params`. |
10
- | **Linkage Rules / FlowEngine** | Read route parameters (e.g., `params.name`) for logic branching or to pass them to child components. |
11
- | **View Navigation** | Internally compare `ctx.route.pathname` with a target path to determine whether to trigger `ctx.router.navigate`. |
8
+ |----------|-------------|
9
+ | **JSBlock / JSField** | Conditional render or display based on `route.pathname` or `route.params` |
10
+ | **Linkage / event flow** | Read route params (e.g. `params.name`) for logic or pass to children |
11
+ | **View navigation** | Compare `ctx.route.pathname` with target path to decide `ctx.router.navigate` |
12
12
 
13
- > Note: `ctx.route` is only available in RunJS environments that contain a routing context (such as JSBlocks within a page, Flow pages, etc.). It may be null in pure backend or non-routing contexts (such as background workflows).
13
+ > Note: `ctx.route` is only available in RunJS when a router context exists (e.g. JSBlock on a page, Flow page); in pure backend or non-routed contexts (e.g. workflow) it may be empty.
14
14
 
15
- ## Type Definition
15
+ ## Type
16
16
 
17
17
  ```ts
18
18
  type RouteOptions = {
19
- name?: string; // Unique route identifier
20
- path?: string; // Route template (e.g., /admin/:name)
21
- params?: Record<string, any>; // Route parameters (e.g., { name: 'users' })
22
- pathname?: string; // Full path of the current route (e.g., /admin/users)
19
+ name?: string;
20
+ path?: string;
21
+ params?: Record<string, any>;
22
+ pathname?: string;
23
23
  };
24
24
  ```
25
25
 
26
- ## Common Fields
26
+ ## Common fields
27
27
 
28
28
  | Field | Type | Description |
29
- |------|------|------|
30
- | `pathname` | `string` | The full path of the current route, consistent with `ctx.location.pathname`. |
31
- | `params` | `Record<string, any>` | Dynamic parameters parsed from the route template, such as `{ name: 'users' }`. |
32
- | `path` | `string` | The route template, such as `/admin/:name`. |
33
- | `name` | `string` | Unique route identifier, commonly used in multi-tab or multi-view scenarios. |
29
+ |-------|------|-------------|
30
+ | `pathname` | `string` | Full path of current route; same as `ctx.location.pathname` |
31
+ | `params` | `Record<string, any>` | Dynamic params from route template, e.g. `{ name: 'users' }` |
32
+ | `path` | `string` | Route template, e.g. `/admin/:name` |
33
+ | `name` | `string` | Route unique id; often used for tabs/views |
34
34
 
35
- ## Relationship with ctx.router and ctx.location
35
+ ## Relation to ctx.router, ctx.location
36
36
 
37
- | Purpose | Recommended Usage |
38
- |------|----------|
39
- | **Read current path** | `ctx.route.pathname` or `ctx.location.pathname`; both are consistent during matching. |
40
- | **Read route parameters** | `ctx.route.params`, e.g., `params.name` representing the current page UID. |
41
- | **Navigation** | `ctx.router.navigate(path)` |
42
- | **Read query parameters, state** | `ctx.location.search`, `ctx.location.state` |
37
+ | Use | Recommended |
38
+ |-----|-------------|
39
+ | **Current path** | `ctx.route.pathname` or `ctx.location.pathname`; they match when route is matched |
40
+ | **Route params** | `ctx.route.params`, e.g. `params.name` for current page UID |
41
+ | **Navigate** | `ctx.router.navigate(path)` |
42
+ | **Query params, state** | `ctx.location.search`, `ctx.location.state` |
43
43
 
44
- `ctx.route` focuses on the "matched route configuration," while `ctx.location` focuses on the "current URL location." Together, they provide a complete description of the current routing state.
44
+ `ctx.route` is matched route config”; `ctx.location` is current URL”; together they describe the current route state.
45
45
 
46
46
  ## Examples
47
47
 
48
- ### Reading pathname
48
+ ### Read pathname
49
49
 
50
50
  ```ts
51
- // Display the current path
52
- ctx.message.info('Current Page: ' + ctx.route.pathname);
51
+ ctx.message.info('Current page: ' + ctx.route.pathname);
53
52
  ```
54
53
 
55
- ### Branching based on params
54
+ ### Branch by params
56
55
 
57
56
  ```ts
58
- // params.name is typically the current page UID (e.g., a Flow page identifier)
59
57
  if (ctx.route.params?.name === 'users') {
60
- // Execute specific logic on the user management page
58
+ // On user management page
61
59
  }
62
60
  ```
63
61
 
64
- ### Displaying in a Flow page
62
+ ### In Flow page
65
63
 
66
64
  ```tsx
67
65
  <div>
68
- <h1>Current Page - {ctx.route.pathname}</h1>
69
- <p>Route Identifier: {ctx.route.params?.name}</p>
66
+ <h1>Current page - {ctx.route.pathname}</h1>
67
+ <p>Route id: {ctx.route.params?.name}</p>
70
68
  </div>
71
69
  ```
72
70
 
73
71
  ## Related
74
72
 
75
- - [ctx.router](./router.md): Route navigation. When `ctx.router.navigate()` changes the path, `ctx.route` will update accordingly.
76
- - [ctx.location](./location.md): Current URL location (pathname, search, hash, state), used in conjunction with `ctx.route`.
73
+ - [ctx.router](./router.md): navigation; after `ctx.router.navigate()`, `ctx.route` updates
74
+ - [ctx.location](./location.md): current URL (pathname, search, hash, state); use with `ctx.route`
@@ -1,31 +1,31 @@
1
1
  # ctx.router
2
2
 
3
- A router instance based on React Router, used for programmatic navigation within RunJS. It is typically used in conjunction with `ctx.route` and `ctx.location`.
3
+ Router instance based on React Router; used for programmatic navigation in RunJS. Use with `ctx.route` and `ctx.location`.
4
4
 
5
5
  ## Use Cases
6
6
 
7
7
  | Scenario | Description |
8
- |------|------|
9
- | **JSBlock / JSField** | Navigate to detail pages, list pages, or external links after a button click. |
10
- | **Linkage Rules / Event Flow** | Execute `navigate` to a list or detail page after successful submission, or pass `state` to the target page. |
11
- | **JSAction / Event Handling** | Execute route navigation within logic such as form submissions or link clicks. |
12
- | **View Navigation** | Update the URL via `navigate` during internal view stack switching. |
8
+ |----------|-------------|
9
+ | **JSBlock / JSField** | Button navigates to detail, list, or external link |
10
+ | **Linkage / event flow** | After submit success, `navigate` to list or detail, or pass state to target |
11
+ | **JSAction / event handler** | Navigate on form submit, link click, etc. |
12
+ | **View navigation** | Update URL when switching views |
13
13
 
14
- > Note: `ctx.router` is only available in RunJS environments with a routing context (e.g., JSBlock within a page, Flow pages, event flows, etc.); it may be null in pure backend or non-routing contexts (e.g., Workflows).
14
+ > Note: `ctx.router` is only available in RunJS when a router context exists (e.g. JSBlock on a page, Flow page, event flow); in pure backend or non-routed contexts (e.g. workflow) it may be empty.
15
15
 
16
- ## Type Definition
16
+ ## Type
17
17
 
18
18
  ```typescript
19
19
  router: Router
20
20
  ```
21
21
 
22
- `Router` is derived from `@remix-run/router`. In RunJS, navigation operations such as jumping, going back, and refreshing are implemented via `ctx.router.navigate()`.
22
+ `Router` is from `@remix-run/router`; use `ctx.router.navigate()` for navigation, back, refresh.
23
23
 
24
24
  ## Methods
25
25
 
26
26
  ### ctx.router.navigate()
27
27
 
28
- Navigates to a target path, or executes a back/refresh action.
28
+ Navigate to a path, or go back/refresh.
29
29
 
30
30
  **Signature:**
31
31
 
@@ -35,77 +35,65 @@ navigate(to: string | number | null, options?: RouterNavigateOptions): Promise<v
35
35
 
36
36
  **Parameters:**
37
37
 
38
- - `to`: Target path (string), relative history position (number, e.g., `-1` to go back), or `null` (to refresh the current page).
39
- - `options`: Optional configuration.
40
- - `replace?: boolean`: Whether to replace the current history entry (default is `false`, which pushes a new entry).
41
- - `state?: any`: State to pass to the target route. This data does not appear in the URL and can be accessed via `ctx.location.state` on the target page. It is suitable for sensitive information, temporary data, or information that should not be placed in the URL.
38
+ - `to`: Target path (string), relative history position (number, e.g. `-1` for back), or `null` (refresh current page)
39
+ - `options`:
40
+ - `replace?: boolean`: Replace current history entry (default `false`, i.e. push)
41
+ - `state?: any`: State passed to the target route. Not in URL; target page reads it via `ctx.location.state`. Use for sensitive or temporary data.
42
42
 
43
43
  ## Examples
44
44
 
45
- ### Basic Navigation
45
+ ### Basic navigation
46
46
 
47
47
  ```ts
48
- // Navigate to the user list (pushes a new history entry, allows going back)
49
48
  ctx.router.navigate('/admin/users');
50
49
 
51
- // Navigate to a detail page
52
50
  ctx.router.navigate(`/admin/users/${recordId}`);
53
51
  ```
54
52
 
55
- ### Replacing History (No new entry)
53
+ ### Replace (no new history entry)
56
54
 
57
55
  ```ts
58
- // Redirect to the home page after login; the user won't return to the login page when going back
59
56
  ctx.router.navigate('/admin', { replace: true });
60
57
 
61
- // Replace the current page with the detail page after successful form submission
62
58
  ctx.router.navigate(`/admin/users/${newId}`, { replace: true });
63
59
  ```
64
60
 
65
- ### Passing State
61
+ ### Pass state
66
62
 
67
63
  ```ts
68
- // Carry data during navigation; the target page retrieves it via ctx.location.state
69
64
  ctx.router.navigate('/admin/users/123', {
70
65
  state: { from: 'dashboard', tab: 'profile' }
71
66
  });
72
67
  ```
73
68
 
74
- ### Back and Refresh
69
+ ### Back and refresh
75
70
 
76
71
  ```ts
77
- // Go back one page
78
72
  ctx.router.navigate(-1);
79
73
 
80
- // Go back two pages
81
74
  ctx.router.navigate(-2);
82
75
 
83
- // Refresh the current page
84
76
  ctx.router.navigate(null);
85
77
  ```
86
78
 
87
- ## Relationship with ctx.route and ctx.location
79
+ ## Relation to ctx.route, ctx.location
88
80
 
89
- | Purpose | Recommended Usage |
90
- |------|----------|
91
- | **Navigation/Jumping** | `ctx.router.navigate(path)` |
92
- | **Read current path** | `ctx.route.pathname` or `ctx.location.pathname` |
93
- | **Read state passed during navigation** | `ctx.location.state` |
94
- | **Read route parameters** | `ctx.route.params` |
81
+ | Use | Recommended |
82
+ |-----|-------------|
83
+ | **Navigate** | `ctx.router.navigate(path)` |
84
+ | **Current path** | `ctx.route.pathname` or `ctx.location.pathname` |
85
+ | **State from navigation** | `ctx.location.state` |
86
+ | **Route params** | `ctx.route.params` |
95
87
 
96
- `ctx.router` is responsible for "navigation actions," while `ctx.route` and `ctx.location` are responsible for the "current route state."
88
+ `ctx.router` does navigation”; `ctx.route` and `ctx.location` describe current route state”.
97
89
 
98
90
  ## Notes
99
91
 
100
- - `navigate(path)` pushes a new history entry by default, allowing users to return via the browser's back button.
101
- - `replace: true` replaces the current history entry without adding a new one, which is suitable for scenarios like post-login redirection or navigation after successful submission.
102
- - **Regarding the `state` parameter**:
103
- - Data passed via `state` does not appear in the URL, making it suitable for sensitive or temporary data.
104
- - It can be accessed via `ctx.location.state` on the target page.
105
- - `state` is saved in the browser history and remains accessible during forward/backward navigation.
106
- - `state` will be lost after a hard page refresh.
92
+ - `navigate(path)` by default pushes a new history entry; user can use browser back.
93
+ - `replace: true` replaces the current entry; use after login redirect, submit-success redirect, etc.
94
+ - **`state`**: Data in `state` is not in the URL; target page reads it via `ctx.location.state`. State is stored in history (back/forward keep it); it is lost on page refresh.
107
95
 
108
96
  ## Related
109
97
 
110
- - [ctx.route](./route.md): Current route match information (pathname, params, etc.).
111
- - [ctx.location](./location.md): Current URL location (pathname, search, hash, state); `state` is read here after navigation.
98
+ - [ctx.route](./route.md): current route match (pathname, params)
99
+ - [ctx.location](./location.md): current URL; read `state` here after navigation
@@ -1,29 +1,29 @@
1
1
  # ctx.setValue()
2
2
 
3
- Sets the value of the current field in editable field scenarios such as JSField and JSItem. Combined with `ctx.getValue()`, it enables two-way binding with the form.
3
+ In JSField, JSItem, and other editable field contexts, sets the current field’s value. Use with `ctx.getValue()` for two-way binding with the form.
4
4
 
5
5
  ## Use Cases
6
6
 
7
7
  | Scenario | Description |
8
- |------|------|
9
- | **JSField** | Write user-selected or calculated values into editable custom fields. |
10
- | **JSItem** | Update the current cell value in editable items of tables/sub-tables. |
11
- | **JSColumn** | Update the field value of the corresponding row based on logic during table column rendering. |
8
+ |----------|-------------|
9
+ | **JSField** | Write user selection or computed value in editable custom fields |
10
+ | **JSItem** | Update current cell value in table/sub-table editable items |
11
+ | **JSColumn** | Update row field value when rendering a column |
12
12
 
13
- > **Note**: `ctx.setValue(v)` is only available in RunJS contexts with form binding. It is not available in scenarios without field binding, such as FlowEngine, linkage rules, or JSBlock. It is recommended to use optional chaining before use: `ctx.setValue?.(value)`.
13
+ > Note: `ctx.setValue(v)` is only available in RunJS contexts with form binding; in event flow, linkage, JSBlock, etc. (no field binding) the method may not exist—use optional chaining: `ctx.setValue?.(value)`.
14
14
 
15
- ## Type Definition
15
+ ## Type
16
16
 
17
17
  ```ts
18
18
  setValue<T = any>(value: T): void;
19
19
  ```
20
20
 
21
- - **Parameters**: `value` is the field value to be written. The type is determined by the form item type of the field.
21
+ - **Parameter**: `value` is the value to write; type depends on the field’s form item type.
22
22
 
23
23
  ## Behavior
24
24
 
25
- - `ctx.setValue(v)` updates the value of the current field in the Ant Design Form and triggers related form linkage and validation logic.
26
- - If the form has not finished rendering or the field is not registered, the call may be ineffective. It is recommended to use `ctx.getValue()` to confirm the write result.
25
+ - `ctx.setValue(v)` updates the current field’s value in the Ant Design Form and triggers linkage and validation.
26
+ - If the form is not yet rendered or the field is not registered, the call may have no effect; use `ctx.getValue()` to confirm.
27
27
 
28
28
  ## Examples
29
29
 
@@ -42,7 +42,7 @@ ctx.render(
42
42
  );
43
43
  ```
44
44
 
45
- ### Setting default values based on conditions
45
+ ### Set default by condition
46
46
 
47
47
  ```ts
48
48
  const status = ctx.getValue();
@@ -51,10 +51,9 @@ if (status == null || status === '') {
51
51
  }
52
52
  ```
53
53
 
54
- ### Writing back to the current field when linked to other fields
54
+ ### Write current field when linking others
55
55
 
56
56
  ```ts
57
- // Synchronously update the current field when another field changes
58
57
  const otherValue = ctx.form?.getFieldValue('type');
59
58
  if (otherValue === 'custom') {
60
59
  ctx.setValue?.({ label: 'Custom', value: 'custom' });
@@ -63,11 +62,11 @@ if (otherValue === 'custom') {
63
62
 
64
63
  ## Notes
65
64
 
66
- - In non-editable fields (e.g., JSField in Read-only Mode, JSBlock), `ctx.setValue` may be `undefined`. It is recommended to use `ctx.setValue?.(value)` to avoid errors.
67
- - When setting values for association fields (M2O, O2M, etc.), you need to pass a structure that matches the field type (e.g., `{ id, [titleField]: label }`), depending on the specific field configuration.
65
+ - In non-editable contexts (e.g. JSField detail mode, JSBlock), `ctx.setValue` may be `undefined`; use `ctx.setValue?.(value)`.
66
+ - For association fields (m2o, o2m, etc.), pass a value that matches the field type (e.g. `{ id, [titleField]: label }`); see field config.
68
67
 
69
68
  ## Related
70
69
 
71
- - [ctx.getValue()](./get-value.md) - Get the current field value, used with setValue for two-way binding.
72
- - [ctx.form](./form.md) - Ant Design Form instance, used to read or write other fields.
73
- - `js-field:value-change` - A container event triggered when an external value changes, used to update the display.
70
+ - [ctx.getValue()](./get-value.md): get current field value; use with setValue for two-way binding
71
+ - [ctx.form](./form.md): Ant Design Form; read/write other fields
72
+ - `js-field:value-change`: container event when value changes from outside; use to update display
@@ -1,12 +1,12 @@
1
1
  # ctx.t()
2
2
 
3
- An i18n shortcut function used in RunJS to translate text based on the current context's language settings. It is suitable for internationalizing inline copy such as buttons, titles, and prompts.
3
+ i18n helper in RunJS for translating copy; uses the current contexts language. Use for buttons, titles, hints, etc.
4
4
 
5
5
  ## Use Cases
6
6
 
7
- `ctx.t()` can be used in all RunJS execution environments.
7
+ Available in all RunJS environments.
8
8
 
9
- ## Type Definition
9
+ ## Type
10
10
 
11
11
  ```ts
12
12
  t(key: string, options?: Record<string, any>): string
@@ -16,38 +16,35 @@ t(key: string, options?: Record<string, any>): string
16
16
 
17
17
  | Parameter | Type | Description |
18
18
  |-----------|------|-------------|
19
- | `key` | `string` | Translation key or template with placeholders (e.g., `Hello {{name}}`, `{{count}} rows`). |
20
- | `options` | `object` | Optional. Interpolation variables (e.g., `{ name: 'John', count: 5 }`), or i18n options (e.g., `defaultValue`, `ns`). |
19
+ | `key` | `string` | Translation key or template with placeholders (e.g. `Hello {{name}}`, `{{count}} rows`) |
20
+ | `options` | `object` | Optional. Interpolation (e.g. `{ name: 'John', count: 5 }`) or i18n options (`defaultValue`, `ns`) |
21
21
 
22
- ## Return Value
22
+ ## Returns
23
23
 
24
- - Returns the translated string. If no translation exists for the key and no `defaultValue` is provided, it may return the key itself or the interpolated string.
24
+ - Translated string; if key has no translation and no `defaultValue`, may return the key or the interpolated string.
25
25
 
26
26
  ## Namespace (ns)
27
27
 
28
- The **default namespace for the RunJS environment is `runjs`**. When `ns` is not specified, `ctx.t(key)` will look up the key in the `runjs` namespace.
28
+ RunJS **default namespace is `runjs`**. Without `ns`, `ctx.t(key)` looks up the key in the `runjs` namespace.
29
29
 
30
30
  ```ts
31
- // Looks up key from the 'runjs' namespace by default
32
- ctx.t('Submit'); // Equivalent to ctx.t('Submit', { ns: 'runjs' })
31
+ ctx.t('Submit'); // same as ctx.t('Submit', { ns: 'runjs' })
33
32
 
34
- // Looks up key from a specific namespace
35
33
  ctx.t('Submit', { ns: 'myModule' });
36
34
 
37
- // Searches multiple namespaces sequentially (first 'runjs', then 'common')
38
35
  ctx.t('Save', { ns: ['runjs', 'common'] });
39
36
  ```
40
37
 
41
38
  ## Examples
42
39
 
43
- ### Simple Key
40
+ ### Simple key
44
41
 
45
42
  ```ts
46
43
  ctx.t('Submit');
47
44
  ctx.t('No data');
48
45
  ```
49
46
 
50
- ### With Interpolation Variables
47
+ ### With interpolation
51
48
 
52
49
  ```ts
53
50
  const text = ctx.t('Hello {{name}}', { name: ctx.user?.nickname || 'Guest' });
@@ -58,14 +55,14 @@ ctx.render(`<div>${text}</div>`);
58
55
  ctx.message.success(ctx.t('Processed {{count}} rows', { count: rows.length }));
59
56
  ```
60
57
 
61
- ### Dynamic Copy (e.g., Relative Time)
58
+ ### Relative time etc.
62
59
 
63
60
  ```ts
64
61
  if (minutes < 60) return ctx.t('{{count}} minutes ago', { count: minutes });
65
62
  if (hours < 24) return ctx.t('{{count}} hours ago', { count: hours });
66
63
  ```
67
64
 
68
- ### Specifying a Namespace
65
+ ### Specify namespace
69
66
 
70
67
  ```ts
71
68
  ctx.t('Hello {{name}}', { name: 'Guest', ns: 'myModule' });
@@ -73,10 +70,10 @@ ctx.t('Hello {{name}}', { name: 'Guest', ns: 'myModule' });
73
70
 
74
71
  ## Notes
75
72
 
76
- - **Localization Plugin**: To translate text, the Localization plugin must be activated. Missing translation keys will be automatically extracted to the localization management list for unified maintenance and translation.
77
- - Supports i18next-style interpolation: Use `{{variableName}}` in the key and pass the corresponding variable in `options` to replace it.
78
- - The language is determined by the current context (e.g., `ctx.i18n.language`, user locale).
73
+ - **Localization plugin**: Activate the localization plugin to manage translations. Missing keys can be collected for translation.
74
+ - i18next-style interpolation: use `{{varName}}` in the key and pass the same name in `options`.
75
+ - Language comes from the current context (e.g. `ctx.i18n.language`, user locale).
79
76
 
80
77
  ## Related
81
78
 
82
- - [ctx.i18n](./i18n.md): Read or switch languages
79
+ - [ctx.i18n](./i18n.md): read or change language