@xmesh/system-design 0.0.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/README.md +472 -0
- package/assets/brand-lockup-dark.svg +9 -0
- package/assets/brand-lockup-light.svg +9 -0
- package/assets/brand-mark.svg +9 -0
- package/colors_and_type.css +11 -0
- package/dist/lit/components/alert/index.css +201 -0
- package/dist/lit/components/alert/index.d.ts +25 -0
- package/dist/lit/components/alert/index.js +191 -0
- package/dist/lit/components/app-bar/index.css +80 -0
- package/dist/lit/components/app-bar/index.d.ts +19 -0
- package/dist/lit/components/app-bar/index.js +120 -0
- package/dist/lit/components/artifact/index.css +166 -0
- package/dist/lit/components/artifact/index.d.ts +37 -0
- package/dist/lit/components/artifact/index.js +294 -0
- package/dist/lit/components/autocomplete/index.css +171 -0
- package/dist/lit/components/autocomplete/index.d.ts +47 -0
- package/dist/lit/components/autocomplete/index.js +404 -0
- package/dist/lit/components/avatar/index.css +62 -0
- package/dist/lit/components/avatar/index.d.ts +19 -0
- package/dist/lit/components/avatar/index.js +112 -0
- package/dist/lit/components/avatar-group/index.css +60 -0
- package/dist/lit/components/avatar-group/index.d.ts +19 -0
- package/dist/lit/components/avatar-group/index.js +97 -0
- package/dist/lit/components/badge/index.css +72 -0
- package/dist/lit/components/badge/index.d.ts +18 -0
- package/dist/lit/components/badge/index.js +115 -0
- package/dist/lit/components/brand-mark/index.css +109 -0
- package/dist/lit/components/brand-mark/index.d.ts +24 -0
- package/dist/lit/components/brand-mark/index.js +116 -0
- package/dist/lit/components/breadcrumbs/index.css +91 -0
- package/dist/lit/components/breadcrumbs/index.d.ts +19 -0
- package/dist/lit/components/breadcrumbs/index.js +104 -0
- package/dist/lit/components/bubble/index.css +182 -0
- package/dist/lit/components/bubble/index.d.ts +72 -0
- package/dist/lit/components/bubble/index.js +617 -0
- package/dist/lit/components/button/index.css +342 -0
- package/dist/lit/components/button/index.d.ts +32 -0
- package/dist/lit/components/button/index.js +202 -0
- package/dist/lit/components/card/index.css +99 -0
- package/dist/lit/components/card/index.d.ts +20 -0
- package/dist/lit/components/card/index.js +133 -0
- package/dist/lit/components/chat/index.css +292 -0
- package/dist/lit/components/chat/index.d.ts +74 -0
- package/dist/lit/components/chat/index.js +589 -0
- package/dist/lit/components/checkbox/index.css +126 -0
- package/dist/lit/components/checkbox/index.d.ts +21 -0
- package/dist/lit/components/checkbox/index.js +138 -0
- package/dist/lit/components/chip/index.css +145 -0
- package/dist/lit/components/chip/index.d.ts +30 -0
- package/dist/lit/components/chip/index.js +230 -0
- package/dist/lit/components/chip-group/index.css +19 -0
- package/dist/lit/components/chip-group/index.d.ts +24 -0
- package/dist/lit/components/chip-group/index.js +171 -0
- package/dist/lit/components/code/index.css +42 -0
- package/dist/lit/components/code/index.d.ts +12 -0
- package/dist/lit/components/code/index.js +68 -0
- package/dist/lit/components/composer/index.css +548 -0
- package/dist/lit/components/composer/index.d.ts +67 -0
- package/dist/lit/components/composer/index.js +713 -0
- package/dist/lit/components/data-table/index.css +166 -0
- package/dist/lit/components/data-table/index.d.ts +55 -0
- package/dist/lit/components/data-table/index.js +390 -0
- package/dist/lit/components/dialog/index.css +124 -0
- package/dist/lit/components/dialog/index.d.ts +24 -0
- package/dist/lit/components/dialog/index.js +199 -0
- package/dist/lit/components/divider/index.css +27 -0
- package/dist/lit/components/divider/index.d.ts +13 -0
- package/dist/lit/components/divider/index.js +67 -0
- package/dist/lit/components/empty-state/index.css +69 -0
- package/dist/lit/components/empty-state/index.d.ts +21 -0
- package/dist/lit/components/empty-state/index.js +123 -0
- package/dist/lit/components/expansion-panel/index.css +120 -0
- package/dist/lit/components/expansion-panel/index.d.ts +22 -0
- package/dist/lit/components/expansion-panel/index.js +174 -0
- package/dist/lit/components/field/index.css +223 -0
- package/dist/lit/components/field/index.d.ts +106 -0
- package/dist/lit/components/field/index.js +388 -0
- package/dist/lit/components/file-input/index.css +257 -0
- package/dist/lit/components/file-input/index.d.ts +30 -0
- package/dist/lit/components/file-input/index.js +298 -0
- package/dist/lit/components/form/index.css +29 -0
- package/dist/lit/components/form/index.d.ts +38 -0
- package/dist/lit/components/form/index.js +192 -0
- package/dist/lit/components/grid/index.css +53 -0
- package/dist/lit/components/grid/index.d.ts +14 -0
- package/dist/lit/components/grid/index.js +82 -0
- package/dist/lit/components/kbd/index.css +35 -0
- package/dist/lit/components/kbd/index.d.ts +11 -0
- package/dist/lit/components/kbd/index.js +43 -0
- package/dist/lit/components/list/index.css +15 -0
- package/dist/lit/components/list/index.d.ts +28 -0
- package/dist/lit/components/list/index.js +188 -0
- package/dist/lit/components/list-item/index.css +119 -0
- package/dist/lit/components/list-item/index.d.ts +20 -0
- package/dist/lit/components/list-item/index.js +127 -0
- package/dist/lit/components/menu/index.css +94 -0
- package/dist/lit/components/menu/index.d.ts +47 -0
- package/dist/lit/components/menu/index.js +386 -0
- package/dist/lit/components/navigation-drawer/index.css +114 -0
- package/dist/lit/components/navigation-drawer/index.d.ts +29 -0
- package/dist/lit/components/navigation-drawer/index.js +218 -0
- package/dist/lit/components/overlay/index.css +171 -0
- package/dist/lit/components/overlay/index.d.ts +65 -0
- package/dist/lit/components/overlay/index.js +566 -0
- package/dist/lit/components/pagination/index.css +102 -0
- package/dist/lit/components/pagination/index.d.ts +22 -0
- package/dist/lit/components/pagination/index.js +184 -0
- package/dist/lit/components/primitives/index.css +504 -0
- package/dist/lit/components/primitives/index.d.ts +25 -0
- package/dist/lit/components/primitives/index.js +283 -0
- package/dist/lit/components/progress/index.css +143 -0
- package/dist/lit/components/progress/index.d.ts +23 -0
- package/dist/lit/components/progress/index.js +180 -0
- package/dist/lit/components/radio-group/index.css +178 -0
- package/dist/lit/components/radio-group/index.d.ts +35 -0
- package/dist/lit/components/radio-group/index.js +292 -0
- package/dist/lit/components/select/index.css +151 -0
- package/dist/lit/components/select/index.d.ts +50 -0
- package/dist/lit/components/select/index.js +390 -0
- package/dist/lit/components/sidebar-item/index.css +133 -0
- package/dist/lit/components/sidebar-item/index.d.ts +20 -0
- package/dist/lit/components/sidebar-item/index.js +105 -0
- package/dist/lit/components/skeleton/index.css +81 -0
- package/dist/lit/components/skeleton/index.d.ts +19 -0
- package/dist/lit/components/skeleton/index.js +119 -0
- package/dist/lit/components/slider/index.css +171 -0
- package/dist/lit/components/slider/index.d.ts +36 -0
- package/dist/lit/components/slider/index.js +302 -0
- package/dist/lit/components/snackbar/index.css +279 -0
- package/dist/lit/components/snackbar/index.d.ts +33 -0
- package/dist/lit/components/snackbar/index.js +195 -0
- package/dist/lit/components/stack/index.css +41 -0
- package/dist/lit/components/stack/index.d.ts +20 -0
- package/dist/lit/components/stack/index.js +103 -0
- package/dist/lit/components/switch/index.css +126 -0
- package/dist/lit/components/switch/index.d.ts +17 -0
- package/dist/lit/components/switch/index.js +116 -0
- package/dist/lit/components/table/index.css +85 -0
- package/dist/lit/components/table/index.d.ts +25 -0
- package/dist/lit/components/table/index.js +139 -0
- package/dist/lit/components/tabs/index.css +116 -0
- package/dist/lit/components/tabs/index.d.ts +49 -0
- package/dist/lit/components/tabs/index.js +320 -0
- package/dist/lit/components/text-field/index.css +90 -0
- package/dist/lit/components/text-field/index.d.ts +17 -0
- package/dist/lit/components/text-field/index.js +101 -0
- package/dist/lit/components/textarea/index.css +55 -0
- package/dist/lit/components/textarea/index.d.ts +26 -0
- package/dist/lit/components/textarea/index.js +124 -0
- package/dist/lit/components/tooltip/index.css +37 -0
- package/dist/lit/components/tooltip/index.d.ts +31 -0
- package/dist/lit/components/tooltip/index.js +196 -0
- package/dist/lit/components/validation/index.css +386 -0
- package/dist/lit/components/validation/index.d.ts +45 -0
- package/dist/lit/components/validation/index.js +318 -0
- package/dist/lit/index.d.ts +50 -0
- package/dist/lit/index.js +59 -0
- package/package.json +81 -0
- package/styles/README.md +346 -0
- package/styles/_elevation.css +24 -0
- package/styles/_fonts.css +6 -0
- package/styles/_layout.css +37 -0
- package/styles/_primitives.css +154 -0
- package/styles/_scroll.css +75 -0
- package/styles/_semantic.css +146 -0
- package/styles/_space.css +61 -0
- package/styles/_type.css +139 -0
- package/styles/_xmesh-extensions.css +232 -0
- package/styles/index.css +44 -0
- package/styles/md3/_color.css +102 -0
- package/styles/md3/_elevation.css +26 -0
- package/styles/md3/_motion.css +35 -0
- package/styles/md3/_shape.css +22 -0
- package/styles/md3/_state.css +22 -0
- package/styles/md3/_type.css +111 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* ============================================
|
|
2
|
+
Chip group — selection container for chips.
|
|
3
|
+
|
|
4
|
+
<xm-chip-group> lays slotted <xm-chip> children in a wrapping
|
|
5
|
+
row and owns selection (single by default, multi with `multiple`).
|
|
6
|
+
Layout only — the chips own all chrome. Sits on a surface* host,
|
|
7
|
+
so it adds no surface of its own.
|
|
8
|
+
============================================ */
|
|
9
|
+
|
|
10
|
+
.chip-group {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-wrap: wrap;
|
|
13
|
+
align-items: center;
|
|
14
|
+
gap: var(--s-2);
|
|
15
|
+
/* The group sits on a surface* host; establish on-surface as the
|
|
16
|
+
inherited ink so any chip that resolves currentColor against the
|
|
17
|
+
group reads correctly on the desk (AD-13). */
|
|
18
|
+
color: var(--md-sys-color-on-surface);
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import type { TemplateResult } from "lit";
|
|
3
|
+
type Primitive = string | number;
|
|
4
|
+
declare class XmChipGroup extends LitElement {
|
|
5
|
+
multiple: boolean;
|
|
6
|
+
value: Primitive | Primitive[] | null;
|
|
7
|
+
connectedCallback(): void;
|
|
8
|
+
disconnectedCallback(): void;
|
|
9
|
+
firstUpdated(): void;
|
|
10
|
+
private _chips;
|
|
11
|
+
private _enabledChips;
|
|
12
|
+
private _syncValueFromChips;
|
|
13
|
+
private _onChipActivate;
|
|
14
|
+
private _onKeydown;
|
|
15
|
+
private _updateRovingTabindex;
|
|
16
|
+
render(): TemplateResult;
|
|
17
|
+
private _onSlot;
|
|
18
|
+
}
|
|
19
|
+
declare global {
|
|
20
|
+
interface HTMLElementTagNameMap {
|
|
21
|
+
"xm-chip-group": XmChipGroup;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/*
|
|
2
|
+
chip-group/index.ts — <xm-chip-group>.
|
|
3
|
+
|
|
4
|
+
Selection owner for a set of <xm-chip> children. Single-select by
|
|
5
|
+
default; multi-select with `multiple`. Reads/sets each chip's public
|
|
6
|
+
`value` / `selected` properties only — never their shadow roots (AD-12).
|
|
7
|
+
|
|
8
|
+
Authoring:
|
|
9
|
+
<xm-chip-group name="filter">
|
|
10
|
+
<xm-chip value="all" selected>All</xm-chip>
|
|
11
|
+
<xm-chip value="open">Open</xm-chip>
|
|
12
|
+
<xm-chip value="closed">Closed</xm-chip>
|
|
13
|
+
</xm-chip-group>
|
|
14
|
+
|
|
15
|
+
<xm-chip-group multiple>
|
|
16
|
+
<xm-chip value="rest">REST</xm-chip>
|
|
17
|
+
<xm-chip value="graphql">GraphQL</xm-chip>
|
|
18
|
+
</xm-chip-group>
|
|
19
|
+
|
|
20
|
+
Properties:
|
|
21
|
+
multiple boolean — allow more than one selected chip
|
|
22
|
+
value string|number|Array — the current selection (reflected to
|
|
23
|
+
children on render); read it back from the change event
|
|
24
|
+
|
|
25
|
+
Events:
|
|
26
|
+
change bubbles+composed. detail.value = single primitive (single-
|
|
27
|
+
select) | Array<primitive> (multi-select). The chip's `value`,
|
|
28
|
+
never the element (AD-8a).
|
|
29
|
+
|
|
30
|
+
Keyboard (roving focus, WAI-ARIA toolbar/listbox-ish): ←/→ move between
|
|
31
|
+
chips, Home/End jump to ends; the focused chip's own Enter/Space toggles.
|
|
32
|
+
Shadow DOM; Lit is a bare `import` (peer dep).
|
|
33
|
+
*/
|
|
34
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
35
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
36
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
37
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
38
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
39
|
+
};
|
|
40
|
+
import { LitElement, html } from "lit";
|
|
41
|
+
import { customElement, property } from "lit/decorators.js";
|
|
42
|
+
const GROUP_CSS = new URL("../chip-group/index.css", import.meta.url).href;
|
|
43
|
+
let XmChipGroup = class XmChipGroup extends LitElement {
|
|
44
|
+
constructor() {
|
|
45
|
+
super(...arguments);
|
|
46
|
+
this.multiple = false;
|
|
47
|
+
this.value = null;
|
|
48
|
+
this._onChipActivate = (e) => {
|
|
49
|
+
const chip = e.target;
|
|
50
|
+
if (chip.tagName?.toLowerCase() !== "xm-chip")
|
|
51
|
+
return;
|
|
52
|
+
// Own the selection: stop the chip from self-toggling.
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
if (chip.disabled)
|
|
55
|
+
return;
|
|
56
|
+
if (this.multiple) {
|
|
57
|
+
chip.selected = !chip.selected;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
const wasSelected = chip.selected;
|
|
61
|
+
this._chips().forEach((c) => (c.selected = c === chip ? !wasSelected : false));
|
|
62
|
+
}
|
|
63
|
+
this._syncValueFromChips();
|
|
64
|
+
this._updateRovingTabindex();
|
|
65
|
+
this.dispatchEvent(new CustomEvent("change", {
|
|
66
|
+
detail: { value: this.value },
|
|
67
|
+
bubbles: true,
|
|
68
|
+
composed: true,
|
|
69
|
+
}));
|
|
70
|
+
};
|
|
71
|
+
this._onKeydown = (e) => {
|
|
72
|
+
const k = e.key;
|
|
73
|
+
if (k !== "ArrowLeft" && k !== "ArrowRight" && k !== "Home" && k !== "End")
|
|
74
|
+
return;
|
|
75
|
+
const chips = this._enabledChips();
|
|
76
|
+
if (chips.length === 0)
|
|
77
|
+
return;
|
|
78
|
+
const active = e.target;
|
|
79
|
+
const idx = chips.indexOf(active);
|
|
80
|
+
if (idx === -1)
|
|
81
|
+
return;
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
let next;
|
|
84
|
+
if (k === "Home")
|
|
85
|
+
next = 0;
|
|
86
|
+
else if (k === "End")
|
|
87
|
+
next = chips.length - 1;
|
|
88
|
+
else if (k === "ArrowRight")
|
|
89
|
+
next = (idx + 1) % chips.length;
|
|
90
|
+
else
|
|
91
|
+
next = (idx - 1 + chips.length) % chips.length;
|
|
92
|
+
const target = chips[next];
|
|
93
|
+
if (target) {
|
|
94
|
+
this._updateRovingTabindex(target);
|
|
95
|
+
target.focus();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
this._onSlot = () => {
|
|
99
|
+
this._syncValueFromChips();
|
|
100
|
+
this._updateRovingTabindex();
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
connectedCallback() {
|
|
104
|
+
super.connectedCallback();
|
|
105
|
+
this.addEventListener("xm-chip-activate", this._onChipActivate);
|
|
106
|
+
this.addEventListener("keydown", this._onKeydown);
|
|
107
|
+
}
|
|
108
|
+
disconnectedCallback() {
|
|
109
|
+
super.disconnectedCallback();
|
|
110
|
+
this.removeEventListener("xm-chip-activate", this._onChipActivate);
|
|
111
|
+
this.removeEventListener("keydown", this._onKeydown);
|
|
112
|
+
}
|
|
113
|
+
firstUpdated() {
|
|
114
|
+
// Adopt the chips' initial `selected`/`value` state as the group value,
|
|
115
|
+
// then normalize roving tabindex.
|
|
116
|
+
this._syncValueFromChips();
|
|
117
|
+
this._updateRovingTabindex();
|
|
118
|
+
}
|
|
119
|
+
_chips() {
|
|
120
|
+
return [...this.children].filter((c) => c.tagName.toLowerCase() === "xm-chip");
|
|
121
|
+
}
|
|
122
|
+
_enabledChips() {
|
|
123
|
+
return this._chips().filter((c) => !c.disabled);
|
|
124
|
+
}
|
|
125
|
+
_syncValueFromChips() {
|
|
126
|
+
const selected = this._chips().filter((c) => c.selected);
|
|
127
|
+
if (this.multiple) {
|
|
128
|
+
this.value = selected.map((c) => c.value);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
// Single-select: keep at most one selected.
|
|
132
|
+
if (selected.length > 1) {
|
|
133
|
+
selected.slice(1).forEach((c) => (c.selected = false));
|
|
134
|
+
}
|
|
135
|
+
this.value = selected[0]?.value ?? null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
_updateRovingTabindex(focused) {
|
|
139
|
+
const chips = this._chips();
|
|
140
|
+
const enabled = this._enabledChips();
|
|
141
|
+
const tabStop = focused ?? enabled.find((c) => c.selected) ?? enabled[0] ?? null;
|
|
142
|
+
chips.forEach((c) => {
|
|
143
|
+
c.tabIndex = c === tabStop && !c.disabled ? 0 : -1;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
render() {
|
|
147
|
+
return html `
|
|
148
|
+
<link rel="stylesheet" href="${GROUP_CSS}" />
|
|
149
|
+
<style>
|
|
150
|
+
:host {
|
|
151
|
+
display: block;
|
|
152
|
+
}
|
|
153
|
+
:host([hidden]) {
|
|
154
|
+
display: none;
|
|
155
|
+
}
|
|
156
|
+
</style>
|
|
157
|
+
<div class="chip-group" role="group">
|
|
158
|
+
<slot @slotchange=${this._onSlot}></slot>
|
|
159
|
+
</div>
|
|
160
|
+
`;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
__decorate([
|
|
164
|
+
property({ type: Boolean })
|
|
165
|
+
], XmChipGroup.prototype, "multiple", void 0);
|
|
166
|
+
__decorate([
|
|
167
|
+
property({ attribute: false })
|
|
168
|
+
], XmChipGroup.prototype, "value", void 0);
|
|
169
|
+
XmChipGroup = __decorate([
|
|
170
|
+
customElement("xm-chip-group")
|
|
171
|
+
], XmChipGroup);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* ============================================
|
|
2
|
+
Code — inline / block code display primitive.
|
|
3
|
+
|
|
4
|
+
<xm-code> presents code verbatim using the JetBrains Mono
|
|
5
|
+
typescale (--xm-typescale-mono-*). Inline by default; the
|
|
6
|
+
`block` modifier wraps it in a <pre> for a small code block.
|
|
7
|
+
|
|
8
|
+
A recessed surface-container-* backplate raised off the host,
|
|
9
|
+
a hairline 1px outline-variant border, ink --md-sys-color-on-surface
|
|
10
|
+
matched to the backplate (AD-13). Presentational chrome — never a
|
|
11
|
+
status hue (AD-11).
|
|
12
|
+
============================================ */
|
|
13
|
+
|
|
14
|
+
.code {
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
padding: 1px var(--s-2);
|
|
17
|
+
border: 1px solid var(--md-sys-color-outline-variant);
|
|
18
|
+
border-radius: var(--md-sys-shape-corner-extra-small);
|
|
19
|
+
background: var(--md-sys-color-surface-container-low);
|
|
20
|
+
color: var(--md-sys-color-on-surface);
|
|
21
|
+
font-family: var(--xm-typescale-mono-font);
|
|
22
|
+
font-size: var(--xm-typescale-mono-size);
|
|
23
|
+
font-weight: var(--xm-typescale-mono-weight);
|
|
24
|
+
line-height: var(--xm-typescale-mono-line-height);
|
|
25
|
+
letter-spacing: var(--xm-typescale-mono-tracking);
|
|
26
|
+
white-space: nowrap;
|
|
27
|
+
vertical-align: baseline;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* Block — recessed code panel. Wraps, scrolls horizontally if needed,
|
|
31
|
+
and uses the small corner + more padding of a panel rather than an
|
|
32
|
+
inline token. */
|
|
33
|
+
.code--block {
|
|
34
|
+
display: block;
|
|
35
|
+
margin: 0;
|
|
36
|
+
padding: var(--s-3) var(--s-4);
|
|
37
|
+
border-radius: var(--md-sys-shape-corner-small);
|
|
38
|
+
background: var(--md-sys-color-surface-container-low);
|
|
39
|
+
white-space: pre;
|
|
40
|
+
overflow-x: auto;
|
|
41
|
+
tab-size: 2;
|
|
42
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import type { TemplateResult } from "lit";
|
|
3
|
+
declare class XmCode extends LitElement {
|
|
4
|
+
block: boolean;
|
|
5
|
+
render(): TemplateResult;
|
|
6
|
+
}
|
|
7
|
+
declare global {
|
|
8
|
+
interface HTMLElementTagNameMap {
|
|
9
|
+
"xm-code": XmCode;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
code/index.ts — <xm-code>.
|
|
3
|
+
|
|
4
|
+
Inline (default) or block code display primitive. Wraps its
|
|
5
|
+
default-slot content in a native <code> for semantics + copy/paste,
|
|
6
|
+
and renders it using the JetBrains Mono typescale. With `block`,
|
|
7
|
+
the <code> is wrapped in a <pre> for a small recessed code panel.
|
|
8
|
+
|
|
9
|
+
Authoring:
|
|
10
|
+
Set <xm-code>data-theme="dark"</xm-code> on the root.
|
|
11
|
+
|
|
12
|
+
<xm-code block>
|
|
13
|
+
routing:
|
|
14
|
+
planner: sonnet-4.7
|
|
15
|
+
</xm-code>
|
|
16
|
+
|
|
17
|
+
Properties:
|
|
18
|
+
block boolean — render as a <pre><code> block panel
|
|
19
|
+
|
|
20
|
+
Presentational, non-interactive. Shadow DOM for <slot> projection;
|
|
21
|
+
Lit is a bare `import` (peer dep); CSS via <link> resolved relative to the built module.
|
|
22
|
+
*/
|
|
23
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
24
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
25
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
26
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
27
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
28
|
+
};
|
|
29
|
+
import { LitElement, html } from "lit";
|
|
30
|
+
import { customElement, property } from "lit/decorators.js";
|
|
31
|
+
const CODE_CSS = new URL("../code/index.css", import.meta.url).href;
|
|
32
|
+
let XmCode = class XmCode extends LitElement {
|
|
33
|
+
constructor() {
|
|
34
|
+
super(...arguments);
|
|
35
|
+
this.block = false;
|
|
36
|
+
}
|
|
37
|
+
render() {
|
|
38
|
+
const styleHost = html `
|
|
39
|
+
<style>
|
|
40
|
+
:host {
|
|
41
|
+
display: ${this.block ? "block" : "inline"};
|
|
42
|
+
vertical-align: baseline;
|
|
43
|
+
}
|
|
44
|
+
:host([hidden]) {
|
|
45
|
+
display: none;
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
48
|
+
`;
|
|
49
|
+
if (this.block) {
|
|
50
|
+
return html `
|
|
51
|
+
<link rel="stylesheet" href="${CODE_CSS}" />
|
|
52
|
+
${styleHost}
|
|
53
|
+
<pre class="code code--block"><code><slot></slot></code></pre>
|
|
54
|
+
`;
|
|
55
|
+
}
|
|
56
|
+
return html `
|
|
57
|
+
<link rel="stylesheet" href="${CODE_CSS}" />
|
|
58
|
+
${styleHost}
|
|
59
|
+
<code class="code"><slot></slot></code>
|
|
60
|
+
`;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
__decorate([
|
|
64
|
+
property({ type: Boolean })
|
|
65
|
+
], XmCode.prototype, "block", void 0);
|
|
66
|
+
XmCode = __decorate([
|
|
67
|
+
customElement("xm-code")
|
|
68
|
+
], XmCode);
|