@openelement/ui 1.0.0-alpha.14 → 1.0.0-alpha.16

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.
Files changed (43) hide show
  1. package/CUSTOMIZATION.md +106 -112
  2. package/README.md +19 -39
  3. package/custom-elements.json +369 -0
  4. package/package.json +3 -2
  5. package/src/button-machine.js +54 -0
  6. package/src/component-config.js +7 -0
  7. package/src/component-recipes.js +2 -24
  8. package/src/copy-feedback.js +32 -0
  9. package/src/dialog-machine.js +104 -0
  10. package/src/dropdown-machine.js +253 -0
  11. package/src/generated-manifest.json +135 -87
  12. package/src/index.d.ts +7 -8
  13. package/src/index.js +7 -8
  14. package/src/input-machine.js +33 -0
  15. package/src/open-button.css +119 -108
  16. package/src/open-button.d.ts +34 -342
  17. package/src/open-button.generated.js +592 -0
  18. package/src/open-button.js +115 -1140
  19. package/src/open-code-block.css +24 -44
  20. package/src/open-code-block.d.ts +15 -175
  21. package/src/open-code-block.generated.js +293 -0
  22. package/src/open-code-block.js +112 -224
  23. package/src/open-dialog.css +114 -127
  24. package/src/open-dialog.d.ts +22 -261
  25. package/src/open-dialog.generated.js +501 -0
  26. package/src/open-dialog.js +137 -632
  27. package/src/open-dropdown.css +26 -26
  28. package/src/open-dropdown.d.ts +15 -218
  29. package/src/open-dropdown.generated.js +211 -0
  30. package/src/open-dropdown.js +74 -355
  31. package/src/open-input.css +69 -74
  32. package/src/open-input.d.ts +34 -461
  33. package/src/open-input.generated.js +685 -0
  34. package/src/open-input.js +161 -1802
  35. package/src/open-theme-toggle.css +37 -47
  36. package/src/open-theme-toggle.d.ts +19 -190
  37. package/src/open-theme-toggle.generated.js +564 -0
  38. package/src/open-theme-toggle.js +209 -509
  39. package/src/theme-contract.js +40 -0
  40. package/src/theme.css +26 -8
  41. package/src/control-recipe.css +0 -21
  42. package/src/register.d.ts +0 -4
  43. package/src/register.js +0 -22
@@ -1,46 +1,26 @@
1
- /* open-code-block — authored component styles, ported verbatim from the pre-#1558
2
- * recipe() sheet (the alpha.9 design system). The #1558 migration had
3
- * replaced this with a placeholder shell under the false note that the
4
- * component "carried no authored styles"; it did — this is that sheet. */
5
- :host {
6
- display: block;
7
- position: relative;
8
- }
1
+ /* open-code-block — the irreducible authored rules (alpha15 S lane).
2
+ *
3
+ * The chip's presentation is authored as Tailwind utilities on the button in
4
+ * open-code-block.tsx: the compiler admits every static class token and the
5
+ * build compiles the component stylesheet (theme + utilities) into the shadow
6
+ * root. What stays here, and why (CUSTOMIZATION.md -> "Why the residue is CSS"):
7
+ * the host box, and the `:state()`-scoped copy feedback — the state lives on the
8
+ * HOST, so the `:host(:state(...))` selector is what ties the rule to it (its
9
+ * utility spelling, `[:host(:state(copied))_&]:text-success`, compiles, and the
10
+ * owned rule reads better). Both feedback rules read role table colors, so they
11
+ * follow a consumer's retheme and re-seat in forced-colors. */
12
+ :host {
13
+ display: block;
14
+ position: relative;
15
+ }
9
16
 
10
- .copy-btn {
11
- position: absolute;
12
- top: calc(var(--spacing) * 2);
13
- right: calc(var(--spacing) * 2);
14
- background: color-mix(in srgb, var(--color-primary) 14%, transparent);
15
- color: var(--color-foreground);
16
- padding: calc(var(--spacing) * 1) calc(var(--spacing) * 3);
17
- font-size: var(--text-xs);
18
- font-family: var(--font-sans);
19
- font-weight: var(--font-weight-semibold);
20
- border: 0.5px solid transparent;
21
- cursor: pointer;
22
- border-radius: var(--radius-md);
23
- transition: all var(--ease-in-out) var(--default-transition-duration);
24
- z-index: 1;
25
- letter-spacing: var(--tracking-wider);
26
- }
17
+ :host(:state(copied)) .copy-btn {
18
+ color: var(--color-success);
19
+ border-color: color-mix(in srgb, var(--color-success) 30%, transparent);
20
+ background: color-mix(in srgb, var(--color-success) 8%, transparent);
21
+ }
27
22
 
28
- /* No ink override on hover: the primary-foreground ink belongs to a brand
29
- *fill*, and this chip's hover surface is a translucent brand tint
30
- instead, so the chip keeps the code surface's ink. */
31
- .copy-btn:hover {
32
- background: color-mix(in srgb, var(--color-primary) 23%, transparent);
33
- border-color: var(--color-primary);
34
- }
35
-
36
- :host(:state(copied)) .copy-btn {
37
- color: #22c55e;
38
- border-color: rgba(34,197,94,0.3);
39
- background: rgba(34,197,94,0.08);
40
- }
41
-
42
- :host(:state(failed)) .copy-btn {
43
- color: var(--color-destructive);
44
- border-color: var(--color-destructive);
45
- }
46
-
23
+ :host(:state(failed)) .copy-btn {
24
+ color: var(--color-destructive);
25
+ border-color: var(--color-destructive);
26
+ }
@@ -1,182 +1,22 @@
1
- import { OpenElement, StyleSheetLike } from "@openelement/element";
2
1
  //#region src/open-code-block.d.ts
3
- declare const __partProgram: {
4
- version: number;
5
- tag: string;
6
- root: {
7
- id: string;
8
- kind: string;
9
- nodes: string[];
10
- };
11
- template: {
12
- k: string;
13
- id: string;
14
- tag: string;
15
- attrs: string[][];
16
- children: {
17
- k: string;
18
- id: string;
19
- tag: string;
20
- attrs: string[][];
21
- children: {
22
- k: string;
23
- id: string;
24
- index: number;
25
- }[];
26
- }[];
27
- }[];
28
- parts: ({
29
- k: string;
30
- event: string;
31
- handler: string;
32
- action: {
33
- kind: string;
34
- name: string;
35
- };
36
- path: number[];
37
- index: number;
38
- location: {
39
- id: string;
40
- kind: string;
41
- path: number[];
42
- node: string;
43
- };
44
- signal?: undefined;
45
- } | {
46
- k: string;
47
- signal: string;
48
- index: number;
49
- location: {
50
- id: string;
51
- kind: string;
52
- path: number[];
53
- node?: undefined;
54
- };
55
- event?: undefined;
56
- handler?: undefined;
57
- action?: undefined;
58
- path?: undefined;
59
- })[];
60
- regions: never[];
61
- dependencies: {
62
- signal: string;
63
- owner: {
64
- kind: string;
65
- index: number;
66
- };
67
- location: string;
68
- }[];
69
- locations: ({
70
- id: string;
71
- kind: string;
72
- tag: string;
73
- path: number[];
74
- part?: undefined;
75
- node?: undefined;
76
- } | {
77
- id: string;
78
- kind: string;
79
- part: number;
80
- node: string;
81
- path: number[];
82
- tag?: undefined;
83
- } | {
84
- id: string;
85
- kind: string;
86
- part: number;
87
- path: number[];
88
- tag?: undefined;
89
- node?: undefined;
90
- })[];
91
- metadata: {
92
- tag: string;
93
- className: string;
94
- sourceFile: string;
95
- properties: {
96
- name: string;
97
- attribute: null;
98
- type: string;
99
- converter: string;
100
- reflect: boolean;
101
- default: string;
102
- }[];
103
- observedAttributes: never[];
104
- cem: {
105
- tagName: string;
106
- className: string;
107
- declaration: {
108
- name: string;
109
- module: string;
110
- };
111
- attributes: never[];
112
- members: {
113
- name: string;
114
- fieldName: string;
115
- type: string;
116
- attribute: null;
117
- reflect: boolean;
118
- }[];
119
- };
120
- };
121
- };
122
- declare const __compiledProperties: {
123
- name: string;
124
- attribute: null;
125
- type: string;
126
- converter: string;
127
- reflect: boolean;
128
- default: string;
129
- }[];
130
- declare const __elementMetadata: {
131
- tag: string;
132
- className: string;
133
- sourceFile: string;
2
+ /**
3
+ * Platform facts for the generated element: shadow root, the authored
4
+ * component stylesheet, and the `copyLabel` property (property-only, no
5
+ * attribute form).
6
+ */
7
+ export declare const openElement: {
8
+ root: "shadow";
9
+ styles: string[];
134
10
  properties: {
135
- name: string;
136
- attribute: null;
137
- type: string;
138
- converter: string;
139
- reflect: boolean;
140
- default: string;
141
- }[];
142
- observedAttributes: never[];
143
- cem: {
144
- tagName: string;
145
- className: string;
146
- declaration: {
147
- name: string;
148
- module: string;
11
+ copyLabel: {
12
+ default: string;
13
+ attribute: false;
149
14
  };
150
- attributes: never[];
151
- members: {
152
- name: string;
153
- fieldName: string;
154
- type: string;
155
- attribute: null;
156
- reflect: boolean;
157
- }[];
158
- };
159
- };
160
- declare const __observedAttributes: string[];
161
- declare const __compiledProps: {
162
- copyLabel: {
163
- type: StringConstructor;
164
- default: string;
165
- reflect: boolean;
166
- attribute: boolean;
167
15
  };
168
16
  };
169
- export declare class OpenCodeBlock extends OpenElement {
170
- static __partProgram: typeof __partProgram;
171
- static __compiledProperties: typeof __compiledProperties;
172
- static __elementMetadata: typeof __elementMetadata;
173
- static props: typeof __compiledProps;
174
- static observedAttributes: typeof __observedAttributes;
175
- static styles: StyleSheetLike[];
17
+ /** Code block with a copy button. */
18
+ declare function OpenCodeBlock(props: {
176
19
  copyLabel: string;
177
- private getCodeText;
178
- private copy;
179
- render(): never;
180
- }
20
+ }): any;
181
21
  //#endregion
182
- export { __elementMetadata, __partProgram };
22
+ export { OpenCodeBlock as default };
@@ -0,0 +1,293 @@
1
+ import { assertElementInHtmlNamespace, assertStaticAttributeSeed, assertTextSlotMarker, bindSignalWrites, computed, createRecipe, displayValue, emitComment, escapeAttrValue, escapeText, leafClaimMismatch, leafRuntimeError, markerText, signal, textSlotMarker } from "@openelement/element/internal/compiled/leaf-runtime";
2
+ import { log } from "./component-recipes.js";
3
+ import { cancelCopyReset } from "./copy-feedback.js";
4
+ import { scheduleCopyReset } from "./copy-feedback.js";
5
+ function __oe_rootInstance(__oe_owner, __oe_host) {
6
+ const props = __oe_host.props;
7
+ const chinese = signal((false));
8
+ const translatedLabel = computed(() => !chinese.value
9
+ ? props.copyLabel
10
+ : props.copyLabel === 'Copy'
11
+ ? '复制'
12
+ : props.copyLabel === 'Copied!'
13
+ ? '已复制'
14
+ : props.copyLabel === 'Failed'
15
+ ? '复制失败'
16
+ : props.copyLabel);
17
+ const copy = ((host) => {
18
+ const text = host.textContent || '';
19
+ try {
20
+ globalThis.navigator.clipboard.writeText(text).then(() => {
21
+ (host).copyLabel = 'Copied!';
22
+ }, (error) => {
23
+ log.warn('Clipboard write failed:', error);
24
+ (host).copyLabel = 'Failed';
25
+ });
26
+ }
27
+ catch (error) {
28
+ log.warn('Clipboard write failed:', error);
29
+ (host).copyLabel = 'Failed';
30
+ }
31
+ });
32
+ const __oe_connectEnv = [];
33
+ __oe_connectEnv.push(((env) => {
34
+ globalThis.queueMicrotask(() => {
35
+ if (env.signal.aborted)
36
+ return;
37
+ const language = env.host.closest('[lang]')?.getAttribute('lang') ??
38
+ env.host.ownerDocument.documentElement.lang;
39
+ chinese.value = /^zh(?:-|$)/i.test(language);
40
+ });
41
+ }));
42
+ const __oe_teardownSignal = __oe_owner.signal;
43
+ __oe_owner.add(() => ((env) => {
44
+ cancelCopyReset(env.host);
45
+ })({ host: __oe_host.__oe_hostElement, signal: __oe_teardownSignal, states: __oe_host.__oe_states }));
46
+ if (__oe_host.__oe_onPropertyChange !== undefined)
47
+ __oe_host.__oe_onPropertyChange(((env) => {
48
+ if (env.name !== 'copyLabel')
49
+ return;
50
+ if (env.value === 'Copied!') {
51
+ env.states.add('copied');
52
+ env.states.delete('failed');
53
+ scheduleCopyReset(env.host);
54
+ return;
55
+ }
56
+ if (env.value === 'Failed') {
57
+ env.states.add('failed');
58
+ env.states.delete('copied');
59
+ scheduleCopyReset(env.host);
60
+ return;
61
+ }
62
+ env.states.delete('copied');
63
+ env.states.delete('failed');
64
+ cancelCopyReset(env.host);
65
+ }));
66
+ return { chinese, translatedLabel, copy, __oe_connectEnv };
67
+ }
68
+ function OpenCodeBlock__mount(__oe_scope, __oe_props, __oe_host) {
69
+ const props = __oe_props;
70
+ const __oe_requireBinding = (name) => { const value = __oe_host.bindings[name]; if (value === undefined)
71
+ throw new Error("OEIR_LEAF_MISSING_VALUE: " + name); return value; };
72
+ const chinese = __oe_requireBinding("chinese");
73
+ const translatedLabel = __oe_requireBinding("translatedLabel");
74
+ const __oe_lifecycleEnvHooks = __oe_host.bindings.__oe_connectEnv;
75
+ if (__oe_lifecycleEnvHooks !== undefined) {
76
+ for (const __oe_lifecycleEnvHook of __oe_lifecycleEnvHooks) {
77
+ const __oe_lifecycleEnvCleanup = __oe_lifecycleEnvHook({ host: __oe_host.__oe_hostElement, signal: __oe_scope.signal, states: __oe_host.__oe_states });
78
+ if (typeof __oe_lifecycleEnvCleanup === "function")
79
+ __oe_scope.add(__oe_lifecycleEnvCleanup);
80
+ }
81
+ }
82
+ const __oe_nodes = [];
83
+ const __oe_setup = __oe_host.bindings ?? {};
84
+ const __oe_requireRootSetup = (name) => { if (!Object.hasOwn(__oe_setup, name))
85
+ throw new Error("OEIR_LEAF_MISSING_VALUE: " + name); return __oe_setup[name]; };
86
+ const copy = __oe_requireRootSetup("copy");
87
+ const __oe_el0 = document.createElement("div");
88
+ __oe_el0.setAttribute("style", "display:contents");
89
+ const __oe_el1 = document.createElement("slot");
90
+ __oe_el0.appendChild(__oe_el1);
91
+ const __oe_el2 = document.createElement("button");
92
+ __oe_el2.setAttribute("type", "button");
93
+ __oe_el2.setAttribute("class", "copy-btn absolute top-2 right-2 z-10 cursor-pointer rounded-md border-[0.5px] border-transparent bg-primary/14 px-3 py-1 font-sans text-xs font-semibold tracking-wider text-foreground transition-all duration-150 ease-in-out hover:border-primary hover:bg-primary/23");
94
+ __oe_el2.setAttribute("part", "copy");
95
+ const __oe_eventHandler3 = ((event) => {
96
+ const target = event.currentTarget;
97
+ copy((target.getRootNode()).host);
98
+ });
99
+ if (typeof __oe_eventHandler3 !== "function")
100
+ throw leafRuntimeError("OEIR_LEAF_EVENT_HANDLER_INVALID", "onClick handler is not callable", { file: "src/open-code-block.tsx", line: 128, column: 9 });
101
+ const __oe_eventListener4 = (event) => __oe_eventHandler3(event);
102
+ __oe_el2.addEventListener("click", __oe_eventListener4);
103
+ __oe_scope.add(() => __oe_el2.removeEventListener("click", __oe_eventListener4));
104
+ const __oe_textStart5 = emitComment(textSlotMarker(0));
105
+ const __oe_text7 = document.createTextNode("");
106
+ const __oe_textEnd6 = emitComment(textSlotMarker(0, true));
107
+ function __oe_refresh8() {
108
+ __oe_text7.nodeValue = displayValue((translatedLabel.value));
109
+ }
110
+ __oe_refresh8();
111
+ bindSignalWrites(__oe_scope, translatedLabel, "translatedLabel", __oe_refresh8);
112
+ __oe_el2.appendChild(__oe_textStart5);
113
+ __oe_el2.appendChild(__oe_text7);
114
+ __oe_el2.appendChild(__oe_textEnd6);
115
+ __oe_el0.appendChild(__oe_el2);
116
+ __oe_nodes.push(__oe_el0);
117
+ return __oe_nodes;
118
+ }
119
+ export function createOpenCodeBlockRecipe(__oe_owner, __oe_host) {
120
+ const __oe_mountHost = { bindings: __oe_host.bindings, propDeps: [], __oe_hostElement: __oe_host.__oe_hostElement, __oe_states: __oe_host.__oe_states, __oe_onPropertyChange: __oe_host.__oe_onPropertyChange };
121
+ return createRecipe({
122
+ definitionOwner: __oe_owner,
123
+ source: "src/open-code-block.tsx#OpenCodeBlock",
124
+ mount(__oe_scope) {
125
+ return OpenCodeBlock__mount(__oe_scope, __oe_host.props, __oe_mountHost);
126
+ },
127
+ claim(__oe_scope, __oe_props, __oe_parent) {
128
+ return OpenCodeBlock__claim(__oe_scope, __oe_host.props, __oe_mountHost, __oe_parent);
129
+ },
130
+ });
131
+ }
132
+ function OpenCodeBlock__claim(__oe_scope, __oe_props, __oe_host, __oe_parent) {
133
+ const props = __oe_props;
134
+ const __oe_requireBinding = (name) => { const value = __oe_host.bindings[name]; if (value === undefined)
135
+ throw new Error("OEIR_LEAF_MISSING_VALUE: " + name); return value; };
136
+ const chinese = __oe_requireBinding("chinese");
137
+ const translatedLabel = __oe_requireBinding("translatedLabel");
138
+ const __oe_lifecycleEnvHooks = __oe_host.bindings.__oe_connectEnv;
139
+ if (__oe_lifecycleEnvHooks !== undefined) {
140
+ for (const __oe_lifecycleEnvHook of __oe_lifecycleEnvHooks) {
141
+ const __oe_lifecycleEnvCleanup = __oe_lifecycleEnvHook({ host: __oe_host.__oe_hostElement, signal: __oe_scope.signal, states: __oe_host.__oe_states });
142
+ if (typeof __oe_lifecycleEnvCleanup === "function")
143
+ __oe_scope.add(__oe_lifecycleEnvCleanup);
144
+ }
145
+ }
146
+ const __oe_setup = __oe_host.bindings ?? {};
147
+ const __oe_requireRootSetup = (name) => { if (!Object.hasOwn(__oe_setup, name))
148
+ throw new Error("OEIR_LEAF_MISSING_VALUE: " + name); return __oe_setup[name]; };
149
+ const copy = __oe_requireRootSetup("copy");
150
+ const __oe_adopted0 = [];
151
+ assertElementInHtmlNamespace(__oe_parent, "/", { file: "src/open-code-block.tsx", line: 48, column: 1 });
152
+ let __oe_claimStart2 = __oe_parent.firstChild;
153
+ while (__oe_claimStart2 !== null && __oe_claimStart2.nodeType === 1 && __oe_claimStart2.nodeName === "LINK" && __oe_claimStart2.hasAttribute("data-oe-static-styles"))
154
+ __oe_claimStart2 = __oe_claimStart2.nextSibling;
155
+ const __oe_cursor1 = { node: __oe_claimStart2 };
156
+ const __oe_el3 = __oe_cursor1.node;
157
+ if (__oe_el3 == null)
158
+ throw leafClaimMismatch("missing node at /0", { file: "src/open-code-block.tsx", line: 122, column: 5 });
159
+ __oe_cursor1.node = __oe_el3.nextSibling;
160
+ if (__oe_el3.nodeType !== 1 || String(__oe_el3.localName || __oe_el3.tagName || "").toLowerCase() !== "div")
161
+ throw leafClaimMismatch("expected element 'div' at /0", { file: "src/open-code-block.tsx", line: 122, column: 5 });
162
+ assertElementInHtmlNamespace(__oe_el3, "/0", { file: "src/open-code-block.tsx", line: 122, column: 5 });
163
+ assertStaticAttributeSeed(__oe_el3, [{ name: "style", value: "display:contents" }], "/0", [], { file: "src/open-code-block.tsx", line: 122, column: 5 });
164
+ const __oe_cursor4 = { node: __oe_el3.firstChild };
165
+ const __oe_el5 = __oe_cursor4.node;
166
+ if (__oe_el5 == null)
167
+ throw leafClaimMismatch("missing node at /0/0", { file: "src/open-code-block.tsx", line: 123, column: 7 });
168
+ __oe_cursor4.node = __oe_el5.nextSibling;
169
+ if (__oe_el5.nodeType !== 1 || String(__oe_el5.localName || __oe_el5.tagName || "").toLowerCase() !== "slot")
170
+ throw leafClaimMismatch("expected element 'slot' at /0/0", { file: "src/open-code-block.tsx", line: 123, column: 7 });
171
+ assertElementInHtmlNamespace(__oe_el5, "/0/0", { file: "src/open-code-block.tsx", line: 123, column: 7 });
172
+ assertStaticAttributeSeed(__oe_el5, [], "/0/0", [], { file: "src/open-code-block.tsx", line: 123, column: 7 });
173
+ const __oe_cursor6 = { node: __oe_el5.firstChild };
174
+ if (__oe_cursor6.node !== null)
175
+ throw leafClaimMismatch("extra node at /0/0", { file: "src/open-code-block.tsx", line: 123, column: 7 });
176
+ const __oe_el7 = __oe_cursor4.node;
177
+ if (__oe_el7 == null)
178
+ throw leafClaimMismatch("missing node at /0/1", { file: "src/open-code-block.tsx", line: 124, column: 7 });
179
+ __oe_cursor4.node = __oe_el7.nextSibling;
180
+ if (__oe_el7.nodeType !== 1 || String(__oe_el7.localName || __oe_el7.tagName || "").toLowerCase() !== "button")
181
+ throw leafClaimMismatch("expected element 'button' at /0/1", { file: "src/open-code-block.tsx", line: 124, column: 7 });
182
+ assertElementInHtmlNamespace(__oe_el7, "/0/1", { file: "src/open-code-block.tsx", line: 124, column: 7 });
183
+ assertStaticAttributeSeed(__oe_el7, [{ name: "type", value: "button" }, { name: "class", value: "copy-btn absolute top-2 right-2 z-10 cursor-pointer rounded-md border-[0.5px] border-transparent bg-primary/14 px-3 py-1 font-sans text-xs font-semibold tracking-wider text-foreground transition-all duration-150 ease-in-out hover:border-primary hover:bg-primary/23" }, { name: "part", value: "copy" }], "/0/1", [], { file: "src/open-code-block.tsx", line: 124, column: 7 });
184
+ const __oe_cursor8 = { node: __oe_el7.firstChild };
185
+ const __oe_textStart9 = __oe_cursor8.node;
186
+ if (__oe_textStart9 == null)
187
+ throw leafClaimMismatch("missing node at /0/1/0/text-start", { file: "src/open-code-block.tsx", line: 133, column: 10 });
188
+ __oe_cursor8.node = __oe_textStart9.nextSibling;
189
+ assertTextSlotMarker(__oe_textStart9, 0, false, "/0/1/0/text-start", { file: "src/open-code-block.tsx", line: 133, column: 10 });
190
+ let __oe_slotText10 = null;
191
+ const __oe_maybeText11 = __oe_cursor8.node;
192
+ if (__oe_maybeText11 !== null && __oe_maybeText11.nodeType === 3) {
193
+ __oe_slotText10 = __oe_maybeText11;
194
+ __oe_cursor8.node = __oe_maybeText11.nextSibling;
195
+ }
196
+ const __oe_textEnd12 = __oe_cursor8.node;
197
+ if (__oe_textEnd12 == null)
198
+ throw leafClaimMismatch("missing node at /0/1/0/text-end", { file: "src/open-code-block.tsx", line: 133, column: 10 });
199
+ __oe_cursor8.node = __oe_textEnd12.nextSibling;
200
+ assertTextSlotMarker(__oe_textEnd12, 0, true, "/0/1/0/text-end", { file: "src/open-code-block.tsx", line: 133, column: 10 });
201
+ if (__oe_cursor8.node !== null)
202
+ throw leafClaimMismatch("extra node at /0/1", { file: "src/open-code-block.tsx", line: 124, column: 7 });
203
+ if (__oe_cursor4.node !== null)
204
+ throw leafClaimMismatch("extra node at /0", { file: "src/open-code-block.tsx", line: 122, column: 5 });
205
+ __oe_adopted0.push(__oe_el3);
206
+ if (__oe_cursor1.node !== null)
207
+ throw leafClaimMismatch("extra node at /", { file: "src/open-code-block.tsx", line: 48, column: 1 });
208
+ const __oe_eventHandler13 = ((event) => {
209
+ const target = event.currentTarget;
210
+ copy((target.getRootNode()).host);
211
+ });
212
+ if (typeof __oe_eventHandler13 !== "function")
213
+ throw leafRuntimeError("OEIR_LEAF_EVENT_HANDLER_INVALID", "onClick handler is not callable", { file: "src/open-code-block.tsx", line: 128, column: 9 });
214
+ const __oe_eventListener14 = (event) => __oe_eventHandler13(event);
215
+ __oe_el7.addEventListener("click", __oe_eventListener14);
216
+ __oe_scope.add(() => __oe_el7.removeEventListener("click", __oe_eventListener14));
217
+ function __oe_refresh15() {
218
+ const __oe_value16 = displayValue((translatedLabel.value));
219
+ if (__oe_slotText10 === null) {
220
+ if (__oe_value16 !== "") {
221
+ const __oe_text17 = document.createTextNode(__oe_value16);
222
+ __oe_textEnd12.parentNode.insertBefore(__oe_text17, __oe_textEnd12);
223
+ __oe_scope.addRangeCleanup(() => __oe_text17.remove());
224
+ __oe_slotText10 = __oe_text17;
225
+ }
226
+ }
227
+ else if (__oe_slotText10.nodeValue !== __oe_value16) {
228
+ __oe_slotText10.nodeValue = __oe_value16;
229
+ }
230
+ }
231
+ __oe_refresh15();
232
+ bindSignalWrites(__oe_scope, translatedLabel, "translatedLabel", __oe_refresh15);
233
+ return __oe_adopted0;
234
+ }
235
+ export function OpenCodeBlock__ssr(__oe_props, __oe_host) {
236
+ const props = __oe_props;
237
+ const chinese = signal((false));
238
+ const translatedLabel = computed(() => !chinese.value
239
+ ? props.copyLabel
240
+ : props.copyLabel === 'Copy'
241
+ ? '复制'
242
+ : props.copyLabel === 'Copied!'
243
+ ? '已复制'
244
+ : props.copyLabel === 'Failed'
245
+ ? '复制失败'
246
+ : props.copyLabel);
247
+ const __oe_out0 = [];
248
+ __oe_out0.push("<div");
249
+ __oe_out0.push(" style=\"", escapeAttrValue("display:contents"), "\"");
250
+ __oe_out0.push(">");
251
+ __oe_out0.push("<slot");
252
+ __oe_out0.push(">");
253
+ __oe_out0.push("</slot>");
254
+ __oe_out0.push("<button");
255
+ __oe_out0.push(" type=\"", escapeAttrValue("button"), "\"");
256
+ __oe_out0.push(" class=\"", escapeAttrValue("copy-btn absolute top-2 right-2 z-10 cursor-pointer rounded-md border-[0.5px] border-transparent bg-primary/14 px-3 py-1 font-sans text-xs font-semibold tracking-wider text-foreground transition-all duration-150 ease-in-out hover:border-primary hover:bg-primary/23"), "\"");
257
+ __oe_out0.push(" part=\"", escapeAttrValue("copy"), "\"");
258
+ __oe_out0.push(">");
259
+ __oe_out0.push("<!--", markerText(textSlotMarker(0)), "-->");
260
+ __oe_out0.push(escapeText(displayValue((translatedLabel.value))));
261
+ __oe_out0.push("<!--", markerText(textSlotMarker(0, true)), "-->");
262
+ __oe_out0.push("</button>");
263
+ __oe_out0.push("</div>");
264
+ return __oe_out0.join("");
265
+ }
266
+ import { createGeneratedElementClassWithFeatures as __oe_createElementClass, generatedElementProperties as __oe_propertiesFeature, serializeGeneratedElementHtml, seedGeneratedElementHostProperties } from "@openelement/element/internal/compiled/generated-element/shell";
267
+ const __oeElementDescriptor = {
268
+ tag: "open-code-block",
269
+ root: "shadow-open",
270
+ properties: [
271
+ { name: "copyLabel", attribute: null, type: "string", reflect: false, default: "Copy" },
272
+ ],
273
+ createRecipe: createOpenCodeBlockRecipe,
274
+ createInstance: __oe_rootInstance,
275
+ };
276
+ const __oeOpenCodeBlockElement = __oe_createElementClass(__oeElementDescriptor, { properties: __oe_propertiesFeature });
277
+ export default __oeOpenCodeBlockElement;
278
+ export { __oeOpenCodeBlockElement as OpenCodeBlockElement };
279
+ export const __oeElementTag = "open-code-block";
280
+ export function OpenCodeBlock__ssrHost(props, lightChildren, attributes, styleLinks, nestedHost) {
281
+ if (!Array.isArray(styleLinks) || styleLinks.length === 0)
282
+ throw new Error("OEIR_LEAF_MISSING_VALUE: styleLinks (the styled generated element received no declared stylesheet URLs; mixed generated-element/entry artifacts or a missing style-link carrier)");
283
+ const __oeHostProps = seedGeneratedElementHostProperties(__oeElementDescriptor.properties, props, attributes);
284
+ const __oeHostAttrs = __oeHostProps.__oeHostAttributes;
285
+ return serializeGeneratedElementHtml({
286
+ tag: "open-code-block",
287
+ root: "open",
288
+ content: OpenCodeBlock__ssr(__oeHostProps, nestedHost === undefined ? undefined : { "__oe_nestedHost": nestedHost }),
289
+ ...(lightChildren === undefined ? {} : { lightChildren }),
290
+ ...(attributes === undefined && __oeHostAttrs === undefined ? {} : { attributes: __oeHostAttrs === undefined ? attributes : __oeHostAttrs }),
291
+ ...(styleLinks === undefined ? {} : { styleLinks }),
292
+ });
293
+ }