@umami/shiso 1.7.0 → 1.8.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.
@@ -0,0 +1,217 @@
1
+ import type { ImgHTMLAttributes, ReactElement, ReactNode } from 'react';
2
+
3
+ export interface AccordionProps {
4
+ title?: ReactNode;
5
+ icon?: ReactNode | string;
6
+ defaultOpen?: boolean;
7
+ children?: ReactNode;
8
+ }
9
+
10
+ export interface AccordionGroupProps {
11
+ children?: ReactNode;
12
+ defaultOpen?: boolean;
13
+ }
14
+
15
+ export declare function Accordion(props: AccordionProps): ReactElement;
16
+ export declare function AccordionGroup(props: AccordionGroupProps): ReactElement | null;
17
+
18
+ export type BadgeColor =
19
+ | 'gray'
20
+ | 'blue'
21
+ | 'green'
22
+ | 'yellow'
23
+ | 'orange'
24
+ | 'red'
25
+ | 'purple'
26
+ | 'white'
27
+ | 'surface'
28
+ | 'white-destructive'
29
+ | 'surface-destructive';
30
+ export type BadgeSize = 'xs' | 'sm' | 'md' | 'lg';
31
+ export type BadgeShape = 'rounded' | 'pill';
32
+
33
+ export interface BadgeProps {
34
+ color?: BadgeColor;
35
+ size?: BadgeSize;
36
+ shape?: BadgeShape;
37
+ icon?: ReactNode;
38
+ stroke?: boolean;
39
+ disabled?: boolean;
40
+ className?: string;
41
+ /** @deprecated Use `color` instead. */
42
+ tone?: 'muted' | 'primary';
43
+ children?: ReactNode;
44
+ }
45
+
46
+ export declare function Badge(props: BadgeProps): ReactElement;
47
+
48
+ export interface ButtonProps {
49
+ href?: string;
50
+ variant?: 'default' | 'outline' | 'secondary' | 'ghost' | 'destructive' | 'link';
51
+ size?: 'default' | 'xs' | 'sm' | 'lg';
52
+ icon?: ReactNode | string;
53
+ className?: string;
54
+ children?: ReactNode;
55
+ }
56
+
57
+ export declare function Button(props: ButtonProps): ReactElement;
58
+
59
+ export type CalloutVariant = 'note' | 'tip' | 'warning' | 'info' | 'check' | 'danger';
60
+
61
+ export interface CalloutProps {
62
+ title?: ReactNode;
63
+ icon?: ReactNode | string;
64
+ children?: ReactNode;
65
+ variant?: CalloutVariant;
66
+ }
67
+
68
+ export interface ChildrenProps {
69
+ children?: ReactNode;
70
+ }
71
+
72
+ export declare function Callout(props: CalloutProps): ReactElement;
73
+ export declare function Note(props: ChildrenProps): ReactElement;
74
+ export declare function Tip(props: ChildrenProps): ReactElement;
75
+ export declare function Warning(props: ChildrenProps): ReactElement;
76
+ export declare function Info(props: ChildrenProps): ReactElement;
77
+ export declare function Check(props: ChildrenProps): ReactElement;
78
+ export declare function Danger(props: ChildrenProps): ReactElement;
79
+ export declare function WarningBanner(props: ChildrenProps): ReactElement;
80
+
81
+ export type CardType = 'note' | 'info' | 'warning' | 'tip' | 'check' | 'danger';
82
+
83
+ export interface CardProps {
84
+ title?: ReactNode;
85
+ href?: string;
86
+ icon?: ReactNode | string;
87
+ color?: string;
88
+ img?: string;
89
+ cta?: string;
90
+ horizontal?: boolean;
91
+ arrow?: boolean;
92
+ type?: CardType;
93
+ children?: ReactNode;
94
+ }
95
+
96
+ export interface CardGroupProps {
97
+ children?: ReactNode;
98
+ cols?: 1 | 2 | 3 | 4;
99
+ }
100
+
101
+ export declare function Card(props: CardProps): ReactElement;
102
+ export declare function CardGroup(props: CardGroupProps): ReactElement;
103
+
104
+ export interface CodeGroupProps {
105
+ children?: ReactNode;
106
+ }
107
+
108
+ export declare function CodeGroup(props: CodeGroupProps): ReactElement | null;
109
+
110
+ export interface ColumnsProps {
111
+ children?: ReactNode;
112
+ cols?: 1 | 2 | 3 | 4;
113
+ }
114
+
115
+ export interface ColumnProps {
116
+ children?: ReactNode;
117
+ }
118
+
119
+ export declare function Columns(props: ColumnsProps): ReactElement;
120
+ export declare function Column(props: ColumnProps): ReactElement;
121
+
122
+ export interface ExpandableProps {
123
+ title: ReactNode;
124
+ children?: ReactNode;
125
+ defaultOpen?: boolean;
126
+ }
127
+
128
+ export declare function Expandable(props: ExpandableProps): ReactElement;
129
+
130
+ export interface FrameProps {
131
+ caption?: ReactNode;
132
+ hint?: ReactNode;
133
+ children?: ReactNode;
134
+ }
135
+
136
+ export declare function Frame(props: FrameProps): ReactElement;
137
+
138
+ export interface IconProps {
139
+ icon?: string;
140
+ src?: string;
141
+ color?: string;
142
+ size?: number;
143
+ className?: string;
144
+ }
145
+
146
+ export declare function Icon(props: IconProps): ReactElement | null;
147
+
148
+ export interface ParamFieldProps {
149
+ name?: string;
150
+ query?: string;
151
+ path?: string;
152
+ header?: string;
153
+ body?: string;
154
+ type?: string;
155
+ required?: boolean;
156
+ children?: ReactNode;
157
+ }
158
+
159
+ export declare function ParamField(props: ParamFieldProps): ReactElement;
160
+ export declare function Param(props: ChildrenProps): ReactElement;
161
+
162
+ export interface PropertiesTableProps {
163
+ children?: ReactNode;
164
+ }
165
+
166
+ export declare function PropertiesTable(props: PropertiesTableProps): ReactElement | null;
167
+
168
+ type FieldValue = string | number | boolean | null | undefined;
169
+
170
+ export interface ResponseFieldProps {
171
+ name: string;
172
+ type?: FieldValue;
173
+ default?: FieldValue;
174
+ required?: boolean;
175
+ deprecated?: boolean;
176
+ children?: ReactNode;
177
+ }
178
+
179
+ export declare function ResponseField(props: ResponseFieldProps): ReactElement;
180
+
181
+ export interface StepProps {
182
+ title?: ReactNode;
183
+ children?: ReactNode;
184
+ }
185
+
186
+ export interface StepsProps {
187
+ children?: ReactNode;
188
+ }
189
+
190
+ export declare function Step(props: StepProps): ReactElement;
191
+ export declare function Steps(props: StepsProps): ReactElement | null;
192
+
193
+ export interface TabProps {
194
+ title?: ReactNode;
195
+ children?: ReactNode;
196
+ }
197
+
198
+ export interface TabsProps {
199
+ children?: ReactNode;
200
+ group?: string;
201
+ }
202
+
203
+ export declare function Tab(props: TabProps): ReactElement;
204
+ export declare function Tabs(props: TabsProps): ReactElement | null;
205
+
206
+ export interface TooltipProps {
207
+ tip?: ReactNode;
208
+ children?: ReactNode;
209
+ }
210
+
211
+ export declare function Tooltip(props: TooltipProps): ReactElement;
212
+
213
+ export interface ZoomableImageProps extends ImgHTMLAttributes<HTMLImageElement> {
214
+ noZoom?: boolean;
215
+ }
216
+
217
+ export declare function ZoomableImage(props: ZoomableImageProps): ReactElement;
package/vite.config.ts CHANGED
@@ -3,7 +3,7 @@ import path from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  import tailwindcss from '@tailwindcss/vite';
5
5
  import react from '@vitejs/plugin-react';
6
- import { defineConfig, type Plugin } from 'vite';
6
+ import { defineConfig, type Plugin, searchForWorkspaceRoot } from 'vite';
7
7
  import { shisoMdx } from './mdx.config.ts';
8
8
  import { generateIconRegistry } from './scripts/generate-icon-registry.mjs';
9
9
  import { shisoLastModified } from './scripts/generate-last-modified.mjs';
@@ -49,7 +49,11 @@ function shisoSearchIndex(
49
49
  await generateSearchIndex({ config: getDocsConfig(), shiso: getShisoConfig(), root, output });
50
50
  },
51
51
  async handleHotUpdate({ file }) {
52
- if (/\.(md|mdx)$/.test(file) || file.endsWith('docs.json') || /shiso\.config\.\w+$/.test(file)) {
52
+ if (
53
+ /\.(md|mdx)$/.test(file) ||
54
+ file.endsWith('docs.json') ||
55
+ /shiso\.config\.\w+$/.test(file)
56
+ ) {
53
57
  await generateSearchIndex({
54
58
  config: getDocsConfig(),
55
59
  shiso: getShisoConfig(),
@@ -294,9 +298,9 @@ function shisoHtml(getDocsConfig: () => DocsConfig): Plugin {
294
298
 
295
299
  /**
296
300
  * Serves the raw markdown source for `<route>.md` URLs during development,
297
- * mirroring the `.md` copies the prerenderer publishes next to every page in
298
- * production builds. The contextual menu's copy/view options and AI links
299
- * depend on these URLs.
301
+ * mirroring the `.md` copies the prerenderer publishes next to Markdown and
302
+ * MDX pages in production builds. TSX standalone pages return 404 because
303
+ * their source is not a Markdown representation.
300
304
  */
301
305
  function shisoMarkdownDev(
302
306
  getDocsConfig: () => DocsConfig,
@@ -336,7 +340,7 @@ function shisoMarkdownDev(
336
340
  const pageSlug = standalone.page
337
341
  .trim()
338
342
  .replace(/^\/+/, '')
339
- .replace(/\.mdx?$/, '');
343
+ .replace(/\.(?:mdx?|tsx)$/, '');
340
344
 
341
345
  for (const candidate of [`${pageSlug}.mdx`, `${pageSlug}.md`]) {
342
346
  const filePath = path.resolve(pagesRoot, candidate);
@@ -355,6 +359,11 @@ function shisoMarkdownDev(
355
359
  // Try the next candidate.
356
360
  }
357
361
  }
362
+
363
+ // Component pages intentionally have no raw Markdown representation.
364
+ res.statusCode = 404;
365
+ res.end('Not found');
366
+ return;
358
367
  }
359
368
 
360
369
  if (docsPrefix && route.startsWith(docsPrefix)) {
@@ -404,7 +413,22 @@ export default defineConfig(async () => {
404
413
  const getDocsConfig = configModule.getConfig as () => DocsConfig;
405
414
  const getShisoConfig = configModule.getShisoConfig as () => ResolvedShisoConfig;
406
415
 
416
+ // Shiso may be installed via link:/file: from a directory outside the
417
+ // project's workspace root. Allow the framework's real location (and the
418
+ // repository root above it, which holds its dependency store) so raw assets
419
+ // like fonts remain servable in dev instead of returning 403.
420
+ const shisoRoot = path.dirname(fileURLToPath(import.meta.url));
421
+
407
422
  return {
423
+ server: {
424
+ fs: {
425
+ allow: [
426
+ searchForWorkspaceRoot(process.cwd()),
427
+ shisoRoot,
428
+ path.resolve(shisoRoot, '..', '..'),
429
+ ],
430
+ },
431
+ },
408
432
  optimizeDeps: {
409
433
  // The published runtime is already bundled ESM and contains project-time
410
434
  // virtual imports that are resolved by the plugins below.