@gramlot/gramlot 0.3.4 → 0.3.6
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/dist/gramlot.js +1344 -875
- package/dist/gramlot.min.js +22 -23
- package/package.json +2 -2
- package/src/binding/ask-dialog.js +46 -23
- package/src/binding/inline.js +7 -5
- package/src/binding/installation.js +14 -5
- package/src/binding/logic.js +10 -5
- package/src/binding/pointer.js +6 -10
- package/src/binding/providers.js +105 -82
- package/src/binding/remote.js +60 -26
- package/src/binding/router.js +2 -4
- package/src/binding/rpc-resolver.js +102 -53
- package/src/binding/runtime.js +58 -17
- package/src/bootstrap.d.ts +8 -1
- package/src/bootstrap.js +28 -11
- package/src/builder/binding.json +13 -1
- package/src/builder/gramlot-builder.d.ts +5 -2
- package/src/builder/gramlot-builder.js +15 -7
- package/src/builder/name-syntax.d.ts +37 -0
- package/src/builder/name-syntax.js +54 -0
- package/src/builder/source.js +169 -13
- package/src/components/border-container.js +17 -10
- package/src/components/inputs.js +22 -3
- package/src/components/selected-container.js +19 -18
- package/src/dom.d.ts +3 -0
- package/src/format.js +3 -10
- package/src/frame-messages.js +2 -1
- package/src/gramlot.d.ts +12 -4
- package/src/gramlot.js +25 -10
- package/src/handlers/rpc-handler.d.ts +25 -12
- package/src/handlers/rpc-handler.js +57 -13
- package/src/handlers/source-handler.d.ts +13 -3
- package/src/handlers/source-handler.js +23 -18
- package/src/handlers/subscriptions-handler.js +24 -0
- package/src/http-transport.d.ts +11 -2
- package/src/http-transport.js +31 -11
- package/src/index.d.ts +4 -2
- package/src/index.js +6 -2
- package/src/random-id.js +14 -0
- package/src/renderer/attributes.js +1 -1
- package/src/renderer/gramlot-html-renderer.js +14 -5
- package/src/renderer/gramlot-renderer.js +3 -3
- package/src/server/conformance.d.ts +4 -2
- package/src/server/conformance.js +70 -9
- package/src/server/files.js +40 -0
- package/src/server/gramlot-file-server.d.ts +2 -0
- package/src/server/gramlot-file-server.js +18 -18
- package/src/server/gramlot-server.d.ts +26 -7
- package/src/server/gramlot-server.js +153 -33
- package/src/server/index-page.js +1 -1
- package/src/server/index.d.ts +3 -1
- package/src/server/index.js +2 -1
- package/src/server/page-base.js +55 -20
- package/src/server/page.d.ts +37 -15
- package/src/server/page.js +7 -0
- package/src/server/resources.d.ts +2 -0
- package/src/server-adapter.d.ts +17 -0
- package/src/server-adapter.js +23 -0
- package/src/view/button.js +5 -5
- package/src/view/controls.js +5 -6
- package/src/view/html.js +7 -1
- package/themes/gramlot-base/README.md +5 -4
- package/themes/gramlot-base/theme.css +2 -0
- package/themes/gramlot-compact/README.md +5 -12
- package/themes/joanna/README.md +2 -3
- package/themes/mimi/README.md +2 -3
package/src/view/button.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* target selection; this binding owns execution, ask, delay and disposal.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {AskDialog} from '../binding/ask-dialog.js';
|
|
7
6
|
|
|
8
7
|
export class ButtonBinding {
|
|
9
8
|
#binding;
|
|
@@ -107,7 +106,7 @@ export class ButtonBinding {
|
|
|
107
106
|
// Legacy reads inherited _delay. An explicit zero overrides an ancestor's delay.
|
|
108
107
|
let owner = this.node;
|
|
109
108
|
while (owner && owner.getAttr('_delay') == null) owner = owner.parentNode;
|
|
110
|
-
const delay = owner ? owner.
|
|
109
|
+
const delay = owner ? owner.rootBuilder.runtimeValues(owner)[1]._delay : 0;
|
|
111
110
|
if (delay > 0) {
|
|
112
111
|
const count = this.#pendingCount + 1;
|
|
113
112
|
this.#cancelDelay?.();
|
|
@@ -143,7 +142,7 @@ export class ButtonBinding {
|
|
|
143
142
|
provider?.invoke({kind: 'click', event, counter});
|
|
144
143
|
} else if (mechanism === 'action') {
|
|
145
144
|
const read = () => {
|
|
146
|
-
const [, attrs] = node.
|
|
145
|
+
const [, attrs] = node.rootBuilder.runtimeValues(node);
|
|
147
146
|
const authored = Object.fromEntries(Object.entries(attrs).filter(([name]) => name !== 'ask'));
|
|
148
147
|
return {...this.binding.runtime.renderer.references.resolveArguments(authored), event, _counter: counter, modifiers};
|
|
149
148
|
};
|
|
@@ -154,8 +153,9 @@ export class ButtonBinding {
|
|
|
154
153
|
this.binding.runtime.inlineCompiler.compile(node, 'action', node.getAttr('action'), Object.keys(values))(values);
|
|
155
154
|
};
|
|
156
155
|
const ask = node.getAttr('ask');
|
|
157
|
-
|
|
158
|
-
|
|
156
|
+
const askDialog = this.binding.runtime.askDialog;
|
|
157
|
+
if (ask && askDialog.required(this.binding, ask, read(), 'ask')) {
|
|
158
|
+
return askDialog.show(this.binding, ask, read()).then(execute);
|
|
159
159
|
}
|
|
160
160
|
execute(undefined);
|
|
161
161
|
} else {
|
package/src/view/controls.js
CHANGED
|
@@ -139,17 +139,16 @@ export class ControlAdapter {
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
/**
|
|
142
|
-
* Write `read()` at the `value` pointer (`^`, `?attr` included)
|
|
143
|
-
*
|
|
144
|
-
*
|
|
142
|
+
* Write `read()` at the `value` pointer (`^`, `?attr` included) with HtmlElement.writeParameter,
|
|
143
|
+
* the DOM → Data rule of component parameters too. A literal or `=` value accepts input and writes
|
|
144
|
+
* nothing (gate decision 5); a value equal to the Data value is not written; a null path raises
|
|
145
|
+
* from the listener (Q7). A closed NodeBinding writes nothing (R12).
|
|
145
146
|
*/
|
|
146
147
|
commit(event, value = this.read()) {
|
|
147
148
|
if (this.binding.closed) return;
|
|
148
|
-
const pointer = this.node.getAttr('value');
|
|
149
|
-
if (this.node.pointerType(pointer) !== '^') return;
|
|
150
149
|
this.#committing = true;
|
|
151
150
|
try {
|
|
152
|
-
this.
|
|
151
|
+
this.binding.runtime.renderer.html.writeParameter(this.node, 'value', value);
|
|
153
152
|
} finally {
|
|
154
153
|
this.#committing = false;
|
|
155
154
|
}
|
package/src/view/html.js
CHANGED
|
@@ -110,7 +110,13 @@ export class HtmlElement {
|
|
|
110
110
|
&& record.element.namespaceURI === namespace;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
/**
|
|
113
|
+
/**
|
|
114
|
+
* Write `value`, produced in the DOM, through the attribute `name` of `node`: the one DOM → Data
|
|
115
|
+
* rule, used by component parameters and by ControlAdapter.commit. Only a plain reactive `^`
|
|
116
|
+
* pointer writes; a literal, a `=` pointer and a pointer with a suffix write nothing (no inverse
|
|
117
|
+
* conversion, 11.81). A value equal (`Object.is`) to the Data value is not written, as the legacy
|
|
118
|
+
* `setAttributeInDatasource` with `lazySet`: a null value on a missing path creates no Data node.
|
|
119
|
+
*/
|
|
114
120
|
writeParameter(node, name, value) {
|
|
115
121
|
const pointer = node.getAttr(name);
|
|
116
122
|
if (node.pointerType(pointer) === '^' && !pointerTransform(pointer)
|
|
@@ -6,15 +6,16 @@
|
|
|
6
6
|
<link rel="stylesheet" href="/themes/gramlot-base/theme.css">
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
The adapters of `gramlot-py-server` and `gramlot-js-server` serve the themes packaged with the core at `/themes/…`, below the mount prefix, and `@gramlot/gramlot-serverless` copies or inlines them in its export. Another host must serve this file at that path. The theme styles semantic HTML, forms, tables, dialogs, details, code, focus states, and a few optional layout classes: `.example-page`, `.stack`, `.grid`, `.card`, `.muted`, and fluid SVG `.example-art`. Secondary button variants are `.button--secondary` and `.button--quiet`; status chips use `.status` with a semantic modifier. SVG icons can use `.gramlot-icon` (fill) or `.gramlot-icon--stroke` (stroke) and inherit `currentColor`. Supply an accessible name or mark decorative icons `aria-hidden="true"` in the application.
|
|
9
|
+
The adapters of `gramlot-py-server` and `gramlot-js-server` serve the themes packaged with the core at `/themes/…`, below the mount prefix, and `@gramlot/gramlot-serverless` copies or inlines them in its export. Another host must serve this file at that path. The theme styles semantic HTML, forms, tables, dialogs, details, code, focus states, and a few optional layout classes: `.example-page`, `.stack`, `.grid`, `.card`, `.muted`, `.actions` (a wrapping row of buttons), `.eyebrow` (a small uppercase label above a heading), and fluid SVG `.example-art`. Secondary button variants are `.button--secondary` and `.button--quiet`; status chips use `.status` with a semantic modifier. SVG icons can use `.gramlot-icon` (fill) or `.gramlot-icon--stroke` (stroke) and inherit `currentColor`. Supply an accessible name or mark decorative icons `aria-hidden="true"` in the application.
|
|
10
10
|
|
|
11
11
|
## Available themes
|
|
12
12
|
|
|
13
13
|
Base is the original theme. [Compact](../gramlot-compact/README.md) is its denser
|
|
14
14
|
alternative, with smaller headings, gaps, card padding and form controls. Both
|
|
15
|
-
support light and dark mode.
|
|
16
|
-
|
|
17
|
-
list can be declared once on a shared
|
|
15
|
+
support light and dark mode. A Gramlot server loads Base on every page as its base
|
|
16
|
+
theme (option `css_theme`, GC-090 §030); a page adds `/themes/gramlot-compact/theme.css`
|
|
17
|
+
with `Page.css` for Compact. The `Page.css` list can be declared once on a shared
|
|
18
|
+
application Page base class.
|
|
18
19
|
|
|
19
20
|
## Tokens and extension
|
|
20
21
|
|
|
@@ -255,6 +255,8 @@
|
|
|
255
255
|
.example-art { display: block; inline-size: 100%; block-size: auto; }
|
|
256
256
|
.example-art { display: block; inline-size: 100%; block-size: auto; }
|
|
257
257
|
.muted { color: var(--gramlot-text-secondary); }
|
|
258
|
+
.actions { display: flex; flex-wrap: wrap; gap: var(--gramlot-space-2); }
|
|
259
|
+
.eyebrow { margin: 0; color: var(--gramlot-text-secondary); font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
|
|
258
260
|
.surface-subtle { background: var(--gramlot-surface-subtle); }
|
|
259
261
|
.status { display: inline-flex; align-items: center; gap: 0.4em; border-radius: 999px; padding: 0.25em 0.65em; font-size: 0.75rem; font-weight: 650; }
|
|
260
262
|
.status--success { background: var(--gramlot-success-background); color: var(--gramlot-success); }
|
|
@@ -4,35 +4,28 @@ Compact is the denser alternative to Gramlot Base. It reduces typography, spacin
|
|
|
4
4
|
headings, card padding, table cells and form controls. It shares Base's palette,
|
|
5
5
|
light/dark modes, focus indicators and semantic HTML rules.
|
|
6
6
|
|
|
7
|
-
Load
|
|
7
|
+
Load Compact after Base. The server loads Base as its base theme (GC-090 §030);
|
|
8
|
+
the page adds Compact with `Page.css`. Compact contains only the size and spacing
|
|
8
9
|
rules that differ; it does not duplicate the Base stylesheet or import another URL.
|
|
9
|
-
The same resource list works with Python servers, JavaScript servers and standalone
|
|
10
|
-
exports using the existing `Page.css` mechanism.
|
|
11
10
|
|
|
12
11
|
```python
|
|
13
12
|
from gramlot import Page as BasePage
|
|
14
13
|
|
|
15
14
|
class Page(BasePage):
|
|
16
|
-
css = (
|
|
17
|
-
"/themes/gramlot-base/theme.css",
|
|
18
|
-
"/themes/gramlot-compact/theme.css",
|
|
19
|
-
)
|
|
15
|
+
css = ("/themes/gramlot-compact/theme.css",)
|
|
20
16
|
```
|
|
21
17
|
|
|
22
18
|
```javascript
|
|
23
19
|
import {Page as BasePage} from '@gramlot/gramlot/page';
|
|
24
20
|
|
|
25
21
|
export class Page extends BasePage {
|
|
26
|
-
static css = [
|
|
27
|
-
'/themes/gramlot-base/theme.css',
|
|
28
|
-
'/themes/gramlot-compact/theme.css',
|
|
29
|
-
];
|
|
22
|
+
static css = ['/themes/gramlot-compact/theme.css'];
|
|
30
23
|
}
|
|
31
24
|
```
|
|
32
25
|
|
|
33
26
|
Declare this list on a shared application Page base class to reuse it across pages.
|
|
34
27
|
Keep the usual native elements and classes in `main`; there is no theme-specific
|
|
35
|
-
builder syntax.
|
|
28
|
+
builder syntax. Declare no `css` to use the original theme, Base alone.
|
|
36
29
|
|
|
37
30
|
| Setting | Base | Compact |
|
|
38
31
|
| --- | --- | --- |
|
package/themes/joanna/README.md
CHANGED
|
@@ -6,12 +6,11 @@ implemented for current HTML and Gramlot components, without Dojo dependencies.
|
|
|
6
6
|
Dark mode is a new coordinated adaptation. It is not a pixel-identical port of
|
|
7
7
|
legacy layout widgets. Legacy user color variants are outside this increment.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
The server loads Base (its base theme, GC-090 §030); load Compact and this profile after it:
|
|
10
10
|
|
|
11
11
|
```python
|
|
12
12
|
class Page(BasePage):
|
|
13
|
-
css = ("/themes/gramlot-
|
|
14
|
-
"/themes/gramlot-compact/theme.css",
|
|
13
|
+
css = ("/themes/gramlot-compact/theme.css",
|
|
15
14
|
"/themes/joanna/theme.css")
|
|
16
15
|
```
|
|
17
16
|
|
package/themes/mimi/README.md
CHANGED
|
@@ -6,12 +6,11 @@ implemented for current HTML and Gramlot components, without Dojo dependencies.
|
|
|
6
6
|
Dark mode is a new coordinated adaptation. It is not a pixel-identical port of
|
|
7
7
|
legacy layout widgets. Legacy user color variants are outside this increment.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
The server loads Base (its base theme, GC-090 §030); load Compact and this profile after it:
|
|
10
10
|
|
|
11
11
|
```python
|
|
12
12
|
class Page(BasePage):
|
|
13
|
-
css = ("/themes/gramlot-
|
|
14
|
-
"/themes/gramlot-compact/theme.css",
|
|
13
|
+
css = ("/themes/gramlot-compact/theme.css",
|
|
15
14
|
"/themes/mimi/theme.css")
|
|
16
15
|
```
|
|
17
16
|
|