varvara-typedoc-theme 0.2.1 → 0.3.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.
@@ -1,33 +1,26 @@
1
- @media (prefers-color-scheme: light) {
2
- :root {
3
- --va-color-foreground: #29353d;
4
- --va-color-background: #f3f5f7;
5
- --va-border-color: LightGray;
6
- --va-color-primary: RoyalBlue;
7
- }
1
+ [data-theme='light'] {
2
+ color-scheme: light;
8
3
  }
9
4
 
10
- @media (prefers-color-scheme: dark) {
11
- :root {
12
- --va-color-foreground: #b3ccd6;
13
- --va-color-background: #2a303c;
14
- --va-border-color: LightSlateGray;
15
- --va-color-primary: LightSkyBlue;
16
- }
5
+ [data-theme='dark'] {
6
+ color-scheme: dark;
17
7
  }
18
8
 
19
- [data-theme='light'] {
20
- --va-color-foreground: #29353d;
21
- --va-color-background: #f3f5f7;
22
- --va-border-color: LightGray;
23
- --va-color-primary: RoyalBlue;
9
+ * {
10
+ box-sizing: border-box;
24
11
  }
25
12
 
26
- [data-theme='dark'] {
27
- --va-color-foreground: #b3ccd6;
28
- --va-color-background: #2a303c;
29
- --va-border-color: LightSlateGray;
30
- --va-color-primary: LightSkyBlue;
13
+ .va-collapse {
14
+ overflow: hidden;
15
+ }
16
+
17
+ .va-button {
18
+ display: flex;
19
+ align-items: center;
20
+ }
21
+
22
+ .title {
23
+ flex: 1;
31
24
  }
32
25
 
33
26
  body {
@@ -61,97 +54,30 @@ a {
61
54
  gap: 1rem;
62
55
  }
63
56
 
64
- .search {
65
- position: relative;
66
- display: flex;
67
- margin-bottom: 1rem;
68
- }
69
-
70
- #tsd-search.has-focus {
71
- background-color: transparent;
72
- }
73
-
74
- .search input,
75
- .search a:not([href='#']) {
76
- flex: 1;
77
- }
78
-
79
- .search a[href='#'] {
80
- display: none;
81
- }
82
-
83
- #tsd-search .field {
84
- position: static;
85
- width: 100%;
86
- }
87
-
88
- #tsd-search .field label {
89
- position: static;
90
- }
91
-
92
- #tsd-search .field input {
93
- top: auto;
94
- font-size: 1rem;
95
- opacity: 1; // Temporally
96
- }
97
-
98
- #tsd-search.has-focus .field input {
99
- display: flex;
57
+ #tsd-search-input {
58
+ border-radius: 0;
59
+ border-width: var(--va-input-border-width);
60
+ border-color: var(--va-input-border-color);
100
61
  }
101
62
 
102
- #tsd-search .results {
103
- top: 100%;
104
- z-index: 1;
63
+ dialog {
64
+ background-color: var(--va-color-background);
105
65
  }
106
66
 
107
- .navigation-links a {
108
- display: flex;
109
- }
110
67
  .navigation-links a span {
111
68
  flex: 1;
112
69
  }
113
70
 
114
- .navigation-links a svg {
115
- color: var(--va-color-foreground);
116
- }
117
-
118
- .navigation-links a:active svg {
119
- color: currentColor;
120
- }
121
-
122
- .settings .settings-label {
123
- margin-top: 1em;
124
- text-transform: none;
125
- font-size: var(--va-font-size-0);
126
- }
127
-
128
- .settings ul {
129
- list-style: none;
130
- padding-left: 0;
131
- }
132
-
133
- .settings .va-select {
134
- width: 100%;
135
- border-left-color: transparent;
136
- border-right: 0;
137
- border-bottom: 0;
138
- }
139
-
140
- .settings label:has(.va-select) {
141
- padding-left: 0 !important;
142
- }
143
-
144
71
  .site-menu {
145
72
  margin-top: 0;
146
73
  }
147
74
 
148
- .va-collapse {
149
- overflow: hidden;
75
+ .tsd-filter-input {
76
+ margin: 0;
150
77
  }
151
78
 
152
- .va-button {
153
- display: flex;
154
- align-items: center;
79
+ .tsd-filter-item:not(:last-child) {
80
+ margin-bottom: 0;
155
81
  }
156
82
 
157
83
  .tsd-signature,
@@ -176,9 +102,6 @@ footer {
176
102
  .page-toolbar {
177
103
  margin-top: 1rem;
178
104
  }
179
- .search a[href='#'] {
180
- display: inline-block;
181
- }
182
105
  .has-menu .col-sidebar {
183
106
  padding: 1rem;
184
107
  }
package/dist/index.js CHANGED
@@ -2,27 +2,21 @@ import { createRequire } from "node:module";
2
2
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
3
 
4
4
  // src/themes/VarvaraTheme.tsx
5
- import {
6
- DefaultTheme as DefaultTheme2,
7
- JSX as JSX6,
8
- RendererEvent
9
- } from "typedoc";
5
+ import { DefaultTheme as DefaultTheme2, JSX as JSX6, RendererEvent } from "typedoc";
10
6
  import * as path from "path";
11
7
  import * as fs from "fs";
12
8
  import { fileURLToPath } from "url";
13
9
 
14
10
  // src/themes/VarvaraThemeContext.ts
15
- import {
16
- DefaultThemeRenderContext as DefaultThemeRenderContext3
17
- } from "typedoc";
11
+ import { DefaultThemeRenderContext as DefaultThemeRenderContext3 } from "typedoc";
18
12
 
19
13
  // src/partials/footer.tsx
20
- import { JSX } from "typedoc";
14
+ import { i18n, JSX } from "typedoc";
21
15
  function footer(context) {
22
16
  const hideGenerator = context.options.getValue("hideGenerator");
23
17
  let generatorDisplay = /* @__PURE__ */ JSX.createElement(JSX.Fragment, null);
24
18
  if (!hideGenerator) {
25
- const message = context.i18n.theme_generated_using_typedoc();
19
+ const message = i18n.theme_generated_using_typedoc();
26
20
  const index = message.indexOf("TypeDoc");
27
21
  if (index == -1) {
28
22
  generatorDisplay = /* @__PURE__ */ JSX.createElement("p", {
@@ -61,7 +55,7 @@ function footer(context) {
61
55
  }
62
56
 
63
57
  // src/partials/sidebar.tsx
64
- import { JSX as JSX2 } from "typedoc";
58
+ import { i18n as i18n2, JSX as JSX2 } from "typedoc";
65
59
  function sidebar(context) {
66
60
  const navigation = context.getNavigation();
67
61
  return (props) => {
@@ -71,12 +65,9 @@ function sidebar(context) {
71
65
  class: "va-collapse tsd-accordion"
72
66
  }, /* @__PURE__ */ JSX2.createElement("summary", null, /* @__PURE__ */ JSX2.createElement("a", {
73
67
  href: context.urlTo(props.project)
74
- }, context.i18n.kind_plural_module())), navigation.map((item) => /* @__PURE__ */ JSX2.createElement("a", {
68
+ }, i18n2.kind_plural_module())), navigation.map((item) => /* @__PURE__ */ JSX2.createElement("a", {
75
69
  href: `${context.relativeURL("./")}/${item.path}`,
76
- class: [
77
- "va-button",
78
- item.path?.includes(props.url) && "va-button--active"
79
- ].join(" ")
70
+ class: ["va-button", item.path?.includes(props.url) && "va-button--active"].join(" ")
80
71
  }, /* @__PURE__ */ JSX2.createElement("svg", {
81
72
  width: "20",
82
73
  height: "20",
@@ -90,7 +81,7 @@ function sidebar(context) {
90
81
  }
91
82
 
92
83
  // src/partials/navigation.tsx
93
- import { JSX as JSX3, ReflectionFlag } from "typedoc";
84
+ import { JSX as JSX3, ReflectionFlag, i18n as i18n3, translateTagName, ReflectionFlags } from "typedoc";
94
85
  function pageSidebar(context) {
95
86
  return (props) => {
96
87
  return /* @__PURE__ */ JSX3.createElement("div", {
@@ -111,30 +102,26 @@ function settings(context) {
111
102
  for (const key of Object.keys(defaultFilters)) {
112
103
  if (key.startsWith("@")) {
113
104
  const filterName = key.substring(1).replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
114
- visibilityOptions.push(buildFilterItem(context, filterName, context.internationalization.translateTagName(key), defaultFilters[key]));
105
+ visibilityOptions.push(buildFilterItem(context, filterName, translateTagName(key), defaultFilters[key]));
115
106
  } else if (key === "protected" && !context.options.getValue("excludeProtected") || key === "private" && !context.options.getValue("excludePrivate") || key === "external" && !context.options.getValue("excludeExternals") || key === "inherited") {
116
- visibilityOptions.push(buildFilterItem(context, key, context.internationalization.flagString(flagOptionNameToReflectionFlag[key]), defaultFilters[key]));
107
+ visibilityOptions.push(buildFilterItem(context, key, ReflectionFlags.flagString(flagOptionNameToReflectionFlag[key]), defaultFilters[key]));
117
108
  }
118
109
  }
119
110
  return /* @__PURE__ */ JSX3.createElement("details", {
120
111
  class: "va-collapse settings tsd-accordion",
121
112
  open: false
122
- }, /* @__PURE__ */ JSX3.createElement("summary", null, context.i18n.theme_settings()), visibilityOptions.length && /* @__PURE__ */ JSX3.createElement("div", {
123
- class: "tsd-filter-visibility"
124
- }, /* @__PURE__ */ JSX3.createElement("span", {
125
- class: "settings-label"
126
- }, context.i18n.theme_member_visibility()), /* @__PURE__ */ JSX3.createElement("ul", {
127
- id: "tsd-filter-options"
128
- }, ...visibilityOptions)), /* @__PURE__ */ JSX3.createElement("label", null, /* @__PURE__ */ JSX3.createElement("span", null, context.i18n.theme_theme()), /* @__PURE__ */ JSX3.createElement("select", {
113
+ }, /* @__PURE__ */ JSX3.createElement("summary", null, i18n3.theme_settings()), visibilityOptions.length && /* @__PURE__ */ JSX3.createElement("details", {
114
+ class: "va-collapse"
115
+ }, /* @__PURE__ */ JSX3.createElement("summary", null, i18n3.theme_member_visibility()), ...visibilityOptions), /* @__PURE__ */ JSX3.createElement("label", null, /* @__PURE__ */ JSX3.createElement("span", null, i18n3.theme_theme()), /* @__PURE__ */ JSX3.createElement("select", {
129
116
  id: "tsd-theme",
130
117
  class: "va-select"
131
118
  }, /* @__PURE__ */ JSX3.createElement("option", {
132
119
  value: "os"
133
- }, context.i18n.theme_os()), /* @__PURE__ */ JSX3.createElement("option", {
120
+ }, i18n3.theme_os()), /* @__PURE__ */ JSX3.createElement("option", {
134
121
  value: "light"
135
- }, context.i18n.theme_light()), /* @__PURE__ */ JSX3.createElement("option", {
122
+ }, i18n3.theme_light()), /* @__PURE__ */ JSX3.createElement("option", {
136
123
  value: "dark"
137
- }, context.i18n.theme_dark()))));
124
+ }, i18n3.theme_dark()))));
138
125
  };
139
126
  }
140
127
  function buildSectionNavigation(context, headings) {
@@ -170,17 +157,16 @@ function buildSectionNavigation(context, headings) {
170
157
  finalizeLevel(true);
171
158
  return levels[0];
172
159
  }
173
- function buildFilterItem(context, name, displayName, defaultValue) {
174
- return /* @__PURE__ */ JSX3.createElement("li", {
160
+ function buildFilterItem(_context, name, displayName, defaultValue) {
161
+ return /* @__PURE__ */ JSX3.createElement("label", {
175
162
  class: "tsd-filter-item"
176
- }, /* @__PURE__ */ JSX3.createElement("label", {
177
- class: "tsd-filter-input"
178
- }, /* @__PURE__ */ JSX3.createElement("input", {
163
+ }, /* @__PURE__ */ JSX3.createElement("span", null, displayName), /* @__PURE__ */ JSX3.createElement("input", {
164
+ class: "tsd-filter-input va-checkbox",
179
165
  type: "checkbox",
180
166
  id: `tsd-filter-${name}`,
181
167
  name,
182
168
  checked: defaultValue
183
- }), context.icons.checkbox(), /* @__PURE__ */ JSX3.createElement("span", null, displayName)));
169
+ }));
184
170
  }
185
171
  function pageNavigation(context) {
186
172
  return (props) => {
@@ -203,52 +189,39 @@ function pageNavigation(context) {
203
189
  return /* @__PURE__ */ JSX3.createElement("details", {
204
190
  open: false,
205
191
  class: "va-collapse page-navigation tsd-accordion"
206
- }, /* @__PURE__ */ JSX3.createElement("summary", null, context.i18n.theme_on_this_page()), sections);
192
+ }, /* @__PURE__ */ JSX3.createElement("summary", null, i18n3.theme_on_this_page()), sections);
207
193
  };
208
194
  }
209
195
 
210
196
  // src/partials/toolbar.tsx
211
- import {
212
- DeclarationReflection,
213
- JSX as JSX4,
214
- ProjectReflection
215
- } from "typedoc";
197
+ import { i18n as i18n4, DeclarationReflection, JSX as JSX4, ProjectReflection } from "typedoc";
216
198
  function toolbar(context) {
217
199
  return (props) => /* @__PURE__ */ JSX4.createElement("header", {
218
200
  class: "page-toolbar"
219
201
  }, /* @__PURE__ */ JSX4.createElement("div", {
220
- class: "search",
221
- id: "tsd-search"
222
- }, /* @__PURE__ */ JSX4.createElement("div", {
223
- class: "field va-button-group"
202
+ class: "va-button-group"
224
203
  }, /* @__PURE__ */ JSX4.createElement("div", {
225
204
  class: "va-button-group va-button-group--horizontal"
226
205
  }, /* @__PURE__ */ JSX4.createElement("a", {
227
206
  href: context.options.getValue("titleLink") || context.relativeURL("index.html"),
228
- class: "va-button"
207
+ class: "title va-button"
229
208
  }, /* @__PURE__ */ JSX4.createElement("b", null, props.project.name), (props.project instanceof DeclarationReflection || props.project instanceof ProjectReflection) && props.project.packageVersion && /* @__PURE__ */ JSX4.createElement("span", {
230
209
  class: "version-badge"
231
- }, "v", props.project.packageVersion)), /* @__PURE__ */ JSX4.createElement("label", {
232
- for: "tsd-search-field",
233
- class: "va-button"
234
- }, context.icons.search()), /* @__PURE__ */ JSX4.createElement("a", {
235
- href: "#",
210
+ }, "v", props.project.packageVersion)), /* @__PURE__ */ JSX4.createElement("button", {
211
+ id: "tsd-search-trigger",
236
212
  class: "va-button",
237
- "data-toggle": "menu",
238
- "aria-label": context.i18n.theme_menu()
239
- }, context.icons.menu())), /* @__PURE__ */ JSX4.createElement("input", {
240
- type: "text",
241
- id: "tsd-search-field",
242
- class: "va-input",
243
- placeholder: context.i18n.theme_search(),
244
- "aria-label": context.i18n.theme_search()
245
- })), /* @__PURE__ */ JSX4.createElement("ul", {
246
- class: "results"
247
- }, /* @__PURE__ */ JSX4.createElement("li", {
248
- class: "state loading"
249
- }, context.i18n.theme_preparing_search_index()), /* @__PURE__ */ JSX4.createElement("li", {
250
- class: "state failure"
251
- }, context.i18n.theme_search_index_not_available()))), /* @__PURE__ */ JSX4.createElement("div", {
213
+ "aria-label": i18n4.theme_search()
214
+ }, /* @__PURE__ */ JSX4.createElement("svg", {
215
+ xmlns: "http://www.w3.org/2000/svg",
216
+ fill: "none",
217
+ viewBox: "0 0 24 24",
218
+ "stroke-width": "2.5",
219
+ width: "16",
220
+ height: "16",
221
+ stroke: "currentColor"
222
+ }, /* @__PURE__ */ JSX4.createElement("path", {
223
+ d: "m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z"
224
+ })))), /* @__PURE__ */ JSX4.createElement("div", {
252
225
  class: "navigation-links va-button-group"
253
226
  }, Object.entries(context.options.getValue("navigationLinks")).map(([label, url]) => /* @__PURE__ */ JSX4.createElement("a", {
254
227
  href: url,
@@ -264,14 +237,34 @@ function toolbar(context) {
264
237
  "clip-rule": "evenodd",
265
238
  d: "M1.52346 0.380859H15.6187V14.4761H13.333V4.28282L2.33158 15.2842L0.715332 13.668L11.7167 2.66657H1.52346V0.380859Z",
266
239
  fill: "currentColor"
267
- }))))));
240
+ })))))), /* @__PURE__ */ JSX4.createElement("dialog", {
241
+ id: "tsd-search",
242
+ "aria-label": i18n4.theme_search()
243
+ }, /* @__PURE__ */ JSX4.createElement("input", {
244
+ role: "combobox",
245
+ class: "va-input",
246
+ id: "tsd-search-input",
247
+ "aria-controls": "tsd-search-results",
248
+ "aria-autocomplete": "list",
249
+ "aria-expanded": "true",
250
+ spellcheck: false,
251
+ autocapitalize: "off",
252
+ autocomplete: "off",
253
+ placeholder: i18n4.theme_search_placeholder(),
254
+ maxLength: 100
255
+ }), /* @__PURE__ */ JSX4.createElement("ul", {
256
+ role: "listbox",
257
+ id: "tsd-search-results"
258
+ }), /* @__PURE__ */ JSX4.createElement("div", {
259
+ id: "tsd-search-status",
260
+ "aria-live": "polite",
261
+ "aria-atomic": "true"
262
+ }, /* @__PURE__ */ JSX4.createElement("div", null, i18n4.theme_preparing_search_index()))));
268
263
  }
269
264
 
270
265
  // src/partials/layout.tsx
271
266
  import { extname } from "path";
272
- import {
273
- JSX as JSX5
274
- } from "typedoc";
267
+ import { JSX as JSX5 } from "typedoc";
275
268
 
276
269
  // src/utils.ts
277
270
  import {
@@ -427,8 +420,8 @@ function buildSiteMetadata(context) {
427
420
 
428
421
  // src/themes/VarvaraThemeContext.ts
429
422
  class VarvaraThemeContext extends DefaultThemeRenderContext3 {
430
- constructor(theme, page, options) {
431
- super(theme, page, options);
423
+ constructor(router, theme, page, options) {
424
+ super(router, theme, page, options);
432
425
  this.pageSidebar = pageSidebar(this);
433
426
  this.toolbar = toolbar(this);
434
427
  this.defaultLayout = layout(this);
@@ -459,7 +452,7 @@ class VarvaraTheme extends DefaultTheme2 {
459
452
  })));
460
453
  }
461
454
  getRenderContext(pageEvent) {
462
- return new VarvaraThemeContext(this, pageEvent, this.application.options);
455
+ return new VarvaraThemeContext(this.router, this, pageEvent, this.application.options);
463
456
  }
464
457
  }
465
458
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "varvara-typedoc-theme",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "author": "Marc Mariné <shenobi@gmail.com>",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,13 +15,13 @@
15
15
  ],
16
16
  "license": "MIT",
17
17
  "dependencies": {
18
- "varvara-css": "latest"
18
+ "varvara-css": "^0.6.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/bun": "latest"
22
22
  },
23
23
  "peerDependencies": {
24
- "typedoc": "^0.27.5",
24
+ "typedoc": "^0.28.0",
25
25
  "typescript": "^5.0.0"
26
26
  },
27
27
  "scripts": {