@openelement/ui 1.0.0-alpha.6 → 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/package.json +2 -2
- package/src/component-recipes.js +60 -60
- package/src/generated-manifest.json +1 -1
- package/src/index.d.ts +15 -43
- package/src/index.js +15 -50
- package/src/instance-state.d.ts +16 -2
- package/src/instance-state.js +30 -24
- package/src/manifest.d.ts +5 -9
- package/src/manifest.js +6 -11
- package/src/open-badge.d.ts +113 -159
- package/src/open-badge.js +200 -239
- package/src/open-button.d.ts +296 -898
- package/src/open-button.js +1150 -1322
- package/src/open-callout.d.ts +225 -366
- package/src/open-callout.js +488 -569
- package/src/open-card.d.ts +114 -144
- package/src/open-card.js +197 -251
- package/src/open-code-block.d.ts +165 -168
- package/src/open-code-block.js +315 -366
- package/src/open-dialog.d.ts +241 -424
- package/src/open-dialog.js +643 -823
- package/src/open-dropdown.d.ts +195 -252
- package/src/open-dropdown.js +368 -471
- package/src/open-input.d.ts +404 -1420
- package/src/open-input.js +1809 -2095
- package/src/open-props-tokens.d.ts +5 -5
- package/src/open-props-tokens.js +12 -7
- package/src/open-tabs.d.ts +163 -191
- package/src/open-tabs.js +306 -361
- package/src/open-theme-toggle.d.ts +171 -287
- package/src/open-theme-toggle.js +530 -754
- package/src/register.d.ts +4 -1
- package/src/register.js +27 -58
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openelement/ui",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -98,6 +98,6 @@
|
|
|
98
98
|
"sideEffects": false,
|
|
99
99
|
"peerDependenciesMeta": {},
|
|
100
100
|
"dependencies": {
|
|
101
|
-
"@openelement/element": "1.0.0-alpha.
|
|
101
|
+
"@openelement/element": "1.0.0-alpha.7"
|
|
102
102
|
}
|
|
103
103
|
}
|
package/src/component-recipes.js
CHANGED
|
@@ -1,75 +1,73 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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. */
|
|
22
|
-
|
|
15
|
+
/** Return the next realm-unique instance id suffix. */
|
|
16
|
+
function nextInstanceId() {
|
|
17
|
+
return instanceCount++;
|
|
23
18
|
}
|
|
24
19
|
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
+
"version": "1.0.0-alpha.7",
|
|
6
6
|
"description": "Open Props Web Component library for openElement",
|
|
7
7
|
"author": "openElement",
|
|
8
8
|
"license": "MIT",
|
package/src/index.d.ts
CHANGED
|
@@ -1,43 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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 { readInstanceState, writeInstanceState } from "./instance-state.js";
|
|
32
|
-
export { OpenButton } from "./open-button.js";
|
|
33
|
-
export { OpenCard } from "./open-card.js";
|
|
34
|
-
export { OpenInput } from "./open-input.js";
|
|
35
|
-
export { OpenCodeBlock } from "./open-code-block.js";
|
|
36
|
-
export { OpenBadge } from "./open-badge.js";
|
|
37
|
-
export { OpenThemeToggle } from "./open-theme-toggle.js";
|
|
38
|
-
export { OpenDialog } from "./open-dialog.js";
|
|
39
|
-
export { OpenCallout } from "./open-callout.js";
|
|
40
|
-
export { OpenDropdown } from "./open-dropdown.js";
|
|
41
|
-
export { OpenTabs } from "./open-tabs.js";
|
|
42
|
-
export { manifest } from "./manifest.js";
|
|
43
|
-
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,50 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
// Per-instance mutable state for compiled classes (host-scoped, garbage-
|
|
33
|
-
// collected with the host; a side-effect-free module — import the
|
|
34
|
-
// './instance-state' subpath from islands to keep chunks minimal).
|
|
35
|
-
export { readInstanceState, writeInstanceState } from './instance-state.js';
|
|
36
|
-
// Components
|
|
37
|
-
export { OpenButton } from './open-button.js';
|
|
38
|
-
export { OpenCard } from './open-card.js';
|
|
39
|
-
export { OpenInput } from './open-input.js';
|
|
40
|
-
export { OpenCodeBlock } from './open-code-block.js';
|
|
41
|
-
export { OpenBadge } from './open-badge.js';
|
|
42
|
-
export { OpenThemeToggle } from './open-theme-toggle.js';
|
|
43
|
-
export { OpenDialog } from './open-dialog.js';
|
|
44
|
-
export { OpenCallout } from './open-callout.js';
|
|
45
|
-
export { OpenDropdown } from './open-dropdown.js';
|
|
46
|
-
export { OpenTabs } from './open-tabs.js';
|
|
47
|
-
// Package manifest (WC Package Protocol)
|
|
48
|
-
// Consumers (the router build) read manifest.declarations to derive island metadata.
|
|
49
|
-
export { manifest } from './manifest.js';
|
|
50
|
-
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/instance-state.d.ts
CHANGED
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
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
|
package/src/instance-state.js
CHANGED
|
@@ -1,27 +1,33 @@
|
|
|
1
|
+
//#region src/instance-state.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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. */
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 };
|