@umami/shiso 1.6.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.
@@ -5,6 +5,32 @@
5
5
 
6
6
  @custom-variant dark (&:where([data-theme="dark"], [data-theme="dark"] *));
7
7
 
8
+ /* tw-animate-css defines these keyframes against Radix-style height variables
9
+ (--radix-accordion-content-height etc.). Base UI exposes the panel height as
10
+ --accordion-panel-height instead, so the originals resolve to `auto` and the
11
+ open/close animation jumps. Redefining them inside @theme replaces the
12
+ originals in Tailwind's emitted output (a plain top-level @keyframes rule
13
+ would lose: Tailwind emits theme keyframes at the end of the stylesheet). */
14
+ @theme inline {
15
+ @keyframes accordion-down {
16
+ from {
17
+ height: 0;
18
+ }
19
+ to {
20
+ height: var(--accordion-panel-height);
21
+ }
22
+ }
23
+
24
+ @keyframes accordion-up {
25
+ from {
26
+ height: var(--accordion-panel-height);
27
+ }
28
+ to {
29
+ height: 0;
30
+ }
31
+ }
32
+ }
33
+
8
34
  @layer base {
9
35
  *,
10
36
  *::before,
@@ -73,11 +99,11 @@
73
99
  color: color-mix(in srgb, var(--foreground) 25%, var(--muted-foreground));
74
100
  }
75
101
 
76
- .docs-markdown > * + * {
102
+ .docs-markdown > * + *:not(:where(.not-prose, .not-prose *)) {
77
103
  margin-top: 1rem;
78
104
  }
79
105
 
80
- .docs-markdown :where(h2, h3, h4, h5, h6) {
106
+ .docs-markdown :where(h1, h2, h3, h4, h5, h6):not(:where(.not-prose, .not-prose *)) {
81
107
  font-family: var(--font-heading);
82
108
  font-weight: var(--font-heading-weight, 600);
83
109
  letter-spacing: -0.02em;
@@ -102,57 +128,57 @@
102
128
  opacity: 1;
103
129
  }
104
130
 
105
- .docs-markdown h2 {
131
+ .docs-markdown h2:not(:where(.not-prose, .not-prose *)) {
106
132
  margin-top: 2.25rem;
107
133
  margin-bottom: 1rem;
108
134
  font-size: 1.5rem;
109
135
  }
110
136
 
111
- .docs-markdown h3 {
137
+ .docs-markdown h3:not(:where(.not-prose, .not-prose *)) {
112
138
  margin-top: 1.75rem;
113
139
  margin-bottom: 0.75rem;
114
140
  font-size: 1.2rem;
115
141
  }
116
142
 
117
- .docs-markdown p {
143
+ .docs-markdown p:not(:where(.not-prose, .not-prose *)) {
118
144
  margin: 0.75rem 0;
119
145
  }
120
146
 
121
- .docs-markdown ul,
122
- .docs-markdown ol {
147
+ .docs-markdown ul:not(:where(.not-prose, .not-prose *)),
148
+ .docs-markdown ol:not(:where(.not-prose, .not-prose *)) {
123
149
  margin: 0.75rem 0;
124
150
  padding-left: 1.25rem;
125
151
  }
126
152
 
127
- .docs-markdown ul {
153
+ .docs-markdown ul:not(:where(.not-prose, .not-prose *)) {
128
154
  list-style: disc;
129
155
  }
130
156
 
131
- .docs-markdown ol {
157
+ .docs-markdown ol:not(:where(.not-prose, .not-prose *)) {
132
158
  list-style: decimal;
133
159
  }
134
160
 
135
- .docs-markdown li {
161
+ .docs-markdown li:not(:where(.not-prose, .not-prose *)) {
136
162
  margin: 0.35rem 0;
137
163
  }
138
164
 
139
- .docs-markdown :where(strong, b) {
165
+ .docs-markdown :where(strong, b):not(:where(.not-prose, .not-prose *)) {
140
166
  color: var(--foreground);
141
167
  font-weight: 600;
142
168
  }
143
169
 
144
- .docs-markdown a {
170
+ .docs-markdown a:not(:where(.not-prose, .not-prose *)) {
145
171
  color: var(--foreground);
146
172
  text-decoration: underline;
147
173
  text-decoration-color: color-mix(in srgb, currentColor 30%, transparent);
148
174
  text-underline-offset: 0.2em;
149
175
  }
150
176
 
151
- .docs-markdown a:hover {
177
+ .docs-markdown a:hover:not(:where(.not-prose, .not-prose *)) {
152
178
  text-decoration-color: currentColor;
153
179
  }
154
180
 
155
- .docs-markdown code:not(pre code) {
181
+ .docs-markdown code:not(pre code):not(:where(.not-prose, .not-prose *)) {
156
182
  color: var(--foreground);
157
183
  border-radius: var(--radius-sm);
158
184
  background: color-mix(in srgb, currentColor 4%, transparent);
@@ -162,7 +188,7 @@
162
188
 
163
189
  /* Styled to match the PropertiesTable component: rounded outer border,
164
190
  horizontal row separators only, and no header fill. */
165
- .docs-markdown table {
191
+ .docs-markdown table:not(:where(.not-prose, .not-prose *)) {
166
192
  width: 100%;
167
193
  margin: 1rem 0;
168
194
  font-size: 0.875rem;
@@ -172,12 +198,12 @@
172
198
  border-radius: var(--radius-lg);
173
199
  }
174
200
 
175
- .docs-markdown th {
201
+ .docs-markdown th:not(:where(.not-prose, .not-prose *)) {
176
202
  color: var(--foreground);
177
203
  }
178
204
 
179
- .docs-markdown th,
180
- .docs-markdown td {
205
+ .docs-markdown th:not(:where(.not-prose, .not-prose *)),
206
+ .docs-markdown td:not(:where(.not-prose, .not-prose *)) {
181
207
  border: none;
182
208
  border-bottom: 1px solid var(--border);
183
209
  padding: 0.6rem 0.75rem;
@@ -185,36 +211,36 @@
185
211
  vertical-align: top;
186
212
  }
187
213
 
188
- .docs-markdown th:first-child,
189
- .docs-markdown td:first-child {
214
+ .docs-markdown th:first-child:not(:where(.not-prose, .not-prose *)),
215
+ .docs-markdown td:first-child:not(:where(.not-prose, .not-prose *)) {
190
216
  padding-left: 1.5rem;
191
217
  }
192
218
 
193
- .docs-markdown th:last-child,
194
- .docs-markdown td:last-child {
219
+ .docs-markdown th:last-child:not(:where(.not-prose, .not-prose *)),
220
+ .docs-markdown td:last-child:not(:where(.not-prose, .not-prose *)) {
195
221
  padding-right: 1.5rem;
196
222
  }
197
223
 
198
- .docs-markdown th {
224
+ .docs-markdown th:not(:where(.not-prose, .not-prose *)) {
199
225
  background: transparent;
200
226
  font-weight: 600;
201
227
  }
202
228
 
203
- .docs-markdown tbody tr:last-child td {
229
+ .docs-markdown tbody tr:last-child td:not(:where(.not-prose, .not-prose *)) {
204
230
  border-bottom: none;
205
231
  }
206
232
 
207
- .docs-markdown table code:not(pre code) {
233
+ .docs-markdown table code:not(pre code):not(:where(.not-prose, .not-prose *)) {
208
234
  font-size: 0.75rem;
209
235
  }
210
236
 
211
- .docs-markdown blockquote {
237
+ .docs-markdown blockquote:not(:where(.not-prose, .not-prose *)) {
212
238
  border-left: 3px solid var(--input);
213
239
  padding-left: 1rem;
214
240
  color: var(--muted-foreground);
215
241
  }
216
242
 
217
- .docs-markdown hr {
243
+ .docs-markdown hr:not(:where(.not-prose, .not-prose *)) {
218
244
  border: none;
219
245
  border-top: 1px solid var(--border);
220
246
  margin: 2rem 0;
@@ -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.