@canvas-components/utils 0.2.3 → 0.2.4

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/index.d.cts CHANGED
@@ -4,3 +4,35 @@ export { ValueDataIndex, getValueByDataIndex, isSameDataIndex, stringifyDataInde
4
4
  export { formatDateTimeValue, isDateTimeFormatPattern, resolveDateValue } from './date/index.cjs';
5
5
  export { clamp, isPointInRect } from './geometry/index.cjs';
6
6
  export { ChineseNumberStyle, NumberFormatOptions, PreciseNumberInput, PreciseRoundingMode, addPreciseNumbers, comparePreciseNumbers, dividePreciseNumber, formatChineseNumber, formatCustomNumberPattern, formatNumberValue, formatPercentValue, formatPreciseNumber, formatScientificValue, normalizeDecimalPlaces, parseChineseNumber, parseNumberValue, roundPreciseNumber, sumPreciseNumbers } from './number/index.cjs';
7
+
8
+ /** 单轴 Canvas 滚动条样式。尺寸单位均为 CSS 像素。 */
9
+ interface CanvasScrollbarAxisOptions {
10
+ /** 是否显示;隐藏不禁用滚轮或程序滚动。 */
11
+ visible?: boolean;
12
+ /** 横向高度 / 纵向宽度,默认 10,最小 6。 */
13
+ thickness?: number;
14
+ /** 滑块填充颜色。 */
15
+ thumbColor?: string;
16
+ /** 滚动槽背景颜色,不传时保持表格背景。 */
17
+ trackColor?: string;
18
+ /** 两端箭头颜色。 */
19
+ buttonColor?: string;
20
+ /** 滑块圆角;不传时保持胶囊形状。 */
21
+ thumbRadius?: number;
22
+ }
23
+ /** 通用样式由单轴配置覆盖;全局 visible: false 隐藏两个方向。 */
24
+ interface CanvasScrollbarOptions extends CanvasScrollbarAxisOptions {
25
+ horizontal?: CanvasScrollbarAxisOptions | false;
26
+ vertical?: CanvasScrollbarAxisOptions | false;
27
+ }
28
+ /** 合并通用与单轴配置,并归一化无效尺寸。 */
29
+ declare function resolveCanvasScrollbarAxis(options: CanvasScrollbarOptions | undefined, axis: "horizontal" | "vertical"): {
30
+ visible: boolean;
31
+ thickness: number;
32
+ thumbColor: string;
33
+ trackColor: string | undefined;
34
+ buttonColor: string;
35
+ thumbRadius: number | undefined;
36
+ };
37
+
38
+ export { type CanvasScrollbarAxisOptions, type CanvasScrollbarOptions, resolveCanvasScrollbarAxis };
package/dist/index.d.ts CHANGED
@@ -4,3 +4,35 @@ export { ValueDataIndex, getValueByDataIndex, isSameDataIndex, stringifyDataInde
4
4
  export { formatDateTimeValue, isDateTimeFormatPattern, resolveDateValue } from './date/index.js';
5
5
  export { clamp, isPointInRect } from './geometry/index.js';
6
6
  export { ChineseNumberStyle, NumberFormatOptions, PreciseNumberInput, PreciseRoundingMode, addPreciseNumbers, comparePreciseNumbers, dividePreciseNumber, formatChineseNumber, formatCustomNumberPattern, formatNumberValue, formatPercentValue, formatPreciseNumber, formatScientificValue, normalizeDecimalPlaces, parseChineseNumber, parseNumberValue, roundPreciseNumber, sumPreciseNumbers } from './number/index.js';
7
+
8
+ /** 单轴 Canvas 滚动条样式。尺寸单位均为 CSS 像素。 */
9
+ interface CanvasScrollbarAxisOptions {
10
+ /** 是否显示;隐藏不禁用滚轮或程序滚动。 */
11
+ visible?: boolean;
12
+ /** 横向高度 / 纵向宽度,默认 10,最小 6。 */
13
+ thickness?: number;
14
+ /** 滑块填充颜色。 */
15
+ thumbColor?: string;
16
+ /** 滚动槽背景颜色,不传时保持表格背景。 */
17
+ trackColor?: string;
18
+ /** 两端箭头颜色。 */
19
+ buttonColor?: string;
20
+ /** 滑块圆角;不传时保持胶囊形状。 */
21
+ thumbRadius?: number;
22
+ }
23
+ /** 通用样式由单轴配置覆盖;全局 visible: false 隐藏两个方向。 */
24
+ interface CanvasScrollbarOptions extends CanvasScrollbarAxisOptions {
25
+ horizontal?: CanvasScrollbarAxisOptions | false;
26
+ vertical?: CanvasScrollbarAxisOptions | false;
27
+ }
28
+ /** 合并通用与单轴配置,并归一化无效尺寸。 */
29
+ declare function resolveCanvasScrollbarAxis(options: CanvasScrollbarOptions | undefined, axis: "horizontal" | "vertical"): {
30
+ visible: boolean;
31
+ thickness: number;
32
+ thumbColor: string;
33
+ trackColor: string | undefined;
34
+ buttonColor: string;
35
+ thumbRadius: number | undefined;
36
+ };
37
+
38
+ export { type CanvasScrollbarAxisOptions, type CanvasScrollbarOptions, resolveCanvasScrollbarAxis };
package/dist/index.js CHANGED
@@ -753,6 +753,21 @@ function isPointInRect(x, y, rect) {
753
753
  return x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height;
754
754
  }
755
755
 
756
+ // src/canvas-scrollbar.ts
757
+ function resolveCanvasScrollbarAxis(options, axis) {
758
+ const override = options?.[axis];
759
+ const merged = { ...options, ...override };
760
+ const thickness = Number.isFinite(merged.thickness) ? Math.max(merged.thickness, 6) : 10;
761
+ return {
762
+ visible: options?.visible !== false && override !== false && merged.visible !== false,
763
+ thickness,
764
+ thumbColor: merged.thumbColor ?? "rgba(100, 116, 139, 0.8)",
765
+ trackColor: merged.trackColor,
766
+ buttonColor: merged.buttonColor ?? "rgba(71, 85, 105, 0.88)",
767
+ thumbRadius: Number.isFinite(merged.thumbRadius) ? Math.max(merged.thumbRadius, 0) : void 0
768
+ };
769
+ }
770
+
756
771
  // src/number/precise.ts
757
772
  function addPreciseNumbers(left, right) {
758
773
  const leftParts = parseDecimal(left);
@@ -1134,6 +1149,6 @@ function resolveThousandsSeparator(separator) {
1134
1149
  return ",";
1135
1150
  }
1136
1151
 
1137
- export { addPreciseNumbers, buildCsvContent, buildTxtContent, clamp, comparePreciseNumbers, copyJson, copyRows, copyText, copyTextSync, dividePreciseNumber, downloadJsonFile, exportTableToCsv, exportTableToTxt, exportTableToXlsx, formatChineseNumber, formatCustomNumberPattern, formatDateTimeValue, formatNumberValue, formatPercentValue, formatPreciseNumber, formatRowsForClipboard, formatScientificValue, getValueByDataIndex, isDateTimeFormatPattern, isPointInRect, isSameDataIndex, mapRowsToExportRecords, normalizeDecimalPlaces, parseChineseNumber, parseNumberValue, resolveDateValue, roundPreciseNumber, serializeCsvRows, stringifyDataIndex, sumPreciseNumbers };
1152
+ export { addPreciseNumbers, buildCsvContent, buildTxtContent, clamp, comparePreciseNumbers, copyJson, copyRows, copyText, copyTextSync, dividePreciseNumber, downloadJsonFile, exportTableToCsv, exportTableToTxt, exportTableToXlsx, formatChineseNumber, formatCustomNumberPattern, formatDateTimeValue, formatNumberValue, formatPercentValue, formatPreciseNumber, formatRowsForClipboard, formatScientificValue, getValueByDataIndex, isDateTimeFormatPattern, isPointInRect, isSameDataIndex, mapRowsToExportRecords, normalizeDecimalPlaces, parseChineseNumber, parseNumberValue, resolveCanvasScrollbarAxis, resolveDateValue, roundPreciseNumber, serializeCsvRows, stringifyDataIndex, sumPreciseNumbers };
1138
1153
  //# sourceMappingURL=index.js.map
1139
1154
  //# sourceMappingURL=index.js.map