@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/format.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import {isDecimal} from '@genrojs/tytx';
|
|
2
|
+
/** Bounded numeric patterns and temporal styles for Gramlot's formatting contract. */
|
|
3
|
+
|
|
4
|
+
export function validateMask(mask) {
|
|
5
|
+
if (mask != null && (typeof mask !== 'string' || /[{}]/.test(mask.replaceAll('{}', '')))) {
|
|
6
|
+
throw new RangeError('This formatter mask supports only {} placeholders');
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Shared composition for formatted values and plain display text. */
|
|
11
|
+
export function applyMask(text, mask) {
|
|
12
|
+
validateMask(mask);
|
|
13
|
+
return mask == null ? text : mask.replaceAll('{}', () => text);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function inferredType(value) {
|
|
17
|
+
if (value instanceof Date) {
|
|
18
|
+
// Match TYTX's documented inference; dtype can override this ambiguity.
|
|
19
|
+
const epochDay = value.getUTCFullYear() === 1970 && value.getUTCMonth() === 0 && value.getUTCDate() === 1;
|
|
20
|
+
const midnight = value.getUTCHours() === 0 && value.getUTCMinutes() === 0 &&
|
|
21
|
+
value.getUTCSeconds() === 0 && value.getUTCMilliseconds() === 0;
|
|
22
|
+
if (epochDay && !midnight) return 'H';
|
|
23
|
+
if (midnight && !epochDay) return 'D';
|
|
24
|
+
return 'DHZ';
|
|
25
|
+
}
|
|
26
|
+
if (isDecimal(value)) return 'N';
|
|
27
|
+
if (typeof value === 'number') return Number.isInteger(value) ? 'L' : 'R';
|
|
28
|
+
throw new TypeError('Formatting requires finite JavaScript numbers, TYTX Decimal values or valid Date objects');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function temporalText(value, dtype, {pattern = 'short', locale, timeZone}) {
|
|
32
|
+
if (!['short', 'medium', 'long', 'full'].includes(pattern)) {
|
|
33
|
+
throw new RangeError('Temporal formatting currently supports short, medium, long and full only');
|
|
34
|
+
}
|
|
35
|
+
if (dtype === 'DHZ' && (typeof timeZone !== 'string' || !timeZone)) {
|
|
36
|
+
throw new TypeError('DHZ formatting currently requires an explicit timeZone');
|
|
37
|
+
}
|
|
38
|
+
// Civil fields are stored in UTC by TYTX; they must not shift with display timezone.
|
|
39
|
+
const options = {timeZone: dtype === 'DHZ' ? timeZone : 'UTC'};
|
|
40
|
+
if (dtype !== 'H') options.dateStyle = pattern;
|
|
41
|
+
if (dtype !== 'D') options.timeStyle = pattern;
|
|
42
|
+
return new Intl.DateTimeFormat(locale, options).format(value);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function numericSection(section) {
|
|
46
|
+
// Only decimal skeletons and sign/parenthesis affixes are implemented here.
|
|
47
|
+
const match = /^(-|\()?(#,##0|0+)(?:\.(0*#*))?(\))?$/.exec(section);
|
|
48
|
+
if (!match || (match[1] === '(') !== (match[4] === ')') || section.endsWith('.')) {
|
|
49
|
+
throw new RangeError(`Unsupported numeric pattern section: ${section}`);
|
|
50
|
+
}
|
|
51
|
+
const fraction = match[3] ?? '';
|
|
52
|
+
return {
|
|
53
|
+
prefix: match[1] ?? '', suffix: match[4] ?? '',
|
|
54
|
+
intl: {
|
|
55
|
+
useGrouping: match[2].startsWith('#,##') ? 'always' : false,
|
|
56
|
+
minimumIntegerDigits: match[2].replace('#,##', '').length,
|
|
57
|
+
minimumFractionDigits: fraction.replaceAll('#', '').length,
|
|
58
|
+
maximumFractionDigits: fraction.length,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function numericPattern(pattern) {
|
|
64
|
+
const sections = pattern.split(';');
|
|
65
|
+
if (sections.length > 3) throw new RangeError('Numeric patterns support at most three sections');
|
|
66
|
+
const positive = numericSection(sections[0]);
|
|
67
|
+
if (positive.prefix || positive.suffix) throw new RangeError('Positive-section affixes are not implemented');
|
|
68
|
+
const zero = sections.length === 3 ? sections[1] : null;
|
|
69
|
+
// The first slice supports the already agreed literal '-' and empty zero branch.
|
|
70
|
+
if (zero !== null && zero !== '' && zero !== '-') numericSection(zero);
|
|
71
|
+
const negative = sections.length > 1 ? numericSection(sections.at(-1)) : null;
|
|
72
|
+
// Unicode negative sections supply affixes; digit settings come from the positive section.
|
|
73
|
+
return {positive, zero, negative};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Internal implementation; the only public entry point is Gramlot.format. */
|
|
77
|
+
export function formatValue(value, options = {}, context = {}) {
|
|
78
|
+
// A null value bypasses both the pattern and the mask, by contract.
|
|
79
|
+
if (value === null) return '';
|
|
80
|
+
if (typeof options === 'string') options = {pattern: options};
|
|
81
|
+
if (!options || typeof options !== 'object' || Array.isArray(options)) {
|
|
82
|
+
throw new TypeError('Format options must be a pattern string or an options object');
|
|
83
|
+
}
|
|
84
|
+
for (const key of Object.keys(options)) {
|
|
85
|
+
if (!['pattern', 'locale', 'mask', 'dtype', 'timeZone'].includes(key)) throw new RangeError(`Unsupported format option: ${key}`);
|
|
86
|
+
}
|
|
87
|
+
options = {...options, locale: options.locale ?? context.locale, timeZone: options.timeZone ?? context.timeZone};
|
|
88
|
+
const dtype = options.dtype === undefined ? inferredType(value) : options.dtype;
|
|
89
|
+
const temporal = ['D', 'H', 'DHZ'].includes(dtype);
|
|
90
|
+
if (!temporal && !['L', 'R', 'N'].includes(dtype)) throw new RangeError(`Unsupported format dtype: ${dtype}`);
|
|
91
|
+
if (temporal) {
|
|
92
|
+
if (!(value instanceof Date) || !Number.isFinite(value.getTime())) throw new TypeError(`${dtype} requires a valid Date object`);
|
|
93
|
+
} else if (!(typeof value === 'number' && Number.isFinite(value)) && !(isDecimal(value) && !['NaN', 'Infinity', '-Infinity'].includes(value.toString()))) {
|
|
94
|
+
throw new TypeError(`${dtype} formatting requires finite JavaScript numbers or TYTX Decimal values`);
|
|
95
|
+
}
|
|
96
|
+
if (dtype === 'L' && !Number.isInteger(value)) throw new TypeError('L formatting requires an integer');
|
|
97
|
+
const {pattern, locale, mask} = options;
|
|
98
|
+
if (!temporal && typeof pattern !== 'string') throw new TypeError('Numeric formatting currently requires an explicit pattern');
|
|
99
|
+
if (typeof locale !== 'string' || !locale) throw new TypeError('Formatting currently requires an explicit locale');
|
|
100
|
+
// Do not silently select the browser locale when the requested locale is unavailable.
|
|
101
|
+
const intl = temporal ? Intl.DateTimeFormat : Intl.NumberFormat;
|
|
102
|
+
if (!intl.supportedLocalesOf([locale]).length) throw new RangeError(`Unsupported format locale: ${locale}`);
|
|
103
|
+
validateMask(mask);
|
|
104
|
+
if (temporal) {
|
|
105
|
+
const text = temporalText(value, dtype, options);
|
|
106
|
+
return applyMask(text, mask);
|
|
107
|
+
}
|
|
108
|
+
const {positive, zero, negative} = numericPattern(pattern);
|
|
109
|
+
const decimal = isDecimal(value);
|
|
110
|
+
const zeroValue = decimal ? value.eq(0) : value === 0;
|
|
111
|
+
const negativeValue = decimal ? value.lt(0) : value < 0;
|
|
112
|
+
if (decimal && new Intl.NumberFormat('en', {useGrouping: false}).format('9007199254740993') !== '9007199254740993') throw new Error('This browser cannot format Decimal without precision loss');
|
|
113
|
+
let text;
|
|
114
|
+
if (zeroValue && zero !== null) {
|
|
115
|
+
if (zero === '') return '';
|
|
116
|
+
if (zero === '-') text = '-';
|
|
117
|
+
else {
|
|
118
|
+
const section = numericSection(zero);
|
|
119
|
+
text = section.prefix + new Intl.NumberFormat(locale, section.intl).format(0) + section.suffix;
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
const affix = negativeValue && negative ? negative : positive;
|
|
123
|
+
const number = decimal ? (negativeValue && negative ? value.abs() : value).toString()
|
|
124
|
+
: negativeValue && negative ? -value : (value === 0 ? 0 : value);
|
|
125
|
+
text = affix.prefix + new Intl.NumberFormat(locale, positive.intl).format(number) + affix.suffix;
|
|
126
|
+
}
|
|
127
|
+
return applyMask(text, mask);
|
|
128
|
+
}
|
package/src/gramlot.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type {DomElement, DomDocument, DomEvent, DomWindow} from './dom.d.ts';
|
|
7
7
|
import type {Bag} from '@genrojs/bag';
|
|
8
|
+
import type {createDecimal} from '@genrojs/tytx';
|
|
8
9
|
import type {SourceBagNode} from '@genrojs/builders';
|
|
9
10
|
import type {RpcTransport} from './handlers/rpc-handler.js';
|
|
10
11
|
import type {SourceHandler} from './handlers/source-handler.js';
|
|
@@ -14,6 +15,12 @@ import type {UtilitiesHandler} from './handlers/utilities-handler.js';
|
|
|
14
15
|
|
|
15
16
|
/** The options of a `Gramlot` instance. */
|
|
16
17
|
export interface GramlotOptions {
|
|
18
|
+
/** Formatting locale of this page; null/omitted uses the browser locale. */
|
|
19
|
+
locale?: string | null;
|
|
20
|
+
/** Declared device suitability; empty means unspecified. */
|
|
21
|
+
devices?: Array<'desktop' | 'tablet' | 'phone'>;
|
|
22
|
+
/** Timezone for instants; null/omitted uses the browser timezone. */
|
|
23
|
+
timeZone?: string | null;
|
|
17
24
|
/** The id of the server page, as registered by the server. */
|
|
18
25
|
pageId?: string;
|
|
19
26
|
/** The URL of the rpc endpoint that receives the envelopes. */
|
|
@@ -40,12 +47,28 @@ export type GramlotState = 'ready' | 'loading' | 'started' | 'failed' | 'dispose
|
|
|
40
47
|
/** Opaque registration returned by subscribe; meaningful only to its owning page. */
|
|
41
48
|
export interface SubscriptionHandle { readonly __subscriptionHandle: unique symbol; }
|
|
42
49
|
|
|
50
|
+
/** Bounded formatting subset. Call options override the page context. */
|
|
51
|
+
export interface FormatOptions {
|
|
52
|
+
/** Numeric pattern or temporal short (default), medium, long, full. */
|
|
53
|
+
pattern?: string;
|
|
54
|
+
locale?: string;
|
|
55
|
+
/** Overrides value inference; does not coerce strings or other incompatible values. */
|
|
56
|
+
dtype?: 'L' | 'R' | 'N' | 'D' | 'H' | 'DHZ';
|
|
57
|
+
/** Overrides the page timezone for DHZ; D/H do not shift. */
|
|
58
|
+
timeZone?: string;
|
|
59
|
+
/** Wrap formatted text using {}. Null and an empty zero section bypass the mask. */
|
|
60
|
+
mask?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
43
63
|
/** Legacy-shaped publication. Frame forwarding follows synchronous local delivery. */
|
|
44
64
|
export type Publication = string | {topic: string; nodeId: string} |
|
|
45
65
|
{topic: string; parent?: boolean; iframe?: string | SourceBagNode};
|
|
46
66
|
|
|
47
67
|
/** One Gramlot page: lifecycle, Data and the four proxies `src`, `rpc`, `dom`, `utl`. */
|
|
48
68
|
export class Gramlot {
|
|
69
|
+
readonly devices: readonly ('desktop' | 'tablet' | 'phone')[];
|
|
70
|
+
locale: string;
|
|
71
|
+
timeZone: string;
|
|
49
72
|
/** The id of the server page. */
|
|
50
73
|
pageId: string | undefined;
|
|
51
74
|
/** The capabilities announced by the server in the bootstrap, frozen. */
|
|
@@ -80,6 +103,8 @@ export class Gramlot {
|
|
|
80
103
|
subscribe(topic: string, callback: (payload: Record<string, unknown>) => unknown): SubscriptionHandle;
|
|
81
104
|
/** Remove a registration; repeating removal of an owned handle is harmless. */
|
|
82
105
|
unsubscribe(registration: SubscriptionHandle): void;
|
|
106
|
+
/** Format a number, Date or null. Explicit dtype overrides TYTX-style Date inference. */
|
|
107
|
+
format(value: number | Date | ReturnType<typeof createDecimal> | null, options?: string | FormatOptions): string;
|
|
83
108
|
/** Load `main` from the server and mount it; resolves with the instance. */
|
|
84
109
|
start(): Promise<Gramlot>;
|
|
85
110
|
/** Request `main` from the transport and mount it. */
|
package/src/gramlot.js
CHANGED
|
@@ -10,6 +10,9 @@ import {RpcHandler} from './handlers/rpc-handler.js';
|
|
|
10
10
|
import {DomHandler} from './handlers/dom-handler.js';
|
|
11
11
|
import {SubscriptionsHandler} from './handlers/subscriptions-handler.js';
|
|
12
12
|
import {UtilitiesHandler} from './handlers/utilities-handler.js';
|
|
13
|
+
import buttons from './components/buttons.js';
|
|
14
|
+
import {ComponentCollection} from './components/registry.js';
|
|
15
|
+
import {formatValue} from './format.js';
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
* One Gramlot page: lifecycle, Data and the four proxies `src`, `rpc`, `dom`, `utl`.
|
|
@@ -17,8 +20,18 @@ import {UtilitiesHandler} from './handlers/utilities-handler.js';
|
|
|
17
20
|
*/
|
|
18
21
|
export class Gramlot {
|
|
19
22
|
constructor({pageId, rpcUrl = '/gramlot/rpc', closeUrl = '/gramlot/close', rootId = 'gramlot-root', capabilities = [],
|
|
20
|
-
element = null, document = element?.ownerDocument ?? globalThis.document, transport = null, collections = []
|
|
23
|
+
element = null, document = element?.ownerDocument ?? globalThis.document, transport = null, collections = [],
|
|
24
|
+
locale = null, timeZone = null, devices = []} = {}) {
|
|
25
|
+
buttons.register(document.defaultView);
|
|
26
|
+
for (const collection of collections) {
|
|
27
|
+
if (collection instanceof ComponentCollection) collection.register(document.defaultView);
|
|
28
|
+
}
|
|
21
29
|
this.pageId = pageId;
|
|
30
|
+
const browserContext = locale == null || timeZone == null
|
|
31
|
+
? document.defaultView.Intl.DateTimeFormat().resolvedOptions() : null;
|
|
32
|
+
this.devices = Object.freeze([...devices]);
|
|
33
|
+
this.locale = locale ?? browserContext.locale;
|
|
34
|
+
this.timeZone = timeZone ?? browserContext.timeZone;
|
|
22
35
|
Object.defineProperty(this, '_subscriptions', {value: new SubscriptionsHandler(this)});
|
|
23
36
|
this.capabilities = Object.freeze([...capabilities]);
|
|
24
37
|
this.src = new SourceHandler(this, {collections, destination: element ?? document.getElementById(rootId)});
|
|
@@ -38,6 +51,7 @@ export class Gramlot {
|
|
|
38
51
|
publish(topic, payload = {}) { return this._subscriptions.publish(topic, payload); }
|
|
39
52
|
subscribe(topic, callback) { return this._subscriptions.subscribe(topic, callback); }
|
|
40
53
|
unsubscribe(registration) { this._subscriptions.unsubscribe(registration); }
|
|
54
|
+
format(value, options) { return formatValue(value, options, {locale: this.locale, timeZone: this.timeZone}); }
|
|
41
55
|
|
|
42
56
|
start() {
|
|
43
57
|
if (this.state === 'disposed') return Promise.reject(new Error('Gramlot is disposed'));
|
|
@@ -10,6 +10,7 @@ import {Handler} from './handler.js';
|
|
|
10
10
|
|
|
11
11
|
/** The DOM and its correspondence with the Source. */
|
|
12
12
|
export class DomHandler extends Handler {
|
|
13
|
+
setTouchMode(mode?: 'auto' | 'on' | 'off'): void;
|
|
13
14
|
/** Resolve a node or DOM reference descriptor. */
|
|
14
15
|
reference(descriptor: SourceReference): SourceBagNode | DomElement;
|
|
15
16
|
/** The Source node of the nearest element generated by the renderer. */
|
|
@@ -8,6 +8,13 @@ import {Handler} from './handler.js';
|
|
|
8
8
|
|
|
9
9
|
/** The DOM and its correspondence with the Source. */
|
|
10
10
|
export class DomHandler extends Handler {
|
|
11
|
+
/** Size controls for the input device without rebuilding the page. */
|
|
12
|
+
setTouchMode(mode = 'auto') {
|
|
13
|
+
if (!['auto', 'on', 'off'].includes(mode)) throw new TypeError(`Invalid touch mode: ${mode}`);
|
|
14
|
+
const root = this.gramlot.src.renderer.destination.ownerDocument.documentElement;
|
|
15
|
+
if (mode === 'auto') root.removeAttribute('data-gramlot-touch');
|
|
16
|
+
else root.setAttribute('data-gramlot-touch', mode);
|
|
17
|
+
}
|
|
11
18
|
reference(descriptor) { return this.gramlot.src.renderer.references.resolve(descriptor); }
|
|
12
19
|
/** The Source node of the nearest element generated by the renderer (§4.11bis). */
|
|
13
20
|
getBaseSourceNode(domNode) { return this.gramlot.src.renderer.getBaseSourceNode(domNode); }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* @ts-self-types="./index-page-runtime.d.ts" */
|
|
2
|
-
import {
|
|
2
|
+
import {appearanceStyles} from './index-page-styles.js';
|
|
3
3
|
import {THEME_READY, THEME_SET, THEMES, APPEARANCES} from './index-theme.js';
|
|
4
4
|
|
|
5
5
|
/** Index-page behavior; writes UI state through the existing Source records. */
|
|
@@ -15,6 +15,10 @@ export function mountIndexPage(renderer, root, onSelection = () => {}, prepareEn
|
|
|
15
15
|
const appearance = byId('index-appearance');
|
|
16
16
|
const sidebar = byId('index-sidebar');
|
|
17
17
|
const sidebarHandle = byId('index-sidebar-divider');
|
|
18
|
+
const navigationToggle = byId('index-navigation-toggle');
|
|
19
|
+
const codeToggle = byId('index-code-toggle');
|
|
20
|
+
const codeSidebar = byId('index-code');
|
|
21
|
+
const codeHandle = byId('index-code-divider');
|
|
18
22
|
// localStorage is scoped to this origin; the path separates mounted galleries.
|
|
19
23
|
const preferencesKey = `gramlot.${shell.id}.preferences:${window.location.pathname}`;
|
|
20
24
|
let preferences = {};
|
|
@@ -39,11 +43,16 @@ export function mountIndexPage(renderer, root, onSelection = () => {}, prepareEn
|
|
|
39
43
|
state.setItem('keyboard', (keyboard?.checked ?? false));
|
|
40
44
|
state.setItem('theme', (theme?.value ?? 'light'));
|
|
41
45
|
state.setItem('appearance', (appearance?.value ?? 'compact'));
|
|
46
|
+
state.setItem('navigationVisible', preferences.navigationVisible !== false);
|
|
47
|
+
state.setItem('codeVisible', preferences.codeVisible !== false);
|
|
42
48
|
const savePreferences = () => {
|
|
43
49
|
try {
|
|
44
50
|
window.localStorage.setItem(preferencesKey, JSON.stringify({
|
|
45
51
|
theme: state.getItem('theme'), appearance: state.getItem('appearance'),
|
|
46
52
|
sidebarWidth: state.getItem('preferredSidebarWidth'),
|
|
53
|
+
codeWidth: state.getItem('preferredCodeWidth'),
|
|
54
|
+
navigationVisible: state.getItem('navigationVisible'),
|
|
55
|
+
codeVisible: state.getItem('codeVisible'),
|
|
47
56
|
}));
|
|
48
57
|
} catch (error) {
|
|
49
58
|
// A browser may deny storage (including opaque file origins) or exhaust its quota.
|
|
@@ -53,7 +62,7 @@ export function mountIndexPage(renderer, root, onSelection = () => {}, prepareEn
|
|
|
53
62
|
};
|
|
54
63
|
const entries = new Map();
|
|
55
64
|
const releases = [];
|
|
56
|
-
const style = root.builder.wrapSource(root.value).style(
|
|
65
|
+
const style = root.builder.wrapSource(root.value).style(appearanceStyles[appearance?.value ?? 'compact']);
|
|
57
66
|
let drag = null;
|
|
58
67
|
let disposed = false;
|
|
59
68
|
let installPrompt = null;
|
|
@@ -83,10 +92,27 @@ export function mountIndexPage(renderer, root, onSelection = () => {}, prepareEn
|
|
|
83
92
|
const send = frame => frame.contentWindow.postMessage({type: THEME_SET, theme: state.getItem('theme'), appearance: state.getItem('appearance')}, '*');
|
|
84
93
|
const applyTheme = () => {
|
|
85
94
|
document.documentElement.setAttribute('data-theme', state.getItem('theme'));
|
|
86
|
-
style.
|
|
95
|
+
style.setValue(appearanceStyles[state.getItem('appearance')]);
|
|
87
96
|
for (const {frame} of entries.values()) if (frame) send(frame);
|
|
88
97
|
};
|
|
89
98
|
const updateInspector = () => onSelection(entries, state.getItem('active'));
|
|
99
|
+
const updatePanels = () => {
|
|
100
|
+
if (navigationToggle) {
|
|
101
|
+
const visible = state.getItem('navigationVisible');
|
|
102
|
+
set(sidebar, {hidden: !visible});
|
|
103
|
+
set(sidebarHandle, {hidden: !visible});
|
|
104
|
+
set(navigationToggle, {aria_expanded: String(visible)});
|
|
105
|
+
set(shell, {data_navigation_hidden: String(!visible)});
|
|
106
|
+
}
|
|
107
|
+
if (codeSidebar) {
|
|
108
|
+
const available = Boolean(entries.get(state.getItem('active'))?.code);
|
|
109
|
+
const visible = available && state.getItem('codeVisible');
|
|
110
|
+
set(codeSidebar, {hidden: !visible});
|
|
111
|
+
set(codeHandle, {hidden: !visible});
|
|
112
|
+
set(codeToggle, {disabled: !available, aria_expanded: String(visible)});
|
|
113
|
+
set(shell, {data_code_visible: String(visible)});
|
|
114
|
+
}
|
|
115
|
+
};
|
|
90
116
|
function select(key) {
|
|
91
117
|
const entry = entries.get(key);
|
|
92
118
|
if (!opened.getItem(key)) {
|
|
@@ -99,29 +125,38 @@ export function mountIndexPage(renderer, root, onSelection = () => {}, prepareEn
|
|
|
99
125
|
const active = current === key;
|
|
100
126
|
set(item.tab, {aria_selected: String(active), tabindex: active && state.getItem('keyboard') ? 0 : -1});
|
|
101
127
|
set(item.panel, {hidden: !active});
|
|
128
|
+
if (item.code) set(item.code, {hidden: !active});
|
|
102
129
|
if (item.open) set(item.open, {aria_current: active ? 'page' : null});
|
|
103
130
|
}
|
|
104
131
|
state.setItem('active', key);
|
|
132
|
+
updatePanels();
|
|
105
133
|
updateInspector();
|
|
106
134
|
}
|
|
107
|
-
function setRatio(entry, value) {
|
|
108
|
-
const ratio = Math.max(20, Math.min(80, value));
|
|
109
|
-
state.setItem(`ratio.${entry.key}`, ratio);
|
|
110
|
-
set(entry.split, {style: `--split-position: ${ratio}%`});
|
|
111
|
-
set(entry.handle, {aria_valuenow: ratio});
|
|
112
|
-
}
|
|
113
135
|
const sidebarMaximum = () => Math.max(120, Math.min(460, Math.floor(window.innerWidth * .6)));
|
|
136
|
+
const applyWidths = () => set(shell, {style: `--sidebar-width: ${state.getItem('sidebarWidth')}px; --code-width: ${state.getItem('codeWidth') ?? 420}px`});
|
|
114
137
|
const setSidebarWidth = (value, remember = false) => {
|
|
115
138
|
const maximum = sidebarMaximum();
|
|
116
139
|
const width = Math.max(120, Math.min(maximum, value));
|
|
117
140
|
state.setItem('sidebarWidth', width);
|
|
118
|
-
|
|
141
|
+
applyWidths();
|
|
119
142
|
set(sidebarHandle, {aria_valuenow: width, aria_valuemax: maximum});
|
|
120
143
|
if (remember) {
|
|
121
144
|
state.setItem('preferredSidebarWidth', width);
|
|
122
145
|
savePreferences();
|
|
123
146
|
}
|
|
124
147
|
};
|
|
148
|
+
const codeMaximum = () => Math.max(200, Math.floor(window.innerWidth * .6));
|
|
149
|
+
const setCodeWidth = (value, remember = false) => {
|
|
150
|
+
const maximum = codeMaximum();
|
|
151
|
+
const width = Math.max(200, Math.min(maximum, value));
|
|
152
|
+
state.setItem('codeWidth', width);
|
|
153
|
+
applyWidths();
|
|
154
|
+
set(codeHandle, {aria_valuenow: width, aria_valuemax: maximum});
|
|
155
|
+
if (remember) {
|
|
156
|
+
state.setItem('preferredCodeWidth', width);
|
|
157
|
+
savePreferences();
|
|
158
|
+
}
|
|
159
|
+
};
|
|
125
160
|
const beginDrag = (handle, event, move) => {
|
|
126
161
|
if (event.button !== 0) return;
|
|
127
162
|
stopDrag();
|
|
@@ -167,6 +202,36 @@ export function mountIndexPage(renderer, root, onSelection = () => {}, prepareEn
|
|
|
167
202
|
? savedWidth : sidebar.getBoundingClientRect().width || Number(sidebarHandle.getAttribute('aria-valuenow'));
|
|
168
203
|
state.setItem('preferredSidebarWidth', width);
|
|
169
204
|
setSidebarWidth(width);
|
|
205
|
+
listen(navigationToggle, 'click', () => {
|
|
206
|
+
state.setItem('navigationVisible', !state.getItem('navigationVisible'));
|
|
207
|
+
updatePanels();
|
|
208
|
+
savePreferences();
|
|
209
|
+
});
|
|
210
|
+
listen(codeToggle, 'click', () => {
|
|
211
|
+
state.setItem('codeVisible', !state.getItem('codeVisible'));
|
|
212
|
+
updatePanels();
|
|
213
|
+
savePreferences();
|
|
214
|
+
});
|
|
215
|
+
if (codeHandle) {
|
|
216
|
+
const saved = preferences.codeWidth;
|
|
217
|
+
const width = typeof saved === 'number' && Number.isFinite(saved) && saved >= 200 ? saved : 420;
|
|
218
|
+
state.setItem('preferredCodeWidth', width);
|
|
219
|
+
setCodeWidth(width);
|
|
220
|
+
listen(codeHandle, 'keydown', event => {
|
|
221
|
+
const current = state.getItem('codeWidth');
|
|
222
|
+
const value = event.key === 'ArrowLeft' ? current + 10 : event.key === 'ArrowRight' ? current - 10
|
|
223
|
+
: event.key === 'Home' ? 200 : event.key === 'End' ? codeMaximum() : null;
|
|
224
|
+
if (value == null) return;
|
|
225
|
+
event.preventDefault();
|
|
226
|
+
setCodeWidth(value, true);
|
|
227
|
+
});
|
|
228
|
+
listen(codeHandle, 'pointerdown', event => beginDrag(codeHandle, event,
|
|
229
|
+
x => setCodeWidth(Math.round(shell.getBoundingClientRect().right - x), true)));
|
|
230
|
+
listen(codeHandle, 'lostpointercapture', () => {
|
|
231
|
+
if (drag?.handle === codeHandle) stopDrag();
|
|
232
|
+
});
|
|
233
|
+
listen(window, 'resize', () => setCodeWidth(state.getItem('preferredCodeWidth')));
|
|
234
|
+
}
|
|
170
235
|
listen(sidebarHandle, 'keydown', event => {
|
|
171
236
|
const current = state.getItem('sidebarWidth');
|
|
172
237
|
const value = event.key === 'ArrowLeft' ? current - 10 : event.key === 'ArrowRight' ? current + 10
|
|
@@ -184,6 +249,7 @@ export function mountIndexPage(renderer, root, onSelection = () => {}, prepareEn
|
|
|
184
249
|
for (const tab of shell.querySelectorAll('.index-tabs button')) {
|
|
185
250
|
const key = tab.id.slice('tab-'.length);
|
|
186
251
|
const entry = {key, tab, panel: byId(`panel-${key}`),
|
|
252
|
+
code: byId(`codepane-${key}`),
|
|
187
253
|
open: key === 'intro' ? null : byId(`open-${key}`)};
|
|
188
254
|
entries.set(key, entry);
|
|
189
255
|
if (!tab.hidden) opened.setItem(key, true);
|
|
@@ -205,26 +271,7 @@ export function mountIndexPage(renderer, root, onSelection = () => {}, prepareEn
|
|
|
205
271
|
prepareEntry(entry, {byId, node, set, listen});
|
|
206
272
|
if (entry.panel.classList.contains('index-category')) continue;
|
|
207
273
|
entry.frame = byId(`frame-${key}`);
|
|
208
|
-
entry.split = byId(`split-${key}`);
|
|
209
|
-
entry.handle = byId(`divider-${key}`);
|
|
210
|
-
if (entry.handle) state.setItem(`ratio.${key}`, Number(entry.handle.getAttribute('aria-valuenow')));
|
|
211
274
|
listen(entry.frame, 'load', () => send(entry.frame));
|
|
212
|
-
if (!entry.handle) continue;
|
|
213
|
-
listen(entry.handle, 'keydown', event => {
|
|
214
|
-
const current = state.getItem(`ratio.${key}`);
|
|
215
|
-
const value = event.key === 'ArrowLeft' ? current - 5 : event.key === 'ArrowRight' ? current + 5
|
|
216
|
-
: event.key === 'Home' ? 20 : event.key === 'End' ? 80 : null;
|
|
217
|
-
if (value == null) return;
|
|
218
|
-
event.preventDefault();
|
|
219
|
-
setRatio(entry, value);
|
|
220
|
-
});
|
|
221
|
-
listen(entry.handle, 'pointerdown', event => beginDrag(entry.handle, event, x => {
|
|
222
|
-
const bounds = entry.split.getBoundingClientRect();
|
|
223
|
-
if (bounds.width > 0) setRatio(entry, Math.round((x - bounds.left) * 100 / bounds.width));
|
|
224
|
-
}));
|
|
225
|
-
listen(entry.handle, 'lostpointercapture', () => {
|
|
226
|
-
if (drag?.handle === entry.handle) stopDrag();
|
|
227
|
-
});
|
|
228
275
|
}
|
|
229
276
|
listen(document, 'pointermove', event => {
|
|
230
277
|
if (!drag || event.pointerId !== drag.pointerId) return;
|
|
@@ -243,7 +290,7 @@ export function mountIndexPage(renderer, root, onSelection = () => {}, prepareEn
|
|
|
243
290
|
}
|
|
244
291
|
});
|
|
245
292
|
listen(appearance, 'change', () => {
|
|
246
|
-
if (!APPEARANCES.has((appearance?.value ?? 'compact'))) throw new Error('
|
|
293
|
+
if (!APPEARANCES.has((appearance?.value ?? 'compact'))) throw new Error('Unknown index appearance');
|
|
247
294
|
state.setItem('appearance', (appearance?.value ?? 'compact'));
|
|
248
295
|
set(appearance, {value: (appearance?.value ?? 'compact')});
|
|
249
296
|
for (const option of appearance.options) set(option, {selected: option.value === (appearance?.value ?? 'compact')});
|
|
@@ -265,6 +312,7 @@ export function mountIndexPage(renderer, root, onSelection = () => {}, prepareEn
|
|
|
265
312
|
}
|
|
266
313
|
});
|
|
267
314
|
applyTheme();
|
|
315
|
+
updatePanels();
|
|
268
316
|
updateInspector();
|
|
269
317
|
renderer.onDispose(root, dispose);
|
|
270
318
|
} catch (error) {
|
package/src/index-page-styles.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// Generated from themes
|
|
2
|
-
export const compactStyle = "/* Gramlot Compact: load after gramlot-base/theme.css. Colors and behavior stay in Base. */\n@layer gramlot.tokens {\n :root {\n --gramlot-space-1: .2rem;\n --gramlot-space-2: .4rem;\n --gramlot-space-3: .5rem;\n --gramlot-space-4: .6rem;\n --gramlot-space-6: .9rem;\n --gramlot-space-8: 1.2rem;\n --gramlot-space-12: 1.8rem;\n --gramlot-radius-sm: .25rem;\n --gramlot-radius: .35rem;\n --gramlot-radius-lg: .4rem;\n }\n}\n\n@layer gramlot.base {\n html { font-size: 13px; }\n body { line-height: 1.35; }\n :where(h1, h2, h3, h4, h5, h6, p, ul, ol, dl, blockquote, pre, figure) { margin-block: 0 .5rem; }\n h1 { font-size: 1.35rem; }\n h2 { font-size: 1.15rem; }\n h3 { font-size: 1.05rem; }\n pre { padding: .5rem; }\n blockquote { padding-inline-start: .6rem; }\n hr { margin-block: 1rem; }\n}\n\n@layer gramlot.components {\n :where(button, input[type=\"button\"], input[type=\"submit\"], input[type=\"reset\"], .button) {\n min-block-size: 28px;\n padding: .25rem .5rem;\n font-size: 1rem;\n line-height: 1.35;\n }\n :where(label) { font-size: .95rem; }\n :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) {\n min-block-size: 28px;\n padding: .25rem .5rem;\n font-size: 1rem;\n line-height: 1.35;\n }\n :where(textarea) { min-block-size: 5rem; }\n :where(input[type=\"color\"]) { min-block-size: 28px; }\n :where(input[type=\"file\"])::file-selector-button { margin-inline-end: .5rem; padding: .25rem .5rem; }\n :where(fieldset) { margin-block-end: .6rem; padding: .5rem; }\n :where(table) { font-size: 1rem; }\n :where(th, td) { padding: .4rem .5rem; }\n :where(details) { padding: .4rem .5rem; }\n :where(details[open] > summary) { margin-block-end: .5rem; }\n :where(dialog) { padding: .75rem; }\n}\n\n@layer gramlot.utilities {\n .example-page { inline-size: min(100% - 1.2rem, var(--gramlot-page-width)); padding-block: .6rem; }\n .card { padding: .6rem; box-shadow: none; }\n}\n";
|
|
1
|
+
// Generated from canonical themes; edit themes/, not this file.
|
|
2
|
+
export const appearanceStyles = {"base":"","compact":"/* Gramlot Compact: load after gramlot-base/theme.css. Colors and behavior stay in Base. */\n@layer gramlot.tokens {\n :root {\n --gramlot-field-height: 28px;\n --gramlot-field-line-height: 1.35;\n --gramlot-field-padding: .25rem .5rem;\n --gramlot-field-font-size: 1rem;\n --gramlot-space-1: .2rem;\n --gramlot-space-2: .4rem;\n --gramlot-space-3: .5rem;\n --gramlot-space-4: .6rem;\n --gramlot-space-6: .9rem;\n --gramlot-space-8: 1.2rem;\n --gramlot-space-12: 1.8rem;\n --gramlot-radius-sm: .25rem;\n --gramlot-radius: .35rem;\n --gramlot-radius-lg: .4rem;\n }\n}\n\n@layer gramlot.base {\n html { font-size: 13px; }\n body { line-height: 1.35; }\n :where(h1, h2, h3, h4, h5, h6, p, ul, ol, dl, blockquote, pre, figure) { margin-block: 0 .5rem; }\n h1 { font-size: 1.35rem; }\n h2 { font-size: 1.15rem; }\n h3 { font-size: 1.05rem; }\n pre { padding: .5rem; }\n blockquote { padding-inline-start: .6rem; }\n hr { margin-block: 1rem; }\n}\n\n@layer gramlot.components {\n :where(button, input[type=\"button\"], input[type=\"submit\"], input[type=\"reset\"], .button) {\n min-block-size: 28px;\n padding: .25rem .5rem;\n font-size: 1rem;\n line-height: 1.35;\n }\n :where(label) { font-size: .95rem; }\n :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) {\n min-block-size: var(--gramlot-field-height);\n padding: var(--gramlot-field-padding);\n font-size: var(--gramlot-field-font-size);\n line-height: var(--gramlot-field-line-height);\n }\n :where(textarea) { min-block-size: 5rem; }\n :where(input[type=\"color\"]) { min-block-size: 28px; }\n :where(input[type=\"file\"])::file-selector-button { margin-inline-end: .5rem; padding: .25rem .5rem; }\n :where(fieldset) { margin-block-end: .6rem; padding: .5rem; }\n :where(table) { font-size: 1rem; }\n :where(th, td) { padding: .4rem .5rem; }\n :where(details) { padding: .4rem .5rem; }\n :where(details[open] > summary) { margin-block-end: .5rem; }\n :where(dialog) { padding: .75rem; }\n}\n\n@layer gramlot.utilities {\n .example-page { inline-size: min(100% - 1.2rem, var(--gramlot-page-width)); padding-block: .6rem; }\n .card { padding: .6rem; box-shadow: none; }\n}\n","mimi":"/* Gramlot Compact: load after gramlot-base/theme.css. Colors and behavior stay in Base. */\n@layer gramlot.tokens {\n :root {\n --gramlot-field-height: 28px;\n --gramlot-field-line-height: 1.35;\n --gramlot-field-padding: .25rem .5rem;\n --gramlot-field-font-size: 1rem;\n --gramlot-space-1: .2rem;\n --gramlot-space-2: .4rem;\n --gramlot-space-3: .5rem;\n --gramlot-space-4: .6rem;\n --gramlot-space-6: .9rem;\n --gramlot-space-8: 1.2rem;\n --gramlot-space-12: 1.8rem;\n --gramlot-radius-sm: .25rem;\n --gramlot-radius: .35rem;\n --gramlot-radius-lg: .4rem;\n }\n}\n\n@layer gramlot.base {\n html { font-size: 13px; }\n body { line-height: 1.35; }\n :where(h1, h2, h3, h4, h5, h6, p, ul, ol, dl, blockquote, pre, figure) { margin-block: 0 .5rem; }\n h1 { font-size: 1.35rem; }\n h2 { font-size: 1.15rem; }\n h3 { font-size: 1.05rem; }\n pre { padding: .5rem; }\n blockquote { padding-inline-start: .6rem; }\n hr { margin-block: 1rem; }\n}\n\n@layer gramlot.components {\n :where(button, input[type=\"button\"], input[type=\"submit\"], input[type=\"reset\"], .button) {\n min-block-size: 28px;\n padding: .25rem .5rem;\n font-size: 1rem;\n line-height: 1.35;\n }\n :where(label) { font-size: .95rem; }\n :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) {\n min-block-size: var(--gramlot-field-height);\n padding: var(--gramlot-field-padding);\n font-size: var(--gramlot-field-font-size);\n line-height: var(--gramlot-field-line-height);\n }\n :where(textarea) { min-block-size: 5rem; }\n :where(input[type=\"color\"]) { min-block-size: 28px; }\n :where(input[type=\"file\"])::file-selector-button { margin-inline-end: .5rem; padding: .25rem .5rem; }\n :where(fieldset) { margin-block-end: .6rem; padding: .5rem; }\n :where(table) { font-size: 1rem; }\n :where(th, td) { padding: .4rem .5rem; }\n :where(details) { padding: .4rem .5rem; }\n :where(details[open] > summary) { margin-block-end: .5rem; }\n :where(dialog) { padding: .75rem; }\n}\n\n@layer gramlot.utilities {\n .example-page { inline-size: min(100% - 1.2rem, var(--gramlot-page-width)); padding-block: .6rem; }\n .card { padding: .6rem; box-shadow: none; }\n}\n\n/* Gramlot adaptation of legacy mimi; load after Base and Compact. */\n@layer gramlot.tokens {\n :root {\n --gramlot-background: #EDEEF0;\n --gramlot-surface: #F5F5F6;\n --gramlot-surface-subtle: #E0E1E3;\n --gramlot-ink: #3C3D40;\n --gramlot-text-secondary: #6B6E72;\n --gramlot-border: #BDBFC2;\n --gramlot-border-control: #9EA0A3;\n --gramlot-navigation: #48494C;\n --gramlot-navigation-text: #FFFFFF;\n --gramlot-action: #0071E3;\n --gramlot-action-hover: #005BBB;\n --gramlot-brand-blue: #0071E3;\n --gramlot-brand-yellow: #9EA0A3;\n --gramlot-selected: #E8F1FC;\n --gramlot-focus-ring: #0071E3;\n --gramlot-field-background: #FFFFFF;\n --gramlot-field-readonly-background: #E0E1E3;\n --gramlot-error: #B3261E;\n --gramlot-error-background: #FFF1F0;\n --gramlot-shadow: 0 1px 4px rgb(0 0 0 / 6%);\n --gramlot-radius-sm: 4px;\n --gramlot-radius: 3px;\n --gramlot-radius-lg: 3px;\n --gramlot-field-height: 18px;\n --gramlot-field-padding: 1px 3px;\n --gramlot-field-line-height: 1.15;\n --gramlot-field-font-size: 1rem;\n --gramlot-label-size: .9em;\n --gramlot-label-gap: 2px;\n --gramlot-label-color: var(--gramlot-text-secondary);\n --gramlot-space-4: 6px;\n --gramlot-font-ui: -apple-system, BlinkMacSystemFont, \"Helvetica Neue\", Arial, sans-serif;\n }\n @media (prefers-color-scheme: dark) {\n :root:not([data-theme=\"light\"]) {\n --gramlot-background: #242527;\n --gramlot-surface: #303134;\n --gramlot-surface-subtle: #3C3D40;\n --gramlot-ink: #F2F2F7;\n --gramlot-text-secondary: #C7C7CC;\n --gramlot-border: #6B6E72;\n --gramlot-border-control: #8E8E93;\n --gramlot-navigation: #1C1C1E;\n --gramlot-action: #78B7FF;\n --gramlot-action-hover: #A6CFFF;\n --gramlot-brand-blue: #3478CA;\n --gramlot-selected: #254163;\n --gramlot-focus-ring: #78B7FF;\n --gramlot-field-background: #202124;\n --gramlot-field-readonly-background: #3C3D40;\n --gramlot-error: #FFB4AB;\n --gramlot-error-background: #482524;\n --gramlot-shadow: 0 1px 4px rgb(0 0 0 / 20%);\n }\n }\n :root[data-theme=\"dark\"] {\n --gramlot-background: #242527;\n --gramlot-surface: #303134;\n --gramlot-surface-subtle: #3C3D40;\n --gramlot-ink: #F2F2F7;\n --gramlot-text-secondary: #C7C7CC;\n --gramlot-border: #6B6E72;\n --gramlot-border-control: #8E8E93;\n --gramlot-navigation: #1C1C1E;\n --gramlot-action: #78B7FF;\n --gramlot-action-hover: #A6CFFF;\n --gramlot-brand-blue: #3478CA;\n --gramlot-selected: #254163;\n --gramlot-focus-ring: #78B7FF;\n --gramlot-field-background: #202124;\n --gramlot-field-readonly-background: #3C3D40;\n --gramlot-error: #FFB4AB;\n --gramlot-error-background: #482524;\n --gramlot-shadow: 0 1px 4px rgb(0 0 0 / 20%);\n }\n}\n@layer gramlot.base {\n html { font-size: 12px; }\n}\n@layer gramlot.components {\n :where(label) { font-size: var(--gramlot-label-size); font-weight: normal; color: var(--gramlot-label-color); margin-block-end: var(--gramlot-label-gap); }\n :where(button, input[type=\"button\"], input[type=\"submit\"], input[type=\"reset\"], .button) { min-block-size: 24px; padding: 2px 8px; font-weight: 500; }\n}\n@layer gramlot.utilities {\n .card { box-shadow: var(--gramlot-shadow); }\n}\n","joanna":"/* Gramlot Compact: load after gramlot-base/theme.css. Colors and behavior stay in Base. */\n@layer gramlot.tokens {\n :root {\n --gramlot-field-height: 28px;\n --gramlot-field-line-height: 1.35;\n --gramlot-field-padding: .25rem .5rem;\n --gramlot-field-font-size: 1rem;\n --gramlot-space-1: .2rem;\n --gramlot-space-2: .4rem;\n --gramlot-space-3: .5rem;\n --gramlot-space-4: .6rem;\n --gramlot-space-6: .9rem;\n --gramlot-space-8: 1.2rem;\n --gramlot-space-12: 1.8rem;\n --gramlot-radius-sm: .25rem;\n --gramlot-radius: .35rem;\n --gramlot-radius-lg: .4rem;\n }\n}\n\n@layer gramlot.base {\n html { font-size: 13px; }\n body { line-height: 1.35; }\n :where(h1, h2, h3, h4, h5, h6, p, ul, ol, dl, blockquote, pre, figure) { margin-block: 0 .5rem; }\n h1 { font-size: 1.35rem; }\n h2 { font-size: 1.15rem; }\n h3 { font-size: 1.05rem; }\n pre { padding: .5rem; }\n blockquote { padding-inline-start: .6rem; }\n hr { margin-block: 1rem; }\n}\n\n@layer gramlot.components {\n :where(button, input[type=\"button\"], input[type=\"submit\"], input[type=\"reset\"], .button) {\n min-block-size: 28px;\n padding: .25rem .5rem;\n font-size: 1rem;\n line-height: 1.35;\n }\n :where(label) { font-size: .95rem; }\n :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) {\n min-block-size: var(--gramlot-field-height);\n padding: var(--gramlot-field-padding);\n font-size: var(--gramlot-field-font-size);\n line-height: var(--gramlot-field-line-height);\n }\n :where(textarea) { min-block-size: 5rem; }\n :where(input[type=\"color\"]) { min-block-size: 28px; }\n :where(input[type=\"file\"])::file-selector-button { margin-inline-end: .5rem; padding: .25rem .5rem; }\n :where(fieldset) { margin-block-end: .6rem; padding: .5rem; }\n :where(table) { font-size: 1rem; }\n :where(th, td) { padding: .4rem .5rem; }\n :where(details) { padding: .4rem .5rem; }\n :where(details[open] > summary) { margin-block-end: .5rem; }\n :where(dialog) { padding: .75rem; }\n}\n\n@layer gramlot.utilities {\n .example-page { inline-size: min(100% - 1.2rem, var(--gramlot-page-width)); padding-block: .6rem; }\n .card { padding: .6rem; box-shadow: none; }\n}\n\n/* Gramlot adaptation of legacy joanna; load after Base and Compact. */\n@layer gramlot.tokens {\n :root {\n --gramlot-background: #F2F2F7;\n --gramlot-surface: #FFFFFF;\n --gramlot-surface-subtle: #F2F2F7;\n --gramlot-ink: #3A3A3C;\n --gramlot-text-secondary: #636366;\n --gramlot-border: #D1D1D6;\n --gramlot-border-control: #AEAEB2;\n --gramlot-navigation: #3A3A3C;\n --gramlot-navigation-text: #FFFFFF;\n --gramlot-action: #007AFF;\n --gramlot-action-hover: #0061CC;\n --gramlot-brand-blue: #007AFF;\n --gramlot-brand-yellow: #AEAEB2;\n --gramlot-selected: #E0EFFF;\n --gramlot-focus-ring: #007AFF;\n --gramlot-field-background: #FFFFFF;\n --gramlot-field-readonly-background: #F2F2F7;\n --gramlot-error: #B3261E;\n --gramlot-error-background: #FFF1F0;\n --gramlot-shadow: 0 1px 4px rgb(0 0 0 / 6%);\n --gramlot-radius-sm: 6px;\n --gramlot-radius: 6px;\n --gramlot-radius-lg: 6px;\n --gramlot-field-height: 20px;\n --gramlot-field-padding: 1px 3px;\n --gramlot-field-line-height: 1.15;\n --gramlot-field-font-size: 1rem;\n --gramlot-label-size: .8em;\n --gramlot-label-gap: 2px;\n --gramlot-label-color: var(--gramlot-text-secondary);\n --gramlot-space-4: 6px;\n --gramlot-font-ui: -apple-system, BlinkMacSystemFont, \"Helvetica Neue\", Arial, sans-serif;\n }\n @media (prefers-color-scheme: dark) {\n :root:not([data-theme=\"light\"]) {\n --gramlot-background: #1C1C1E;\n --gramlot-surface: #2C2C2E;\n --gramlot-surface-subtle: #3A3A3C;\n --gramlot-ink: #F2F2F7;\n --gramlot-text-secondary: #C7C7CC;\n --gramlot-border: #636366;\n --gramlot-border-control: #8E8E93;\n --gramlot-navigation: #1C1C1E;\n --gramlot-action: #78B7FF;\n --gramlot-action-hover: #A6CFFF;\n --gramlot-brand-blue: #3478CA;\n --gramlot-selected: #254163;\n --gramlot-focus-ring: #78B7FF;\n --gramlot-field-background: #202124;\n --gramlot-field-readonly-background: #3A3A3C;\n --gramlot-error: #FFB4AB;\n --gramlot-error-background: #482524;\n --gramlot-shadow: 0 1px 4px rgb(0 0 0 / 20%);\n }\n }\n :root[data-theme=\"dark\"] {\n --gramlot-background: #1C1C1E;\n --gramlot-surface: #2C2C2E;\n --gramlot-surface-subtle: #3A3A3C;\n --gramlot-ink: #F2F2F7;\n --gramlot-text-secondary: #C7C7CC;\n --gramlot-border: #636366;\n --gramlot-border-control: #8E8E93;\n --gramlot-navigation: #1C1C1E;\n --gramlot-action: #78B7FF;\n --gramlot-action-hover: #A6CFFF;\n --gramlot-brand-blue: #3478CA;\n --gramlot-selected: #254163;\n --gramlot-focus-ring: #78B7FF;\n --gramlot-field-background: #202124;\n --gramlot-field-readonly-background: #3A3A3C;\n --gramlot-error: #FFB4AB;\n --gramlot-error-background: #482524;\n --gramlot-shadow: 0 1px 4px rgb(0 0 0 / 20%);\n }\n}\n@layer gramlot.base {\n html { font-size: 13px; }\n}\n@layer gramlot.components {\n :where(label) { font-size: var(--gramlot-label-size); font-weight: normal; color: var(--gramlot-label-color); margin-block-end: var(--gramlot-label-gap); }\n :where(button, input[type=\"button\"], input[type=\"submit\"], input[type=\"reset\"], .button) { min-block-size: 26px; padding: 2px 8px; font-weight: 500; }\n}\n@layer gramlot.utilities {\n .card { box-shadow: var(--gramlot-shadow); }\n}\n"};
|
package/src/index-theme.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
export const THEME_READY = 'index:theme-ready';
|
|
3
3
|
export const THEME_SET = 'index:theme-set';
|
|
4
4
|
export const THEMES = new Set(['light', 'dark']);
|
|
5
|
-
export const APPEARANCES = new Set(['base', 'compact']);
|
|
5
|
+
export const APPEARANCES = new Set(['base', 'compact', 'mimi', 'joanna']);
|
package/src/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export {SourceHandler} from './handlers/source-handler.js';
|
|
|
11
11
|
export {RpcHandler} from './handlers/rpc-handler.js';
|
|
12
12
|
export {DomHandler} from './handlers/dom-handler.js';
|
|
13
13
|
export {UtilitiesHandler} from './handlers/utilities-handler.js';
|
|
14
|
-
export type {GramlotOptions, GramlotState, Publication, SubscriptionHandle} from './gramlot.js';
|
|
14
|
+
export type {GramlotOptions, GramlotState, Publication, SubscriptionHandle, FormatOptions} from './gramlot.js';
|
|
15
15
|
export {PageBootstrap} from './bootstrap.js';
|
|
16
16
|
export type {PageBootstrapOptions, PageResources} from './bootstrap.js';
|
|
17
17
|
export {Page} from './server/page.js';
|
|
@@ -31,3 +31,6 @@ export type {BeaconNavigator, DomDocument, DomElement, DomEvent, DomFragment, Do
|
|
|
31
31
|
|
|
32
32
|
export {IndexPage} from "./server/index-page.js";
|
|
33
33
|
export {IndexLogic, mountIndexPage} from "./index-page-runtime.js";
|
|
34
|
+
|
|
35
|
+
export {parseDateExpression} from './date-parser/index.js';
|
|
36
|
+
export type {DateExpressionOptions, DateExpressionResult, DateExpressionErrorCode} from './date-parser/index.js';
|