@webority/ui-react 0.66.0 → 0.67.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"./warnUnknownProps.js";import{cloneElement as
|
|
1
|
+
import e from"./warnInvalidValue.js";import t from"./warnUnknownProps.js";import n from"../lib/FocusPanel.js";import{cloneElement as r,useId as i,useRef as a,useState as o}from"react";import{OverlayTrigger as s,Popover as c}from"react-bootstrap";import{jsx as l,jsxs as u}from"react/jsx-runtime";var d={start:`left`,end:`right`,top:`top`,bottom:`bottom`,auto:`auto`},f={modifiers:[{name:`computeStyles`,options:{gpuAcceleration:!1}}]},p=[`dialog`];function m({trigger:m,children:h,title:g,placement:_=`bottom`,triggerType:v=`click`,onToggle:y,className:b=``,show:x,role:S,labelledBy:C,autoFocus:w=!1,...T}){t(`AppPopover`,T),e(`AppPopover`,`role`,S,p);let E=i(),D=`${E}-title`,O=a(null),[k,A]=o(!1),j=x!==void 0,M=j?x:k,N=S===`dialog`,P=e=>{j||A(e),y?.(e)},F=u(c,{id:E,className:b||void 0,...N?{role:`dialog`,"aria-modal":`false`,"aria-labelledby":C??(g?D:void 0)}:{},children:[w&&l(n,{triggerRef:O}),g&&l(c.Header,{as:`h3`,id:D,children:g}),h==null?null:l(c.Body,{children:h})]}),{onClick:I,"aria-expanded":L,...R}=T,z=m.props[`aria-expanded`],B,V=v===`click`||Array.isArray(v)&&v.includes(`click`);L===void 0?z===void 0?V&&(B=M):B=z:B=L;let H=r(m,{...R,...B===void 0?{}:{"aria-expanded":B},onClick:e=>{O.current=e.currentTarget,I?.(e),typeof m.props.onClick==`function`&&m.props.onClick(e)}}),U=v===`click`,W=v===`hover`||Array.isArray(v)&&v.includes(`hover`);return l(s,{trigger:v,placement:d[_]||_,popperConfig:f,overlay:F,rootClose:U||N,delay:W?{show:80,hide:220}:void 0,onToggle:P,...j?{show:x}:{},children:H})}export{m as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useEffect as e,useRef as t}from"react";import{jsx as n}from"react/jsx-runtime";var r=`a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function i({triggerRef:i}){let a=t(null);return e(()=>{let e=i.current??document.activeElement;return a.current?.parentElement?.querySelector(r)?.focus(),()=>e?.focus?.()},[i]),n(`span`,{ref:a,hidden:!0})}export{i as default};
|
|
@@ -18,8 +18,14 @@
|
|
|
18
18
|
* opens it; pass an array for multiple (e.g. ['hover', 'focus']).
|
|
19
19
|
* @param {(show: boolean) => void} [props.onToggle] Callback fired when the panel opens/closes.
|
|
20
20
|
* @param {string} [props.className] Class on the popover panel.
|
|
21
|
+
* @param {boolean} [props.show] Controls the open state. When set, the panel follows it, and
|
|
22
|
+
* `onToggle` reports each request to change it.
|
|
23
|
+
* @param {'dialog'} [props.role] `dialog` names the panel after `title` or `labelledBy`, sets
|
|
24
|
+
* `aria-modal="false"`, and lets Escape close it.
|
|
25
|
+
* @param {string} [props.labelledBy] Id of the element that names a dialog panel; wins over `title`.
|
|
26
|
+
* @param {boolean} [props.autoFocus=false] Moves focus into the panel on open and back to the trigger on close.
|
|
21
27
|
*/
|
|
22
|
-
export default function AppPopover({ trigger, children, title, placement, triggerType, onToggle, className, ...rest }: {
|
|
28
|
+
export default function AppPopover({ trigger, children, title, placement, triggerType, onToggle, className, show, role, labelledBy, autoFocus, ...rest }: {
|
|
23
29
|
trigger: import('react').ReactElement;
|
|
24
30
|
children: import('react').ReactNode;
|
|
25
31
|
title?: string;
|
|
@@ -27,4 +33,8 @@ export default function AppPopover({ trigger, children, title, placement, trigge
|
|
|
27
33
|
triggerType?: 'click' | 'hover' | 'focus' | ('click' | 'hover' | 'focus')[];
|
|
28
34
|
onToggle?: (show: boolean) => void;
|
|
29
35
|
className?: string;
|
|
36
|
+
show?: boolean;
|
|
37
|
+
role?: 'dialog';
|
|
38
|
+
labelledBy?: string;
|
|
39
|
+
autoFocus?: boolean;
|
|
30
40
|
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rendered inside an open panel: mounting it moves focus to the panel's first focusable element, and
|
|
3
|
+
* unmounting it (close, Escape or an outside click) hands focus back to whatever opened the panel,
|
|
4
|
+
* which is the trigger for a click.
|
|
5
|
+
* @internal not exported from the package barrel
|
|
6
|
+
*/
|
|
7
|
+
export default function FocusPanel({ triggerRef }: {
|
|
8
|
+
triggerRef: any;
|
|
9
|
+
}): import("react").JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/ui-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.67.0",
|
|
4
4
|
"description": "Webority shared React component library — App* primitives on react-bootstrap + the @webority/theme design system.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
},
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@webority/theme": "0.
|
|
31
|
-
"@webority/ui-elements": "0.
|
|
30
|
+
"@webority/theme": "0.67.0",
|
|
31
|
+
"@webority/ui-elements": "0.67.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@webority/analytics": "^0.23.0",
|