@webority/ui-react 0.60.1 → 0.61.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"./warnInvalidValue.js";import t from"./warnUnknownProps.js";import{shortcutAria as n}from"../lib/shortcutChip.js";import r from"./withTooltip.js";import i from"./renderIconProp.js";import{
|
|
1
|
+
import e from"./warnInvalidValue.js";import t from"./warnUnknownProps.js";import{shortcutAria as n}from"../lib/shortcutChip.js";import r from"./withTooltip.js";import i from"./renderIconProp.js";import{useRef as a}from"react";import{Fragment as o,jsx as s,jsxs as c}from"react/jsx-runtime";var l=[`linear`,`outline`,`bold`,`bulk`,`broken`,`twotone`];function u({icon:u,iconVariant:d,label:f,tooltipPlacement:p=`auto`,shortcut:m,danger:h=!1,disabled:g=!1,size:_=20,onClick:v,className:y=``,as:b,href:x,accept:S,multiple:C=!1,onFiles:w,...T}){t(`AppActionIcon`,b===void 0?T:{...T,as:b}),e(`AppActionIcon`,`iconVariant`,d,l);let E=typeof w==`function`;E&&(b!==void 0||x!==void 0)&&console.warn(`AppActionIcon: file mode renders a button; href and as are ignored.`),!E&&(S!==void 0||C)&&console.warn(`AppActionIcon: accept and multiple apply only in file mode (pass onFiles).`);let D=a(null),O=e=>{let t=[...e.target.files];e.target.value=``,t.length>0&&w(t)},k=[`u-action`,h?`danger`:``,y].filter(Boolean).join(` `),{style:A,...j}=T,M={"--wui-action-size":`${_+16}px`,...A},N=E?`button`:b??(x?`a`:`button`),P=N===`button`,F=r(s(N,{type:P?`button`:void 0,href:P||g?void 0:x,className:k,style:M,"aria-label":f,"aria-keyshortcuts":n(m),disabled:P?g:void 0,"aria-disabled":!P&&g?`true`:void 0,role:!P&&g?`link`:void 0,tabIndex:!P&&g?-1:void 0,onClick:e=>{if(g){e.preventDefault(),e.stopPropagation();return}v?.(e),E&&!e.defaultPrevented&&D.current?.click()},...j,children:i(u,{size:_,variant:d})}),f,p,m);return E?c(o,{children:[F,s(`input`,{type:`file`,ref:D,className:`wui-action-icon-file`,hidden:!0,tabIndex:-1,"aria-hidden":`true`,accept:S,multiple:C,onChange:O,onClick:e=>e.stopPropagation()})]}):F}export{u as default};
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* `label` is required: an icon-only control with no accessible name is unusable with a screen
|
|
8
8
|
* reader, and it doubles as the hover/focus tooltip — shown through `AppTooltip` (Popper), so it
|
|
9
9
|
* is collision-aware: it prefers `tooltipPlacement` and flips to stay on-screen.
|
|
10
|
+
* A camera on a defect or a paperclip on a ticket uses its file mode (`onFiles`).
|
|
10
11
|
*
|
|
11
12
|
* @param {object} props
|
|
12
13
|
* @param {string|import('react').ReactNode} props.icon glyph name (see Icon), or a custom node (e.g. an iconsax glyph)
|
|
@@ -29,8 +30,11 @@
|
|
|
29
30
|
* for the tooltip (Popper) to anchor correctly — router `Link`s already do; a hand-rolled `as`
|
|
30
31
|
* wrapper must use `forwardRef` (the tooltip still opens without it, but may be mispositioned).
|
|
31
32
|
* @param {string} [props.href] sets an anchor without needing `as`.
|
|
33
|
+
* @param {(files: File[]) => void} [props.onFiles] turns the button into a file chooser: a hidden file input opens on click, Enter and Space, and the chosen files arrive here. The control is always a button in this mode.
|
|
34
|
+
* @param {string} [props.accept] file types the chooser offers (the input's accept), file mode only
|
|
35
|
+
* @param {boolean} [props.multiple=false] allow several files, file mode only
|
|
32
36
|
*/
|
|
33
|
-
export default function AppActionIcon({ icon, iconVariant, label, tooltipPlacement, shortcut, danger, disabled, size, onClick, className, as, href, ...rest }: {
|
|
37
|
+
export default function AppActionIcon({ icon, iconVariant, label, tooltipPlacement, shortcut, danger, disabled, size, onClick, className, as, href, accept, multiple, onFiles, ...rest }: {
|
|
34
38
|
icon: string | import('react').ReactNode;
|
|
35
39
|
iconVariant?: 'linear' | 'outline' | 'bold' | 'bulk' | 'broken' | 'twotone';
|
|
36
40
|
label: string;
|
|
@@ -43,4 +47,7 @@ export default function AppActionIcon({ icon, iconVariant, label, tooltipPlaceme
|
|
|
43
47
|
className?: string;
|
|
44
48
|
as?: React.ElementType;
|
|
45
49
|
href?: string;
|
|
50
|
+
onFiles?: (files: File[]) => void;
|
|
51
|
+
accept?: string;
|
|
52
|
+
multiple?: boolean;
|
|
46
53
|
}): any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/ui-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.61.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.61.0",
|
|
31
|
+
"@webority/ui-elements": "0.61.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@webority/analytics": "^0.23.0",
|