xmlui 0.11.1 → 0.11.3
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/lib/{index-CEq6OdjV.js → index-DSUDwtWN.js} +68 -39
- package/dist/lib/{initMock-DhUnLKrR.js → initMock-DdH1iCH-.js} +1 -1
- package/dist/lib/language-server-web-worker.js +1 -1
- package/dist/lib/language-server.js +1 -1
- package/dist/lib/{server-common-2DaoOOL5.js → server-common-hq0poDwA.js} +2548 -2464
- package/dist/lib/xmlui.js +1 -1
- package/dist/metadata/{collectedComponentMetadata-BAI5eK2v.js → collectedComponentMetadata-C8Lr9TFe.js} +68 -39
- package/dist/metadata/{initMock-CekNG5Ax.js → initMock-CWwgOjW_.js} +1 -1
- package/dist/metadata/xmlui-metadata.js +1 -1
- package/dist/metadata/xmlui-metadata.umd.cjs +1 -1
- package/dist/scripts/package.json +3 -4
- package/dist/scripts/src/components/Charts/BarChart/BarChartNative.js +10 -4
- package/dist/scripts/src/components/Charts/LineChart/LineChartNative.js +1 -1
- package/dist/scripts/src/components/Splitter/Splitter.js +2 -1
- package/dist/scripts/src/components/Splitter/Splitter.spec.js +88 -0
- package/dist/scripts/src/components/Splitter/SplitterNative.js +38 -14
- package/dist/scripts/src/components/Splitter/utils.js +7 -2
- package/dist/scripts/src/components/Text/Text.js +17 -16
- package/dist/scripts/src/components/Text/Text.spec.js +284 -0
- package/dist/standalone/xmlui-standalone.umd.js +6 -6
- package/package.json +3 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xmlui",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.3",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -99,7 +99,6 @@
|
|
|
99
99
|
"remark-gfm": "^4.0.1",
|
|
100
100
|
"sass": "1.55.0",
|
|
101
101
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
102
|
-
"ts-node": "10.9.1",
|
|
103
102
|
"turndown": "^7.2.0",
|
|
104
103
|
"unist-util-visit": "^5.0.0",
|
|
105
104
|
"use-context-selector": "1.4.1",
|
|
@@ -108,7 +107,8 @@
|
|
|
108
107
|
"vite-plugin-svgr": "4.2.0",
|
|
109
108
|
"vscode-languageserver": "^9.0.1",
|
|
110
109
|
"vscode-languageserver-textdocument": "^1.0.11",
|
|
111
|
-
"yargs": "17.7.2"
|
|
110
|
+
"yargs": "17.7.2",
|
|
111
|
+
"tsx": "4.20.6"
|
|
112
112
|
},
|
|
113
113
|
"devDependencies": {
|
|
114
114
|
"@babel/core": "7.19.6",
|
|
@@ -145,7 +145,6 @@
|
|
|
145
145
|
"rollup-plugin-visualizer": "5.8.3",
|
|
146
146
|
"serve": "14.2.0",
|
|
147
147
|
"terser": "^5.44.0",
|
|
148
|
-
"tsx": "4.20.6",
|
|
149
148
|
"typescript": "5.7.3",
|
|
150
149
|
"vite": "5.4.19",
|
|
151
150
|
"vite-plugin-dts": "4.5.0",
|
|
@@ -119,7 +119,7 @@ function BarChart({ data = [], layout = exports.defaultProps.layout, nameKey, st
|
|
|
119
119
|
payloadArray.push({
|
|
120
120
|
label: dataKey,
|
|
121
121
|
value: originalPayload[dataKey],
|
|
122
|
-
color: colorValues[index] || colorValues[0]
|
|
122
|
+
color: colorValues[index] || colorValues[0],
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
});
|
|
@@ -247,7 +247,7 @@ function BarChart({ data = [], layout = exports.defaultProps.layout, nameKey, st
|
|
|
247
247
|
const customTooltipRenderer = (0, react_1.useCallback)((props) => {
|
|
248
248
|
const tooltipContent = safeTooltipRenderer(props);
|
|
249
249
|
return ((0, jsx_runtime_1.jsx)("div", { ref: (el) => {
|
|
250
|
-
if (el
|
|
250
|
+
if (el) {
|
|
251
251
|
setTooltipElement(el);
|
|
252
252
|
}
|
|
253
253
|
}, children: tooltipContent }));
|
|
@@ -260,7 +260,7 @@ function BarChart({ data = [], layout = exports.defaultProps.layout, nameKey, st
|
|
|
260
260
|
height: miniMode || hideX ? 0 : xAxisHeight,
|
|
261
261
|
tick: miniMode || hideTickX ? false : { fill: "currentColor", fontSize },
|
|
262
262
|
tickFormatter: miniMode || hideTickX ? undefined : tickFormatterX,
|
|
263
|
-
domain: [0, (dataMax) => dataMax * 1.05],
|
|
263
|
+
domain: [0, (dataMax) => Math.ceil((dataMax * 1.05) / 10) * 10],
|
|
264
264
|
}
|
|
265
265
|
: {
|
|
266
266
|
type: "category",
|
|
@@ -293,7 +293,13 @@ function BarChart({ data = [], layout = exports.defaultProps.layout, nameKey, st
|
|
|
293
293
|
tickCount: yTickCount,
|
|
294
294
|
tickFormatter: miniMode || hideTickY ? undefined : tickFormatterY,
|
|
295
295
|
width: miniMode || hideY ? 0 : yAxisWidth,
|
|
296
|
-
domain: [
|
|
296
|
+
domain: [
|
|
297
|
+
0,
|
|
298
|
+
(dataMax) => {
|
|
299
|
+
const roundedMax = Math.ceil((dataMax * 1.05) / 10) * 10;
|
|
300
|
+
return roundedMax;
|
|
301
|
+
},
|
|
302
|
+
],
|
|
297
303
|
};
|
|
298
304
|
return ((0, jsx_runtime_1.jsxs)(ChartProvider_1.default, { value: chartContextValue, children: [children, (0, jsx_runtime_1.jsx)("div", { ref: labelsRef, style: { position: "absolute", visibility: "hidden", height: 0, overflow: "hidden" }, children: validData
|
|
299
305
|
.map((d) => d[nameKey])
|
|
@@ -181,7 +181,7 @@ exports.LineChart = (0, react_1.forwardRef)(function LineChart({ data, dataKeys
|
|
|
181
181
|
? safeData
|
|
182
182
|
.map((d) => d === null || d === void 0 ? void 0 : d[nameKey])
|
|
183
183
|
.map((label, idx) => ((0, jsx_runtime_1.jsx)("span", { style: { fontSize: 12, whiteSpace: "nowrap" }, children: label }, idx)))
|
|
184
|
-
: null }), (0, jsx_runtime_1.jsx)("div", { ref: forwardedRef, className: (0, classnames_1.default)(className, LineChart_module_scss_1.default.wrapper), style: Object.assign({ flexGrow: 1 }, style), children: (0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { ref: containerRef, width: "100%", height: "100%", minWidth: 60, minHeight: 30, debounce: 100, children: (0, jsx_runtime_1.jsxs)(recharts_1.LineChart, { accessibilityLayer: true, data: data, margin: miniMode ? { left: 0, right: 0, top: 0, bottom: 0 } : chartMargin, children: [(0, jsx_runtime_1.jsx)(recharts_1.XAxis, { interval: interval, tickLine: false, dataKey: nameKey, angle: tickAngle, textAnchor: tickAnchor, tick: miniMode ? false : !hideTickX && { fill: "currentColor", fontSize }, tickFormatter: miniMode ? undefined : tickFormatterX, height: miniMode || hideX ? 0 : xAxisHeight, hide: miniMode || hideX }), (0, jsx_runtime_1.jsx)(recharts_1.YAxis, { hide: miniMode || hideY, tickLine: false, tickFormatter: miniMode ? undefined : tickFormatterY, tick: miniMode ? false : !hideTickY && { fill: "currentColor", fontSize }, domain: [
|
|
184
|
+
: null }), (0, jsx_runtime_1.jsx)("div", { ref: forwardedRef, className: (0, classnames_1.default)(className, LineChart_module_scss_1.default.wrapper), style: Object.assign({ flexGrow: 1 }, style), children: (0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { ref: containerRef, width: "100%", height: "100%", minWidth: 60, minHeight: 30, debounce: 100, children: (0, jsx_runtime_1.jsxs)(recharts_1.LineChart, { accessibilityLayer: true, data: data, margin: miniMode ? { left: 0, right: 0, top: 0, bottom: 0 } : chartMargin, children: [(0, jsx_runtime_1.jsx)(recharts_1.XAxis, { interval: interval, tickLine: false, dataKey: nameKey, angle: tickAngle, textAnchor: tickAnchor, tick: miniMode ? false : !hideTickX && { fill: "currentColor", fontSize }, tickFormatter: miniMode ? undefined : tickFormatterX, height: miniMode || hideX ? 0 : xAxisHeight, hide: miniMode || hideX }), (0, jsx_runtime_1.jsx)(recharts_1.YAxis, { hide: miniMode || hideY, tickLine: false, tickFormatter: miniMode ? undefined : tickFormatterY, tick: miniMode ? false : !hideTickY && { fill: "currentColor", fontSize }, domain: [0, (dataMax) => Math.ceil((dataMax * 1.05) / 10) * 10] }), !miniMode && !hideTooltip && (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { content: safeTooltipRenderer }), dataKeys.map((dataKey, i) => ((0, jsx_runtime_1.jsx)(recharts_1.Line, { type: "monotone", dataKey: dataKey, name: dataKey, stroke: colorValues[i], strokeWidth: strokeWidth, dot: false }, dataKey))), showLegend && ((0, jsx_runtime_1.jsx)(recharts_1.Legend, { wrapperStyle: {
|
|
185
185
|
bottom: 0,
|
|
186
186
|
left: 0,
|
|
187
187
|
right: 0,
|
|
@@ -40,7 +40,8 @@ const baseSplitterMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
40
40
|
},
|
|
41
41
|
maxPrimarySize: {
|
|
42
42
|
description: `This property sets the maximum size the primary section can have. The unit of the size ` +
|
|
43
|
-
`value is in pixels or percentages
|
|
43
|
+
`value is in pixels or percentages. Negative values are supported and calculate from the ` +
|
|
44
|
+
`end of the container (e.g., "-20%" means "80% of container", "-100px" means "container size - 100px").`,
|
|
44
45
|
valueType: "string",
|
|
45
46
|
defaultValue: SplitterNative_1.defaultProps.maxPrimarySize,
|
|
46
47
|
},
|
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const component_test_helpers_1 = require("../../testing/component-test-helpers");
|
|
13
13
|
const fixtures_1 = require("../../testing/fixtures");
|
|
14
|
+
const utils_1 = require("./utils");
|
|
14
15
|
// =============================================================================
|
|
15
16
|
// BASIC FUNCTIONALITY TESTS
|
|
16
17
|
// =============================================================================
|
|
@@ -282,6 +283,54 @@ fixtures_1.test.describe("Basic Functionality", () => {
|
|
|
282
283
|
const bounds = yield (0, component_test_helpers_1.getBounds)(primary);
|
|
283
284
|
(0, fixtures_1.expect)(bounds.width).toBeLessThanOrEqual(310); // Allow small tolerance
|
|
284
285
|
}));
|
|
286
|
+
(0, fixtures_1.test)("negative maxPrimarySize in pixels constrains from end", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, createSplitterDriver }) {
|
|
287
|
+
yield initTestBed(`
|
|
288
|
+
<Splitter height="200px" width="400px" orientation="horizontal" maxPrimarySize="-100px" testId="splitter">
|
|
289
|
+
<Stack backgroundColor="lightblue" height="100%" testId="primary"/>
|
|
290
|
+
<Stack backgroundColor="darksalmon" height="100%" testId="secondary"/>
|
|
291
|
+
</Splitter>
|
|
292
|
+
`);
|
|
293
|
+
const splitter = page.getByTestId("splitter");
|
|
294
|
+
const primary = page.getByTestId("primary");
|
|
295
|
+
const driver = yield createSplitterDriver(splitter);
|
|
296
|
+
// Try to drag resizer far to the right
|
|
297
|
+
yield driver.dragResizer(350, 0);
|
|
298
|
+
// Primary should not be larger than 400 - 100 = 300px
|
|
299
|
+
const bounds = yield (0, component_test_helpers_1.getBounds)(primary);
|
|
300
|
+
(0, fixtures_1.expect)(bounds.width).toBeLessThanOrEqual(310); // Allow small tolerance for 300px max
|
|
301
|
+
}));
|
|
302
|
+
(0, fixtures_1.test)("negative maxPrimarySize in percentage constrains from end", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, createSplitterDriver }) {
|
|
303
|
+
yield initTestBed(`
|
|
304
|
+
<Splitter height="200px" width="400px" orientation="horizontal" maxPrimarySize="-25%" testId="splitter">
|
|
305
|
+
<Stack backgroundColor="lightblue" height="100%" testId="primary"/>
|
|
306
|
+
<Stack backgroundColor="darksalmon" height="100%" testId="secondary"/>
|
|
307
|
+
</Splitter>
|
|
308
|
+
`);
|
|
309
|
+
const splitter = page.getByTestId("splitter");
|
|
310
|
+
const primary = page.getByTestId("primary");
|
|
311
|
+
const driver = yield createSplitterDriver(splitter);
|
|
312
|
+
// Try to drag resizer far to the right
|
|
313
|
+
yield driver.dragResizer(350, 0);
|
|
314
|
+
// Primary should not be larger than 75% of 400px = 300px
|
|
315
|
+
const bounds = yield (0, component_test_helpers_1.getBounds)(primary);
|
|
316
|
+
(0, fixtures_1.expect)(bounds.width).toBeLessThanOrEqual(310); // Allow small tolerance for 300px max
|
|
317
|
+
}));
|
|
318
|
+
(0, fixtures_1.test)("negative maxPrimarySize works in vertical orientation", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, createSplitterDriver }) {
|
|
319
|
+
yield initTestBed(`
|
|
320
|
+
<Splitter height="400px" width="200px" orientation="vertical" maxPrimarySize="-100px" testId="splitter">
|
|
321
|
+
<Stack backgroundColor="lightblue" width="100%" testId="primary"/>
|
|
322
|
+
<Stack backgroundColor="darksalmon" width="100%" testId="secondary"/>
|
|
323
|
+
</Splitter>
|
|
324
|
+
`);
|
|
325
|
+
const splitter = page.getByTestId("splitter");
|
|
326
|
+
const primary = page.getByTestId("primary");
|
|
327
|
+
const driver = yield createSplitterDriver(splitter);
|
|
328
|
+
// Try to drag resizer far down
|
|
329
|
+
yield driver.dragResizer(0, 350);
|
|
330
|
+
// Primary should not be larger than 400 - 100 = 300px height
|
|
331
|
+
const bounds = yield (0, component_test_helpers_1.getBounds)(primary);
|
|
332
|
+
(0, fixtures_1.expect)(bounds.height).toBeLessThanOrEqual(310); // Allow small tolerance for 300px max
|
|
333
|
+
}));
|
|
285
334
|
});
|
|
286
335
|
fixtures_1.test.describe("resize event", () => {
|
|
287
336
|
(0, fixtures_1.test)("fires resize event when dragging", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, createSplitterDriver }) {
|
|
@@ -541,3 +590,42 @@ fixtures_1.test.describe("Other Edge Cases", () => {
|
|
|
541
590
|
yield (0, fixtures_1.expect)(page.getByTestId("secondary")).toBeVisible();
|
|
542
591
|
}));
|
|
543
592
|
});
|
|
593
|
+
// =============================================================================
|
|
594
|
+
// UTILITY FUNCTION TESTS
|
|
595
|
+
// =============================================================================
|
|
596
|
+
fixtures_1.test.describe("Utility Functions", () => {
|
|
597
|
+
fixtures_1.test.describe("parseSize", () => {
|
|
598
|
+
(0, fixtures_1.test)("parses positive pixel values", () => {
|
|
599
|
+
(0, fixtures_1.expect)((0, utils_1.parseSize)("100px", 400)).toBe(100);
|
|
600
|
+
(0, fixtures_1.expect)((0, utils_1.parseSize)("200px", 400)).toBe(200);
|
|
601
|
+
});
|
|
602
|
+
(0, fixtures_1.test)("parses positive percentage values", () => {
|
|
603
|
+
(0, fixtures_1.expect)((0, utils_1.parseSize)("50%", 400)).toBe(200);
|
|
604
|
+
(0, fixtures_1.expect)((0, utils_1.parseSize)("25%", 400)).toBe(100);
|
|
605
|
+
(0, fixtures_1.expect)((0, utils_1.parseSize)("100%", 400)).toBe(400);
|
|
606
|
+
});
|
|
607
|
+
(0, fixtures_1.test)("parses negative pixel values (calculated from end)", () => {
|
|
608
|
+
(0, fixtures_1.expect)((0, utils_1.parseSize)("-100px", 400)).toBe(300); // 400 - 100
|
|
609
|
+
(0, fixtures_1.expect)((0, utils_1.parseSize)("-50px", 400)).toBe(350); // 400 - 50
|
|
610
|
+
(0, fixtures_1.expect)((0, utils_1.parseSize)("-200px", 600)).toBe(400); // 600 - 200
|
|
611
|
+
});
|
|
612
|
+
(0, fixtures_1.test)("parses negative percentage values (calculated from end)", () => {
|
|
613
|
+
(0, fixtures_1.expect)((0, utils_1.parseSize)("-20%", 400)).toBe(320); // 80% of 400
|
|
614
|
+
(0, fixtures_1.expect)((0, utils_1.parseSize)("-50%", 400)).toBe(200); // 50% of 400
|
|
615
|
+
(0, fixtures_1.expect)((0, utils_1.parseSize)("-10%", 600)).toBe(540); // 90% of 600
|
|
616
|
+
});
|
|
617
|
+
(0, fixtures_1.test)("throws error for invalid format", () => {
|
|
618
|
+
(0, fixtures_1.expect)(() => (0, utils_1.parseSize)("100", 400)).toThrow("Invalid size format. Use px or %.");
|
|
619
|
+
(0, fixtures_1.expect)(() => (0, utils_1.parseSize)("100em", 400)).toThrow("Invalid size format. Use px or %.");
|
|
620
|
+
(0, fixtures_1.expect)(() => (0, utils_1.parseSize)("invalid", 400)).toThrow("Invalid size format. Use px or %.");
|
|
621
|
+
});
|
|
622
|
+
});
|
|
623
|
+
fixtures_1.test.describe("toPercentage", () => {
|
|
624
|
+
(0, fixtures_1.test)("converts pixel size to percentage", () => {
|
|
625
|
+
(0, fixtures_1.expect)((0, utils_1.toPercentage)(200, 400)).toBe(50);
|
|
626
|
+
(0, fixtures_1.expect)((0, utils_1.toPercentage)(100, 400)).toBe(25);
|
|
627
|
+
(0, fixtures_1.expect)((0, utils_1.toPercentage)(400, 400)).toBe(100);
|
|
628
|
+
(0, fixtures_1.expect)((0, utils_1.toPercentage)(0, 400)).toBe(0);
|
|
629
|
+
});
|
|
630
|
+
});
|
|
631
|
+
});
|
|
@@ -65,41 +65,65 @@ exports.defaultProps = {
|
|
|
65
65
|
const Splitter = (_a) => {
|
|
66
66
|
var _b;
|
|
67
67
|
var { initialPrimarySize = exports.defaultProps.initialPrimarySize, minPrimarySize = exports.defaultProps.minPrimarySize, maxPrimarySize = exports.defaultProps.maxPrimarySize, orientation = exports.defaultProps.orientation, children, style, className, swapped = exports.defaultProps.swapped, floating = exports.defaultProps.floating, splitterTemplate, resize = constants_1.noop } = _a, rest = __rest(_a, ["initialPrimarySize", "minPrimarySize", "maxPrimarySize", "orientation", "children", "style", "className", "swapped", "floating", "splitterTemplate", "resize"]);
|
|
68
|
-
const [
|
|
68
|
+
const [sizePercentage, setSizePercentage] = (0, react_1.useState)(50); // Store as percentage
|
|
69
|
+
const [containerSize, setContainerSize] = (0, react_1.useState)(0);
|
|
69
70
|
const [splitter, setSplitter] = (0, react_1.useState)(null);
|
|
70
71
|
const [resizerVisible, setResizerVisible] = (0, react_1.useState)(false);
|
|
71
72
|
const [resizer, setResizer] = (0, react_1.useState)(null);
|
|
72
73
|
const [floatingResizer, setFloatingResizer] = (0, react_1.useState)(null);
|
|
73
74
|
const resizerElement = (0, react_1.useMemo)(() => (floating ? floatingResizer : resizer), [floating, resizer, floatingResizer]);
|
|
75
|
+
// Calculate actual size in pixels from percentage
|
|
76
|
+
const size = (0, react_1.useMemo)(() => {
|
|
77
|
+
return (sizePercentage / 100) * containerSize;
|
|
78
|
+
}, [sizePercentage, containerSize]);
|
|
79
|
+
// ResizeObserver to track container size changes
|
|
80
|
+
(0, react_1.useEffect)(() => {
|
|
81
|
+
if (!splitter)
|
|
82
|
+
return;
|
|
83
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
84
|
+
for (const entry of entries) {
|
|
85
|
+
const newContainerSize = orientation === "horizontal"
|
|
86
|
+
? entry.contentRect.width
|
|
87
|
+
: entry.contentRect.height;
|
|
88
|
+
setContainerSize(newContainerSize);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
resizeObserver.observe(splitter);
|
|
92
|
+
return () => {
|
|
93
|
+
resizeObserver.disconnect();
|
|
94
|
+
};
|
|
95
|
+
}, [splitter, orientation]);
|
|
96
|
+
// Initialize container size and primary panel percentage
|
|
74
97
|
(0, react_1.useEffect)(() => {
|
|
75
98
|
if (splitter) {
|
|
76
|
-
const
|
|
99
|
+
const newContainerSize = orientation === "horizontal"
|
|
77
100
|
? splitter.getBoundingClientRect().width
|
|
78
101
|
: splitter.getBoundingClientRect().height;
|
|
79
|
-
|
|
80
|
-
|
|
102
|
+
setContainerSize(newContainerSize);
|
|
103
|
+
// Parse initial size and convert to percentage
|
|
104
|
+
const initialParsedSize = (0, utils_1.parseSize)(initialPrimarySize, newContainerSize);
|
|
105
|
+
const initialPercentage = (0, utils_1.toPercentage)(initialParsedSize, newContainerSize);
|
|
106
|
+
setSizePercentage(initialPercentage);
|
|
81
107
|
if (resize) {
|
|
82
108
|
resize([
|
|
83
|
-
|
|
84
|
-
|
|
109
|
+
initialPercentage,
|
|
110
|
+
100 - initialPercentage,
|
|
85
111
|
]);
|
|
86
112
|
}
|
|
87
113
|
}
|
|
88
114
|
}, [initialPrimarySize, orientation, resize, splitter, swapped]);
|
|
89
115
|
(0, react_1.useEffect)(() => {
|
|
90
116
|
const handleMouseMove = (event) => {
|
|
91
|
-
if (splitter && resizerElement) {
|
|
92
|
-
const containerSize = orientation === "horizontal"
|
|
93
|
-
? splitter.getBoundingClientRect().width
|
|
94
|
-
: splitter.getBoundingClientRect().height;
|
|
117
|
+
if (splitter && resizerElement && containerSize > 0) {
|
|
95
118
|
const newSize = orientation === "horizontal"
|
|
96
119
|
? Math.min(Math.max(event.clientX - splitter.getBoundingClientRect().left, (0, utils_1.parseSize)(minPrimarySize, containerSize)), (0, utils_1.parseSize)(maxPrimarySize, containerSize))
|
|
97
120
|
: Math.min(Math.max(event.clientY - splitter.getBoundingClientRect().top, (0, utils_1.parseSize)(minPrimarySize, containerSize)), (0, utils_1.parseSize)(maxPrimarySize, containerSize));
|
|
98
|
-
|
|
121
|
+
const newPercentage = (0, utils_1.toPercentage)(newSize, containerSize);
|
|
122
|
+
setSizePercentage(newPercentage);
|
|
99
123
|
if (resize) {
|
|
100
124
|
resize([
|
|
101
|
-
|
|
102
|
-
|
|
125
|
+
newPercentage,
|
|
126
|
+
100 - newPercentage,
|
|
103
127
|
]);
|
|
104
128
|
}
|
|
105
129
|
}
|
|
@@ -122,7 +146,7 @@ const Splitter = (_a) => {
|
|
|
122
146
|
document.removeEventListener("mousemove", handleMouseMove);
|
|
123
147
|
document.removeEventListener("mouseup", handleMouseUp);
|
|
124
148
|
};
|
|
125
|
-
}, [minPrimarySize, maxPrimarySize, orientation, resize, floating, resizerElement, splitter]);
|
|
149
|
+
}, [minPrimarySize, maxPrimarySize, orientation, resize, floating, resizerElement, splitter, containerSize]);
|
|
126
150
|
(0, react_1.useEffect)(() => {
|
|
127
151
|
const watchResizer = (event) => {
|
|
128
152
|
const cursorPosition = orientation === "horizontal" ? event.clientX : event.clientY;
|
|
@@ -3,10 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.toPercentage = exports.parseSize = void 0;
|
|
4
4
|
const parseSize = (size, containerSize) => {
|
|
5
5
|
if (size.endsWith('px')) {
|
|
6
|
-
|
|
6
|
+
const pixels = parseInt(size, 10);
|
|
7
|
+
// If negative, calculate from the end: containerSize - abs(pixels)
|
|
8
|
+
return pixels < 0 ? containerSize + pixels : pixels;
|
|
7
9
|
}
|
|
8
10
|
else if (size.endsWith('%')) {
|
|
9
|
-
|
|
11
|
+
const percentage = parseInt(size, 10);
|
|
12
|
+
// If negative, calculate from the end: 100% - abs(percentage)
|
|
13
|
+
const actualPercentage = percentage < 0 ? 100 + percentage : percentage;
|
|
14
|
+
return (actualPercentage / 100) * containerSize;
|
|
10
15
|
}
|
|
11
16
|
throw new Error('Invalid size format. Use px or %.');
|
|
12
17
|
};
|
|
@@ -107,15 +107,20 @@ exports.TextMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
107
107
|
[`borderStyle-${COMP}`]: "solid",
|
|
108
108
|
[`fontSize-${COMP}`]: "$fontSize-sm",
|
|
109
109
|
[`borderWidth-${COMP}`]: "$space-0",
|
|
110
|
-
[`lineHeight-${COMP}-codefence`]: "1.5",
|
|
111
|
-
[`fontWeight-${COMP}-abbr`]: "$fontWeight-bold",
|
|
112
|
-
[`textTransform-${COMP}-abbr`]: "uppercase",
|
|
113
|
-
[`fontSize-${COMP}-secondary`]: "$fontSize-sm",
|
|
114
|
-
[`fontStyle-${COMP}-cite`]: "italic",
|
|
115
110
|
[`textColor-${COMP}`]: "$textColor-primary",
|
|
116
111
|
[`fontFamily-${COMP}`]: "$fontFamily",
|
|
117
112
|
[`fontWeight-${COMP}`]: "$fontWeight-normal",
|
|
113
|
+
[`fontSize-${COMP}-secondary`]: "$fontSize-sm",
|
|
114
|
+
[`textColor-${COMP}-secondary`]: "$textColor-secondary",
|
|
115
|
+
[`fontWeight-${COMP}-abbr`]: "$fontWeight-bold",
|
|
116
|
+
[`textTransform-${COMP}-abbr`]: "uppercase",
|
|
117
|
+
[`fontStyle-${COMP}-cite`]: "italic",
|
|
118
118
|
[`fontSize-${COMP}-codefence`]: "$fontSize-code",
|
|
119
|
+
[`fontFamily-${COMP}-codefence`]: "$fontFamily-monospace",
|
|
120
|
+
[`paddingHorizontal-${COMP}-codefence`]: "$space-4",
|
|
121
|
+
[`paddingVertical-${COMP}-codefence`]: "$space-3",
|
|
122
|
+
[`textColor-${COMP}-codefence`]: "$color-surface-900",
|
|
123
|
+
[`lineHeight-${COMP}-codefence`]: "1.5",
|
|
119
124
|
[`fontFamily-${COMP}-code`]: "$fontFamily-monospace",
|
|
120
125
|
[`fontSize-${COMP}-code`]: "$fontSize-sm",
|
|
121
126
|
[`borderWidth-${COMP}-code`]: "1px",
|
|
@@ -123,6 +128,8 @@ exports.TextMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
123
128
|
[`borderRadius-${COMP}-code`]: "4px",
|
|
124
129
|
[`paddingHorizontal-${COMP}-code`]: "$space-0_5",
|
|
125
130
|
[`paddingBottom-${COMP}-code`]: "2px",
|
|
131
|
+
[`backgroundColor-${COMP}-code`]: "rgb(from $color-surface-100 r g b / 0.4)",
|
|
132
|
+
[`borderColor-${COMP}-code`]: "$color-surface-100",
|
|
126
133
|
[`textDecorationLine-${COMP}-deleted`]: "line-through",
|
|
127
134
|
[`textDecorationLine-${COMP}-inserted`]: "underline",
|
|
128
135
|
[`fontFamily-${COMP}-keyboard`]: "$fontFamily-monospace",
|
|
@@ -130,6 +137,8 @@ exports.TextMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
130
137
|
[`fontWeight-${COMP}-keyboard`]: "$fontWeight-bold",
|
|
131
138
|
[`borderWidth-${COMP}-keyboard`]: "1px",
|
|
132
139
|
[`paddingHorizontal-${COMP}-keyboard`]: "$space-1",
|
|
140
|
+
[`backgroundColor-${COMP}-keyboard`]: "rgb(from $color-surface-100 r g b / 0.4)",
|
|
141
|
+
[`borderColor-${COMP}-keyboard`]: "$color-surface-300",
|
|
133
142
|
[`fontFamily-${COMP}-sample`]: "$fontFamily-monospace",
|
|
134
143
|
[`fontSize-${COMP}-sample`]: "$fontSize-sm",
|
|
135
144
|
[`fontSize-${COMP}-sup`]: "$fontSize-xs",
|
|
@@ -144,28 +153,20 @@ exports.TextMd = (0, metadata_helpers_1.createMetadata)({
|
|
|
144
153
|
[`fontSize-${COMP}-small`]: "$fontSize-sm",
|
|
145
154
|
[`letterSpacing-${COMP}-caption`]: "0.05rem",
|
|
146
155
|
[`fontSize-${COMP}-placeholder`]: "$fontSize-xs",
|
|
147
|
-
[`
|
|
148
|
-
[`paddingHorizontal-${COMP}-codefence`]: "$space-4",
|
|
149
|
-
[`paddingVertical-${COMP}-codefence`]: "$space-3",
|
|
156
|
+
[`textColor-${COMP}-placeholder`]: "$color-surface-500",
|
|
150
157
|
[`paddingVertical-${COMP}-paragraph`]: "$space-1",
|
|
151
158
|
[`fontSize-${COMP}-subheading`]: "$fontSize-H6",
|
|
152
159
|
[`fontWeight-${COMP}-subheading`]: "$fontWeight-bold",
|
|
153
160
|
[`letterSpacing-${COMP}-subheading`]: "0.04em",
|
|
154
161
|
[`textTransform-${COMP}-subheading`]: "uppercase",
|
|
162
|
+
[`textColor-${COMP}-subheading`]: "$textColor-secondary",
|
|
155
163
|
[`marginTop-${COMP}-tableheading`]: "$space-1",
|
|
156
164
|
[`marginBottom-${COMP}-tableheading`]: "$space-4",
|
|
157
165
|
[`paddingHorizontal-${COMP}-tableheading`]: "$space-1",
|
|
158
166
|
[`fontSize-${COMP}-tableheading`]: "$fontSize-H6",
|
|
159
167
|
[`fontWeight-${COMP}-tableheading`]: "$fontWeight-bold",
|
|
160
|
-
[`
|
|
161
|
-
[`borderColor-${COMP}-code`]: "$color-surface-100",
|
|
162
|
-
[`backgroundColor-${COMP}-keyboard`]: "rgb(from $color-surface-100 r g b / 0.4)",
|
|
163
|
-
[`borderColor-${COMP}-keyboard`]: "$color-surface-300",
|
|
168
|
+
[`fontWeight-${COMP}-strong`]: "$fontWeight-bold",
|
|
164
169
|
[`backgroundColor-${COMP}-marked`]: "rgb(from $color-primary-200 r g b / 0.4)",
|
|
165
|
-
[`textColor-${COMP}-placeholder`]: "$color-surface-500",
|
|
166
|
-
[`textColor-${COMP}-codefence`]: "$color-surface-900",
|
|
167
|
-
[`textColor-${COMP}-subheading`]: "$textColor-secondary",
|
|
168
|
-
[`textColor-${COMP}-secondary`]: "$textColor-secondary",
|
|
169
170
|
dark: {
|
|
170
171
|
[`backgroundColor-${COMP}-marked`]: "rgb(from $color-primary-400 r g b / 0.4)",
|
|
171
172
|
},
|