@itrocks/handbook 0.0.12 → 0.0.15
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/AGENTS.md +2 -0
- package/docs/framework-changes/architecture/README.md +1 -0
- package/docs/framework-changes/architecture/browser-components.md +10 -0
- package/docs/framework-changes/architecture/html-templates-and-targets.md +3 -0
- package/docs/framework-changes/documentation/markdown.md +12 -0
- package/docs/framework-usage/README.md +2 -1
- package/docs/framework-usage/coding-conventions.md +40 -3
- package/docs/framework-usage/structured-views.md +150 -0
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -8,6 +8,8 @@ Paths below are relative to this package.
|
|
|
8
8
|
- Update instructions or conventions for AI agents: [agent conventions](docs/agent-conventions/README.md).
|
|
9
9
|
|
|
10
10
|
If a task spans several categories, read each applicable guide.
|
|
11
|
+
For any front-end change, follow
|
|
12
|
+
[interactive browser verification](docs/framework-changes/architecture/browser-components.md#interactive-browser-verification).
|
|
11
13
|
|
|
12
14
|
## Commits
|
|
13
15
|
|
|
@@ -11,6 +11,7 @@ A package is a published `@itrocks/*` module; `HasPlugins` and `Plugin<T>` refer
|
|
|
11
11
|
- Request, route, action, response or workflow: [actions and routes](requests-actions-and-routes.md).
|
|
12
12
|
- Conversion or view metadata: [transformations and views](transformations-and-views.md).
|
|
13
13
|
- Template, include, fragment or target: [HTML templates](html-templates-and-targets.md).
|
|
14
|
+
- Business view, object form or structured modal: [structured views](../../framework-usage/structured-views.md).
|
|
14
15
|
- DOM activation, navigation or browser plugin: [browser components](browser-components.md).
|
|
15
16
|
- Selector, UI state, stylesheet or asset: [SCSS and assets](scss-and-assets.md).
|
|
16
17
|
- Storage, relations, schema or database adapter: [persistence](persistence-and-schema.md).
|
|
@@ -11,6 +11,16 @@ Use semantic selectors and guard repeated activation when components do not alre
|
|
|
11
11
|
Load heavy or optional behaviour inside the callback. Browser subpath imports use explicit `.js` extensions.
|
|
12
12
|
Keep structure in HTML, behaviour in TypeScript and visual state in SCSS, sharing documented classes and attributes.
|
|
13
13
|
|
|
14
|
+
## Interactive browser verification
|
|
15
|
+
|
|
16
|
+
Test every front-end change interactively in a browser before delivery. Exercise the complete affected workflows in
|
|
17
|
+
the application, including related screens and actions that share the same UI. For business objects, follow the
|
|
18
|
+
applicable paths through the list, record view, edit form and save, then reopen the record to check the result.
|
|
19
|
+
|
|
20
|
+
Check that interactions work without errors, the workflow is easy to use, and the visible layout and behaviour
|
|
21
|
+
match the requested design and the rest of the application. Check relevant viewport sizes and dynamic navigation.
|
|
22
|
+
Use isolated test data when a workflow writes data. Builds and automated tests complement the interactive pass.
|
|
23
|
+
|
|
14
24
|
## Plugins and navigation
|
|
15
25
|
|
|
16
26
|
A host extends `HasPlugins<Host>`, accepts `Partial<Options<Host>>`, establishes its base state, then calls
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
Render valid standalone HTML and identify the fragment for asynchronous navigation.
|
|
4
4
|
The action prepares a small named data context and owns business decisions.
|
|
5
5
|
|
|
6
|
+
For the structure of new object views, lists, forms and structured modal content, follow
|
|
7
|
+
[structured business views](../../framework-usage/structured-views.md).
|
|
8
|
+
|
|
6
9
|
## Authoring and validation
|
|
7
10
|
|
|
8
11
|
Author page and fragment markup in HTML templates. Server actions prepare data; browser code enhances the rendered DOM.
|
|
@@ -19,6 +19,18 @@ Name context-specific sections explicitly. Keep manual setup and adapter wiring
|
|
|
19
19
|
already supplies them. Put dependency binding details in [dependency documentation](dependencies.md), linked from
|
|
20
20
|
the relevant context section.
|
|
21
21
|
|
|
22
|
+
## AI authorship
|
|
23
|
+
|
|
24
|
+
When AI writes a new document, add this notice near the top. In a package README, place it after the opening
|
|
25
|
+
description. In supporting documentation, place it after the title.
|
|
26
|
+
|
|
27
|
+
*This documentation was written by an artificial intelligence and may contain errors or approximations.
|
|
28
|
+
It has not yet been fully reviewed by a human. If anything seems unclear or incomplete,
|
|
29
|
+
please feel free to contact the author of this package.*
|
|
30
|
+
|
|
31
|
+
When AI edits an existing document, keep any existing notice. If the document has no notice, assume it has been
|
|
32
|
+
reviewed and approved by a human and leave the authorship unstated.
|
|
33
|
+
|
|
22
34
|
## Formatting
|
|
23
35
|
|
|
24
36
|
- Limit source lines to 120 columns, including Markdown syntax. Only indivisible content such as URLs may exceed it.
|
|
@@ -6,7 +6,8 @@ then the owning package's README for the feature being used.
|
|
|
6
6
|
Read only the conventions needed by the task:
|
|
7
7
|
|
|
8
8
|
- Application source: [coding conventions](coding-conventions.md).
|
|
9
|
-
-
|
|
9
|
+
- New business views, object forms and structured modal content: [structured business views](structured-views.md).
|
|
10
|
+
- HTML syntax, fragments and front-end assets:
|
|
10
11
|
[templates and targets](../framework-changes/architecture/html-templates-and-targets.md).
|
|
11
12
|
- Markdown: [documentation conventions](../framework-changes/documentation/markdown.md).
|
|
12
13
|
- Framework extension or integration: select the relevant [architecture
|
|
@@ -17,6 +17,7 @@ proportionate to the task; choose the KISS (Keep It Simple And Stupid) solution
|
|
|
17
17
|
Prefer less code when correctness and readability are equivalent.
|
|
18
18
|
- Apply SOLID through clear responsibilities, existing extension points, substitutable contracts, focused interfaces
|
|
19
19
|
and appropriate dependency boundaries. Each separation must serve the current behaviour and simplify maintenance.
|
|
20
|
+
- When a condition encloses the rest of a loop body, prefer an inverted `continue` guard to another indentation level.
|
|
20
21
|
|
|
21
22
|
When fixing a bug, reconsider the model before adding another condition or special case. For example, column drag
|
|
22
23
|
placement can remember the hovered column and react to changes of column and movement direction, instead of repeatedly
|
|
@@ -29,13 +30,48 @@ inferring placement from position thresholds.
|
|
|
29
30
|
such as YAML.
|
|
30
31
|
- Omit semicolons; use single quotes and template literals for interpolation or multiline text.
|
|
31
32
|
- Space postfix operators: `index ++`, `index --`.
|
|
32
|
-
- Align `from`, `=`,
|
|
33
|
+
- Align `from`, `=`, `:`, `??` and values in adjacent related lines where the limit allows. Include mixed `const`/`let`
|
|
34
|
+
declarations, assignments and constructor parameters in the same alignment group; keep a space before each operator.
|
|
35
|
+
- Declare one variable per statement. Separate preparation, object configuration and the final call or return with
|
|
36
|
+
blank lines when they form distinct steps.
|
|
33
37
|
- Put `{` on the next line for classes, interfaces, functions, methods and constructors.
|
|
34
38
|
- Keep `{` on the control line for conditions, loops, `switch`, `try`, `catch` and `finally`.
|
|
35
39
|
- Put `else`, `catch` and `finally` on a new line after the preceding `}`.
|
|
36
|
-
-
|
|
40
|
+
- Use braces and a separate body line for conditional returns. Otherwise prefer braces; very short flow guards such
|
|
41
|
+
as `if (condition) continue` may remain on one line.
|
|
42
|
+
- For empty constructors, keep `{}` on the closing parameter line, including after a multiline parameter list.
|
|
37
43
|
- Leave a blank line after a non-empty class opening brace and before its closing brace.
|
|
38
44
|
|
|
45
|
+
## Wrapped expressions
|
|
46
|
+
|
|
47
|
+
The 120-column limit is a maximum, not a target. Break dense expressions earlier when their structure is clearer.
|
|
48
|
+
|
|
49
|
+
- For multiline control conditions, put `if (` on its own line, indent the condition once, and align `) {` with `if`.
|
|
50
|
+
Put leading `&&` and `||` on continuation lines at the same condition indentation.
|
|
51
|
+
- Prefer a direct ternary return when choosing between two values. Keep only simple ternaries on one line; otherwise
|
|
52
|
+
put `?` and `:` on separate lines, one level below the return or assignment. Parenthesise concatenation branches.
|
|
53
|
+
- For a ternary chain, align successive conditions and their results instead of increasing indentation for each case.
|
|
54
|
+
- In multiline array and object literals, put one entry per line, including spreads and shorthand properties.
|
|
55
|
+
Break nested calls at argument boundaries and close each enclosing call at its corresponding indentation level.
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
if (
|
|
59
|
+
!path || !path.startsWith('/') || path.startsWith('//')
|
|
60
|
+
|| (new URL(path, origin).pathname !== path)
|
|
61
|
+
) {
|
|
62
|
+
return ''
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return (!prefix || path.startsWith(prefix + '/'))
|
|
66
|
+
? path
|
|
67
|
+
: (prefix + path)
|
|
68
|
+
|
|
69
|
+
result =
|
|
70
|
+
isFunction(value) ? value(options) :
|
|
71
|
+
isType(value) ? new value(options) :
|
|
72
|
+
value
|
|
73
|
+
```
|
|
74
|
+
|
|
39
75
|
## Signatures
|
|
40
76
|
|
|
41
77
|
Choose the first layout below that fits 120 columns. Apply the same parameter and return-type breaks to methods,
|
|
@@ -71,7 +107,8 @@ function calculate(
|
|
|
71
107
|
|
|
72
108
|
Sort homogeneous sequences alphabetically by stable name wherever order has no semantic significance.
|
|
73
109
|
This includes configuration, documentation, object/array entries, declarations, members, imports, exports,
|
|
74
|
-
parameters and test cases.
|
|
110
|
+
parameters and test cases. Preserve existing responsibility groups, placing new members in their matching group,
|
|
111
|
+
then sort within each group. Use short sentence-case section comments, preserving acronym capitals such as HTML and URL.
|
|
75
112
|
Preserve required initialisation, side effects, fallback, precedence, lifecycle, overload, protocol and runtime order;
|
|
76
113
|
comment non-obvious constraints.
|
|
77
114
|
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Structured business views
|
|
2
|
+
|
|
3
|
+
Use an `<article>` for a structured view of business objects or an action on them, wherever it appears:
|
|
4
|
+
in `main`, a modal, a form or another view. Keep the same header, content and optional footer structure.
|
|
5
|
+
Notifications, navigation, inline references and other compact supporting elements may use smaller markup.
|
|
6
|
+
|
|
7
|
+
The standard edit view uses `<form>` as its article-equivalent root, with exactly the same structure.
|
|
8
|
+
Use this form root when the whole view is one submission; use articles for structured views within a larger form.
|
|
9
|
+
Never nest forms. A list uses an article containing its search/selection form.
|
|
10
|
+
|
|
11
|
+
Follow [templates and targets](../framework-changes/architecture/html-templates-and-targets.md) for expressions,
|
|
12
|
+
translation, URLs, fragment syntax, assets and HTML validation.
|
|
13
|
+
|
|
14
|
+
## Structure and identity
|
|
15
|
+
|
|
16
|
+
- Put the view directly inside its destination. In `main`, use `main > article` or `main > form`;
|
|
17
|
+
an extra wrapper prevents the standard panel layout from matching.
|
|
18
|
+
- Put `<header>` first, containing `<h2>` and, when needed, `<ul class="general actions">`.
|
|
19
|
+
Keep the heading even when the application hides it: the framework uses top-level headings for the breadcrumb.
|
|
20
|
+
Keep the document `<title>` consistent with it.
|
|
21
|
+
- Use one direct child for the content: a property list, table container, form or wrapper around several sections.
|
|
22
|
+
An optional direct `<footer>` follows it. Do not put several content siblings beside the header/footer:
|
|
23
|
+
`article.css` assigns them all to the same grid area, causing overlap.
|
|
24
|
+
- Put `data-action`, `data-class` and `data-route` on the article or equivalent form root.
|
|
25
|
+
They identify the view's operation, business class and addressed business route, respectively.
|
|
26
|
+
`data-class` is the reflected class name, not its display label. `data-route` excludes the action suffix;
|
|
27
|
+
use the object's route for an object view and the type's route for a collection.
|
|
28
|
+
Add `data-id="{?id}"` for an identified object; omit it for a new object or collection.
|
|
29
|
+
- Keep action names consistent with routes, CSS and action definitions. Use additional `data-*` attributes only
|
|
30
|
+
when the owning component consumes them.
|
|
31
|
+
|
|
32
|
+
`ux-core/css/article.css` supplies the header/content/footer grid and content scrolling for `main > article` and
|
|
33
|
+
`main > form`. Its grid selectors do not match modal or nested views. Preserve the structure there and use the
|
|
34
|
+
owning component's layout; provide scoped CSS if it needs equivalent sizing or scrolling.
|
|
35
|
+
Do not insert another `<main>` into a modal to obtain those styles.
|
|
36
|
+
|
|
37
|
+
## Properties, actions and forms
|
|
38
|
+
|
|
39
|
+
The action passes the business object or a small named view model to `htmlTemplateResponse`.
|
|
40
|
+
For an object context, use `{%name}`, `{@route}` and `<!--%orderedProperties-->`.
|
|
41
|
+
For a view model, enter its object block before using object reflection; collections use their explicit type/columns.
|
|
42
|
+
`{.actions}` and `{.action}` access the enclosing action context from the root object;
|
|
43
|
+
each loop changes the current context. Keep business decisions in the action.
|
|
44
|
+
|
|
45
|
+
- Object properties: `<ul class="object properties">`, with one `<li data-property="{name}">` per property.
|
|
46
|
+
For display, use `<label>{@display}</label>{outputMandatoryContainer}`.
|
|
47
|
+
For editing, use `{edit}`, which supplies the field markup and labels through the configured transformers.
|
|
48
|
+
For selected fields, use reflected properties such as `{%property.name.edit}` rather than rebuilding widgets.
|
|
49
|
+
- Actions: one `<li class="{action}">{{template}}</li>` per configured action in `ul.general.actions`.
|
|
50
|
+
Reuse action templates, captions, destinations and icon styles. Put selection actions in `ul.selection.actions`
|
|
51
|
+
within the selection form, normally in its footer. Buttons that do not submit must have `type="button"`.
|
|
52
|
+
- Forms: declare `action="app://(...)"`, `method="post"` for a mutation, and the response `target`.
|
|
53
|
+
Use `target="main"` for a view response and `target="#notifications:prepend"` for notification feedback.
|
|
54
|
+
A submit control may override these with `formaction` and `formtarget`.
|
|
55
|
+
Follow standard edit forms with `autocomplete="off"` and conditional `enctype="multipart/form-data"`
|
|
56
|
+
when file properties are present. Add `data-allow-new` only when related-object creation is intended.
|
|
57
|
+
- Lists: preserve the standard search/selection form, `table.objects`, column/filter metadata, feed include and
|
|
58
|
+
selection controls when using the list components. Start from `list/src/list.html` and `feed.html`;
|
|
59
|
+
copying just the visible table loses their browser contracts.
|
|
60
|
+
|
|
61
|
+
## Template for main
|
|
62
|
+
|
|
63
|
+
This object-view example is located at `app/customer/output.html`; adjust asset paths to the template's location.
|
|
64
|
+
Declare the styles the view uses, including `app.css`, `article.css`, action-bar styles and property/action styles.
|
|
65
|
+
Declare any view-specific browser build module in the head, as described in
|
|
66
|
+
[browser components](../framework-changes/architecture/browser-components.md).
|
|
67
|
+
|
|
68
|
+
```html
|
|
69
|
+
<!DOCTYPE html>
|
|
70
|
+
<html lang="en">
|
|
71
|
+
<head>
|
|
72
|
+
<meta charset="utf-8">
|
|
73
|
+
<link href="../../node_modules/@itrocks/ux-core/css/app.css" rel="stylesheet">
|
|
74
|
+
<link href="../../node_modules/@itrocks/ux-core/css/article.css" rel="stylesheet">
|
|
75
|
+
<link href="../../node_modules/@itrocks/action-bar/action.css" rel="stylesheet">
|
|
76
|
+
<link href="../../node_modules/@itrocks/output/css/output.css" rel="stylesheet">
|
|
77
|
+
<title>{@output.ucFirst}</title>
|
|
78
|
+
</head>
|
|
79
|
+
<body>
|
|
80
|
+
<main>
|
|
81
|
+
<!--BEGIN-->
|
|
82
|
+
<!--#main-->
|
|
83
|
+
<article data-action="output" data-class="{%name}" data-id="{?id}" data-route="{@route}">
|
|
84
|
+
<header>
|
|
85
|
+
<h2>{@output.ucFirst}</h2>
|
|
86
|
+
<ul class="general actions">
|
|
87
|
+
<li class="close"><a href="app://(@typeRoute)/list" target="main">Close</a></li>
|
|
88
|
+
<!--.actions-->
|
|
89
|
+
<li class="{action}">{{template}}</li>
|
|
90
|
+
<!--end-->
|
|
91
|
+
</ul>
|
|
92
|
+
</header>
|
|
93
|
+
<ul class="object properties">
|
|
94
|
+
<!--%orderedProperties-->
|
|
95
|
+
<li data-property="{name}"><label>{@display}</label>{outputMandatoryContainer}</li>
|
|
96
|
+
<!--end-->
|
|
97
|
+
</ul>
|
|
98
|
+
</article>
|
|
99
|
+
<!--#end-->
|
|
100
|
+
<!--END-->
|
|
101
|
+
</main>
|
|
102
|
+
</body>
|
|
103
|
+
</html>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Keep the document shell and `<main>` outside `BEGIN`/`END`: only the article enters the existing destination.
|
|
107
|
+
The application container owns navigation, breadcrumb, notifications, base URL and import map.
|
|
108
|
+
Use `<!--#main-->` for a response explicitly destined for `main`, as in the standard CRUD views.
|
|
109
|
+
For a view reusable in a modal or another target, omit that target block and its `<!--#end-->`:
|
|
110
|
+
the caller's `target` then chooses the destination. Keep `BEGIN`/`END` around the view in either case.
|
|
111
|
+
A notification response targets `#notifications:prepend` and contains notification items, not another business article.
|
|
112
|
+
|
|
113
|
+
## Edit variant
|
|
114
|
+
|
|
115
|
+
Keep the preceding document/fragment shell, link `edit/css/edit.css` and `save/css/action.css` as well,
|
|
116
|
+
and replace the article with this form. Set the document title to `{.action.ucFirst} {@output}`.
|
|
117
|
+
This follows the standard edit/new contract; the save response supplies notification feedback.
|
|
118
|
+
|
|
119
|
+
```html
|
|
120
|
+
<form action="app://(@route)/save" autocomplete="off" method="post" target="#notifications:prepend"
|
|
121
|
+
data-action="edit" data-class="{%name}" data-id="{?id}" data-route="{@route}"
|
|
122
|
+
data-if="{%hasFileProperty}" enctype="multipart/form-data" data-end>
|
|
123
|
+
<header>
|
|
124
|
+
<h2>{.action.ucFirst} {@output}</h2>
|
|
125
|
+
<ul class="general actions">
|
|
126
|
+
<li class="close"><a href="app://(@route)" target="main">Close</a></li>
|
|
127
|
+
<li class="save"><input type="submit" value="Save"></li>
|
|
128
|
+
<!--id?-->
|
|
129
|
+
<!--.actions-->
|
|
130
|
+
<li class="{action}">{{template}}</li>
|
|
131
|
+
<!--end-->
|
|
132
|
+
<!--end-->
|
|
133
|
+
</ul>
|
|
134
|
+
</header>
|
|
135
|
+
<ul class="object properties">
|
|
136
|
+
<!--%orderedProperties-->
|
|
137
|
+
<li data-property="{name}">{edit}</li>
|
|
138
|
+
<!--end-->
|
|
139
|
+
</ul>
|
|
140
|
+
</form>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Check resolved HTML and the inserted DOM using the
|
|
144
|
+
[validation rules](../framework-changes/architecture/html-templates-and-targets.md#authoring-and-validation).
|
|
145
|
+
Verify direct navigation and partial insertion, heading/breadcrumb, content scrolling, action destinations,
|
|
146
|
+
form submission and first-use asset loading. Check the actual modal/nested context when applicable.
|
|
147
|
+
|
|
148
|
+
Reference implementations, relative to `node_modules/@itrocks/`: `output/src/output.html`, `edit/src/edit.html`,
|
|
149
|
+
`list/src/list.html`, `list/src/feed.html`, `save/src/save.html`, `home/src/container.html`,
|
|
150
|
+
`ux-core/css/article.css` and `action/cjs/action.html`.
|
package/package.json
CHANGED