xmlui 0.8.3 → 0.8.5
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/{apiInterceptorWorker-BbXqnrUa.mjs → apiInterceptorWorker-BNc4vJAb.mjs} +1 -1
- package/dist/{core-BmjxDmQl.mjs → core-CvFpTAHi.mjs} +317 -303
- package/dist/{index-euqWddW6.mjs → index-CnjyjGNQ.mjs} +12558 -12367
- package/dist/index.css +1 -1
- package/dist/scripts/bin/build-lib.js +1 -1
- package/dist/scripts/src/components/App/App.js +10 -1
- package/dist/scripts/src/components/AppHeader/AppHeader.js +3 -1
- package/dist/scripts/src/components/AutoComplete/AutoComplete.js +11 -10
- package/dist/scripts/src/components/Heading/HeadingNative.js +6 -6
- package/dist/scripts/src/components/Markdown/Markdown.js +7 -4
- package/dist/scripts/src/components/Markdown/MarkdownNative.js +10 -4
- package/dist/scripts/src/components/TableOfContents/TableOfContentsNative.js +2 -2
- package/dist/scripts/src/components/Theme/ThemeNative.js +13 -2
- package/dist/scripts/src/components/abstractions.js +5 -5
- package/dist/scripts/src/components-core/DevTools.js +163 -0
- package/dist/scripts/src/components-core/InspectorContext.js +46 -61
- package/dist/scripts/src/components-core/TableOfContentsContext.js +18 -20
- package/dist/scripts/src/components-core/XmluiCodeHighlighter.js +6 -6
- package/dist/scripts/src/components-core/theming/ThemeProvider.js +1 -1
- package/dist/scripts/src/components-core/theming/themes/root.js +0 -1
- package/dist/style.css +1 -1
- package/dist/xmlui-metadata.mjs +5474 -5238
- package/dist/xmlui-metadata.umd.js +13 -11
- package/dist/xmlui-standalone.umd.js +195 -169
- package/dist/xmlui.d.ts +1 -0
- package/dist/xmlui.mjs +1 -1
- package/package.json +8 -5
|
@@ -8,6 +8,7 @@ const react_1 = require("react");
|
|
|
8
8
|
const hooks_1 = require("./utils/hooks");
|
|
9
9
|
const react_2 = require("@remix-run/react");
|
|
10
10
|
const constants_1 = require("./constants");
|
|
11
|
+
const AppContext_1 = require("./AppContext");
|
|
11
12
|
/**
|
|
12
13
|
* Several components work together to represent the hierarchy of a particular
|
|
13
14
|
* app page as a TOC. This React component provides a context for storing this
|
|
@@ -22,7 +23,7 @@ function TableOfContentsProvider({ children }) {
|
|
|
22
23
|
const [headings, setHeadings] = (0, react_1.useState)(constants_1.EMPTY_OBJECT);
|
|
23
24
|
const [callbacks, setCallbacks] = (0, react_1.useState)(constants_1.EMPTY_ARRAY);
|
|
24
25
|
const observer = (0, react_1.useRef)(null);
|
|
25
|
-
const
|
|
26
|
+
const { forceRefreshAnchorScroll } = (0, AppContext_1.useAppContext)();
|
|
26
27
|
const thisRef = (0, react_1.useRef)({
|
|
27
28
|
suspendPositionBasedSetActiveId: false,
|
|
28
29
|
});
|
|
@@ -32,8 +33,10 @@ function TableOfContentsProvider({ children }) {
|
|
|
32
33
|
thisRef.current.suspendPositionBasedSetActiveId = false;
|
|
33
34
|
}, []),
|
|
34
35
|
});
|
|
36
|
+
const [activeAnchorId, setActiveAnchorId] = (0, react_1.useState)(null);
|
|
35
37
|
const notify = (0, react_1.useCallback)((id) => {
|
|
36
38
|
callbacks.forEach((cb) => cb(id));
|
|
39
|
+
setActiveAnchorId(id);
|
|
37
40
|
}, [callbacks]);
|
|
38
41
|
(0, react_1.useEffect)(() => {
|
|
39
42
|
if (callbacks.length) {
|
|
@@ -75,6 +78,7 @@ function TableOfContentsProvider({ children }) {
|
|
|
75
78
|
const scrollToAnchor = (0, react_1.useCallback)((id, smoothScrolling) => {
|
|
76
79
|
const value = headings[id];
|
|
77
80
|
if (value) {
|
|
81
|
+
thisRef.current.suspendPositionBasedSetActiveId = true;
|
|
78
82
|
value.anchor.scrollIntoView({
|
|
79
83
|
block: "start",
|
|
80
84
|
inline: "start",
|
|
@@ -89,8 +93,13 @@ function TableOfContentsProvider({ children }) {
|
|
|
89
93
|
preventHashScroll: true,
|
|
90
94
|
},
|
|
91
95
|
});
|
|
96
|
+
//we clear the preventHashScroll route state: https://stackoverflow.com/questions/72121228/how-to-update-location-state-in-react-router-v6
|
|
97
|
+
requestAnimationFrame(() => {
|
|
98
|
+
navigate({
|
|
99
|
+
hash: `#${value.id}`,
|
|
100
|
+
}, { replace: true });
|
|
101
|
+
});
|
|
92
102
|
});
|
|
93
|
-
thisRef.current.suspendPositionBasedSetActiveId = true;
|
|
94
103
|
}
|
|
95
104
|
}, [headings, navigate, notify]);
|
|
96
105
|
const sortedHeadings = (0, react_1.useMemo)(() => {
|
|
@@ -104,26 +113,13 @@ function TableOfContentsProvider({ children }) {
|
|
|
104
113
|
return -1;
|
|
105
114
|
});
|
|
106
115
|
}, [headings]);
|
|
107
|
-
|
|
116
|
+
//the content could take time to load, this way we try to force the scroll to anchor mechanism to kick in
|
|
117
|
+
const hasHeadings = sortedHeadings.length > 0;
|
|
108
118
|
(0, react_1.useEffect)(() => {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (hash) {
|
|
112
|
-
if (initialHeading.current) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
initialHeading.current = (_a = sortedHeadings.find((value) => `#${value.id}` === hash)) === null || _a === void 0 ? void 0 : _a.anchor;
|
|
117
|
-
if (initialHeading.current) {
|
|
118
|
-
initialHeading.current.scrollIntoView({
|
|
119
|
-
block: "start",
|
|
120
|
-
inline: "start",
|
|
121
|
-
behavior: "instant",
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
}
|
|
119
|
+
if (hasHeadings) {
|
|
120
|
+
forceRefreshAnchorScroll();
|
|
125
121
|
}
|
|
126
|
-
}, [
|
|
122
|
+
}, [forceRefreshAnchorScroll, hasHeadings]);
|
|
127
123
|
const subscribeToActiveAnchorChange = (0, react_1.useCallback)((cb) => {
|
|
128
124
|
setCallbacks((prev) => {
|
|
129
125
|
return [...prev, cb];
|
|
@@ -141,6 +137,7 @@ function TableOfContentsProvider({ children }) {
|
|
|
141
137
|
scrollToAnchor,
|
|
142
138
|
subscribeToActiveAnchorChange,
|
|
143
139
|
hasTableOfContents: callbacks.length > 0,
|
|
140
|
+
activeAnchorId
|
|
144
141
|
};
|
|
145
142
|
}, [
|
|
146
143
|
registerHeading,
|
|
@@ -148,6 +145,7 @@ function TableOfContentsProvider({ children }) {
|
|
|
148
145
|
scrollToAnchor,
|
|
149
146
|
subscribeToActiveAnchorChange,
|
|
150
147
|
callbacks.length,
|
|
148
|
+
activeAnchorId,
|
|
151
149
|
]);
|
|
152
150
|
return ((0, jsx_runtime_1.jsx)(exports.TableOfContentsContext.Provider, { value: contextValue, children: children }));
|
|
153
151
|
}
|
|
@@ -98,12 +98,12 @@ function XmluiCodeHighlighter({ value }) {
|
|
|
98
98
|
},
|
|
99
99
|
});
|
|
100
100
|
}, [initialized, value]);
|
|
101
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(XmluiCodeHighlighter_module_scss_1.default.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
101
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: XmluiCodeHighlighter_module_scss_1.default.wrapper, children: (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(XmluiCodeHighlighter_module_scss_1.default.innerWrapper, {
|
|
102
|
+
[XmluiCodeHighlighter_module_scss_1.default.dark]: activeThemeTone === "dark",
|
|
103
|
+
[XmluiCodeHighlighter_module_scss_1.default.light]: activeThemeTone === "light",
|
|
104
|
+
}), dangerouslySetInnerHTML: {
|
|
105
|
+
__html: html,
|
|
106
|
+
} }) }));
|
|
107
107
|
}
|
|
108
108
|
exports.codeComponentRenderer = (0, renderers_1.createComponentRenderer)("XmluiCodehighlighter", {}, ({ node, renderChild }) => {
|
|
109
109
|
return (0, jsx_runtime_1.jsx)(XmluiCodeHighlighter, { value: renderChild(node.children) });
|
|
@@ -122,7 +122,7 @@ function useCompiledTheme(activeTheme, activeTone, themes = constants_1.EMPTY_AR
|
|
|
122
122
|
return (Object.assign(Object.assign(Object.assign({}, themeDef.themeVars), (_a = themeDef.themeVars) === null || _a === void 0 ? void 0 : _a[activeTone]), (_c = (_b = themeDef.tones) === null || _b === void 0 ? void 0 : _b[activeTone]) === null || _c === void 0 ? void 0 : _c.themeVars));
|
|
123
123
|
})
|
|
124
124
|
.slice(0, themeDefChain.length - 1),
|
|
125
|
-
Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (0, transformThemeVars_1.generateBaseSpacings)(mergedThemeVars)), (0, transformThemeVars_1.generateBaseFontSizes)(mergedThemeVars)), (0, transformThemeVars_1.
|
|
125
|
+
Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (0, transformThemeVars_1.generateBaseSpacings)(mergedThemeVars)), (0, transformThemeVars_1.generateBaseFontSizes)(mergedThemeVars)), (0, transformThemeVars_1.generatePaddingSegments)(mergedThemeVars)), (0, transformThemeVars_1.generateBorderSegments)(mergedThemeVars)), (0, transformThemeVars_1.generateBaseTones)(mergedThemeVars)), (0, transformThemeVars_1.generateButtonTones)(mergedThemeVars)),
|
|
126
126
|
Object.assign(Object.assign(Object.assign({}, themeDefChain[themeDefChain.length - 1].themeVars), (_a = themeDefChain[themeDefChain.length - 1].themeVars) === null || _a === void 0 ? void 0 : _a[activeTone]), (_c = (_b = themeDefChain[themeDefChain.length - 1].tones) === null || _b === void 0 ? void 0 : _b[activeTone]) === null || _c === void 0 ? void 0 : _c.themeVars),
|
|
127
127
|
];
|
|
128
128
|
return resultedTheme;
|
|
@@ -38,7 +38,6 @@ exports.RootThemeDefinition = {
|
|
|
38
38
|
"color-primary-800": "hsl(212,71.9%,18.1%)",
|
|
39
39
|
"color-primary-900": "hsl(212,71.9%,9.1%)",
|
|
40
40
|
"color-primary-950": "hsl(212,71.9%,4.5%)",
|
|
41
|
-
"color-primary": "$color-primary-500",
|
|
42
41
|
// --- Secondary color shades (steel-bluish)
|
|
43
42
|
"color-secondary-50": "hsl(211.7,21.2%,96.9%)",
|
|
44
43
|
"color-secondary-100": "hsl(211.7,21.2%,93.7%)",
|