oneslash-design-system 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import React, { useState, useEffect, isValidElement } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
import { usePopper } from 'react-popper';
|
|
5
5
|
import { overlayHidden, overlayTransition, overlayVisible } from './sharedStyles';
|
|
6
6
|
import { useOverlayTransition } from './useOverlayTransition';
|
|
7
|
+
import Menu from './menu';
|
|
7
8
|
export default function Popover(_a) {
|
|
8
9
|
var id = _a.id, anchorEl = _a.anchorEl, open = _a.open, onClose = _a.onClose, children = _a.children;
|
|
9
10
|
var _b = useState(null), popoverElement = _b[0], setPopoverElement = _b[1];
|
|
@@ -44,11 +45,17 @@ export default function Popover(_a) {
|
|
|
44
45
|
}, []);
|
|
45
46
|
if (!mounted || !hasMounted || !anchorEl)
|
|
46
47
|
return null;
|
|
48
|
+
// A Menu brings its own surface (4px inset, container corners), so the
|
|
49
|
+
// popover adds none around it rather than doubling the padding and edges.
|
|
50
|
+
var isMenu = isValidElement(children) && children.type === Menu;
|
|
51
|
+
var panelClass = isMenu
|
|
52
|
+
? ''
|
|
53
|
+
: 'bg-background-overlay dark:ring-1 dark:ring-misc-divider rounded-control shadow-overlay p-2';
|
|
47
54
|
// Render popover in a portal to prevent layout shifts and positioning issues
|
|
48
55
|
// dark-only edge: a ring only in dark mode, so it keeps a dark: variant (it follows whatever dark variant the app's preset/@theme defines, class-only or OS-aware)
|
|
49
56
|
return createPortal(<div id={id} ref={setPopoverElement} style={styles.popper} {...attributes.popper} className="z-[var(--os-z-overlay)]" role="dialog">
|
|
50
57
|
{/* Popper owns the outer transform, so the fade and scale go on this inner panel */}
|
|
51
|
-
<div className={"
|
|
58
|
+
<div className={"".concat(panelClass, " origin-top-left\n ").concat(overlayTransition, " ").concat(visible ? overlayVisible : overlayHidden)}>
|
|
52
59
|
{children}
|
|
53
60
|
</div>
|
|
54
61
|
</div>, document.body // Mounting the popover in the document body for isolation
|
|
@@ -24,15 +24,15 @@ export default function TextField(_a) {
|
|
|
24
24
|
var colorClasses = disabled
|
|
25
25
|
? 'bg-transparent text-fg-disabled cursor-not-allowed'
|
|
26
26
|
: 'bg-background-default text-fg-primary';
|
|
27
|
-
// Border: error > focus (
|
|
27
|
+
// Border: error > focus (1px offset outline, the same weight as the border) > hover > default
|
|
28
28
|
var getBorderColor = function () {
|
|
29
29
|
if (error) {
|
|
30
|
-
return 'border-error-main focus:outline focus:outline-
|
|
30
|
+
return 'border-error-main focus:outline focus:outline-1 focus:outline-offset-2 focus:outline-error-main';
|
|
31
31
|
}
|
|
32
32
|
if (disabled) {
|
|
33
33
|
return 'border-fg-disabled';
|
|
34
34
|
}
|
|
35
|
-
return "border-fg-disabled\n hover:border-fg-secondary\n focus:outline focus:outline-
|
|
35
|
+
return "border-fg-disabled\n hover:border-fg-secondary\n focus:outline focus:outline-1 focus:outline-offset-2 focus:outline-fg-primary";
|
|
36
36
|
};
|
|
37
37
|
var errorId = "".concat(id, "-error");
|
|
38
38
|
// Get inputMode for mobile keyboard optimization
|
|
@@ -48,15 +48,15 @@ export default function Textarea(_a) {
|
|
|
48
48
|
var colorClasses = disabled
|
|
49
49
|
? 'bg-transparent text-fg-disabled cursor-not-allowed'
|
|
50
50
|
: 'bg-background-default text-fg-primary';
|
|
51
|
-
// Border: error > focus (
|
|
51
|
+
// Border: error > focus (1px offset outline, the same weight as the border) > hover > default
|
|
52
52
|
var getBorderColor = function () {
|
|
53
53
|
if (error) {
|
|
54
|
-
return 'border-error-main focus:outline focus:outline-
|
|
54
|
+
return 'border-error-main focus:outline focus:outline-1 focus:outline-offset-2 focus:outline-error-main';
|
|
55
55
|
}
|
|
56
56
|
if (disabled) {
|
|
57
57
|
return 'border-fg-disabled';
|
|
58
58
|
}
|
|
59
|
-
return "border-fg-disabled\n hover:border-fg-secondary\n focus:outline focus:outline-
|
|
59
|
+
return "border-fg-disabled\n hover:border-fg-secondary\n focus:outline focus:outline-1 focus:outline-offset-2 focus:outline-fg-primary";
|
|
60
60
|
};
|
|
61
61
|
var containerClasses = "\n ".concat(colorClasses, "\n ").concat(baseClasses, "\n ").concat(sizeClasses, "\n ").concat(getBorderColor(), "\n ");
|
|
62
62
|
var errorId = "".concat(id, "-error");
|