fumadocs-ui 14.4.2 → 14.5.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.
- package/dist/components/image-zoom.css +78 -1
- package/dist/components/tabs.d.ts +6 -2
- package/dist/components/tabs.d.ts.map +1 -1
- package/dist/components/tabs.js +32 -18
- package/dist/style.css +2706 -1
- package/dist/tailwind-plugin.d.ts +5 -5
- package/dist/tailwind-plugin.d.ts.map +1 -1
- package/dist/tailwind-plugin.js +9 -10
- package/dist/theme/typography/index.d.ts +12 -0
- package/dist/theme/typography/index.d.ts.map +1 -0
- package/dist/theme/typography/index.js +133 -0
- package/dist/theme/typography/styles.d.ts +486 -0
- package/dist/theme/typography/styles.d.ts.map +1 -0
- package/dist/theme/typography/styles.js +426 -0
- package/package.json +11 -9
- package/dist/theme/typography.d.ts +0 -93
- package/dist/theme/typography.d.ts.map +0 -1
- package/dist/theme/typography.js +0 -97
|
@@ -1 +1,78 @@
|
|
|
1
|
-
[data-rmiz]
|
|
1
|
+
[data-rmiz] {
|
|
2
|
+
display: block;
|
|
3
|
+
position: relative;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
[data-rmiz-ghost] {
|
|
7
|
+
pointer-events: none;
|
|
8
|
+
position: absolute;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
[data-rmiz-btn-zoom],
|
|
12
|
+
[data-rmiz-btn-unzoom] {
|
|
13
|
+
display: none;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
[data-rmiz-content='found'] img {
|
|
17
|
+
cursor: zoom-in;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
[data-rmiz-modal][open] {
|
|
21
|
+
width: 100vw /* fallback */;
|
|
22
|
+
width: 100dvw;
|
|
23
|
+
|
|
24
|
+
height: 100vh /* fallback */;
|
|
25
|
+
height: 100dvh;
|
|
26
|
+
|
|
27
|
+
background-color: transparent;
|
|
28
|
+
max-width: none;
|
|
29
|
+
max-height: none;
|
|
30
|
+
margin: 0;
|
|
31
|
+
padding: 0;
|
|
32
|
+
position: fixed;
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
[data-rmiz-modal]:focus-visible {
|
|
37
|
+
outline: none;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
[data-rmiz-modal-overlay] {
|
|
41
|
+
transition: background-color 0.3s;
|
|
42
|
+
position: absolute;
|
|
43
|
+
inset: 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
[data-rmiz-modal-overlay='hidden'] {
|
|
47
|
+
background-color: transparent;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
[data-rmiz-modal-overlay='visible'] {
|
|
51
|
+
--tw-bg-opacity: 1;
|
|
52
|
+
background-color: hsl(var(--background) / var(--tw-bg-opacity, 1));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
[data-rmiz-modal-content] {
|
|
56
|
+
width: 100%;
|
|
57
|
+
height: 100%;
|
|
58
|
+
position: relative;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
[data-rmiz-modal]::backdrop {
|
|
62
|
+
display: none;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
[data-rmiz-modal-img] {
|
|
66
|
+
cursor: zoom-out;
|
|
67
|
+
image-rendering: high-quality;
|
|
68
|
+
transform-origin: 0 0;
|
|
69
|
+
transition: transform 0.3s;
|
|
70
|
+
position: absolute;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@media (prefers-reduced-motion: reduce) {
|
|
74
|
+
[data-rmiz-modal-overlay],
|
|
75
|
+
[data-rmiz-modal-img] {
|
|
76
|
+
transition-duration: 0.01ms !important;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -15,7 +15,11 @@ export interface TabsProps extends BaseProps {
|
|
|
15
15
|
*/
|
|
16
16
|
defaultIndex?: number;
|
|
17
17
|
items?: string[];
|
|
18
|
+
/**
|
|
19
|
+
* If true, updates the URL hash based on the tab's id
|
|
20
|
+
*/
|
|
21
|
+
updateAnchor?: boolean;
|
|
18
22
|
}
|
|
19
|
-
export declare function Tabs({ groupId, items, persist, defaultIndex, ...props }: TabsProps):
|
|
20
|
-
export declare function Tab({ value, className, ...props }: TabsContentProps):
|
|
23
|
+
export declare function Tabs({ groupId, items, persist, defaultIndex, updateAnchor, ...props }: TabsProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export declare function Tab({ value, className, ...props }: TabsContentProps): import("react/jsx-runtime").JSX.Element;
|
|
21
25
|
//# sourceMappingURL=tabs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../src/components/tabs.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,IAAI,SAAS,EACvB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../src/components/tabs.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,IAAI,SAAS,EACvB,MAAM,sBAAsB,CAAC;AAW9B,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAE,CAAC;AAmBrB,MAAM,WAAW,SAAU,SAAQ,SAAS;IAC1C;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAEjB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAMD,wBAAgB,IAAI,CAAC,EACnB,OAAO,EACP,KAAU,EACV,OAAe,EACf,YAAgB,EAChB,YAAoB,EACpB,GAAG,KAAK,EACT,EAAE,SAAS,2CA+EX;AAMD,wBAAgB,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,gBAAgB,2CAkBnE"}
|
package/dist/components/tabs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useMemo, useState, useCallback, createContext, useContext, useRef, useLayoutEffect,
|
|
3
|
+
import { useMemo, useState, useCallback, createContext, useContext, useRef, useLayoutEffect, } from 'react';
|
|
4
4
|
import { cn } from '../utils/cn';
|
|
5
5
|
import * as Primitive from './ui/tabs';
|
|
6
6
|
export { Primitive };
|
|
@@ -14,19 +14,20 @@ function removeChangeListener(id, listener) {
|
|
|
14
14
|
const list = listeners.get(id) ?? [];
|
|
15
15
|
listeners.set(id, list.filter((item) => item !== listener));
|
|
16
16
|
}
|
|
17
|
-
const
|
|
18
|
-
export function Tabs({ groupId, items = [], persist = false, defaultIndex = 0, ...props }) {
|
|
17
|
+
const ValueToMapContext = createContext(undefined);
|
|
18
|
+
export function Tabs({ groupId, items = [], persist = false, defaultIndex = 0, updateAnchor = false, ...props }) {
|
|
19
19
|
const values = useMemo(() => items.map((item) => toValue(item)), [items]);
|
|
20
20
|
const [value, setValue] = useState(values[defaultIndex]);
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const valueToIdMapRef = useRef(new Map());
|
|
22
|
+
const onChangeRef = useRef();
|
|
23
|
+
onChangeRef.current = (v) => {
|
|
24
|
+
if (values.includes(v))
|
|
25
|
+
setValue(v);
|
|
26
|
+
};
|
|
23
27
|
useLayoutEffect(() => {
|
|
24
28
|
if (!groupId)
|
|
25
29
|
return;
|
|
26
|
-
const onUpdate = (v) =>
|
|
27
|
-
if (valuesRef.current.includes(v))
|
|
28
|
-
setValue(v);
|
|
29
|
-
};
|
|
30
|
+
const onUpdate = (v) => onChangeRef.current?.(v);
|
|
30
31
|
const previous = persist
|
|
31
32
|
? localStorage.getItem(groupId)
|
|
32
33
|
: sessionStorage.getItem(groupId);
|
|
@@ -37,7 +38,23 @@ export function Tabs({ groupId, items = [], persist = false, defaultIndex = 0, .
|
|
|
37
38
|
removeChangeListener(groupId, onUpdate);
|
|
38
39
|
};
|
|
39
40
|
}, [groupId, persist]);
|
|
41
|
+
useLayoutEffect(() => {
|
|
42
|
+
const hash = window.location.hash.slice(1);
|
|
43
|
+
if (!hash)
|
|
44
|
+
return;
|
|
45
|
+
const entry = valueToIdMapRef.current
|
|
46
|
+
.entries()
|
|
47
|
+
.find(([_, id]) => id === hash);
|
|
48
|
+
if (entry)
|
|
49
|
+
setValue(entry[0]);
|
|
50
|
+
}, []);
|
|
40
51
|
const onValueChange = useCallback((v) => {
|
|
52
|
+
if (updateAnchor) {
|
|
53
|
+
const id = valueToIdMapRef.current.get(v);
|
|
54
|
+
if (id) {
|
|
55
|
+
window.history.replaceState(null, '', `#${id}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
41
58
|
if (groupId) {
|
|
42
59
|
listeners.get(groupId)?.forEach((item) => {
|
|
43
60
|
item(v);
|
|
@@ -50,20 +67,17 @@ export function Tabs({ groupId, items = [], persist = false, defaultIndex = 0, .
|
|
|
50
67
|
else {
|
|
51
68
|
setValue(v);
|
|
52
69
|
}
|
|
53
|
-
}, [groupId, persist]);
|
|
54
|
-
return (_jsxs(Primitive.Tabs, { value: value, onValueChange: onValueChange, ...props, className: cn('my-4', props.className), children: [_jsx(Primitive.TabsList, { children: values.map((v, i) => (_jsx(Primitive.TabsTrigger, { value: v, children: items[i] }, v))) }), _jsx(
|
|
70
|
+
}, [groupId, persist, updateAnchor]);
|
|
71
|
+
return (_jsxs(Primitive.Tabs, { value: value, onValueChange: onValueChange, ...props, className: cn('my-4', props.className), children: [_jsx(Primitive.TabsList, { children: values.map((v, i) => (_jsx(Primitive.TabsTrigger, { value: v, children: items[i] }, v))) }), _jsx(ValueToMapContext.Provider, { value: valueToIdMapRef.current, children: props.children })] }));
|
|
55
72
|
}
|
|
56
73
|
function toValue(v) {
|
|
57
74
|
return v.toLowerCase().replace(/\s/, '-');
|
|
58
75
|
}
|
|
59
76
|
export function Tab({ value, className, ...props }) {
|
|
60
77
|
const v = toValue(value);
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
onValueChange(v);
|
|
66
|
-
}
|
|
67
|
-
}, [onValueChange, props.id, v]);
|
|
78
|
+
const valueToIdMap = useContext(ValueToMapContext);
|
|
79
|
+
if (props.id) {
|
|
80
|
+
valueToIdMap?.set(v, props.id);
|
|
81
|
+
}
|
|
68
82
|
return (_jsx(Primitive.TabsContent, { value: v, className: cn('prose-no-margin [&>figure:only-child]:-m-4 [&>figure:only-child]:rounded-none [&>figure:only-child]:border-none', className), ...props }));
|
|
69
83
|
}
|