@efolusi/meridian 1.14.0 → 1.16.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/components.css CHANGED
@@ -1019,6 +1019,12 @@ button.ef-listitem:focus-visible{outline:none;box-shadow:var(--focus-ring)}
1019
1019
  .ef-input--icon.ef-input--md .ef-input__el{padding-left:36px}
1020
1020
  .ef-input--icon.ef-input--lg .ef-input__el{padding-left:40px}
1021
1021
  .ef-input__icon{position:absolute;left:11px;color:var(--text-muted);display:inline-flex;pointer-events:none}
1022
+ .ef-input__reveal{position:absolute;right:6px;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:none;border-radius:var(--radius-sm);background:none;color:var(--text-muted);cursor:pointer}
1023
+ .ef-input__reveal:hover{color:var(--text-primary)}
1024
+ .ef-input__reveal:focus-visible{outline:none;box-shadow:var(--focus-ring)}
1025
+ .ef-input--reveal.ef-input--sm .ef-input__el{padding-right:34px}
1026
+ .ef-input--reveal.ef-input--md .ef-input__el{padding-right:38px}
1027
+ .ef-input--reveal.ef-input--lg .ef-input__el{padding-right:42px}
1022
1028
  .ef-input--invalid .ef-input__el{border-color:var(--danger-600)}
1023
1029
  .ef-input--invalid .ef-input__el:focus{box-shadow:var(--focus-ring-danger)}
1024
1030
  /* components/forms/InputGroup.jsx */
@@ -1275,14 +1281,10 @@ a.ef-crumbs__link:hover{color:var(--text-primary);text-decoration:none}
1275
1281
  .ef-hovercard__trigger{display:inline-flex;border-radius:var(--radius-sm)}
1276
1282
  .ef-hovercard__trigger:focus-visible{outline:none;box-shadow:var(--focus-ring)}
1277
1283
  .ef-hovercard__panel{position:absolute;left:0;background:var(--surface-card);border:1px solid var(--border-strong);border-radius:var(--radius-md);box-shadow:var(--shadow-md);padding:14px;z-index:var(--z-popover);animation:ef-hovercard-in var(--dur-med) var(--ease-out)}
1278
- .ef-hovercard__panel--bottom{top:calc(100% + 8px)}
1279
- .ef-hovercard__panel--top{bottom:calc(100% + 8px)}
1280
1284
  @keyframes ef-hovercard-in{from{opacity:0;transform:translateY(2px)}}
1281
1285
  /* components/overlay/Menu.jsx */
1282
1286
  .ef-menu{position:relative;display:inline-flex}
1283
1287
  .ef-menu__panel{position:absolute;top:calc(100% + 6px);min-width:190px;background:var(--surface-card);border:1px solid var(--border-strong);border-radius:var(--radius-md);box-shadow:var(--shadow-md);padding:4px;z-index:var(--z-dropdown);animation:ef-menu-in var(--dur-fast) var(--ease-out)}
1284
- .ef-menu__panel--left{left:0}
1285
- .ef-menu__panel--right{right:0}
1286
1288
  @keyframes ef-menu-in{from{opacity:0;transform:translateY(-3px)}to{opacity:1;transform:translateY(0)}}
1287
1289
  .ef-menu__item{display:flex;align-items:center;gap:9px;width:100%;height:32px;padding:0 10px;border:none;border-radius:var(--radius-sm);background:none;cursor:pointer;text-align:left;font-family:var(--font-sans);font-size:var(--text-sm);color:var(--text-primary);transition:background var(--dur-fast) var(--ease-out)}
1288
1290
  .ef-menu__item:hover:not(:disabled){background:var(--surface-sunken)}
@@ -1296,8 +1298,6 @@ a.ef-crumbs__link:hover{color:var(--text-primary);text-decoration:none}
1296
1298
  /* components/overlay/Popover.jsx */
1297
1299
  .ef-popover{position:relative;display:inline-flex}
1298
1300
  .ef-popover__panel{position:absolute;top:calc(100% + 8px);width:280px;background:var(--surface-card);border:1px solid var(--border-strong);border-radius:var(--radius-md);box-shadow:var(--shadow-md);padding:14px;z-index:var(--z-dropdown);animation:ef-pop-in var(--dur-fast) var(--ease-out)}
1299
- .ef-popover__panel--left{left:0}
1300
- .ef-popover__panel--right{right:0}
1301
1301
  @keyframes ef-pop-in{from{opacity:0;transform:translateY(-3px)}}
1302
1302
  /* components/overlay/Portal.jsx */
1303
1303
  .ef-portal{position:fixed;top:0;left:0;width:0;height:0}
package/forms/Input.d.ts CHANGED
@@ -10,5 +10,11 @@ export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElem
10
10
  /** @default 'md' */
11
11
  size?: 'sm' | 'md' | 'lg';
12
12
  invalid?: boolean;
13
+ /** Adds a show/hide button to a `type="password"` field */
14
+ revealable?: boolean;
15
+ /** @default 'Show password' */
16
+ revealLabel?: string;
17
+ /** @default 'Hide password' */
18
+ hideLabel?: string;
13
19
  }
14
20
  export declare function Input(props: InputProps): React.JSX.Element;
package/forms/Input.js CHANGED
@@ -10,10 +10,18 @@ export function Input({
10
10
  iconLeft,
11
11
  size = 'md',
12
12
  invalid,
13
+ revealable,
14
+ revealLabel = 'Show password',
15
+ hideLabel = 'Hide password',
13
16
  style,
14
17
  className,
15
18
  ...rest
16
19
  }) {
20
+ // A password field people cannot read back is a password field people mistype.
21
+ // The toggle is a real button so it is reachable by keyboard, and it is left
22
+ // out of the tab order only when there is nothing to reveal.
23
+ const [revealed, setRevealed] = React.useState(false);
24
+ const showToggle = revealable && rest.type === 'password';
17
25
  // Picks up id / aria wiring when nested in a FormField; standalone this is a no-op.
18
26
  const field = useFieldProps({
19
27
  invalid,
@@ -23,7 +31,7 @@ export function Input({
23
31
  });
24
32
  const bad = field.invalid;
25
33
  const control = /*#__PURE__*/React.createElement("span", {
26
- className: `ef-input ef-input--${size}${iconLeft ? ' ef-input--icon' : ''}${bad ? ' ef-input--invalid' : ''}`
34
+ className: `ef-input ef-input--${size}${iconLeft ? ' ef-input--icon' : ''}${showToggle ? ' ef-input--reveal' : ''}${bad ? ' ef-input--invalid' : ''}`
27
35
  }, iconLeft ? /*#__PURE__*/React.createElement("span", {
28
36
  className: "ef-input__icon"
29
37
  }, /*#__PURE__*/React.createElement(Icon, {
@@ -32,7 +40,18 @@ export function Input({
32
40
  })) : null, /*#__PURE__*/React.createElement("input", _extends({
33
41
  className: "ef-input__el",
34
42
  "aria-invalid": bad || undefined
35
- }, rest, field.controlProps)));
43
+ }, rest, field.controlProps, {
44
+ type: showToggle && revealed ? 'text' : rest.type
45
+ })), showToggle ? /*#__PURE__*/React.createElement("button", {
46
+ type: "button",
47
+ className: "ef-input__reveal",
48
+ "aria-label": revealed ? hideLabel : revealLabel,
49
+ "aria-pressed": revealed,
50
+ onClick: () => setRevealed(v => !v)
51
+ }, /*#__PURE__*/React.createElement(Icon, {
52
+ name: revealed ? 'eye-off' : 'eye',
53
+ size: 16
54
+ })) : null);
36
55
  if (!label && !hint && !error) return /*#__PURE__*/React.cloneElement(control, {
37
56
  style,
38
57
  className: control.props.className + (className ? ' ' + className : '')
@@ -2,6 +2,8 @@
2
2
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
3
  import React from 'react';
4
4
  import { Portal, useAnchoredStyle } from "./Portal.js";
5
+ // Panel modifiers pin no edge on purpose; see useAnchoredStyle in Portal.jsx.
6
+
5
7
  export function HoverCard({
6
8
  trigger,
7
9
  side = 'bottom',
package/overlay/Menu.js CHANGED
@@ -4,6 +4,8 @@ import React from 'react';
4
4
  import { Icon } from "../icons/Icon.js";
5
5
  import { mergeRefs } from "../forms/Button.js";
6
6
  import { Portal, useAnchoredStyle } from "./Portal.js";
7
+ // Panel modifiers pin no edge on purpose; see useAnchoredStyle in Portal.jsx.
8
+
7
9
  export const Menu = /*#__PURE__*/React.forwardRef(function Menu({
8
10
  trigger,
9
11
  items,
@@ -3,6 +3,8 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
3
3
  import React from 'react';
4
4
  import { mergeRefs } from "../forms/Button.js";
5
5
  import { Portal, useAnchoredStyle } from "./Portal.js";
6
+ // Panel modifiers pin no edge on purpose; see useAnchoredStyle in Portal.jsx.
7
+
6
8
  export const Popover = /*#__PURE__*/React.forwardRef(function Popover({
7
9
  trigger,
8
10
  children,
package/overlay/Portal.js CHANGED
@@ -56,10 +56,17 @@ export function useAnchoredStyle(anchorRef, panelRef, {
56
56
  matchWidth = false
57
57
  } = {}) {
58
58
  const [state, setState] = React.useState({
59
+ // `right`/`bottom` are pinned to auto from the very first frame. A panel
60
+ // whose class also sets `right: 0` (every align="right" menu) would
61
+ // otherwise be laid out with both edges pinned, stretch to the full
62
+ // viewport, and get measured at that width — so the clamp below shoved it
63
+ // against the left edge instead of under its trigger.
59
64
  style: {
60
65
  position: 'fixed',
61
66
  top: 0,
62
67
  left: 0,
68
+ right: 'auto',
69
+ bottom: 'auto',
63
70
  visibility: 'hidden'
64
71
  },
65
72
  side: placement
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@efolusi/meridian",
3
- "version": "1.14.0",
3
+ "version": "1.16.0",
4
4
  "description": "A general-purpose open-source design system by Efolusi: accessible React components, design tokens, blocks and example apps.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://meridian.efolusi.com",