@webority/ui-react 0.163.0 → 0.165.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/LICENSE +1 -1
- package/README.md +2 -2
- package/dist/canvas-kit/kit.js +212 -212
- package/dist/canvas-kit/manifest.json +1127 -389
- package/dist/canvas-kit/release.json +6 -6
- package/dist/components/AppAccountSwitcher.js +1 -1
- package/dist/components/AppAlert.js +1 -1
- package/dist/components/AppAsyncBlock.js +1 -1
- package/dist/components/AppBreadcrumbs.js +1 -1
- package/dist/components/AppButton.js +1 -1
- package/dist/components/AppCard.js +1 -1
- package/dist/components/AppChartCard.js +1 -1
- package/dist/components/AppChoiceChip.js +1 -1
- package/dist/components/AppCodeBlock.js +1 -1
- package/dist/components/AppColorField.js +1 -1
- package/dist/components/AppCommentThread.js +1 -1
- package/dist/components/AppContextMenu.js +1 -1
- package/dist/components/AppDataTable.js +1 -1
- package/dist/components/AppDatePicker.js +1 -1
- package/dist/components/AppDateRangePicker.js +1 -1
- package/dist/components/AppDescriptions.js +1 -1
- package/dist/components/AppDrawer.js +1 -1
- package/dist/components/AppDropZone.js +1 -1
- package/dist/components/AppDropdown.js +1 -1
- package/dist/components/AppDueDate.js +1 -1
- package/dist/components/AppEntryGrid.js +1 -0
- package/dist/components/AppFileAttachment.js +1 -1
- package/dist/components/AppFilePicker.js +1 -1
- package/dist/components/AppFileViewer.js +1 -1
- package/dist/components/AppFilterBar.js +1 -1
- package/dist/components/AppFloatingButton.js +1 -1
- package/dist/components/AppForm.js +1 -1
- package/dist/components/AppFormulaSteps.js +1 -0
- package/dist/components/AppHoverCard.js +1 -1
- package/dist/components/AppImagePicker.js +1 -1
- package/dist/components/AppInlineEdit.js +1 -1
- package/dist/components/AppInput.js +1 -1
- package/dist/components/AppMarkdown.js +1 -1
- package/dist/components/AppMentionInput.js +1 -1
- package/dist/components/AppMetricStrip.js +1 -1
- package/dist/components/AppModal.js +1 -1
- package/dist/components/AppNotificationCenter.js +1 -1
- package/dist/components/AppNumberInput.js +1 -1
- package/dist/components/AppOtpInput.js +1 -1
- package/dist/components/AppPageHeader.js +1 -1
- package/dist/components/AppPhoneNumberInput.js +1 -1
- package/dist/components/AppPopover.js +1 -1
- package/dist/components/AppRadioGroup.js +1 -1
- package/dist/components/AppRating.js +1 -1
- package/dist/components/AppRichText.js +1 -1
- package/dist/components/AppRowActions.js +1 -0
- package/dist/components/AppScoreScale.js +1 -1
- package/dist/components/AppSearch.js +1 -1
- package/dist/components/AppSectionFeatures.js +1 -1
- package/dist/components/AppSectionLogos.js +1 -1
- package/dist/components/AppSelect.js +1 -1
- package/dist/components/AppShell.js +1 -1
- package/dist/components/AppSlider.js +1 -1
- package/dist/components/AppSparkline.js +1 -1
- package/dist/components/AppTextarea.js +1 -1
- package/dist/components/AppThemeToggle.js +1 -1
- package/dist/components/AppTimePicker.js +1 -1
- package/dist/components/AppToast.js +1 -1
- package/dist/components/AppTooltip.js +1 -1
- package/dist/components/AppWhatsNew.js +1 -1
- package/dist/components/AppWorkspaceSwitcher.js +1 -1
- package/dist/components/warnUnknownProps.js +1 -1
- package/dist/guidance.json +216 -141
- package/dist/hookForm/index.js +1 -0
- package/dist/lib/CheckField.js +1 -1
- package/dist/lib/formFields.js +1 -0
- package/dist/lib/indianGrouping.js +1 -0
- package/dist/lib/unsavedText.js +1 -0
- package/dist/lib/useOverlayRoot.js +1 -0
- package/dist/types/components/AppAccordion.d.ts +1 -1
- package/dist/types/components/AppAlert.d.ts +1 -1
- package/dist/types/components/AppAsyncBlock.d.ts +3 -3
- package/dist/types/components/AppBreadcrumbs.d.ts +6 -0
- package/dist/types/components/AppCard.d.ts +1 -1
- package/dist/types/components/AppChart.d.ts +12 -4
- package/dist/types/components/AppChip.d.ts +2 -2
- package/dist/types/components/AppCodeBlock.d.ts +1 -1
- package/dist/types/components/AppCommandPalette.d.ts +2 -2
- package/dist/types/components/AppDataTable.d.ts +32 -3
- package/dist/types/components/AppDateRangePicker.d.ts +4 -0
- package/dist/types/components/AppDescriptions.d.ts +7 -1
- package/dist/types/components/AppDrawer.d.ts +1 -1
- package/dist/types/components/AppDropdown.d.ts +7 -7
- package/dist/types/components/AppEntryGrid.d.ts +122 -0
- package/dist/types/components/AppFilePicker.d.ts +1 -1
- package/dist/types/components/AppFilterBar.d.ts +12 -1
- package/dist/types/components/AppFloatingDock.d.ts +2 -2
- package/dist/types/components/AppForm.d.ts +18 -0
- package/dist/types/components/AppFormActions.d.ts +1 -1
- package/dist/types/components/AppFormSection.d.ts +1 -1
- package/dist/types/components/AppFormulaSteps.d.ts +64 -0
- package/dist/types/components/AppIcon.d.ts +2 -2
- package/dist/types/components/AppInfoTip.d.ts +1 -1
- package/dist/types/components/AppInlineEdit.d.ts +5 -0
- package/dist/types/components/AppKpiTile.d.ts +1 -1
- package/dist/types/components/AppMeter.d.ts +1 -1
- package/dist/types/components/AppMetricStrip.d.ts +5 -0
- package/dist/types/components/AppModal.d.ts +9 -4
- package/dist/types/components/AppNumberInput.d.ts +7 -0
- package/dist/types/components/AppPageHeader.d.ts +5 -0
- package/dist/types/components/AppPopover.d.ts +3 -3
- package/dist/types/components/AppRequiredMark.d.ts +1 -1
- package/dist/types/components/AppResourceCard.d.ts +1 -1
- package/dist/types/components/AppResult.d.ts +2 -2
- package/dist/types/components/AppRowActions.d.ts +40 -0
- package/dist/types/components/AppScrollbar.d.ts +1 -1
- package/dist/types/components/AppSectionFeatures.d.ts +5 -1
- package/dist/types/components/AppSectionLogos.d.ts +1 -0
- package/dist/types/components/AppShell.d.ts +8 -6
- package/dist/types/components/AppSlider.d.ts +5 -0
- package/dist/types/components/AppSparkline.d.ts +3 -0
- package/dist/types/components/AppSpinner.d.ts +2 -2
- package/dist/types/components/AppSplash.d.ts +2 -2
- package/dist/types/components/AppTabs.d.ts +3 -3
- package/dist/types/components/AppToast.d.ts +6 -1
- package/dist/types/components/AppToolbar.d.ts +5 -5
- package/dist/types/components/AppTooltip.d.ts +5 -5
- package/dist/types/components/AppWorkspaceSwitcher.d.ts +3 -3
- package/dist/types/components/toastStore.d.ts +2 -2
- package/dist/types/components/warnUnknownProps.d.ts +3 -3
- package/dist/types/hookForm/index.d.ts +14 -0
- package/dist/types/index.d.ts +8 -6
- package/dist/types/lib/CheckField.d.ts +1 -1
- package/dist/types/lib/FieldMessage.d.ts +1 -1
- package/dist/types/lib/FileItemRow.d.ts +1 -1
- package/dist/types/lib/fileItem.d.ts +3 -3
- package/dist/types/lib/formFields.d.ts +12 -0
- package/dist/types/lib/indianGrouping.d.ts +2 -0
- package/dist/types/lib/unsavedText.d.ts +5 -0
- package/dist/types/lib/useOverlayRoot.d.ts +2 -0
- package/dist/ui-react.js +1 -1
- package/dist/web-core/dist/errors/extractApiError.js +2 -0
- package/dist/web-core/dist/errors/requestPlatform.js +1 -0
- package/package.json +21 -10
- package/dist/components/AppResizable.js +0 -1
- package/dist/components/AppResizableHandle.js +0 -1
- package/dist/components/AppResizablePanel.js +0 -1
- package/dist/components/AppRollingNumber.js +0 -1
- package/dist/components/AppRowSwitch.js +0 -1
- package/dist/lib/FocusPanel.js +0 -1
- package/dist/lib/pageScrollLock.js +0 -1
- package/dist/types/components/AppResizable.d.ts +0 -37
- package/dist/types/components/AppResizableHandle.d.ts +0 -14
- package/dist/types/components/AppResizablePanel.d.ts +0 -14
- package/dist/types/components/AppRollingNumber.d.ts +0 -30
- package/dist/types/components/AppRowSwitch.d.ts +0 -18
- package/dist/types/lib/FocusPanel.d.ts +0 -11
- package/dist/types/lib/pageScrollLock.d.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../lib/FieldMessage.js";import t from"../lib/FileItemRow.js";import{keyOf as n,linkOf as r,nameOf as i,sizeLabelOf as a,uploadErrorOf as o,uploadProgressOf as s,useItemUrl as c}from"../lib/fileItem.js";import l from"../lib/fillLabel.js";import{linkTarget as
|
|
1
|
+
import e from"../lib/FieldMessage.js";import t from"../lib/FileItemRow.js";import{keyOf as n,linkOf as r,nameOf as i,sizeLabelOf as a,uploadErrorOf as o,uploadProgressOf as s,useItemUrl as c}from"../lib/fileItem.js";import l from"../lib/fillLabel.js";import{useFieldError as u}from"../lib/formFields.js";import{linkTarget as d}from"../lib/linkTarget.js";import{TargetLink as f}from"../lib/TargetLink.js";import p from"../lib/useFileDrop.js";import{splitMarkerProps as m}from"../lib/wuiMarker.js";import h from"./AppIcon.js";import g from"./AppProgress.js";import _ from"./warnUnknownProps.js";import{DEFAULT_IMAGE_ACCEPT as v,DEFAULT_MAX_SIZE_MB as y,acceptDroppedFiles as b,acceptLabel as x,isImageFile as S,isImageOnlyAccept as C}from"@webority/ui-elements/helpers";import{useId as w,useState as T}from"react";import{jsx as E,jsxs as D}from"react/jsx-runtime";function O(i){let{marker:a,props:o}=m(`AppFileAttachment`,i),{label:s=`Attachment`,value:c,name:l,onChange:d,multiple:f=!1,accept:g=v,maxSizeMb:x=y,optional:O=!1,validate:A=!0,error:j,id:M,linkComponent:N,browseLabel:ne=`Browse`,removeLabel:re=`Remove attachment`,uploadingLabel:ie=`Uploading {name}`,maxSizeText:ae=`Up to {size} MB`,typesAndMaxSizeText:oe=`{types}, up to {size} MB`,removeFileLabel:se=`Remove {name}`,optionalLabel:ce=`(optional)`,dropTitle:le,...P}=o,F=u(l),I=j??F;if(_(`AppFileAttachment`,P),!f&&Array.isArray(c))throw TypeError(`[@webority/ui-react] <AppFileAttachment> received a list of files as value without multiple. Pass one file (or null), or set multiple to take a list.`);let L=w(),R=M||L,[z,B]=T(``),V=Array.isArray(c)?c:c?[c]:[],H=C(g),U=e=>e instanceof File?S(e):H||S(te(e)),W=V[0],G=!f&&W!==void 0&&U(W)&&(W instanceof File||r(W)!==null)?W:void 0,K=ee(g,x,ae,oe),q=A?{accept:g,maxSizeMb:x,multiple:f}:{accept:``,maxSizeMb:0,multiple:f},J=e=>{i.multiple||i.onChange(e)},Y=e=>{i.multiple&&i.onChange(e)};function X(e){if(B(``),f){let t=Array.isArray(c)?c:c?[c]:[],r=new Set(t.map(n)),i=t.concat(e.filter(e=>!r.has(n(e))));Y(i)}else J(e[0]??null)}function ue(e){if(!e.length)return;let{files:t,rejections:n}=b(e,q);t.length&&X(t),B(n[0]?.message??``)}let{dragOver:de,dropProps:fe}=p({...q,disabled:P.disabled,onFiles:X,onReject:e=>B(e.message)});function pe(e){let t=Array.from(e.target.files||[]);e.target.value=``,ue(t)}function Z(e){B(``),f?Y(V.filter((t,n)=>n!==e)):J(null)}let Q=I||z,me=Q?`${R}-error`:void 0,he=f||V.length===0,$=H?`image`:`file`,ge=le??(f?`Add ${$}s`:`Add ${H?`an`:`a`} ${$}`);return/* @__PURE__ */ D(`div`,{...a,className:`field`,children:[/* @__PURE__ */ D(`label`,{className:`label`,htmlFor:R,children:[s,O&&/* @__PURE__ */ E(`span`,{className:`label-optional`,children:` ${ce}`})]}),/* @__PURE__ */ D(`label`,{className:`attach-drop${de?` dragging`:``}`,htmlFor:R,style:he?void 0:{display:`none`},...fe,children:[/* @__PURE__ */ E(`span`,{className:`attach-drop-icon`,children:/* @__PURE__ */ E(h,{name:H?`image`:`file-text`,size:18})}),/* @__PURE__ */ D(`span`,{className:`attach-drop-copy`,children:[/* @__PURE__ */ E(`span`,{className:`attach-drop-title`,children:ge}),K&&/* @__PURE__ */ E(`span`,{className:`attach-drop-hint`,children:K})]}),/* @__PURE__ */ E(`span`,{className:`attach-drop-cta`,children:ne})]}),/* @__PURE__ */ E(`input`,{id:R,type:`file`,className:`visually-hidden`,name:l,accept:g||void 0,multiple:f||void 0,"aria-describedby":me,onChange:pe,...P}),G?/* @__PURE__ */ E(k,{item:G,isImage:!0,linkComponent:N,onRemove:()=>Z(0),removeLabel:re,uploadingLabel:ie}):V.length>0&&/* @__PURE__ */ E(`div`,{className:`attach-list`,children:V.map((e,r)=>/* @__PURE__ */ E(t,{item:e,isImage:U(e),linkComponent:N,onRemove:()=>Z(r),removeFileLabel:se},n(e)))}),/* @__PURE__ */ E(e,{error:Q,errorId:`${R}-error`})]})}function ee(e,t,n,r){let i=e?.trim()?x(e):``,a=t>0;return i&&a?l(r,{types:i,size:t}):a?l(n,{size:t}):i}function te({name:e,url:t}){return{...e===void 0?null:{name:e},...t===void 0?null:{url:t}}}function k({item:e,isImage:t,linkComponent:n,onRemove:u,removeLabel:p,uploadingLabel:m}){let _=c(e,t),v=i(e),y=a(e),b=s(e),x=o(e),S=r(e),C=e instanceof File?void 0:e.to,w=d(n,{to:C,href:S??void 0,routeHref:!1});return/* @__PURE__ */ D(`div`,{className:x?`attach-preview wui-attach-failed`:`attach-preview`,children:[/* @__PURE__ */ D(`div`,{className:`attach-figure`,children:[/* @__PURE__ */ E(`img`,{src:_??void 0,alt:v}),/* @__PURE__ */ E(`button`,{type:`button`,className:`attach-remove`,"aria-label":p,onClick:u,children:/* @__PURE__ */ E(h,{name:`x`,size:18})})]}),/* @__PURE__ */ D(`div`,{className:`attach-meta`,children:[/* @__PURE__ */ E(`div`,{className:`attach-name`,children:S||C?/* @__PURE__ */ E(f,{link:w,children:v}):v}),y&&/* @__PURE__ */ E(`div`,{className:`attach-size`,children:y})]}),b!==null&&/* @__PURE__ */ E(g,{value:b,size:`sm`,label:l(m,{name:v}),className:`wui-attach-progress`}),x&&/* @__PURE__ */ E(`div`,{className:`wui-attach-error`,children:x})]})}export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import n from"../lib/FileItemRow.js";import{FIELD_SIZES as r}from"../lib/fieldState.js";import{keyOf as i}from"../lib/fileItem.js";import a from"../lib/fillLabel.js";import o from"../lib/useFileDrop.js";import{splitMarkerProps as
|
|
1
|
+
import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import n from"../lib/FileItemRow.js";import{FIELD_SIZES as r}from"../lib/fieldState.js";import{keyOf as i}from"../lib/fileItem.js";import a from"../lib/fillLabel.js";import{useFieldError as o}from"../lib/formFields.js";import ee from"../lib/useFileDrop.js";import{splitMarkerProps as te}from"../lib/wuiMarker.js";import s from"./AppIcon.js";import ne from"./AppInfoTip.js";import re from"./AppRequiredMark.js";import ie from"./AppSpinner.js";import ae from"./assertValidValue.js";import oe from"./warnUnknownProps.js";import se from"./withTooltip.js";import{DEFAULT_MAX_SIZE_MB as ce,acceptDroppedFiles as le,acceptLabel as c,isImageFile as l,isImageOnlyAccept as ue,isPdfFile as de}from"@webority/ui-elements/helpers";import{useEffect as u,useId as fe,useRef as pe,useState as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";var me=[`dropzone`,`button`],he={sm:` input-sm`,md:``,lg:` input-lg`},ge={md:``,lg:` btn-lg`};function m(e){return e instanceof File?e:{url:e.url,...e.name===void 0?null:{name:e.name}}}function h(h){let{marker:_e,props:ve}=te(`AppFilePicker`,h),{label:g,value:_,name:v,id:ye,onChange:be,multiple:y=!1,variant:b=`dropzone`,buttonLabel:xe=`Add file`,browseLabel:Se=`Click to upload`,dropLabel:Ce=`or drag & drop`,maxSizeText:we=`up to {size} MB`,optionalLabel:Te=`(optional)`,changeImageLabel:Ee=`Change image`,changeFileLabel:De=`Change file`,maxFilesText:Oe=`Up to {count} files.`,removeFileLabel:ke=`Remove {name}`,maxFiles:x,accept:S=`.jpg,.jpeg,.png`,maxSizeMb:C=ce,required:w,optional:Ae=!1,error:je,helperText:T,help:E,helpLabel:Me=`More information`,loading:D=!1,readOnly:O=!1,size:k,disabled:A=!1,className:j=``,fieldClassName:M=``,style:N,...P}=ve,Ne=o(v),Pe=je??Ne;if(oe(`AppFilePicker`,P),ae(`AppFilePicker`,`variant`,b,me),ae(`AppFilePicker`,`size`,k,r),!y&&Array.isArray(_))throw TypeError(`[@webority/ui-react] <AppFilePicker> received a list of files as value without multiple. Pass one file (or null), or set multiple to take a list.`);let F=k===void 0?``:he[k]??``,I=O?{"aria-readonly":`true`,"data-wui-readonly":``}:null,[Fe,L]=d(null),[Ie,R]=d(null),[Le,z]=d(``),B=pe(null),Re=fe(),V=ye||Re,H=A||D;u(()=>{if(!y&&_ instanceof File&&l(_)){let e=URL.createObjectURL(_);return L(e),()=>URL.revokeObjectURL(e)}L(null)},[_,y]);let U=y||Array.isArray(_)?void 0:_,W=U&&!l(m(U))&&de(m(U))?U instanceof File?U:U.url:null;u(()=>{if(!W){R(null);return}let t=!0,n=null;return import(`@webority/ui-elements/file-viewer`).then(e=>e.renderPdfFirstPage(typeof W==`string`?{url:W}:W)).then(e=>{t&&(n=URL.createObjectURL(e),R(n))}).catch(t=>e(`[AppFilePicker] the PDF preview failed:`,t?.message)),()=>{t=!1,R(null),n&&URL.revokeObjectURL(n)}},[W]);let G=y?Array.isArray(_)?_:_?[_]:[]:[],K=Pe||Le,q=K?`${V}-error`:void 0,J=T&&!K?`${V}-hint`:void 0,ze=q||J,Be=ue(S),Ve=b===`button`,He=`btn btn-outline-primary${(k===`md`||k===`lg`?ge[k]:void 0)??` btn-sm`}`,Ue=!y&&!!_,Y=!!U&&(U instanceof File?l(U):Be||l(m(U))),We=U?.name,Ge=U instanceof File?void 0:U?.url,Ke=Y?Ge||Fe:Ie,X=Y?`image`:`file`,qe=g?`Change ${g}`:`Change ${X}`,Je=g?`Remove ${g}`:`Remove ${X}`,Ye=g?`${g} preview`:`Selected ${X} preview`,Xe={accept:S,maxSizeMb:C,multiple:y},Z=e=>{h.multiple||h.onChange(e)},Ze=e=>{h.multiple&&h.onChange(e)},Qe=e=>{if(z(``),!y){Z(e[0]??null);return}let t=Array.isArray(_)?_:_?[_]:[],n=new Set(t.map(i)),r=[];for(let t of e)n.has(i(t))||(n.add(i(t)),r.push(t));let o=t.concat(r);x&&o.length>x&&(o=o.slice(0,x),z(a(Oe,{count:x}))),Ze(o)},$e=e=>z(e.message),{dragOver:et,dropProps:tt}=ee({...Xe,disabled:H||O,onFiles:Qe,onReject:$e}),nt=e=>{if(O)return;let{files:t,rejections:n}=le(e,Xe);t.length&&Qe(t);let[r]=n;r&&$e(r)},rt=e=>nt(e.target.files),it=e=>{O||(z(``),Ze(G.filter((t,n)=>n!==e)))},at=()=>{O||B.current?.click()},Q=D?/* @__PURE__ */ f(`span`,{className:`wui-file-busy`,children:/* @__PURE__ */ f(ie,{size:`sm`})}):null,$=/* @__PURE__ */ f(`input`,{id:V,name:v,ref:B,type:`file`,"aria-describedby":ze,accept:S,multiple:y||void 0,disabled:H||void 0,className:`visually-hidden`,onClick:e=>{O?e.preventDefault():e.currentTarget.value=``},onChange:rt,...P});return/* @__PURE__ */ p(`div`,{..._e,className:`field${M?` ${M}`:``}`,children:[g?/* @__PURE__ */ p(`label`,{className:`label`,htmlFor:V,children:[g,Ae&&!w&&/* @__PURE__ */ f(`span`,{className:`label-optional`,children:` ${Te}`}),w&&/* @__PURE__ */ f(re,{}),E&&/* @__PURE__ */ f(ne,{label:Me,children:E})]}):null,Ve?/* @__PURE__ */ p(`div`,{className:`file-input wui-file-input-button-field${F}${K?` error`:``}${j?` ${j}`:``}`,style:N,"aria-busy":D||void 0,...I,children:[/* @__PURE__ */ p(`label`,{htmlFor:V,className:He,children:[/* @__PURE__ */ f(s,{name:`paperclip`,size:16}),xe]}),$,Q]}):Ue?/* @__PURE__ */ p(`div`,{className:`file-preview${F}${K?` error`:``}${j?` ${j}`:``}`,style:N,"aria-busy":D||void 0,...I,children:[/* @__PURE__ */ p(`button`,{type:`button`,className:`file-preview-open`,"aria-label":qe,onClick:at,disabled:H||O,children:[Ke?/* @__PURE__ */ f(`img`,{src:Ke,alt:Ye,className:`file-preview-img`}):/* @__PURE__ */ p(`span`,{className:`file-preview-file`,children:[/* @__PURE__ */ f(s,{name:`file-text`,size:28}),/* @__PURE__ */ f(`span`,{className:`file-preview-file-name`,children:We})]}),/* @__PURE__ */ f(`span`,{className:`file-preview-overlay`,children:/* @__PURE__ */ p(`span`,{className:`file-preview-cta`,children:[/* @__PURE__ */ f(s,{name:Y?`image`:`file-text`,size:16}),` `,Y?Ee:De]})})]}),se(/* @__PURE__ */ f(`button`,{type:`button`,className:`file-preview-remove`,"aria-label":Je,onClick:()=>Z(null),disabled:H||O,children:/* @__PURE__ */ f(s,{name:`x`,size:16})}),Je),$,Q]}):/* @__PURE__ */ p(`div`,{className:`file-input file-input-tall${F}${et?` dragging`:``}${K?` error`:``}${y&&G.length>0?` has-files`:``}${j?` ${j}`:``}`,style:N,"aria-busy":D||void 0,"aria-disabled":A||void 0,...I,...tt,children:[/* @__PURE__ */ p(`label`,{htmlFor:V,className:`file-input-zone-label`,children:[/* @__PURE__ */ f(`span`,{className:`file-input-icon`,children:/* @__PURE__ */ f(s,{name:`upload`,size:24})}),/* @__PURE__ */ p(`span`,{className:`file-input-title`,children:[/* @__PURE__ */ f(`span`,{className:`browse`,children:Se}),` ${Ce}`]}),/* @__PURE__ */ f(`span`,{className:`file-input-text`,children:C>0?`${c(S)}, ${a(we,{size:C})}`:c(S)})]}),$,Q,y&&G.length>0&&/* @__PURE__ */ f(`div`,{className:`attach-list`,children:G.map((e,t)=>/* @__PURE__ */ f(n,{item:e,isImage:e instanceof File?l(e):Be||l(m(e)),noun:`file`,removeFileLabel:ke,readOnly:O,onRemove:()=>it(t)},i(e)))})]}),/* @__PURE__ */ f(t,{error:K,hint:T,errorId:q,hintId:J})]})}export{h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../lib/useElementEntry.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./warnUnknownProps.js";import{createElement as r,forwardRef as i,useCallback as a,useEffect as o,useLayoutEffect as s,useRef as c,useState as l}from"react";import{Fragment as
|
|
1
|
+
import e from"../lib/useElementEntry.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./warnUnknownProps.js";import{createElement as r,forwardRef as i,useCallback as a,useEffect as o,useLayoutEffect as s,useRef as c,useState as l}from"react";import{createPortal as u}from"react-dom";import{Fragment as d,jsx as f,jsxs as p}from"react/jsx-runtime";var m=`wui-file-viewer:load`,h=`wui-file-viewer:error`,g=`wui-file-viewer:prefs-change`,_=()=>import(`@webority/ui-elements/file-viewer`),v=i(function(i,v){let{marker:y,props:b}=t(`AppFileViewer`,i),{src:x,name:S,type:C,prefs:w,onPrefsChange:T,viewKey:E,download:D=!1,print:O=!0,workerSrc:k,assetBase:A,captions:j,actions:M,onLoad:N,onError:P,className:F=``,style:I,...L}=b;n(`AppFileViewer`,L);let R=e(`wui-file-viewer`,_),z=c(null),B=c(N),V=c(P),H=c(T),[U,W]=l(null),G=a(e=>{z.current=e,typeof v==`function`?v(e):v&&(v.current=e)},[v]);s(()=>{if(!R||w===void 0)return;let e=z.current;if(!e)throw Error(`AppFileViewer: the viewer element is not mounted`);e.prefs=w},[w,R]),o(()=>{B.current=N,V.current=P,H.current=T}),o(()=>{let e=z.current;if(!e)throw Error(`AppFileViewer: the viewer element is not mounted`);let t=e=>{if(!(e instanceof CustomEvent))throw Error(`wui-file-viewer:load arrived without a CustomEvent`);B.current?.(e.detail)},n=e=>{if(!(e instanceof CustomEvent))throw Error(`wui-file-viewer:error arrived without a CustomEvent`);V.current?.(e.detail)},r=e=>{if(!(e instanceof CustomEvent))throw Error(`wui-file-viewer:prefs-change arrived without a CustomEvent`);H.current?.(e.detail)};return e.addEventListener(m,t),e.addEventListener(h,n),e.addEventListener(g,r),()=>{e.removeEventListener(m,t),e.removeEventListener(h,n),e.removeEventListener(g,r)}},[]),o(()=>{if(!R)return;let e=z.current;e?.isConnected&&W(e.actionsContainer)},[R]);let K=I&&I.height!==void 0&&I.minHeight===void 0?{...I,minHeight:0}:I;return/* @__PURE__ */ p(d,{children:[r(`wui-file-viewer`,{ref:G,src:x,name:S||void 0,type:C||void 0,"view-key":E||void 0,download:D?``:void 0,print:O?void 0:`false`,"worker-src":k||void 0,"asset-base":A||void 0,captions:j||void 0,className:F||void 0,style:K,...y,...L}),U&&M!=null&&u(/* @__PURE__ */ f(`div`,{slot:`actions`,className:`wui-file-viewer-slot`,children:M}),U)]})});export{v as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{emptyFacetValue as e,isFacetActive as t}from"../web-core/dist/query/listQuery.js";import{devWarn as n}from"../lib/devWarn.js";import r from"../lib/fillLabel.js";import i from"../lib/useElementEntry.js";import{splitMarkerProps as a}from"../lib/wuiMarker.js";import o from"./AppButton.js";import ee from"./AppChip.js";import s from"./AppDateRangePicker.js";import te from"./AppIcon.js";import c from"./AppSearch.js";import l from"./AppSegmented.js";import u from"./AppSelect.js";import ne from"./AppSwitch.js";import d from"./assertValidValue.js";import re from"./warnUnknownProps.js";import{isImeSafeEnter as ie}from"@webority/ui-elements/helpers";import{Fragment as ae,useEffect as f,useId as oe,useRef as p,useState as se,useSyncExternalStore as ce}from"react";import{Fragment as le,jsx as m,jsxs as h}from"react/jsx-runtime";var g=`(max-width: 575.98px)`,ue=3,_=2,de=e=>{let t=window.matchMedia?.(g);return t?.addEventListener(`change`,e),()=>t?.removeEventListener(`change`,e)},fe=()=>window.matchMedia?.(g).matches??!1,pe=[`enum`,`multiEnum`,`dateRange`,`text`],me=[`sm`,`md`],he=()=>import(`@webority/ui-elements/elements/filter-popover`),v=4,ge=e=>(e.type===`enum`||e.type===`multiEnum`)&&!e.options?.length,y=(e,t)=>e.options?.find(e=>e.value===t)?.label??t,_e=(e,t)=>JSON.stringify(e)===JSON.stringify(t),b=(e,t,n)=>/* @__PURE__ */ RangeError(`[@webority/ui-react] <AppFilterBar> facet "${e.key}" needs ${t}, received ${JSON.stringify(n)}.`),x=(e,t)=>{if(t==null)return``;if(typeof t==`string`)return t;throw b(e,`a string value`,t)},S=(e,t)=>{if(t==null)return[];if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return t;throw b(e,`an array of strings`,t)},C=(e,t)=>{if(t==null)return{from:``,to:``};if(typeof t==`object`&&!Array.isArray(t)&&!(t instanceof Date)){let{from:e,to:n}=t;if((e===void 0||typeof e==`string`)&&(n===void 0||typeof n==`string`))return{from:e,to:n}}throw b(e,`a { from, to } date range`,t)};function ve(n,i,a){if(n.required||!t(n,i))return[];if(n.type===`enum`)return[{id:n.key,text:y(n,x(n,i)),clear:()=>e(n)}];if(n.type===`multiEnum`){let e=S(n,i);return e.map(t=>({id:`${n.key}:${t}`,text:y(n,t),clear:()=>e.filter(e=>e!==t)}))}if(n.type===`dateRange`){let t=C(n,i),o=t.from&&t.to?r(a.range,{from:t.from,to:t.to}):t.from?r(a.from,{date:t.from}):r(a.until,{date:t.to});return[{id:n.key,text:o,clear:()=>e(n)}]}return[]}var w=/* @__PURE__ */ new Set;function ye(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!w.has(e)&&(w.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets allLabel, which only an enum facet uses.`))}var T=/* @__PURE__ */ new Set;function be(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!T.has(e)&&(T.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets required, which only an enum facet uses.`))}var E=/* @__PURE__ */ new Set;function xe(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!E.has(e)&&(E.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets allLabel and required; a required facet has no All segment.`))}var D=/* @__PURE__ */ new Set;function Se(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!D.has(e)&&(D.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets presets, which only a dateRange facet uses.`))}function O(n){i(`wui-filter-popover`,he);let{marker:s,props:c}=a(`AppFilterBar`,n),{facets:l,value:u,onChange:g,inline:v=ue,floating:y=!1,apply:b=!1,size:x=`sm`,className:S=``,clearAllLabel:C=`Clear all`,filtersLabel:w=`Filters`,filtersActiveLabel:T=`Filters, {count} active`,keepOpenLabel:E=`Keep open`,appliesAtOnceText:D=`Changes apply at once.`,applyLabel:O=`Apply`,anyLabel:A=`Any`,removeChipLabel:Ce=`Remove {facet} filter {value}`,dateFromText:we=`From {date}`,dateUntilText:Te=`Until {date}`,dateRangeText:Ee=`{from} to {to}`,...j}=c;re(`AppFilterBar`,j),d(`AppFilterBar`,`size`,x,me);let M=x===`md`,De={range:Ee,from:we,until:Te},N=ce(de,fe,()=>!1),P=p(null),F=p(null),Oe=e=>{let t=P.current,n=F.current;t&&n&&(e.preventDefault(),t.open=!t.open,n.classList.remove(`wui-filter-more-panel-end`),t.open&&n.getBoundingClientRect().right>window.innerWidth-8&&n.classList.add(`wui-filter-more-panel-end`))},I=oe(),[L,R]=se({}),z=p(u);for(let e of l)d(`AppFilterBar`,`facets[].type`,e.type,pe);for(let e of l)e.allLabel!=null&&e.type!==`enum`&&ye(e.key),e.required&&e.type!==`enum`&&be(e.key),e.required&&e.allLabel!=null&&xe(e.key),e.presets!=null&&e.type!==`dateRange`&&Se(e.key);let B=l.filter(e=>!ge(e)),V=B.flatMap(e=>ve(e,u[e.key],De).map(t=>({...t,facet:e}))),H=B.filter(e=>!e.required&&t(e,u[e.key])),U=y||N?0:Math.max(0,v),W=B.slice(U),ke=W.filter(e=>H.includes(e)).length,G=!y&&W.length>0;f(()=>{if(!G)return;let e=e=>{let t=P.current;t?.open&&(e.type===`keydown`?e instanceof KeyboardEvent&&e.key===`Escape`:!e.composedPath().includes(t))&&(t.open=!1)};return document.addEventListener(`click`,e),document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`click`,e),document.removeEventListener(`keydown`,e)}},[G]),f(()=>{let e=z.current;z.current=u,R(t=>{let n=Object.entries(t).filter(([t])=>_e(e[t],u[t]));return n.length===Object.keys(t).length?t:Object.fromEntries(n)})},[u]);let K=e=>b&&!y&&(e.type===`text`||e.type===`dateRange`),q=e=>K(e)&&Object.hasOwn(L,e.key)?L[e.key]:u[e.key],J=e=>t=>K(e)?R(n=>({...n,[e.key]:t})):g(e.key,t),Y=()=>{for(let[e,t]of Object.entries(L))g(e,t);R({})},Ae=e=>{ie(e.nativeEvent)&&Y()},je=e=>{e.preventDefault(),Y()},X=(e,t)=>e.type===`text`&&K(e)?/* @__PURE__ */ m(`span`,{onKeyDownCapture:Ae,children:t}):t,Me=e=>/* @__PURE__ */ m(ae,{children:X(e,/* @__PURE__ */ m(k,{facet:e,value:q(e),onChange:J(e),medium:M,anyLabel:A}))},e.key),Z=e=>/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-field`,children:[/* @__PURE__ */ m(`span`,{className:`label`,"aria-hidden":`true`,children:e.label}),X(e,/* @__PURE__ */ m(k,{facet:e,value:q(e),onChange:J(e),floating:!0,medium:M,anyLabel:A}))]},e.key),Q=(e,t)=>t>0&&/* @__PURE__ */ m(`span`,{className:e,children:` (${t})`}),Ne=e=>/* @__PURE__ */ m(ee,{size:`sm`,label:`${e.facet.label}: ${e.text}`,removeLabel:r(Ce,{facet:e.facet.label,value:e.text}),onRemove:()=>g(e.facet.key,e.clear()),className:!y&&B.indexOf(e.facet)<U?`wui-filter-chip-inline`:void 0},e.id),Pe=/* @__PURE__ */ m(o,{variant:`ghost`,size:M?void 0:`sm`,onClick:()=>{for(let t of H)g(t.key,e(t));R({})},children:C});if(y){let e=V.slice(_),t=H.length;return/* @__PURE__ */ h(`div`,{className:`wui-filter-bar d-flex flex-wrap align-items-center gap-2${S?` ${S}`:``}`,...s,...j,children:[/* @__PURE__ */ h(`wui-filter-popover`,{class:`wui-filter-popover`,children:[/* @__PURE__ */ h(o,{variant:t>0?`outline`:`ghost`,size:M?void 0:`sm`,leftIcon:`filter`,className:`wui-filter-popover-trigger`,"aria-expanded":`false`,"aria-controls":I,"aria-label":t>0?r(T,{count:t}):void 0,children:[w,t>0&&/* @__PURE__ */ m(`span`,{className:`badge rounded-pill text-bg-primary ms-1`,children:t})]}),/* @__PURE__ */ h(`div`,{id:I,className:`wui-filter-popover-panel`,role:`dialog`,"aria-label":w,hidden:!0,children:[/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-head`,children:[/* @__PURE__ */ m(`span`,{className:`wui-filter-popover-title`,children:w}),/* @__PURE__ */ m(ne,{label:E,id:`${I}-pin`})]}),/* @__PURE__ */ m(`div`,{className:`wui-filter-popover-grid`,children:B.map(Z)}),/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-foot`,children:[/* @__PURE__ */ m(`span`,{className:`wui-filter-popover-note`,children:D}),t>0&&Pe]})]})]}),V.slice(0,_).map(Ne),e.length>0&&/* @__PURE__ */ h(`span`,{className:`chip chip-sm wui-filter-popover-more`,title:e.map(e=>`${e.facet.label}: ${e.text}`).join(`, `),children:[`+`,e.length]})]})}let Fe=`wui-filter-bar d-flex flex-wrap align-items-center gap-2${N&&G?` wui-filter-bar--folded`:``}`,Ie=e=>`${e}${S?` ${S}`:``}`,$=/* @__PURE__ */ h(le,{children:[B.slice(0,U).map(Me),G&&/* @__PURE__ */ h(`details`,{ref:P,className:`wui-filter-more`,children:[/* @__PURE__ */ h(`summary`,{className:`btn btn-outline-primary${M?``:` btn-sm`} wui-filter-more-trigger`,onClick:Oe,children:[/* @__PURE__ */ m(te,{name:`filter`,size:14,className:`me-2`}),w,Q(`wui-filter-count-desktop`,ke),Q(`wui-filter-count-phone`,H.length)]}),/* @__PURE__ */ h(`div`,{ref:F,className:`wui-filter-more-panel`,children:[/* @__PURE__ */ m(`div`,{className:`wui-filter-more-head`,children:w}),W.map(Z)]})]}),V.map(Ne),H.length>0&&Pe]});return!b||!B.some(e=>e.type===`text`||e.type===`dateRange`)?/* @__PURE__ */ m(`div`,{className:Ie(Fe),...s,...j,children:$}):/* @__PURE__ */ h(`div`,{className:Ie(`wui-filter-form d-flex flex-wrap align-items-center gap-2`),...s,...j,children:[/* @__PURE__ */ m(`div`,{className:Fe,children:$}),/* @__PURE__ */ m(o,{type:`submit`,size:M?void 0:`sm`,onClick:je,children:O})]})}function k({facet:e,value:t,onChange:n,floating:r=!1,medium:i=!1,anyLabel:a}){if(e.type===`enum`){let o=e.options??[];return(e.required?o.length<=v:o.length<v)?/* @__PURE__ */ m(l,{label:e.label,name:e.key,size:i?`md`:`sm`,value:x(e,t),onChange:n,options:e.required?o:[{value:``,label:e.allLabel||`All`},...o]}):/* @__PURE__ */ m(u,{"aria-label":e.label,name:e.key,placeholder:r?a:e.label,clearable:!e.required,size:i?void 0:`sm`,value:x(e,t),onChange:n,options:o})}return e.type===`multiEnum`?/* @__PURE__ */ m(u,{mode:`multiple`,"aria-label":e.label,name:e.key,placeholder:r?a:e.label,size:i?void 0:`sm`,collapseChips:!0,value:S(e,t),onChange:n,options:e.options??[]}):e.type===`dateRange`?/* @__PURE__ */ m(s,{ariaLabel:e.label,startName:`${e.key}From`,endName:`${e.key}To`,placeholder:r?a:e.label,size:i?void 0:`sm`,presets:e.presets,start:C(e,t).from,end:C(e,t).to,onChange:e=>n({from:e.start??``,to:e.end??``})}):/* @__PURE__ */ m(c,{ariaLabel:e.label,name:e.key,placeholder:e.label,size:i?void 0:`sm`,value:x(e,t),onChange:n})}export{O as default};
|
|
1
|
+
import{emptyFacetValue as e,isFacetActive as t}from"../web-core/dist/query/listQuery.js";import{devWarn as n}from"../lib/devWarn.js";import r from"../lib/fillLabel.js";import i from"../lib/useElementEntry.js";import{splitMarkerProps as a}from"../lib/wuiMarker.js";import o from"./AppButton.js";import ee from"./AppChip.js";import s from"./AppDateRangePicker.js";import te from"./AppIcon.js";import c from"./AppSearch.js";import l from"./AppSegmented.js";import u from"./AppSelect.js";import ne from"./AppSwitch.js";import d from"./assertValidValue.js";import re from"./warnUnknownProps.js";import{isImeSafeEnter as ie}from"@webority/ui-elements/helpers";import{Fragment as ae,useEffect as f,useId as oe,useRef as p,useState as se,useSyncExternalStore as ce}from"react";import{Fragment as le,jsx as m,jsxs as h}from"react/jsx-runtime";var g=`(max-width: 575.98px)`,ue=3,_=2,de=e=>{let t=window.matchMedia?.(g);return t?.addEventListener(`change`,e),()=>t?.removeEventListener(`change`,e)},fe=()=>window.matchMedia?.(g).matches??!1,pe=[`enum`,`multiEnum`,`dateRange`,`text`],me=[`sm`,`md`],he=()=>import(`@webority/ui-elements/elements/filter-popover`),v=4,ge=e=>(e.type===`enum`||e.type===`multiEnum`)&&!e.options?.length,y=(e,t)=>e.options?.find(e=>e.value===t)?.label??t,_e=(e,t)=>JSON.stringify(e)===JSON.stringify(t),b=(e,t,n)=>/* @__PURE__ */ RangeError(`[@webority/ui-react] <AppFilterBar> facet "${e.key}" needs ${t}, received ${JSON.stringify(n)}.`),x=(e,t)=>{if(t==null)return``;if(typeof t==`string`)return t;throw b(e,`a string value`,t)},S=(e,t)=>{if(t==null)return[];if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return t;throw b(e,`an array of strings`,t)},C=(e,t)=>{if(t==null)return{from:``,to:``};if(typeof t==`object`&&!Array.isArray(t)&&!(t instanceof Date)){let{from:e,to:n}=t;if((e===void 0||typeof e==`string`)&&(n===void 0||typeof n==`string`))return{from:e,to:n}}throw b(e,`a { from, to } date range`,t)};function ve(n,i,a){if(n.required||!t(n,i))return[];if(n.type===`enum`)return[{id:n.key,text:y(n,x(n,i)),clear:()=>e(n)}];if(n.type===`multiEnum`){let e=S(n,i);return e.map(t=>({id:`${n.key}:${t}`,text:y(n,t),clear:()=>e.filter(e=>e!==t)}))}if(n.type===`dateRange`){let t=C(n,i),o=t.from&&t.to?r(a.range,{from:t.from,to:t.to}):t.from?r(a.from,{date:t.from}):r(a.until,{date:t.to});return[{id:n.key,text:o,clear:()=>e(n)}]}return[]}var w=/* @__PURE__ */ new Set;function ye(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!w.has(e)&&(w.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets allLabel, which only an enum facet uses.`))}var T=/* @__PURE__ */ new Set;function be(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!T.has(e)&&(T.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets required, which only an enum facet uses.`))}var E=/* @__PURE__ */ new Set;function xe(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!E.has(e)&&(E.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets allLabel and required; a required facet has no All segment.`))}var D=/* @__PURE__ */ new Set;function Se(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!D.has(e)&&(D.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets presets, which only a dateRange facet uses.`))}var O=/* @__PURE__ */ new Set;function Ce(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!O.has(e)&&(O.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets count or icon on an option, which only an enum facet drawn as segments shows.`))}var we=e=>{let t=e.options?.length??0;return e.type===`enum`&&(e.required?t<=v:t<v)};function k(n){i(`wui-filter-popover`,he);let{marker:s,props:c}=a(`AppFilterBar`,n),{facets:l,value:u,onChange:g,onChangeMany:v,inline:y=ue,facetLabels:b=!1,floating:x=!1,apply:S=!1,size:C=`sm`,className:w=``,clearAllLabel:T=`Clear all`,filtersLabel:E=`Filters`,filtersActiveLabel:D=`Filters, {count} active`,keepOpenLabel:O=`Keep open`,appliesAtOnceText:k=`Changes apply at once.`,applyLabel:Te=`Apply`,anyLabel:j=`Any`,removeChipLabel:Ee=`Remove {facet} filter {value}`,dateFromText:De=`From {date}`,dateUntilText:Oe=`Until {date}`,dateRangeText:ke=`{from} to {to}`,...M}=c;re(`AppFilterBar`,M),d(`AppFilterBar`,`size`,C,me);let N=C===`md`,Ae={range:ke,from:De,until:Oe},P=ce(de,fe,()=>!1),F=p(null),I=p(null),je=e=>{let t=F.current,n=I.current;t&&n&&(e.preventDefault(),t.open=!t.open,n.classList.remove(`wui-filter-more-panel-end`),t.open&&n.getBoundingClientRect().right>window.innerWidth-8&&n.classList.add(`wui-filter-more-panel-end`))},L=oe(),[R,z]=se({}),B=p(u);for(let e of l)d(`AppFilterBar`,`facets[].type`,e.type,pe);for(let e of l)e.allLabel!=null&&e.type!==`enum`&&ye(e.key),e.required&&e.type!==`enum`&&be(e.key),e.required&&e.allLabel!=null&&xe(e.key),e.presets!=null&&e.type!==`dateRange`&&Se(e.key),e.options?.some(e=>e.count!=null||e.icon!=null)&&!we(e)&&Ce(e.key);let V=l.filter(e=>!ge(e)),H=V.flatMap(e=>ve(e,u[e.key],Ae).map(t=>({...t,facet:e}))),U=V.filter(e=>!e.required&&t(e,u[e.key])),W=x||P?0:Math.max(0,y),G=V.slice(W),Me=G.filter(e=>U.includes(e)).length,K=!x&&G.length>0;f(()=>{if(!K)return;let e=e=>{let t=F.current;t?.open&&(e.type===`keydown`?e instanceof KeyboardEvent&&e.key===`Escape`:!e.composedPath().includes(t))&&(t.open=!1)};return document.addEventListener(`click`,e),document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`click`,e),document.removeEventListener(`keydown`,e)}},[K]),f(()=>{let e=B.current;B.current=u,z(t=>{let n=Object.entries(t).filter(([t])=>_e(e[t],u[t]));return n.length===Object.keys(t).length?t:Object.fromEntries(n)})},[u]);let q=e=>S&&!x&&(e.type===`text`||e.type===`dateRange`),J=e=>q(e)&&Object.hasOwn(R,e.key)?R[e.key]:u[e.key],Y=e=>t=>q(e)?z(n=>({...n,[e.key]:t})):g(e.key,t),X=e=>{let t=Object.entries(e);if(t.length!==0){if(v)v(e);else for(let[e,n]of t)g(e,n)}},Z=()=>{X(R),z({})},Ne=e=>{ie(e.nativeEvent)&&Z()},Pe=e=>{e.preventDefault(),Z()},Q=(e,t)=>e.type===`text`&&q(e)?/* @__PURE__ */ m(`span`,{onKeyDownCapture:Ne,children:t}):t,Fe=(e,t)=>b?/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-field wui-filter-facet`,children:[/* @__PURE__ */ m(`span`,{className:`label`,"aria-hidden":`true`,children:e.label}),t]},e.key):t,Ie=e=>Fe(e,/* @__PURE__ */ m(ae,{children:Q(e,/* @__PURE__ */ m(A,{facet:e,value:J(e),onChange:Y(e),medium:N,anyLabel:j}))},e.key)),$=e=>/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-field`,children:[/* @__PURE__ */ m(`span`,{className:`label`,"aria-hidden":`true`,children:e.label}),Q(e,/* @__PURE__ */ m(A,{facet:e,value:J(e),onChange:Y(e),floating:!0,medium:N,anyLabel:j}))]},e.key),Le=(e,t)=>t>0&&/* @__PURE__ */ m(`span`,{className:e,children:` (${t})`}),Re=e=>/* @__PURE__ */ m(ee,{size:`sm`,label:`${e.facet.label}: ${e.text}`,removeLabel:r(Ee,{facet:e.facet.label,value:e.text}),onRemove:()=>g(e.facet.key,e.clear()),className:!x&&V.indexOf(e.facet)<W?`wui-filter-chip-inline`:void 0},e.id),ze=/* @__PURE__ */ m(o,{variant:`ghost`,size:N?void 0:`sm`,onClick:()=>{X(Object.fromEntries(U.map(t=>[t.key,e(t)]))),z({})},children:T});if(x){let e=H.slice(_),t=U.length;return/* @__PURE__ */ h(`div`,{className:`wui-filter-bar d-flex flex-wrap align-items-center gap-2${w?` ${w}`:``}`,...s,...M,children:[/* @__PURE__ */ h(`wui-filter-popover`,{class:`wui-filter-popover`,children:[/* @__PURE__ */ h(o,{variant:t>0?`outline`:`ghost`,size:N?void 0:`sm`,leftIcon:`filter`,className:`wui-filter-popover-trigger`,"aria-expanded":`false`,"aria-controls":L,"aria-label":t>0?r(D,{count:t}):void 0,children:[E,t>0&&/* @__PURE__ */ m(`span`,{className:`badge rounded-pill text-bg-primary ms-1`,children:t})]}),/* @__PURE__ */ h(`div`,{id:L,className:`wui-filter-popover-panel`,popover:`auto`,role:`dialog`,"aria-label":E,children:[/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-head`,children:[/* @__PURE__ */ m(`span`,{className:`wui-filter-popover-title`,children:E}),/* @__PURE__ */ m(ne,{label:O,id:`${L}-pin`})]}),/* @__PURE__ */ m(`div`,{className:`wui-filter-popover-grid`,children:V.map($)}),/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-foot`,children:[/* @__PURE__ */ m(`span`,{className:`wui-filter-popover-note`,children:k}),t>0&&ze]})]})]}),H.slice(0,_).map(Re),e.length>0&&/* @__PURE__ */ h(`span`,{className:`chip chip-sm wui-filter-popover-more`,title:e.map(e=>`${e.facet.label}: ${e.text}`).join(`, `),children:[`+`,e.length]})]})}let Be=`wui-filter-bar d-flex flex-wrap align-items-center gap-2${P&&K?` wui-filter-bar--folded`:``}`,Ve=e=>`${e}${w?` ${w}`:``}`,He=/* @__PURE__ */ h(le,{children:[V.slice(0,W).map(Ie),K&&/* @__PURE__ */ h(`details`,{ref:F,className:`wui-filter-more`,children:[/* @__PURE__ */ h(`summary`,{className:`btn btn-outline-primary${N?``:` btn-sm`} wui-filter-more-trigger`,onClick:je,children:[/* @__PURE__ */ m(te,{name:`filter`,size:14,className:`me-2`}),E,Le(`wui-filter-count-desktop`,Me),Le(`wui-filter-count-phone`,U.length)]}),/* @__PURE__ */ h(`div`,{ref:I,className:`wui-filter-more-panel`,children:[/* @__PURE__ */ m(`div`,{className:`wui-filter-more-head`,children:E}),G.map($)]})]}),H.map(Re),U.length>0&&ze]});return!S||!V.some(e=>e.type===`text`||e.type===`dateRange`)?/* @__PURE__ */ m(`div`,{className:Ve(Be),...s,...M,children:He}):/* @__PURE__ */ h(`div`,{className:Ve(`wui-filter-form d-flex flex-wrap align-items-center gap-2`),...s,...M,children:[/* @__PURE__ */ m(`div`,{className:Be,children:He}),/* @__PURE__ */ m(o,{type:`submit`,size:N?void 0:`sm`,onClick:Pe,children:Te})]})}function A({facet:e,value:t,onChange:n,floating:r=!1,medium:i=!1,anyLabel:a}){if(e.type===`enum`){let o=e.options??[];return(e.required?o.length<=v:o.length<v)?/* @__PURE__ */ m(l,{label:e.label,name:e.key,size:i?`md`:`sm`,value:x(e,t),onChange:n,options:e.required?o:[{value:``,label:e.allLabel||`All`},...o]}):/* @__PURE__ */ m(u,{"aria-label":e.label,name:e.key,placeholder:r?a:e.label,clearable:!e.required,size:i?void 0:`sm`,value:x(e,t),onChange:n,options:o})}return e.type===`multiEnum`?/* @__PURE__ */ m(u,{mode:`multiple`,"aria-label":e.label,name:e.key,placeholder:r?a:e.label,size:i?void 0:`sm`,collapseChips:!0,value:S(e,t),onChange:n,options:e.options??[]}):e.type===`dateRange`?/* @__PURE__ */ m(s,{ariaLabel:e.label,startName:`${e.key}From`,endName:`${e.key}To`,placeholder:r?a:e.label,size:i?void 0:`sm`,presets:e.presets,start:C(e,t).from,end:C(e,t).to,onChange:e=>n({from:e.start??``,to:e.end??``})}):/* @__PURE__ */ m(c,{ariaLabel:e.label,name:e.key,placeholder:e.label,size:i?void 0:`sm`,value:x(e,t),onChange:n})}export{k as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useFloatingStack as e}from"../lib/useFloatingStack.js";import{FILL_VARIANTS as t,TONES as n}from"../lib/vocabulary.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppButton.js";import a from"./AppIcon.js";import o from"./assertValidValue.js";import s from"./warnUnknownProps.js";import{
|
|
1
|
+
import{useFloatingStack as e}from"../lib/useFloatingStack.js";import{FILL_VARIANTS as t,TONES as n}from"../lib/vocabulary.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppButton.js";import a from"./AppIcon.js";import o from"./assertValidValue.js";import s from"./warnUnknownProps.js";import{createPortal as c}from"react-dom";import{jsx as l}from"react/jsx-runtime";var u={sm:22,md:24,lg:28},d={sm:` wui-floating-btn--sm`,md:``,lg:` wui-floating-btn--lg`};function f(f){let{marker:p,props:m}=r(`AppFloatingButton`,f),{icon:h,label:g,onClick:_,position:v=`end`,order:y=`primary`,size:b=`md`,tone:x=`primary`,variant:S=`solid`,stacked:C=!0,disabled:w=!1,className:T=``,style:E,...D}=m;s(`AppFloatingButton`,D),o(`AppFloatingButton`,`position`,v,[`end`,`start`]),o(`AppFloatingButton`,`order`,y,[`primary`,`secondary`]),o(`AppFloatingButton`,`size`,b,Object.keys(u)),o(`AppFloatingButton`,`tone`,x,n),o(`AppFloatingButton`,`variant`,S,t);let O=e(v,C),k=typeof h==`string`?/* @__PURE__ */ l(a,{name:h,size:u[b]}):h,A=`wui-floating-btn`+(d[b]??``)+(y===`secondary`?` wui-floating-btn--secondary`:``)+(!C&&T?` ${T}`:``),j=e=>/* @__PURE__ */ l(i,{tone:x,variant:S,className:A,disabled:w,onClick:_,"aria-label":g,tooltip:g,tooltipPlacement:v===`start`?`end`:`start`,...D,...p,...e,children:k});return C?O?c(/* @__PURE__ */ l(`span`,{className:[`wui-floating-stack-item`,`wui-floating-stack-item--${y}`,T].filter(Boolean).join(` `),style:E,children:j()}),O):null:j({style:E})}export{f as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{newIdempotencyKey as e}from"../web-core/dist/api/idempotencyKey.js";import{splitMarkerProps as
|
|
1
|
+
import{newIdempotencyKey as e}from"../web-core/dist/api/idempotencyKey.js";import t from"../lib/focusField.js";import{FormFieldsContext as n,toFieldName as r}from"../lib/formFields.js";import{UNSAVED_TEXT as i}from"../lib/unsavedText.js";import{splitMarkerProps as a}from"../lib/wuiMarker.js";import o from"./AppConfirmDialog.js";import s from"./AppIcon.js";import c from"./warnUnknownProps.js";import{createContext as l,useCallback as u,useContext as d,useEffect as f,useMemo as p,useRef as m,useState as h}from"react";import{jsx as g,jsxs as _}from"react/jsx-runtime";var v=l(null);function y(){let e=d(v);if(e===null)throw Error(`useFormSubmit must be called inside an AppForm`);return e}var b=/* @__PURE__ */ new Set,x=/* @__PURE__ */ new Map;function S(l){let{marker:d,props:y}=a(`AppForm`,l),{onSubmit:S,onChange:C,className:w,children:T,noValidate:E,action:D,method:O,encType:k,acceptCharset:A,fieldErrors:j,formErrors:M,unsavedChanges:N,unsavedChangesMessage:ee,...P}=y;c(`AppForm`,P);let[F,I]=h(!1),[L,R]=h(e),z=m(!1),[B,V]=h(null),H=p(()=>new Map(Object.entries(j??{}).map(([e,t])=>[r(e),t])),[j]),U=JSON.stringify([...H].sort(([e],[t])=>e<t?-1:+(e>t))),[W,G]=h({key:U,names:b}),K=W.key===U?W.names:b,q=u(e=>{C?.(e);let t=e.target;if(!(t instanceof HTMLElement)||!(`name`in t)||typeof t.name!=`string`||t.name===``)return;let n=r(t.name);H.has(n)&&G(e=>{let t=e.key===U?e.names:b;return t.has(n)?e:{key:U,names:/* @__PURE__ */ new Set([...t,n])}})},[C,H,U]),[J,Y]=h(x),X=u(e=>(Y(t=>new Map(t).set(e,(t.get(e)??0)+1)),()=>{Y(t=>{let n=new Map(t),r=(t.get(e)??0)-1;return r>0?n.set(e,r):n.delete(e),n})}),[]),Z=u(e=>K.has(e)?void 0:H.get(e),[K,H]),Q=p(()=>({errorOf:Z,claim:X}),[Z,X]),$=[.../* @__PURE__ */ new Set([...M??[],...[...H].filter(([e])=>!J.has(e)).map(([,e])=>e)])],te=u(async t=>{if(t.preventDefault(),z.current)return;z.current=!0,I(!0);let n=t.currentTarget;try{await S(t,{idempotencyKey:L})?R(e()):V({form:n})}finally{z.current=!1,I(!1)}},[S,L]);f(()=>{if(B===null)return;let{form:e}=B;if(V(null),e.querySelector(`.wui-error-summary`)!==null)return;let n=[...e.querySelectorAll(`[name]`)].map(e=>e.getAttribute(`name`)).find(e=>e!==null&&H.has(r(e)));n!==void 0&&t(n)},[B,H]);let ne=p(()=>({submitting:F,idempotencyKey:L}),[F,L]);return/* @__PURE__ */ g(n.Provider,{value:Q,children:/* @__PURE__ */ _(v.Provider,{value:ne,children:[/* @__PURE__ */ _(`form`,{...d,...P,noValidate:E,action:D,method:O,encType:k,acceptCharset:A,className:w,onChange:q,onSubmit:te,"aria-busy":F||void 0,children:[$.length>0?/* @__PURE__ */ _(`div`,{role:`alert`,className:`alert alert-danger alert-has-icon`,"data-wui-form-errors":``,children:[/* @__PURE__ */ g(`span`,{className:`alert-icon`,children:/* @__PURE__ */ g(s,{name:`x`,size:11})}),/* @__PURE__ */ g(`div`,{className:`alert-content`,children:$.length===1?$[0]:$.map(e=>/* @__PURE__ */ g(`div`,{children:e},e))})]}):null,T]}),N?.blocked?/* @__PURE__ */ g(o,{open:!0,title:i.title,description:ee??i.message,confirmLabel:i.leaveLabel,onConfirm:N.discard,onClose:N.keep}):null]})})}export{v as FormSubmitContext,S as default,y as useFormSubmit};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{splitMarkerProps as e}from"../lib/wuiMarker.js";import t from"./assertValidValue.js";import n from"./warnUnknownProps.js";import{jsx as r,jsxs as i}from"react/jsx-runtime";var a=[`plus`,`minus`,`times`,`divide`,`equal`],o={plus:`+`,minus:`−`,times:`×`,divide:`÷`,equal:`=`};function s(s){let{marker:c,props:l}=e(`AppFormulaSteps`,s),{steps:u=[],label:d=`Calculation`,plusLabel:f=`plus`,minusLabel:p=`minus`,timesLabel:m=`times`,divideLabel:h=`divided by`,equalLabel:g=`equals`,className:_=``,...v}=l;n(`AppFormulaSteps`,v);for(let e of u)t(`AppFormulaSteps`,`steps[].sign`,e.sign,a);let y={plus:f,minus:p,times:m,divide:h,equal:g},b=[`wui-formula-steps`,_].filter(Boolean).join(` `);return/* @__PURE__ */ r(`ol`,{className:b,"aria-label":d,...c,...v,children:u.map((e,t)=>/* @__PURE__ */ i(`li`,{className:e.sign===`equal`?`wui-formula-step wui-formula-step-total`:`wui-formula-step`,children:[/* @__PURE__ */ r(`span`,{className:`wui-formula-sign`,"aria-hidden":`true`,children:e.sign?o[e.sign]:null}),e.sign?/* @__PURE__ */ r(`span`,{className:`visually-hidden`,children:`${y[e.sign]} `}):null,/* @__PURE__ */ r(`span`,{className:`wui-formula-label`,children:e.label}),e.working?/* @__PURE__ */ r(`span`,{className:`wui-formula-working`,children:e.working}):null,/* @__PURE__ */ r(`span`,{className:`wui-formula-result`,children:e.result}),e.note?/* @__PURE__ */ r(`span`,{className:`wui-formula-note`,children:e.note}):null]},e.key??`${e.label}-${t}`))})}export{s as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../lib/useElementEntry.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./warnUnknownProps.js";import{useEffect as r,useRef as i}from"react";import{jsx as a,jsxs as o}from"react/jsx-runtime";var s=()=>import(`@webority/ui-elements/elements/hover-card`);function c(c){e(`wui-hover-card`,s);let{marker:l,props:u}=t(`AppHoverCard`,c),{trigger:d,children:f,open:p,loading:m=!1,loadingLabel:h=`Loading`,label:g,openDelay:_,closeDelay:v,onOpenChange:y,className:b=``,...x}=u;n(`AppHoverCard`,x);let S=i(null),C=i(y);return C.current=y,r(()=>{let e=S.current;if(!e)return;let t=()=>C.current?.(!0),n=()=>C.current?.(!1);return e.addEventListener(`wui:hover-card:open`,t),e.addEventListener(`wui:hover-card:close`,n),()=>{e.removeEventListener(`wui:hover-card:open`,t),e.removeEventListener(`wui:hover-card:close`,n)}},[]),/* @__PURE__ */ o(`wui-hover-card`,{ref:S,class:[`wui-hover-card`,b].filter(Boolean).join(` `),open:p?``:void 0,"open-delay":Number.isFinite(_)?_:void 0,"close-delay":Number.isFinite(v)?v:void 0,...l,...x,children:[/* @__PURE__ */ a(`span`,{className:`wui-hover-card-trigger`,children:d}),/* @__PURE__ */ a(`span`,{className:`wui-hover-card-panel`,role:`group`,"aria-label":g||void 0,"aria-busy":m?`true`:void 0,children:m?/* @__PURE__ */ o(`span`,{className:`wui-hover-card-loading`,role:`status`,children:[/* @__PURE__ */ a(`span`,{className:`wui-spinner wui-spinner-sm`,"aria-hidden":`true`}),/* @__PURE__ */ a(`span`,{children:h})]}):f})]})}export{c as default};
|
|
1
|
+
import e from"../lib/useElementEntry.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./warnUnknownProps.js";import{useEffect as r,useRef as i}from"react";import{jsx as a,jsxs as o}from"react/jsx-runtime";var s=()=>import(`@webority/ui-elements/elements/hover-card`);function c(c){e(`wui-hover-card`,s);let{marker:l,props:u}=t(`AppHoverCard`,c),{trigger:d,children:f,open:p,loading:m=!1,loadingLabel:h=`Loading`,label:g,openDelay:_,closeDelay:v,onOpenChange:y,className:b=``,...x}=u;n(`AppHoverCard`,x);let S=i(null),C=i(y);return C.current=y,r(()=>{let e=S.current;if(!e)return;let t=()=>C.current?.(!0),n=()=>C.current?.(!1);return e.addEventListener(`wui:hover-card:open`,t),e.addEventListener(`wui:hover-card:close`,n),()=>{e.removeEventListener(`wui:hover-card:open`,t),e.removeEventListener(`wui:hover-card:close`,n)}},[]),/* @__PURE__ */ o(`wui-hover-card`,{ref:S,class:[`wui-hover-card`,b].filter(Boolean).join(` `),open:p?``:void 0,"open-delay":Number.isFinite(_)?_:void 0,"close-delay":Number.isFinite(v)?v:void 0,...l,...x,children:[/* @__PURE__ */ a(`span`,{className:`wui-hover-card-trigger`,children:d}),/* @__PURE__ */ a(`span`,{className:`wui-hover-card-panel`,popover:`manual`,role:`group`,"aria-label":g||void 0,"aria-busy":m?`true`:void 0,children:m?/* @__PURE__ */ o(`span`,{className:`wui-hover-card-loading`,role:`status`,children:[/* @__PURE__ */ a(`span`,{className:`wui-spinner wui-spinner-sm`,"aria-hidden":`true`}),/* @__PURE__ */ a(`span`,{children:h})]}):f})]})}export{c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../lib/FieldMessage.js";import t from"../lib/fillLabel.js";import n from"../lib/useElementEntry.js";import ee from"../lib/useFileDrop.js";import{splitMarkerProps as te}from"../lib/wuiMarker.js";import ne from"./AppAlert.js";import r from"./AppButton.js";import i from"./AppIcon.js";import re from"./AppModal.js";import ie from"./AppRequiredMark.js";import a from"./assertValidValue.js";import ae from"./warnUnknownProps.js";import oe from"./withTooltip.js";import{AVATAR_ACCEPT as se,AVATAR_MAX_SIZE_MB as o,AVATAR_OUTPUT_SIZE as ce,AVATAR_OUTPUT_TYPE as s,AVATAR_PREVIEW_SIZES as c,AVATAR_TEXT as l,DEFAULT_IMAGE_ACCEPT as u,DEFAULT_MAX_SIZE_MB as d,avatarUnreadableMessage as f,validateFile as le}from"@webority/ui-elements/helpers";import{useCallback as ue,useEffect as de,useId as fe,useRef as pe,useState as p}from"react";import{Fragment as me,jsx as m,jsxs as h}from"react/jsx-runtime";var he=[`logo`,`avatar`],ge=[`overlay`,`buttons`],_e=[`stacked`,`inline`,`profile`],ve=[`initials`,`avatar`],ye=[`circle`,`rounded`,`square`],be=[`keep`,`image/webp`],xe=c.join(` `),Se=()=>import(`@webority/ui-elements/elements/image-crop`),Ce={logo:{controls:`overlay`,accept:u,maxSizeMb:d,crop:void 0,rotatable:!1,previews:!1,camera:!1,outputSize:void 0,outputType:`keep`,variant:`initials`,sizes:{sm:72,md:120,lg:160}},avatar:{controls:`buttons`,accept:se,maxSizeMb:o,crop:1,rotatable:!0,previews:!0,camera:!0,outputSize:ce,outputType:s,variant:`avatar`,sizes:{sm:64,md:96,lg:128}}},g=`That image could not be cropped. Choose another one.`,we=`That image could not be opened. Choose another one.`,Te={dialogSize:`lg`,dialogTitle:`Crop photo`,dialogSubtitle:`Drag the frame and zoom to choose what to keep.`,save:`Apply`,cancel:`Cancel`,cropFailed:g,unreadable:()=>we},Ee={dialogSize:void 0,dialogTitle:l.dialogTitle,dialogSubtitle:l.dialogSubtitle,save:l.save,cancel:l.cancel,cropFailed:l.cropFailed,unreadable:f};function _(se){n(`wui-image-crop`,Se);let{marker:o,props:ce}=te(`AppImagePicker`,se),{kind:s=`logo`,controls:c,value:u,fallback:d,variant:f,name:g,onChange:we,onRemove:_,removeName:v,loading:y=!1,disabled:De=!1,accept:Oe,maxSizeMb:ke,shape:b=`circle`,size:x=`md`,crop:Ae,rotatable:je,previews:Me,camera:Ne,outputSize:Pe,outputType:Fe,layout:S=`stacked`,title:Ie,subtitle:Le,overlayIcon:Re=`image`,overlayLabel:ze=`Update photo`,removeLabel:C=`Remove photo`,ariaLabel:Be,label:Ve,helperText:w,error:He,required:Ue=!1,optional:We=!1,optionalLabel:Ge=`(optional)`,dialogTitle:Ke,dialogSubtitle:qe,save:Je,cancel:Ye,cropFailed:Xe,unreadable:Ze,uploadLabel:Qe,changeLabel:$e,cameraLabel:et,className:T=``,fieldClassName:E=``,style:D,...O}=ce;ae(`AppImagePicker`,O),a(`AppImagePicker`,`kind`,s,he),a(`AppImagePicker`,`controls`,c,ge),a(`AppImagePicker`,`variant`,f,ve),a(`AppImagePicker`,`layout`,S,_e),a(`AppImagePicker`,`shape`,b,ye),a(`AppImagePicker`,`outputType`,Fe,be);let k=Ce[s]??Ce.logo,tt=Object.fromEntries(Object.entries({dialogTitle:Ke,dialogSubtitle:qe,save:Je,cancel:Ye,cropFailed:Xe,unreadable:Ze===void 0?void 0:e=>t(Ze,{name:e?.name??``})}).filter(([,e])=>e!==void 0)),A={...s===`avatar`?Ee:Te,...tt},j=k.sizes;a(`AppImagePicker`,`size`,typeof x==`string`?x:null,Object.keys(j));let nt=(c??k.controls)===`overlay`,rt=f??k.variant,M=Oe??k.accept,N=ke??k.maxSizeMb,P=Pe??k.outputSize,it=Fe??k.outputType,at=je??k.rotatable,ot=Me??k.previews,st=Ne??k.camera,F=Ae??k.crop,I=F===`free`?null:typeof F==`number`&&Number.isFinite(F)&&F>0?F:void 0;F!=null&&I===void 0&&a(`AppImagePicker`,`crop`,String(F),[`free`,`a positive number`]);let L=I!==void 0&&P===void 0,R=pe(null),ct=pe(null),z=pe(null),B=fe(),[V,lt]=p(null),[ut,dt]=p(!1),[ft,H]=p(!1),[pt,U]=p(``),[W,mt]=p(null),[G,ht]=p(!1),[gt,_t]=p(`loading`),[vt,yt]=p(``),bt=ue(e=>{if(z.current=e,!e)return;let t=()=>{_t(`ready`),e.querySelector(`.wui-crop-stage`)?.focus()},n=()=>_t(`error`);return e.addEventListener(`load`,t),e.addEventListener(`error`,n),()=>{e.removeEventListener(`load`,t),e.removeEventListener(`error`,n),z.current=null}},[]);de(()=>()=>{W&&URL.revokeObjectURL(W.url)},[W]),de(()=>()=>{V&&URL.revokeObjectURL(V)},[V]);let[xt,St]=p(u);u!==xt&&(St(u),lt(null),dt(!1),H(!1));let K=y||De,q=ut?null:V||(u&&!ft?u:null),Ct=!!q,J=He||pt,Y=w&&!J?`${B}-hint`:void 0,X=J?`${B}-error`:void 0,wt=X||Y,Tt=!K&&Ct&&(!!V||!!_||!!v),Et=Ct?$e??l.change:Qe??l.choose,Dt=typeof x==`number`?x:j[x]??j.md,Ot=()=>{K||R.current?.click()},kt=()=>{K||ct.current?.click()},At=e=>{if(g&&R.current&&typeof DataTransfer==`function`){let t=new DataTransfer;t.items.add(e),R.current.files=t.files}dt(!1),H(!1),lt(URL.createObjectURL(e)),we?.(e)},jt=e=>{let t=I!==void 0&&e.type!==`image/svg+xml`,n=le(e,{accept:M,maxSizeMb:t&&L?0:N});n?U(n):(U(``),t?(_t(`loading`),yt(``),mt({file:e,url:URL.createObjectURL(e)})):At(e))},{dragOver:Mt,dropProps:Nt}=ee({accept:M,maxSizeMb:L?0:N,disabled:K,onFiles:e=>{let t=e[0];if(!t)throw Error(`<AppImagePicker> received a drop with no file.`);jt(t)},onReject:({message:e})=>U(e)}),Pt=e=>{let t=it===`keep`?e.type:it;return P===void 0?{name:e.name,type:t,maxBytes:N>0?N*1024*1024:0}:{name:e.name||`photo`,type:t,size:P}},Ft=async()=>{if(!W)return;let{file:e}=W;ht(!0),yt(``);let t=null;try{t=await z.current?.toFile(Pt(e))}catch{t=null}if(ht(!1),!t)yt(A.cropFailed);else if(mt(null),L){let e=le(t,{accept:M,maxSizeMb:N});e?U(e):At(t)}else At(t)},It=()=>{G||mt(null)},Lt=e=>{let t=e.target.files?.[0];e.target.value=``,t&&jt(t)},Rt=()=>{lt(null),dt(!0),U(``),R.current&&(R.current.value=``),_?.()},Z=I!==void 0&&/* @__PURE__ */ h(re,{open:!!W,title:A.dialogTitle,subtitle:A.dialogSubtitle,size:A.dialogSize,staticBackdrop:!0,dismissible:!G,onClose:It,footer:/* @__PURE__ */ h(me,{children:[/* @__PURE__ */ m(r,{type:`button`,variant:`soft`,disabled:G,onClick:It,children:A.cancel}),/* @__PURE__ */ m(r,{type:`button`,loading:G,disabled:gt!==`ready`,onClick:Ft,children:A.save})]}),children:[gt===`error`&&W&&/* @__PURE__ */ m(ne,{tone:`danger`,children:A.unreadable(W.file)}),vt&&/* @__PURE__ */ m(ne,{tone:`danger`,children:vt}),W&>!==`error`&&/* @__PURE__ */ m(`wui-image-crop`,{ref:bt,src:W.url,aspect:I??`free`,round:I===1&&b===`circle`,rotatable:at,previews:ot?xe:void 0})]}),zt=v&&/* @__PURE__ */ m(`input`,{type:`hidden`,name:v,value:`true`,disabled:!ut}),Q=Ve&&/* @__PURE__ */ h(`label`,{className:`label`,htmlFor:B,children:[Ve,We&&!Ue&&/* @__PURE__ */ m(`span`,{className:`label-optional`,children:` ${Ge}`}),Ue&&/* @__PURE__ */ m(ie,{})]}),Bt=/* @__PURE__ */ m(`input`,{id:B,ref:R,type:`file`,name:g,hidden:!0,accept:M,disabled:K,onChange:Lt});if(!nt){let t=Dt,n=st&&/* @__PURE__ */ h(`button`,{type:`button`,className:`btn btn-soft-primary btn-sm wui-image-picker-buttons-camera`,disabled:K,onClick:kt,children:[/* @__PURE__ */ m(i,{name:`camera`,size:16}),et??l.camera]}),ee={"--wui-avatar-size":`${t}px`,...D};return/* @__PURE__ */ h(`div`,{...o,className:`field wui-image-picker-field${E?` ${E}`:``}`,children:[Q,/* @__PURE__ */ h(`div`,{className:`wui-image-picker-buttons${Mt?` is-dragging`:``}${T?` ${T}`:``}`,style:ee,...Nt,children:[/* @__PURE__ */ h(`button`,{type:`button`,className:`wui-image-picker-buttons-face`,tabIndex:-1,"aria-label":Be??Et,"aria-describedby":wt,"aria-busy":y||void 0,disabled:K,onClick:Ot,...O,children:[q?/* @__PURE__ */ m(`img`,{className:`wui-image-picker-buttons-img`,src:q,alt:``,onError:()=>H(!0)}):/* @__PURE__ */ m(`span`,{className:`wui-image-picker-buttons-placeholder`,"aria-hidden":`true`,children:d||/* @__PURE__ */ m(i,{name:`user`,size:Math.round(t*.5)})}),/* @__PURE__ */ m(`span`,{className:`wui-image-picker-buttons-badge`,"aria-hidden":`true`,children:y?/* @__PURE__ */ m(i,{name:`refresh-cw`,size:14,className:`wui-spin`}):/* @__PURE__ */ m(i,{name:`camera`,size:14})})]}),/* @__PURE__ */ h(`div`,{className:`wui-image-picker-buttons-actions`,children:[/* @__PURE__ */ m(r,{variant:`soft`,size:`sm`,disabled:K,"aria-describedby":wt,onClick:Ot,children:Et}),n,/* @__PURE__ */ m(r,{tone:`danger`,variant:`soft`,size:`sm`,"data-wui-image-picker-remove":!0,hidden:!Tt,onClick:Rt,children:C})]}),Bt,st&&/* @__PURE__ */ m(`input`,{ref:ct,type:`file`,hidden:!0,accept:`image/*`,capture:`user`,disabled:K,onChange:Lt}),zt]}),/* @__PURE__ */ m(e,{error:J,hint:w,errorId:X,hintId:Y}),Z]})}let $=Dt,Vt=Math.max(14,Math.round($*.18)),Ht=Math.round($*.5),Ut=`wui-image-picker${rt===`avatar`?` wui-image-picker-avatar`:``}${b===`rounded`?` wui-image-picker-rounded`:b===`square`?` wui-image-picker-square`:``}${Mt?` is-dragging`:``}`,Wt=S===`inline`,Gt=S===`profile`,Kt=[`field`,`wui-image-picker-field`,Wt&&`wui-image-picker-field-inline`,Gt&&`wui-image-picker-field-profile`,T,E].filter(Boolean).join(` `),qt={"--wui-logo-size":`${$}px`},Jt=/* @__PURE__ */ h(`div`,{className:`wui-image-picker-shell`,style:qt,children:[/* @__PURE__ */ m(`button`,{type:`button`,className:Ut,onClick:Ot,disabled:K,"aria-busy":y||void 0,"aria-label":Be??`Upload photo`,"aria-describedby":X||Y,...Nt,...O,children:/* @__PURE__ */ h(`span`,{className:`wui-image-picker-ring`,"data-overlay-label":ze,children:[q?/* @__PURE__ */ m(`img`,{className:`wui-image-picker-img`,src:q,alt:``,onError:()=>H(!0)}):/* @__PURE__ */ m(`span`,{className:`wui-image-picker-logo`,children:d||rt===`avatar`&&/* @__PURE__ */ m(i,{name:`user`,size:Ht})}),y?/* @__PURE__ */ m(`span`,{className:`wui-image-picker-overlay is-loading`,"aria-hidden":`true`,children:/* @__PURE__ */ m(i,{name:`refresh-cw`,size:Vt,className:`wui-spin`})}):!De&&/* @__PURE__ */ h(`span`,{className:`wui-image-picker-overlay`,children:[/* @__PURE__ */ m(i,{name:Re,size:Vt}),/* @__PURE__ */ m(`span`,{children:ze})]})]})}),oe(/* @__PURE__ */ m(`button`,{type:`button`,className:`wui-image-picker-remove`,hidden:!Tt,"aria-label":C,"data-wui-image-picker-remove":!0,onClick:Rt,children:/* @__PURE__ */ m(i,{name:`x`,size:14})}),Tt?C:null),Bt,zt]}),Yt=w&&!J?/* @__PURE__ */ m(`div`,{className:`wui-image-picker-hint`,id:Y,children:w}):null,Xt=J?/* @__PURE__ */ m(e,{error:J,errorId:X}):null,Zt=/* @__PURE__ */ h(`div`,{className:`wui-image-picker-meta`,children:[Ie&&/* @__PURE__ */ m(`div`,{className:`wui-image-picker-title`,children:Ie}),Le&&/* @__PURE__ */ m(`div`,{className:`wui-image-picker-subtitle`,children:Le}),Yt,Xt]});return Wt?/* @__PURE__ */ h(`div`,{...o,className:Kt,style:D,children:[Q,/* @__PURE__ */ h(`div`,{className:`wui-image-picker-row`,children:[Jt,Zt]}),Z]}):Gt?/* @__PURE__ */ h(`div`,{...o,className:Kt,style:D,children:[Q,Jt,Zt,Z]}):/* @__PURE__ */ h(`div`,{...o,className:Kt,style:D,children:[Q,Jt,Yt,Xt,Z]})}export{_ as default};
|
|
1
|
+
import e from"../lib/FieldMessage.js";import t from"../lib/fillLabel.js";import{useFieldError as n}from"../lib/formFields.js";import ee from"../lib/useElementEntry.js";import te from"../lib/useFileDrop.js";import{splitMarkerProps as ne}from"../lib/wuiMarker.js";import re from"./AppAlert.js";import r from"./AppButton.js";import i from"./AppIcon.js";import ie from"./AppModal.js";import ae from"./AppRequiredMark.js";import a from"./assertValidValue.js";import oe from"./warnUnknownProps.js";import se from"./withTooltip.js";import{AVATAR_ACCEPT as ce,AVATAR_MAX_SIZE_MB as o,AVATAR_OUTPUT_SIZE as le,AVATAR_OUTPUT_TYPE as s,AVATAR_PREVIEW_SIZES as c,AVATAR_TEXT as l,DEFAULT_IMAGE_ACCEPT as u,DEFAULT_MAX_SIZE_MB as d,avatarUnreadableMessage as f,validateFile as ue}from"@webority/ui-elements/helpers";import{useCallback as de,useEffect as fe,useId as pe,useRef as me,useState as p}from"react";import{Fragment as he,jsx as m,jsxs as h}from"react/jsx-runtime";var ge=[`logo`,`avatar`],_e=[`overlay`,`buttons`],ve=[`stacked`,`inline`,`profile`],ye=[`initials`,`avatar`],be=[`circle`,`rounded`,`square`],xe=[`keep`,`image/webp`],Se=c.join(` `),Ce=()=>import(`@webority/ui-elements/elements/image-crop`),we={logo:{controls:`overlay`,accept:u,maxSizeMb:d,crop:void 0,rotatable:!1,previews:!1,camera:!1,outputSize:void 0,outputType:`keep`,variant:`initials`,sizes:{sm:72,md:120,lg:160}},avatar:{controls:`buttons`,accept:ce,maxSizeMb:o,crop:1,rotatable:!0,previews:!0,camera:!0,outputSize:le,outputType:s,variant:`avatar`,sizes:{sm:64,md:96,lg:128}}},g=`That image could not be cropped. Choose another one.`,Te=`That image could not be opened. Choose another one.`,Ee={dialogSize:`lg`,dialogTitle:`Crop photo`,dialogSubtitle:`Drag the frame and zoom to choose what to keep.`,save:`Apply`,cancel:`Cancel`,cropFailed:g,unreadable:()=>Te},De={dialogSize:void 0,dialogTitle:l.dialogTitle,dialogSubtitle:l.dialogSubtitle,save:l.save,cancel:l.cancel,cropFailed:l.cropFailed,unreadable:f};function Oe(ce){ee(`wui-image-crop`,Ce);let{marker:o,props:le}=ne(`AppImagePicker`,ce),{kind:s=`logo`,controls:c,value:u,fallback:d,variant:f,name:g,onChange:Te,onRemove:Oe,removeName:_,loading:v=!1,disabled:ke=!1,accept:Ae,maxSizeMb:je,shape:y=`circle`,size:b=`md`,crop:Me,rotatable:Ne,previews:Pe,camera:Fe,outputSize:Ie,outputType:Le,layout:x=`stacked`,title:Re,subtitle:ze,overlayIcon:Be=`image`,overlayLabel:Ve=`Update photo`,removeLabel:S=`Remove photo`,ariaLabel:He,label:Ue,helperText:C,error:We,required:Ge=!1,optional:Ke=!1,optionalLabel:qe=`(optional)`,dialogTitle:Je,dialogSubtitle:Ye,save:Xe,cancel:Ze,cropFailed:Qe,unreadable:$e,uploadLabel:et,changeLabel:tt,cameraLabel:nt,className:rt=``,fieldClassName:it=``,style:w,...T}=le,at=n(g),ot=We??at;oe(`AppImagePicker`,T),a(`AppImagePicker`,`kind`,s,ge),a(`AppImagePicker`,`controls`,c,_e),a(`AppImagePicker`,`variant`,f,ye),a(`AppImagePicker`,`layout`,x,ve),a(`AppImagePicker`,`shape`,y,be),a(`AppImagePicker`,`outputType`,Le,xe);let E=we[s]??we.logo,st=Object.fromEntries(Object.entries({dialogTitle:Je,dialogSubtitle:Ye,save:Xe,cancel:Ze,cropFailed:Qe,unreadable:$e===void 0?void 0:e=>t($e,{name:e?.name??``})}).filter(([,e])=>e!==void 0)),D={...s===`avatar`?De:Ee,...st},O=E.sizes;a(`AppImagePicker`,`size`,typeof b==`string`?b:null,Object.keys(O));let ct=(c??E.controls)===`overlay`,lt=f??E.variant,k=Ae??E.accept,A=je??E.maxSizeMb,j=Ie??E.outputSize,ut=Le??E.outputType,dt=Ne??E.rotatable,ft=Pe??E.previews,pt=Fe??E.camera,M=Me??E.crop,N=M===`free`?null:typeof M==`number`&&Number.isFinite(M)&&M>0?M:void 0;M!=null&&N===void 0&&a(`AppImagePicker`,`crop`,String(M),[`free`,`a positive number`]);let mt=N!==void 0&&j===void 0,P=me(null),ht=me(null),gt=me(null),F=pe(),[I,L]=p(null),[_t,R]=p(!1),[vt,z]=p(!1),[yt,B]=p(``),[V,H]=p(null),[U,bt]=p(!1),[W,G]=p(`loading`),[xt,K]=p(``),St=de(e=>{if(gt.current=e,!e)return;let t=()=>{G(`ready`),e.querySelector(`.wui-crop-stage`)?.focus()},n=()=>G(`error`);return e.addEventListener(`load`,t),e.addEventListener(`error`,n),()=>{e.removeEventListener(`load`,t),e.removeEventListener(`error`,n),gt.current=null}},[]);fe(()=>()=>{V&&URL.revokeObjectURL(V.url)},[V]),fe(()=>()=>{I&&URL.revokeObjectURL(I)},[I]);let[Ct,wt]=p(u);u!==Ct&&(wt(u),L(null),R(!1),z(!1));let q=v||ke,J=_t?null:I||(u&&!vt?u:null),Tt=!!J,Y=ot||yt,X=C&&!Y?`${F}-hint`:void 0,Z=Y?`${F}-error`:void 0,Et=Z||X,Dt=!q&&Tt&&(!!I||!!Oe||!!_),Ot=Tt?tt??l.change:et??l.choose,kt=typeof b==`number`?b:O[b]??O.md,At=()=>{q||P.current?.click()},jt=()=>{q||ht.current?.click()},Mt=e=>{if(g&&P.current&&typeof DataTransfer==`function`){let t=new DataTransfer;t.items.add(e),P.current.files=t.files}R(!1),z(!1),L(URL.createObjectURL(e)),Te?.(e)},Nt=e=>{let t=N!==void 0&&e.type!==`image/svg+xml`,n=ue(e,{accept:k,maxSizeMb:t&&mt?0:A});n?B(n):(B(``),t?(G(`loading`),K(``),H({file:e,url:URL.createObjectURL(e)})):Mt(e))},{dragOver:Pt,dropProps:Ft}=te({accept:k,maxSizeMb:mt?0:A,disabled:q,onFiles:e=>{let t=e[0];if(!t)throw Error(`<AppImagePicker> received a drop with no file.`);Nt(t)},onReject:({message:e})=>B(e)}),It=e=>{let t=ut===`keep`?e.type:ut;return j===void 0?{name:e.name,type:t,maxBytes:A>0?A*1024*1024:0}:{name:e.name||`photo`,type:t,size:j}},Lt=async()=>{if(!V)return;let{file:e}=V;bt(!0),K(``);let t=null;try{t=await gt.current?.toFile(It(e))}catch{t=null}if(bt(!1),!t)K(D.cropFailed);else if(H(null),mt){let e=ue(t,{accept:k,maxSizeMb:A});e?B(e):Mt(t)}else Mt(t)},Rt=()=>{U||H(null)},zt=e=>{let t=e.target.files?.[0];e.target.value=``,t&&Nt(t)},Bt=()=>{L(null),R(!0),B(``),P.current&&(P.current.value=``),Oe?.()},Q=N!==void 0&&/* @__PURE__ */ h(ie,{open:!!V,title:D.dialogTitle,subtitle:D.dialogSubtitle,size:D.dialogSize,staticBackdrop:!0,dismissible:!U,closeOnEscape:!U,onClose:Rt,footer:/* @__PURE__ */ h(he,{children:[/* @__PURE__ */ m(r,{type:`button`,variant:`soft`,disabled:U,onClick:Rt,children:D.cancel}),/* @__PURE__ */ m(r,{type:`button`,loading:U,disabled:W!==`ready`,onClick:Lt,children:D.save})]}),children:[W===`error`&&V&&/* @__PURE__ */ m(re,{tone:`danger`,children:D.unreadable(V.file)}),xt&&/* @__PURE__ */ m(re,{tone:`danger`,children:xt}),V&&W!==`error`&&/* @__PURE__ */ m(`wui-image-crop`,{ref:St,src:V.url,aspect:N??`free`,round:N===1&&y===`circle`,rotatable:dt,previews:ft?Se:void 0})]}),Vt=_&&/* @__PURE__ */ m(`input`,{type:`hidden`,name:_,value:`true`,disabled:!_t}),$=Ue&&/* @__PURE__ */ h(`label`,{className:`label`,htmlFor:F,children:[Ue,Ke&&!Ge&&/* @__PURE__ */ m(`span`,{className:`label-optional`,children:` ${qe}`}),Ge&&/* @__PURE__ */ m(ae,{})]}),Ht=/* @__PURE__ */ m(`input`,{id:F,ref:P,type:`file`,name:g,hidden:!0,accept:k,disabled:q,onChange:zt});if(!ct){let t=kt,n=pt&&/* @__PURE__ */ h(`button`,{type:`button`,className:`btn btn-soft-primary btn-sm wui-image-picker-buttons-camera`,disabled:q,onClick:jt,children:[/* @__PURE__ */ m(i,{name:`camera`,size:16}),nt??l.camera]}),ee={"--wui-avatar-size":`${t}px`,...w};return/* @__PURE__ */ h(`div`,{...o,className:`field wui-image-picker-field${it?` ${it}`:``}`,children:[$,/* @__PURE__ */ h(`div`,{className:`wui-image-picker-buttons${Pt?` is-dragging`:``}${rt?` ${rt}`:``}`,style:ee,...Ft,children:[/* @__PURE__ */ h(`button`,{type:`button`,className:`wui-image-picker-buttons-face`,tabIndex:-1,"aria-label":He??Ot,"aria-describedby":Et,"aria-busy":v||void 0,disabled:q,onClick:At,...T,children:[J?/* @__PURE__ */ m(`img`,{className:`wui-image-picker-buttons-img`,src:J,alt:``,onError:()=>z(!0)}):/* @__PURE__ */ m(`span`,{className:`wui-image-picker-buttons-placeholder`,"aria-hidden":`true`,children:d||/* @__PURE__ */ m(i,{name:`user`,size:Math.round(t*.5)})}),/* @__PURE__ */ m(`span`,{className:`wui-image-picker-buttons-badge`,"aria-hidden":`true`,children:v?/* @__PURE__ */ m(i,{name:`refresh-cw`,size:14,className:`wui-spin`}):/* @__PURE__ */ m(i,{name:`camera`,size:14})})]}),/* @__PURE__ */ h(`div`,{className:`wui-image-picker-buttons-actions`,children:[/* @__PURE__ */ m(r,{variant:`soft`,size:`sm`,disabled:q,"aria-describedby":Et,onClick:At,children:Ot}),n,/* @__PURE__ */ m(r,{tone:`danger`,variant:`soft`,size:`sm`,"data-wui-image-picker-remove":!0,hidden:!Dt,onClick:Bt,children:S})]}),Ht,pt&&/* @__PURE__ */ m(`input`,{ref:ht,type:`file`,hidden:!0,accept:`image/*`,capture:`user`,disabled:q,onChange:zt}),Vt]}),/* @__PURE__ */ m(e,{error:Y,hint:C,errorId:Z,hintId:X}),Q]})}let Ut=kt,Wt=Math.max(14,Math.round(Ut*.18)),Gt=Math.round(Ut*.5),Kt=`wui-image-picker${lt===`avatar`?` wui-image-picker-avatar`:``}${y===`rounded`?` wui-image-picker-rounded`:y===`square`?` wui-image-picker-square`:``}${Pt?` is-dragging`:``}`,qt=x===`inline`,Jt=x===`profile`,Yt=[`field`,`wui-image-picker-field`,qt&&`wui-image-picker-field-inline`,Jt&&`wui-image-picker-field-profile`,rt,it].filter(Boolean).join(` `),Xt={"--wui-logo-size":`${Ut}px`},Zt=/* @__PURE__ */ h(`div`,{className:`wui-image-picker-shell`,style:Xt,children:[/* @__PURE__ */ m(`button`,{type:`button`,className:Kt,onClick:At,disabled:q,"aria-busy":v||void 0,"aria-label":He??`Upload photo`,"aria-describedby":Z||X,...Ft,...T,children:/* @__PURE__ */ h(`span`,{className:`wui-image-picker-ring`,"data-overlay-label":Ve,children:[J?/* @__PURE__ */ m(`img`,{className:`wui-image-picker-img`,src:J,alt:``,onError:()=>z(!0)}):/* @__PURE__ */ m(`span`,{className:`wui-image-picker-logo`,children:d||lt===`avatar`&&/* @__PURE__ */ m(i,{name:`user`,size:Gt})}),v?/* @__PURE__ */ m(`span`,{className:`wui-image-picker-overlay is-loading`,"aria-hidden":`true`,children:/* @__PURE__ */ m(i,{name:`refresh-cw`,size:Wt,className:`wui-spin`})}):!ke&&/* @__PURE__ */ h(`span`,{className:`wui-image-picker-overlay`,children:[/* @__PURE__ */ m(i,{name:Be,size:Wt}),/* @__PURE__ */ m(`span`,{children:Ve})]})]})}),se(/* @__PURE__ */ m(`button`,{type:`button`,className:`wui-image-picker-remove`,hidden:!Dt,"aria-label":S,"data-wui-image-picker-remove":!0,onClick:Bt,children:/* @__PURE__ */ m(i,{name:`x`,size:14})}),Dt?S:null),Ht,Vt]}),Qt=C&&!Y?/* @__PURE__ */ m(`div`,{className:`wui-image-picker-hint`,id:X,children:C}):null,$t=Y?/* @__PURE__ */ m(e,{error:Y,errorId:Z}):null,en=/* @__PURE__ */ h(`div`,{className:`wui-image-picker-meta`,children:[Re&&/* @__PURE__ */ m(`div`,{className:`wui-image-picker-title`,children:Re}),ze&&/* @__PURE__ */ m(`div`,{className:`wui-image-picker-subtitle`,children:ze}),Qt,$t]});return qt?/* @__PURE__ */ h(`div`,{...o,className:Yt,style:w,children:[$,/* @__PURE__ */ h(`div`,{className:`wui-image-picker-row`,children:[Zt,en]}),Q]}):Jt?/* @__PURE__ */ h(`div`,{...o,className:Yt,style:w,children:[$,Zt,en,Q]}):/* @__PURE__ */ h(`div`,{...o,className:Yt,style:w,children:[$,Zt,Qt,$t,Q]})}export{Oe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../lib/useElementEntry.js";import{splitMarkerProps as
|
|
1
|
+
import{groupIndianText as e}from"../lib/indianGrouping.js";import t from"../lib/useElementEntry.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppIcon.js";import ee from"./AppSelect.js";import i from"./assertValidValue.js";import a from"./warnUnknownProps.js";import{INLINE_EDIT_TEXT as o,INLINE_EDIT_TYPES as s,inlineEditText as c}from"@webority/ui-elements/helpers";import{useEffect as l,useId as u,useRef as d,useState as f}from"react";import{flushSync as p}from"react-dom";import{jsx as m,jsxs as h}from"react/jsx-runtime";var te=()=>import(`@webority/ui-elements/elements/datepicker`),ne=()=>import(`@webority/ui-elements/elements/inline-edit`),g=[`none`,`indian`],_=e=>e==null?``:String(e),v=(e,t)=>t===`number`?e===``?null:Number(e):e;function y(y){let b=t(`wui-inline-edit`,ne);t(`wui-datepicker`,te);let{marker:x,props:S}=n(`AppInlineEdit`,y),{value:C,onSave:w,type:T,options:E=[],label:D,placeholder:O,validate:k,renderValue:A,grouping:j=`none`,wrap:M=!0,disabled:N=!1,className:re=``,id:P,...F}=S;a(`AppInlineEdit`,F),i(`AppInlineEdit`,`type`,T,s),i(`AppInlineEdit`,`grouping`,j,g);let I=T??`text`,L=u(),R=P||`inline-edit-${L.replace(/[^a-zA-Z0-9_-]/g,``)}`,z=`${R}-error`,B=`${R}-control`,V=d(null),H=_(C),[U,W]=f(H),[G,K]=f(H);U!==H&&(W(H),K(H));let[q,J]=f(null),Y=d({onSave:w,validate:k,kind:I});Y.current={onSave:w,validate:k,kind:I},l(()=>{let e=V.current;if(e&&b)return e.save=async e=>{J(e);let t=!1;try{await Y.current.onSave?.(v(e,Y.current.kind)),t=!0}finally{p(()=>{t&&K(e),J(null)})}},e.validate=e=>Y.current.validate?.(v(e,Y.current.kind))||null,()=>{e.save=void 0,e.validate=void 0}},[b]);let X=q??G,Z=c(X,{type:I,options:E,...O===void 0?null:{placeholder:O}}),ie=I===`number`&&j===`indian`?e(Z.text):Z.text,ae=A&&!Z.empty?A(v(X,I)):ie,Q={id:B,"data-wui-control":``,"aria-label":D},$;if(I===`select`){let e=E.map(e=>({value:String(e.value),label:_(e.label??e.value)}));$=/* @__PURE__ */ m(ee,{id:B,"data-wui-control":``,"aria-label":D,size:`sm`,placeholder:O||void 0,options:e})}else $=I===`date`?/* @__PURE__ */ m(`wui-datepicker`,{...Q,size:`sm`,"aria-describedby":z,placeholder:O||void 0}):I===`textarea`?/* @__PURE__ */ m(`textarea`,{...Q,className:`form-control textarea`,rows:3,"aria-describedby":z,placeholder:O||void 0}):/* @__PURE__ */ m(`input`,{...Q,type:I===`number`?`number`:`text`,inputMode:I===`number`?`decimal`:void 0,className:`form-control input input-sm`,"aria-describedby":z,placeholder:O||void 0});let oe=[`wui-inline-edit`,M===!1?`wui-inline-edit--nowrap`:``,re].filter(Boolean).join(` `);return/* @__PURE__ */ h(`wui-inline-edit`,{ref:V,id:R,class:oe,type:I,label:D,value:G,placeholder:O||void 0,disabled:N?``:void 0,controlled:``,...x,...F,children:[/* @__PURE__ */ h(`button`,{type:`button`,className:`wui-inline-edit-display`,"data-wui-display":``,"aria-describedby":z,disabled:N,children:[/* @__PURE__ */ m(`span`,{className:`visually-hidden`,children:N?o.readOnly(D):o.edit(D)}),/* @__PURE__ */ m(`span`,{className:`wui-inline-edit-value`,"data-wui-value":``,"data-wui-empty":Z.empty?``:void 0,children:ae}),/* @__PURE__ */ m(`span`,{className:`wui-inline-edit-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ m(r,{name:`edit`,size:14})})]}),/* @__PURE__ */ m(`span`,{className:`wui-inline-edit-editor`,"data-wui-editor":``,hidden:!0,children:$}),/* @__PURE__ */ h(`span`,{className:`wui-inline-edit-status`,"aria-hidden":`true`,children:[/* @__PURE__ */ m(`span`,{className:`wui-inline-edit-spinner spinner-border spinner-border-sm`}),/* @__PURE__ */ m(`span`,{className:`wui-inline-edit-saved`,children:/* @__PURE__ */ m(r,{name:`tick-circle`,size:16})})]}),/* @__PURE__ */ m(`span`,{className:`wui-inline-edit-error`,id:z,"data-wui-error":``,hidden:!0}),/* @__PURE__ */ m(`span`,{className:`visually-hidden`,"data-wui-live":``,"aria-live":`polite`,"aria-atomic":`true`})]})}export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import{FIELD_BUSY_CLASS as n,blockWhenReadOnly as ee}from"../lib/fieldState.js";import{
|
|
1
|
+
import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import{FIELD_BUSY_CLASS as n,blockWhenReadOnly as ee}from"../lib/fieldState.js";import{useFieldError as te}from"../lib/formFields.js";import{splitMarkerProps as ne}from"../lib/wuiMarker.js";import r from"./AppIcon.js";import re from"./AppInfoTip.js";import ie from"./AppPopover.js";import i from"./AppRequiredMark.js";import a from"./assertValidValue.js";import ae from"./warnUnknownProps.js";import{MASK_INPUT_TYPES as oe,MASK_NAMES as se,attachInputMask as ce,evaluatePassword as le,formatMasked as ue,isMaskPattern as de,postedMasked as fe}from"@webority/ui-elements/helpers";import{cloneElement as pe,forwardRef as me,useEffect as o,useId as he,useRef as s,useState as c}from"react";import{jsx as l,jsxs as u}from"react/jsx-runtime";import{Form as d}from"react-bootstrap";var ge=[`sm`,`md`,`lg`],_e=[`bare`],ve=[`off`,`border`,`above`],ye=[`off`,`shown`];function f(e,t){if(t!=null&&t!==``&&t!==!1)throw Error(`<AppInput> controlOnly draws no field, so it takes no ${e}; draw the label or message on the page.`)}function be(e){return e==null||{...`minLength`in e&&{minLength:e.minLength??0},...`uppercase`in e&&{uppercase:e.uppercase??!1},...`lowercase`in e&&{lowercase:e.lowercase??!1},...`digit`in e&&{digit:e.digit??!1},...`special`in e&&{special:e.special??!1},...`uniqueChars`in e&&{uniqueChars:e.uniqueChars??0},...`customRules`in e&&{customRules:e.customRules??[]}}}var p=me(function(me,p){let{marker:xe,props:Se}=ne(`AppInput`,me),{label:m,required:h=!1,optional:g=!1,error:Ce,helperText:_,help:v,helpLabel:we=`More information`,type:y=`text`,size:b=`md`,leftIcon:x,rightIcon:S,onRightIconClick:Te,rightIconLabel:Ee,unit:C,id:De,name:Oe,className:ke=``,fieldClassName:w=``,disabled:Ae=!1,readOnly:T=!1,loading:E=!1,clearable:D=!1,clearLabel:je=`Clear`,optionalLabel:Me=`(optional)`,requirementsTitle:Ne=`Password requirements`,showPasswordLabel:Pe=`Show password`,hidePasswordLabel:Fe=`Hide password`,showCount:O=!1,maxLength:k,monospace:Ie=!1,prefix:A,suffix:j,action:Le,floatingLabel:M=`off`,variant:Re,passwordRequirements:N=`off`,passwordPolicy:ze,requirementsPlacement:P=`auto`,mask:F,postFormatted:I=!1,onMaskChange:Be,controlOnly:Ve=!1,value:L,...R}=Se,He=te(Oe);ae(`AppInput`,R);let{onChange:Ue,onBlur:We,onClick:Ge,onInput:z,...Ke}=R;a(`AppInput`,`size`,b,ge),a(`AppInput`,`variant`,Re,_e),a(`AppInput`,`floatingLabel`,M,ve),a(`AppInput`,`passwordRequirements`,N,ye),Ve&&(f(`label`,m),f(`error`,Ce),f(`helperText`,_),f(`fieldClassName`,w),f(`showCount`,O),f(`help`,v),f(`optional`,g),f(`floatingLabel`,M===`off`?void 0:M),f(`passwordRequirements`,N===`shown`?N:void 0)),o(()=>{g&&h&&typeof process<`u`&&process.env.NODE_ENV!==`production`&&e(`AppInput: optional and required together; optional ignored`)},[g,h]),F!=null&&!de(F)&&a(`AppInput`,`mask`,F,se),F!=null&&a(`AppInput`,`type`,y,oe);let[B,qe]=c(!1),[Je,Ye]=c(``),V=Ce||Je||He,Xe=he(),H=De||Xe,U=y===`password`,Ze=U&&B?`text`:y,W=s(null),Qe=e=>{W.current=e,typeof p==`function`?p(e):p&&(p.current=e)},G=String(L??R.defaultValue??``),[$e,K]=c(()=>!!G),[et,tt]=c(()=>G.length),nt=D&&!Ae&&!T&&!E,q=D||O,J=U&&N===`shown`,[rt,it]=c(G);o(()=>{J&&L!==void 0&&it(String(L??``))},[L,J]),o(()=>{if(!q||L===void 0)return;let e=String(L??``);K(!!e),tt(e.length)},[L,q]);let at=e=>{let t=e.currentTarget;K(!!t.value),tt(t.value.length),z?.(e)},ot=e=>{J&&it(e.currentTarget.value),q?at(e):z?.(e)},st=F?{...L!==void 0&&{value:ue(F,L)},...R.defaultValue!==void 0&&{defaultValue:ue(F,R.defaultValue)}}:null,ct=s(Be);ct.current=Be,o(()=>{let e=W.current;if(F&&e)return ce(e,{mask:F,postFormatted:I,onChange:(e,t)=>ct.current?.(e,t),onInvalidChange:Ye})},[F,I]);let lt=e=>F&&!I&&e?t=>{let n=t.currentTarget,ee=new Proxy(n,{get:(e,t)=>{if(t===`value`)return fe(F,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,ut=nt?/* @__PURE__ */ l(`button`,{type:`button`,className:`input-clear`,onClick:()=>{let e=W.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})),K(!1),e.focus()},"aria-label":je,tabIndex:-1,hidden:!$e,children:/* @__PURE__ */ l(r,{name:`x`,size:16})}):null,dt=V&&H?`${H}-error`:void 0,ft=_&&H?`${H}-hint`:void 0,Y=J&&P===`inline`,pt=Y&&H?`${H}-requirements`:void 0,mt=dt||(Y?pt:ft),ht=[`input`,b===`sm`?`input-sm`:``,b===`lg`?`input-lg`:``,V?`error`:``,U?`pw`:``,C?`num-input`:``,!(M!==`off`&&m||A||j||C||U||S)&&D&&nt?`has-clear`:``,Re===`bare`?`input-bare`:``,Ie?`wui-mono`:``,E?n:``,ke].filter(Boolean).join(` `),X=ee(T||E),gt=X?e=>{X(e),Ge?.(e)}:Ge,_t=lt(Ue),vt=lt(We),yt=q||J?ot:z,Z=/* @__PURE__ */ l(d.Control,{id:H,name:Oe,type:Ze,className:ht,disabled:Ae,readOnly:T||E,"aria-busy":E||void 0,required:h,"aria-invalid":V?`true`:`false`,"aria-describedby":mt,maxLength:k,...L===void 0?null:{value:L},...Ke,...gt?{onClick:gt}:null,..._t?{onChange:_t}:null,...vt?{onBlur:vt}:null,...st,placeholder:M===`off`?R.placeholder:` `,ref:Qe,...yt?{onInput:yt}:null}),Q=ze??!0,bt=Q&&typeof Q==`object`&&Q.title||Ne,xt=J?le(rt,be(ze)):null,St=J?/* @__PURE__ */ l(`ul`,{className:`pw-criteria`,"aria-live":`polite`,id:pt,"aria-label":Y?bt:void 0,children:xt?.map(e=>/* @__PURE__ */ u(`li`,{className:`pw-rule ${e.met?`met`:`unmet`}`,children:[/* @__PURE__ */ l(`span`,{className:`pw-mark`,"aria-hidden":`true`}),/* @__PURE__ */ l(`span`,{className:`pw-rule-text`,children:e.label}),/* @__PURE__ */ l(`span`,{className:`visually-hidden`,children:e.met?`: met`:`: not met`})]},e.key))}):null,$;if(M!==`off`&&m&&!U)$=/* @__PURE__ */ u(`div`,{className:M===`above`?`field-float wui-float-above`:`field-float`,children:[Z,/* @__PURE__ */ u(`label`,{className:`float-label`,htmlFor:H,children:[m,h&&/* @__PURE__ */ l(i,{})]})]});else if(Le)$=/* @__PURE__ */ u(`div`,{className:`input-action-row`,children:[/* @__PURE__ */ u(`div`,{className:x?`input-icon`:`input-wrap`,children:[x&&/* @__PURE__ */ l(`span`,{className:`ic`,children:/* @__PURE__ */ l(r,{name:x,size:16})}),Z]}),/* @__PURE__ */ l(`div`,{className:`input-action`,children:Le})]});else if(A||j)$=/* @__PURE__ */ u(`div`,{className:`input-affixed`,children:[A!=null&&/* @__PURE__ */ l(`span`,{className:`affix affix-pre`,children:A}),Z,j!=null&&/* @__PURE__ */ l(`span`,{className:`affix affix-suf`,children:j})]});else if(C)$=/* @__PURE__ */ u(`div`,{className:`input-with-unit`,children:[Z,/* @__PURE__ */ l(`span`,{className:`unit`,children:C})]});else if(U){let e=/* @__PURE__ */ u(`button`,{type:`button`,className:`pw-toggle${B?` pw-revealed`:``}`,onClick:()=>qe(e=>!e),"aria-label":B?Fe:Pe,tabIndex:-1,children:[/* @__PURE__ */ l(r,{name:`eye`,size:18,className:`pw-eye`}),/* @__PURE__ */ l(r,{name:`eye-off`,size:18,className:`pw-eye-off`})]}),t=M!==`off`&&m?/* @__PURE__ */ l(`div`,{className:M===`above`?`field-float wui-float-above`:`field-float`,children:/* @__PURE__ */ u(`div`,{className:`input-wrap`,children:[Z,e,/* @__PURE__ */ u(`label`,{className:`float-label`,htmlFor:H,children:[m,h&&/* @__PURE__ */ l(i,{})]})]})}):/* @__PURE__ */ u(`div`,{className:x?`input-icon`:`input-wrap`,children:[x&&/* @__PURE__ */ l(`span`,{className:`ic`,children:/* @__PURE__ */ l(r,{name:x,size:16})}),Z,e]});$=J&&!Y&&P!==`inline`?/* @__PURE__ */ l(ie,{trigger:t,triggerType:`focus`,placement:P,title:bt,className:`pw-popover`,children:St}):t}else $=S?/* @__PURE__ */ u(`div`,{className:`input-wrap`,children:[Z,/* @__PURE__ */ l(`button`,{type:`button`,className:`pw-toggle`,onClick:Te,disabled:!Te,tabIndex:-1,"aria-label":Ee||S,children:/* @__PURE__ */ l(r,{name:S,size:18})})]}):D?/* @__PURE__ */ u(`div`,{className:x?`input-icon`:`input-wrap`,children:[x&&/* @__PURE__ */ l(`span`,{className:`ic`,children:/* @__PURE__ */ l(r,{name:x,size:16})}),Z,ut]}):x?/* @__PURE__ */ u(`div`,{className:`input-icon`,children:[/* @__PURE__ */ l(`span`,{className:`ic`,children:/* @__PURE__ */ l(r,{name:x,size:16})}),Z]}):Z;return Ve?pe($,xe):/* @__PURE__ */ u(d.Group,{...xe,className:`field${w?` ${w}`:``}`,children:[m&&M===`off`&&/* @__PURE__ */ u(d.Label,{className:`label`,htmlFor:H,children:[m,g&&!h&&/* @__PURE__ */ l(`span`,{className:`label-optional`,children:` ${Me}`}),h&&/* @__PURE__ */ l(i,{}),v&&/* @__PURE__ */ l(re,{label:we,children:v})]}),$,Y&&/* @__PURE__ */ l(`div`,{className:`wui-pw-inline`,children:St}),/* @__PURE__ */ l(t,{error:V,hint:Y?null:_,errorId:dt,hintId:ft}),O&&/* @__PURE__ */ u(`div`,{className:`field-count${k&&et>=k?` at-limit`:``}`,children:[et,k?` / ${k}`:``]})]})});export{p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{linkBase as e,linkTarget as t,webRoute as n}from"../markdown-core/dist/links.js";import{parseInline as r}from"../markdown-core/dist/inline.js";import{parseMarkdown as i}from"../markdown-core/dist/parse.js";import{devWarn as a}from"../lib/devWarn.js";import o from"../lib/useElementEntry.js";import{splitMarkerProps as s}from"../lib/wuiMarker.js";import c from"./AppChip.js";import l from"./AppCodeBlock.js";import u from"./AppLink.js";import d from"./assertValidValue.js";import f from"./warnUnknownProps.js";import{Fragment as p,useMemo as m}from"react";import{jsx as h,jsxs as g}from"react/jsx-runtime";var _=()=>import(`@webority/ui-elements/elements/markdown`),v=[`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`css`],y=e=>v.some(t=>t===e),b=/* @__PURE__ */ new Set,
|
|
1
|
+
import{linkBase as e,linkTarget as t,webRoute as n}from"../markdown-core/dist/links.js";import{parseInline as r}from"../markdown-core/dist/inline.js";import{parseMarkdown as i}from"../markdown-core/dist/parse.js";import{devWarn as a}from"../lib/devWarn.js";import o from"../lib/useElementEntry.js";import{splitMarkerProps as s}from"../lib/wuiMarker.js";import c from"./AppChip.js";import l from"./AppCodeBlock.js";import u from"./AppLink.js";import d from"./assertValidValue.js";import f from"./warnUnknownProps.js";import{Fragment as p,useMemo as m}from"react";import{jsx as h,jsxs as g}from"react/jsx-runtime";var _=()=>import(`@webority/ui-elements/elements/markdown`),v=[`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`razor`,`css`],y=e=>v.some(t=>t===e),b=[`razor`,`cshtml`],x=e=>e!==null&&b.includes(e.toLowerCase())?`razor`:y(e)?e:`text`,S=/* @__PURE__ */ new Set,C=()=>{try{return process.env.NODE_ENV!==`production`}catch{return!0}};function w(e){C()&&!S.has(e)&&(S.add(e),a(`AppMarkdown ignores base="${e}": a base must be an https origin with no path, query, fragment or credentials.`))}function T(t){o(`wui-markdown`,_);let{marker:n,props:r}=s(`AppMarkdown`,t),{value:a,className:c=``,linkComponent:l,resolveLink:u,isCitation:p,figureText:g,onOpenCitation:v,links:y=`web`,headings:b=`outline`,base:x,...S}=r;f(`AppMarkdown`,S),d(`AppMarkdown`,`links`,y,[`app`,`web`,`page`]),d(`AppMarkdown`,`headings`,b,[`outline`,`text`]);let C=x==null?null:e(x);x!=null&&C===null&&w(x);let T=m(()=>i(a),[a]),E={links:y,headings:b,resolveLink:u,linkComponent:l,isCitation:p,figureText:g,onOpenCitation:v,base:C};return/* @__PURE__ */ h(`wui-markdown`,{class:[`wui-markdown`,c].filter(Boolean).join(` `),...n,...S,children:T.map(e=>/* @__PURE__ */ h(N,{block:e,options:E},e.key))})}function E({token:e,options:r}){let i=/* @__PURE__ */ h(D,{tokens:e.children,options:r}),a=t(e.href,r.links,r.resolveLink,globalThis.location?.origin,r.base);if(a?.kind===`app`){let e=n(a.target);if(e)return/* @__PURE__ */ h(u,{href:e,linkComponent:r.linkComponent,animation:`static`,children:i});let o=a.target;if(r.links!==`page`||typeof o!=`string`||!/^https?:\/\//i.test(o))return i;let s=t(o,`web`,void 0,globalThis.location?.origin)?.kind===`web`;return/* @__PURE__ */ h(u,{href:o,external:s,animation:`static`,children:i})}return a?.kind===`page`?/* @__PURE__ */ h(u,{href:a.href,linkComponent:r.linkComponent,animation:`static`,children:i}):a?.kind===`web`?/* @__PURE__ */ h(u,{href:a.href,external:!0,animation:`static`,children:i}):a?.kind===`contact`?/* @__PURE__ */ h(u,{href:a.href,animation:`static`,children:i}):i}function D({tokens:e,options:t}){return e.map(e=>{switch(e.type){case`code`:return/* @__PURE__ */ h(`code`,{children:e.text},e.key);case`strong`:return/* @__PURE__ */ h(`strong`,{children:/* @__PURE__ */ h(D,{tokens:e.children,options:t})},e.key);case`em`:return/* @__PURE__ */ h(`em`,{children:/* @__PURE__ */ h(D,{tokens:e.children,options:t})},e.key);case`strike`:return/* @__PURE__ */ h(`del`,{children:/* @__PURE__ */ h(D,{tokens:e.children,options:t})},e.key);case`image`:return/* @__PURE__ */ g(p,{children:[`[`,/* @__PURE__ */ h(D,{tokens:e.children,options:t}),`]`]},e.key);case`link`:return/* @__PURE__ */ h(E,{token:e,options:t},e.key);case`citation`:return/* @__PURE__ */ h(c,{label:e.text,size:`sm`,tone:`primary`,variant:`outline`,"aria-label":e.text,className:`wui-markdown-citation`,onClick:t.onOpenCitation?()=>t.onOpenCitation?.(e.text):void 0},e.key);case`text`:{if(!t.figureText)return/* @__PURE__ */ h(p,{children:e.text},e.key);let n=t.figureText(e.text).map((e,t)=>({key:`run-${t}`,...e}));return/* @__PURE__ */ h(p,{children:n.map(e=>{if(e.kind===`text`)return e.text;let t=e.kind===`sub`?`sub`:`sup`;return/* @__PURE__ */ h(t,{children:e.text},e.key)})},e.key)}default:{let t=e;return/* @__PURE__ */ h(p,{children:t.text},t.key)}}})}function O({text:e,options:t}){return/* @__PURE__ */ h(D,{tokens:r(e,{isCitation:t.isCitation}),options:t})}function k({lines:e,options:t}){return e.map((e,t)=>({key:`line-${t}`,text:e,position:t})).map(({key:e,text:n,position:r})=>/* @__PURE__ */ g(p,{children:[r>0&&/* @__PURE__ */ h(`br`,{}),/* @__PURE__ */ h(O,{text:n,options:t})]},e))}function A({block:e,options:t}){let n=e=>/* @__PURE__ */ h(O,{text:e,options:t}),r=e.header.map((e,t)=>({key:`column-${t}`,text:e})),i=e.rows.map((e,t)=>({key:`row-${t}`,cells:r.map((t,n)=>({key:t.key,text:e[n]??``}))}));return/* @__PURE__ */ h(`div`,{className:`table-responsive`,children:/* @__PURE__ */ g(`table`,{className:`table`,children:[/* @__PURE__ */ h(`thead`,{children:/* @__PURE__ */ h(`tr`,{children:r.map(e=>/* @__PURE__ */ h(`th`,{scope:`col`,children:n(e.text)},e.key))})}),/* @__PURE__ */ h(`tbody`,{children:i.map(e=>/* @__PURE__ */ h(`tr`,{children:e.cells.map(e=>/* @__PURE__ */ h(`td`,{children:n(e.text)},e.key))},e.key))})]})})}function j(e,t,n){let{items:r}=e,i=r[t];if(i===void 0)throw Error(`AppMarkdown list run starts past the last item`);let{depth:a,ordered:o,number:s}=i,c=[],l=t;for(;l<r.length;){let t=r[l];if(t===void 0||t.depth<a)break;if(t.depth>a){let t=j(e,l,n),r=c[c.length-1];if(!r)throw Error(`AppMarkdown list ${e.key} has a nested item with no item above it to nest under.`);r.nested=t.node,l=t.next}else c.push({item:t,index:l,nested:null}),l+=1}let u=c.map(({item:t,index:r,nested:i})=>/* @__PURE__ */ g(`li`,{children:[/* @__PURE__ */ h(O,{text:t.text,options:n}),i]},`${e.key}-${r}`));return{node:o?/* @__PURE__ */ h(`ol`,{start:o&&s!==1?s:void 0,children:u},`${e.key}-${t}`):/* @__PURE__ */ h(`ul`,{children:u},`${e.key}-${t}`),next:l}}function M(e,t){let n=[],r=0;for(;r<e.items.length;){let i=j(e,r,t);n.push(i.node),r=i.next}return n}function N({block:e,options:t}){switch(e.type){case`paragraph`:return/* @__PURE__ */ h(`p`,{children:/* @__PURE__ */ h(k,{lines:e.lines,options:t})});case`quote`:return/* @__PURE__ */ h(`blockquote`,{children:/* @__PURE__ */ h(k,{lines:e.lines,options:t})});case`heading`:{let n=/* @__PURE__ */ h(O,{text:e.text,options:t});return t.headings===`text`?/* @__PURE__ */ h(`p`,{className:`fw-semibold`,children:n}):/* @__PURE__ */ h(`h2`,{children:n})}case`list`:return M(e,t);case`table`:return/* @__PURE__ */ h(A,{block:e,options:t});case`code`:return/* @__PURE__ */ h(l,{code:e.text,language:x(e.language)});case`rule`:return/* @__PURE__ */ h(`hr`,{});default:return null}}export{T as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../lib/FieldMessage.js";import{FIELD_SIZES as t}from"../lib/fieldState.js";import n from"../lib/useElementEntry.js";import{splitMarkerProps as
|
|
1
|
+
import e from"../lib/FieldMessage.js";import{FIELD_SIZES as t}from"../lib/fieldState.js";import{useFieldError as n}from"../lib/formFields.js";import r from"../lib/useElementEntry.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./AppInfoTip.js";import o from"./AppRequiredMark.js";import ee from"./assertValidValue.js";import s from"./useWuiControl.js";import c from"./warnUnknownProps.js";import{forwardRef as l,useEffect as u,useId as d,useRef as f}from"react";import{jsx as p,jsxs as m}from"react/jsx-runtime";var h=()=>import(`@webority/ui-elements/elements/mention-input`),te=e=>typeof e==`object`&&!!e&&`query`in e&&typeof e.query==`string`,g=l(function(l,g){let _=r(`wui-mention-input`,h),{marker:v,props:y}=i(`AppMentionInput`,l),{value:b,defaultValue:x,onChange:S,people:C,loadPeople:w,minChars:T,debounce:E,onSubmit:D,rows:O=3,placeholder:k,disabled:A=!1,readOnly:j=!1,loading:M=!1,size:N=`md`,name:P,id:F,label:I,error:L,helperText:R,required:z=!1,help:B,helpLabel:V=`More information`,className:H=``,fieldClassName:U=``,...W}=y,G=n(P),K=L??G;c(`AppMentionInput`,W),ee(`AppMentionInput`,`size`,N,t);let q=typeof w==`function`,J=d(),Y=F||`mention-${J.replace(/[^a-zA-Z0-9_-]/g,``)}`,X=K?`${Y}-error`:R?`${Y}-hint`:void 0,Z=f(M),Q=f(!1),{setRef:ne,innerRef:$}=s({ready:_,ref:g,value:b??(x===void 0?``:void 0),defaultValue:x,on:{change:e=>{let t=$.current;if(e.target===e.currentTarget&&t){if(typeof t.value!=`string`||!Array.isArray(t.mentions))throw TypeError(`<wui-mention-input> reported a change without its value and mentions.`);S?.(t.value,{mentions:t.mentions})}},"wui:mention-input:submit":()=>D?.()}});return u(()=>{let e=$.current;e&&_&&!q&&(e.people=C||[])},[C,q,_,$]),u(()=>{Z.current=M;let e=$.current;e&&_&&!Q.current&&(e.loading=M)},[M,_,$]),u(()=>{let e=$.current;if(!e||!_||!q)return;let t=0,n=null,r=async r=>{if(!(r instanceof CustomEvent))throw TypeError(`<wui-mention-input> search arrived without its query.`);let i=r.detail;if(!te(i))throw TypeError(`<wui-mention-input> search arrived without its query.`);let a=i.query,o=++t;n?.abort(),n=typeof AbortController==`function`?new AbortController:null,Q.current=!0,e.loading=!0;try{let r=await w(a,{signal:n?.signal});o===t&&(e.people=r||[])}catch(r){if((r instanceof DOMException||r instanceof Error)&&r.name===`AbortError`)return;o===t&&(e.people=[],e.searchFailed=!0,n?.signal.aborted||reportError(r))}finally{o===t&&(Q.current=!1,e.loading=Z.current)}};return e.addEventListener(`search`,r),()=>{t=-1,n?.abort(),e.removeEventListener(`search`,r),Q.current=!1,e.loading=Z.current}},[q,w,_,$]),/* @__PURE__ */ m(`div`,{...v,className:`field${U?` ${U}`:``}`,children:[I&&/* @__PURE__ */ m(`label`,{className:`label`,htmlFor:`${Y}-text`,children:[I,z&&/* @__PURE__ */ p(o,{}),B&&/* @__PURE__ */ p(a,{label:V,children:B})]}),/* @__PURE__ */ p(`wui-mention-input`,{ref:ne,id:Y,class:H?`wui-mention-input ${H}`:`wui-mention-input`,label:typeof I==`string`?I:void 0,placeholder:k||void 0,rows:String(O),name:P||void 0,remote:q?``:void 0,"min-chars":T==null?void 0:String(T),debounce:E==null?void 0:String(E),disabled:A?``:void 0,readonly:j?``:void 0,loading:M?``:void 0,size:N===`md`?void 0:N,"aria-describedby":X,"aria-invalid":K?`true`:void 0,...W}),/* @__PURE__ */ p(e,{error:K,hint:R,errorId:`${Y}-error`,hintId:`${Y}-hint`})]})});export{g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{linkTarget as e}from"../lib/linkTarget.js";import{TargetLink as t}from"../lib/TargetLink.js";import{TONES as n}from"../lib/vocabulary.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./assertValidValue.js";import a from"./warnUnknownProps.js";import{Fragment as o,jsx as s,jsxs as c}from"react/jsx-runtime";var l=[3,4,5],u=[`sm`,`md`],d=n.filter(e=>e!==`primary`);function f(n){let{marker:f,props:p}=r(`AppMetricStrip`,n),{items:m=[],columns:h=4,size:g=`md`,
|
|
1
|
+
import{linkTarget as e}from"../lib/linkTarget.js";import{TargetLink as t}from"../lib/TargetLink.js";import{TONES as n}from"../lib/vocabulary.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./assertValidValue.js";import a from"./warnUnknownProps.js";import{Fragment as o,jsx as s,jsxs as c}from"react/jsx-runtime";var l=[3,4,5],u=[`sm`,`md`],d=n.filter(e=>e!==`primary`);function f(n){let{marker:f,props:p}=r(`AppMetricStrip`,n),{items:m=[],columns:h=4,size:g=`md`,divided:_=!1,linkComponent:v,className:y=``,...b}=p;a(`AppMetricStrip`,b),i(`AppMetricStrip`,`columns`,h,l),i(`AppMetricStrip`,`size`,g,u);let x=[`wui-metric-strip`,`wui-metric-strip-cols-${h}`,g===`sm`?`wui-metric-strip-sm`:``,_?`wui-metric-strip-divided`:``,y].filter(Boolean).join(` `);return/* @__PURE__ */ s(`div`,{className:x,...f,...b,children:m.map((n,r)=>{i(`AppMetricStrip`,`tone`,n.tone,d);let a=`wui-metric${n.tone&&n.tone!==`neutral`?` wui-metric-tone-${n.tone}`:``}`,l=/* @__PURE__ */ c(o,{children:[/* @__PURE__ */ s(`div`,{className:`wui-metric-label`,children:n.label}),/* @__PURE__ */ s(`div`,{className:`wui-metric-value`,children:n.value}),n.note&&/* @__PURE__ */ s(`div`,{className:`wui-metric-note`,children:n.note})]}),u=`${n.label}-${r}`,f=e(v,{href:n.href});return n.href?/* @__PURE__ */ s(t,{link:f,className:a,children:l},u):/* @__PURE__ */ s(`div`,{className:a,children:l},u)})})}export{f as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../lib/DiscardPrompt.js";import{devWarn as t}from"../lib/devWarn.js";import
|
|
1
|
+
import e from"../lib/DiscardPrompt.js";import{devWarn as t}from"../lib/devWarn.js";import n from"../lib/useElementEntry.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppIcon.js";import a from"./assertValidValue.js";import ee from"./warnUnknownProps.js";import{useCallback as o,useEffect as s,useRef as c,useState as l}from"react";import{createPortal as u}from"react-dom";import{jsx as d,jsxs as f}from"react/jsx-runtime";var p=[`neutral`,`danger`,`success`,`warning`],m=[`center`,`top`],te=[`sans`,`serif`],ne=()=>import(`@webority/ui-elements/elements/modal`),h={sm:380,md:440,lg:640,xl:880},re=`wui-modal-fullscreen`,ie=e=>typeof e==`number`?e:e===`fullscreen`?h.md:h[e],g=!1;function _(){let e=!0;try{e=process.env.NODE_ENV!==`production`}catch{e=!0}e&&!g&&(g=!0,t("[@webority/ui-react] <AppModal hideHeader> has no accessible name: pass `ariaLabel` (or a string `title`)."))}function v(t){n(`wui-modal`,ne);let{marker:g,props:v}=r(`AppModal`,t),{open:y,eyebrow:b,title:x,subtitle:S,headerIcon:C,tone:w=`neutral`,dismissible:ae=!0,onClose:T,onBack:E,backLabel:D=`Back`,headerActions:O,footer:k,size:A=`md`,placement:j=`center`,titleFont:M=`sans`,hideHeader:N=!1,staticBackdrop:oe=!0,closeOnEscape:se=!0,confirmDiscard:P,dirty:ce=!1,ariaLabel:F,closeLabel:le=`Close`,className:I=``,children:L,...R}=v;ee(`AppModal`,R),a(`AppModal`,`tone`,w,p),a(`AppModal`,`placement`,j,m),a(`AppModal`,`titleFont`,M,te),a(`AppModal`,`size`,typeof A==`string`?A:null,[...Object.keys(h),`fullscreen`]);let{style:z,ref:B,onExited:V,"data-wui":H,"data-wui-props":U,...ue}=R,W=H?{"data-wui":H,"data-wui-props":U}:g,de=W[`data-wui`],fe=W[`data-wui-props`];N&&!F&&typeof x!=`string`&&_();let G=c(null),K=c(null),[pe,q]=l(y),me=y||pe;s(()=>{y&&q(!0)},[y]);let J=c(null),[Y,X]=l(!1);s(()=>{y||X(!1)},[y]),s(()=>{Y&&J.current?.focus()},[Y]);let he=o(e=>{K.current=e,typeof B==`function`?B(e):B&&(B.current=e)},[B]),ge=()=>{P&&ce?X(!0):T?.()},Z=c({open:y,requestClose:()=>{},onExited:V});Z.current={open:y,requestClose:ge,onExited:V};let _e=o(e=>{if(!e)return;let t=t=>t.target instanceof Element&&t.target.closest(`wui-modal`)===e,n=e=>{t(e)&&(e.preventDefault(),Z.current.requestClose())},r=e=>{if(!t(e))return;Z.current.open||q(!1);let n=K.current;if(!n)throw TypeError(`<wui-modal> closed without its dialog.`);Z.current.onExited?.(n)};return e.addEventListener(`wui-modal-close`,n),e.addEventListener(`wui-modal-closed`,r),()=>{e.removeEventListener(`wui-modal-close`,n),e.removeEventListener(`wui-modal-closed`,r)}},[]),Q=()=>{X(!1),T?.()},ve=()=>{X(!1),(G.current?.querySelector(`input:not([type="hidden"]):not([disabled]),select:not([disabled]),textarea:not([disabled])`))?.focus()},$=A===`fullscreen`,ye=ie(A),be=[`modal-content`,`wui-modal`,w===`neutral`?``:`tone-${w}`,I].filter(Boolean).join(` `),xe=[`modal`,`wui-modal-shell`,$&&re].filter(Boolean).join(` `),Se=[`modal-dialog`,j!==`top`&&`modal-dialog-centered`,`wui-rb-dialog`].filter(Boolean).join(` `),Ce=$?z:{"--wui-modal-max-width":`${ye}px`,...z};return!me||typeof document>`u`?null:u(/* @__PURE__ */ d(`wui-modal`,{ref:_e,"data-wui":de,"data-wui-props":fe,open:y?``:void 0,static:oe?``:void 0,"no-escape":se&&!Y?void 0:``,"confirm-discard":P||void 0,children:/* @__PURE__ */ d(`dialog`,{...ue,ref:he,className:xe,"aria-label":F||(typeof x==`string`?x:void 0),style:Ce,children:/* @__PURE__ */ d(`div`,{className:Se,children:/* @__PURE__ */ f(`div`,{className:be,children:[!N&&/* @__PURE__ */ f(`div`,{className:`wui-modal-header`,children:[E&&/* @__PURE__ */ d(`button`,{type:`button`,className:`wui-modal-back`,onClick:E,"aria-label":D,children:/* @__PURE__ */ d(i,{name:`arrow-left`,size:18})}),/* @__PURE__ */ f(`div`,{className:`wui-modal-heading`,children:[C&&/* @__PURE__ */ d(`span`,{className:`wui-modal-headicon`,children:/* @__PURE__ */ d(i,{name:C,size:18})}),/* @__PURE__ */ f(`div`,{className:`wui-modal-headtext`,children:[b&&/* @__PURE__ */ d(`div`,{className:`wui-modal-eyebrow`,children:b}),/* @__PURE__ */ d(`div`,{className:M===`serif`?`wui-modal-title wui-modal-title-serif`:`wui-modal-title`,children:x}),S&&/* @__PURE__ */ d(`div`,{className:`wui-modal-subtitle`,children:S})]})]}),O&&/* @__PURE__ */ d(`div`,{className:`wui-modal-header-actions`,children:O}),ae&&/* @__PURE__ */ d(`button`,{type:`button`,className:`wui-modal-close`,"data-wui-dismiss":``,"aria-label":le,children:/* @__PURE__ */ d(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:/* @__PURE__ */ d(`path`,{d:`M18 6 6 18M6 6l12 12`})})})]}),/* @__PURE__ */ d(`div`,{className:`wui-modal-body`,ref:G,children:L}),(k||Y)&&/* @__PURE__ */ f(`div`,{className:Y?`wui-modal-footer wui-drawer-discarding`:`wui-modal-footer`,children:[Y&&/* @__PURE__ */ d(e,{text:P,confirmRef:J,onDiscard:Q,onKeep:ve}),k]})]})})})}),document.body)}export{v as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{linkTarget as e}from"../lib/linkTarget.js";import{TargetLink as t}from"../lib/TargetLink.js";import n from"../lib/useElementEntry.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppIcon.js";import a from"./AppTabs.js";import o from"./assertValidValue.js";import s from"./warnUnknownProps.js";import{NOTIFICATION_TEXT as c,groupNotificationsByDay as l,notificationCountText as u,notificationTime as d,notificationTriggerLabel as f,notificationUnreadAnnouncement as p}from"@webority/ui-elements/helpers";import{useEffect as m,useId as h,useLayoutEffect as g,useRef as _,useState as v}from"react";import{Fragment as y,jsx as b,jsxs as x}from"react/jsx-runtime";var S=[`all`,`unread`,`archived`],C={all:`All`,unread:`Unread`,archived:`Archived`},w=`a, button, input, select, textarea`,T=()=>import(`@webority/ui-elements/elements/notification-center`);function E(e){n(`wui-notification-center`,T);let{marker:t,props:o}=r(`AppNotificationCenter`,e),{items:d,unread:y,label:S=c.label,emptyText:C=c.empty,viewAllHref:w,defaultOpen:E=!1,now:A,onMarkAllRead:M,onItemClick:N,renderItem:P,tabs:F,onTabChange:I,onOpenChange:L,linkComponent:R,className:z=``,...B}=o;if(s(`AppNotificationCenter`,B),!Array.isArray(d))throw Error(`<AppNotificationCenter> items is required: pass the notifications, newest first.`);let V=D(F),[H,U]=v(V[0]?.key),W=V.some(e=>e.key===H)?H:V[0]?.key,G=e=>{e!==W&&(U(e),I?.(e))},K=h(),q=h(),J=_(null),Y=_(L);Y.current=L,m(()=>{let e=J.current;if(!e)return;let t=e=>{if(!(e instanceof CustomEvent))throw Error(`wui:notification-center:toggle carried no CustomEvent`);let t=e.detail;if(typeof t!=`object`||!t||!(`open`in t))throw Error(`wui:notification-center:toggle carried no open flag in its detail`);Y.current?.(!!t.open)};return e.addEventListener(`wui:notification-center:toggle`,t),()=>e.removeEventListener(`wui:notification-center:toggle`,t)},[]);let X=_(E);g(()=>{if(!X.current)return;let e=J.current;e&&(e.setAttribute(`open`,``),e.querySelector(`.wui-notification-center-trigger`)?.setAttribute(`aria-expanded`,`true`))},[]);let Z=y??d.filter(e=>!e.read&&!e.archived).length,[ee,te]=v(``),Q=_(Z);m(()=>{Q.current!==Z&&(Q.current=Z,te(p(Z)))},[Z]);let $=l(V.length>0?O(d,W):d,A),ne=[`wui-notification-center`,z].filter(Boolean).join(` `);return/* @__PURE__ */ x(`wui-notification-center`,{ref:J,class:ne,label:S,controlled:``,...t,...B,children:[/* @__PURE__ */ x(`button`,{type:`button`,className:`topbar-icon-btn wui-notification-center-trigger`,"aria-expanded":X.current?`true`:`false`,"aria-controls":K,"aria-haspopup":`dialog`,"aria-label":f(S,Z),children:[/* @__PURE__ */ b(i,{name:`notification`,size:20}),/* @__PURE__ */ b(`span`,{className:`wui-notification-center-count`,"aria-hidden":`true`,hidden:Z===0,children:u(Z)})]}),/* @__PURE__ */ b(`span`,{className:`visually-hidden wui-notification-center-live`,"aria-live":`polite`,children:ee}),/* @__PURE__ */ x(`div`,{className:`wui-notification-center-panel`,id:K,role:`dialog`,"aria-labelledby":q,tabIndex:-1,children:[/* @__PURE__ */ x(`div`,{className:`wui-notification-center-head`,children:[/* @__PURE__ */ b(`h2`,{className:`wui-notification-center-title`,id:q,children:S}),M&&/* @__PURE__ */ b(`button`,{type:`button`,className:`wui-notification-center-markall`,disabled:Z===0,onClick:M,children:c.markAll})]}),W!==void 0&&/* @__PURE__ */ b(`div`,{className:`wui-notification-center-tabs`,children:/* @__PURE__ */ b(a,{tabs:V,value:W,onChange:G,size:`sm`,fitted:!0,ariaLabel:S})}),$.length===0?/* @__PURE__ */ b(`p`,{className:`wui-notification-center-empty`,children:C}):/* @__PURE__ */ b(`div`,{className:`wui-notification-center-list`,children:$.map(e=>/* @__PURE__ */ x(`section`,{"aria-labelledby":`${K}-${e.key}`,children:[/* @__PURE__ */ b(`h3`,{className:`wui-notification-center-day`,id:`${K}-${e.key}`,children:e.heading}),/* @__PURE__ */ b(`ul`,{className:`wui-notification-center-items`,children:e.items.map(e=>/* @__PURE__ */ b(`li`,{children:/* @__PURE__ */ b(j,{item:e,onItemClick:N,renderItem:P,linkComponent:R})},e.id))})]},e.key))}),w&&/* @__PURE__ */ b(k,{href:w,linkComponent:R})]})]})}function D(e){return e===!0?S.map(e=>({key:e,label:C[e]})):Array.isArray(e)?e.map(e=>(o(`AppNotificationCenter`,`tabs[].key`,e.key,S),{key:e.key,label:e.label??C[e.key]})):[]}function O(e,t){if(t===`archived`)return e.filter(e=>e.archived);let n=e.filter(e=>!e.archived);return t===`unread`?n.filter(e=>!e.read):n}function k({href:n,linkComponent:r}){let i=e(r,{href:n}),a=i.Tag===`a`?void 0:e=>A(e.currentTarget);return/* @__PURE__ */ b(t,{link:i,className:`wui-notification-center-foot`,onClick:a,children:c.viewAll})}function A(e){e.closest(`wui-notification-center`)?.close?.()}function j({item:n,onItemClick:r,renderItem:a,linkComponent:o}){let s=`wui-notification-center-item${n.read?` wui-notification-center-item-read`:``}`,l=!n.read&&/* @__PURE__ */ b(`span`,{className:`visually-hidden wui-notification-center-unread-label`,children:c.unreadPrefix}),u=/* @__PURE__ */ b(`span`,{className:`wui-notification-center-dot`,"aria-hidden":`true`});if(a){let e=r?e=>{let t=e.target;t instanceof Element&&!t.closest(w)&&r(n,e)}:void 0;return/* @__PURE__ */ x(`div`,{className:s,"data-id":n.id,tabIndex:-1,onClick:e,children:[u,/* @__PURE__ */ x(`span`,{className:`wui-notification-center-body`,children:[l,a(n)]})]})}let f=d(n.at),p=/* @__PURE__ */ x(y,{children:[u,n.icon&&/* @__PURE__ */ b(`span`,{className:`wui-notification-center-icon`,children:/* @__PURE__ */ b(i,{name:n.icon,size:18})}),/* @__PURE__ */ x(`span`,{className:`wui-notification-center-body`,children:[l,/* @__PURE__ */ b(`span`,{className:`wui-notification-center-item-title`,children:n.title}),n.text&&/* @__PURE__ */ b(`span`,{className:`wui-notification-center-item-text`,children:n.text}),f&&/* @__PURE__ */ b(`time`,{className:`wui-notification-center-when`,dateTime:String(n.at),children:f})]})]}),m=r?e=>r(n,e):void 0;if(n.href){let i=e(o,{href:n.href});return/* @__PURE__ */ b(t,{link:i,className:s,"data-id":n.id,onClick:e=>{r?.(n,e),i.Tag!==`a`&&A(e.currentTarget)},children:p})}return/* @__PURE__ */ b(`button`,{type:`button`,className:s,"data-id":n.id,onClick:m,children:p})}export{E as default};
|
|
1
|
+
import{linkTarget as e}from"../lib/linkTarget.js";import{TargetLink as t}from"../lib/TargetLink.js";import n from"../lib/useElementEntry.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppIcon.js";import a from"./AppTabs.js";import o from"./assertValidValue.js";import s from"./warnUnknownProps.js";import{NOTIFICATION_TEXT as c,groupNotificationsByDay as l,notificationCountText as u,notificationTime as d,notificationTriggerLabel as f,notificationUnreadAnnouncement as p}from"@webority/ui-elements/helpers";import{useEffect as m,useId as h,useLayoutEffect as g,useRef as _,useState as v}from"react";import{Fragment as y,jsx as b,jsxs as x}from"react/jsx-runtime";var S=[`all`,`unread`,`archived`],C={all:`All`,unread:`Unread`,archived:`Archived`},w=`a, button, input, select, textarea`,T=()=>import(`@webority/ui-elements/elements/notification-center`);function E(e){n(`wui-notification-center`,T);let{marker:t,props:o}=r(`AppNotificationCenter`,e),{items:d,unread:y,label:S=c.label,emptyText:C=c.empty,viewAllHref:w,defaultOpen:E=!1,now:A,onMarkAllRead:M,onItemClick:N,renderItem:P,tabs:F,onTabChange:I,onOpenChange:L,linkComponent:R,className:z=``,...B}=o;if(s(`AppNotificationCenter`,B),!Array.isArray(d))throw Error(`<AppNotificationCenter> items is required: pass the notifications, newest first.`);let V=D(F),[H,U]=v(V[0]?.key),W=V.some(e=>e.key===H)?H:V[0]?.key,G=e=>{e!==W&&(U(e),I?.(e))},K=h(),q=h(),J=_(null),Y=_(L);Y.current=L,m(()=>{let e=J.current;if(!e)return;let t=e=>{if(!(e instanceof CustomEvent))throw Error(`wui:notification-center:toggle carried no CustomEvent`);let t=e.detail;if(typeof t!=`object`||!t||!(`open`in t))throw Error(`wui:notification-center:toggle carried no open flag in its detail`);Y.current?.(!!t.open)};return e.addEventListener(`wui:notification-center:toggle`,t),()=>e.removeEventListener(`wui:notification-center:toggle`,t)},[]);let X=_(E);g(()=>{if(!X.current)return;let e=J.current;e&&(e.setAttribute(`open`,``),e.querySelector(`.wui-notification-center-trigger`)?.setAttribute(`aria-expanded`,`true`))},[]);let Z=y??d.filter(e=>!e.read&&!e.archived).length,[ee,te]=v(``),Q=_(Z);m(()=>{Q.current!==Z&&(Q.current=Z,te(p(Z)))},[Z]);let $=l(V.length>0?O(d,W):d,A),ne=[`wui-notification-center`,z].filter(Boolean).join(` `);return/* @__PURE__ */ x(`wui-notification-center`,{ref:J,class:ne,label:S,controlled:``,...t,...B,children:[/* @__PURE__ */ x(`button`,{type:`button`,className:`topbar-icon-btn wui-notification-center-trigger`,"aria-expanded":X.current?`true`:`false`,"aria-controls":K,"aria-haspopup":`dialog`,"aria-label":f(S,Z),children:[/* @__PURE__ */ b(i,{name:`notification`,size:20}),/* @__PURE__ */ b(`span`,{className:`wui-notification-center-count`,"aria-hidden":`true`,hidden:Z===0,children:u(Z)})]}),/* @__PURE__ */ b(`span`,{className:`visually-hidden wui-notification-center-live`,"aria-live":`polite`,children:ee}),/* @__PURE__ */ x(`div`,{className:`wui-notification-center-panel`,popover:`auto`,id:K,role:`dialog`,"aria-labelledby":q,tabIndex:-1,children:[/* @__PURE__ */ x(`div`,{className:`wui-notification-center-head`,children:[/* @__PURE__ */ b(`h2`,{className:`wui-notification-center-title`,id:q,children:S}),M&&/* @__PURE__ */ b(`button`,{type:`button`,className:`wui-notification-center-markall`,disabled:Z===0,onClick:M,children:c.markAll})]}),W!==void 0&&/* @__PURE__ */ b(`div`,{className:`wui-notification-center-tabs`,children:/* @__PURE__ */ b(a,{tabs:V,value:W,onChange:G,size:`sm`,fitted:!0,ariaLabel:S})}),$.length===0?/* @__PURE__ */ b(`p`,{className:`wui-notification-center-empty`,children:C}):/* @__PURE__ */ b(`div`,{className:`wui-notification-center-list`,children:$.map(e=>/* @__PURE__ */ x(`section`,{"aria-labelledby":`${K}-${e.key}`,children:[/* @__PURE__ */ b(`h3`,{className:`wui-notification-center-day`,id:`${K}-${e.key}`,children:e.heading}),/* @__PURE__ */ b(`ul`,{className:`wui-notification-center-items`,children:e.items.map(e=>/* @__PURE__ */ b(`li`,{children:/* @__PURE__ */ b(j,{item:e,onItemClick:N,renderItem:P,linkComponent:R})},e.id))})]},e.key))}),w&&/* @__PURE__ */ b(k,{href:w,linkComponent:R})]})]})}function D(e){return e===!0?S.map(e=>({key:e,label:C[e]})):Array.isArray(e)?e.map(e=>(o(`AppNotificationCenter`,`tabs[].key`,e.key,S),{key:e.key,label:e.label??C[e.key]})):[]}function O(e,t){if(t===`archived`)return e.filter(e=>e.archived);let n=e.filter(e=>!e.archived);return t===`unread`?n.filter(e=>!e.read):n}function k({href:n,linkComponent:r}){let i=e(r,{href:n}),a=i.Tag===`a`?void 0:e=>A(e.currentTarget);return/* @__PURE__ */ b(t,{link:i,className:`wui-notification-center-foot`,onClick:a,children:c.viewAll})}function A(e){e.closest(`wui-notification-center`)?.close?.()}function j({item:n,onItemClick:r,renderItem:a,linkComponent:o}){let s=`wui-notification-center-item${n.read?` wui-notification-center-item-read`:``}`,l=!n.read&&/* @__PURE__ */ b(`span`,{className:`visually-hidden wui-notification-center-unread-label`,children:c.unreadPrefix}),u=/* @__PURE__ */ b(`span`,{className:`wui-notification-center-dot`,"aria-hidden":`true`});if(a){let e=r?e=>{let t=e.target;t instanceof Element&&!t.closest(w)&&r(n,e)}:void 0;return/* @__PURE__ */ x(`div`,{className:s,"data-id":n.id,tabIndex:-1,onClick:e,children:[u,/* @__PURE__ */ x(`span`,{className:`wui-notification-center-body`,children:[l,a(n)]})]})}let f=d(n.at),p=/* @__PURE__ */ x(y,{children:[u,n.icon&&/* @__PURE__ */ b(`span`,{className:`wui-notification-center-icon`,children:/* @__PURE__ */ b(i,{name:n.icon,size:18})}),/* @__PURE__ */ x(`span`,{className:`wui-notification-center-body`,children:[l,/* @__PURE__ */ b(`span`,{className:`wui-notification-center-item-title`,children:n.title}),n.text&&/* @__PURE__ */ b(`span`,{className:`wui-notification-center-item-text`,children:n.text}),f&&/* @__PURE__ */ b(`time`,{className:`wui-notification-center-when`,dateTime:String(n.at),children:f})]})]}),m=r?e=>r(n,e):void 0;if(n.href){let i=e(o,{href:n.href});return/* @__PURE__ */ b(t,{link:i,className:s,"data-id":n.id,onClick:e=>{r?.(n,e),i.Tag!==`a`&&A(e.currentTarget)},children:p})}return/* @__PURE__ */ b(`button`,{type:`button`,className:s,"data-id":n.id,onClick:m,children:p})}export{E as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../lib/FieldMessage.js";import{FIELD_BUSY_CLASS as t}from"../lib/fieldState.js";import{
|
|
1
|
+
import e from"../lib/FieldMessage.js";import{FIELD_BUSY_CLASS as t}from"../lib/fieldState.js";import{useFieldError as n}from"../lib/formFields.js";import{groupIndianText as r}from"../lib/indianGrouping.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./AppIcon.js";import ee from"./AppInfoTip.js";import te from"./AppRequiredMark.js";import o from"./assertValidValue.js";import ne from"./warnUnknownProps.js";import{forwardRef as s,useCallback as re,useEffect as ie,useId as ae,useLayoutEffect as oe,useRef as c,useState as l}from"react";import{jsx as u,jsxs as d}from"react/jsx-runtime";import{Form as f}from"react-bootstrap";var se=[`sm`,`md`,`lg`],ce=[`none`,`indian`],p=e=>{if(e===``||e==null)return null;let t=parseFloat(e.replace(/,/g,``));return Number.isNaN(t)?null:t},m=(e,t)=>e.slice(0,t).replace(/\D/g,``).length,h=(e,t)=>{if(t<=0)return 0;let n=0;for(let r=0;r<e.length;r++)if(/\d/.test(e.charAt(r))&&++n===t)return r+1;return e.length},g=(e,t,n)=>{let i=t>0&&typeof e==`number`&&Number.isFinite(e)?e.toFixed(t):String(e??``);return n===`indian`?r(i):i},_=s(function(s,_){let{marker:le,props:ue}=i(`AppNumberInput`,s),{label:v,required:y=!1,optional:de=!1,error:fe,helperText:b,help:x,helpLabel:pe=`More information`,decreaseLabel:me=`Decrease`,increaseLabel:he=`Increase`,optionalLabel:ge=`(optional)`,value:S,onChange:C,min:w,max:T,step:_e=1,precision:E=0,grouping:D=`none`,unit:O,size:k=`md`,id:ve,name:A,className:ye=``,fieldClassName:j=``,disabled:M=!1,readOnly:N=!1,loading:P=!1,defaultValue:F,...I}=ue,be=n(A),L=fe??be,R=N||P;ne(`AppNumberInput`,I),o(`AppNumberInput`,`size`,k,se),o(`AppNumberInput`,`grouping`,D,ce);let xe=ae(),z=ve||xe,B=e=>{if(E===0)return Math.round(e);let t=10**E;return Math.round(e*t)/t},V=e=>{let t=e;return typeof w==`number`&&(t=Math.max(t,w)),typeof T==`number`&&(t=Math.min(t,T)),t},H=e=>g(e,E,D),[U,W]=l(()=>H(S??F)),G=c(D);ie(()=>{let e=S??F,t=G.current!==D;G.current=D,W(n=>!t&&p(n)===(e??null)?n:g(t&&S===void 0?p(n):e,E,D))},[S,F,E,D]);let K=c(null),q=c(null),[,Se]=l(0),Ce=re(e=>{K.current=e,typeof _==`function`?_(e):_&&(_.current=e)},[_]);oe(()=>{let e=q.current,t=K.current;if(e===null||t===null)return;q.current=null;let n=h(U,e);t.setSelectionRange(n,n)});let J=e=>{let t=(p(U)??V(0))+e*_e,n=V(B(t));W(H(n)),C?.(n)},Y=p(U),we=M||N||P||Y!==null&&typeof w==`number`&&Y<=w,Te=M||N||P||Y!==null&&typeof T==`number`&&Y>=T,X=L&&z?`${z}-error`:void 0,Z=b&&z?`${z}-hint`:void 0,Ee=X||Z,De=[`input`,k===`sm`?`input-sm`:``,k===`lg`?`input-lg`:``,L?`error`:``,`num-input`,ye,P?t:``].filter(Boolean).join(` `),Q=RegExp(`^${typeof w==`number`&&w>=0?``:`-?`}\\d*${E>0?`(\\.\\d*)?`:``}$`),$=(e,t)=>{let n=D===`indian`?e.replace(/,/g,``):e;if(!Q.test(n))return;let i=D===`indian`?r(n):n;if(i!==e&&i===U){let e=h(i,t);queueMicrotask(()=>K.current?.setSelectionRange(e,e))}else i!==e&&(q.current=t,Se(e=>e+1));W(i);let a=p(n);a!==null&&C?.(a)},Oe=e=>{let t=e.target.value;$(t,m(t,e.target.selectionStart??t.length))},ke=e=>{if(R){I.onBlur?.(e);return}let t=p(e.target.value);if(t===null)W(``),C?.(null);else{let e=V(B(t));W(H(e)),C?.(e)}I.onBlur?.(e)},Ae=e=>{if(R)I.onKeyDown?.(e);else{if(D===`indian`&&(e.key===`Backspace`||e.key===`Delete`)){let t=e.currentTarget.value,n=e.currentTarget.selectionStart;if(n!==null&&e.currentTarget.selectionEnd===n){let r=e.key===`Backspace`?n-1:n,i=e.key===`Backspace`?n-2:n+1;i>=0&&t.charAt(r)===`,`&&/\d/.test(t.charAt(i))&&(e.preventDefault(),$(t.slice(0,i)+t.slice(i+1),m(t,i)))}}e.key===`ArrowUp`?(e.preventDefault(),J(1)):e.key===`ArrowDown`&&(e.preventDefault(),J(-1)),I.onKeyDown?.(e)}},je=/* @__PURE__ */ u(f.Control,{...I,id:z,name:D===`indian`?void 0:A,type:`text`,inputMode:E>0?`decimal`:`numeric`,className:De,disabled:M,readOnly:R,"aria-busy":P||void 0,required:y,"aria-invalid":L?`true`:`false`,"aria-describedby":Ee,value:U,ref:Ce,onChange:Oe,onBlur:ke,onKeyDown:Ae}),Me=[`num-wrap`,k===`sm`?`num-wrap-sm`:``,k===`lg`?`num-wrap-lg`:``].filter(Boolean).join(` `),Ne=/* @__PURE__ */ d(`div`,{className:Me,children:[/* @__PURE__ */ u(`button`,{type:`button`,className:`num-btn`,"aria-label":me,tabIndex:-1,disabled:we,onClick:()=>J(-1),children:/* @__PURE__ */ u(a,{name:`minus`,size:16})}),je,O&&/* @__PURE__ */ u(`span`,{className:`affix`,children:O}),/* @__PURE__ */ u(`button`,{type:`button`,className:`num-btn`,"aria-label":he,tabIndex:-1,disabled:Te,onClick:()=>J(1),children:/* @__PURE__ */ u(a,{name:`plus`,size:16})})]}),Pe=D===`indian`&&A?/* @__PURE__ */ u(`input`,{type:`hidden`,name:A,value:U.replace(/,/g,``),disabled:M,"data-wui-number-plain":``}):null;return/* @__PURE__ */ d(f.Group,{...le,"data-grouping":D===`indian`?D:void 0,className:`field${j?` ${j}`:``}`,children:[v&&/* @__PURE__ */ d(f.Label,{className:`label`,htmlFor:z,children:[v,de&&!y&&/* @__PURE__ */ u(`span`,{className:`label-optional`,children:` ${ge}`}),y&&/* @__PURE__ */ u(te,{}),x&&/* @__PURE__ */ u(ee,{label:pe,children:x})]}),Ne,Pe,/* @__PURE__ */ u(e,{error:L,hint:b,errorId:X,hintId:Z})]})});export{_ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../lib/FieldMessage.js";import{FIELD_SIZES as t}from"../lib/fieldState.js";import n from"../lib/useElementEntry.js";import{splitMarkerProps as
|
|
1
|
+
import e from"../lib/FieldMessage.js";import{FIELD_SIZES as t}from"../lib/fieldState.js";import{useFieldError as n}from"../lib/formFields.js";import r from"../lib/useElementEntry.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./AppInfoTip.js";import o from"./AppRequiredMark.js";import s from"./assertValidValue.js";import c from"./useWuiControl.js";import l from"./warnUnknownProps.js";import{cloneElement as u,forwardRef as d,useId as f}from"react";import{jsx as p,jsxs as m}from"react/jsx-runtime";var h=[`numeric`,`alphanumeric`],g=()=>import(`@webority/ui-elements/elements/otp`),_=d(function(d,_){let v=r(`wui-otp`,g),{marker:y,props:b}=i(`AppOtpInput`,d),{value:x,defaultValue:S,onChange:C,onComplete:w,length:T=6,mode:E=`numeric`,size:D=`md`,label:O,required:k=!1,optional:A=!1,optionalLabel:j=`(optional)`,helperText:M,help:N,helpLabel:P=`More information`,error:F,disabled:I=!1,readOnly:L=!1,loading:R=!1,name:z,id:B,className:V=``,fieldClassName:H=``,...U}=b,W=n(z),G=F??W;l(`AppOtpInput`,U),s(`AppOtpInput`,`mode`,E,h),s(`AppOtpInput`,`size`,D,t);let K=f(),q=B||K,J=G?`${q}-error`:void 0,Y=M?`${q}-hint`:void 0,X=J||Y,{setRef:Z}=c({ready:v,ref:_,value:x??(S===void 0?``:void 0),onChange:C,on:{complete:e=>w?.(e.detail)}}),Q=/* @__PURE__ */ p(`wui-otp`,{"aria-label":typeof O==`string`?O:void 0,ref:Z,id:q,name:z,length:String(T),mode:E,size:D===`md`?void 0:D,value:(x??S)||void 0,"aria-describedby":X,"aria-invalid":G?`true`:void 0,disabled:I?``:void 0,readonly:L?``:void 0,loading:R?``:void 0,required:k?``:void 0,className:V||void 0,...U});return!O&&!G&&!M?u(Q,y):/* @__PURE__ */ m(`div`,{...y,className:`field${H?` ${H}`:``}`,children:[O&&/* @__PURE__ */ m(`label`,{className:`label`,htmlFor:q,children:[O,A&&!k&&/* @__PURE__ */ p(`span`,{className:`label-optional`,children:` ${j}`}),k&&/* @__PURE__ */ p(o,{}),N&&/* @__PURE__ */ p(a,{label:P,children:N})]}),Q,/* @__PURE__ */ p(e,{error:G,hint:M,errorId:J,hintId:Y})]})});export{_ as default};
|