@openelement/ui 1.0.0-alpha.5 → 1.0.0-alpha.7

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/README.md CHANGED
@@ -160,6 +160,7 @@ manifest; the per-component JSDoc is the source of truth for those.
160
160
  @openelement/ui/open-tabs
161
161
  @openelement/ui/open-props-tokens
162
162
  @openelement/ui/open-props-tokens.js (legacy alias of the previous entry)
163
+ @openelement/ui/instance-state (per-element instance state store; tree-shakeable leaf)
163
164
  ```
164
165
 
165
166
  The last entry is a compatibility alias kept for import maps written against the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openelement/ui",
3
- "version": "1.0.0-alpha.5",
3
+ "version": "1.0.0-alpha.7",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -60,6 +60,11 @@
60
60
  "import": "./src/open-tabs.js",
61
61
  "default": "./src/open-tabs.js"
62
62
  },
63
+ "./instance-state": {
64
+ "types": "./src/instance-state.d.ts",
65
+ "import": "./src/instance-state.js",
66
+ "default": "./src/instance-state.js"
67
+ },
63
68
  "./open-props-tokens": {
64
69
  "types": "./src/open-props-tokens.d.ts",
65
70
  "import": "./src/open-props-tokens.js",
@@ -93,6 +98,6 @@
93
98
  "sideEffects": false,
94
99
  "peerDependenciesMeta": {},
95
100
  "dependencies": {
96
- "@openelement/element": "1.0.0-alpha.5"
101
+ "@openelement/element": "1.0.0-alpha.7"
97
102
  }
98
103
  }
@@ -1,75 +1,73 @@
1
- /** Shared helpers and visual recipes for the public UI primitives. */ import { createLogger, StyleSheet } from '@openelement/element';
1
+ import { StyleSheet, createLogger } from "@openelement/element";
2
+ //#region src/component-recipes.ts
3
+ /** Shared helpers and visual recipes for the public UI primitives. */
2
4
  /**
3
- * Shared component logger. Compiled modules may not carry runtime top-level
4
- * statements (OEC9008), so the logger instance lives in this plain module.
5
- */ export const log = createLogger('ui');
6
- /** open-code-block tuning constants (compiled modules carry no top-level consts). */ export const CODE_BLOCK_CONSTANTS = {
7
- maxHighlightRetries: 120,
8
- copyFeedbackMs: 2000
5
+ * Shared component logger. Compiled modules may not carry runtime top-level
6
+ * statements (OEC9008), so the logger instance lives in this plain module.
7
+ */
8
+ const log = createLogger("ui");
9
+ /** open-code-block tuning constants (compiled modules carry no top-level consts). */
10
+ const CODE_BLOCK_CONSTANTS = {
11
+ maxHighlightRetries: 120,
12
+ copyFeedbackMs: 2e3
9
13
  };
10
- // Instance-unique ids so multiple instances of one component on a page never
11
- // collide on id/htmlFor/aria-*. Uniqueness holds within one realm only: SSG
12
- // renders every page in a single process (the count accumulates across
13
- // pages) and island hydration does not upgrade components in document order,
14
- // so the server and client counters can assign different ids to the same
15
- // instance. Pairs that must match across realms therefore have to be
16
- // re-synced on the client — the compiled components assign their ids at
17
- // activation (open-input, open-dropdown, open-tabs), so client and server
18
- // each keep one consistent realm. References that stay inside a single
19
- // activation need no repair.
20
14
  let instanceCount = 0;
21
- /** Return the next realm-unique instance id suffix. */ export function nextInstanceId() {
22
- return instanceCount++;
15
+ /** Return the next realm-unique instance id suffix. */
16
+ function nextInstanceId() {
17
+ return instanceCount++;
23
18
  }
24
19
  /**
25
- * Build a StyleSheetLike from a CSS string. Shared by the component-local
26
- * sheets so components do not repeat new StyleSheet()+replaceSync boilerplate.
27
- */ export function recipe(css) {
28
- const sheet = new StyleSheet();
29
- sheet.replaceSync(css);
30
- return sheet;
20
+ * Build a StyleSheetLike from a CSS string. Shared by the component-local
21
+ * sheets so components do not repeat new StyleSheet()+replaceSync boilerplate.
22
+ */
23
+ function recipe(css) {
24
+ const sheet = new StyleSheet();
25
+ sheet.replaceSync(css);
26
+ return sheet;
31
27
  }
32
28
  /**
33
- * Reflect the `disabled` attribute into ElementInternals custom states
34
- * (:state(disabled)/:state(enabled)). Shared by the form-associated
35
- * primitives (open-button, open-input).
36
- */ export function syncDisabledState(internals, disabled) {
37
- if (!internals?.states) return;
38
- if (disabled) {
39
- internals.states.delete('enabled');
40
- internals.states.add('disabled');
41
- } else {
42
- internals.states.delete('disabled');
43
- internals.states.add('enabled');
44
- }
29
+ * Reflect the `disabled` attribute into ElementInternals custom states
30
+ * (:state(disabled)/:state(enabled)). Shared by the form-associated
31
+ * primitives (open-button, open-input).
32
+ */
33
+ function syncDisabledState(internals, disabled) {
34
+ if (!internals?.states) return;
35
+ if (disabled) {
36
+ internals.states.delete("enabled");
37
+ internals.states.add("disabled");
38
+ } else {
39
+ internals.states.delete("disabled");
40
+ internals.states.add("enabled");
41
+ }
45
42
  }
46
43
  /**
47
- * Compiled modules may not carry helper functions at top level (OEC9008), so
48
- * the form lookup shared by the form-associated primitives lives here.
49
- */ export function closestFormOf(element) {
50
- return typeof element.closest === 'function' ? element.closest('form') : null;
44
+ * Compiled modules may not carry helper functions at top level (OEC9008), so
45
+ * the form lookup shared by the form-associated primitives lives here.
46
+ */
47
+ function closestFormOf(element) {
48
+ return typeof element.closest === "function" ? element.closest("form") : null;
51
49
  }
52
50
  /**
53
- * Deepest focused element, descending through open shadow roots (OEC9008:
54
- * shared helpers live in plain .ts modules, not compiled component modules).
55
- */ export function deepActiveElement() {
56
- let active = document.activeElement;
57
- while(active?.shadowRoot?.activeElement){
58
- active = active.shadowRoot.activeElement;
59
- }
60
- return active ?? null;
51
+ * Deepest focused element, descending through open shadow roots (OEC9008:
52
+ * shared helpers live in plain .ts modules, not compiled component modules).
53
+ */
54
+ function deepActiveElement() {
55
+ let active = document.activeElement;
56
+ while (active?.shadowRoot?.activeElement) active = active.shadowRoot.activeElement;
57
+ return active ?? null;
61
58
  }
62
59
  /**
63
- * open-callout's type → icon map. Compiled modules may not carry runtime
64
- * top-level statements (OEC9008), so shared lookup tables live in plain .ts
65
- * modules like this one.
66
- */ export const CALLOUT_TYPE_ICONS = {
67
- info: 'ℹ️',
68
- warning: '⚠',
69
- danger: '✕',
70
- tip: '✓'
60
+ * open-callout's type → icon map. Compiled modules may not carry runtime
61
+ * top-level statements (OEC9008), so shared lookup tables live in plain .ts
62
+ * modules like this one.
63
+ */
64
+ const CALLOUT_TYPE_ICONS = {
65
+ info: "ℹ️",
66
+ warning: "⚠",
67
+ danger: "✕",
68
+ tip: "✓"
71
69
  };
72
- export const controlRecipe = recipe(`
70
+ const controlRecipe = recipe(`
73
71
  .control {
74
72
  font: inherit;
75
73
  color: var(--ui-control-text);
@@ -89,7 +87,7 @@ export const controlRecipe = recipe(`
89
87
  }
90
88
  .control:disabled, .control[aria-disabled="true"] { opacity: .48; cursor: not-allowed; }
91
89
  `);
92
- export const surfaceRecipe = recipe(`
90
+ const surfaceRecipe = recipe(`
93
91
  .surface {
94
92
  color: var(--text-primary);
95
93
  background: var(--surface-glass);
@@ -98,7 +96,7 @@ export const surfaceRecipe = recipe(`
98
96
  box-shadow: var(--surface-highlight), var(--surface-shadow);
99
97
  }
100
98
  `);
101
- export const overlayRecipe = recipe(`
99
+ const overlayRecipe = recipe(`
102
100
  .overlay {
103
101
  color: var(--text-primary);
104
102
  background: var(--surface-overlay);
@@ -107,3 +105,5 @@ export const overlayRecipe = recipe(`
107
105
  box-shadow: var(--surface-highlight), var(--overlay-shadow);
108
106
  }
109
107
  `);
108
+ //#endregion
109
+ export { CALLOUT_TYPE_ICONS, CODE_BLOCK_CONSTANTS, closestFormOf, controlRecipe, deepActiveElement, log, nextInstanceId, overlayRecipe, recipe, surfaceRecipe, syncDisabledState };
@@ -2,7 +2,7 @@
2
2
  "$comment": "GENERATED FILE - do not edit. Regenerate with: deno task generate:ui-manifest (drift gate: ui-manifest:check).",
3
3
  "schemaVersion": "1.0.0",
4
4
  "packageName": "@openelement/ui",
5
- "version": "1.0.0-alpha.5",
5
+ "version": "1.0.0-alpha.7",
6
6
  "description": "Open Props Web Component library for openElement",
7
7
  "author": "openElement",
8
8
  "license": "MIT",
@@ -50,6 +50,7 @@
50
50
  "dsd": true,
51
51
  "layer": "dsd-static",
52
52
  "hydrate": "idle",
53
+ "status": "experimental",
53
54
  "module": "@openelement/ui/open-card",
54
55
  "export": "OpenCard"
55
56
  }
@@ -96,6 +97,7 @@
96
97
  "dsd": true,
97
98
  "layer": "dsd-static",
98
99
  "hydrate": "idle",
100
+ "status": "experimental",
99
101
  "module": "@openelement/ui/open-callout",
100
102
  "export": "OpenCallout"
101
103
  }
@@ -162,6 +164,7 @@
162
164
  "dsd": true,
163
165
  "layer": "dsd-interactive",
164
166
  "hydrate": "load",
167
+ "status": "stable",
165
168
  "module": "@openelement/ui/open-button",
166
169
  "export": "OpenButton"
167
170
  }
@@ -260,6 +263,7 @@
260
263
  "dsd": true,
261
264
  "layer": "dsd-interactive",
262
265
  "hydrate": "load",
266
+ "status": "experimental",
263
267
  "module": "@openelement/ui/open-input",
264
268
  "export": "OpenInput"
265
269
  }
@@ -302,6 +306,7 @@
302
306
  "dsd": true,
303
307
  "layer": "dsd-interactive",
304
308
  "hydrate": "load",
309
+ "status": "stable",
305
310
  "module": "@openelement/ui/open-theme-toggle",
306
311
  "export": "OpenThemeToggle"
307
312
  }
@@ -328,6 +333,7 @@
328
333
  "dsd": true,
329
334
  "layer": "dsd-static",
330
335
  "hydrate": "idle",
336
+ "status": "stable",
331
337
  "module": "@openelement/ui/open-code-block",
332
338
  "export": "OpenCodeBlock"
333
339
  }
@@ -366,6 +372,7 @@
366
372
  "dsd": true,
367
373
  "layer": "dsd-static",
368
374
  "hydrate": "idle",
375
+ "status": "stable",
369
376
  "module": "@openelement/ui/open-badge",
370
377
  "export": "OpenBadge"
371
378
  }
@@ -436,6 +443,7 @@
436
443
  "dsd": true,
437
444
  "layer": "dsd-interactive",
438
445
  "hydrate": "idle",
446
+ "status": "experimental",
439
447
  "module": "@openelement/ui/open-dialog",
440
448
  "export": "OpenDialog"
441
449
  }
@@ -470,6 +478,7 @@
470
478
  "dsd": true,
471
479
  "layer": "dsd-interactive",
472
480
  "hydrate": "load",
481
+ "status": "experimental",
473
482
  "module": "@openelement/ui/open-dropdown",
474
483
  "export": "OpenDropdown"
475
484
  }
@@ -494,6 +503,7 @@
494
503
  "dsd": true,
495
504
  "layer": "dsd-interactive",
496
505
  "hydrate": "load",
506
+ "status": "experimental",
497
507
  "module": "@openelement/ui/open-tabs",
498
508
  "export": "OpenTabs"
499
509
  }
package/src/index.d.ts CHANGED
@@ -1,42 +1,15 @@
1
- /**
2
- * @openelement/ui - openElement UI Component Library
3
- *
4
- * Swiss International Style: minimal, typography-driven, violet brand accent.
5
- * Zero Lit dependency - built on openElement (native HTMLElement).
6
- *
7
- * Components:
8
- * - open-button: Button with variants (default, primary, ghost, accent)
9
- * - open-card: Card container with optional header/footer
10
- * - open-input: Input field with label and error states
11
- * - open-code-block: Code block with copy button
12
- * - open-badge: Open Props status badge
13
- * - open-theme-toggle: Theme toggle Island (Dark/Light)
14
- * - open-dialog: Dialog component using native <dialog>
15
- * - open-callout: Callout/notice box (info/warning/danger/tip)
16
- * - open-dropdown: Dropdown toggle with trigger slot and content slot
17
- * - open-tabs: Tab interface with tab and panel slots
18
- *
19
- * Usage:
20
- * ```ts
21
- * // Import all components
22
- * import { registerOpenUi } from '@openelement/ui';
23
- * registerOpenUi();
24
- *
25
- * // Or import specific components
26
- * import { OpenButton } from '@openelement/ui/open-button';
27
- * ```
28
- *
29
- * @module @openelement/ui
30
- */ export { openPropsTokenSheet } from "./open-props-tokens.js";
31
- export { OpenButton } from "./open-button.js";
32
- export { OpenCard } from "./open-card.js";
33
- export { OpenInput } from "./open-input.js";
34
- export { OpenCodeBlock } from "./open-code-block.js";
35
- export { OpenBadge } from "./open-badge.js";
36
- export { OpenThemeToggle } from "./open-theme-toggle.js";
37
- export { OpenDialog } from "./open-dialog.js";
38
- export { OpenCallout } from "./open-callout.js";
39
- export { OpenDropdown } from "./open-dropdown.js";
40
- export { OpenTabs } from "./open-tabs.js";
41
- export { manifest } from "./manifest.js";
42
- export { registerOpenUi } from "./register.js";
1
+ import { openPropsTokenSheet } from "./open-props-tokens.js";
2
+ import { readInstanceState, writeInstanceState } from "./instance-state.js";
3
+ import { OpenButton } from "./open-button.js";
4
+ import { OpenCard } from "./open-card.js";
5
+ import { OpenInput } from "./open-input.js";
6
+ import { OpenCodeBlock } from "./open-code-block.js";
7
+ import { OpenBadge } from "./open-badge.js";
8
+ import { OpenThemeToggle } from "./open-theme-toggle.js";
9
+ import { OpenDialog } from "./open-dialog.js";
10
+ import { OpenCallout } from "./open-callout.js";
11
+ import { OpenDropdown } from "./open-dropdown.js";
12
+ import { OpenTabs } from "./open-tabs.js";
13
+ import { manifest } from "./manifest.js";
14
+ import { registerOpenUi } from "./register.js";
15
+ export { OpenBadge, OpenButton, OpenCallout, OpenCard, OpenCodeBlock, OpenDialog, OpenDropdown, OpenInput, OpenTabs, OpenThemeToggle, manifest, openPropsTokenSheet, readInstanceState, registerOpenUi, writeInstanceState };
package/src/index.js CHANGED
@@ -1,46 +1,15 @@
1
- /**
2
- * @openelement/ui - openElement UI Component Library
3
- *
4
- * Swiss International Style: minimal, typography-driven, violet brand accent.
5
- * Zero Lit dependency - built on openElement (native HTMLElement).
6
- *
7
- * Components:
8
- * - open-button: Button with variants (default, primary, ghost, accent)
9
- * - open-card: Card container with optional header/footer
10
- * - open-input: Input field with label and error states
11
- * - open-code-block: Code block with copy button
12
- * - open-badge: Open Props status badge
13
- * - open-theme-toggle: Theme toggle Island (Dark/Light)
14
- * - open-dialog: Dialog component using native <dialog>
15
- * - open-callout: Callout/notice box (info/warning/danger/tip)
16
- * - open-dropdown: Dropdown toggle with trigger slot and content slot
17
- * - open-tabs: Tab interface with tab and panel slots
18
- *
19
- * Usage:
20
- * ```ts
21
- * // Import all components
22
- * import { registerOpenUi } from '@openelement/ui';
23
- * registerOpenUi();
24
- *
25
- * // Or import specific components
26
- * import { OpenButton } from '@openelement/ui/open-button';
27
- * ```
28
- *
29
- * @module @openelement/ui
30
- */ // Design tokens (CSSStyleSheet, zero Lit dependency)
31
- export { openPropsTokenSheet } from './open-props-tokens.js';
32
- // Components
33
- export { OpenButton } from './open-button.js';
34
- export { OpenCard } from './open-card.js';
35
- export { OpenInput } from './open-input.js';
36
- export { OpenCodeBlock } from './open-code-block.js';
37
- export { OpenBadge } from './open-badge.js';
38
- export { OpenThemeToggle } from './open-theme-toggle.js';
39
- export { OpenDialog } from './open-dialog.js';
40
- export { OpenCallout } from './open-callout.js';
41
- export { OpenDropdown } from './open-dropdown.js';
42
- export { OpenTabs } from './open-tabs.js';
43
- // Package manifest (WC Package Protocol)
44
- // Consumers (the router build) read manifest.declarations to derive island metadata.
45
- export { manifest } from './manifest.js';
46
- export { registerOpenUi } from './register.js';
1
+ import { openPropsTokenSheet } from "./open-props-tokens.js";
2
+ import { readInstanceState, writeInstanceState } from "./instance-state.js";
3
+ import { OpenButton } from "./open-button.js";
4
+ import { OpenCard } from "./open-card.js";
5
+ import { OpenInput } from "./open-input.js";
6
+ import { OpenCodeBlock } from "./open-code-block.js";
7
+ import { OpenBadge } from "./open-badge.js";
8
+ import { OpenThemeToggle } from "./open-theme-toggle.js";
9
+ import { OpenDialog } from "./open-dialog.js";
10
+ import { OpenCallout } from "./open-callout.js";
11
+ import { OpenDropdown } from "./open-dropdown.js";
12
+ import { OpenTabs } from "./open-tabs.js";
13
+ import { manifest } from "./manifest.js";
14
+ import { registerOpenUi } from "./register.js";
15
+ export { OpenBadge, OpenButton, OpenCallout, OpenCard, OpenCodeBlock, OpenDialog, OpenDropdown, OpenInput, OpenTabs, OpenThemeToggle, manifest, openPropsTokenSheet, readInstanceState, registerOpenUi, writeInstanceState };
@@ -0,0 +1,16 @@
1
+ //#region src/instance-state.d.ts
2
+ /**
3
+ * Per-instance mutable state for the compiled UI primitives.
4
+ *
5
+ * Compiled classes carry only @property fields and methods — ephemeral
6
+ * imperative state (highlight bookkeeping, pointer guards, effect teardown)
7
+ * lives here, in a plain module, keyed by host. This mirrors the fixture
8
+ * pre-1.0 request-time pattern): the
9
+ * compiled kernel owns the program sinks; everything else is host-scoped and
10
+ * garbage-collected with it.
11
+ */
12
+ /** Read the host's `key` slot, initializing it with `init()` on first use. */
13
+ export declare function readInstanceState<T>(host: object, key: string, init: () => T): T;
14
+ /** Overwrite the host's `key` slot. */
15
+ export declare function writeInstanceState(host: object, key: string, value: unknown): void;
16
+ //#endregion
@@ -1,27 +1,33 @@
1
+ //#region src/instance-state.ts
1
2
  /**
2
- * Per-instance mutable state for the compiled UI primitives.
3
- *
4
- * Compiled classes carry only @property fields and methods — ephemeral
5
- * imperative state (highlight bookkeeping, pointer guards, effect teardown)
6
- * lives here, in a plain module, keyed by host. This mirrors the fixture
7
- * pre-1.0 request-time pattern): the
8
- * compiled kernel owns the program sinks; everything else is host-scoped and
9
- * garbage-collected with it.
10
- */ const stores = new WeakMap();
11
- /** Read the host's `key` slot, initializing it with `init()` on first use. */ export function readInstanceState(host, key, init) {
12
- let store = stores.get(host);
13
- if (!store) {
14
- store = new Map();
15
- stores.set(host, store);
16
- }
17
- if (!store.has(key)) store.set(key, init());
18
- return store.get(key);
3
+ * Per-instance mutable state for the compiled UI primitives.
4
+ *
5
+ * Compiled classes carry only @property fields and methods — ephemeral
6
+ * imperative state (highlight bookkeeping, pointer guards, effect teardown)
7
+ * lives here, in a plain module, keyed by host. This mirrors the fixture
8
+ * pre-1.0 request-time pattern): the
9
+ * compiled kernel owns the program sinks; everything else is host-scoped and
10
+ * garbage-collected with it.
11
+ */
12
+ const stores = /* @__PURE__ */ new WeakMap();
13
+ /** Read the host's `key` slot, initializing it with `init()` on first use. */
14
+ function readInstanceState(host, key, init) {
15
+ let store = stores.get(host);
16
+ if (!store) {
17
+ store = /* @__PURE__ */ new Map();
18
+ stores.set(host, store);
19
+ }
20
+ if (!store.has(key)) store.set(key, init());
21
+ return store.get(key);
19
22
  }
20
- /** Overwrite the host's `key` slot. */ export function writeInstanceState(host, key, value) {
21
- let store = stores.get(host);
22
- if (!store) {
23
- store = new Map();
24
- stores.set(host, store);
25
- }
26
- store.set(key, value);
23
+ /** Overwrite the host's `key` slot. */
24
+ function writeInstanceState(host, key, value) {
25
+ let store = stores.get(host);
26
+ if (!store) {
27
+ store = /* @__PURE__ */ new Map();
28
+ stores.set(host, store);
29
+ }
30
+ store.set(key, value);
27
31
  }
32
+ //#endregion
33
+ export { readInstanceState, writeInstanceState };
package/src/manifest.d.ts CHANGED
@@ -1,9 +1,5 @@
1
- /**
2
- * @openelement/ui - Generated Package Manifest
3
- *
4
- * Imports the tracked, generated manifest JSON (a reviewed package contract,
5
- * not a build cache). Generator: the ui manifest task; regenerate
6
- * with `deno task generate:ui-manifest`, drift gate with
7
- * `deno task ui-manifest:check` (wired into the source gate).
8
- */ import type { OpenElementPackageManifest } from '@openelement/element';
9
- /** The build-time generated package manifest (declarations for every UI component). */ export declare const manifest: OpenElementPackageManifest;
1
+ import { OpenElementPackageManifest } from "@openelement/element";
2
+ //#region src/manifest.d.ts
3
+ /** The build-time generated package manifest (declarations for every UI component). */
4
+ export declare const manifest: OpenElementPackageManifest;
5
+ //#endregion
package/src/manifest.js CHANGED
@@ -1,11 +1,6 @@
1
- /**
2
- * @openelement/ui - Generated Package Manifest
3
- *
4
- * Imports the tracked, generated manifest JSON (a reviewed package contract,
5
- * not a build cache). Generator: the ui manifest task; regenerate
6
- * with `deno task generate:ui-manifest`, drift gate with
7
- * `deno task ui-manifest:check` (wired into the source gate).
8
- */ import manifestData from './generated-manifest.json' with {
9
- type: 'json'
10
- };
11
- /** The build-time generated package manifest (declarations for every UI component). */ export const manifest = manifestData;
1
+ import manifestData from "./generated-manifest.json" with { type: "json" };
2
+ //#region src/manifest.ts
3
+ /** The build-time generated package manifest (declarations for every UI component). */
4
+ const manifest = manifestData;
5
+ //#endregion
6
+ export { manifest };