@number10/jsx-components 5.0.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/LICENSE +667 -0
- package/README.md +43 -0
- package/dist/Accordion.cjs +1 -0
- package/dist/Accordion.d.ts +43 -0
- package/dist/Accordion.d.ts.map +1 -0
- package/dist/Accordion.js +71 -0
- package/dist/Accordion.test.d.ts +2 -0
- package/dist/Accordion.test.d.ts.map +1 -0
- package/dist/ActivityIndicator.cjs +1 -0
- package/dist/ActivityIndicator.d.ts +21 -0
- package/dist/ActivityIndicator.d.ts.map +1 -0
- package/dist/ActivityIndicator.js +133 -0
- package/dist/AlertDialog.cjs +1 -0
- package/dist/AlertDialog.d.ts +53 -0
- package/dist/AlertDialog.d.ts.map +1 -0
- package/dist/AlertDialog.js +76 -0
- package/dist/Badge.cjs +1 -0
- package/dist/Badge.d.ts +96 -0
- package/dist/Badge.d.ts.map +1 -0
- package/dist/Badge.js +238 -0
- package/dist/Badge.test.d.ts +2 -0
- package/dist/Badge.test.d.ts.map +1 -0
- package/dist/BottomSheet.cjs +1 -0
- package/dist/BottomSheet.d.ts +72 -0
- package/dist/BottomSheet.d.ts.map +1 -0
- package/dist/BottomSheet.js +132 -0
- package/dist/Button.cjs +1 -0
- package/dist/Button.d.ts +61 -0
- package/dist/Button.d.ts.map +1 -0
- package/dist/Button.js +251 -0
- package/dist/Checkbox.cjs +1 -0
- package/dist/Checkbox.d.ts +40 -0
- package/dist/Checkbox.d.ts.map +1 -0
- package/dist/Checkbox.js +84 -0
- package/dist/Checkbox.test.d.ts +2 -0
- package/dist/Checkbox.test.d.ts.map +1 -0
- package/dist/ColorPicker.cjs +1 -0
- package/dist/ColorPicker.d.ts +48 -0
- package/dist/ColorPicker.d.ts.map +1 -0
- package/dist/ColorPicker.js +256 -0
- package/dist/DebugPanel.cjs +1 -0
- package/dist/DebugPanel.d.ts +63 -0
- package/dist/DebugPanel.d.ts.map +1 -0
- package/dist/DebugPanel.js +116 -0
- package/dist/Dialog.cjs +1 -0
- package/dist/Dialog.d.ts +59 -0
- package/dist/Dialog.d.ts.map +1 -0
- package/dist/Dialog.js +142 -0
- package/dist/Divider.cjs +1 -0
- package/dist/Divider.d.ts +19 -0
- package/dist/Divider.d.ts.map +1 -0
- package/dist/Divider.js +15 -0
- package/dist/Divider.test.d.ts +2 -0
- package/dist/Divider.test.d.ts.map +1 -0
- package/dist/Dropdown.cjs +1 -0
- package/dist/Dropdown.d.ts +35 -0
- package/dist/Dropdown.d.ts.map +1 -0
- package/dist/Dropdown.js +222 -0
- package/dist/Icon.cjs +1 -0
- package/dist/Icon.d.ts +71 -0
- package/dist/Icon.d.ts.map +1 -0
- package/dist/Icon.js +57 -0
- package/dist/Icon.test.d.ts +2 -0
- package/dist/Icon.test.d.ts.map +1 -0
- package/dist/Image.cjs +1 -0
- package/dist/Image.d.ts +10 -0
- package/dist/Image.d.ts.map +1 -0
- package/dist/Image.js +18 -0
- package/dist/Joystick.cjs +1 -0
- package/dist/Joystick.d.ts +32 -0
- package/dist/Joystick.d.ts.map +1 -0
- package/dist/Joystick.js +185 -0
- package/dist/ListBox.cjs +1 -0
- package/dist/ListBox.d.ts +67 -0
- package/dist/ListBox.d.ts.map +1 -0
- package/dist/ListBox.js +104 -0
- package/dist/ListBox.test.d.ts +2 -0
- package/dist/ListBox.test.d.ts.map +1 -0
- package/dist/MenuButton.cjs +1 -0
- package/dist/MenuButton.d.ts +33 -0
- package/dist/MenuButton.d.ts.map +1 -0
- package/dist/MenuButton.js +63 -0
- package/dist/Modal.cjs +1 -0
- package/dist/Modal.d.ts +27 -0
- package/dist/Modal.d.ts.map +1 -0
- package/dist/Modal.js +174 -0
- package/dist/Modal.test.d.ts +2 -0
- package/dist/Modal.test.d.ts.map +1 -0
- package/dist/NineSlice.cjs +1 -0
- package/dist/NineSlice.d.ts +40 -0
- package/dist/NineSlice.d.ts.map +1 -0
- package/dist/NineSlice.js +314 -0
- package/dist/NineSlice.props.test.d.ts +2 -0
- package/dist/NineSlice.props.test.d.ts.map +1 -0
- package/dist/NineSlice.test.d.ts +2 -0
- package/dist/NineSlice.test.d.ts.map +1 -0
- package/dist/NineSliceButton.cjs +1 -0
- package/dist/NineSliceButton.d.ts +94 -0
- package/dist/NineSliceButton.d.ts.map +1 -0
- package/dist/NineSliceButton.js +61 -0
- package/dist/NineSliceButton.test.d.ts +2 -0
- package/dist/NineSliceButton.test.d.ts.map +1 -0
- package/dist/NumberInput.cjs +1 -0
- package/dist/NumberInput.d.ts +90 -0
- package/dist/NumberInput.d.ts.map +1 -0
- package/dist/NumberInput.js +222 -0
- package/dist/NumberInput.test.d.ts +2 -0
- package/dist/NumberInput.test.d.ts.map +1 -0
- package/dist/PalettePicker.cjs +1 -0
- package/dist/PalettePicker.d.ts +49 -0
- package/dist/PalettePicker.d.ts.map +1 -0
- package/dist/PalettePicker.js +152 -0
- package/dist/PalettePicker.test.d.ts +2 -0
- package/dist/PalettePicker.test.d.ts.map +1 -0
- package/dist/Popover.cjs +1 -0
- package/dist/Popover.d.ts +95 -0
- package/dist/Popover.d.ts.map +1 -0
- package/dist/Popover.js +267 -0
- package/dist/Portal.cjs +1 -0
- package/dist/Portal.d.ts +30 -0
- package/dist/Portal.d.ts.map +1 -0
- package/dist/Portal.js +64 -0
- package/dist/Portal.test.d.ts +2 -0
- package/dist/Portal.test.d.ts.map +1 -0
- package/dist/ProgressBar.cjs +1 -0
- package/dist/ProgressBar.d.ts +61 -0
- package/dist/ProgressBar.d.ts.map +1 -0
- package/dist/ProgressBar.js +80 -0
- package/dist/ProgressBar.test.d.ts +2 -0
- package/dist/ProgressBar.test.d.ts.map +1 -0
- package/dist/ProgressView.cjs +1 -0
- package/dist/ProgressView.d.ts +37 -0
- package/dist/ProgressView.d.ts.map +1 -0
- package/dist/ProgressView.js +71 -0
- package/dist/RadioButton.cjs +1 -0
- package/dist/RadioButton.d.ts +21 -0
- package/dist/RadioButton.d.ts.map +1 -0
- package/dist/RadioButton.js +53 -0
- package/dist/RadioGroup.cjs +1 -0
- package/dist/RadioGroup.d.ts +26 -0
- package/dist/RadioGroup.d.ts.map +1 -0
- package/dist/RadioGroup.js +32 -0
- package/dist/RatingBar.cjs +1 -0
- package/dist/RatingBar.d.ts +24 -0
- package/dist/RatingBar.d.ts.map +1 -0
- package/dist/RatingBar.js +84 -0
- package/dist/ScrollSlider.cjs +1 -0
- package/dist/ScrollSlider.d.ts +48 -0
- package/dist/ScrollSlider.d.ts.map +1 -0
- package/dist/ScrollSlider.js +93 -0
- package/dist/ScrollView.cjs +1 -0
- package/dist/ScrollView.d.ts +121 -0
- package/dist/ScrollView.d.ts.map +1 -0
- package/dist/ScrollView.js +541 -0
- package/dist/ScrollView.test.d.ts +2 -0
- package/dist/ScrollView.test.d.ts.map +1 -0
- package/dist/SegmentedControl.cjs +1 -0
- package/dist/SegmentedControl.d.ts +50 -0
- package/dist/SegmentedControl.d.ts.map +1 -0
- package/dist/SegmentedControl.js +201 -0
- package/dist/SegmentedControl.test.d.ts +2 -0
- package/dist/SegmentedControl.test.d.ts.map +1 -0
- package/dist/Sidebar.cjs +1 -0
- package/dist/Sidebar.d.ts +36 -0
- package/dist/Sidebar.d.ts.map +1 -0
- package/dist/Sidebar.js +122 -0
- package/dist/Slider.cjs +1 -0
- package/dist/Slider.d.ts +80 -0
- package/dist/Slider.d.ts.map +1 -0
- package/dist/Slider.js +233 -0
- package/dist/Tabs.cjs +1 -0
- package/dist/Tabs.d.ts +23 -0
- package/dist/Tabs.d.ts.map +1 -0
- package/dist/Tabs.js +101 -0
- package/dist/TextInput.cjs +17 -0
- package/dist/TextInput.d.ts +82 -0
- package/dist/TextInput.d.ts.map +1 -0
- package/dist/TextInput.js +441 -0
- package/dist/Toast.cjs +1 -0
- package/dist/Toast.d.ts +66 -0
- package/dist/Toast.d.ts.map +1 -0
- package/dist/Toast.js +188 -0
- package/dist/Toast.test.d.ts +2 -0
- package/dist/Toast.test.d.ts.map +1 -0
- package/dist/Toggle.cjs +1 -0
- package/dist/Toggle.d.ts +14 -0
- package/dist/Toggle.d.ts.map +1 -0
- package/dist/Toggle.js +135 -0
- package/dist/Toolbar.cjs +1 -0
- package/dist/Toolbar.d.ts +129 -0
- package/dist/Toolbar.d.ts.map +1 -0
- package/dist/Toolbar.js +159 -0
- package/dist/Toolbar.test.d.ts +2 -0
- package/dist/Toolbar.test.d.ts.map +1 -0
- package/dist/TransformOriginView.cjs +1 -0
- package/dist/TransformOriginView.d.ts +8 -0
- package/dist/TransformOriginView.d.ts.map +1 -0
- package/dist/TransformOriginView.js +38 -0
- package/dist/WheelPicker.cjs +1 -0
- package/dist/WheelPicker.d.ts +58 -0
- package/dist/WheelPicker.d.ts.map +1 -0
- package/dist/WheelPicker.js +167 -0
- package/dist/WrapText.cjs +1 -0
- package/dist/WrapText.d.ts +83 -0
- package/dist/WrapText.d.ts.map +1 -0
- package/dist/WrapText.js +93 -0
- package/dist/WrapText.test.d.ts +2 -0
- package/dist/WrapText.test.d.ts.map +1 -0
- package/dist/contrast-slot-map.d.ts +33 -0
- package/dist/contrast-slot-map.d.ts.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +54 -0
- package/dist/primitives/Image.cjs +1 -0
- package/dist/primitives/Image.d.ts +11 -0
- package/dist/primitives/Image.d.ts.map +1 -0
- package/dist/primitives/Image.js +7 -0
- package/dist/primitives/Sprite.cjs +1 -0
- package/dist/primitives/Sprite.d.ts +11 -0
- package/dist/primitives/Sprite.d.ts.map +1 -0
- package/dist/primitives/Sprite.js +7 -0
- package/dist/primitives/Text.cjs +1 -0
- package/dist/primitives/Text.d.ts +14 -0
- package/dist/primitives/Text.d.ts.map +1 -0
- package/dist/primitives/Text.js +15 -0
- package/dist/primitives/VectorDrawContent.cjs +1 -0
- package/dist/primitives/VectorDrawContent.d.ts +3 -0
- package/dist/primitives/VectorDrawContent.d.ts.map +1 -0
- package/dist/primitives/VectorDrawContent.js +7 -0
- package/dist/primitives/View.cjs +1 -0
- package/dist/primitives/View.d.ts +13 -0
- package/dist/primitives/View.d.ts.map +1 -0
- package/dist/primitives/View.js +7 -0
- package/dist/primitives/index.d.ts +13 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/primitives.test.d.ts +2 -0
- package/dist/primitives/primitives.test.d.ts.map +1 -0
- package/dist/primitives.cjs +1 -0
- package/dist/primitives.d.ts +2 -0
- package/dist/primitives.js +6 -0
- package/dist/theme-defaults.cjs +1 -0
- package/dist/theme-defaults.d.ts +12 -0
- package/dist/theme-defaults.d.ts.map +1 -0
- package/dist/theme-defaults.js +1288 -0
- package/dist/theme-defaults.test.d.ts +2 -0
- package/dist/theme-defaults.test.d.ts.map +1 -0
- package/dist/theme-types.cjs +0 -0
- package/dist/theme-types.d.ts +708 -0
- package/dist/theme-types.d.ts.map +1 -0
- package/dist/theme-types.js +0 -0
- package/dist/useOverlayPresence.cjs +1 -0
- package/dist/useOverlayPresence.d.ts +24 -0
- package/dist/useOverlayPresence.d.ts.map +1 -0
- package/dist/useOverlayPresence.js +19 -0
- package/package.json +83 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { ChildrenType, VNodeLike } from '@number10/jsx-core';
|
|
2
|
+
import { PortableComponentPartialTheme } from './theme-types';
|
|
3
|
+
export type PopoverPlacement = 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end';
|
|
4
|
+
export interface OverlayAnchorRect {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
}
|
|
10
|
+
export interface OverlayContentSize {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}
|
|
14
|
+
export interface OverlayPositionOptions {
|
|
15
|
+
anchor: OverlayAnchorRect;
|
|
16
|
+
content: OverlayContentSize;
|
|
17
|
+
placement: PopoverPlacement;
|
|
18
|
+
offset: number;
|
|
19
|
+
viewport?: OverlayContentSize | undefined;
|
|
20
|
+
viewportPadding?: number | undefined;
|
|
21
|
+
}
|
|
22
|
+
export interface OverlayPosition {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
placement: PopoverPlacement;
|
|
26
|
+
}
|
|
27
|
+
export interface PopoverProps {
|
|
28
|
+
/** Unique key for VDOM identification. */
|
|
29
|
+
key?: string | number | undefined;
|
|
30
|
+
/** Trigger content rendered in normal layout. */
|
|
31
|
+
trigger: ChildrenType;
|
|
32
|
+
/** Overlay content rendered through Portal. */
|
|
33
|
+
children: ChildrenType;
|
|
34
|
+
/** Controlled open state. */
|
|
35
|
+
isOpen?: boolean;
|
|
36
|
+
/** Initial open state for uncontrolled usage. */
|
|
37
|
+
defaultOpen?: boolean;
|
|
38
|
+
/** Called when open state should change. */
|
|
39
|
+
onOpenChange?: (open: boolean) => void;
|
|
40
|
+
/** Placement relative to the trigger. */
|
|
41
|
+
placement?: PopoverPlacement;
|
|
42
|
+
/** Distance between trigger and content. */
|
|
43
|
+
offset?: number;
|
|
44
|
+
/** Portal depth. */
|
|
45
|
+
depth?: number;
|
|
46
|
+
/** Close when clicking outside. */
|
|
47
|
+
closeOnOutside?: boolean;
|
|
48
|
+
/** Close on Escape key. */
|
|
49
|
+
closeOnEscape?: boolean;
|
|
50
|
+
/** Disable trigger interaction. */
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
/** Optional fixed width override. By default Popover measures its content after layout. */
|
|
53
|
+
contentWidth?: number;
|
|
54
|
+
/** Optional fixed height override. By default Popover measures its content after layout. */
|
|
55
|
+
contentHeight?: number;
|
|
56
|
+
/** Use trigger width for content width. */
|
|
57
|
+
matchTriggerWidth?: boolean;
|
|
58
|
+
/** Padding inside the viewport clamp. */
|
|
59
|
+
viewportPadding?: number;
|
|
60
|
+
/** Custom effect name for showing overlay content. */
|
|
61
|
+
openEffect?: string;
|
|
62
|
+
/** Custom effect name for hiding overlay content. */
|
|
63
|
+
closeEffect?: string;
|
|
64
|
+
/** Open animation duration in milliseconds. */
|
|
65
|
+
openDuration?: number;
|
|
66
|
+
/** Close animation duration in milliseconds. */
|
|
67
|
+
closeDuration?: number;
|
|
68
|
+
/** Props applied to the trigger wrapper. */
|
|
69
|
+
triggerProps?: Record<string, unknown>;
|
|
70
|
+
/** Props applied to the content wrapper. */
|
|
71
|
+
contentProps?: Record<string, unknown>;
|
|
72
|
+
/** Theme overrides. */
|
|
73
|
+
theme?: PortableComponentPartialTheme<'Popover'>;
|
|
74
|
+
}
|
|
75
|
+
export interface ContextMenuItem {
|
|
76
|
+
id: string;
|
|
77
|
+
label: string;
|
|
78
|
+
disabled?: boolean;
|
|
79
|
+
danger?: boolean;
|
|
80
|
+
prefix?: ChildrenType;
|
|
81
|
+
suffix?: ChildrenType;
|
|
82
|
+
onSelect?: () => void;
|
|
83
|
+
}
|
|
84
|
+
export interface ContextMenuProps extends Omit<PopoverProps, 'children' | 'contentWidth' | 'contentHeight' | 'contentProps' | 'matchTriggerWidth'> {
|
|
85
|
+
/** Menu items shown in the context menu. */
|
|
86
|
+
items: ContextMenuItem[];
|
|
87
|
+
/** Menu width. */
|
|
88
|
+
width?: number;
|
|
89
|
+
/** Called when an item is selected. */
|
|
90
|
+
onSelect?: (item: ContextMenuItem) => void;
|
|
91
|
+
}
|
|
92
|
+
export declare function calculateOverlayPosition(options: OverlayPositionOptions): OverlayPosition;
|
|
93
|
+
export declare function Popover(props: PopoverProps): VNodeLike;
|
|
94
|
+
export declare function ContextMenu(props: ContextMenuProps): VNodeLike;
|
|
95
|
+
//# sourceMappingURL=Popover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../src/Popover.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C;;;;;;;GAOG;AACH,OAAO,KAAK,EACV,YAAY,EAMZ,SAAS,EACV,MAAM,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AAA;CACtB;AAED,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAC5C,YAAY,EACZ,UAAU,GAAG,cAAc,GAAG,eAAe,GAAG,cAAc,GAAG,mBAAmB,CACrF;IACC,4CAA4C;IAC5C,KAAK,EAAE,eAAe,EAAE,CAAA;IACxB,kBAAkB;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,uCAAuC;IACvC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAA;CAC3C;AAcD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,sBAAsB,GAAG,eAAe,CAiCzF;AAqED,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,CA8OtD;AAMD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,SAAS,CA4F9D"}
|
package/dist/Popover.js
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { Text as e } from "./primitives/Text.js";
|
|
2
|
+
import { View as t } from "./primitives/View.js";
|
|
3
|
+
import "./primitives.js";
|
|
4
|
+
import { Portal as n } from "./Portal.js";
|
|
5
|
+
import { useOverlayPresence as r } from "./useOverlayPresence.js";
|
|
6
|
+
import { DeferredLayoutQueue as i, KNOWN_COMPONENTS as a, applyEffect as o, getGlobalThemeDefaults as s, mergeThemes as c, resolveComponentTheme as l, stopEffect as u, useEffect as d, useRef as f, useState as p, useTheme as m, useViewportSize as h } from "@number10/jsx-core";
|
|
7
|
+
import { Fragment as g, jsx as _, jsxs as v } from "@number10/jsx-core/jsx-runtime";
|
|
8
|
+
//#region src/Popover.tsx
|
|
9
|
+
function y(e) {
|
|
10
|
+
return e.split("-")[0];
|
|
11
|
+
}
|
|
12
|
+
function b(e) {
|
|
13
|
+
return e.split("-")[1] ?? "center";
|
|
14
|
+
}
|
|
15
|
+
function x(e) {
|
|
16
|
+
let { anchor: t, content: n, placement: r, offset: i } = e, a = y(r), o = b(r), s, c;
|
|
17
|
+
a === "top" || a === "bottom" ? (c = a === "top" ? t.y - n.height - i : t.y + t.height + i, s = o === "start" ? t.x : o === "end" ? t.x + t.width - n.width : t.x + (t.width - n.width) / 2) : (s = a === "left" ? t.x - n.width - i : t.x + t.width + i, c = o === "start" ? t.y : o === "end" ? t.y + t.height - n.height : t.y + (t.height - n.height) / 2);
|
|
18
|
+
let l = e.viewport;
|
|
19
|
+
if (l) {
|
|
20
|
+
let t = e.viewportPadding ?? 8;
|
|
21
|
+
s = Math.min(Math.max(t, s), Math.max(t, l.width - n.width - t)), c = Math.min(Math.max(t, c), Math.max(t, l.height - n.height - t));
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
x: s,
|
|
25
|
+
y: c,
|
|
26
|
+
placement: r
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function S(e) {
|
|
30
|
+
return e?.__getLayoutSize?.() ?? e?.__cachedLayoutSize ?? {
|
|
31
|
+
width: 0,
|
|
32
|
+
height: 0
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function C(e) {
|
|
36
|
+
let t = e;
|
|
37
|
+
if (typeof t.getAbsolutePosition == "function") {
|
|
38
|
+
let e = t.getAbsolutePosition();
|
|
39
|
+
return {
|
|
40
|
+
x: e.x,
|
|
41
|
+
y: e.y
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
let n = e;
|
|
45
|
+
if (typeof n.getGlobalPosition == "function") {
|
|
46
|
+
let e = n.getGlobalPosition();
|
|
47
|
+
return {
|
|
48
|
+
x: e.x,
|
|
49
|
+
y: e.y
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
let r = e.x ?? 0, i = e.y ?? 0, a = e.parent;
|
|
53
|
+
for (; a;) r += a.x ?? 0, i += a.y ?? 0, a = a.parent;
|
|
54
|
+
return {
|
|
55
|
+
x: r,
|
|
56
|
+
y: i
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function w(e) {
|
|
60
|
+
if (!e) return {
|
|
61
|
+
x: 0,
|
|
62
|
+
y: 0,
|
|
63
|
+
width: 0,
|
|
64
|
+
height: 0
|
|
65
|
+
};
|
|
66
|
+
let t = S(e), n = C(e);
|
|
67
|
+
return {
|
|
68
|
+
x: n.x,
|
|
69
|
+
y: n.y,
|
|
70
|
+
width: t.width,
|
|
71
|
+
height: t.height
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
var T = {
|
|
75
|
+
width: 220,
|
|
76
|
+
height: 120
|
|
77
|
+
};
|
|
78
|
+
function E(e, t) {
|
|
79
|
+
if (e) {
|
|
80
|
+
if (typeof e == "function") {
|
|
81
|
+
e(t);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
e.current = t;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function D(e) {
|
|
88
|
+
let y = m(), b = e.theme ? c(y ?? {}, e.theme) : y, { props: C, nestedTheme: D } = l({
|
|
89
|
+
componentName: "Popover",
|
|
90
|
+
globalTheme: s(),
|
|
91
|
+
localTheme: b,
|
|
92
|
+
knownComponents: a
|
|
93
|
+
}), O = f(null), k = f(null), [A, j] = p(null), [ee, te] = p(e.defaultOpen ?? !1), M = e.isOpen !== void 0, N = M ? e.isOpen === !0 : ee, P = r(N), ne = e.placement ?? C.placement ?? "bottom", re = e.offset ?? C.offset ?? 8, ie = e.depth ?? C.depth ?? 1100, ae = e.closeOnOutside ?? C.closeOnOutside ?? !0, F = e.closeOnEscape ?? C.closeOnEscape ?? !0, I = e.viewportPadding ?? C.viewportPadding ?? 8, oe = e.openEffect ?? C.openEffect ?? "fadeIn", se = e.closeEffect ?? C.closeEffect ?? "fadeOut", L = e.openDuration ?? C.openDuration ?? 120, R = e.closeDuration ?? C.closeDuration ?? 100, z = e.contentWidth ?? C.contentWidth, B = e.contentHeight ?? C.contentHeight, V = h(), [H, U] = p(w(O.current)), W = A?.width ?? T.width, G = A?.height ?? T.height, K = z === void 0 || B === void 0, q = !K || A !== null, J = e.matchTriggerWidth ? Math.max(H.width, z ?? W) : z ?? W, Y = x({
|
|
94
|
+
anchor: H,
|
|
95
|
+
content: {
|
|
96
|
+
width: J,
|
|
97
|
+
height: B ?? G
|
|
98
|
+
},
|
|
99
|
+
placement: ne,
|
|
100
|
+
offset: re,
|
|
101
|
+
viewport: V,
|
|
102
|
+
viewportPadding: I
|
|
103
|
+
}), X = (t) => {
|
|
104
|
+
e.disabled && t || (M || te(t), e.onOpenChange?.(t));
|
|
105
|
+
}, ce = (e) => {
|
|
106
|
+
e.stopPropagation(), X(!N);
|
|
107
|
+
}, le = (e) => {
|
|
108
|
+
e?.stopPropagation(), X(!1);
|
|
109
|
+
}, Z = e.contentProps ?? {}, ue = Z.ref, Q = Z.alpha, de = (e) => {
|
|
110
|
+
let t = e;
|
|
111
|
+
k.current = t, E(ue, t);
|
|
112
|
+
}, $ = P.phase === "entered" || P.phase === "exiting" ? Q : 0;
|
|
113
|
+
return d(() => {
|
|
114
|
+
if (!F || !N) return;
|
|
115
|
+
let e = (e) => {
|
|
116
|
+
e.key === "Escape" && X(!1);
|
|
117
|
+
};
|
|
118
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
119
|
+
}, [F, N]), d(() => {
|
|
120
|
+
if (!P.isPresent) return;
|
|
121
|
+
let e = !1, t = () => {
|
|
122
|
+
if (e) return;
|
|
123
|
+
let n = w(O.current);
|
|
124
|
+
U((e) => Math.abs(e.x - n.x) < .5 && Math.abs(e.y - n.y) < .5 && Math.abs(e.width - n.width) < .5 && Math.abs(e.height - n.height) < .5 ? e : n), i.defer(t);
|
|
125
|
+
};
|
|
126
|
+
return i.defer(t), () => {
|
|
127
|
+
e = !0;
|
|
128
|
+
};
|
|
129
|
+
}, [P.isPresent]), d(() => {
|
|
130
|
+
if (!P.isPresent || !K) return;
|
|
131
|
+
let e = !1, t = () => {
|
|
132
|
+
if (e) return;
|
|
133
|
+
let n = S(k.current);
|
|
134
|
+
n.width > 0 && n.height > 0 && j((e) => e && Math.abs(e.width - n.width) < .5 && Math.abs(e.height - n.height) < .5 ? e : {
|
|
135
|
+
width: n.width,
|
|
136
|
+
height: n.height
|
|
137
|
+
}), i.defer(t);
|
|
138
|
+
};
|
|
139
|
+
return i.defer(t), () => {
|
|
140
|
+
e = !0;
|
|
141
|
+
};
|
|
142
|
+
}, [
|
|
143
|
+
P.isPresent,
|
|
144
|
+
K,
|
|
145
|
+
e.children,
|
|
146
|
+
z,
|
|
147
|
+
B
|
|
148
|
+
]), d(() => {
|
|
149
|
+
let e = k.current;
|
|
150
|
+
if (!(!e || !P.isPresent)) if (P.phase === "entering") {
|
|
151
|
+
if (!q) return;
|
|
152
|
+
u(e), e.setVisible?.(!0), o(e, oe, {
|
|
153
|
+
time: L,
|
|
154
|
+
onComplete: P.finishEnter
|
|
155
|
+
});
|
|
156
|
+
} else P.phase === "exiting" && (u(e), o(e, se, {
|
|
157
|
+
time: R,
|
|
158
|
+
onComplete: () => {
|
|
159
|
+
k.current?.setVisible?.(!1), j(null), P.finishExit();
|
|
160
|
+
}
|
|
161
|
+
}));
|
|
162
|
+
}, [
|
|
163
|
+
P.phase,
|
|
164
|
+
P.isPresent,
|
|
165
|
+
q,
|
|
166
|
+
L,
|
|
167
|
+
R
|
|
168
|
+
]), /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ _(t, {
|
|
169
|
+
...e.triggerProps ?? {},
|
|
170
|
+
ref: O,
|
|
171
|
+
enableGestures: !e.disabled,
|
|
172
|
+
onTouch: ce,
|
|
173
|
+
children: e.trigger
|
|
174
|
+
}), P.isPresent && /* @__PURE__ */ v(n, {
|
|
175
|
+
depth: ie,
|
|
176
|
+
blockEvents: !1,
|
|
177
|
+
children: [ae && /* @__PURE__ */ _(t, {
|
|
178
|
+
width: V.width,
|
|
179
|
+
height: V.height,
|
|
180
|
+
backgroundColor: 0,
|
|
181
|
+
backgroundAlpha: 0,
|
|
182
|
+
onTouch: le,
|
|
183
|
+
onTouchMove: (e) => e.stopPropagation()
|
|
184
|
+
}), /* @__PURE__ */ _(t, {
|
|
185
|
+
direction: "column",
|
|
186
|
+
backgroundColor: C.backgroundColor ?? 1120295,
|
|
187
|
+
borderColor: C.borderColor ?? 3359061,
|
|
188
|
+
borderWidth: C.borderWidth ?? 1,
|
|
189
|
+
cornerRadius: C.cornerRadius ?? 8,
|
|
190
|
+
padding: C.padding ?? 10,
|
|
191
|
+
gap: C.gap ?? 8,
|
|
192
|
+
...Z,
|
|
193
|
+
ref: de,
|
|
194
|
+
x: Y.x,
|
|
195
|
+
y: Y.y,
|
|
196
|
+
...e.matchTriggerWidth || z !== void 0 ? { width: J } : {},
|
|
197
|
+
...$ === void 0 ? {} : { alpha: $ },
|
|
198
|
+
onTouch: (e) => e.stopPropagation(),
|
|
199
|
+
theme: D,
|
|
200
|
+
children: e.children
|
|
201
|
+
})]
|
|
202
|
+
})] });
|
|
203
|
+
}
|
|
204
|
+
function O(n) {
|
|
205
|
+
let { items: r, width: i, onSelect: o, isOpen: u, defaultOpen: d, onOpenChange: f, ...h } = n, g = m(), y = n.theme ? c(g ?? {}, n.theme) : g, { props: b, nestedTheme: x } = l({
|
|
206
|
+
componentName: "ContextMenu",
|
|
207
|
+
globalTheme: s(),
|
|
208
|
+
localTheme: y,
|
|
209
|
+
knownComponents: a
|
|
210
|
+
}), [S, C] = p(d ?? !1), w = u !== void 0, T = w ? u === !0 : S, E = i ?? b.width ?? 220, O = b.itemHeight ?? 34, k = (e) => {
|
|
211
|
+
w || C(e), f?.(e);
|
|
212
|
+
}, A = (e) => {
|
|
213
|
+
e.disabled || (e.onSelect?.(), o?.(e), k(!1));
|
|
214
|
+
};
|
|
215
|
+
return /* @__PURE__ */ _(D, {
|
|
216
|
+
...h,
|
|
217
|
+
isOpen: T,
|
|
218
|
+
onOpenChange: k,
|
|
219
|
+
contentWidth: E,
|
|
220
|
+
contentHeight: Math.max(1, r.length) * O + 20,
|
|
221
|
+
contentProps: {
|
|
222
|
+
padding: b.padding ?? 6,
|
|
223
|
+
gap: b.gap ?? 2,
|
|
224
|
+
backgroundColor: b.backgroundColor,
|
|
225
|
+
borderColor: b.borderColor,
|
|
226
|
+
borderWidth: b.borderWidth,
|
|
227
|
+
cornerRadius: b.cornerRadius,
|
|
228
|
+
theme: x
|
|
229
|
+
},
|
|
230
|
+
children: r.map((n) => {
|
|
231
|
+
let r = b.textStyle, i = n.disabled ? b.disabledTextColor ?? "#64748b" : n.danger ? b.dangerTextColor ?? "#fecaca" : r?.color ?? "#f8fafc";
|
|
232
|
+
return /* @__PURE__ */ v(t, {
|
|
233
|
+
width: "fill",
|
|
234
|
+
height: O,
|
|
235
|
+
direction: "row",
|
|
236
|
+
alignItems: "center",
|
|
237
|
+
justifyContent: "space-between",
|
|
238
|
+
backgroundColor: n.disabled ? void 0 : b.itemBackgroundColor,
|
|
239
|
+
borderColor: n.disabled ? void 0 : b.itemBorderColor,
|
|
240
|
+
cornerRadius: b.itemCornerRadius ?? 4,
|
|
241
|
+
padding: b.itemPadding ?? {
|
|
242
|
+
left: 10,
|
|
243
|
+
right: 10
|
|
244
|
+
},
|
|
245
|
+
enableGestures: !n.disabled,
|
|
246
|
+
onTouch: (e) => {
|
|
247
|
+
e.stopPropagation(), A(n);
|
|
248
|
+
},
|
|
249
|
+
theme: x,
|
|
250
|
+
children: [/* @__PURE__ */ v(t, {
|
|
251
|
+
direction: "row",
|
|
252
|
+
alignItems: "center",
|
|
253
|
+
gap: b.itemGap ?? 8,
|
|
254
|
+
children: [n.prefix, /* @__PURE__ */ _(e, {
|
|
255
|
+
text: n.label,
|
|
256
|
+
style: {
|
|
257
|
+
color: i,
|
|
258
|
+
fontSize: "14px"
|
|
259
|
+
}
|
|
260
|
+
})]
|
|
261
|
+
}), n.suffix]
|
|
262
|
+
}, n.id);
|
|
263
|
+
})
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
//#endregion
|
|
267
|
+
export { O as ContextMenu, D as Popover, x as calculateOverlayPosition };
|
package/dist/Portal.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e=require(`@number10/jsx-core`);function t(t){let n=t.depth??1e3,r=t.blockEvents??!0,{surface:i,error:a,update:o,vdom:s}=(0,e.usePortalSurface)({depth:n,id:(0,e.useMemo)(()=>t.id??`portal-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,[t.id]),blockEvents:r}),c=(0,e.useRef)([]),l=(0,e.useRef)([]),u=(0,e.useRef)(!1),d=e=>{i&&i.context.adapter?.syncPortalEventBlocking?.(i,e)},f=t=>{i&&e.DeferredLayoutQueue.defer(()=>{d(t)})},p=e=>e?(Array.isArray(e)?e.flat(1/0):[e]).filter(e=>!!e&&typeof e==`object`&&`type`in e):[];return(0,e.useEffect)(()=>{if(!i||!s)return;let{mount:e}=s,n=i.root,a=p(t.children),o=[];for(let t of a)if(t){let r=e(n,t);r&&o.push(r)}c.current=o,l.current=a,u.current=!0,f(r)},[i,s,r]),(0,e.useEffect)(()=>{if(!i||!s)return;let e=p(t.children),a=l.current;if(u.current){u.current=!1;return}let{patchVNode:d,mount:m,unmount:h}=s,g=i.root,_=Math.max(a.length,e.length);for(let t=0;t<_;t++){let n=a[t],r=e[t];if(n&&r)d(g,n,r);else if(!n&&r){let e=m(g,r);e&&c.current.push(e)}else n&&!r&&h(n)}l.current=e,n!==i.zIndex&&o({depth:n}),f(r)},[t.children,n,i,s,o,r]),(0,e.useEffect)(()=>{if(i){if(!r){d(!1);return}return f(!0),()=>{d(!1)}}},[i,r]),a&&console.error(`[Portal] ${a}`),null}exports.Portal=t;
|
package/dist/Portal.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ChildrenType, VNodeLike } from '@number10/jsx-core';
|
|
2
|
+
/**
|
|
3
|
+
* Props for Portal component
|
|
4
|
+
*/
|
|
5
|
+
export interface PortalProps {
|
|
6
|
+
/** Unique key for VDOM identification */
|
|
7
|
+
key?: string | number | undefined;
|
|
8
|
+
/** Content to render in portal */
|
|
9
|
+
children: ChildrenType;
|
|
10
|
+
/** Z-depth for portal (higher = foreground) */
|
|
11
|
+
depth?: number;
|
|
12
|
+
/** Optional custom portal ID */
|
|
13
|
+
id?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Block input events from passing through the portal area.
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
|
+
blockEvents?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Portable Portal component.
|
|
22
|
+
*
|
|
23
|
+
* Renders child VNodes into a separate depth layer using the surface
|
|
24
|
+
* adapter from the current renderer. Surface lifecycle and VDOM operations
|
|
25
|
+
* are provided by {@link usePortalSurface}.
|
|
26
|
+
*
|
|
27
|
+
* @param props - Portal configuration
|
|
28
|
+
*/
|
|
29
|
+
export declare function Portal(props: PortalProps): VNodeLike;
|
|
30
|
+
//# sourceMappingURL=Portal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Portal.d.ts","sourceRoot":"","sources":["../src/Portal.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,KAAK,EAAE,YAAY,EAAS,SAAS,EAAE,MAAM,oBAAoB,CAAA;AASxE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,yCAAyC;IACzC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IACjC,kCAAkC;IAClC,QAAQ,EAAE,YAAY,CAAA;IACtB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,gCAAgC;IAChC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,CA8IpD"}
|
package/dist/Portal.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { DeferredLayoutQueue as e, useEffect as t, useMemo as n, usePortalSurface as r, useRef as i } from "@number10/jsx-core";
|
|
2
|
+
//#region src/Portal.tsx
|
|
3
|
+
function a(a) {
|
|
4
|
+
let o = a.depth ?? 1e3, s = a.blockEvents ?? !0, { surface: c, error: l, update: u, vdom: d } = r({
|
|
5
|
+
depth: o,
|
|
6
|
+
id: n(() => a.id ?? `portal-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, [a.id]),
|
|
7
|
+
blockEvents: s
|
|
8
|
+
}), f = i([]), p = i([]), m = i(!1), h = (e) => {
|
|
9
|
+
c && c.context.adapter?.syncPortalEventBlocking?.(c, e);
|
|
10
|
+
}, g = (t) => {
|
|
11
|
+
c && e.defer(() => {
|
|
12
|
+
h(t);
|
|
13
|
+
});
|
|
14
|
+
}, _ = (e) => e ? (Array.isArray(e) ? e.flat(Infinity) : [e]).filter((e) => !!e && typeof e == "object" && "type" in e) : [];
|
|
15
|
+
return t(() => {
|
|
16
|
+
if (!c || !d) return;
|
|
17
|
+
let { mount: e } = d, t = c.root, n = _(a.children), r = [];
|
|
18
|
+
for (let i of n) if (i) {
|
|
19
|
+
let n = e(t, i);
|
|
20
|
+
n && r.push(n);
|
|
21
|
+
}
|
|
22
|
+
f.current = r, p.current = n, m.current = !0, g(s);
|
|
23
|
+
}, [
|
|
24
|
+
c,
|
|
25
|
+
d,
|
|
26
|
+
s
|
|
27
|
+
]), t(() => {
|
|
28
|
+
if (!c || !d) return;
|
|
29
|
+
let e = _(a.children), t = p.current;
|
|
30
|
+
if (m.current) {
|
|
31
|
+
m.current = !1;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
let { patchVNode: n, mount: r, unmount: i } = d, l = c.root, h = Math.max(t.length, e.length);
|
|
35
|
+
for (let a = 0; a < h; a++) {
|
|
36
|
+
let o = t[a], s = e[a];
|
|
37
|
+
if (o && s) n(l, o, s);
|
|
38
|
+
else if (!o && s) {
|
|
39
|
+
let e = r(l, s);
|
|
40
|
+
e && f.current.push(e);
|
|
41
|
+
} else o && !s && i(o);
|
|
42
|
+
}
|
|
43
|
+
p.current = e, o !== c.zIndex && u({ depth: o }), g(s);
|
|
44
|
+
}, [
|
|
45
|
+
a.children,
|
|
46
|
+
o,
|
|
47
|
+
c,
|
|
48
|
+
d,
|
|
49
|
+
u,
|
|
50
|
+
s
|
|
51
|
+
]), t(() => {
|
|
52
|
+
if (c) {
|
|
53
|
+
if (!s) {
|
|
54
|
+
h(!1);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
return g(!0), () => {
|
|
58
|
+
h(!1);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}, [c, s]), l && console.error(`[Portal] ${l}`), null;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { a as Portal };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Portal.test.d.ts","sourceRoot":"","sources":["../src/Portal.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./primitives/Text.cjs`),t=require(`./primitives/View.cjs`);require(`./primitives.cjs`);let n=require(`@number10/jsx-core`),r=require(`@number10/jsx-core/jsx-runtime`);function i(e,t,n){return Number.isFinite(e)?Math.min(Math.max(e,t),n):t}function a(e,t,n){if(!Number.isFinite(t)||!Number.isFinite(n)||t===n)return 0;let r=Math.min(t,n),a=Math.max(t,n);return(i(e,r,a)-r)/(a-r)}function o(e){return`${Math.round(e.percent)}%`}function s(i){let{value:s,min:c=0,max:l=100,orientation:u,label:d,showValue:f,labelPosition:p,formatValue:m,trackColor:h,fillColor:g,borderColor:_,borderWidth:v,cornerRadius:y,labelStyle:b,disabled:x=!1,disabledAlpha:S,theme:C,width:w,height:T,alpha:E,...D}=i,O=(0,n.useTheme)(),k=C?(0,n.mergeThemes)(O??{},C):O,{props:A,nestedTheme:j}=(0,n.resolveComponentTheme)({componentName:`ProgressBar`,globalTheme:(0,n.getGlobalThemeDefaults)(),localTheme:k,knownComponents:n.KNOWN_COMPONENTS}),M=u??A.orientation??`horizontal`,N=a(s,c,l),P=N*100,F=p??A.labelPosition??(f||d?`right`:`none`),I=F!==`none`&&!!(f||d),L=I?[d,f?(m??o)({value:s,min:c,max:l,ratio:N,percent:P}):void 0].filter(Boolean).join(` `):``,R=w??A.width??(M===`horizontal`?240:24),z=T??A.height??(M===`horizontal`?22:160),B=h??A.trackColor??2042167,V=g??A.fillColor??2278750,H=_??A.borderColor??3359061,U=v??A.borderWidth??1,W=y??A.cornerRadius??(M===`horizontal`?11:8),G=b??A.labelStyle??{color:`#ffffff`,fontSize:`12px`},K=S??A.disabledAlpha??.5,q=x?K:E,J=F===`left`||F===`right`?`row`:`column`,Y=I?(0,r.jsx)(e.Text,{text:L,style:G}):null,X=M===`horizontal`?{width:`${P}%`,height:`fill`}:{width:`fill`,height:`${P}%`},Z=(0,r.jsxs)(t.View,{width:R,height:z,direction:M===`horizontal`?`stack`:`column`,justifyContent:M===`vertical`?`end`:`start`,backgroundColor:B,borderColor:H,borderWidth:U,cornerRadius:W,overflow:`hidden`,theme:j,children:[(0,r.jsx)(t.View,{...X,backgroundColor:V,cornerRadius:W}),F===`inside`&&I&&(0,r.jsx)(t.View,{width:`fill`,height:`fill`,justifyContent:`center`,alignItems:`center`,children:Y})]});return(0,r.jsxs)(t.View,{...D,direction:J,alignItems:`center`,gap:A.gap??8,...q===void 0?{}:{alpha:q},theme:j,children:[F===`top`||F===`left`?Y:null,Z,F!==`inside`&&(F===`bottom`||F===`right`)?Y:null]})}exports.ProgressBar=s,exports.clampProgressValue=i,exports.getProgressRatio=a;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { PortableTextStyle, VNodeLike } from '@number10/jsx-core';
|
|
2
|
+
import { PortableComponentPartialTheme } from './theme-types';
|
|
3
|
+
export type ProgressBarOrientation = 'horizontal' | 'vertical';
|
|
4
|
+
export type ProgressBarLabelPosition = 'none' | 'inside' | 'top' | 'bottom' | 'left' | 'right';
|
|
5
|
+
export interface ProgressBarFormatProps {
|
|
6
|
+
value: number;
|
|
7
|
+
min: number;
|
|
8
|
+
max: number;
|
|
9
|
+
ratio: number;
|
|
10
|
+
percent: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ProgressBarProps {
|
|
13
|
+
/** Unique key for VDOM identification */
|
|
14
|
+
key?: string | number | undefined;
|
|
15
|
+
/** Current progress value */
|
|
16
|
+
value: number;
|
|
17
|
+
/** Minimum value used for normalization (default 0) */
|
|
18
|
+
min?: number;
|
|
19
|
+
/** Maximum value used for normalization (default 100) */
|
|
20
|
+
max?: number;
|
|
21
|
+
/** Progress direction (default 'horizontal') */
|
|
22
|
+
orientation?: ProgressBarOrientation;
|
|
23
|
+
/** Optional static label prefix */
|
|
24
|
+
label?: string;
|
|
25
|
+
/** Show formatted value text */
|
|
26
|
+
showValue?: boolean;
|
|
27
|
+
/** Position of the label/value text */
|
|
28
|
+
labelPosition?: ProgressBarLabelPosition;
|
|
29
|
+
/** Custom formatter for value text */
|
|
30
|
+
formatValue?: (props: ProgressBarFormatProps) => string;
|
|
31
|
+
/** Track/background color */
|
|
32
|
+
trackColor?: number;
|
|
33
|
+
/** Filled progress color */
|
|
34
|
+
fillColor?: number;
|
|
35
|
+
/** Border color around the track */
|
|
36
|
+
borderColor?: number;
|
|
37
|
+
/** Border width around the track */
|
|
38
|
+
borderWidth?: number;
|
|
39
|
+
/** Track corner radius */
|
|
40
|
+
cornerRadius?: number;
|
|
41
|
+
/** Text style for label/value */
|
|
42
|
+
labelStyle?: PortableTextStyle;
|
|
43
|
+
/** Disabled state */
|
|
44
|
+
disabled?: boolean;
|
|
45
|
+
/** Alpha applied while disabled */
|
|
46
|
+
disabledAlpha?: number;
|
|
47
|
+
/** Theme overrides */
|
|
48
|
+
theme?: PortableComponentPartialTheme<'ProgressBar'>;
|
|
49
|
+
/** Width */
|
|
50
|
+
width?: import('@number10/jsx-core').SizeValue | undefined;
|
|
51
|
+
/** Height */
|
|
52
|
+
height?: import('@number10/jsx-core').SizeValue | undefined;
|
|
53
|
+
/** Alpha transparency */
|
|
54
|
+
alpha?: number;
|
|
55
|
+
/** Gap between label and track */
|
|
56
|
+
gap?: number;
|
|
57
|
+
}
|
|
58
|
+
export declare function clampProgressValue(value: number, min: number, max: number): number;
|
|
59
|
+
export declare function getProgressRatio(value: number, min: number, max: number): number;
|
|
60
|
+
export declare function ProgressBar(props: ProgressBarProps): VNodeLike;
|
|
61
|
+
//# sourceMappingURL=ProgressBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProgressBar.d.ts","sourceRoot":"","sources":["../src/ProgressBar.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAStE,OAAO,KAAK,EAAE,6BAA6B,EAAoB,MAAM,eAAe,CAAA;AAIpF,MAAM,MAAM,sBAAsB,GAAG,YAAY,GAAG,UAAU,CAAA;AAC9D,MAAM,MAAM,wBAAwB,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;AAE9F,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,yCAAyC;IACzC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IACjC,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,uDAAuD;IACvD,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,yDAAyD;IACzD,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,gDAAgD;IAChD,WAAW,CAAC,EAAE,sBAAsB,CAAA;IACpC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C,KAAK,EAAE,gBAAgB,GAAG,SAAS,CA2H9D"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Text as e } from "./primitives/Text.js";
|
|
2
|
+
import { View as t } from "./primitives/View.js";
|
|
3
|
+
import "./primitives.js";
|
|
4
|
+
import { KNOWN_COMPONENTS as n, getGlobalThemeDefaults as r, mergeThemes as i, resolveComponentTheme as a, useTheme as o } from "@number10/jsx-core";
|
|
5
|
+
import { jsx as s, jsxs as c } from "@number10/jsx-core/jsx-runtime";
|
|
6
|
+
//#region src/ProgressBar.tsx
|
|
7
|
+
function l(e, t, n) {
|
|
8
|
+
return Number.isFinite(e) ? Math.min(Math.max(e, t), n) : t;
|
|
9
|
+
}
|
|
10
|
+
function u(e, t, n) {
|
|
11
|
+
if (!Number.isFinite(t) || !Number.isFinite(n) || t === n) return 0;
|
|
12
|
+
let r = Math.min(t, n), i = Math.max(t, n);
|
|
13
|
+
return (l(e, r, i) - r) / (i - r);
|
|
14
|
+
}
|
|
15
|
+
function d(e) {
|
|
16
|
+
return `${Math.round(e.percent)}%`;
|
|
17
|
+
}
|
|
18
|
+
function f(l) {
|
|
19
|
+
let { value: f, min: p = 0, max: m = 100, orientation: h, label: g, showValue: _, labelPosition: v, formatValue: y, trackColor: b, fillColor: x, borderColor: S, borderWidth: C, cornerRadius: w, labelStyle: T, disabled: E = !1, disabledAlpha: ee, theme: D, width: O, height: k, alpha: A, ...j } = l, M = o(), N = D ? i(M ?? {}, D) : M, { props: P, nestedTheme: F } = a({
|
|
20
|
+
componentName: "ProgressBar",
|
|
21
|
+
globalTheme: r(),
|
|
22
|
+
localTheme: N,
|
|
23
|
+
knownComponents: n
|
|
24
|
+
}), I = h ?? P.orientation ?? "horizontal", L = u(f, p, m), R = L * 100, z = v ?? P.labelPosition ?? (_ || g ? "right" : "none"), B = z !== "none" && !!(_ || g), V = B ? [g, _ ? (y ?? d)({
|
|
25
|
+
value: f,
|
|
26
|
+
min: p,
|
|
27
|
+
max: m,
|
|
28
|
+
ratio: L,
|
|
29
|
+
percent: R
|
|
30
|
+
}) : void 0].filter(Boolean).join(" ") : "", H = O ?? P.width ?? (I === "horizontal" ? 240 : 24), U = k ?? P.height ?? (I === "horizontal" ? 22 : 160), W = b ?? P.trackColor ?? 2042167, G = x ?? P.fillColor ?? 2278750, K = S ?? P.borderColor ?? 3359061, q = C ?? P.borderWidth ?? 1, J = w ?? P.cornerRadius ?? (I === "horizontal" ? 11 : 8), Y = T ?? P.labelStyle ?? {
|
|
31
|
+
color: "#ffffff",
|
|
32
|
+
fontSize: "12px"
|
|
33
|
+
}, X = ee ?? P.disabledAlpha ?? .5, Z = E ? X : A, Q = z === "left" || z === "right" ? "row" : "column", $ = B ? /* @__PURE__ */ s(e, {
|
|
34
|
+
text: V,
|
|
35
|
+
style: Y
|
|
36
|
+
}) : null, te = I === "horizontal" ? {
|
|
37
|
+
width: `${R}%`,
|
|
38
|
+
height: "fill"
|
|
39
|
+
} : {
|
|
40
|
+
width: "fill",
|
|
41
|
+
height: `${R}%`
|
|
42
|
+
}, ne = /* @__PURE__ */ c(t, {
|
|
43
|
+
width: H,
|
|
44
|
+
height: U,
|
|
45
|
+
direction: I === "horizontal" ? "stack" : "column",
|
|
46
|
+
justifyContent: I === "vertical" ? "end" : "start",
|
|
47
|
+
backgroundColor: W,
|
|
48
|
+
borderColor: K,
|
|
49
|
+
borderWidth: q,
|
|
50
|
+
cornerRadius: J,
|
|
51
|
+
overflow: "hidden",
|
|
52
|
+
theme: F,
|
|
53
|
+
children: [/* @__PURE__ */ s(t, {
|
|
54
|
+
...te,
|
|
55
|
+
backgroundColor: G,
|
|
56
|
+
cornerRadius: J
|
|
57
|
+
}), z === "inside" && B && /* @__PURE__ */ s(t, {
|
|
58
|
+
width: "fill",
|
|
59
|
+
height: "fill",
|
|
60
|
+
justifyContent: "center",
|
|
61
|
+
alignItems: "center",
|
|
62
|
+
children: $
|
|
63
|
+
})]
|
|
64
|
+
});
|
|
65
|
+
return /* @__PURE__ */ c(t, {
|
|
66
|
+
...j,
|
|
67
|
+
direction: Q,
|
|
68
|
+
alignItems: "center",
|
|
69
|
+
gap: P.gap ?? 8,
|
|
70
|
+
...Z === void 0 ? {} : { alpha: Z },
|
|
71
|
+
theme: F,
|
|
72
|
+
children: [
|
|
73
|
+
z === "top" || z === "left" ? $ : null,
|
|
74
|
+
ne,
|
|
75
|
+
z !== "inside" && (z === "bottom" || z === "right") ? $ : null
|
|
76
|
+
]
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
export { f as ProgressBar, l as clampProgressValue, u as getProgressRatio };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProgressBar.test.d.ts","sourceRoot":"","sources":["../src/ProgressBar.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./primitives/Text.cjs`),t=require(`./primitives/View.cjs`);require(`./primitives.cjs`);const n=require(`./Button.cjs`),r=require(`./ActivityIndicator.cjs`),i=require(`./ProgressBar.cjs`);let a=require(`@number10/jsx-core`),o=require(`@number10/jsx-core/jsx-runtime`);function s(s){let{value:c,min:l=0,max:u=100,indeterminate:d=!1,label:f,showPercentage:p=!1,showCancel:m=!1,onCancel:h,labels:g,progressBarProps:_,theme:v,...y}=s,b=(0,a.useTheme)(),x=v?(0,a.mergeThemes)(b??{},v):b,{props:S,nestedTheme:C}=(0,a.resolveComponentTheme)({componentName:`ProgressView`,globalTheme:(0,a.getGlobalThemeDefaults)(),localTheme:x,knownComponents:a.KNOWN_COMPONENTS}),w={...S.labels??{},...g??{}},T=S.gap??8,E=S.barHeight??24,D=S.labelStyle??{color:`#e0e7ff`,fontSize:`14px`},O=S.percentageStyle??{color:`#9fb3c8`,fontSize:`13px`},k=c===void 0?void 0:Math.round((c-l)/(u-l)*100);return(0,o.jsxs)(t.View,{direction:`column`,gap:T,width:S.width??`fill`,...y,theme:C,children:[(f||p)&&!d?(0,o.jsxs)(t.View,{direction:`row`,justifyContent:`space-between`,width:`fill`,children:[f?(0,o.jsx)(e.Text,{text:f,style:D}):(0,o.jsx)(t.View,{}),p&&k!==void 0?(0,o.jsx)(e.Text,{text:`${k}%`,style:O}):null]}):null,d?(0,o.jsx)(r.ActivityIndicator,{...f||w.loading?{label:f??w.loading}:{},theme:C}):(0,o.jsx)(i.ProgressBar,{value:c??0,min:l,max:u,height:E,width:`fill`,..._,theme:C}),m&&h?(0,o.jsx)(t.View,{alignItems:`center`,width:`fill`,children:(0,o.jsx)(n.Button,{variant:`ghost`,size:S.cancelButtonSize??`small`,onClick:h,children:(0,o.jsx)(e.Text,{text:w.cancel??`Cancel`})})}):null]})}exports.ProgressView=s;
|