ooxml-ui 0.1.1
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/LICENSE +202 -0
- package/NOTICE +3 -0
- package/README.md +72 -0
- package/dist/button.d.ts +10 -0
- package/dist/checkable.d.ts +4 -0
- package/dist/chunk-5UKGBJXE.js +745 -0
- package/dist/chunk-7MCSBDSU.js +99 -0
- package/dist/chunk-EY266IK3.js +73 -0
- package/dist/chunk-H4KFVIGT.js +61 -0
- package/dist/chunk-KJV76AB7.js +221 -0
- package/dist/chunk-RLPL7Q6J.js +118 -0
- package/dist/controls.d.ts +16 -0
- package/dist/controls.js +3 -0
- package/dist/dialog.d.ts +13 -0
- package/dist/icons.d.ts +16 -0
- package/dist/icons.js +2 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +35 -0
- package/dist/presence.d.ts +31 -0
- package/dist/presence.js +2 -0
- package/dist/registry.d.ts +18 -0
- package/dist/ribbon.d.ts +8 -0
- package/dist/select.d.ts +13 -0
- package/dist/smartart-svg.d.ts +18 -0
- package/dist/smartart.d.ts +14 -0
- package/dist/smartart.js +2 -0
- package/dist/status-bar.d.ts +11 -0
- package/dist/styles.d.ts +8 -0
- package/dist/theme.d.ts +9 -0
- package/dist/theme.js +1 -0
- package/package.json +85 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { installOfficeUiTheme } from './chunk-H4KFVIGT.js';
|
|
2
|
+
export { THEME_CSS, THEME_STYLE_ID, installOfficeUiTheme } from './chunk-H4KFVIGT.js';
|
|
3
|
+
import { registerControls } from './chunk-5UKGBJXE.js';
|
|
4
|
+
export { CONTROL_DEFINERS, defineButton, defineCheckbox, defineDialog, defineRibbonGroup, defineSelect, defineStatusBar, defineStatusItem, defineSwitch, defineToolbar, registerControls } from './chunk-5UKGBJXE.js';
|
|
5
|
+
export { ICON_CSS, createIconSvg, defineIcon, getIcon, listIcons, paintIcon, registerIcon } from './chunk-7MCSBDSU.js';
|
|
6
|
+
import { definePresence } from './chunk-RLPL7Q6J.js';
|
|
7
|
+
export { definePresence, initialsOf, participantsFromAwareness } from './chunk-RLPL7Q6J.js';
|
|
8
|
+
import { defineSmartArt } from './chunk-KJV76AB7.js';
|
|
9
|
+
export { defineSmartArt, renderDiagramDrawing } from './chunk-KJV76AB7.js';
|
|
10
|
+
export { CONTRACT_REVISION } from './chunk-EY266IK3.js';
|
|
11
|
+
|
|
12
|
+
// src/index.ts
|
|
13
|
+
var OFFICE_UI_TAGS = [
|
|
14
|
+
"office-ui-icon",
|
|
15
|
+
"office-ui-button",
|
|
16
|
+
"office-ui-checkbox",
|
|
17
|
+
"office-ui-switch",
|
|
18
|
+
"office-ui-select",
|
|
19
|
+
"office-ui-ribbon-group",
|
|
20
|
+
"office-ui-toolbar",
|
|
21
|
+
"office-ui-dialog",
|
|
22
|
+
"office-ui-status-bar",
|
|
23
|
+
"office-ui-status-item",
|
|
24
|
+
"office-ui-presence",
|
|
25
|
+
"office-ui-smartart"
|
|
26
|
+
];
|
|
27
|
+
function registerOfficeUi(options = {}) {
|
|
28
|
+
if (typeof window === "undefined" || !window.customElements) return;
|
|
29
|
+
if (options.theme !== false) installOfficeUiTheme();
|
|
30
|
+
registerControls();
|
|
31
|
+
definePresence();
|
|
32
|
+
defineSmartArt();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { OFFICE_UI_TAGS, registerOfficeUi };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One collaborator as the avatar stack needs it. This is a deliberately minimal structural
|
|
3
|
+
* view of an awareness entry (identity, colour, activity); core's `collab` awareness model
|
|
4
|
+
* satisfies it, and `participantsFromAwareness` adapts raw `{ user }` awareness states.
|
|
5
|
+
*/
|
|
6
|
+
export interface PresenceParticipant {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
/** CSS colour of the participant's cursor and avatar ring. */
|
|
10
|
+
color?: string;
|
|
11
|
+
status?: 'active' | 'idle' | 'away';
|
|
12
|
+
/** The local user: sorted first and labelled "(you)". */
|
|
13
|
+
self?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export type OfficePresenceSelectEvent = CustomEvent<{
|
|
16
|
+
id: string;
|
|
17
|
+
}>;
|
|
18
|
+
/** Adapt awareness-like states (`{ clientId?, user: { id?, name, color? } }`) to participants. */
|
|
19
|
+
export declare function participantsFromAwareness(states: Iterable<{
|
|
20
|
+
clientId?: string | number;
|
|
21
|
+
user?: Partial<PresenceParticipant>;
|
|
22
|
+
} | undefined>, selfId?: string): PresenceParticipant[];
|
|
23
|
+
export declare const initialsOf: (name: string) => string;
|
|
24
|
+
/**
|
|
25
|
+
* Presence avatar stack. `participants` property (array of `PresenceParticipant`), `max`
|
|
26
|
+
* attribute (visible avatars, default 4; the rest collapse into a "+N" chip). `role="list"`
|
|
27
|
+
* with one button per person (accessible name = name, status and "(you)"); activating one emits
|
|
28
|
+
* `office-presence-select` `{ id }` so the host can follow that user. Rendering carries no
|
|
29
|
+
* identity beyond what the host passes in.
|
|
30
|
+
*/
|
|
31
|
+
export declare const definePresence: import("./registry.js").Definer;
|
package/dist/presence.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Internal UI ABI, independent of package versions. Bump for incompatible contracts. */
|
|
2
|
+
export declare const CONTRACT_REVISION = 1;
|
|
3
|
+
/** Throws when a tag is already defined by an incompatible ooxml-ui build. */
|
|
4
|
+
export declare function assertContract(registry: Pick<CustomElementRegistry, 'get'>, tag: string): void;
|
|
5
|
+
/**
|
|
6
|
+
* Define `tag` once per registry. Classes are built lazily inside `make`, so importing this
|
|
7
|
+
* package never touches `HTMLElement` (SSR-safe); only a define call needs a DOM.
|
|
8
|
+
*/
|
|
9
|
+
export declare function defineOnce(registry: CustomElementRegistry, tag: string, make: () => CustomElementConstructor): void;
|
|
10
|
+
export type Definer = ((registry?: CustomElementRegistry) => void) & {
|
|
11
|
+
readonly tag: string;
|
|
12
|
+
};
|
|
13
|
+
/** The registry of the current window, or undefined where there is no DOM (SSR). */
|
|
14
|
+
export declare function browserRegistry(): CustomElementRegistry | undefined;
|
|
15
|
+
/** Wrap a per-tag `make` factory into a public, SSR-safe, idempotent definer. */
|
|
16
|
+
export declare function definer(tag: string, make: () => CustomElementConstructor): Definer;
|
|
17
|
+
/** Bubbling, composed event: crosses shadow boundaries like the native ones do. */
|
|
18
|
+
export declare function emit<T>(host: HTMLElement, type: string, detail: T, cancelable?: boolean): boolean;
|
package/dist/ribbon.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Labelled group of ribbon commands: `role="group"`, `label` attribute is caption and name. */
|
|
2
|
+
export declare const defineRibbonGroup: import("./registry.js").Definer;
|
|
3
|
+
/**
|
|
4
|
+
* `role="toolbar"` container. Left/Right/Home/End move focus between enabled direct or
|
|
5
|
+
* group-nested controls (Up/Down instead when `aria-orientation="vertical"`).
|
|
6
|
+
* All items stay in the tab order: roving tabindex is not implemented yet.
|
|
7
|
+
*/
|
|
8
|
+
export declare const defineToolbar: import("./registry.js").Definer;
|
package/dist/select.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface OfficeSelectOption {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Single-select dropdown. Properties: `options` (array), `value`, `disabled`, `selectedIndex`;
|
|
8
|
+
* attributes `value`, `disabled`, `aria-label`. Trigger has `role="combobox"` and the popup is a
|
|
9
|
+
* `listbox`. Keyboard: ArrowDown/Up (open, move), Home, End, Enter/Space (choose), Escape
|
|
10
|
+
* (close), printable keys (typeahead); disabled options are skipped. `input` then `change`
|
|
11
|
+
* bubble when the user picks; setting a property is silent.
|
|
12
|
+
*/
|
|
13
|
+
export declare const defineSelect: import("./registry.js").Definer;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DiagramColor, DiagramDrawing } from 'ooxml-core/diagram';
|
|
2
|
+
export interface SmartArtRenderReport {
|
|
3
|
+
shapeCount: number;
|
|
4
|
+
/** Preset geometries drawn as a plain rectangle because no outline is available here. */
|
|
5
|
+
approximatedGeometries: string[];
|
|
6
|
+
/** Shapes that carry 3D scene data: drawn flat, the 3D is kept only in the source part. */
|
|
7
|
+
flattened3d: number;
|
|
8
|
+
/** Fill kinds drawn as a neutral placeholder (gradient is approximated by its first stop). */
|
|
9
|
+
approximatedFills: string[];
|
|
10
|
+
}
|
|
11
|
+
/** Theme colours the host resolved (`accent1` -> `#4472c4`); unresolved scheme colours are grey. */
|
|
12
|
+
export type SchemeColors = Readonly<Record<string, string>>;
|
|
13
|
+
export declare function colorToCss(color: DiagramColor | undefined, scheme: SchemeColors): string | undefined;
|
|
14
|
+
/** Render a core `DiagramDrawing` into an `<svg>`: pure DOM construction, no markup injection. */
|
|
15
|
+
export declare function renderDiagramDrawing(doc: Document, drawing: DiagramDrawing, scheme?: SchemeColors): {
|
|
16
|
+
svg: SVGSVGElement;
|
|
17
|
+
report: SmartArtRenderReport;
|
|
18
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type SmartArtRenderReport } from './smartart-svg.js';
|
|
2
|
+
export type { SchemeColors, SmartArtRenderReport } from './smartart-svg.js';
|
|
3
|
+
export { renderDiagramDrawing } from './smartart-svg.js';
|
|
4
|
+
export type OfficeSmartArtRenderEvent = CustomEvent<SmartArtRenderReport>;
|
|
5
|
+
/**
|
|
6
|
+
* `<office-ui-smartart>` draws the cached drawing of a SmartArt diagram (core
|
|
7
|
+
* `DiagramDrawing`, from `ooxml-core/diagram`) as SVG. Set `drawing` (and
|
|
8
|
+
* optionally `schemeColors`, resolved theme colours such as `{ accent1: '#4472c4' }`);
|
|
9
|
+
* `label` becomes the accessible name (`role="img"`). It never re-lays-out a diagram: it shows
|
|
10
|
+
* what the producing application last computed. Approximations (preset outlines drawn as
|
|
11
|
+
* rectangles, gradient and pattern fills, 3D) are reported honestly in the
|
|
12
|
+
* `office-smartart-render` event detail and in `data-approximated` attributes, never hidden.
|
|
13
|
+
*/
|
|
14
|
+
export declare const defineSmartArt: import("./registry.js").Definer;
|
package/dist/smartart.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type OfficeStatusActivateEvent = CustomEvent<{
|
|
2
|
+
id: string;
|
|
3
|
+
}>;
|
|
4
|
+
/** Status bar container: `role="group"` named by its `label` attribute (default "Status"). */
|
|
5
|
+
export declare const defineStatusBar: import("./registry.js").Definer;
|
|
6
|
+
/**
|
|
7
|
+
* One status entry: `label` and `value` attributes (textual, so assistive tech reads both).
|
|
8
|
+
* With the `interactive` attribute it renders a button and emits `office-status-activate`
|
|
9
|
+
* `{ id }` (`id` attribute) on click, Enter or Space; zoom or language pickers are examples.
|
|
10
|
+
*/
|
|
11
|
+
export declare const defineStatusItem: import("./registry.js").Definer;
|
package/dist/styles.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Attach scoped CSS to a shadow root: a constructed stylesheet when available, else a `<style>`. */
|
|
2
|
+
export declare function attachStyles(root: ShadowRoot, css: string): void;
|
|
3
|
+
/**
|
|
4
|
+
* Rules every control repeats: `hidden`, the coarse-pointer touch target and the forced-colors
|
|
5
|
+
* focus ring. Prepended to each control's own CSS by `controlCss`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const COMMON_CONTROL_CSS = "\n:host([hidden]) { display: none !important; }\n@media (pointer: coarse), (max-width: 767px) {\n\t:host { --office-target-size: 44px; }\n}\n@media (forced-colors: active) {\n\t:host(:focus-visible), :focus-visible { outline: 2px solid Highlight; outline-offset: 2px; }\n}\n";
|
|
8
|
+
export declare const controlCss: (css: string) => string;
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme-token foundation. Custom properties cross shadow boundaries, so one `<style>` in the
|
|
3
|
+
* document head themes every control. Every token also has a fallback inside each control, so
|
|
4
|
+
* installing the theme is optional; a host overrides any token on `:root` or on a container.
|
|
5
|
+
*/
|
|
6
|
+
export declare const THEME_STYLE_ID = "office-ui-theme";
|
|
7
|
+
export declare const THEME_CSS = "\n:root {\n\t--office-foreground: #1f2937;\n\t--office-muted-foreground: #6b7280;\n\t--office-background: #ffffff;\n\t--office-surface: #f3f4f6;\n\t--office-border: #d1d5db;\n\t--office-accent: #2563eb;\n\t--office-accent-foreground: #ffffff;\n\t--office-ring: #2563eb;\n\t--office-danger: #b91c1c;\n\t--office-target-size: 28px;\n\t--office-radius: 4px;\n\t--office-font: system-ui, -apple-system, \"Segoe UI\", sans-serif;\n}\n@media (prefers-color-scheme: dark) {\n\t:root:not([data-office-theme=\"light\"]) {\n\t--office-foreground: #f9fafb;\n\t--office-muted-foreground: #9ca3af;\n\t--office-background: #111827;\n\t--office-surface: #1f2937;\n\t--office-border: #374151;\n\t--office-accent: #6366f1;\n\t--office-ring: #818cf8;\n\t--office-danger: #f87171;\n\t}\n}\n:root[data-office-theme=\"dark\"] {\n\t--office-foreground: #f9fafb;\n\t--office-muted-foreground: #9ca3af;\n\t--office-background: #111827;\n\t--office-surface: #1f2937;\n\t--office-border: #374151;\n\t--office-accent: #6366f1;\n\t--office-ring: #818cf8;\n\t--office-danger: #f87171;\n}\n@media (pointer: coarse), (max-width: 767px) {\n\t:root { --office-target-size: 44px; }\n}\n@media (forced-colors: active) {\n\t:root {\n\t\t--office-foreground: CanvasText;\n\t\t--office-muted-foreground: GrayText;\n\t\t--office-background: Canvas;\n\t\t--office-surface: Canvas;\n\t\t--office-border: CanvasText;\n\t\t--office-accent: Highlight;\n\t\t--office-accent-foreground: HighlightText;\n\t\t--office-ring: Highlight;\n\t\t--office-danger: CanvasText;\n\t}\n}\n";
|
|
8
|
+
/** Idempotent. Browser-only; returns false (and does nothing) without a document. */
|
|
9
|
+
export declare function installOfficeUiTheme(doc?: Document | undefined): boolean;
|
package/dist/theme.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { THEME_CSS, THEME_STYLE_ID, installOfficeUiTheme } from './chunk-H4KFVIGT.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ooxml-ui",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Shared, format-neutral web components and styles for the Office viewers (Word, PowerPoint, Excel)",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"custom-elements",
|
|
7
|
+
"docx",
|
|
8
|
+
"office",
|
|
9
|
+
"pptx",
|
|
10
|
+
"ribbon",
|
|
11
|
+
"web-components"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/ChristopherVR/ooxml/tree/main/packages/ui#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/ChristopherVR/ooxml/issues"
|
|
16
|
+
},
|
|
17
|
+
"license": "Apache-2.0",
|
|
18
|
+
"author": "ChristopherVR",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/ChristopherVR/ooxml.git",
|
|
22
|
+
"directory": "packages/ui"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"LICENSE",
|
|
27
|
+
"NOTICE",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"type": "module",
|
|
31
|
+
"sideEffects": false,
|
|
32
|
+
"main": "./dist/index.js",
|
|
33
|
+
"module": "./dist/index.js",
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"import": "./dist/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./theme": {
|
|
41
|
+
"types": "./dist/theme.d.ts",
|
|
42
|
+
"import": "./dist/theme.js"
|
|
43
|
+
},
|
|
44
|
+
"./icons": {
|
|
45
|
+
"types": "./dist/icons.d.ts",
|
|
46
|
+
"import": "./dist/icons.js"
|
|
47
|
+
},
|
|
48
|
+
"./controls": {
|
|
49
|
+
"types": "./dist/controls.d.ts",
|
|
50
|
+
"import": "./dist/controls.js"
|
|
51
|
+
},
|
|
52
|
+
"./presence": {
|
|
53
|
+
"types": "./dist/presence.d.ts",
|
|
54
|
+
"import": "./dist/presence.js"
|
|
55
|
+
},
|
|
56
|
+
"./smartart": {
|
|
57
|
+
"types": "./dist/smartart.d.ts",
|
|
58
|
+
"import": "./dist/smartart.js"
|
|
59
|
+
},
|
|
60
|
+
"./package.json": "./package.json"
|
|
61
|
+
},
|
|
62
|
+
"publishConfig": {
|
|
63
|
+
"access": "public"
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "node scripts/build.mjs",
|
|
67
|
+
"prepack": "node scripts/ensure-built.mjs",
|
|
68
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
69
|
+
"test": "vitest run",
|
|
70
|
+
"test:package": "node scripts/package-smoke.mjs"
|
|
71
|
+
},
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"ooxml-core": "^0.2.0"
|
|
74
|
+
},
|
|
75
|
+
"devDependencies": {
|
|
76
|
+
"@types/jsdom": "^21.1.7",
|
|
77
|
+
"jsdom": "^26.1.0",
|
|
78
|
+
"tsup": "^8.5.1",
|
|
79
|
+
"typescript": "^5.9.3",
|
|
80
|
+
"vitest": "^3.2.0"
|
|
81
|
+
},
|
|
82
|
+
"engines": {
|
|
83
|
+
"node": ">=22"
|
|
84
|
+
}
|
|
85
|
+
}
|