basefn 1.10.0 → 1.11.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/package.json +3 -3
- package/rescript.json +1 -1
- package/src/Basefn__Responsive.res.mjs +5 -5
- package/src/Basefn__Utils.res.mjs +2 -2
- package/src/Demo.res +59 -59
- package/src/Demo.res.mjs +630 -628
- package/src/Example.res +3 -3
- package/src/Example.res.mjs +48 -47
- package/src/components/Basefn__Accordion.res +5 -5
- package/src/components/Basefn__Accordion.res.mjs +25 -26
- package/src/components/Basefn__Alert.res +4 -4
- package/src/components/Basefn__Alert.res.mjs +20 -18
- package/src/components/Basefn__AlertDialog.res +5 -5
- package/src/components/Basefn__AlertDialog.res.mjs +23 -21
- package/src/components/Basefn__AppLayout.res +3 -3
- package/src/components/Basefn__AppLayout.res.mjs +25 -24
- package/src/components/Basefn__AspectRatio.res +1 -1
- package/src/components/Basefn__AspectRatio.res.mjs +2 -2
- package/src/components/Basefn__Avatar.res.mjs +3 -3
- package/src/components/Basefn__Badge.res +1 -1
- package/src/components/Basefn__Badge.res.mjs +2 -2
- package/src/components/Basefn__Breadcrumb.res +5 -5
- package/src/components/Basefn__Breadcrumb.res.mjs +14 -14
- package/src/components/Basefn__Button.res +1 -1
- package/src/components/Basefn__Button.res.mjs +10 -9
- package/src/components/Basefn__ButtonGroup.res +1 -1
- package/src/components/Basefn__ButtonGroup.res.mjs +2 -2
- package/src/components/Basefn__Card.res +3 -3
- package/src/components/Basefn__Card.res.mjs +11 -11
- package/src/components/Basefn__Checkbox.res +1 -1
- package/src/components/Basefn__Checkbox.res.mjs +7 -7
- package/src/components/Basefn__ContextMenu.res +4 -4
- package/src/components/Basefn__ContextMenu.res.mjs +22 -20
- package/src/components/Basefn__Drawer.res +5 -5
- package/src/components/Basefn__Drawer.res.mjs +22 -20
- package/src/components/Basefn__Dropdown.res +4 -4
- package/src/components/Basefn__Dropdown.res.mjs +20 -18
- package/src/components/Basefn__Grid.res.mjs +15 -14
- package/src/components/Basefn__HoverCard.res +3 -3
- package/src/components/Basefn__HoverCard.res.mjs +14 -12
- package/src/components/Basefn__Icon.res.mjs +8 -7
- package/src/components/Basefn__Input.res.mjs +4 -4
- package/src/components/Basefn__Kbd.res +2 -2
- package/src/components/Basefn__Kbd.res.mjs +5 -5
- package/src/components/Basefn__Label.res +1 -1
- package/src/components/Basefn__Label.res.mjs +4 -4
- package/src/components/Basefn__Modal.res +5 -5
- package/src/components/Basefn__Modal.res.mjs +20 -18
- package/src/components/Basefn__Popover.res +3 -3
- package/src/components/Basefn__Popover.res.mjs +15 -13
- package/src/components/Basefn__Progress.res +2 -2
- package/src/components/Basefn__Progress.res.mjs +16 -14
- package/src/components/Basefn__Radio.res +1 -1
- package/src/components/Basefn__Radio.res.mjs +7 -7
- package/src/components/Basefn__Resizable.res +49 -20
- package/src/components/Basefn__Resizable.res.mjs +66 -36
- package/src/components/Basefn__ScrollArea.res +1 -1
- package/src/components/Basefn__ScrollArea.res.mjs +2 -2
- package/src/components/Basefn__Select.res +2 -2
- package/src/components/Basefn__Select.res.mjs +7 -6
- package/src/components/Basefn__Separator.res +1 -1
- package/src/components/Basefn__Separator.res.mjs +9 -9
- package/src/components/Basefn__Sidebar.res +7 -7
- package/src/components/Basefn__Sidebar.res.mjs +28 -24
- package/src/components/Basefn__Skeleton.res.mjs +2 -2
- package/src/components/Basefn__Slider.res +4 -4
- package/src/components/Basefn__Slider.res.mjs +21 -20
- package/src/components/Basefn__Spinner.res +1 -1
- package/src/components/Basefn__Spinner.res.mjs +8 -8
- package/src/components/Basefn__Spotlight.res +14 -14
- package/src/components/Basefn__Spotlight.res.mjs +69 -65
- package/src/components/Basefn__Stepper.res +6 -6
- package/src/components/Basefn__Stepper.res.mjs +20 -24
- package/src/components/Basefn__Switch.res +1 -1
- package/src/components/Basefn__Switch.res.mjs +16 -14
- package/src/components/Basefn__Tabs.res +4 -4
- package/src/components/Basefn__Tabs.res.mjs +19 -17
- package/src/components/Basefn__Textarea.res.mjs +4 -4
- package/src/components/Basefn__ThemeToggle.res +1 -1
- package/src/components/Basefn__ThemeToggle.res.mjs +13 -10
- package/src/components/Basefn__Timeline.res +6 -6
- package/src/components/Basefn__Timeline.res.mjs +21 -21
- package/src/components/Basefn__Toast.res +4 -4
- package/src/components/Basefn__Toast.res.mjs +23 -20
- package/src/components/Basefn__Toggle.res +1 -1
- package/src/components/Basefn__Toggle.res.mjs +8 -7
- package/src/components/Basefn__ToggleGroup.res +2 -2
- package/src/components/Basefn__ToggleGroup.res.mjs +12 -10
- package/src/components/Basefn__Tooltip.res +3 -3
- package/src/components/Basefn__Tooltip.res.mjs +14 -12
- package/src/components/Basefn__Topbar.res +7 -7
- package/src/components/Basefn__Topbar.res.mjs +22 -22
- package/src/components/Basefn__Typography.res +2 -2
- package/src/components/Basefn__Typography.res.mjs +13 -13
- package/src/styles/Basefn__Theme.res.mjs +5 -5
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
-
import * as Xote from "xote/src/
|
|
4
|
-
import * as
|
|
3
|
+
import * as Node$Xote from "xote/src/Node.res.mjs";
|
|
4
|
+
import * as Signal$Xote from "xote/src/Signal.res.mjs";
|
|
5
|
+
import * as XoteJSX$Xote from "xote/src/XoteJSX.res.mjs";
|
|
6
|
+
import * as Computed$Xote from "xote/src/Computed.res.mjs";
|
|
5
7
|
|
|
6
8
|
import './Basefn__Popover.css'
|
|
7
9
|
;
|
|
@@ -42,14 +44,14 @@ function Basefn__Popover(props) {
|
|
|
42
44
|
let align = __align !== undefined ? __align : "Center";
|
|
43
45
|
let closeOnClickOutside = __closeOnClickOutside !== undefined ? __closeOnClickOutside : true;
|
|
44
46
|
let handleTriggerClick = param => {
|
|
45
|
-
let newValue = !Xote.
|
|
46
|
-
Xote.
|
|
47
|
+
let newValue = !Signal$Xote.get(isOpen);
|
|
48
|
+
Signal$Xote.set(isOpen, newValue);
|
|
47
49
|
if (onOpenChange !== undefined) {
|
|
48
50
|
return onOpenChange(newValue);
|
|
49
51
|
}
|
|
50
52
|
};
|
|
51
53
|
let handleClose = () => {
|
|
52
|
-
Xote.
|
|
54
|
+
Signal$Xote.set(isOpen, false);
|
|
53
55
|
if (onOpenChange !== undefined) {
|
|
54
56
|
return onOpenChange(false);
|
|
55
57
|
}
|
|
@@ -68,14 +70,14 @@ function Basefn__Popover(props) {
|
|
|
68
70
|
let alignClass = " basefn-popover__content--align-" + alignToString(align);
|
|
69
71
|
return "basefn-popover__content" + positionClass + alignClass;
|
|
70
72
|
};
|
|
71
|
-
let popoverContent = Xote.
|
|
72
|
-
if (Xote.
|
|
73
|
+
let popoverContent = Computed$Xote.make(() => {
|
|
74
|
+
if (Signal$Xote.get(isOpen)) {
|
|
73
75
|
return [
|
|
74
|
-
|
|
76
|
+
XoteJSX$Xote.Elements.jsx("div", {
|
|
75
77
|
class: "basefn-popover__backdrop",
|
|
76
78
|
onClick: handleBackdropClick
|
|
77
79
|
}),
|
|
78
|
-
|
|
80
|
+
XoteJSX$Xote.Elements.jsx("div", {
|
|
79
81
|
class: getContentClassName(),
|
|
80
82
|
children: content
|
|
81
83
|
})
|
|
@@ -84,15 +86,15 @@ function Basefn__Popover(props) {
|
|
|
84
86
|
return [];
|
|
85
87
|
}
|
|
86
88
|
}, undefined);
|
|
87
|
-
return
|
|
89
|
+
return XoteJSX$Xote.Elements.jsxs("div", {
|
|
88
90
|
class: getPopoverClassName(),
|
|
89
|
-
children:
|
|
90
|
-
|
|
91
|
+
children: XoteJSX$Xote.array([
|
|
92
|
+
XoteJSX$Xote.Elements.jsx("div", {
|
|
91
93
|
class: "basefn-popover__trigger",
|
|
92
94
|
onClick: handleTriggerClick,
|
|
93
95
|
children: props.trigger
|
|
94
96
|
}),
|
|
95
|
-
Xote.
|
|
97
|
+
Node$Xote.signalFragment(popoverContent)
|
|
96
98
|
])
|
|
97
99
|
});
|
|
98
100
|
}
|
|
@@ -74,14 +74,14 @@ let make = (
|
|
|
74
74
|
{showLabel || label->Option.isSome
|
|
75
75
|
? <div class="basefn-progress__label">
|
|
76
76
|
<span>
|
|
77
|
-
{
|
|
77
|
+
{Node.text(
|
|
78
78
|
switch label {
|
|
79
79
|
| Some(labelText) => labelText
|
|
80
80
|
| None => "Progress"
|
|
81
81
|
},
|
|
82
82
|
)}
|
|
83
83
|
</span>
|
|
84
|
-
{!indeterminate ? {
|
|
84
|
+
{!indeterminate ? {Node.signalText(() => getPercentage() ++ "%")} : <> </>}
|
|
85
85
|
</div>
|
|
86
86
|
: <> </>}
|
|
87
87
|
</>
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
-
import * as Xote from "xote/src/
|
|
4
|
-
import * as
|
|
3
|
+
import * as Node$Xote from "xote/src/Node.res.mjs";
|
|
4
|
+
import * as Signal$Xote from "xote/src/Signal.res.mjs";
|
|
5
5
|
import * as Core__Option from "@rescript/core/src/Core__Option.res.mjs";
|
|
6
|
+
import * as XoteJSX$Xote from "xote/src/XoteJSX.res.mjs";
|
|
7
|
+
import * as Computed$Xote from "xote/src/Computed.res.mjs";
|
|
6
8
|
|
|
7
9
|
import './Basefn__Progress.css'
|
|
8
10
|
;
|
|
@@ -56,20 +58,20 @@ function Basefn__Progress(props) {
|
|
|
56
58
|
return "basefn-progress__bar " + variantClass + animatedClass;
|
|
57
59
|
};
|
|
58
60
|
let getPercentage = () => {
|
|
59
|
-
let currentValue = Xote.
|
|
61
|
+
let currentValue = Signal$Xote.get(value);
|
|
60
62
|
let percent = currentValue / max * 100.0;
|
|
61
63
|
let clamped = percent > 100.0 ? 100.0 : (
|
|
62
64
|
percent < 0.0 ? 0.0 : percent
|
|
63
65
|
);
|
|
64
66
|
return clamped.toString();
|
|
65
67
|
};
|
|
66
|
-
return
|
|
67
|
-
children:
|
|
68
|
-
|
|
68
|
+
return XoteJSX$Xote.jsxs(XoteJSX$Xote.jsxFragment, {
|
|
69
|
+
children: XoteJSX$Xote.array([
|
|
70
|
+
XoteJSX$Xote.Elements.jsx("div", {
|
|
69
71
|
class: getProgressClass(),
|
|
70
|
-
children:
|
|
72
|
+
children: XoteJSX$Xote.Elements.jsx("div", {
|
|
71
73
|
class: getBarClass(),
|
|
72
|
-
style: Xote.
|
|
74
|
+
style: Computed$Xote.make(() => {
|
|
73
75
|
if (indeterminate) {
|
|
74
76
|
return "width: 30%";
|
|
75
77
|
} else {
|
|
@@ -78,15 +80,15 @@ function Basefn__Progress(props) {
|
|
|
78
80
|
}, undefined)
|
|
79
81
|
})
|
|
80
82
|
}),
|
|
81
|
-
showLabel || Core__Option.isSome(label) ?
|
|
83
|
+
showLabel || Core__Option.isSome(label) ? XoteJSX$Xote.Elements.jsxs("div", {
|
|
82
84
|
class: "basefn-progress__label",
|
|
83
|
-
children:
|
|
84
|
-
|
|
85
|
-
children: Xote.
|
|
85
|
+
children: XoteJSX$Xote.array([
|
|
86
|
+
XoteJSX$Xote.Elements.jsx("span", {
|
|
87
|
+
children: Node$Xote.text(label !== undefined ? label : "Progress")
|
|
86
88
|
}),
|
|
87
|
-
indeterminate ?
|
|
89
|
+
indeterminate ? XoteJSX$Xote.jsx(XoteJSX$Xote.jsxFragment, {}) : Node$Xote.signalText(() => getPercentage() + "%")
|
|
88
90
|
])
|
|
89
|
-
}) :
|
|
91
|
+
}) : XoteJSX$Xote.jsx(XoteJSX$Xote.jsxFragment, {})
|
|
90
92
|
])
|
|
91
93
|
});
|
|
92
94
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
-
import * as Xote from "xote/src/
|
|
4
|
-
import * as
|
|
3
|
+
import * as Node$Xote from "xote/src/Node.res.mjs";
|
|
4
|
+
import * as XoteJSX$Xote from "xote/src/XoteJSX.res.mjs";
|
|
5
5
|
|
|
6
6
|
import './Basefn__Radio.css'
|
|
7
7
|
;
|
|
@@ -10,10 +10,10 @@ function Basefn__Radio(props) {
|
|
|
10
10
|
let __disabled = props.disabled;
|
|
11
11
|
let disabled = __disabled !== undefined ? __disabled : false;
|
|
12
12
|
let base = "basefn-radio-wrapper";
|
|
13
|
-
return
|
|
13
|
+
return XoteJSX$Xote.Elements.jsxs("label", {
|
|
14
14
|
class: disabled ? base + " basefn-radio-wrapper--disabled" : base,
|
|
15
|
-
children:
|
|
16
|
-
|
|
15
|
+
children: XoteJSX$Xote.array([
|
|
16
|
+
XoteJSX$Xote.Elements.jsx("input", {
|
|
17
17
|
class: "basefn-radio-input",
|
|
18
18
|
type: "radio",
|
|
19
19
|
name: props.name,
|
|
@@ -22,9 +22,9 @@ function Basefn__Radio(props) {
|
|
|
22
22
|
checked: props.checked,
|
|
23
23
|
onChange: props.onChange
|
|
24
24
|
}),
|
|
25
|
-
|
|
25
|
+
XoteJSX$Xote.Elements.jsx("span", {
|
|
26
26
|
class: "basefn-radio-label",
|
|
27
|
-
children: Xote.
|
|
27
|
+
children: Node$Xote.text(props.label)
|
|
28
28
|
})
|
|
29
29
|
])
|
|
30
30
|
});
|
|
@@ -5,7 +5,7 @@ open Xote
|
|
|
5
5
|
type direction = Horizontal | Vertical
|
|
6
6
|
|
|
7
7
|
type panel = {
|
|
8
|
-
content:
|
|
8
|
+
content: Node.node,
|
|
9
9
|
defaultSize: float,
|
|
10
10
|
minSize?: float,
|
|
11
11
|
maxSize?: float,
|
|
@@ -66,28 +66,53 @@ let genId: unit => string = %raw(`function() {
|
|
|
66
66
|
return "basefn-resizable-" + Math.random().toString(36).substr(2, 9);
|
|
67
67
|
}`)
|
|
68
68
|
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
// Global event delegation: register callbacks by container ID, one document
|
|
70
|
+
// listener handles all instances. No timing dependency on DOM rendering.
|
|
71
|
+
let registerInstance: (string, (int, Dom.event) => unit) => unit = %raw(`function(id, cb) {
|
|
72
|
+
if (!window.__basefn_resizable) {
|
|
73
|
+
window.__basefn_resizable = {};
|
|
74
74
|
|
|
75
75
|
function handler(e) {
|
|
76
76
|
var target = e.target;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
if (!target || !target.closest) return;
|
|
78
|
+
var handle = target.closest(".basefn-resizable__handle");
|
|
79
|
+
if (!handle) return;
|
|
80
|
+
var container = handle.closest(".basefn-resizable");
|
|
81
|
+
if (!container || !container.id) return;
|
|
82
|
+
var entry = window.__basefn_resizable[container.id];
|
|
83
|
+
if (!entry) return;
|
|
84
|
+
// Find the handle index among direct children of the container
|
|
85
|
+
var children = container.children;
|
|
86
|
+
var handleIndex = 0;
|
|
87
|
+
for (var i = 0; i < children.length; i++) {
|
|
88
|
+
if (children[i].classList.contains("basefn-resizable__handle")) {
|
|
89
|
+
if (children[i] === handle) {
|
|
90
|
+
entry(handleIndex, e);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
handleIndex++;
|
|
84
94
|
}
|
|
85
95
|
}
|
|
86
96
|
}
|
|
87
97
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
98
|
+
document.addEventListener("mousedown", handler);
|
|
99
|
+
document.addEventListener("touchstart", handler, { passive: false });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
window.__basefn_resizable[id] = cb;
|
|
103
|
+
}`)
|
|
104
|
+
|
|
105
|
+
// Lazily attach mousedown/touchstart directly to a handle element.
|
|
106
|
+
// Called from onMouseEnter so the element is guaranteed to exist.
|
|
107
|
+
let initHandle: (Dom.element, int, (int, Dom.event) => unit) => unit = %raw(`function(el, idx, cb) {
|
|
108
|
+
if (el._basefnInit) return;
|
|
109
|
+
el._basefnInit = true;
|
|
110
|
+
el.addEventListener("mousedown", function(e) { cb(idx, e); });
|
|
111
|
+
el.addEventListener("touchstart", function(e) { cb(idx, e); }, { passive: false });
|
|
112
|
+
}`)
|
|
113
|
+
|
|
114
|
+
let getCurrentTarget: Dom.event => Dom.element = %raw(`function(e) {
|
|
115
|
+
return e.currentTarget;
|
|
91
116
|
}`)
|
|
92
117
|
|
|
93
118
|
type dragInfo = {
|
|
@@ -234,15 +259,15 @@ let make = (
|
|
|
234
259
|
}
|
|
235
260
|
}
|
|
236
261
|
|
|
237
|
-
//
|
|
238
|
-
|
|
262
|
+
// Register this instance for global event delegation
|
|
263
|
+
registerInstance(containerId, startDrag)
|
|
239
264
|
|
|
240
265
|
let containerClass =
|
|
241
266
|
"basefn-resizable basefn-resizable--" ++
|
|
242
267
|
directionToString(direction) ++
|
|
243
268
|
(class !== "" ? " " ++ class : "")
|
|
244
269
|
|
|
245
|
-
let elements: array<
|
|
270
|
+
let elements: array<Node.node> = []
|
|
246
271
|
|
|
247
272
|
panels->Array.forEachWithIndex((panel, index) => {
|
|
248
273
|
let panelStyle = Computed.make(() => {
|
|
@@ -275,6 +300,10 @@ let make = (
|
|
|
275
300
|
<div
|
|
276
301
|
key={"handle-" ++ Int.toString(index)}
|
|
277
302
|
class={handleClass}
|
|
303
|
+
onMouseEnter={evt => {
|
|
304
|
+
let el = getCurrentTarget(evt)
|
|
305
|
+
initHandle(el, index, startDrag)
|
|
306
|
+
}}
|
|
278
307
|
onKeyDown={evt => handleKeyDown(index, evt)}
|
|
279
308
|
role="separator"
|
|
280
309
|
tabIndex={0}
|
|
@@ -285,5 +314,5 @@ let make = (
|
|
|
285
314
|
}
|
|
286
315
|
})
|
|
287
316
|
|
|
288
|
-
<div id={containerId} class={containerClass}> {elements->
|
|
317
|
+
<div id={containerId} class={containerClass}> {elements->Node.fragment} </div>
|
|
289
318
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
-
import * as Xote from "xote/src/
|
|
4
|
-
import * as
|
|
3
|
+
import * as Node$Xote from "xote/src/Node.res.mjs";
|
|
4
|
+
import * as Signal$Xote from "xote/src/Signal.res.mjs";
|
|
5
5
|
import * as Core__Option from "@rescript/core/src/Core__Option.res.mjs";
|
|
6
|
+
import * as XoteJSX$Xote from "xote/src/XoteJSX.res.mjs";
|
|
7
|
+
import * as Computed$Xote from "xote/src/Computed.res.mjs";
|
|
6
8
|
|
|
7
9
|
import './Basefn__Resizable.css'
|
|
8
10
|
;
|
|
@@ -63,27 +65,49 @@ let genId = (function() {
|
|
|
63
65
|
return "basefn-resizable-" + Math.random().toString(36).substr(2, 9);
|
|
64
66
|
});
|
|
65
67
|
|
|
66
|
-
let
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (!container) return;
|
|
68
|
+
let registerInstance = (function(id, cb) {
|
|
69
|
+
if (!window.__basefn_resizable) {
|
|
70
|
+
window.__basefn_resizable = {};
|
|
70
71
|
|
|
71
72
|
function handler(e) {
|
|
72
73
|
var target = e.target;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
if (!target || !target.closest) return;
|
|
75
|
+
var handle = target.closest(".basefn-resizable__handle");
|
|
76
|
+
if (!handle) return;
|
|
77
|
+
var container = handle.closest(".basefn-resizable");
|
|
78
|
+
if (!container || !container.id) return;
|
|
79
|
+
var entry = window.__basefn_resizable[container.id];
|
|
80
|
+
if (!entry) return;
|
|
81
|
+
// Find the handle index among direct children of the container
|
|
82
|
+
var children = container.children;
|
|
83
|
+
var handleIndex = 0;
|
|
84
|
+
for (var i = 0; i < children.length; i++) {
|
|
85
|
+
if (children[i].classList.contains("basefn-resizable__handle")) {
|
|
86
|
+
if (children[i] === handle) {
|
|
87
|
+
entry(handleIndex, e);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
handleIndex++;
|
|
80
91
|
}
|
|
81
92
|
}
|
|
82
93
|
}
|
|
83
94
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
95
|
+
document.addEventListener("mousedown", handler);
|
|
96
|
+
document.addEventListener("touchstart", handler, { passive: false });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
window.__basefn_resizable[id] = cb;
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
let initHandle = (function(el, idx, cb) {
|
|
103
|
+
if (el._basefnInit) return;
|
|
104
|
+
el._basefnInit = true;
|
|
105
|
+
el.addEventListener("mousedown", function(e) { cb(idx, e); });
|
|
106
|
+
el.addEventListener("touchstart", function(e) { cb(idx, e); }, { passive: false });
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
let getCurrentTarget = (function(e) {
|
|
110
|
+
return e.currentTarget;
|
|
87
111
|
});
|
|
88
112
|
|
|
89
113
|
function Basefn__Resizable(props) {
|
|
@@ -96,8 +120,8 @@ function Basefn__Resizable(props) {
|
|
|
96
120
|
let withHandle = __withHandle !== undefined ? __withHandle : true;
|
|
97
121
|
let $$class = __class !== undefined ? __class : "";
|
|
98
122
|
let containerId = genId();
|
|
99
|
-
let sizes = Xote.
|
|
100
|
-
let isDragging = Xote.
|
|
123
|
+
let sizes = Signal$Xote.make(panels.map(p => p.defaultSize), undefined, undefined);
|
|
124
|
+
let isDragging = Signal$Xote.make(false, undefined, undefined);
|
|
101
125
|
let dragRef = {
|
|
102
126
|
contents: undefined
|
|
103
127
|
};
|
|
@@ -152,7 +176,7 @@ function Basefn__Resizable(props) {
|
|
|
152
176
|
}
|
|
153
177
|
};
|
|
154
178
|
let applySizes = newSizes => {
|
|
155
|
-
Xote.
|
|
179
|
+
Signal$Xote.set(sizes, newSizes);
|
|
156
180
|
if (onResize !== undefined) {
|
|
157
181
|
return onResize(newSizes);
|
|
158
182
|
}
|
|
@@ -173,14 +197,14 @@ function Basefn__Resizable(props) {
|
|
|
173
197
|
let origLeft = info.startSizes[li];
|
|
174
198
|
let origRight = info.startSizes[ri];
|
|
175
199
|
let match = clampSizes(li, ri, origLeft + deltaPercent, origRight - deltaPercent);
|
|
176
|
-
let newSizes = Xote.
|
|
200
|
+
let newSizes = Signal$Xote.get(sizes).slice();
|
|
177
201
|
newSizes[li] = match[0];
|
|
178
202
|
newSizes[ri] = match[1];
|
|
179
203
|
applySizes(newSizes);
|
|
180
204
|
};
|
|
181
205
|
let onMouseUp = param => {
|
|
182
206
|
dragRef.contents = undefined;
|
|
183
|
-
Xote.
|
|
207
|
+
Signal$Xote.set(isDragging, false);
|
|
184
208
|
enableSelect();
|
|
185
209
|
removeDocListener("mousemove", onMouseMove);
|
|
186
210
|
removeDocListener("mouseup", onMouseUp);
|
|
@@ -195,10 +219,10 @@ function Basefn__Resizable(props) {
|
|
|
195
219
|
dragRef.contents = {
|
|
196
220
|
handleIndex: handleIndex,
|
|
197
221
|
startPos: getPos(evt),
|
|
198
|
-
startSizes: Xote.
|
|
222
|
+
startSizes: Signal$Xote.get(sizes).slice(),
|
|
199
223
|
container: maybeContainer
|
|
200
224
|
};
|
|
201
|
-
Xote.
|
|
225
|
+
Signal$Xote.set(isDragging, true);
|
|
202
226
|
disableSelect();
|
|
203
227
|
addDocListener("mousemove", onMouseMove);
|
|
204
228
|
addDocListener("mouseup", onMouseUp);
|
|
@@ -206,25 +230,25 @@ function Basefn__Resizable(props) {
|
|
|
206
230
|
return addDocListener("touchend", onMouseUp);
|
|
207
231
|
}
|
|
208
232
|
};
|
|
209
|
-
|
|
233
|
+
registerInstance(containerId, startDrag);
|
|
210
234
|
let containerClass = "basefn-resizable basefn-resizable--" + directionToString(direction) + (
|
|
211
235
|
$$class !== "" ? " " + $$class : ""
|
|
212
236
|
);
|
|
213
237
|
let elements = [];
|
|
214
238
|
panels.forEach((panel, index) => {
|
|
215
|
-
let panelStyle = Xote.
|
|
216
|
-
let size = Xote.
|
|
239
|
+
let panelStyle = Computed$Xote.make(() => {
|
|
240
|
+
let size = Signal$Xote.get(sizes)[index];
|
|
217
241
|
return "flex-basis:" + size.toString() + "%;flex-grow:0;flex-shrink:0";
|
|
218
242
|
}, undefined);
|
|
219
|
-
let panelClass = Xote.
|
|
243
|
+
let panelClass = Computed$Xote.make(() => {
|
|
220
244
|
let base = "basefn-resizable__panel";
|
|
221
|
-
if (Xote.
|
|
245
|
+
if (Signal$Xote.get(isDragging)) {
|
|
222
246
|
return base + " basefn-resizable__panel--dragging";
|
|
223
247
|
} else {
|
|
224
248
|
return base;
|
|
225
249
|
}
|
|
226
250
|
}, undefined);
|
|
227
|
-
elements.push(
|
|
251
|
+
elements.push(XoteJSX$Xote.Elements.jsxKeyed("div", {
|
|
228
252
|
class: panelClass,
|
|
229
253
|
style: panelStyle,
|
|
230
254
|
children: panel.content
|
|
@@ -235,14 +259,14 @@ function Basefn__Resizable(props) {
|
|
|
235
259
|
let handleClass = "basefn-resizable__handle basefn-resizable__handle--" + directionToString(direction) + (
|
|
236
260
|
withHandle ? " basefn-resizable__handle--with-grip" : ""
|
|
237
261
|
);
|
|
238
|
-
elements.push(
|
|
262
|
+
elements.push(XoteJSX$Xote.Elements.jsxKeyed("div", {
|
|
239
263
|
class: handleClass,
|
|
240
264
|
role: "separator",
|
|
241
265
|
tabIndex: 0,
|
|
242
266
|
onKeyDown: evt => {
|
|
243
267
|
let key = getKey(evt);
|
|
244
268
|
let ri = index + 1 | 0;
|
|
245
|
-
let currentSizes = Xote.
|
|
269
|
+
let currentSizes = Signal$Xote.get(sizes);
|
|
246
270
|
let left = currentSizes[index];
|
|
247
271
|
let right = currentSizes[ri];
|
|
248
272
|
let delta;
|
|
@@ -279,15 +303,19 @@ function Basefn__Resizable(props) {
|
|
|
279
303
|
newSizes[ri] = match[1];
|
|
280
304
|
applySizes(newSizes);
|
|
281
305
|
},
|
|
282
|
-
|
|
306
|
+
onMouseEnter: evt => {
|
|
307
|
+
let el = getCurrentTarget(evt);
|
|
308
|
+
initHandle(el, index, startDrag);
|
|
309
|
+
},
|
|
310
|
+
children: withHandle ? XoteJSX$Xote.Elements.jsx("div", {
|
|
283
311
|
class: "basefn-resizable__handle-grip"
|
|
284
|
-
}) :
|
|
312
|
+
}) : XoteJSX$Xote.jsx(XoteJSX$Xote.jsxFragment, {})
|
|
285
313
|
}, "handle-" + index.toString(), undefined));
|
|
286
314
|
});
|
|
287
|
-
return
|
|
315
|
+
return XoteJSX$Xote.Elements.jsx("div", {
|
|
288
316
|
id: containerId,
|
|
289
317
|
class: containerClass,
|
|
290
|
-
children: Xote.
|
|
318
|
+
children: Node$Xote.fragment(elements)
|
|
291
319
|
});
|
|
292
320
|
}
|
|
293
321
|
|
|
@@ -307,7 +335,9 @@ export {
|
|
|
307
335
|
getEventTarget,
|
|
308
336
|
preventDefault,
|
|
309
337
|
genId,
|
|
310
|
-
|
|
338
|
+
registerInstance,
|
|
339
|
+
initHandle,
|
|
340
|
+
getCurrentTarget,
|
|
311
341
|
make,
|
|
312
342
|
}
|
|
313
343
|
/* Not a pure module */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
-
import * as
|
|
3
|
+
import * as XoteJSX$Xote from "xote/src/XoteJSX.res.mjs";
|
|
4
4
|
|
|
5
5
|
import './Basefn__ScrollArea.css'
|
|
6
6
|
;
|
|
@@ -46,7 +46,7 @@ function Basefn__ScrollArea(props) {
|
|
|
46
46
|
let maxWidthStyle = maxWidth !== undefined ? "max-width: " + maxWidth + ";" : "";
|
|
47
47
|
return maxHeightStyle + maxWidthStyle;
|
|
48
48
|
};
|
|
49
|
-
return
|
|
49
|
+
return XoteJSX$Xote.Elements.jsx("div", {
|
|
50
50
|
class: getClassName(),
|
|
51
51
|
style: getStyle(),
|
|
52
52
|
children: props.children
|
|
@@ -26,8 +26,8 @@ let make = (
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
<select name="test" class="basefn-select" value={value} disabled onChange>
|
|
29
|
-
{
|
|
30
|
-
<option value={opt.value}> {
|
|
29
|
+
{Node.list(options, opt =>
|
|
30
|
+
<option value={opt.value}> {Node.text(opt.label)} </option>
|
|
31
31
|
)}
|
|
32
32
|
</select>
|
|
33
33
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
-
import * as Xote from "xote/src/
|
|
4
|
-
import * as
|
|
3
|
+
import * as Node$Xote from "xote/src/Node.res.mjs";
|
|
4
|
+
import * as Signal$Xote from "xote/src/Signal.res.mjs";
|
|
5
|
+
import * as XoteJSX$Xote from "xote/src/XoteJSX.res.mjs";
|
|
5
6
|
|
|
6
7
|
import './Basefn__Select.css'
|
|
7
8
|
;
|
|
@@ -14,20 +15,20 @@ function Basefn__Select(props) {
|
|
|
14
15
|
let onChange$1 = e => {
|
|
15
16
|
let t = e.target;
|
|
16
17
|
let v = t.value;
|
|
17
|
-
Xote.
|
|
18
|
+
Signal$Xote.set(value, v);
|
|
18
19
|
if (onChange !== undefined) {
|
|
19
20
|
return onChange(v);
|
|
20
21
|
}
|
|
21
22
|
};
|
|
22
|
-
return
|
|
23
|
+
return XoteJSX$Xote.Elements.jsx("select", {
|
|
23
24
|
class: "basefn-select",
|
|
24
25
|
name: "test",
|
|
25
26
|
value: value,
|
|
26
27
|
disabled: disabled,
|
|
27
28
|
onChange: onChange$1,
|
|
28
|
-
children: Xote.
|
|
29
|
+
children: Node$Xote.list(props.options, opt => XoteJSX$Xote.Elements.jsx("option", {
|
|
29
30
|
value: opt.value,
|
|
30
|
-
children: Xote.
|
|
31
|
+
children: Node$Xote.text(opt.label)
|
|
31
32
|
}))
|
|
32
33
|
});
|
|
33
34
|
}
|
|
@@ -37,7 +37,7 @@ let make = (
|
|
|
37
37
|
| Some(text) =>
|
|
38
38
|
<div class={getClassName() ++ " basefn-separator--with-label"}>
|
|
39
39
|
<div class="basefn-separator__line" />
|
|
40
|
-
<span class="basefn-separator__label"> {
|
|
40
|
+
<span class="basefn-separator__label"> {Node.text(text)} </span>
|
|
41
41
|
<div class="basefn-separator__line" />
|
|
42
42
|
</div>
|
|
43
43
|
| None => <div class={getClassName()} role="separator" />
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
-
import * as Xote from "xote/src/
|
|
4
|
-
import * as
|
|
3
|
+
import * as Node$Xote from "xote/src/Node.res.mjs";
|
|
4
|
+
import * as XoteJSX$Xote from "xote/src/XoteJSX.res.mjs";
|
|
5
5
|
|
|
6
6
|
import './Basefn__Separator.css'
|
|
7
7
|
;
|
|
@@ -37,23 +37,23 @@ function Basefn__Separator(props) {
|
|
|
37
37
|
return "basefn-separator " + orientationClass + " " + variantClass;
|
|
38
38
|
};
|
|
39
39
|
if (label !== undefined) {
|
|
40
|
-
return
|
|
40
|
+
return XoteJSX$Xote.Elements.jsxs("div", {
|
|
41
41
|
class: getClassName() + " basefn-separator--with-label",
|
|
42
|
-
children:
|
|
43
|
-
|
|
42
|
+
children: XoteJSX$Xote.array([
|
|
43
|
+
XoteJSX$Xote.Elements.jsx("div", {
|
|
44
44
|
class: "basefn-separator__line"
|
|
45
45
|
}),
|
|
46
|
-
|
|
46
|
+
XoteJSX$Xote.Elements.jsx("span", {
|
|
47
47
|
class: "basefn-separator__label",
|
|
48
|
-
children: Xote.
|
|
48
|
+
children: Node$Xote.text(label)
|
|
49
49
|
}),
|
|
50
|
-
|
|
50
|
+
XoteJSX$Xote.Elements.jsx("div", {
|
|
51
51
|
class: "basefn-separator__line"
|
|
52
52
|
})
|
|
53
53
|
])
|
|
54
54
|
});
|
|
55
55
|
} else {
|
|
56
|
-
return
|
|
56
|
+
return XoteJSX$Xote.Elements.jsx("div", {
|
|
57
57
|
class: getClassName(),
|
|
58
58
|
role: "separator"
|
|
59
59
|
});
|