rapidoc 11.0.1 → 12.1.0

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 (96) hide show
  1. package/README.md +171 -54
  2. package/dist/rapidoc-flow-min.js +580 -0
  3. package/dist/rapidoc-flow-min.js.LICENSE.txt +171 -0
  4. package/dist/rapidoc-min.js +645 -202
  5. package/dist/rapidoc-min.js.LICENSE.txt +381 -0
  6. package/package.json +57 -42
  7. package/src/README.md +150 -0
  8. package/src/components/README.md +91 -0
  9. package/src/components/api-request.ts +912 -0
  10. package/src/components/api-response.ts +514 -0
  11. package/src/components/json-tree.ts +171 -0
  12. package/src/components/schema-base-element.ts +329 -0
  13. package/src/components/schema-table.ts +475 -0
  14. package/src/components/schema-tree.ts +393 -0
  15. package/src/components/tag-input.ts +180 -0
  16. package/src/flow.js +3 -0
  17. package/src/index.js +6 -0
  18. package/src/oauth-receiver.ts +29 -0
  19. package/src/rapi-flow.ts +1178 -0
  20. package/src/rapidoc-mini.ts +603 -0
  21. package/src/rapidoc.ts +1854 -0
  22. package/src/styles/README.md +96 -0
  23. package/src/styles/auth-styles.js +318 -0
  24. package/src/styles/border-styles.js +24 -0
  25. package/src/styles/css-bundle.js +129 -0
  26. package/src/styles/custom-styles.js +8 -0
  27. package/src/styles/dialog-box-styles.js +102 -0
  28. package/src/styles/endpoint-styles.js +564 -0
  29. package/src/styles/flex-styles.js +16 -0
  30. package/src/styles/flow-styles.js +248 -0
  31. package/src/styles/font-styles.js +432 -0
  32. package/src/styles/info-styles.js +36 -0
  33. package/src/styles/input-styles.js +555 -0
  34. package/src/styles/layout-styles.js +396 -0
  35. package/src/styles/microlighter-styles.js +99 -0
  36. package/src/styles/nav-styles.js +633 -0
  37. package/src/styles/param-list-styles.js +261 -0
  38. package/src/styles/schema-styles.js +296 -0
  39. package/src/styles/tab-styles.js +106 -0
  40. package/src/styles/theme-tokens.js +582 -0
  41. package/src/templates/README.md +89 -0
  42. package/src/templates/advanced-search-dialog-template.js +94 -0
  43. package/src/templates/api-response-template.js +223 -0
  44. package/src/templates/callback-template.js +86 -0
  45. package/src/templates/code-samples-template.js +52 -0
  46. package/src/templates/components-template.js +86 -0
  47. package/src/templates/downloads-template.js +70 -0
  48. package/src/templates/endpoint-template.js +377 -0
  49. package/src/templates/expanded-endpoint-template.js +270 -0
  50. package/src/templates/focused-endpoint-template.js +146 -0
  51. package/src/templates/header-template.js +92 -0
  52. package/src/templates/logo-template.js +21 -0
  53. package/src/templates/main-body-template.js +102 -0
  54. package/src/templates/navbar-template.js +498 -0
  55. package/src/templates/overview-template.js +104 -0
  56. package/src/templates/request-body-template.js +673 -0
  57. package/src/templates/request-params-template.js +485 -0
  58. package/src/templates/security-scheme-template.js +1272 -0
  59. package/src/templates/server-template.js +153 -0
  60. package/src/utils/README.md +146 -0
  61. package/src/utils/arazzo/README.md +119 -0
  62. package/src/utils/arazzo/components.js +15 -0
  63. package/src/utils/arazzo/graph.js +269 -0
  64. package/src/utils/arazzo/index.js +52 -0
  65. package/src/utils/arazzo/operations.js +106 -0
  66. package/src/utils/arazzo/parse.js +196 -0
  67. package/src/utils/arazzo/refs.js +40 -0
  68. package/src/utils/arazzo/svg.js +707 -0
  69. package/src/utils/auto-color-scheme.js +99 -0
  70. package/src/utils/bind-navbar.js +175 -0
  71. package/src/utils/color-utils.js +59 -0
  72. package/src/utils/common-utils.js +191 -0
  73. package/src/utils/curl-utils.js +126 -0
  74. package/src/utils/highlighter.js +419 -0
  75. package/src/utils/markdown-utils.js +110 -0
  76. package/src/utils/mcp/README.md +155 -0
  77. package/src/utils/mcp/common.js +166 -0
  78. package/src/utils/mcp/manifest.js +382 -0
  79. package/src/utils/mcp/project/server.ts +53 -0
  80. package/src/utils/mcp/project.js +88 -0
  81. package/src/utils/mcp/runtime.js +289 -0
  82. package/src/utils/mcp/schema.js +98 -0
  83. package/src/utils/mcp/workflow-runtime.js +374 -0
  84. package/src/utils/mcp/workflows.js +240 -0
  85. package/src/utils/mcp/zip.js +102 -0
  86. package/src/utils/mcp-generator.js +47 -0
  87. package/src/utils/mock-interceptor.js +557 -0
  88. package/src/utils/oauth-utils.js +87 -0
  89. package/src/utils/request-utils.js +264 -0
  90. package/src/utils/response-utils.js +203 -0
  91. package/src/utils/sanitize.js +57 -0
  92. package/src/utils/schema-utils.js +1954 -0
  93. package/src/utils/slugger.js +187 -0
  94. package/src/utils/spec-parser.js +941 -0
  95. package/src/utils/url-utils.js +246 -0
  96. package/src/utils/xml-utils.js +61 -0
@@ -0,0 +1,96 @@
1
+ # `src/styles` — RapiDoc Stylesheets and Theme Tokens
2
+
3
+ ## Overview
4
+
5
+ The CSS of `<rapi-doc>` and `<rapi-doc-mini>`, written as Lit `css` templates (one default export
6
+ per stylesheet file), plus the theming helpers that turn the `theme` attribute into CSS custom
7
+ properties, and string transforms that reuse the same CSS outside a shadow root.
8
+
9
+ - `theme-tokens.js` defines the custom properties (shadcn/ui names such as `--background`,
10
+ `--primary`, `--radius`; `--sidebar-*` for navigation; `--h1-font-size`… and `--heading-*`) and
11
+ switches them on host attributes (`theme`, `color-scheme`, `radius`, `scale`,
12
+ `nav-item-spacing`). The other stylesheets read those tokens and style component class names.
13
+ - `css-bundle.js` composes every stylesheet into `allStyles` and rewrites `:host` selectors for
14
+ Light DOM use.
15
+
16
+ Not owned here: which attributes exist (`src/rapidoc.ts`), the documented token list
17
+ (`docs/src/page-data/styling-data.yaml`), and the portal's own layout CSS.
18
+
19
+ Dependents: `src/rapidoc.ts`, `src/rapidoc-mini.ts` and the shadow-root components in
20
+ `src/components/` list the stylesheets they need in `static get styles()`; `packages/rapidoc-prerender/src/index.js`
21
+ re-exports `getBundledCss`, `getNavCss` and `getThemeTokensCss` as `@rapidoc/prerender`, and
22
+ `packages/rapidoc-prerender/src/render.js` uses `getBundledCss` for Declarative Shadow DOM output; `@rapidoc/portal`
23
+ (`src/pages/api-reference.astro`) uses `getNavCss` and `getThemeTokensCss`.
24
+
25
+ ## Interface
26
+
27
+ `theme-tokens.js`:
28
+
29
+ - `DEFAULT_THEME` (`"ember"`), `THEMES` (preset name to `{ dark, light }` declaration strings),
30
+ `THEME_PRESETS` (its keys).
31
+ - `isValidHexColor`, `isValidTheme`, `isCustomColor`, `isLightColor`: theme value checks.
32
+ - `normalizeTheme(theme) -> { theme }`: presets lower-cased, hex kept, anything else becomes
33
+ `DEFAULT_THEME`.
34
+ - `applyCustomTheme(element, themeVal)`: sets inline `--primary` and `--primary-foreground` on
35
+ the host for a valid hex string, and removes them for anything else (presets, non-strings).
36
+ - default export: the token stylesheet (defaults, geometry switches, color schemes, presets).
37
+
38
+ `css-bundle.js`:
39
+
40
+ - `allStyles`: every stylesheet in cascade order, `ThemeTokens` first, `CustomStyles` last.
41
+ - `getBundledCss({ scope })` (also the default export): `allStyles` as one string; with a scope
42
+ other than `:host`, rewrites `:host(X)` to `<scope>X`, `:host` to `<scope>` and `::slotted(X)` to
43
+ `X`. Only `scope` is read, although the JSDoc also lists `theme` and `colorScheme`.
44
+ - `getNavCss(scope)`: `nav-styles.js` with the same rewrites, wrapped in a `<scope> { ... }` block
45
+ that also sets a compact `--sidebar-item-padding`, for the portal sidebar.
46
+ - `getThemeTokensCss(theme, scope = ":root")`: the token stylesheet with `theme` / `color-scheme`
47
+ host rules rewritten to `[data-theme='dark'|'light'|'system']` selectors (other presets keyed by
48
+ `[data-theme-preset='<name>']`).
49
+
50
+ Every other file default-exports one stylesheet named after what it styles (`nav-styles.js`,
51
+ `endpoint-styles.js`, `schema-styles.js`, ...); `custom-styles.js` is an empty slot kept last.
52
+ `flow-styles.js` styles the Arazzo diagram for `<rapi-flow>` and `@rapidoc/prerender` `getFlowCss()`; it
53
+ uses plain class selectors (no `:host`) and is not part of `allStyles`.
54
+
55
+ The custom properties themselves are not listed here: `theme-tokens.js` is the source of truth and
56
+ `docs/src/page-data/styling-data.yaml` is the documented list (`packages/rapidoc/AGENTS.md` §5,
57
+ rule 6).
58
+
59
+ ## Invariants
60
+
61
+ - Every custom property RapiDoc reads is defined somewhere in `src`; public tokens are defined
62
+ with a default in `theme-tokens.js`. `tests/unit/css-variables.test.js` enforces this, forbids
63
+ the removed v11 names and requires the shadcn/ui core tokens.
64
+ - Tokens are read as plain `var(--x)`, without a fallback. The one exception is the local
65
+ `--method-color` in `endpoint-styles.js`, which `.m-endpoint` and the verb classes set and which
66
+ is read with a fallback to `--method-default` or `--primary`.
67
+ - Adding, renaming or removing a token also updates `docs/src/page-data/styling-data.yaml` and the
68
+ current migration guide.
69
+ - Dark is the default scheme: the dark block matches `:host`, `[color-scheme='dark']`,
70
+ `[color-scheme='system']` and no `color-scheme`; `system` turns light only under
71
+ `@media (prefers-color-scheme: light)`. `DEFAULT_THEME` also applies with no `theme` attribute.
72
+ - `--primary` and `--primary-foreground` have no `:host` default; they come from a preset rule or
73
+ from `applyCustomTheme`. `--ring` follows `--primary`.
74
+ - The `:host(...)` selector shapes written by `presetCss` and the color-scheme block are exactly
75
+ what `getThemeTokensCss` and `getNavCss` match with regular expressions; change both together.
76
+ `getThemeTokensCss` rewrites only `theme` / `color-scheme` rules, so the `radius`, `scale` and
77
+ `nav-item-spacing` rules come out as unusable `<scope>([...])` selectors.
78
+ - `ThemeTokens` is first in `allStyles` and in both components' `static get styles()`.
79
+ `CustomStyles` is last in `allStyles` and in `rapidoc.ts`; `rapidoc-mini.ts` does not load it
80
+ and ends with its own inline `css` block.
81
+ - Lit templates are not reformatted by oxfmt; keep the CSS text inside `css` templates as written.
82
+
83
+ ## Side Effects
84
+
85
+ - Each stylesheet file creates a Lit `CSSResult` at import; `theme-tokens.js` also builds the
86
+ preset CSS from `THEMES` once.
87
+ - `applyCustomTheme` mutates the element's inline style. Everything else is pure; nothing touches
88
+ the network or disk.
89
+
90
+ ## Verification
91
+
92
+ - `npm run test:unit` from the repo root. Suites: `tests/unit/css-variables.test.js` (defined
93
+ tokens, no undefined reads), `tests/unit/theme-validation.test.js` (`theme-tokens.js` helpers,
94
+ `nav-styles.js`), `tests/unit/static-renderer.test.js` (`getBundledCss`, `getNavCss`,
95
+ `getThemeTokensCss` output).
96
+ - After editing, `npm run lint`, `npm run format-fix` and `npm run build:rapidoc`.
@@ -0,0 +1,318 @@
1
+ import { css } from "lit";
2
+
3
+ /**
4
+ * Authentication: the security-scheme list in the Authentication section and the
5
+ * security chips on each operation. Loaded by <rapi-doc> and <rapi-doc-mini>.
6
+ */
7
+ export default css`
8
+ /* Authentication: one list item per security scheme; OAuth flows nest inside their scheme. */
9
+ .auth-status {
10
+ display: flex;
11
+ flex-wrap: wrap;
12
+ align-items: center;
13
+ justify-content: space-between;
14
+ gap: 0.5rem;
15
+ margin-bottom: 0.5rem;
16
+ }
17
+
18
+ .auth-list {
19
+ container-type: inline-size;
20
+ margin: 0;
21
+ padding: 0;
22
+ list-style: none;
23
+ border: 1px solid var(--border);
24
+ border-radius: min(var(--radius), 0.5rem);
25
+ /* Card surface, same as .param-list */
26
+ background: color-mix(in srgb, var(--card) 80%, transparent);
27
+ font-size: var(--font-size-small);
28
+ line-height: 1.5;
29
+ direction: ltr;
30
+ }
31
+
32
+ .auth-scheme {
33
+ padding: calc(var(--auth-scheme-padding) * 1.5);
34
+ margin: 0;
35
+ overflow-wrap: break-word;
36
+
37
+ & + .auth-scheme {
38
+ border-top: 1px solid var(--border);
39
+ }
40
+ }
41
+
42
+ /* Each block of a scheme (header, description, hint, controls, flows) is spaced by the same gap */
43
+ .auth-scheme-body,
44
+ .oauth-flow {
45
+ display: flex;
46
+ flex-direction: column;
47
+ align-items: flex-start;
48
+ gap: 0.75em;
49
+
50
+ & > * {
51
+ margin: 0;
52
+ max-width: 100%;
53
+ }
54
+ }
55
+
56
+ .auth-scheme-header {
57
+ display: flex;
58
+ flex-wrap: wrap;
59
+ align-items: center;
60
+ gap: 0.5em;
61
+ }
62
+
63
+ .auth-scheme-title {
64
+ font-size: var(--font-size-regular);
65
+ font-weight: 600;
66
+ }
67
+
68
+ /* Prose (description, "Send X in header") keeps a readable line length */
69
+ .auth-scheme-body > .m-markdown,
70
+ .auth-hint,
71
+ .auth-host-note {
72
+ max-width: 70ch;
73
+ }
74
+
75
+ /* "Use a different token" under a host note: a text link, not a full-size button */
76
+ .auth-host-toggle {
77
+ font-size: var(--font-size-small);
78
+ }
79
+
80
+ /*
81
+ * Inputs and their button on a grid of equal columns (12em-16em), so a field that wraps to the next
82
+ * line keeps the width of the one above it; the button sits at the start of its cell.
83
+ */
84
+ .auth-controls {
85
+ display: grid;
86
+ grid-template-columns: repeat(auto-fill, minmax(12em, 16em));
87
+ align-items: center;
88
+ gap: 0.5em;
89
+ width: 100%;
90
+
91
+ & > :is(input, select) {
92
+ width: 100%;
93
+ min-width: 0;
94
+ box-sizing: border-box;
95
+ }
96
+
97
+ & > .btn {
98
+ justify-self: start;
99
+ }
100
+ }
101
+
102
+ /* OAuth flows: one after another, each opened by its heading and parted from the previous one by a dashed rule */
103
+ .oauth-flow {
104
+ padding-block: 1.25em;
105
+
106
+ & + .oauth-flow {
107
+ border-top: 1px dashed var(--border);
108
+ }
109
+
110
+ &:last-child {
111
+ padding-bottom: 0;
112
+ }
113
+
114
+ & > .tiny-title {
115
+ margin: 0;
116
+ }
117
+ }
118
+
119
+ .oauth-urls {
120
+ display: grid;
121
+ grid-template-columns: max-content minmax(0, 1fr);
122
+ gap: 0.25em 1.5em;
123
+
124
+ & > dt {
125
+ color: var(--muted-foreground);
126
+ }
127
+
128
+ & > dd {
129
+ margin: 0;
130
+ overflow-wrap: anywhere;
131
+ }
132
+ }
133
+
134
+ .oauth-scopes-label {
135
+ color: var(--muted-foreground);
136
+ margin-bottom: -0.25em;
137
+ }
138
+
139
+ .oauth-scopes {
140
+ display: flex;
141
+ flex-direction: column;
142
+ gap: 0.5em;
143
+ }
144
+
145
+ /* Scope value in the foreground color, its description muted, with a dash between */
146
+ .oauth-scope-name {
147
+ color: var(--foreground);
148
+ }
149
+
150
+ .oauth-scope-descr {
151
+ color: var(--muted-foreground);
152
+
153
+ &::before {
154
+ content: '– ';
155
+ }
156
+ }
157
+
158
+ /* Toggle + its text; the text wraps beside the toggle, not under it. The toggle is 1.5em tall,
159
+ the same as one line of text here, so it lines up with the first line. */
160
+ .auth-toggle {
161
+ display: inline-flex;
162
+ align-items: flex-start;
163
+ gap: 0.625em;
164
+ cursor: pointer;
165
+ }
166
+
167
+ .oauth-resp-display:empty {
168
+ display: none;
169
+ }
170
+
171
+ /* Narrow containers: fields take the full row; URL labels stack above their values */
172
+ @container (max-width: 30rem) {
173
+ .auth-controls {
174
+ grid-template-columns: minmax(0, 1fr);
175
+ }
176
+
177
+ .oauth-urls {
178
+ grid-template-columns: minmax(0, 1fr);
179
+
180
+ & > dd + dt {
181
+ margin-top: 0.375em;
182
+ }
183
+ }
184
+ }
185
+
186
+ /*
187
+ * Operation security: a lock, then a row of chips right under the method and path, one per alternative,
188
+ * with "OR" between them. The lock marks the row as authorization (and links to the Authentication
189
+ * section when that is shown); a chip opens its details popover on hover or focus.
190
+ */
191
+ .operation-security {
192
+ display: flex;
193
+ align-items: flex-start;
194
+ gap: 0.375em;
195
+ margin: 0 0 12px;
196
+ min-width: 0;
197
+ max-width: 100%;
198
+ font-size: var(--font-size-small);
199
+ line-height: 1.25;
200
+ }
201
+ .security-chips {
202
+ align-items: center;
203
+ row-gap: 6px;
204
+
205
+ /* Keeps "OR" centered on the chip beside it */
206
+ & > li {
207
+ display: inline-flex;
208
+ align-items: center;
209
+ }
210
+ }
211
+ .value-list-items.security-chips > li:not(:last-child)::after {
212
+ content: 'OR';
213
+ margin-inline: 0.625em;
214
+ font-size: var(--font-size-xs);
215
+ letter-spacing: 0.04em;
216
+ }
217
+ .security-chip {
218
+ display: inline-flex;
219
+ align-items: center;
220
+ gap: 0.375em;
221
+ min-width: 0;
222
+ max-width: 100%;
223
+ padding: 0.25em 0.625em;
224
+ color: var(--foreground);
225
+ background: color-mix(in srgb, var(--card) 80%, transparent);
226
+ border: 1px solid var(--input);
227
+ /* Same radius as buttons, inputs and the popover it opens */
228
+ border-radius: var(--radius);
229
+ transition:
230
+ color 0.15s ease,
231
+ border-color 0.15s ease;
232
+
233
+ &.has-details {
234
+ cursor: pointer;
235
+ }
236
+ &.has-details:is(:hover, :focus-within) {
237
+ color: var(--primary);
238
+ border-color: var(--primary);
239
+ }
240
+ }
241
+ /* Same size as a chip (and .btn-sm), so it lines up with the first row of chips */
242
+ .security-lock-btn {
243
+ display: inline-flex;
244
+ flex: none;
245
+ align-items: center;
246
+ justify-content: center;
247
+ width: calc(1.75em + 2px);
248
+ height: calc(1.75em + 2px);
249
+ color: var(--muted-foreground);
250
+ border-radius: var(--radius);
251
+ }
252
+ a.security-lock-btn {
253
+ transition:
254
+ color 0.15s ease,
255
+ background-color 0.15s ease;
256
+
257
+ &:hover {
258
+ color: var(--foreground);
259
+ background: var(--muted);
260
+ }
261
+ &:focus-visible {
262
+ outline: none;
263
+ box-shadow: var(--focus-shadow);
264
+ }
265
+ }
266
+ .security-lock {
267
+ width: 1.25em;
268
+ height: 1.25em;
269
+ stroke: currentColor;
270
+ stroke-linecap: round;
271
+ stroke-linejoin: round;
272
+ }
273
+ .security-chip-label {
274
+ display: block;
275
+ max-width: 240px;
276
+ padding: 0;
277
+ overflow: hidden;
278
+ white-space: nowrap;
279
+ text-overflow: ellipsis;
280
+ color: inherit;
281
+ text-decoration: none;
282
+ font: inherit;
283
+ background: none;
284
+ border: none;
285
+ border-radius: 0;
286
+ cursor: inherit;
287
+
288
+ &:focus-visible {
289
+ outline: 2px solid var(--ring);
290
+ outline-offset: 2px;
291
+ }
292
+ }
293
+
294
+ /* Scheme details for a chip: a top-layer popover anchored below it (above when there is no room) */
295
+ /* Left edge on the chip's left edge, 6px below it; a page-colored surface with a thin border and a soft, tight shadow */
296
+ .security-popover {
297
+ inset: auto;
298
+ margin: 6px 0 6px 0;
299
+ position-area: bottom span-right;
300
+ position-try-fallbacks: flip-block;
301
+ width: max-content;
302
+ max-width: min(400px, calc(100vw - 16px));
303
+ padding: 0.75em 1em;
304
+ color: var(--foreground);
305
+ background: var(--background);
306
+ border: 1px solid var(--border);
307
+ border-radius: var(--radius);
308
+ box-shadow:
309
+ 0 1px 2px rgba(0, 0, 0, 0.06),
310
+ 0 4px 12px rgba(0, 0, 0, 0.08);
311
+ font-family: var(--font-sans);
312
+ font-size: var(--font-size-description);
313
+ line-height: 1.5;
314
+ text-align: start;
315
+ overflow-wrap: anywhere;
316
+ cursor: auto;
317
+ }
318
+ `;
@@ -0,0 +1,24 @@
1
+ import { css } from "lit";
2
+
3
+ export default css`
4
+ .border-top {
5
+ border-top: 1px solid var(--border);
6
+ }
7
+ .border {
8
+ border: 1px solid var(--border);
9
+ border-radius: min(var(--radius), 0.5rem);
10
+ }
11
+ .light-border {
12
+ border: 1px solid var(--border);
13
+ border-radius: min(var(--radius), 0.5rem);
14
+ }
15
+ .pad-8-16 {
16
+ padding: 8px 16px;
17
+ }
18
+ .pad-top-8 {
19
+ padding-top: 8px;
20
+ }
21
+ .mar-top-8 {
22
+ margin-top: 8px;
23
+ }
24
+ `;
@@ -0,0 +1,129 @@
1
+ import ThemeTokens, { DEFAULT_THEME } from "./theme-tokens.js";
2
+ import FontStyles from "./font-styles.js";
3
+ import InputStyles from "./input-styles.js";
4
+ import FlexStyles from "./flex-styles.js";
5
+ import AuthStyles from "./auth-styles.js";
6
+ import ParamListStyles from "./param-list-styles.js";
7
+ import EndpointStyles from "./endpoint-styles.js";
8
+ import MicrolighterStyles from "./microlighter-styles.js";
9
+ import TabStyles from "./tab-styles.js";
10
+ import NavStyles from "./nav-styles.js";
11
+ import InfoStyles from "./info-styles.js";
12
+ import DialogBoxStyles from "./dialog-box-styles.js";
13
+ import LayoutStyles from "./layout-styles.js";
14
+ import BorderStyles from "./border-styles.js";
15
+ import SchemaStyles from "./schema-styles.js";
16
+ import CustomStyles from "./custom-styles.js";
17
+
18
+ export const allStyles = [
19
+ ThemeTokens,
20
+ FontStyles,
21
+ InputStyles,
22
+ FlexStyles,
23
+ AuthStyles,
24
+ ParamListStyles,
25
+ BorderStyles,
26
+ EndpointStyles,
27
+ MicrolighterStyles,
28
+ TabStyles,
29
+ NavStyles,
30
+ InfoStyles,
31
+ DialogBoxStyles,
32
+ LayoutStyles,
33
+ SchemaStyles,
34
+ CustomStyles,
35
+ ];
36
+
37
+ /**
38
+ * Returns aggregated CSS text for Declarative Shadow DOM or Light DOM SSR/SSG pre-rendering.
39
+ *
40
+ * @param {Object} [options]
41
+ * @param {string} [options.theme='ember'] - Theme preset name or valid hex color code
42
+ * @param {'dark'|'light'|'system'} [options.colorScheme='dark'] - Color scheme
43
+ * @param {string} [options.scope=''] - Optional outer selector (for Light DOM / non-shadow pre-rendering)
44
+ * @returns {string} Fully concatenated CSS string
45
+ */
46
+ export function getBundledCss(options = {}) {
47
+ const { scope = "" } = options;
48
+
49
+ let combinedCss = allStyles.map((s) => (s && s.cssText ? s.cssText : String(s || ""))).join("\n");
50
+
51
+ // If rendering in Light DOM without Shadow DOM, adapt :host selectors to the container
52
+ if (scope && scope !== ":host") {
53
+ combinedCss = combinedCss
54
+ .replace(/:host\(((?:[^()]|\([^()]*\))+)\)/g, `${scope}$1`)
55
+ .replace(/:host\b/g, scope)
56
+ .replace(/::slotted\(([^)]+)\)/g, `$1`);
57
+ }
58
+
59
+ return combinedCss;
60
+ }
61
+
62
+ /**
63
+ * Returns RapiDoc's navigation CSS text for shared usage in @rapidoc/portal.
64
+ *
65
+ * @param {string} [scope=''] - Optional outer selector
66
+ * @returns {string} Navigation CSS string
67
+ */
68
+ export function getNavCss(scope = "") {
69
+ let navCss = NavStyles && NavStyles.cssText ? NavStyles.cssText : String(NavStyles || "");
70
+ if (scope && scope !== ":host") {
71
+ navCss = navCss
72
+ .replace(
73
+ /:host\(\[color-scheme='([^']+)'\]\)/g,
74
+ `[data-theme='$1'] ${scope}, ${scope}[color-scheme='$1']`,
75
+ )
76
+ .replace(/:host\(((?:[^()]|\([^()]*\))+)\)/g, `${scope}$1`)
77
+ .replace(/:host\b/g, scope)
78
+ .replace(/::slotted\(([^)]+)\)/g, `$1`)
79
+ .replace(/^\s*\.nav-bar\s*\{/gm, "&.nav-bar, & {");
80
+ navCss = `${scope} {\n --sidebar-item-padding: 0.3125rem 1rem 0.3125rem 0.625rem;\n${navCss}\n}\n[data-theme='light'] ${scope} .nav-method.as-colored-block {\n color: var(--method-badge-fg);\n}\n`;
81
+ }
82
+ return navCss;
83
+ }
84
+
85
+ /**
86
+ * Returns RapiDoc's design system & theme tokens CSS text for shared usage in @rapidoc/portal.
87
+ * Converts Web Component :host rules into Light DOM portal selectors (:root, [data-theme='dark'], [data-theme='light']).
88
+ *
89
+ * @param {string} [theme='ember'] - Theme preset name (see THEME_PRESETS) or hex color
90
+ * @param {string} [scope=':root'] - Scope selector
91
+ * @returns {string} Theme tokens CSS string
92
+ */
93
+ export function getThemeTokensCss(theme = DEFAULT_THEME, scope = ":root") {
94
+ let tokensCss =
95
+ ThemeTokens && ThemeTokens.cssText ? ThemeTokens.cssText : String(ThemeTokens || "");
96
+ const activeTheme =
97
+ typeof theme === "string"
98
+ ? theme.trim().toLowerCase()
99
+ : typeof theme === "object" && theme?.theme
100
+ ? String(theme.theme).trim().toLowerCase()
101
+ : DEFAULT_THEME;
102
+
103
+ tokensCss = tokensCss
104
+ .replace(/:host\(\[theme='([^']+)'\]\[color-scheme='light'\]\)/g, (match, t) =>
105
+ t === activeTheme ? "[data-theme='light']" : `[data-theme='light'][data-theme-preset='${t}']`,
106
+ )
107
+ .replace(/:host\(\[theme='([^']+)'\]\[color-scheme='system'\]\)/g, (match, t) =>
108
+ t === activeTheme
109
+ ? "[data-theme='system']"
110
+ : `[data-theme='system'][data-theme-preset='${t}']`,
111
+ )
112
+ .replace(/:host\(\[theme='([^']+)'\]\)/g, (match, t) =>
113
+ t === activeTheme
114
+ ? `${scope}, [data-theme='dark']`
115
+ : `[data-theme='dark'][data-theme-preset='${t}']`,
116
+ )
117
+ .replace(/:host\(:not\(\[theme\]\)\[color-scheme='light'\]\)/g, "[data-theme='light']")
118
+ .replace(/:host\(:not\(\[theme\]\)\[color-scheme='system'\]\)/g, "[data-theme='system']")
119
+ .replace(/:host\(:not\(\[theme\]\)\)/g, `${scope}, [data-theme='dark']`)
120
+ .replace(/:host\(\[color-scheme='light'\]\)/g, "[data-theme='light']")
121
+ .replace(/:host\(\[color-scheme='dark'\]\)/g, "[data-theme='dark']")
122
+ .replace(/:host\(\[color-scheme='system'\]\)/g, "[data-theme='system']")
123
+ .replace(/:host\(:not\(\[color-scheme\]\)\)/g, `${scope}, [data-theme='dark']`)
124
+ .replace(/:host\b/g, scope);
125
+
126
+ return tokensCss;
127
+ }
128
+
129
+ export default getBundledCss;
@@ -0,0 +1,8 @@
1
+ import { css } from "lit";
2
+
3
+ /*
4
+ This file is reserved for any custom css that developers want to add to
5
+ customize their theme. Simply add your css to this file and yarn build.
6
+ */
7
+
8
+ export default css``;
@@ -0,0 +1,102 @@
1
+ import { css } from "lit";
2
+
3
+ export default css`
4
+ *,
5
+ *:before,
6
+ *:after {
7
+ box-sizing: border-box;
8
+ }
9
+
10
+ .dialog-box {
11
+ position: absolute;
12
+ top: 100px;
13
+ background: var(--card);
14
+ padding: 0;
15
+ color: var(--card-foreground);
16
+ border-radius: min(var(--radius), 0.5rem);
17
+ max-height: 70vh;
18
+ height: 70vh;
19
+ max-width: 70vw;
20
+ width: 70vw;
21
+ border: 1px solid var(--border);
22
+ overflow: hidden;
23
+ box-shadow:
24
+ 0 14px 28px rgba(0, 0, 0, 0.25),
25
+ 0 10px 10px rgba(0, 0, 0, 0.22);
26
+ }
27
+
28
+ .dialog-box-header {
29
+ position: sticky;
30
+ top: 0;
31
+ align-self: stretch;
32
+ z-index: 10;
33
+ backdrop-filter: blur(12px);
34
+ display: flex;
35
+ align-items: center;
36
+ padding: 0px 16px;
37
+ min-height: 60px;
38
+ max-height: 60px;
39
+ border-bottom: 1px solid var(--border);
40
+ overflow: hidden;
41
+ border-top-left-radius: min(var(--radius), 0.5rem);
42
+ border-top-right-radius: min(var(--radius), 0.5rem);
43
+ & button {
44
+ font-size: 1.5rem;
45
+ font-weight: 700;
46
+ line-height: 1;
47
+ color: var(--foreground);
48
+ border: none;
49
+ outline: none;
50
+ background: transparent;
51
+ cursor: pointer;
52
+ border: 1px solid transparent;
53
+ border-radius: 50%;
54
+ margin-inline-end: -8px;
55
+
56
+ &:hover {
57
+ border-color: var(--primary);
58
+ }
59
+ }
60
+ }
61
+
62
+ .dialog-box-content {
63
+ padding: 1rem;
64
+ display: block;
65
+ overflow: auto;
66
+ height: 100%;
67
+ }
68
+
69
+ .dialog-box-title {
70
+ flex-grow: 1;
71
+ font-size: var(--h2-font-size);
72
+ }
73
+
74
+ .search-options-row {
75
+ display: flex;
76
+ gap: 16px;
77
+ flex-wrap: wrap;
78
+ margin: 8px 0 24px;
79
+ }
80
+
81
+ .search-option-label {
82
+ cursor: pointer;
83
+ display: inline-flex;
84
+ align-items: center;
85
+ gap: 0.5em;
86
+ user-select: none;
87
+ }
88
+
89
+ .search-option-label input {
90
+ cursor: pointer;
91
+ }
92
+
93
+ .search-match-row {
94
+ padding: 5px;
95
+ cursor: pointer;
96
+ border-bottom: 1px solid var(--border);
97
+ }
98
+
99
+ .search-match-row * {
100
+ pointer-events: none;
101
+ }
102
+ `;