@webority/ui-react 0.75.1 → 0.76.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 n from"./withTooltip.js";import r from"./
|
|
1
|
+
import e from"./warnInvalidValue.js";import t from"./warnUnknownProps.js";import n from"./withTooltip.js";import r from"./renderIconProp.js";import{initialsOf as i}from"../lib/initials.js";import{useEffect as a,useState as o}from"react";import{Fragment as s,jsx as c,jsxs as l}from"react/jsx-runtime";var u=[`circle`,`rounded`,`square`],d=[`primary`,`neutral`,`success`,`warning`,`danger`,`info`,`auto`],f=[`none`,`online`,`offline`,`away`,`busy`],p=[`linear`,`outline`,`bold`,`bulk`,`broken`,`twotone`],m=new Set([`xs`,`sm`,`md`,`lg`,`xl`,`2xl`]),h={xs:20,sm:24,md:32,lg:48,xl:64,"2xl":96};function g(e){return i(e)||`?`}function _(e){let t=e||``,n=0;for(let e=0;e<t.length;e+=1)n=Math.imul(n,31)+t.charCodeAt(e)>>>0;return n%360}function v(e){if(typeof e==`number`)return e;if(h[e]!=null)return h[e];let t=Number.parseInt(e,10);return Number.isNaN(t)?32:t}function y({name:i,src:h,size:y=`md`,shape:b=`circle`,tone:x=`primary`,status:S=`none`,ring:C=!1,label:w,icon:T,iconVariant:E,badge:D,href:O,onClick:k,linkComponent:A,tooltip:j,tooltipPlacement:M,className:N=``,...P}){t(`AppAvatar`,P),e(`AppAvatar`,`shape`,b,u),e(`AppAvatar`,`tone`,x,d),e(`AppAvatar`,`status`,S,f),e(`AppAvatar`,`iconVariant`,E,p);let{style:F,...I}=P,[L,R]=o(!1);a(()=>{R(!1)},[h]);let z=typeof y==`string`&&m.has(y),B=z?null:typeof y==`number`||/^\d+$/.test(y)?`${y}px`:y,V=O!=null||k!=null,H=h!=null&&h!==``&&!L,U=[`avatar`,z&&y!==`md`?`avatar-${y}`:``,b===`circle`?``:`avatar-${b}`,x===`primary`?``:`avatar-${x}`,C?`avatar-ring`:``,V?`avatar-clickable`:``,N].filter(Boolean).join(` `),W={};B&&(W[`--avatar-size`]=B),x===`auto`&&(W[`--avatar-hue`]=_(i));let G=Object.keys(W).length||F?{...W,...F}:void 0,K=c(`span`,{className:`avatar-face`,"aria-hidden":`true`,children:T!=null&&T!==!1&&T!==``?r(T,{size:Math.round(v(y)*.55),variant:E}):g(i)}),q=l(s,{children:[S!==`none`&&c(`span`,{className:`avatar-status avatar-status-${S}`,"aria-hidden":`true`}),D!=null&&c(`span`,{className:`avatar-badge`,children:D}),w!=null&&c(`span`,{className:`avatar-label`,"aria-hidden":`true`,children:w})]}),J=l(s,{children:[K,H&&c(`img`,{className:`avatar-img`,src:h,alt:V?``:i||`Profile photo`,onError:()=>R(!0)}),q]});if(O!=null){let e=A||`a`,t=A?{to:O}:{href:O};return n(c(e,{className:U,style:G,...I,"aria-label":w||i,...t,onClick:k,children:J}),j,M)}if(k!=null)return n(c(`button`,{type:`button`,className:U,style:G,...I,"aria-label":w||i,onClick:k,children:J}),j,M);if(H)return n(c(`span`,{className:U,style:G,...I,children:J}),j,M);let Y=w?.trim()||i?.trim();return n(Y?c(`span`,{className:U,style:G,...I,role:`img`,"aria-label":Y,children:J}):c(`span`,{className:U,style:G,...I,"aria-hidden":`true`,children:J}),j,M)}export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"./warnInvalidValue.js";import t from"./warnUnknownProps.js";import n from"./AppIcon.js";import ee from"../lib/FieldMessage.js";import te from"./AppPopover.js";import ne from"./AppInfoTip.js";import r from"./AppRequiredMark.js";import{MASK_INPUT_TYPES as re,MASK_NAMES as ie,attachInputMask as ae,evaluatePassword as oe,formatMasked as i,isMaskPattern as se,postedMasked as ce}from"@webority/ui-elements/helpers";import{forwardRef as a,useEffect as o,useId as le,useRef as s,useState as c}from"react";import{Form as l}from"react-bootstrap";import{jsx as u,jsxs as d}from"react/jsx-runtime";var ue=[`sm`,`md`,`lg`],de=[`bare`],f=a(function({label:a,required:f=!1,error:
|
|
1
|
+
import e from"./warnInvalidValue.js";import t from"./warnUnknownProps.js";import n from"./AppIcon.js";import ee from"../lib/FieldMessage.js";import te from"./AppPopover.js";import ne from"./AppInfoTip.js";import r from"./AppRequiredMark.js";import{MASK_INPUT_TYPES as re,MASK_NAMES as ie,attachInputMask as ae,evaluatePassword as oe,formatMasked as i,isMaskPattern as se,postedMasked as ce}from"@webority/ui-elements/helpers";import{forwardRef as a,useEffect as o,useId as le,useRef as s,useState as c}from"react";import{Form as l}from"react-bootstrap";import{jsx as u,jsxs as d}from"react/jsx-runtime";var ue=[`sm`,`md`,`lg`],de=[`bare`],fe=[!0,!1,`above`],f=a(function({label:a,required:f=!1,error:pe,hint:p,help:m,helpLabel:me=`More information`,type:h=`text`,size:g=`md`,leftIcon:_,rightIcon:v,onRightIconClick:he,rightIconLabel:ge,unit:y,id:_e,name:ve,className:ye=``,fieldClassName:b=``,disabled:x=!1,clearable:S=!1,showCount:C=!1,maxLength:w,prefix:T,suffix:E,action:D,floatingLabel:O=!1,variant:k,passwordRequirements:A=!1,requirementsPlacement:j=`auto`,mask:M,postFormatted:N=!1,onMaskChange:P,...F},I){t(`AppInput`,F),e(`AppInput`,`size`,g,ue),e(`AppInput`,`variant`,k,de),e(`AppInput`,`floatingLabel`,O,fe),M!=null&&!se(M)&&e(`AppInput`,`mask`,M,ie),M!=null&&e(`AppInput`,`type`,h,re);let[L,be]=c(!1),[xe,Se]=c(``),R=pe||xe,Ce=le(),z=_e||Ce,B=h===`password`,we=B&&L?`text`:h,V=s(null),Te=e=>{V.current=e,typeof I==`function`?I(e):I&&(I.current=e)},H=String(F.value??F.defaultValue??``),[Ee,U]=c(()=>!!H),[W,G]=c(()=>H.length),K=S&&!x,q=S||C,J=B&&!!A,[De,Oe]=c(H);o(()=>{!J||F.value===void 0||Oe(String(F.value??``))},[F.value,J]),o(()=>{if(!q||F.value===void 0)return;let e=String(F.value??``);U(!!e),G(e.length)},[F.value,q]);let ke=e=>{U(!!e.target.value),G(e.target.value.length),F.onInput?.(e)},Ae=e=>{J&&Oe(e.target.value),q?ke(e):F.onInput?.(e)},je=M?{...F.value!==void 0&&{value:i(M,F.value)},...F.defaultValue!==void 0&&{defaultValue:i(M,F.defaultValue)}}:null,Me=s(P);Me.current=P,o(()=>{let e=V.current;if(!(!M||!e))return ae(e,{mask:M,postFormatted:N,onChange:(e,t)=>Me.current?.(e,t),onInvalidChange:Se})},[M,N]);let Ne=e=>M&&!N&&e?t=>{let n=t.target,ee=new Proxy(n,{get:(e,t)=>{if(t===`value`)return ce(M,e.value);let n=Reflect.get(e,t,e);return typeof n==`function`?n.bind(e):n}});e(Object.create(t,{target:{value:ee}}))}:e,Pe=K?u(`button`,{type:`button`,className:`input-clear`,onClick:()=>{let e=V.current;if(!e)return;let t=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,`value`)?.set;t?t.call(e,``):e.value=``,e.dispatchEvent(new Event(`input`,{bubbles:!0})),U(!1),e.focus()},"aria-label":`Clear`,tabIndex:-1,hidden:!Ee,children:u(n,{name:`x`,size:16})}):null,Y=R&&z?`${z}-error`:void 0,Fe=p&&z?`${z}-hint`:void 0,X=J&&j===`inline`,Ie=X&&z?`${z}-requirements`:void 0,Le=Y||(X?Ie:Fe),Re=[`input`,g===`sm`?`input-sm`:``,g===`lg`?`input-lg`:``,R?`error`:``,B?`pw`:``,y?`num-input`:``,!(O&&a||T||E||y||B||v)&&S&&K?`has-clear`:``,k===`bare`?`input-bare`:``,ye].filter(Boolean).join(` `),Z=u(l.Control,{id:z,name:ve,type:we,className:Re,disabled:x,required:f,"aria-invalid":R?`true`:`false`,"aria-describedby":Le,maxLength:w,...F,onChange:Ne(F.onChange),onBlur:Ne(F.onBlur),...je,placeholder:O?` `:F.placeholder,ref:Te,onInput:q||J?Ae:F.onInput}),Q=A===!0||A,ze=Q&&typeof Q==`object`&&Q.title||`Password requirements`,Be=J?oe(De,Q):null,Ve=J?u(`ul`,{className:`pw-criteria`,"aria-live":`polite`,id:Ie,"aria-label":X?ze:void 0,children:Be.map(e=>d(`li`,{className:`pw-rule ${e.met?`met`:`unmet`}`,children:[u(`span`,{className:`pw-mark`,"aria-hidden":`true`}),u(`span`,{className:`pw-rule-text`,children:e.label}),u(`span`,{className:`visually-hidden`,children:e.met?`: met`:`: not met`})]},e.key))}):null,$;if(O&&a)$=d(`div`,{className:O===`above`?`field-float wui-float-above`:`field-float`,children:[Z,d(`label`,{className:`float-label`,htmlFor:z,children:[a,f&&u(r,{})]})]});else if(D)$=d(`div`,{className:`input-action-row`,children:[d(`div`,{className:_?`input-icon`:`input-wrap`,children:[_&&u(`span`,{className:`ic`,children:u(n,{name:_,size:16})}),Z]}),u(`div`,{className:`input-action`,children:D})]});else if(T||E)$=d(`div`,{className:`input-affixed`,children:[T!=null&&u(`span`,{className:`affix affix-pre`,children:T}),Z,E!=null&&u(`span`,{className:`affix affix-suf`,children:E})]});else if(y)$=d(`div`,{className:`input-with-unit`,children:[Z,u(`span`,{className:`unit`,children:y})]});else if(B){let e=d(`div`,{className:_?`input-icon`:`input-wrap`,children:[_&&u(`span`,{className:`ic`,children:u(n,{name:_,size:16})}),Z,d(`button`,{type:`button`,className:`pw-toggle${L?` pw-revealed`:``}`,onClick:()=>be(e=>!e),"aria-label":L?`Hide password`:`Show password`,tabIndex:-1,children:[u(n,{name:`eye`,size:18,className:`pw-eye`}),u(n,{name:`eye-off`,size:18,className:`pw-eye-off`})]})]});$=J&&!X?u(te,{trigger:e,triggerType:`focus`,placement:j,title:ze,className:`pw-popover`,children:Ve}):e}else $=v?d(`div`,{className:`input-wrap`,children:[Z,u(`button`,{type:`button`,className:`pw-toggle`,onClick:he,disabled:!he,tabIndex:-1,"aria-label":ge||v,children:u(n,{name:v,size:18})})]}):S?d(`div`,{className:_?`input-icon`:`input-wrap`,children:[_&&u(`span`,{className:`ic`,children:u(n,{name:_,size:16})}),Z,Pe]}):_?d(`div`,{className:`input-icon`,children:[u(`span`,{className:`ic`,children:u(n,{name:_,size:16})}),Z]}):Z;return d(l.Group,{className:`field${b?` ${b}`:``}`,children:[a&&!O&&d(l.Label,{className:`label`,htmlFor:z,children:[a,f&&u(r,{}),m&&u(ne,{label:me,children:m})]}),$,X&&u(`div`,{className:`wui-pw-inline`,children:Ve}),u(ee,{error:R,hint:X?null:p,errorId:Y,hintId:Fe}),C&&d(`div`,{className:`field-count${w&&W>=w?` at-limit`:``}`,children:[W,w?` / ${w}`:``]})]})});export{f as default};
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* @param {"none"|"online"|"offline"|"away"|"busy"} [props.status="none"] A presence dot.
|
|
11
11
|
* @param {boolean} [props.ring=false] A ring around the disc.
|
|
12
12
|
* @param {string} [props.label] Text shown as a tooltip above the avatar on hover/focus.
|
|
13
|
-
* @param {string} [props.icon]
|
|
13
|
+
* @param {string|import('react').ReactNode} [props.icon] Fallback face used instead of initials when there's no photo: a library icon name, or any React node (a product's own glyph), drawn as given.
|
|
14
|
+
* @param {"linear"|"outline"|"bold"|"bulk"|"broken"|"twotone"} [props.iconVariant="linear"] The iconsax style of a named `icon`; a node icon is drawn as given.
|
|
14
15
|
* @param {import('react').ReactNode} [props.badge] A small count/marker in the top-right corner.
|
|
15
16
|
* @param {string} [props.href] Makes the avatar a link.
|
|
16
17
|
* @param {(e) => void} [props.onClick] Makes the avatar a button (when no href).
|
|
@@ -19,7 +20,7 @@
|
|
|
19
20
|
* @param {"auto"|"top"|"bottom"|"start"|"end"} [props.tooltipPlacement="auto"] Preferred tooltip side; `auto` picks the side with the most room.
|
|
20
21
|
* @param {string} [props.className]
|
|
21
22
|
*/
|
|
22
|
-
export default function AppAvatar({ name, src, size, shape, tone, status, ring, label, icon, badge, href, onClick, linkComponent: Link, tooltip, tooltipPlacement, className, ...rest }: {
|
|
23
|
+
export default function AppAvatar({ name, src, size, shape, tone, status, ring, label, icon, iconVariant, badge, href, onClick, linkComponent: Link, tooltip, tooltipPlacement, className, ...rest }: {
|
|
23
24
|
name?: string;
|
|
24
25
|
src?: string;
|
|
25
26
|
size?: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | number | string;
|
|
@@ -28,7 +29,8 @@ export default function AppAvatar({ name, src, size, shape, tone, status, ring,
|
|
|
28
29
|
status?: "none" | "online" | "offline" | "away" | "busy";
|
|
29
30
|
ring?: boolean;
|
|
30
31
|
label?: string;
|
|
31
|
-
icon?: string;
|
|
32
|
+
icon?: string | import('react').ReactNode;
|
|
33
|
+
iconVariant?: "linear" | "outline" | "bold" | "bulk" | "broken" | "twotone";
|
|
32
34
|
badge?: import('react').ReactNode;
|
|
33
35
|
href?: string;
|
|
34
36
|
onClick?: (e: any) => void;
|
|
@@ -38,8 +38,9 @@
|
|
|
38
38
|
* border — a labelled action button (verify, apply, send code), or a confirmation once the field
|
|
39
39
|
* is resolved. The field flexes to fill the row; the action keeps its natural width. Exclusive
|
|
40
40
|
* with the in-field shells (unit / password / affix / trailing icon); pairs with a leading icon.
|
|
41
|
-
* @param {boolean} [props.floatingLabel=false] Label sits inside as a placeholder, then slides
|
|
42
|
-
* on focus/fill.
|
|
41
|
+
* @param {boolean|"above"} [props.floatingLabel=false] Label sits inside as a placeholder, then slides
|
|
42
|
+
* up on focus/fill. `true` rests it on the top border; `"above"` rests it above the box at the
|
|
43
|
+
* top-left, clear of the border. Opt-in variant; standalone only (no icon/unit/prefix in the same field).
|
|
43
44
|
* @param {"bare"} [props.variant] Borderless variant — no border/background, inherits the
|
|
44
45
|
* container's chrome (inline-rename, ⌘K).
|
|
45
46
|
* @param {boolean|object} [props.passwordRequirements=false] Only honoured when `type="password"`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/ui-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.76.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.76.0",
|
|
31
|
+
"@webority/ui-elements": "0.76.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@webority/analytics": "^0.23.0",
|