@gramlot/gramlot 0.2.19 → 0.3.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/dist/gramlot.js +2145 -224
- package/dist/gramlot.min.js +363 -21
- package/package.json +6 -3
- package/src/binding/ask-dialog.js +2 -2
- package/src/binding/inline.js +11 -12
- package/src/binding/installation.js +4 -1
- package/src/binding/pointer.js +63 -0
- package/src/binding/providers.js +8 -4
- package/src/binding/runtime.js +11 -5
- package/src/bootstrap.d.ts +2 -0
- package/src/bootstrap.js +9 -2
- package/src/builder/gramlot-builder.js +24 -3
- package/src/builder/source.js +33 -9
- package/src/components/bases.js +182 -0
- package/src/components/buttons.js +254 -0
- package/src/components/choice-editor.js +221 -0
- package/src/components/choices.js +13 -0
- package/src/components/date-calendar.js +139 -0
- package/src/components/field-state.js +166 -0
- package/src/components/formlet-labels.js +80 -0
- package/src/components/index.js +5 -0
- package/src/components/inputs.js +196 -0
- package/src/components/labelbox.js +74 -0
- package/src/components/layout.js +190 -0
- package/src/components/parameters.js +6 -0
- package/src/components/popup.js +22 -0
- package/src/components/registry.js +83 -0
- package/src/components/typed-editor.js +260 -0
- package/src/components/validation.js +138 -0
- package/src/date-parser/civil.js +61 -0
- package/src/date-parser/index.d.ts +18 -0
- package/src/date-parser/index.js +196 -0
- package/src/date-parser/locales.js +257 -0
- package/src/format.js +128 -0
- package/src/gramlot.d.ts +25 -0
- package/src/gramlot.js +15 -1
- package/src/handlers/dom-handler.d.ts +1 -0
- package/src/handlers/dom-handler.js +7 -0
- package/src/index-page-runtime.js +78 -30
- package/src/index-page-styles.js +2 -2
- package/src/index-theme.js +1 -1
- package/src/index.d.ts +4 -1
- package/src/index.js +2 -0
- package/src/renderer/attributes.js +25 -50
- package/src/renderer/gramlot-html-renderer.js +4 -3
- package/src/renderer/gramlot-renderer.js +63 -3
- package/src/server/gramlot-server.d.ts +5 -0
- package/src/server/gramlot-server.js +14 -5
- package/src/server/index-page.d.ts +1 -0
- package/src/server/index-page.js +8 -3
- package/src/server/page-base.js +3 -0
- package/src/server/page.d.ts +3 -0
- package/src/server/resources.d.ts +2 -0
- package/src/view/button.js +17 -13
- package/src/view/controls.js +152 -4
- package/src/view/html.js +18 -0
- package/themes/gramlot-base/README.md +6 -0
- package/themes/gramlot-base/theme.css +34 -6
- package/themes/gramlot-compact/README.md +6 -0
- package/themes/gramlot-compact/theme.css +8 -4
- package/themes/joanna/README.md +23 -0
- package/themes/joanna/theme.css +89 -0
- package/themes/mimi/README.md +23 -0
- package/themes/mimi/theme.css +89 -0
- package/tools/gramlot-tools-inspector.js +42 -18
- package/tools/inspector-agent.js +8 -4
package/src/view/controls.js
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* Checkbox and radio consume `value` as a boolean; RadioGroups gives the radios of a group their name.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import {createDecimal, isDecimal, getDecimalLibrary} from '@genrojs/tytx';
|
|
9
|
+
import {Bag} from '@genrojs/bag';
|
|
8
10
|
import {XHTML_NS} from '../renderer/attributes.js';
|
|
9
11
|
|
|
10
12
|
// The elements whose `type`, `multiple` and `group` have no setter: a change rebuilds (C04.1, D7).
|
|
@@ -22,6 +24,9 @@ export class ControlAdapter {
|
|
|
22
24
|
static liveWrites = false;
|
|
23
25
|
// Whether a literal `value` is also written as the default a native form Reset restores.
|
|
24
26
|
static writesDefault = true;
|
|
27
|
+
static preservesUnchangedValue = false;
|
|
28
|
+
#projectedValue;
|
|
29
|
+
#hasProjectedValue = false;
|
|
25
30
|
#binding;
|
|
26
31
|
#record;
|
|
27
32
|
#committing = false;
|
|
@@ -41,6 +46,10 @@ export class ControlAdapter {
|
|
|
41
46
|
*/
|
|
42
47
|
static classFor(element, attrs) {
|
|
43
48
|
if (element.namespaceURI !== XHTML_NS) return null;
|
|
49
|
+
if (element.constructor.gramlotComponent) {
|
|
50
|
+
if (element.constructor.gramlotComponent.parameters.value?.binding !== 'twoWay') return null;
|
|
51
|
+
return element.control.type === 'radio' ? ComponentRadioControl : ComponentControl;
|
|
52
|
+
}
|
|
44
53
|
if (element.localName === 'textarea') return TextControl;
|
|
45
54
|
if (element.localName === 'select') return SelectControl;
|
|
46
55
|
if (element.localName !== 'input') return null;
|
|
@@ -54,6 +63,7 @@ export class ControlAdapter {
|
|
|
54
63
|
* `attrs` are the attributes of the renderer's resolved projection (`^`, `=` and `==` resolved).
|
|
55
64
|
*/
|
|
56
65
|
static shape(element, attrs) {
|
|
66
|
+
if (element?.constructor.gramlotComponent?.parameters.value?.binding === 'twoWay' && element.control.type === 'radio') return JSON.stringify([attrs.group ?? null]);
|
|
57
67
|
if (element?.namespaceURI !== XHTML_NS || !CONTROL_TAGS.has(element.localName)) return null;
|
|
58
68
|
return JSON.stringify(REBUILD_ATTRIBUTES.map(name => attrs[name] ?? null));
|
|
59
69
|
}
|
|
@@ -66,6 +76,7 @@ export class ControlAdapter {
|
|
|
66
76
|
get binding() { return this.#binding; }
|
|
67
77
|
get element() { return this.#record.element; }
|
|
68
78
|
get node() { return this.binding.node; }
|
|
79
|
+
get eventElement() { return this.element; }
|
|
69
80
|
/** The attributes of the last resolved projection of the node (`^`, `=` and `==` resolved). */
|
|
70
81
|
get resolved() { return this.#record.resolved; }
|
|
71
82
|
/**
|
|
@@ -88,6 +99,9 @@ export class ControlAdapter {
|
|
|
88
99
|
this.#pending = true;
|
|
89
100
|
return;
|
|
90
101
|
}
|
|
102
|
+
if (this.constructor.preservesUnchangedValue && this.#hasProjectedValue && this.same(this.#projectedValue, value)) return;
|
|
103
|
+
this.#projectedValue = value;
|
|
104
|
+
this.#hasProjectedValue = true;
|
|
91
105
|
if (this.#committing && this.same(this.read(), value)) return;
|
|
92
106
|
if (this.constructor.writesDefault && !this.node.pointerType(this.node.getAttr('value'))) {
|
|
93
107
|
this.writeDefault(value);
|
|
@@ -129,13 +143,13 @@ export class ControlAdapter {
|
|
|
129
143
|
* input and writes nothing (gate decision 5); a null path raises from the listener (Q7). A closed
|
|
130
144
|
* NodeBinding writes nothing (R12).
|
|
131
145
|
*/
|
|
132
|
-
commit(event) {
|
|
146
|
+
commit(event, value = this.read()) {
|
|
133
147
|
if (this.binding.closed) return;
|
|
134
148
|
const pointer = this.node.getAttr('value');
|
|
135
149
|
if (this.node.pointerType(pointer) !== '^') return;
|
|
136
150
|
this.#committing = true;
|
|
137
151
|
try {
|
|
138
|
-
this.node.setRelativeData(pointer.slice(1),
|
|
152
|
+
this.node.setRelativeData(pointer.slice(1), value);
|
|
139
153
|
} finally {
|
|
140
154
|
this.#committing = false;
|
|
141
155
|
}
|
|
@@ -143,13 +157,13 @@ export class ControlAdapter {
|
|
|
143
157
|
|
|
144
158
|
attach() {
|
|
145
159
|
for (const type of ['input', 'change', 'compositionstart', 'compositionend']) {
|
|
146
|
-
this.
|
|
160
|
+
this.eventElement.addEventListener(type, this);
|
|
147
161
|
}
|
|
148
162
|
}
|
|
149
163
|
|
|
150
164
|
detach() {
|
|
151
165
|
for (const type of ['input', 'change', 'compositionstart', 'compositionend']) {
|
|
152
|
-
this.
|
|
166
|
+
this.eventElement.removeEventListener(type, this);
|
|
153
167
|
}
|
|
154
168
|
this.#pending = false;
|
|
155
169
|
}
|
|
@@ -181,6 +195,41 @@ export class ControlAdapter {
|
|
|
181
195
|
}
|
|
182
196
|
}
|
|
183
197
|
|
|
198
|
+
/** Custom controls share the existing typed commit, IME and cleanup machinery. */
|
|
199
|
+
class ComponentControl extends ControlAdapter {
|
|
200
|
+
static writesDefault = false;
|
|
201
|
+
static preservesUnchangedValue = true;
|
|
202
|
+
get eventElement() { return this.element.control; }
|
|
203
|
+
attach() {
|
|
204
|
+
this.element.setPageContext(componentContext(this));
|
|
205
|
+
super.attach();
|
|
206
|
+
}
|
|
207
|
+
project(value, change) {
|
|
208
|
+
if (this.element.shouldProjectControlValue(value)) super.project(value, change);
|
|
209
|
+
}
|
|
210
|
+
same(a, b) { return this.element.sameControlValue(a, b); }
|
|
211
|
+
detach() { this.element.releaseControl(); super.detach(); }
|
|
212
|
+
commit(event) {
|
|
213
|
+
if (this.binding.closed || this.element.control.disabled || this.element.control.readOnly) return;
|
|
214
|
+
commitComponent(this.element, this.element.acceptControlValue(), result => super.commit(event, result.value));
|
|
215
|
+
}
|
|
216
|
+
get writeEvent() {
|
|
217
|
+
if (this.element.commitOnChange) return 'change';
|
|
218
|
+
const control = this.element.control;
|
|
219
|
+
return this.live && (control.localName === 'textarea' || ['text', 'password', 'range', 'color'].includes(control.type)) ? 'input' : 'change';
|
|
220
|
+
}
|
|
221
|
+
read() { return this.element.readControlValue(); }
|
|
222
|
+
write(value) { this.element.writeControlValue(value); }
|
|
223
|
+
handleEvent(event) {
|
|
224
|
+
super.handleEvent(event);
|
|
225
|
+
// Native change does not cross a shadow boundary; expose it to connect_onchange.
|
|
226
|
+
if (!event.composed && !this.binding.closed && ['input', 'change'].includes(event.type)) {
|
|
227
|
+
const Event = this.element.ownerDocument.defaultView.Event;
|
|
228
|
+
this.element.dispatchEvent(new Event(event.type, {bubbles: true, composed: true}));
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
184
233
|
/** text, password, email, url, tel, search, textarea: a string; the empty string stays. */
|
|
185
234
|
export class TextControl extends ControlAdapter {
|
|
186
235
|
static liveWrites = true;
|
|
@@ -395,6 +444,54 @@ export class RadioControl extends CheckboxControl {
|
|
|
395
444
|
}
|
|
396
445
|
}
|
|
397
446
|
|
|
447
|
+
/** A single radio component joins the same Source-scoped groups as native radios. */
|
|
448
|
+
class ComponentRadioControl extends RadioControl {
|
|
449
|
+
static writesDefault = false;
|
|
450
|
+
get host() { return super.element; }
|
|
451
|
+
get element() { return this.host.control; }
|
|
452
|
+
project(value, change) {
|
|
453
|
+
if (this.host.shouldProjectControlValue(value)) super.project(value, change);
|
|
454
|
+
}
|
|
455
|
+
commit(event) {
|
|
456
|
+
if (this.binding.closed || this.element.disabled || this.element.readOnly) return;
|
|
457
|
+
commitComponent(this.host, this.host.acceptControlValue(), () => super.commit(event));
|
|
458
|
+
}
|
|
459
|
+
read() { return this.host.readControlValue(); }
|
|
460
|
+
write(value) { this.host.writeControlValue(value); }
|
|
461
|
+
attach() {
|
|
462
|
+
this.host.setPageContext(componentContext(this));
|
|
463
|
+
super.attach();
|
|
464
|
+
this.element.addEventListener('keydown', this);
|
|
465
|
+
}
|
|
466
|
+
detach() {
|
|
467
|
+
this.host.releaseControl();
|
|
468
|
+
this.element.removeEventListener('keydown', this);
|
|
469
|
+
super.detach();
|
|
470
|
+
}
|
|
471
|
+
handleEvent(event) {
|
|
472
|
+
if (this.binding.closed) return;
|
|
473
|
+
// Separate shadow roots cannot use the browser's same-tree radio navigation.
|
|
474
|
+
if (event.type === 'keydown') {
|
|
475
|
+
if (this.resolved.group == null || !['ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].includes(event.key)) return;
|
|
476
|
+
const peers = this.groups.peersOf(this.resolved.group, formNode(this.node))
|
|
477
|
+
.filter(peer => !peer.binding.closed && !peer.element.disabled);
|
|
478
|
+
const index = peers.indexOf(this);
|
|
479
|
+
if (index < 0) return;
|
|
480
|
+
event.preventDefault();
|
|
481
|
+
const delta = ['ArrowLeft', 'ArrowUp'].includes(event.key) ? -1 : 1;
|
|
482
|
+
const next = peers[(index + delta + peers.length) % peers.length];
|
|
483
|
+
next.element.focus();
|
|
484
|
+
next.element.click();
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
super.handleEvent(event);
|
|
488
|
+
if (!event.composed && !this.binding.closed && ['input', 'change'].includes(event.type)) {
|
|
489
|
+
const Event = this.host.ownerDocument.defaultView.Event;
|
|
490
|
+
this.host.dispatchEvent(new Event(event.type, {bubbles: true, composed: true}));
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
398
495
|
/**
|
|
399
496
|
* The radio groups of one live renderer (P11). A group is the `group` value within its form: the
|
|
400
497
|
* nearest Source ancestor with `formId` or `form=true`, or none. The generated `name` joins the
|
|
@@ -467,3 +564,54 @@ const INPUT_CONTROLS = {
|
|
|
467
564
|
hidden: null, file: null,
|
|
468
565
|
button: null, submit: null, reset: null, image: null,
|
|
469
566
|
};
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
/** Component validation uses the same Source, activated code and RPC services as controllers. */
|
|
570
|
+
function componentContext(adapter) {
|
|
571
|
+
const {binding, node} = adapter, app = binding.runtime.gramlot;
|
|
572
|
+
const invoke = (attribute, code, keywords, expression = false) => {
|
|
573
|
+
if (!expression && /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(code)) {
|
|
574
|
+
const {group, method} = app.src.logicRegistry.resolve(code, node);
|
|
575
|
+
return method.call(group, node, keywords);
|
|
576
|
+
}
|
|
577
|
+
return binding.runtime.inlineCompiler.compile(node, attribute, code, Object.keys(keywords),
|
|
578
|
+
expression ? `return (${code});` : code)(keywords);
|
|
579
|
+
};
|
|
580
|
+
return {
|
|
581
|
+
locale:app.locale, timeZone:app.timeZone, createDecimal, isDecimal, getDecimalLibrary,
|
|
582
|
+
isActive:() => !binding.closed,
|
|
583
|
+
callLogic:(name, keywords) => {
|
|
584
|
+
const {group, method} = app.src.logicRegistry.resolve(name, node);
|
|
585
|
+
return method.call(group, node, keywords);
|
|
586
|
+
},
|
|
587
|
+
format:(value, options) => app.format(value, options), invoke,
|
|
588
|
+
remote:(method, keywords, signal) => app.rpc.call('data', method, keywords, {signal}),
|
|
589
|
+
validationCurrent:() => {
|
|
590
|
+
const pointer = node.getAttr('value');
|
|
591
|
+
const path = node.pointerType(pointer) ? node.absDatapath(pointer) : null;
|
|
592
|
+
return () => !binding.closed && node.getAttr('value') === pointer && (path === null || node.absDatapath(pointer) === path);
|
|
593
|
+
},
|
|
594
|
+
finishValidation:({ok, result, rules}) => {
|
|
595
|
+
if (binding.closed) return;
|
|
596
|
+
if (ok) for (const patch of result.datachanges) node.getRelativeData('.').update(patch);
|
|
597
|
+
const attribute = ok ? 'validate_onAccept' : 'validate_onReject';
|
|
598
|
+
if (rules[attribute]) {
|
|
599
|
+
const report = error => console.error('Validation notification failed:', error);
|
|
600
|
+
try {
|
|
601
|
+
const validations = Object.fromEntries(Object.entries(rules).map(([key, value]) => [key.slice(9), value]));
|
|
602
|
+
const returned = invoke(attribute, rules[attribute], {value:result.value, result, validations, userChange:true});
|
|
603
|
+
if (returned instanceof Promise) returned.catch(report);
|
|
604
|
+
} catch (error) { report(error); }
|
|
605
|
+
}
|
|
606
|
+
},
|
|
607
|
+
checkDataPatch:patch => {
|
|
608
|
+
if (!(patch instanceof Bag)) throw new TypeError('Validation data changes must be a Bag.');
|
|
609
|
+
if (!(node.getRelativeData('.') instanceof Bag)) throw new TypeError('Validation data changes require a Bag datapath.');
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
function commitComponent(host, outcome, commit) {
|
|
614
|
+
const finish = result => { if (result.ok && result.isCurrent()) { commit(result); host.finishValidation(result); } };
|
|
615
|
+
if (outcome instanceof Promise) outcome.then(finish).catch(error => console.error('Validation notification failed:', error));
|
|
616
|
+
else finish(outcome);
|
|
617
|
+
}
|
package/src/view/html.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {SourceBag, META_ATTRS, resolveRenderTag, sourceAttributeItems, SvgBuilder} from '@genrojs/builders';
|
|
2
2
|
import {ControlAdapter} from './controls.js';
|
|
3
3
|
import {SVG_NS, XHTML_NS} from '../renderer/attributes.js';
|
|
4
|
+
import {requireNoScriptAttributes, requireStyleClassAttributes} from '../renderer/attributes.js';
|
|
4
5
|
import {webcomponentCode} from '../webcomponent.js';
|
|
5
6
|
|
|
6
7
|
const DEFAULT_TEXT = Symbol('source text');
|
|
@@ -61,6 +62,7 @@ export class HtmlElement {
|
|
|
61
62
|
throw new TypeError('HTML text must be scalar');
|
|
62
63
|
}
|
|
63
64
|
for (const [key, value] of Object.entries(node.attr)) {
|
|
65
|
+
if (key === 'value' && this.definition(node).meta.gramlot_component) continue;
|
|
64
66
|
if (this.metadataAttributes.has(key) || ['ask', '_ask'].includes(key) || (value && typeof value === 'object' && Object.hasOwn(value, '$gramlotRef'))) continue;
|
|
65
67
|
if (value != null && !['string', 'number', 'boolean'].includes(typeof value)) {
|
|
66
68
|
throw new TypeError(`HTML attribute ${key} must be scalar`);
|
|
@@ -79,6 +81,15 @@ export class HtmlElement {
|
|
|
79
81
|
tag ??= defaultTag;
|
|
80
82
|
const element = namespace === XHTML_NS
|
|
81
83
|
? document.createElement(tag) : document.createElementNS(namespace, tag);
|
|
84
|
+
if (meta.gramlot_component && element.constructor.gramlotComponent?.tag !== tag) {
|
|
85
|
+
throw new Error(`Component collection must be activated before rendering ${tag}`);
|
|
86
|
+
}
|
|
87
|
+
if (meta.gramlot_component?.dataScope) {
|
|
88
|
+
element.readDataScope = () => {
|
|
89
|
+
if (!node.getAttr('datapath')) throw new Error('Data scope requires an explicit datapath');
|
|
90
|
+
return node.getRelativeData('.');
|
|
91
|
+
};
|
|
92
|
+
}
|
|
82
93
|
const text = document.createTextNode(this.text(node));
|
|
83
94
|
if (namespace !== XHTML_NS || !meta.void) element.append(text);
|
|
84
95
|
const record = {element, text, tag};
|
|
@@ -108,6 +119,13 @@ export class HtmlElement {
|
|
|
108
119
|
const isHtml = element.namespaceURI === XHTML_NS;
|
|
109
120
|
const renderAttributes = this.definition(node).meta.render_attributes ?? {};
|
|
110
121
|
const previous = record.attrs ?? {};
|
|
122
|
+
if (this.definition(node).meta.gramlot_component) {
|
|
123
|
+
attrs = element.projectAttributes(attrs, values => {
|
|
124
|
+
requireNoScriptAttributes(node, values, node.builder.constructor.dialectPrefixes);
|
|
125
|
+
requireStyleClassAttributes(node, values, node.builder.constructor.dialectPrefixes);
|
|
126
|
+
return node.builder.renderer_html.adaptAttrs(values);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
111
129
|
attrs = Object.fromEntries(sourceAttributeItems({...attrs, ...renderAttributes}));
|
|
112
130
|
const controlled = ControlAdapter.classFor(element, attrs) !== null;
|
|
113
131
|
if (textValue === DEFAULT_TEXT) textValue = this.text(node);
|
|
@@ -36,3 +36,9 @@ Modern evergreen browsers are the intended target. Cascade layers, `clamp()`, CS
|
|
|
36
36
|
Syntax highlighting uses `.hljs-*` token classes mapped to the same semantic colors in light and dark mode. Python and JavaScript detection belongs to the runtime; the theme only styles the resulting code spans.
|
|
37
37
|
|
|
38
38
|
The base text size is 14px with compact headings and spacing. Navigation surfaces use the tokens `--gramlot-navigation` and `--gramlot-navigation-text`, the approved navy surface; a selected item uses the blue and the brand accent the yellow of the existing palette, not new colors.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
For additional compact palettes, load `mimi/theme.css` or
|
|
42
|
+
`joanna/theme.css` after Base and Compact. Both inherit the same semantic
|
|
43
|
+
variables and style input components as well as ordinary HTML. See
|
|
44
|
+
[theme profiles](../../docs/public/096-themes-and-css.md#gc-096-017).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* Gramlot Base: application UI theme. Brand sources: assets/branding/theme-tokens.json. */
|
|
2
|
-
@layer gramlot.reset, gramlot.tokens, gramlot.base, gramlot.components, gramlot.utilities;
|
|
2
|
+
@layer gramlot.reset, gramlot.tokens, gramlot.base, gramlot.components, gramlot.utilities, gramlot.touch;
|
|
3
3
|
|
|
4
4
|
@layer gramlot.reset {
|
|
5
5
|
*, *::before, *::after { box-sizing: border-box; }
|
|
@@ -34,6 +34,12 @@
|
|
|
34
34
|
--gramlot-error: #b13d48;
|
|
35
35
|
--gramlot-error-background: #fceef0;
|
|
36
36
|
|
|
37
|
+
--gramlot-field-height: 2.75rem;
|
|
38
|
+
--gramlot-field-padding: .55rem .75rem;
|
|
39
|
+
--gramlot-field-font-size: .875rem;
|
|
40
|
+
--gramlot-field-background: var(--gramlot-surface);
|
|
41
|
+
--gramlot-field-readonly-background: var(--gramlot-surface-subtle);
|
|
42
|
+
--gramlot-label-size: 1em;
|
|
37
43
|
--gramlot-font-ui: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
|
|
38
44
|
--gramlot-font-code: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
39
45
|
--gramlot-space-1: 0.25rem;
|
|
@@ -185,14 +191,14 @@
|
|
|
185
191
|
display: block;
|
|
186
192
|
inline-size: 100%;
|
|
187
193
|
min-inline-size: 0;
|
|
188
|
-
min-block-size:
|
|
194
|
+
min-block-size: var(--gramlot-field-height);
|
|
189
195
|
border: 1px solid var(--gramlot-border-control);
|
|
190
196
|
border-radius: var(--gramlot-radius-sm);
|
|
191
|
-
background: var(--gramlot-
|
|
197
|
+
background: var(--gramlot-field-background);
|
|
192
198
|
color: var(--gramlot-ink);
|
|
193
|
-
padding:
|
|
194
|
-
font-size:
|
|
195
|
-
line-height: 1.5;
|
|
199
|
+
padding: var(--gramlot-field-padding);
|
|
200
|
+
font-size: var(--gramlot-field-font-size);
|
|
201
|
+
line-height: var(--gramlot-field-line-height,1.5);
|
|
196
202
|
}
|
|
197
203
|
:where(textarea) { min-block-size: 7rem; resize: vertical; }
|
|
198
204
|
:where(input, textarea)::placeholder { color: var(--gramlot-text-secondary); opacity: 1; }
|
|
@@ -262,3 +268,25 @@
|
|
|
262
268
|
html { scroll-behavior: auto; }
|
|
263
269
|
*, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
|
|
264
270
|
}
|
|
271
|
+
|
|
272
|
+
/* Interaction density is independent of the selected color/profile theme. */
|
|
273
|
+
@layer gramlot.touch {
|
|
274
|
+
:root[data-gramlot-touch="on"] {--gramlot-touch-target:44px; --gramlot-field-height:44px; --gramlot-field-font-size:16px;
|
|
275
|
+
--gramlot-field-padding:8px 10px; --gramlot-field-line-height:1.35;
|
|
276
|
+
--gramlot-label-size:14px; --gramlot-label-gap:6px; --gramlot-space-2:10px;
|
|
277
|
+
--gramlot-calendar-width:322px; --gramlot-choice-toggle-width:44px;}
|
|
278
|
+
@media (pointer: coarse) {
|
|
279
|
+
:root:not([data-gramlot-touch="off"]) {--gramlot-touch-target:44px; --gramlot-field-height:44px; --gramlot-field-font-size:16px;
|
|
280
|
+
--gramlot-field-padding:8px 10px; --gramlot-field-line-height:1.35;
|
|
281
|
+
--gramlot-label-size:14px; --gramlot-label-gap:6px; --gramlot-space-2:10px;
|
|
282
|
+
--gramlot-calendar-width:322px; --gramlot-choice-toggle-width:44px;}
|
|
283
|
+
}
|
|
284
|
+
button, select, input:not([type=checkbox]):not([type=radio]), summary {
|
|
285
|
+
min-block-size:var(--gramlot-touch-target, revert-layer);
|
|
286
|
+
}
|
|
287
|
+
button { min-inline-size:var(--gramlot-touch-target, revert-layer); }
|
|
288
|
+
input[type=checkbox], input[type=radio] {
|
|
289
|
+
min-inline-size:calc(var(--gramlot-touch-target, 0px) / 2);
|
|
290
|
+
min-block-size:calc(var(--gramlot-touch-target, 0px) / 2);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
@@ -47,3 +47,9 @@ Color mode is independent: `data-theme="light"` or `data-theme="dark"` on the
|
|
|
47
47
|
document root selects it, otherwise Base follows the system preference. Application
|
|
48
48
|
CSS outside the Gramlot cascade layers can override both themes. Browser zoom remains
|
|
49
49
|
available; multiline controls keep their native behavior.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
For additional compact palettes, load `mimi/theme.css` or
|
|
53
|
+
`joanna/theme.css` after Base and Compact. Both inherit the same semantic
|
|
54
|
+
variables and style input components as well as ordinary HTML. See
|
|
55
|
+
[theme profiles](../../docs/public/096-themes-and-css.md#gc-096-017).
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/* Gramlot Compact: load after gramlot-base/theme.css. Colors and behavior stay in Base. */
|
|
2
2
|
@layer gramlot.tokens {
|
|
3
3
|
:root {
|
|
4
|
+
--gramlot-field-height: 28px;
|
|
5
|
+
--gramlot-field-line-height: 1.35;
|
|
6
|
+
--gramlot-field-padding: .25rem .5rem;
|
|
7
|
+
--gramlot-field-font-size: 1rem;
|
|
4
8
|
--gramlot-space-1: .2rem;
|
|
5
9
|
--gramlot-space-2: .4rem;
|
|
6
10
|
--gramlot-space-3: .5rem;
|
|
@@ -35,10 +39,10 @@
|
|
|
35
39
|
}
|
|
36
40
|
:where(label) { font-size: .95rem; }
|
|
37
41
|
:where(input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]), select, textarea) {
|
|
38
|
-
min-block-size:
|
|
39
|
-
padding:
|
|
40
|
-
font-size:
|
|
41
|
-
line-height:
|
|
42
|
+
min-block-size: var(--gramlot-field-height);
|
|
43
|
+
padding: var(--gramlot-field-padding);
|
|
44
|
+
font-size: var(--gramlot-field-font-size);
|
|
45
|
+
line-height: var(--gramlot-field-line-height);
|
|
42
46
|
}
|
|
43
47
|
:where(textarea) { min-block-size: 5rem; }
|
|
44
48
|
:where(input[type="color"]) { min-block-size: 28px; }
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# joanna
|
|
2
|
+
|
|
3
|
+
A Gramlot interpretation of GenroPy's `joanna` theme. The light palette
|
|
4
|
+
comes from `resources/common/themes/joanna.css` in GenroPy; styles are
|
|
5
|
+
implemented for current HTML and Gramlot components, without Dojo dependencies.
|
|
6
|
+
Dark mode is a new coordinated adaptation. It is not a pixel-identical port of
|
|
7
|
+
legacy layout widgets. Legacy user color variants are outside this increment.
|
|
8
|
+
|
|
9
|
+
Load Base, Compact and this profile in order:
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
class Page(BasePage):
|
|
13
|
+
css = ("/themes/gramlot-base/theme.css",
|
|
14
|
+
"/themes/gramlot-compact/theme.css",
|
|
15
|
+
"/themes/joanna/theme.css")
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The index/gallery Theme selector applies this same CSS to the shell and frames.
|
|
19
|
+
Color mode is independent. CSS variables inherit into input shadow roots, including
|
|
20
|
+
labels, choices, calendar and validation messages. Application CSS can override the
|
|
21
|
+
semantic variables; component-specific Source attributes keep normal precedence.
|
|
22
|
+
|
|
23
|
+
Density refinement: live Mimi invoice fields measured 17.5px / 12px text / 10.8px labels. Gramlot Mimi uses 18px fields, joanna 20px; both use 1px × 3px padding, 2px label gap and 6px stack spacing. joanna retains its own 13px typography and Joanna .8em label ratio; only Mimi was measured in the live invoice. Override field-line-height and label-gap using the shared --gramlot-* tokens.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/* Gramlot adaptation of legacy joanna; load after Base and Compact. */
|
|
2
|
+
@layer gramlot.tokens {
|
|
3
|
+
:root {
|
|
4
|
+
--gramlot-background: #F2F2F7;
|
|
5
|
+
--gramlot-surface: #FFFFFF;
|
|
6
|
+
--gramlot-surface-subtle: #F2F2F7;
|
|
7
|
+
--gramlot-ink: #3A3A3C;
|
|
8
|
+
--gramlot-text-secondary: #636366;
|
|
9
|
+
--gramlot-border: #D1D1D6;
|
|
10
|
+
--gramlot-border-control: #AEAEB2;
|
|
11
|
+
--gramlot-navigation: #3A3A3C;
|
|
12
|
+
--gramlot-navigation-text: #FFFFFF;
|
|
13
|
+
--gramlot-action: #007AFF;
|
|
14
|
+
--gramlot-action-hover: #0061CC;
|
|
15
|
+
--gramlot-brand-blue: #007AFF;
|
|
16
|
+
--gramlot-brand-yellow: #AEAEB2;
|
|
17
|
+
--gramlot-selected: #E0EFFF;
|
|
18
|
+
--gramlot-focus-ring: #007AFF;
|
|
19
|
+
--gramlot-field-background: #FFFFFF;
|
|
20
|
+
--gramlot-field-readonly-background: #F2F2F7;
|
|
21
|
+
--gramlot-error: #B3261E;
|
|
22
|
+
--gramlot-error-background: #FFF1F0;
|
|
23
|
+
--gramlot-shadow: 0 1px 4px rgb(0 0 0 / 6%);
|
|
24
|
+
--gramlot-radius-sm: 6px;
|
|
25
|
+
--gramlot-radius: 6px;
|
|
26
|
+
--gramlot-radius-lg: 6px;
|
|
27
|
+
--gramlot-field-height: 20px;
|
|
28
|
+
--gramlot-field-padding: 1px 3px;
|
|
29
|
+
--gramlot-field-line-height: 1.15;
|
|
30
|
+
--gramlot-field-font-size: 1rem;
|
|
31
|
+
--gramlot-label-size: .8em;
|
|
32
|
+
--gramlot-label-gap: 2px;
|
|
33
|
+
--gramlot-label-color: var(--gramlot-text-secondary);
|
|
34
|
+
--gramlot-space-4: 6px;
|
|
35
|
+
--gramlot-font-ui: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
|
|
36
|
+
}
|
|
37
|
+
@media (prefers-color-scheme: dark) {
|
|
38
|
+
:root:not([data-theme="light"]) {
|
|
39
|
+
--gramlot-background: #1C1C1E;
|
|
40
|
+
--gramlot-surface: #2C2C2E;
|
|
41
|
+
--gramlot-surface-subtle: #3A3A3C;
|
|
42
|
+
--gramlot-ink: #F2F2F7;
|
|
43
|
+
--gramlot-text-secondary: #C7C7CC;
|
|
44
|
+
--gramlot-border: #636366;
|
|
45
|
+
--gramlot-border-control: #8E8E93;
|
|
46
|
+
--gramlot-navigation: #1C1C1E;
|
|
47
|
+
--gramlot-action: #78B7FF;
|
|
48
|
+
--gramlot-action-hover: #A6CFFF;
|
|
49
|
+
--gramlot-brand-blue: #3478CA;
|
|
50
|
+
--gramlot-selected: #254163;
|
|
51
|
+
--gramlot-focus-ring: #78B7FF;
|
|
52
|
+
--gramlot-field-background: #202124;
|
|
53
|
+
--gramlot-field-readonly-background: #3A3A3C;
|
|
54
|
+
--gramlot-error: #FFB4AB;
|
|
55
|
+
--gramlot-error-background: #482524;
|
|
56
|
+
--gramlot-shadow: 0 1px 4px rgb(0 0 0 / 20%);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
:root[data-theme="dark"] {
|
|
60
|
+
--gramlot-background: #1C1C1E;
|
|
61
|
+
--gramlot-surface: #2C2C2E;
|
|
62
|
+
--gramlot-surface-subtle: #3A3A3C;
|
|
63
|
+
--gramlot-ink: #F2F2F7;
|
|
64
|
+
--gramlot-text-secondary: #C7C7CC;
|
|
65
|
+
--gramlot-border: #636366;
|
|
66
|
+
--gramlot-border-control: #8E8E93;
|
|
67
|
+
--gramlot-navigation: #1C1C1E;
|
|
68
|
+
--gramlot-action: #78B7FF;
|
|
69
|
+
--gramlot-action-hover: #A6CFFF;
|
|
70
|
+
--gramlot-brand-blue: #3478CA;
|
|
71
|
+
--gramlot-selected: #254163;
|
|
72
|
+
--gramlot-focus-ring: #78B7FF;
|
|
73
|
+
--gramlot-field-background: #202124;
|
|
74
|
+
--gramlot-field-readonly-background: #3A3A3C;
|
|
75
|
+
--gramlot-error: #FFB4AB;
|
|
76
|
+
--gramlot-error-background: #482524;
|
|
77
|
+
--gramlot-shadow: 0 1px 4px rgb(0 0 0 / 20%);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
@layer gramlot.base {
|
|
81
|
+
html { font-size: 13px; }
|
|
82
|
+
}
|
|
83
|
+
@layer gramlot.components {
|
|
84
|
+
:where(label) { font-size: var(--gramlot-label-size); font-weight: normal; color: var(--gramlot-label-color); margin-block-end: var(--gramlot-label-gap); }
|
|
85
|
+
:where(button, input[type="button"], input[type="submit"], input[type="reset"], .button) { min-block-size: 26px; padding: 2px 8px; font-weight: 500; }
|
|
86
|
+
}
|
|
87
|
+
@layer gramlot.utilities {
|
|
88
|
+
.card { box-shadow: var(--gramlot-shadow); }
|
|
89
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# mimi
|
|
2
|
+
|
|
3
|
+
A Gramlot interpretation of GenroPy's `mimi` theme. The light palette
|
|
4
|
+
comes from `resources/common/themes/mimi.css` in GenroPy; styles are
|
|
5
|
+
implemented for current HTML and Gramlot components, without Dojo dependencies.
|
|
6
|
+
Dark mode is a new coordinated adaptation. It is not a pixel-identical port of
|
|
7
|
+
legacy layout widgets. Legacy user color variants are outside this increment.
|
|
8
|
+
|
|
9
|
+
Load Base, Compact and this profile in order:
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
class Page(BasePage):
|
|
13
|
+
css = ("/themes/gramlot-base/theme.css",
|
|
14
|
+
"/themes/gramlot-compact/theme.css",
|
|
15
|
+
"/themes/mimi/theme.css")
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The index/gallery Theme selector applies this same CSS to the shell and frames.
|
|
19
|
+
Color mode is independent. CSS variables inherit into input shadow roots, including
|
|
20
|
+
labels, choices, calendar and validation messages. Application CSS can override the
|
|
21
|
+
semantic variables; component-specific Source attributes keep normal precedence.
|
|
22
|
+
|
|
23
|
+
Density refinement: live Mimi invoice fields measured 17.5px / 12px text / 10.8px labels. Gramlot Mimi uses 18px fields, joanna 20px; both use 1px × 3px padding, 2px label gap and 6px stack spacing. joanna retains its own 13px typography and Joanna .8em label ratio; only Mimi was measured in the live invoice. Override field-line-height and label-gap using the shared --gramlot-* tokens.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/* Gramlot adaptation of legacy mimi; load after Base and Compact. */
|
|
2
|
+
@layer gramlot.tokens {
|
|
3
|
+
:root {
|
|
4
|
+
--gramlot-background: #EDEEF0;
|
|
5
|
+
--gramlot-surface: #F5F5F6;
|
|
6
|
+
--gramlot-surface-subtle: #E0E1E3;
|
|
7
|
+
--gramlot-ink: #3C3D40;
|
|
8
|
+
--gramlot-text-secondary: #6B6E72;
|
|
9
|
+
--gramlot-border: #BDBFC2;
|
|
10
|
+
--gramlot-border-control: #9EA0A3;
|
|
11
|
+
--gramlot-navigation: #48494C;
|
|
12
|
+
--gramlot-navigation-text: #FFFFFF;
|
|
13
|
+
--gramlot-action: #0071E3;
|
|
14
|
+
--gramlot-action-hover: #005BBB;
|
|
15
|
+
--gramlot-brand-blue: #0071E3;
|
|
16
|
+
--gramlot-brand-yellow: #9EA0A3;
|
|
17
|
+
--gramlot-selected: #E8F1FC;
|
|
18
|
+
--gramlot-focus-ring: #0071E3;
|
|
19
|
+
--gramlot-field-background: #FFFFFF;
|
|
20
|
+
--gramlot-field-readonly-background: #E0E1E3;
|
|
21
|
+
--gramlot-error: #B3261E;
|
|
22
|
+
--gramlot-error-background: #FFF1F0;
|
|
23
|
+
--gramlot-shadow: 0 1px 4px rgb(0 0 0 / 6%);
|
|
24
|
+
--gramlot-radius-sm: 4px;
|
|
25
|
+
--gramlot-radius: 3px;
|
|
26
|
+
--gramlot-radius-lg: 3px;
|
|
27
|
+
--gramlot-field-height: 18px;
|
|
28
|
+
--gramlot-field-padding: 1px 3px;
|
|
29
|
+
--gramlot-field-line-height: 1.15;
|
|
30
|
+
--gramlot-field-font-size: 1rem;
|
|
31
|
+
--gramlot-label-size: .9em;
|
|
32
|
+
--gramlot-label-gap: 2px;
|
|
33
|
+
--gramlot-label-color: var(--gramlot-text-secondary);
|
|
34
|
+
--gramlot-space-4: 6px;
|
|
35
|
+
--gramlot-font-ui: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
|
|
36
|
+
}
|
|
37
|
+
@media (prefers-color-scheme: dark) {
|
|
38
|
+
:root:not([data-theme="light"]) {
|
|
39
|
+
--gramlot-background: #242527;
|
|
40
|
+
--gramlot-surface: #303134;
|
|
41
|
+
--gramlot-surface-subtle: #3C3D40;
|
|
42
|
+
--gramlot-ink: #F2F2F7;
|
|
43
|
+
--gramlot-text-secondary: #C7C7CC;
|
|
44
|
+
--gramlot-border: #6B6E72;
|
|
45
|
+
--gramlot-border-control: #8E8E93;
|
|
46
|
+
--gramlot-navigation: #1C1C1E;
|
|
47
|
+
--gramlot-action: #78B7FF;
|
|
48
|
+
--gramlot-action-hover: #A6CFFF;
|
|
49
|
+
--gramlot-brand-blue: #3478CA;
|
|
50
|
+
--gramlot-selected: #254163;
|
|
51
|
+
--gramlot-focus-ring: #78B7FF;
|
|
52
|
+
--gramlot-field-background: #202124;
|
|
53
|
+
--gramlot-field-readonly-background: #3C3D40;
|
|
54
|
+
--gramlot-error: #FFB4AB;
|
|
55
|
+
--gramlot-error-background: #482524;
|
|
56
|
+
--gramlot-shadow: 0 1px 4px rgb(0 0 0 / 20%);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
:root[data-theme="dark"] {
|
|
60
|
+
--gramlot-background: #242527;
|
|
61
|
+
--gramlot-surface: #303134;
|
|
62
|
+
--gramlot-surface-subtle: #3C3D40;
|
|
63
|
+
--gramlot-ink: #F2F2F7;
|
|
64
|
+
--gramlot-text-secondary: #C7C7CC;
|
|
65
|
+
--gramlot-border: #6B6E72;
|
|
66
|
+
--gramlot-border-control: #8E8E93;
|
|
67
|
+
--gramlot-navigation: #1C1C1E;
|
|
68
|
+
--gramlot-action: #78B7FF;
|
|
69
|
+
--gramlot-action-hover: #A6CFFF;
|
|
70
|
+
--gramlot-brand-blue: #3478CA;
|
|
71
|
+
--gramlot-selected: #254163;
|
|
72
|
+
--gramlot-focus-ring: #78B7FF;
|
|
73
|
+
--gramlot-field-background: #202124;
|
|
74
|
+
--gramlot-field-readonly-background: #3C3D40;
|
|
75
|
+
--gramlot-error: #FFB4AB;
|
|
76
|
+
--gramlot-error-background: #482524;
|
|
77
|
+
--gramlot-shadow: 0 1px 4px rgb(0 0 0 / 20%);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
@layer gramlot.base {
|
|
81
|
+
html { font-size: 12px; }
|
|
82
|
+
}
|
|
83
|
+
@layer gramlot.components {
|
|
84
|
+
:where(label) { font-size: var(--gramlot-label-size); font-weight: normal; color: var(--gramlot-label-color); margin-block-end: var(--gramlot-label-gap); }
|
|
85
|
+
:where(button, input[type="button"], input[type="submit"], input[type="reset"], .button) { min-block-size: 24px; padding: 2px 8px; font-weight: 500; }
|
|
86
|
+
}
|
|
87
|
+
@layer gramlot.utilities {
|
|
88
|
+
.card { box-shadow: var(--gramlot-shadow); }
|
|
89
|
+
}
|