@webority/ui-react 0.128.0 → 0.130.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/README.md +1 -1
- package/dist/canvas-kit/kit.js +29757 -25503
- package/dist/canvas-kit/manifest.json +3343 -275
- package/dist/canvas-kit/release.json +6 -6
- package/dist/components/AppAccountSwitcher.js +1 -0
- package/dist/components/AppActionIcon.js +1 -1
- package/dist/components/AppAlert.js +1 -1
- package/dist/components/AppAsyncBlock.js +1 -1
- package/dist/components/AppAuthLayout.js +1 -0
- package/dist/components/AppAutocomplete.js +1 -1
- package/dist/components/AppAvatar.js +1 -1
- package/dist/components/AppAvatarGroup.js +1 -1
- package/dist/components/AppBadge.js +1 -1
- package/dist/components/AppBanner.js +1 -1
- package/dist/components/AppButton.js +1 -1
- package/dist/components/AppCalendar.js +1 -1
- package/dist/components/AppCard.js +1 -1
- package/dist/components/AppCell.js +1 -0
- package/dist/components/AppChart.js +1 -1
- package/dist/components/AppChartCard.js +1 -1
- package/dist/components/AppCheckbox.js +1 -1
- package/dist/components/AppChip.js +1 -1
- package/dist/components/AppChoiceCard.js +1 -1
- package/dist/components/AppChoiceChip.js +1 -1
- package/dist/components/AppColorField.js +1 -1
- package/dist/components/AppCommandPalette.js +1 -1
- package/dist/components/AppCommentThread.js +1 -1
- package/dist/components/AppCompareTable.js +1 -1
- package/dist/components/AppConfirmDialog.js +1 -1
- package/dist/components/AppConfirmProvider.js +1 -1
- package/dist/components/AppConsentBanner.js +1 -1
- package/dist/components/AppContextMenu.js +1 -1
- package/dist/components/AppCopyButton.js +1 -1
- package/dist/components/AppCountrySelect.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/AppEmptyState.js +1 -1
- package/dist/components/AppErrorBoundary.js +1 -0
- package/dist/components/AppFileAttachment.js +1 -1
- package/dist/components/AppFilePicker.js +1 -1
- package/dist/components/AppFileTiles.js +1 -1
- package/dist/components/AppFilterBar.js +1 -1
- package/dist/components/AppFloatingButton.js +1 -0
- package/dist/components/AppImagePicker.js +1 -1
- package/dist/components/AppInfoTip.js +1 -1
- package/dist/components/AppInlineEdit.js +1 -1
- package/dist/components/AppInput.js +1 -1
- package/dist/components/AppKanban.js +1 -1
- package/dist/components/AppKpiTile.js +1 -1
- package/dist/components/AppLeadPopup.js +1 -0
- package/dist/components/AppLink.js +1 -1
- package/dist/components/AppMarkdown.js +1 -1
- package/dist/components/AppMentionInput.js +1 -1
- package/dist/components/AppMeter.js +1 -1
- package/dist/components/AppMetricStrip.js +1 -1
- package/dist/components/AppModal.js +1 -1
- package/dist/components/AppMultiSelect.js +1 -1
- package/dist/components/AppNavList.js +1 -1
- package/dist/components/AppNotificationCenter.js +1 -1
- package/dist/components/AppNumberInput.js +1 -1
- package/dist/components/AppOnboardingChecklist.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/AppProgress.js +1 -1
- package/dist/components/AppRadio.js +1 -1
- package/dist/components/AppRadioGroup.js +1 -1
- package/dist/components/AppRating.js +1 -1
- package/dist/components/AppRepeater.js +1 -1
- package/dist/components/AppResourceCard.js +1 -1
- package/dist/components/AppRichText.js +1 -1
- package/dist/components/AppRouteError.js +1 -1
- package/dist/components/AppScoreScale.js +1 -1
- package/dist/components/AppSearch.js +1 -1
- package/dist/components/AppSectionHero.js +1 -1
- package/dist/components/AppSectionLeadCapture.js +1 -1
- package/dist/components/AppSectionLogos.js +1 -1
- package/dist/components/AppSegmented.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/AppSortableList.js +1 -1
- package/dist/components/AppSparkline.js +1 -1
- package/dist/components/AppSplash.js +1 -1
- package/dist/components/AppSplitButton.js +1 -1
- package/dist/components/AppSplitView.js +1 -1
- package/dist/components/AppStatusBadge.js +1 -1
- package/dist/components/AppStepper.js +1 -1
- package/dist/components/AppSwitch.js +1 -1
- package/dist/components/AppTablePagination.js +1 -1
- package/dist/components/AppTableToolbar.js +1 -1
- package/dist/components/AppTabs.js +1 -1
- package/dist/components/AppTagInput.js +1 -1
- package/dist/components/AppTextarea.js +1 -1
- package/dist/components/AppTimePicker.js +1 -1
- package/dist/components/AppTimeline.js +1 -1
- package/dist/components/AppToast.js +1 -1
- package/dist/components/AppToolbar.js +1 -1
- package/dist/components/AppTooltip.js +1 -1
- package/dist/components/AppUpdateBar.js +1 -1
- package/dist/components/AppWhatsNew.js +1 -1
- package/dist/components/AppWizard.js +1 -1
- package/dist/components/AppWorkspaceSwitcher.js +1 -1
- package/dist/components/iconCatalogNames.g.js +1 -1
- package/dist/components/iconGlyphs.g.js +1 -1
- package/dist/components/iconVariants.g.js +1 -1
- package/dist/components/useWuiControl.js +1 -1
- package/dist/guidance.json +273 -47
- package/dist/lib/CheckField.js +1 -1
- package/dist/lib/DiscardPrompt.js +1 -1
- package/dist/lib/FileItemRow.js +1 -1
- package/dist/lib/buttonClass.js +1 -0
- package/dist/lib/fieldState.js +1 -0
- package/dist/lib/fillLabel.js +1 -0
- package/dist/lib/labelWithHelp.js +1 -0
- package/dist/lib/linkTarget.js +1 -0
- package/dist/lib/sectionShell.js +1 -1
- package/dist/lib/vocabulary.js +1 -0
- package/dist/markdown-core/dist/links.js +1 -1
- package/dist/types/components/AppAccountSwitcher.d.ts +41 -0
- package/dist/types/components/AppActionIcon.d.ts +3 -12
- package/dist/types/components/AppAsyncBlock.d.ts +24 -0
- package/dist/types/components/AppAuthLayout.d.ts +45 -0
- package/dist/types/components/AppAutocomplete.d.ts +23 -3
- package/dist/types/components/AppAvatar.d.ts +6 -0
- package/dist/types/components/AppAvatarGroup.d.ts +6 -0
- package/dist/types/components/AppBanner.d.ts +8 -2
- package/dist/types/components/AppButton.d.ts +9 -4
- package/dist/types/components/AppCalendar.d.ts +3 -1
- package/dist/types/components/AppCard.d.ts +16 -4
- package/dist/types/components/AppCell.d.ts +36 -0
- package/dist/types/components/AppChart.d.ts +14 -0
- package/dist/types/components/AppChartCard.d.ts +60 -0
- package/dist/types/components/AppCheckbox.d.ts +23 -1
- package/dist/types/components/AppChoiceCard.d.ts +21 -0
- package/dist/types/components/AppChoiceChip.d.ts +21 -0
- package/dist/types/components/AppColorField.d.ts +45 -6
- package/dist/types/components/AppCommandPalette.d.ts +6 -0
- package/dist/types/components/AppCommentThread.d.ts +102 -3
- package/dist/types/components/AppCompareTable.d.ts +24 -0
- package/dist/types/components/AppConfirmDialog.d.ts +10 -10
- package/dist/types/components/AppConfirmProvider.d.ts +5 -6
- package/dist/types/components/AppConsentBanner.d.ts +3 -3
- package/dist/types/components/AppContextMenu.d.ts +2 -2
- package/dist/types/components/AppCopyButton.d.ts +8 -2
- package/dist/types/components/AppCountrySelect.d.ts +6 -1
- package/dist/types/components/AppDataTable.d.ts +1 -1
- package/dist/types/components/AppDatePicker.d.ts +26 -2
- package/dist/types/components/AppDateRangePicker.d.ts +32 -2
- package/dist/types/components/AppDescriptions.d.ts +4 -1
- package/dist/types/components/AppDrawer.d.ts +6 -0
- package/dist/types/components/AppDropZone.d.ts +26 -2
- package/dist/types/components/AppDropdown.d.ts +7 -7
- package/dist/types/components/AppDueDate.d.ts +42 -0
- package/dist/types/components/AppEmptyState.d.ts +3 -3
- package/dist/types/components/AppErrorBoundary.d.ts +39 -0
- package/dist/types/components/AppFileAttachment.d.ts +54 -1
- package/dist/types/components/AppFilePicker.d.ts +80 -5
- package/dist/types/components/AppFileTiles.d.ts +6 -3
- package/dist/types/components/AppFilterBar.d.ts +73 -0
- package/dist/types/components/AppFloatingButton.d.ts +70 -0
- package/dist/types/components/AppImagePicker.d.ts +64 -4
- package/dist/types/components/AppInlineEdit.d.ts +6 -0
- package/dist/types/components/AppInput.d.ts +38 -3
- package/dist/types/components/AppKanban.d.ts +32 -0
- package/dist/types/components/AppLeadPopup.d.ts +122 -0
- package/dist/types/components/AppLink.d.ts +3 -0
- package/dist/types/components/AppMentionInput.d.ts +18 -1
- package/dist/types/components/AppMetricStrip.d.ts +2 -0
- package/dist/types/components/AppModal.d.ts +9 -3
- package/dist/types/components/AppMultiSelect.d.ts +20 -3
- package/dist/types/components/AppNotificationCenter.d.ts +2 -0
- package/dist/types/components/AppNumberInput.d.ts +25 -3
- package/dist/types/components/AppOnboardingChecklist.d.ts +3 -3
- package/dist/types/components/AppOtpInput.d.ts +31 -2
- package/dist/types/components/AppPhoneNumberInput.d.ts +25 -1
- package/dist/types/components/AppPopover.d.ts +5 -5
- package/dist/types/components/AppRadio.d.ts +23 -1
- package/dist/types/components/AppRadioGroup.d.ts +26 -2
- package/dist/types/components/AppRating.d.ts +42 -3
- package/dist/types/components/AppRepeater.d.ts +3 -3
- package/dist/types/components/AppResourceCard.d.ts +2 -2
- package/dist/types/components/AppRichText.d.ts +10 -3
- package/dist/types/components/AppRouteError.d.ts +54 -0
- package/dist/types/components/AppScoreScale.d.ts +9 -3
- package/dist/types/components/AppSearch.d.ts +17 -2
- package/dist/types/components/AppSectionLeadCapture.d.ts +50 -2
- package/dist/types/components/AppSectionLogos.d.ts +2 -0
- package/dist/types/components/AppSegmented.d.ts +27 -3
- package/dist/types/components/AppSelect.d.ts +23 -3
- package/dist/types/components/AppShell.d.ts +151 -4
- package/dist/types/components/AppSlider.d.ts +29 -1
- package/dist/types/components/AppSortableList.d.ts +5 -0
- package/dist/types/components/AppSparkline.d.ts +24 -0
- package/dist/types/components/AppSplash.d.ts +2 -2
- package/dist/types/components/AppSplitButton.d.ts +10 -4
- package/dist/types/components/AppSplitView.d.ts +68 -0
- package/dist/types/components/AppStepper.d.ts +6 -0
- package/dist/types/components/AppSwitch.d.ts +24 -2
- package/dist/types/components/AppTablePagination.d.ts +44 -2
- package/dist/types/components/AppTableToolbar.d.ts +30 -0
- package/dist/types/components/AppTagInput.d.ts +20 -3
- package/dist/types/components/AppTextarea.d.ts +21 -1
- package/dist/types/components/AppTimePicker.d.ts +19 -2
- package/dist/types/components/AppTimeline.d.ts +8 -0
- package/dist/types/components/AppToast.d.ts +6 -0
- package/dist/types/components/AppToolbar.d.ts +3 -3
- package/dist/types/components/AppTooltip.d.ts +7 -4
- package/dist/types/components/AppUpdateBar.d.ts +20 -2
- package/dist/types/components/AppWhatsNew.d.ts +2 -0
- package/dist/types/components/AppWorkspaceSwitcher.d.ts +18 -0
- package/dist/types/components/iconGlyphs.g.d.ts +1 -0
- package/dist/types/components/iconVariants.g.d.ts +5 -0
- package/dist/types/components/useWuiControl.d.ts +3 -1
- package/dist/types/index.d.ts +6 -0
- package/dist/types/lib/FileItemRow.d.ts +9 -2
- package/dist/types/lib/buttonClass.d.ts +9 -0
- package/dist/types/lib/fieldState.d.ts +3 -0
- package/dist/types/lib/fillLabel.d.ts +1 -0
- package/dist/types/lib/labelWithHelp.d.ts +10 -0
- package/dist/types/lib/linkTarget.d.ts +30 -0
- package/dist/types/lib/sectionShell.d.ts +0 -1
- package/dist/types/lib/vocabulary.d.ts +3 -0
- package/dist/ui-react.js +1 -1
- package/dist/web-core/dist/query/listQuery.js +1 -0
- package/package.json +8 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{FILL_VARIANTS as e,TONES as t}from"../lib/vocabulary.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppActionIcon.js";import i from"./AppButton.js";import a from"./warnInvalidValue.js";import o from"./warnUnknownProps.js";import s from"./withTooltip.js";import{COPY_FEEDBACK_MS as c,copyTextToClipboard as l}from"@webority/ui-elements/helpers";import{useCallback as u,useEffect as d,useRef as f,useState as p}from"react";import{jsx as m}from"react/jsx-runtime";var h={sm:14,md:16,lg:20};function g(g){let{marker:_,props:v}=n(`AppCopyButton`,g),{text:y,label:b=`Copy`,copiedLabel:x=`Copied`,iconOnly:S=!1,size:C=`md`,tone:w=`primary`,variant:T=`ghost`,onCopied:E,className:D=``,tooltip:O,tooltipPlacement:k,...A}=v;o(`AppCopyButton`,A),a(`AppCopyButton`,`size`,C,Object.keys(h)),a(`AppCopyButton`,`tone`,w,t),a(`AppCopyButton`,`variant`,T,e);let[j,M]=p(!1),N=f(null);d(()=>()=>clearTimeout(N.current),[]);let P=u(async()=>{await l(y)&&(M(!0),clearTimeout(N.current),N.current=setTimeout(()=>M(!1),c),E?.())},[y,E]),F=j?x:b,I=j?`check`:`files`;return s(S?/* @__PURE__ */ m(r,{icon:I,label:F,size:h[C]??h.md,onClick:P,className:D,...A,..._}):/* @__PURE__ */ m(i,{leftIcon:I,tone:w,variant:T,size:C,onClick:P,className:D,"aria-live":`polite`,...A,..._,children:F}),O,k)}export{g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../lib/FieldMessage.js";import{loadFlagStyles as t}from"../lib/flagStyles.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppInfoTip.js";import i from"./AppRequiredMark.js";import a from"./useWuiControl.js";import o from"./warnInvalidValue.js";import s from"./warnUnknownProps.js";import{cloneElement as c,forwardRef as l,useEffect as u,useId as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import"@webority/ui-elements/elements/country-select";var m=[`sm`,`md`,`lg`],h=[`off`,`border`],g=l(function(l,g){let{marker:_,props:v}=n(`AppCountrySelect`,l),{value:y,onChange:b,countries:x,placeholder:S=`Select country`,searchPlaceholder:C=`Search countries...`,searchable:w=!0,clearable:T=!1,size:E=`md`,floatingLabel:D=`off`,disabled:O,open:k,label:A,required:j=!1,optional:M=!1,
|
|
1
|
+
import e from"../lib/FieldMessage.js";import{loadFlagStyles as t}from"../lib/flagStyles.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppInfoTip.js";import i from"./AppRequiredMark.js";import a from"./useWuiControl.js";import o from"./warnInvalidValue.js";import s from"./warnUnknownProps.js";import{cloneElement as c,forwardRef as l,useEffect as u,useId as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import"@webority/ui-elements/elements/country-select";var m=[`sm`,`md`,`lg`],h=[`off`,`border`],g=l(function(l,g){let{marker:_,props:v}=n(`AppCountrySelect`,l),{value:y,onChange:b,countries:x,placeholder:S=`Select country`,searchPlaceholder:C=`Search countries...`,searchable:w=!0,clearable:T=!1,size:E=`md`,floatingLabel:D=`off`,disabled:O,open:k,label:A,required:j=!1,optional:M=!1,optionalLabel:N=`(optional)`,error:P,helperText:F,help:I,helpLabel:L=`More information`,id:R,name:z,className:B=``,fieldClassName:V=``,"aria-label":H,"aria-labelledby":U,"aria-describedby":W,...G}=v;s(`AppCountrySelect`,G),o(`AppCountrySelect`,`size`,E,m),o(`AppCountrySelect`,`floatingLabel`,D,h),u(()=>{t()},[]);let K=d(),{setRef:q}=a({ref:g,value:y??``,onChange:b}),J=R||K,Y=D!==`off`&&A,X=P&&J?`${J}-error`:void 0,Z=F&&J?`${J}-hint`:void 0,Q=/* @__PURE__ */ f(`wui-country-select`,{"aria-label":H||(typeof A==`string`?A:void 0),"aria-labelledby":U||void 0,"aria-describedby":X||Z||W||void 0,"aria-invalid":P?`true`:void 0,ref:q,id:J,name:z,countries:Array.isArray(x)?x.join(`,`):void 0,placeholder:Y?` `:S,"search-placeholder":C,searchable:w?``:void 0,clearable:T?``:void 0,size:E===`sm`||E===`lg`?E:void 0,disabled:O?``:void 0,open:k?``:void 0,required:j?``:void 0,className:B||void 0,...G});if(!A&&!P&&!F)return c(Q,_);let $=[`field`,V].filter(Boolean).join(` `);return/* @__PURE__ */ p(`div`,{..._,className:$,children:[A&&!Y&&/* @__PURE__ */ p(`label`,{className:`label`,htmlFor:J,children:[A,M&&!j&&/* @__PURE__ */ f(`span`,{className:`label-optional`,children:` ${N}`}),j&&/* @__PURE__ */ f(i,{}),I&&/* @__PURE__ */ f(r,{label:L,children:I})]}),Y?/* @__PURE__ */ p(`div`,{className:`field-float`,children:[Q,/* @__PURE__ */ p(`label`,{className:`float-label`,htmlFor:J,children:[A,M&&!j&&/* @__PURE__ */ f(`span`,{className:`label-optional`,children:` ${N}`}),j&&/* @__PURE__ */ f(i,{})]})]}):Q,/* @__PURE__ */ f(e,{error:P,hint:F,errorId:X,hintId:Z})]})});export{g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{devWarn as e}from"../lib/devWarn.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./AppIcon.js";import r from"./AppSkeleton.js";import i from"./AppTablePagination.js";import a from"./warnInvalidValue.js";import o from"./warnUnknownProps.js";import{attachRowDrag as s,attachScrollEdges as c,syncTargets as ee}from"@webority/ui-elements/helpers";import{Children as l,Fragment as te,useEffect as u,useLayoutEffect as d,useMemo as ne,useRef as f,useState as p}from"react";import{Fragment as re,jsx as m,jsxs as h}from"react/jsx-runtime";import{FORCED_STATE_CLASSES as ie}from"@webority/theme/runtime";import{COLUMN_MAX_WIDTH as ae,COLUMN_MIN_WIDTH as oe,DATA_TABLE_TEXT as se,PIN_AT_VAR as ce,PIN_SIDES as le,ROW_HEIGHTS as ue,ROW_MOVE_LIMIT as de,ROW_SAVE_ERROR_CLASS as fe,groupCount as pe,groupItems as me,measureRows as he,pinAtValue as ge,pinClasses as _e,planPins as ve,playRowMoves as ye,rowOrderChanged as be,saveOutcomeText as xe,settledRows as Se,virtualRange as Ce}from"@webority/ui-elements/elements/data-table";var we=[`comfortable`,`cozy`,`compact`],Te=[`auto`,`fixed`],Ee=()=>{try{return process.env.NODE_ENV!==`production`}catch{return!0}},g=/* @__PURE__ */ new Set;function _(t,n){!g.has(t)&&Ee()&&(g.add(t),e(`[@webority/ui-react] <AppDataTable> ${n}`))}var De=100,Oe=e=>e.id,ke=()=>{},Ae=(e,t,n)=>{let r=!!t?.(e),i=r?``:n?.(e)||``;return{state:r?`saving`:i?`error`:null,message:i}};function v(e){return e===`end`?`wui-cell-end`:e===`num`?`num`:e===`center`?`text-center`:``}function je(e){return e===`center`?`44%`:e===`end`||e===`num`?`56%`:`60%`}function Me(e){return e==null||e===``?`-`:Array.isArray(e)?l.toArray(e):typeof e==`boolean`?String(e):e}function Ne(e){if(!e||!(e.total>0))return!1;let t=e.pageSizes?.length?e.pageSizes:[e.pageSize];return e.total>Math.min(...t)}function y(e){let{marker:l,props:Ee}=t(`AppDataTable`,e),{columns:g,rows:y,rowKey:b=Oe,sort:x,onSort:S,loading:C=!1,skeletonRows:Pe=5,empty:Fe=`No records found.`,emptyFiltered:Ie,sourceCount:Le,rowActions:w,rowActionsLabel:Re,pagination:T,ariaLabel:ze,className:Be=``,wrapperClassName:Ve=``,selectable:E=!1,selectedIds:D,isRowSelectable:He,onToggleRow:Ue,onToggleAll:We,onSelectRange:Ge,renderExpanded:Ke,density:O=`comfortable`,tableLayout:qe=`auto`,striped:Je=!1,flush:Ye=!1,pad:Xe,headerTone:Ze,rowDrag:k=!1,maxHeight:Qe,stickyFirstColumn:$e=!1,stickyActions:et=!1,stackOnMobile:A=!1,hiddenColumns:tt,rowStatus:nt,rowHref:j,onRowClick:rt,activeRowKey:it,hoverRowKey:at,resizableColumns:M=!1,viewKey:ot,groupBy:N,groupLabel:st,virtual:P=!1,rowSaving:F,rowSaveError:I,...ct}=Ee;o(`AppDataTable`,ct);let{style:lt,...ut}=ct,dt=tt?.length?new Set(tt):null;g=dt?g.filter(e=>!(e.hideable&&dt.has(e.key))):g,a(`AppDataTable`,`density`,O,we),a(`AppDataTable`,`tableLayout`,qe,Te);for(let e of g)a(`AppDataTable`,`column.pin`,e.pin,le);let ft=[`table table-ledger`,O===`cozy`||O===`compact`?`wui-table-${O}`:``,Je?`wui-table-striped`:``,$e?`wui-table-sticky-first`:``,et?`wui-table-sticky-actions`:``,A?`wui-table-stack`:``,Be].filter(Boolean).join(` `),L=typeof Ke==`function`,[pt,mt]=p(()=>/* @__PURE__ */ new Set),ht=e=>mt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),gt=g.some(e=>typeof e.footer==`function`),R=typeof j==`function`||typeof rt==`function`,_t=e=>!!e.target.closest(`a, button, input, select, textarea, label, [role='menu'], [role='menuitem'], .dropdown`),vt=(e,t)=>{if(_t(t)||(rt&&rt(e),!j))return;let n=j(e);n&&(t.ctrlKey||t.metaKey||t.button===1?window.open(n,`_blank`,`noopener`):window.location.assign(n))},z=Qe!==void 0,yt=[`table-wrap`,z?`wui-table-scroll`:``,Ye?`wui-table-flush`:``,Ve].filter(Boolean).join(` `),bt={maxHeight:z?Qe:void 0,"--wui-table-pad":Xe!=null&&!Ye?`${Xe}px`:void 0,"--wui-table-header-bg":Ze??void 0},xt=Object.values(bt).some(e=>e!==void 0)||lt!==void 0?{...bt,...lt}:void 0,St=Math.max(1,g.length+ +!!w+ +!!E+ +!!L),Ct=g.some(e=>e.pin===`start`||e.pin===`end`),B=Ct||M||!!N||P,V=+!!L+ +!!E,wt=Ct?ve([...L?[`lead`]:[],...E?[`lead`]:[],...g.map(e=>e.pin===`start`||e.pin===`end`?e.pin:null),...w?[null]:[]]):[],H=(e,t=``)=>{let n=wt[e];return n?{className:`${t.trim()} ${_e(n)}`.trim(),style:{[ce]:ge(n.side,n.ordinal)}}:{className:t,style:void 0}},U=(e,t)=>wt[e]?{...t,...H(e).style}:t,Tt=g.length-1+ +!!w;ot&&!M&&_(`view-key`,"`viewKey` remembers resized widths: add `resizableColumns`."),P&&!z&&_(`virtual-height`,"`virtual` needs `maxHeight`: without a scroll box every row renders."),P&&(L||A)&&_(`virtual-shape`,"`virtual` takes rows of one height, so it is off with `renderExpanded` or `stackOnMobile`."),!P&&y?.length>500&&_(`rows-without-virtual`,`renders more than 500 rows without virtual: add virtual with maxHeight, or page the data.`);let W=P&&z&&!L&&!A&&!C&&y?.length>0,G=(e,t)=>!He||!!He(e,t),Et=E&&y?y.reduce((e,t,n)=>e+ +!!G(t,n),0):0,K=E&&y?y.reduce((e,t,n)=>e+(G(t,n)&&D?.has(b(t,n))?1:0),0):0,Dt=Et>0&&K===Et,Ot=K>0&&!Dt,kt=e=>{e&&(e.indeterminate=Ot)},At=f(null),jt=(e,t)=>{let n=At.current;At.current=e;let r=t&&n!==null?y.findIndex((e,t)=>b(e,t)===n):-1,i=y.findIndex((t,n)=>b(t,n)===e);if(r<0||i<0||r===i){Ue?.(e);return}let a=!D?.has(e),o=Math.min(r,i),s=y.slice(o,Math.max(r,i)+1).map((e,t)=>[e,o+t]).filter(([e,t])=>G(e,t)).map(([e,t])=>b(e,t)).filter(e=>(D?.has(e)||!1)!==a);if(Ge)Ge(s,a);else for(let e of s)Ue?.(e)},Mt=e=>{He?(y||[]).forEach((t,n)=>{let r=b(t,n);G(t,n)&&(D?.has(r)||!1)!==e&&Ue?.(r)}):We?.(e)},[Nt,Pt]=p(()=>/* @__PURE__ */ new Set),Ft=e=>Pt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),q=ne(()=>{let e=(y||[]).map((e,t)=>({row:e,i:t}));return N?me(e,({row:e})=>String(e[N]??``)).flatMap(e=>[{group:e,open:!Nt.has(e.key)},...Nt.has(e.key)?[]:e.items]):e},[y,N,Nt]),J=f(null),It=f(null);u(()=>{let e=J.current;if(!e)return;let t=e=>{let t=e.target.closest?.(`.u-name`);t&&!t.title&&(t.scrollWidth>t.clientWidth||t.scrollHeight>t.clientHeight)&&(t.title=t.textContent.trim())},n=e=>{let t=e.target.closest?.(`tbody > tr[aria-rowindex]`)?.getAttribute(`aria-rowindex`);It.current=t?Number(t)-2:null},r=t=>{e.contains(t.relatedTarget)||(It.current=null)};e.addEventListener(`mouseover`,t),e.addEventListener(`focusin`,t),e.addEventListener(`focusin`,n),e.addEventListener(`focusout`,r);let i=c(e);return()=>{e.removeEventListener(`mouseover`,t),e.removeEventListener(`focusin`,t),e.removeEventListener(`focusin`,n),e.removeEventListener(`focusout`,r),i()}},[B]),u(()=>{if(!k||!J.current)return;let e=s(J.current);return ee(document),e},[k,B]);let Lt=f(!1);u(()=>{!Lt.current&&(Lt.current=!0,K===0)||J.current?.querySelector(`table`)?.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:{selected:K,total:y?.length??0,keys:y?y.flatMap((e,t)=>{let n=b(e,t);return G(e,t)&&D?.has(n)?[String(n)]:[]}):[]}}))},[E,K]);let[Rt,zt]=p({top:0,height:0}),[Y,Bt]=p(ue[O]??ue.comfortable);u(()=>{let e=J.current;if(!W||!e)return;let t=0,n=()=>{t=0;let n=e.querySelector(`:scope > table > thead`)?.getBoundingClientRect().height||0,r={top:Math.max(0,e.scrollTop-n),height:e.clientHeight};zt(e=>e.top===r.top&&e.height===r.height?e:r)},r=()=>{t||=requestAnimationFrame(n)};e.addEventListener(`scroll`,r,{passive:!0});let i=typeof ResizeObserver<`u`?new ResizeObserver(r):null;return i?.observe(e),n(),()=>{e.removeEventListener(`scroll`,r),i?.disconnect(),t&&cancelAnimationFrame(t)}},[W,B]),d(()=>{if(!W)return;let e=(J.current?.querySelector(`:scope > table > tbody > tr:not(.wui-virtual-spacer, .wui-group-row)`))?.getBoundingClientRect().height;e>0&&Math.abs(e-Y)>.5&&Bt(e)},[O,y?.length,P,W]);let X={start:0,end:q.length,before:0,after:0};if(W){X=Ce({scrollTop:Rt.top,viewport:Rt.height||Number.parseFloat(Qe)||0,rowHeight:Y,count:q.length});let e=It.current;e!==null&&e>=0&&e<q.length&&(e<X.start&&X.start-e<=De&&(X={...X,start:e,before:e*Y}),e>=X.end&&e-X.end<De&&(X={...X,end:e+1,after:(q.length-e-1)*Y}))}let Vt=f(null),Ht=f(null),Ut=f(null),Wt=!P&&!C&&y?.length>0&&y.length<=de;d(()=>{let e=Vt.current;if(!Wt||!e){Ht.current=null,Ut.current=null;return}let t=y.map((e,t)=>b(e,t));be(Ut.current,t)&&ye(e.rows,Ht.current),Ht.current=he(e.rows),Ut.current=t});let Gt=typeof F==`function`||typeof I==`function`,Kt=f(null),qt=f(null);u(()=>{if(!Gt){qt.current=null;return}let e=g[0]?.key,t=/* @__PURE__ */ new Map;(y||[]).forEach((n,r)=>{let i=e===void 0?void 0:n[e],a=typeof i==`string`||typeof i==`number`?String(i):``;t.set(b(n,r),{...Ae(n,F,I),label:a})});let n=xe(Se(qt.current,t));qt.current=t,n&&Kt.current&&(Kt.current.textContent=n)},[y,F,I,b]);let Z=Ie!==void 0&&(Le===void 0||Le>0)?Ie:Fe,Jt=({group:e,open:t},r)=>{let i=e.items[0].row[N],a=e.items.map(e=>e.row);return/* @__PURE__ */ m(`tr`,{className:`wui-group-row`,"data-group-key":e.key,"aria-rowindex":W?r+2:void 0,children:/* @__PURE__ */ m(`th`,{className:`wui-group-cell`,scope:`rowgroup`,colSpan:St,children:/* @__PURE__ */ h(`button`,{type:`button`,className:`wui-group-toggle`,"aria-expanded":t,onClick:()=>Ft(e.key),children:[/* @__PURE__ */ m(n,{name:`chevron-down`,size:16}),/* @__PURE__ */ m(`span`,{className:`wui-group-label`,children:st?st(i,a):Me(i)}),/* @__PURE__ */ m(`span`,{className:`wui-group-count`,"aria-hidden":`true`,children:pe(e.items.length)}),/* @__PURE__ */ m(`span`,{className:`visually-hidden wui-group-rows`,children:`, ${se.rows(e.items.length)}`})]})})},`group:${e.key}`)},Yt=({row:e,i:t},r)=>{let i=b(e,t),a=L&&pt.has(i),o=it!=null&&String(it)===String(i),s=at!=null&&String(at)===String(i),c=String(i).replace(/[^a-z0-9]/gi,`_`),ee=H(0,`wui-expand-cell`),l=H(+!!L,`wui-select-cell`),u=Gt?Ae(e,F,I):null,d=G(e,t);return/* @__PURE__ */ h(te,{children:[/* @__PURE__ */ h(`tr`,{className:[E&&d&&D?.has(i)?`is-selected`:``,R?`wui-row-link`:``,o?`wui-row-active`:``,s?ie.hover:``].filter(Boolean).join(` `)||void 0,"aria-current":o?`true`:void 0,"aria-rowindex":W?r+2:void 0,"aria-busy":u?.state===`saving`?`true`:void 0,"data-wui-save-state":u?.state||void 0,"data-status":nt?.(e)||void 0,"data-href":j?.(e)||void 0,"data-row-key":k?String(i):void 0,tabIndex:R?0:void 0,onClick:R?t=>vt(e,t):void 0,onAuxClick:R&&j?t=>t.button===1&&vt(e,t):void 0,onKeyDown:R?t=>{t.key===`Enter`&&t.target===t.currentTarget&&vt(e,t)}:void 0,children:[L&&/* @__PURE__ */ m(`td`,{className:ee.className,style:ee.style,children:/* @__PURE__ */ m(`button`,{type:`button`,className:`wui-expand-toggle${a?` is-open`:``}`,"aria-expanded":a,"aria-controls":a?`${c}-expanded`:void 0,"aria-label":a?`Collapse row`:`Expand row`,onClick:()=>ht(i),children:/* @__PURE__ */ m(n,{name:`chevron-down`,size:16})})}),E&&/* @__PURE__ */ m(`td`,{className:l.className,style:l.style,children:/* @__PURE__ */ m(`input`,{type:`checkbox`,className:`wui-check`,checked:d&&(D?.has(i)||!1),disabled:!d,onChange:e=>jt(i,e.nativeEvent.shiftKey),onMouseDown:e=>{e.shiftKey&&e.preventDefault()},"aria-label":`Select row`})}),g.map((t,n)=>/* @__PURE__ */ h(`td`,{className:H(V+n,(n===0?`wui-name-cell `:``)+(t.nowrap?`text-nowrap `:``)+v(t.align)+(t.cellClassName?` ${t.cellClassName}`:``)).className,style:U(V+n,t.cellStyle),"data-label":A&&typeof t.label==`string`?t.label:void 0,children:[t.render?t.render(e):Me(e[t.key]),n===0&&u?.state===`error`&&/* @__PURE__ */ m(`span`,{className:fe,children:u.message})]},t.key)),w&&/* @__PURE__ */ m(`td`,{children:/* @__PURE__ */ m(`div`,{className:`u-row-actions`,children:w(e)})})]}),a&&/* @__PURE__ */ m(`tr`,{className:`wui-row-expanded`,children:/* @__PURE__ */ m(`td`,{id:`${c}-expanded`,colSpan:St,children:Ke(e)})})]},i)},Xt=(e,t)=>e.group?Jt(e,t):Yt(e,t),Zt=(e,t)=>W?/* @__PURE__ */ m(`tr`,{className:`wui-virtual-spacer`,"aria-hidden":`true`,hidden:t===0,children:/* @__PURE__ */ m(`td`,{colSpan:St,style:{height:t}})},e):null,Q=H(0,`wui-expand-cell`),$=H(+!!L,`wui-select-cell`),Qt=()=>Array.from({length:Pe},(e,t)=>`skeleton-${t}`).map(e=>/* @__PURE__ */ h(`tr`,{children:[L&&/* @__PURE__ */ m(`td`,{className:Q.className,style:Q.style}),E&&/* @__PURE__ */ m(`td`,{className:$.className,style:$.style}),g.map((e,t)=>/* @__PURE__ */ m(`td`,{className:H(V+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+v(e.align)).className,style:U(V+t,void 0),"data-label":A&&typeof e.label==`string`?e.label:void 0,children:/* @__PURE__ */ m(r,{width:je(e.align),height:12,radius:6})},e.key)),w&&/* @__PURE__ */ m(`td`,{children:/* @__PURE__ */ m(`div`,{className:`u-row-actions`,children:/* @__PURE__ */ m(r,{width:`32px`,height:12,radius:6})})})]},e));return/* @__PURE__ */ h(re,{children:[/* @__PURE__ */ h(B?`wui-data-table`:`div`,{ref:J,...B?{class:yt,resizable:M?``:void 0,"view-key":ot||void 0,"data-wui-row-drag":k?``:void 0}:{className:yt,"data-wui-row-drag":k?``:void 0},style:xt,tabIndex:0,...l,...ut,children:[/* @__PURE__ */ h(`table`,{className:ft,"aria-label":ze,"aria-rowcount":W?q.length+1:void 0,style:qe===`fixed`?{tableLayout:`fixed`}:void 0,children:[/* @__PURE__ */ m(`thead`,{children:/* @__PURE__ */ h(`tr`,{"aria-rowindex":W?1:void 0,children:[L&&/* @__PURE__ */ m(`th`,{className:Q.className,style:Q.style,children:/* @__PURE__ */ m(`span`,{className:`visually-hidden`,children:`Expand`})}),E&&/* @__PURE__ */ m(`th`,{className:$.className,style:$.style,children:/* @__PURE__ */ m(`input`,{ref:kt,type:`checkbox`,className:`wui-check`,checked:Dt,disabled:C,onChange:e=>Mt(e.target.checked),"aria-label":`Select all rows`})}),g.map((e,t)=>{let r=!!(e.sortable&&S),i=x&&x.key===e.key,a=e.align===`num`||e.align===`end`,o=r&&/* @__PURE__ */ m(`span`,{className:`sort-icon${a?` wui-sort-lead`:``}`,children:/* @__PURE__ */ m(n,{name:`chevrons-up-down`,size:14})}),s=M&&t!==Tt,c=e.width||e.minWidth?{width:e.width,minWidth:e.minWidth}:void 0;return/* @__PURE__ */ h(`th`,{className:H(V+t,(r?`sortable `:``)+(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+(e.grow?`wui-col-grow `:``)+(s?`wui-col-resizable `:``)+v(e.align)).className,style:U(V+t,c),"data-key":B?e.key:void 0,"aria-label":s&&typeof e.label==`string`?e.label:void 0,"data-pin":e.pin===`start`||e.pin===`end`?e.pin:void 0,tabIndex:r?0:void 0,"aria-sort":i?x.dir===`asc`?`ascending`:`descending`:r?`none`:void 0,onClick:r?()=>{C||S(e.key)}:void 0,onKeyDown:r?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),C||S(e.key))}:void 0,children:[a&&o,e.label,!a&&o,s&&/* @__PURE__ */ m(`span`,{className:`wui-col-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":oe,"aria-valuemax":ae,tabIndex:0,"aria-label":se.resize(typeof e.label==`string`?e.label:e.key)})]},e.key)}),w&&(Re?/* @__PURE__ */ m(`th`,{className:`wui-cell-end`,children:Re}):/* @__PURE__ */ m(`th`,{className:`wui-cell-end`,children:/* @__PURE__ */ m(`span`,{className:`visually-hidden`,children:`Actions`})}))]})}),/* @__PURE__ */ m(`tbody`,{ref:Vt,children:C?Qt():y?.length?/* @__PURE__ */ h(re,{children:[Zt(`before`,X.before),q.slice(X.start,X.end).map((e,t)=>Xt(e,X.start+t)),Zt(`after`,X.after)]}):null}),gt&&!C&&y?.length>0&&/* @__PURE__ */ m(`tfoot`,{children:/* @__PURE__ */ h(`tr`,{children:[L&&/* @__PURE__ */ m(`td`,{className:Q.className,style:Q.style}),E&&/* @__PURE__ */ m(`td`,{className:$.className,style:$.style}),g.map((e,t)=>/* @__PURE__ */ m(`td`,{className:H(V+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+v(e.align)).className,style:U(V+t,void 0),children:e.footer?e.footer(y):null},e.key)),w&&/* @__PURE__ */ m(`td`,{})]})})]}),!C&&!y?.length&&/* @__PURE__ */ m(`div`,{className:`tbl-empty-block`,children:typeof Z==`string`?/* @__PURE__ */ m(`div`,{className:`tbl-empty-plain`,children:Z}):Z})]}),Ne(T)&&/* @__PURE__ */ m(i,{page:T.page,totalPages:T.totalPages,pageSize:T.pageSize,onPageChange:C?ke:T.setPage,onPageSizeChange:C?ke:T.setPageSize,pageSizes:T.pageSizes,mode:T.mode}),Gt&&/* @__PURE__ */ m(`div`,{ref:Kt,className:`visually-hidden`,role:`status`,"aria-live":`polite`,"data-wui-table-status":``})]})}export{y as default};
|
|
1
|
+
import{devWarn as e}from"../lib/devWarn.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./AppIcon.js";import r from"./AppSkeleton.js";import i from"./AppTablePagination.js";import a from"./warnInvalidValue.js";import o from"./warnUnknownProps.js";import{attachRowDrag as s,attachScrollEdges as c,syncTargets as ee}from"@webority/ui-elements/helpers";import{Children as l,Fragment as te,useEffect as u,useLayoutEffect as d,useMemo as ne,useRef as f,useState as p}from"react";import{Fragment as re,jsx as m,jsxs as h}from"react/jsx-runtime";import{FORCED_STATE_CLASSES as ie}from"@webority/theme/runtime";import{COLUMN_MAX_WIDTH as ae,COLUMN_MIN_WIDTH as oe,DATA_TABLE_TEXT as se,PIN_AT_VAR as ce,PIN_SIDES as le,ROW_HEIGHTS as ue,ROW_MOVE_LIMIT as de,ROW_SAVE_ERROR_CLASS as fe,groupCount as pe,groupItems as me,measureRows as he,pinAtValue as ge,pinClasses as _e,planPins as ve,playRowMoves as ye,rowOrderChanged as be,saveOutcomeText as xe,settledRows as Se,virtualRange as Ce}from"@webority/ui-elements/elements/data-table";var we=[`comfortable`,`cozy`,`compact`],Te=[`auto`,`fixed`],Ee=()=>{try{return process.env.NODE_ENV!==`production`}catch{return!0}},g=/* @__PURE__ */ new Set;function _(t,n){!g.has(t)&&Ee()&&(g.add(t),e(`[@webority/ui-react] <AppDataTable> ${n}`))}var De=100,Oe=e=>e.id,ke=()=>{},Ae=(e,t,n)=>{let r=!!t?.(e),i=r?``:n?.(e)||``;return{state:r?`saving`:i?`error`:null,message:i}};function v(e){return e===`end`?`wui-cell-end`:e===`num`?`num`:e===`center`?`text-center`:``}function je(e){return e===`center`?`44%`:e===`end`||e===`num`?`56%`:`60%`}function Me(e){return e==null||e===``?`-`:Array.isArray(e)?l.toArray(e):typeof e==`boolean`?String(e):e}function Ne(e){if(!e||!(e.total>0))return!1;let t=e.pageSizes?.length?e.pageSizes:[e.pageSize];return e.total>Math.min(...t)}function y(e){let{marker:l,props:Ee}=t(`AppDataTable`,e),{columns:g,rows:y,rowKey:b=Oe,sort:x,onSort:S,loading:C=!1,skeletonRows:Pe=5,empty:Fe=`No records found.`,emptyFiltered:Ie,sourceCount:Le,rowActions:w,rowActionsLabel:Re,pagination:T,ariaLabel:ze,className:Be=``,wrapperClassName:Ve=``,selectable:E=!1,selectedIds:D,isRowSelectable:He,onToggleRow:Ue,onToggleAll:We,onSelectRange:Ge,renderExpanded:Ke,density:O=`comfortable`,tableLayout:qe=`auto`,striped:Je=!1,flush:Ye=!1,pad:Xe,headerTone:Ze,rowDrag:k=!1,maxHeight:Qe,stickyFirstColumn:$e=!1,stickyActions:et=!1,stackOnMobile:A=!1,hiddenColumns:tt,rowStatus:nt,rowHref:j,onRowClick:rt,activeRowKey:it,hoverRowKey:at,resizableColumns:M=!1,viewKey:ot,groupBy:N,groupLabel:st,virtual:P=!1,rowSaving:F,rowSaveError:I,...ct}=Ee;o(`AppDataTable`,ct);let{style:lt,...ut}=ct,dt=tt?.length?new Set(tt):null;g=dt?g.filter(e=>!(e.hideable&&dt.has(e.key))):g,a(`AppDataTable`,`density`,O,we),a(`AppDataTable`,`tableLayout`,qe,Te);for(let e of g)a(`AppDataTable`,`column.pin`,e.pin,le);let ft=[`table table-ledger`,O===`cozy`||O===`compact`?`wui-table-${O}`:``,Je?`wui-table-striped`:``,$e?`wui-table-sticky-first`:``,et?`wui-table-sticky-actions`:``,A?`wui-table-stack`:``,Be].filter(Boolean).join(` `),L=typeof Ke==`function`,[pt,mt]=p(()=>/* @__PURE__ */ new Set),ht=e=>mt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),gt=g.some(e=>typeof e.footer==`function`),R=typeof j==`function`||typeof rt==`function`,_t=e=>!!e.target.closest(`a, button, input, select, textarea, label, [role='menu'], [role='menuitem'], .dropdown`),vt=(e,t)=>{if(_t(t)||(rt&&rt(e),!j))return;let n=j(e);n&&(t.ctrlKey||t.metaKey||t.button===1?window.open(n,`_blank`,`noopener`):window.location.assign(n))},z=Qe!==void 0,yt=[`table-wrap`,z?`wui-table-scroll`:``,Ye?`wui-table-flush`:``,Ve].filter(Boolean).join(` `),bt={maxHeight:z?Qe:void 0,"--wui-table-pad":Xe!=null&&!Ye?`${Xe}px`:void 0,"--wui-table-header-bg":Ze??void 0},xt=Object.values(bt).some(e=>e!==void 0)||lt!==void 0?{...bt,...lt}:void 0,St=Math.max(1,g.length+ +!!w+ +!!E+ +!!L),Ct=g.some(e=>e.pin===`start`||e.pin===`end`),B=Ct||M||!!N||P,V=+!!L+ +!!E,wt=Ct?ve([...L?[`lead`]:[],...E?[`lead`]:[],...g.map(e=>e.pin===`start`||e.pin===`end`?e.pin:null),...w?[null]:[]]):[],H=(e,t=``)=>{let n=wt[e];return n?{className:`${t.trim()} ${_e(n)}`.trim(),style:{[ce]:ge(n.side,n.ordinal)}}:{className:t,style:void 0}},U=(e,t)=>wt[e]?{...t,...H(e).style}:t,Tt=g.length-1+ +!!w;ot&&!M&&_(`view-key`,"`viewKey` remembers resized widths: add `resizableColumns`."),P&&!z&&_(`virtual-height`,"`virtual` needs `maxHeight`: without a scroll box every row renders."),P&&(L||A)&&_(`virtual-shape`,"`virtual` takes rows of one height, so it is off with `renderExpanded` or `stackOnMobile`."),!P&&y?.length>500&&_(`rows-without-virtual`,`renders more than 500 rows without virtual: add virtual with maxHeight, or page the data.`);let W=P&&z&&!L&&!A&&!C&&y?.length>0,G=(e,t)=>!He||!!He(e,t),Et=E&&y?y.reduce((e,t,n)=>e+ +!!G(t,n),0):0,K=E&&y?y.reduce((e,t,n)=>e+(G(t,n)&&D?.has(b(t,n))?1:0),0):0,Dt=Et>0&&K===Et,Ot=K>0&&!Dt,kt=e=>{e&&(e.indeterminate=Ot)},At=f(null),jt=(e,t)=>{let n=At.current;At.current=e;let r=t&&n!==null?y.findIndex((e,t)=>b(e,t)===n):-1,i=y.findIndex((t,n)=>b(t,n)===e);if(r<0||i<0||r===i){Ue?.(e);return}let a=!D?.has(e),o=Math.min(r,i),s=y.slice(o,Math.max(r,i)+1).map((e,t)=>[e,o+t]).filter(([e,t])=>G(e,t)).map(([e,t])=>b(e,t)).filter(e=>(D?.has(e)||!1)!==a);if(Ge)Ge(s,a);else for(let e of s)Ue?.(e)},Mt=e=>{He?(y||[]).forEach((t,n)=>{let r=b(t,n);G(t,n)&&(D?.has(r)||!1)!==e&&Ue?.(r)}):We?.(e)},[Nt,Pt]=p(()=>/* @__PURE__ */ new Set),Ft=e=>Pt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),q=ne(()=>{let e=(y||[]).map((e,t)=>({row:e,i:t}));return N?me(e,({row:e})=>String(e[N]??``)).flatMap(e=>[{group:e,open:!Nt.has(e.key)},...Nt.has(e.key)?[]:e.items]):e},[y,N,Nt]),J=f(null),It=f(null);u(()=>{let e=J.current;if(!e)return;let t=e=>{let t=e.target.closest?.(`.u-name`);t&&!t.title&&(t.scrollWidth>t.clientWidth||t.scrollHeight>t.clientHeight)&&(t.title=t.textContent.trim())},n=e=>{let t=e.target.closest?.(`tbody > tr[aria-rowindex]`)?.getAttribute(`aria-rowindex`);It.current=t?Number(t)-2:null},r=t=>{e.contains(t.relatedTarget)||(It.current=null)};e.addEventListener(`mouseover`,t),e.addEventListener(`focusin`,t),e.addEventListener(`focusin`,n),e.addEventListener(`focusout`,r);let i=c(e);return()=>{e.removeEventListener(`mouseover`,t),e.removeEventListener(`focusin`,t),e.removeEventListener(`focusin`,n),e.removeEventListener(`focusout`,r),i()}},[B]),u(()=>{if(!k||!J.current)return;let e=s(J.current);return ee(document),e},[k,B]);let Lt=f(!1);u(()=>{!Lt.current&&(Lt.current=!0,K===0)||J.current?.querySelector(`table`)?.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:{selected:K,total:y?.length??0,keys:y?y.flatMap((e,t)=>{let n=b(e,t);return G(e,t)&&D?.has(n)?[String(n)]:[]}):[]}}))},[E,K]);let[Rt,zt]=p({top:0,height:0}),[Y,Bt]=p(ue[O]??ue.comfortable);u(()=>{let e=J.current;if(!W||!e)return;let t=0,n=()=>{t=0;let n=e.querySelector(`:scope > table > thead`)?.getBoundingClientRect().height||0,r={top:Math.max(0,e.scrollTop-n),height:e.clientHeight};zt(e=>e.top===r.top&&e.height===r.height?e:r)},r=()=>{t||=requestAnimationFrame(n)};e.addEventListener(`scroll`,r,{passive:!0});let i=typeof ResizeObserver<`u`?new ResizeObserver(r):null;return i?.observe(e),n(),()=>{e.removeEventListener(`scroll`,r),i?.disconnect(),t&&cancelAnimationFrame(t)}},[W,B]),d(()=>{if(!W)return;let e=(J.current?.querySelector(`:scope > table > tbody > tr:not(.wui-virtual-spacer, .wui-group-row)`))?.getBoundingClientRect().height;e>0&&Math.abs(e-Y)>.5&&Bt(e)},[O,y?.length,P,W]);let X={start:0,end:q.length,before:0,after:0};if(W){X=Ce({scrollTop:Rt.top,viewport:Rt.height||Number.parseFloat(Qe)||0,rowHeight:Y,count:q.length});let e=It.current;e!==null&&e>=0&&e<q.length&&(e<X.start&&X.start-e<=De&&(X={...X,start:e,before:e*Y}),e>=X.end&&e-X.end<De&&(X={...X,end:e+1,after:(q.length-e-1)*Y}))}let Vt=f(null),Ht=f(null),Ut=f(null),Wt=!P&&!C&&y?.length>0&&y.length<=de;d(()=>{let e=Vt.current;if(!Wt||!e){Ht.current=null,Ut.current=null;return}let t=y.map((e,t)=>b(e,t));be(Ut.current,t)&&ye(e.rows,Ht.current),Ht.current=he(e.rows),Ut.current=t});let Gt=typeof F==`function`||typeof I==`function`,Kt=f(null),qt=f(null);u(()=>{if(!Gt){qt.current=null;return}let e=g[0]?.key,t=/* @__PURE__ */ new Map;(y||[]).forEach((n,r)=>{let i=e===void 0?void 0:n[e],a=typeof i==`string`||typeof i==`number`?String(i):``;t.set(b(n,r),{...Ae(n,F,I),label:a})});let n=xe(Se(qt.current,t));qt.current=t,n&&Kt.current&&(Kt.current.textContent=n)},[y,F,I,b]);let Z=Ie!==void 0&&(Le===void 0||Le>0)?Ie:Fe,Jt=({group:e,open:t},r)=>{let i=e.items[0].row[N],a=e.items.map(e=>e.row);return/* @__PURE__ */ m(`tr`,{className:`wui-group-row`,"data-group-key":e.key,"aria-rowindex":W?r+2:void 0,children:/* @__PURE__ */ m(`th`,{className:`wui-group-cell`,scope:`rowgroup`,colSpan:St,children:/* @__PURE__ */ h(`button`,{type:`button`,className:`wui-group-toggle`,"aria-expanded":t,onClick:()=>Ft(e.key),children:[/* @__PURE__ */ m(n,{name:`chevron-down`,size:16}),/* @__PURE__ */ m(`span`,{className:`wui-group-label`,children:st?st(i,a):Me(i)}),/* @__PURE__ */ m(`span`,{className:`wui-group-count`,"aria-hidden":`true`,children:pe(e.items.length)}),/* @__PURE__ */ m(`span`,{className:`visually-hidden wui-group-rows`,children:`, ${se.rows(e.items.length)}`})]})})},`group:${e.key}`)},Yt=({row:e,i:t},r)=>{let i=b(e,t),a=L&&pt.has(i),o=it!=null&&String(it)===String(i),s=at!=null&&String(at)===String(i),c=String(i).replace(/[^a-z0-9]/gi,`_`),ee=H(0,`wui-expand-cell`),l=H(+!!L,`wui-select-cell`),u=Gt?Ae(e,F,I):null,d=G(e,t);return/* @__PURE__ */ h(te,{children:[/* @__PURE__ */ h(`tr`,{className:[E&&d&&D?.has(i)?`is-selected`:``,R?`wui-row-link`:``,o?`wui-row-active`:``,s?ie.hover:``].filter(Boolean).join(` `)||void 0,"aria-current":o?`true`:void 0,"aria-rowindex":W?r+2:void 0,"aria-busy":u?.state===`saving`?`true`:void 0,"data-wui-save-state":u?.state||void 0,"data-status":nt?.(e)||void 0,"data-href":j?.(e)||void 0,"data-row-key":k?String(i):void 0,tabIndex:R?0:void 0,onClick:R?t=>vt(e,t):void 0,onAuxClick:R&&j?t=>t.button===1&&vt(e,t):void 0,onKeyDown:R?t=>{t.key===`Enter`&&t.target===t.currentTarget&&vt(e,t)}:void 0,children:[L&&/* @__PURE__ */ m(`td`,{className:ee.className,style:ee.style,children:/* @__PURE__ */ m(`button`,{type:`button`,className:`wui-expand-toggle${a?` is-open`:``}`,"aria-expanded":a,"aria-controls":a?`${c}-expanded`:void 0,"aria-label":a?`Collapse row`:`Expand row`,onClick:()=>ht(i),children:/* @__PURE__ */ m(n,{name:`chevron-down`,size:16})})}),E&&/* @__PURE__ */ m(`td`,{className:l.className,style:l.style,children:/* @__PURE__ */ m(`input`,{type:`checkbox`,className:`wui-check`,checked:d&&(D?.has(i)||!1),disabled:!d,onChange:e=>jt(i,e.nativeEvent.shiftKey),onMouseDown:e=>{e.shiftKey&&e.preventDefault()},"aria-label":`Select row`})}),g.map((t,n)=>/* @__PURE__ */ h(`td`,{className:H(V+n,(n===0?`wui-name-cell `:``)+(t.nowrap?`text-nowrap `:``)+v(t.align)+(t.cellClassName?` ${t.cellClassName}`:``)).className,style:U(V+n,t.cellStyle),"data-label":A&&typeof t.label==`string`?t.label:void 0,children:[t.render?t.render(e):Me(e[t.key]),n===0&&u?.state===`error`&&/* @__PURE__ */ m(`span`,{className:fe,children:u.message})]},t.key)),w&&/* @__PURE__ */ m(`td`,{children:/* @__PURE__ */ m(`div`,{className:`u-row-actions`,children:w(e)})})]}),a&&/* @__PURE__ */ m(`tr`,{className:`wui-row-expanded`,children:/* @__PURE__ */ m(`td`,{id:`${c}-expanded`,colSpan:St,children:Ke(e)})})]},i)},Xt=(e,t)=>e.group?Jt(e,t):Yt(e,t),Zt=(e,t)=>W?/* @__PURE__ */ m(`tr`,{className:`wui-virtual-spacer`,"aria-hidden":`true`,hidden:t===0,children:/* @__PURE__ */ m(`td`,{colSpan:St,style:{height:t}})},e):null,Q=H(0,`wui-expand-cell`),$=H(+!!L,`wui-select-cell`),Qt=()=>Array.from({length:Pe},(e,t)=>`skeleton-${t}`).map(e=>/* @__PURE__ */ h(`tr`,{children:[L&&/* @__PURE__ */ m(`td`,{className:Q.className,style:Q.style}),E&&/* @__PURE__ */ m(`td`,{className:$.className,style:$.style}),g.map((e,t)=>/* @__PURE__ */ m(`td`,{className:H(V+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+v(e.align)).className,style:U(V+t,void 0),"data-label":A&&typeof e.label==`string`?e.label:void 0,children:/* @__PURE__ */ m(r,{width:je(e.align),height:12,radius:6})},e.key)),w&&/* @__PURE__ */ m(`td`,{children:/* @__PURE__ */ m(`div`,{className:`u-row-actions`,children:/* @__PURE__ */ m(r,{width:`32px`,height:12,radius:6})})})]},e));return/* @__PURE__ */ h(re,{children:[/* @__PURE__ */ h(B?`wui-data-table`:`div`,{ref:J,...B?{class:yt,resizable:M?``:void 0,"view-key":ot||void 0,"data-wui-row-drag":k?``:void 0}:{className:yt,"data-wui-row-drag":k?``:void 0},style:xt,tabIndex:0,...l,...ut,children:[/* @__PURE__ */ h(`table`,{className:ft,"aria-label":ze,"aria-rowcount":W?q.length+1:void 0,style:qe===`fixed`?{tableLayout:`fixed`}:void 0,children:[/* @__PURE__ */ m(`thead`,{children:/* @__PURE__ */ h(`tr`,{"aria-rowindex":W?1:void 0,children:[L&&/* @__PURE__ */ m(`th`,{className:Q.className,style:Q.style,children:/* @__PURE__ */ m(`span`,{className:`visually-hidden`,children:`Expand`})}),E&&/* @__PURE__ */ m(`th`,{className:$.className,style:$.style,children:/* @__PURE__ */ m(`input`,{ref:kt,type:`checkbox`,className:`wui-check`,checked:Dt,disabled:C,onChange:e=>Mt(e.target.checked),"aria-label":`Select all rows`})}),g.map((e,t)=>{let r=!!(e.sortable&&S),i=x&&x.key===e.key,a=e.align===`num`||e.align===`end`,o=r&&/* @__PURE__ */ m(`span`,{className:`sort-icon${a?` wui-sort-lead`:``}`,children:/* @__PURE__ */ m(n,{name:`chevrons-up-down`,size:14})}),s=M&&t!==Tt,c=e.width||e.minWidth?{width:e.width,minWidth:e.minWidth}:void 0;return/* @__PURE__ */ h(`th`,{className:H(V+t,(r?`sortable `:``)+(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+(e.grow?`wui-col-grow `:``)+(s?`wui-col-resizable `:``)+v(e.align)).className,style:U(V+t,c),"data-key":B?e.key:void 0,"aria-label":s&&typeof e.label==`string`?e.label:void 0,"data-pin":e.pin===`start`||e.pin===`end`?e.pin:void 0,tabIndex:r?0:void 0,"aria-sort":i?x.dir===`asc`?`ascending`:`descending`:r?`none`:void 0,onClick:r?()=>{C||S(e.key)}:void 0,onKeyDown:r?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),C||S(e.key))}:void 0,children:[a&&o,e.label,!a&&o,s&&/* @__PURE__ */ m(`span`,{className:`wui-col-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":oe,"aria-valuemax":ae,tabIndex:0,"aria-label":se.resize(typeof e.label==`string`?e.label:e.key)})]},e.key)}),w&&(Re?/* @__PURE__ */ m(`th`,{className:`wui-cell-end`,children:Re}):/* @__PURE__ */ m(`th`,{className:`wui-cell-end`,children:/* @__PURE__ */ m(`span`,{className:`visually-hidden`,children:`Actions`})}))]})}),/* @__PURE__ */ m(`tbody`,{ref:Vt,children:C?Qt():y?.length?/* @__PURE__ */ h(re,{children:[Zt(`before`,X.before),q.slice(X.start,X.end).map((e,t)=>Xt(e,X.start+t)),Zt(`after`,X.after)]}):null}),gt&&!C&&y?.length>0&&/* @__PURE__ */ m(`tfoot`,{children:/* @__PURE__ */ h(`tr`,{children:[L&&/* @__PURE__ */ m(`td`,{className:Q.className,style:Q.style}),E&&/* @__PURE__ */ m(`td`,{className:$.className,style:$.style}),g.map((e,t)=>/* @__PURE__ */ m(`td`,{className:H(V+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+v(e.align)).className,style:U(V+t,void 0),children:e.footer?e.footer(y):null},e.key)),w&&/* @__PURE__ */ m(`td`,{})]})})]}),!C&&!y?.length&&/* @__PURE__ */ m(`div`,{className:`tbl-empty-block`,children:typeof Z==`string`?/* @__PURE__ */ m(`div`,{className:`tbl-empty-plain`,children:Z}):Z})]}),Ne(T)&&/* @__PURE__ */ m(i,{page:T.page,totalPages:T.totalPages,total:T.total,pageSize:T.pageSize,onPageChange:C?ke:T.setPage,onPageSizeChange:C?ke:T.setPageSize,pageSizes:T.pageSizes,mode:T.mode,summary:T.summary}),Gt&&/* @__PURE__ */ m(`div`,{ref:Kt,className:`visually-hidden`,role:`status`,"aria-live":`polite`,"data-wui-table-status":``})]})}export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./
|
|
1
|
+
import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppInfoTip.js";import i from"./AppRequiredMark.js";import a from"./useWuiControl.js";import o from"./warnInvalidValue.js";import s from"./warnUnknownProps.js";import{cloneElement as c,forwardRef as l,useId as u}from"react";import{jsx as d,jsxs as f}from"react/jsx-runtime";import"@webority/ui-elements/elements/datepicker";var p=[`sm`,`md`,`lg`],m=l(function(l,m){let{marker:h,props:g}=n(`AppDatePicker`,l),{value:_,onChange:v,label:y,required:b=!1,optional:x=!1,optionalLabel:S=`(optional)`,helperText:C,error:w,name:T,min:E,max:D,placeholder:O=`Choose a date`,disabled:k,readOnly:A=!1,loading:j=!1,defaultValue:M,help:N,helpLabel:P=`More information`,size:F,firstDay:I,displayFormat:L,id:R,ariaLabel:z,className:B=``,fieldClassName:V=``,...H}=g;s(`AppDatePicker`,H),o(`AppDatePicker`,`size`,F,p),typeof L==`string`&&L!==``&&/DD|YYYY|YY/.test(L)&&e(`[@webority/ui-react] <AppDatePicker> displayFormat "${L}" uses uppercase day or year tokens, which print as written; the tokens are yyyy, MMMM, MMM, MM, dd and d.`);let U=u(),W=R||U,{setRef:G}=a({ref:m,value:_??(M===void 0?``:void 0),defaultValue:M,onChange:v}),K=!y&&!w&&!C,q=w?`${W}-error`:void 0,J=C?`${W}-hint`:void 0,Y=/* @__PURE__ */ d(`wui-datepicker`,{ref:G,id:W,name:T,value:(_??M)||void 0,min:E,max:D,placeholder:O,size:F||void 0,"first-day":I==null?void 0:String(I),"display-format":L||void 0,"aria-label":z||(typeof y==`string`?y:void 0),"aria-describedby":q||J,"aria-invalid":w?`true`:void 0,disabled:k?``:void 0,readonly:A?``:void 0,loading:j?``:void 0,required:b?``:void 0,className:B||void 0,...H});return K?c(Y,h):/* @__PURE__ */ f(`div`,{...h,className:`field${V?` ${V}`:``}`,children:[y&&/* @__PURE__ */ f(`label`,{className:`label`,htmlFor:W,children:[y,x&&!b&&/* @__PURE__ */ d(`span`,{className:`label-optional`,children:` ${S}`}),b&&/* @__PURE__ */ d(i,{}),N&&/* @__PURE__ */ d(r,{label:P,children:N})]}),Y,/* @__PURE__ */ d(t,{error:w,hint:C,errorId:q,hintId:J})]})});export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../lib/FieldMessage.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./
|
|
1
|
+
import e from"../lib/FieldMessage.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./AppInfoTip.js";import r from"./AppRequiredMark.js";import i from"./useWuiControl.js";import a from"./warnInvalidValue.js";import o from"./warnUnknownProps.js";import{cloneElement as s,forwardRef as c,useEffect as ee,useId as l,useRef as u}from"react";import{jsx as d,jsxs as f}from"react/jsx-runtime";import"@webority/ui-elements/elements/date-range";var te=[`sm`,`md`,`lg`],p=e=>{if(e?.length)return e.every(e=>typeof e==`string`)?e.join(`,`):JSON.stringify(e)},m=c(function(c,m){let{marker:h,props:g}=t(`AppDateRangePicker`,c),{start:_,end:v,defaultStart:y,defaultEnd:b,onChange:x,label:S,help:C,helpLabel:ne=`More information`,required:w=!1,optional:re=!1,optionalLabel:T=`(optional)`,helperText:E,error:D,startName:O,endName:k,min:A,max:j,placeholder:M=`Start to End`,disabled:N,readOnly:P=!1,loading:F=!1,size:I,firstDay:L,timeZone:R,financialYearStart:z,presets:B,id:V,ariaLabel:H,className:U=``,fieldClassName:W=``,...G}=g;o(`AppDateRangePicker`,G),a(`AppDateRangePicker`,`size`,I,te);let K=l(),q=V||K,{setRef:J,innerRef:Y}=i({ref:m,onChange:x}),X=u(!1);ee(()=>{let e=Y.current;if(!e)return;let t=_===void 0?!X.current&&y!==void 0?y:e.value.start:_,n=v===void 0?!X.current&&b!==void 0?b:e.value.end:v;(e.value.start!==t||e.value.end!==n)&&(e.value={start:t,end:n}),X.current=!0},[_,v,y,b,Y]);let ie=!S&&!D&&!E,Z=D?`${q}-error`:void 0,Q=E?`${q}-hint`:void 0,ae=Z||Q,$=/* @__PURE__ */ d(`wui-date-range`,{ref:J,id:q,"start-name":O,"end-name":k,min:A,max:j,placeholder:M,size:I||void 0,"first-day":L==null?void 0:String(L),"time-zone":R||void 0,"financial-year-start":z==null?void 0:String(z),presets:p(B),"aria-label":H||(typeof S==`string`?S:void 0),"aria-describedby":ae,"aria-invalid":D?`true`:void 0,disabled:N?``:void 0,readonly:P?``:void 0,loading:F?``:void 0,required:w?``:void 0,className:U||void 0,...G});return ie?s($,h):/* @__PURE__ */ f(`div`,{...h,className:`field${W?` ${W}`:``}`,children:[S&&/* @__PURE__ */ f(`label`,{className:`label`,htmlFor:q,children:[S,re&&!w&&/* @__PURE__ */ d(`span`,{className:`label-optional`,children:` ${T}`}),w&&/* @__PURE__ */ d(r,{}),C&&/* @__PURE__ */ d(n,{label:ne,children:C})]}),$,/* @__PURE__ */ d(e,{error:D,hint:E,errorId:Z,hintId:Q})]})});export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isEmpty as e}from"../lib/emptyValue.js";import{
|
|
1
|
+
import{isEmpty as e}from"../lib/emptyValue.js";import{linkTarget as t}from"../lib/linkTarget.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./renderIconProp.js";import i from"./warnInvalidValue.js";import a from"./warnUnknownProps.js";import{jsx as o,jsxs as s}from"react/jsx-runtime";var c=[`sm`,`md`],l=[`grid`,`summary`,`list`],u=[1,2,3,4];function d(d){let{marker:f,props:p}=n(`AppDescriptions`,d),{items:m=[],columns:h=2,size:g=`md`,bordered:_=!1,layout:v=`grid`,title:y,linkComponent:b,className:x=``,...S}=p;a(`AppDescriptions`,S),i(`AppDescriptions`,`columns`,h,u),i(`AppDescriptions`,`size`,g,c),i(`AppDescriptions`,`layout`,v,l);let C=[`descs`,`descs-col-${h}`,g&&g!==`md`?`descs-${g}`:``,_?`descs-bordered`:``,v===`summary`?`wui-descs-summary`:``,v===`list`?`wui-descs-list`:``,h===4?`wui-descs-col-4`:``,x].filter(Boolean).join(` `)||void 0;return/* @__PURE__ */ s(`div`,{className:C,...f,...S,children:[y&&/* @__PURE__ */ o(`div`,{className:`descs-title`,children:y}),/* @__PURE__ */ o(`dl`,{className:`descs-list`,children:m.map((n,i)=>{let a=e(n.value),c=Math.min(12,Math.max(1,n.span??1)),l=n.key??`${n.label}-${i}`,u=a?`-`:n.value,{Tag:d,linkProps:f}=t(b,{href:n.href});return/* @__PURE__ */ s(`div`,{className:`descs-item${n.emphasis?` wui-descs-emphasis`:``} wui-descs-span-${c}`,children:[n.icon&&/* @__PURE__ */ o(`span`,{className:`wui-descs-icon`,children:r(n.icon,{size:16})}),/* @__PURE__ */ o(`dt`,{className:`descs-label`,children:n.label}),/* @__PURE__ */ o(`dd`,{className:`descs-value${a?` is-empty`:``}${n.multiline&&!a?` wui-pre-line`:``}`,children:n.href?/* @__PURE__ */ o(d,{className:`wui-descs-link`,...f,children:u}):u})]},l)})})]})}export{d as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../lib/DiscardPrompt.js";import{lockPageScroll as t}from"../lib/pageScrollLock.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppIcon.js";import i from"./warnInvalidValue.js";import a from"./warnUnknownProps.js";import{useEffect as o,useRef as s,useState as c}from"react";import{jsx as l,jsxs as u}from"react/jsx-runtime";import"@webority/ui-elements/elements/drawer";var d=[`end`,`start`],f=[`sm`,`md`,`lg`,`xl`],p=[50,90],m=e=>Array.isArray(e)&&e.length>0&&e.every(e=>Number.isFinite(e)&&e>=10&&e<=100);function h(h){let{marker:g,props:_}=n(`AppDrawer`,h),{open:v=!1,onClose:y,title:b,titleIcon:x,header:S,subtitle:C,ariaLabel:w,side:T=`end`,size:E=`md`,width:D,maxWidth:O,snapPoints:k=p,defaultSnap:A=0,sheet:j=!0,onSnapChange:M,onOpened:N,onClosed:P,dismissible:F=!0,closeLabel:I=`Close`,staticBackdrop:
|
|
1
|
+
import e from"../lib/DiscardPrompt.js";import{lockPageScroll as t}from"../lib/pageScrollLock.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppIcon.js";import i from"./warnInvalidValue.js";import a from"./warnUnknownProps.js";import{useEffect as o,useRef as s,useState as c}from"react";import{jsx as l,jsxs as u}from"react/jsx-runtime";import"@webority/ui-elements/elements/drawer";var d=[`end`,`start`],f=[`sm`,`md`,`lg`,`xl`],p=[50,90],m=e=>Array.isArray(e)&&e.length>0&&e.every(e=>Number.isFinite(e)&&e>=10&&e<=100);function h(h){let{marker:g,props:_}=n(`AppDrawer`,h),{open:v=!1,onClose:y,title:b,titleIcon:x,header:S,subtitle:C,ariaLabel:w,side:T=`end`,size:E=`md`,width:D,maxWidth:O,snapPoints:k=p,defaultSnap:A=0,sheet:j=!0,onSnapChange:M,onOpened:N,onClosed:P,dismissible:F=!0,closeLabel:I=`Close`,sheetHeightLabel:L=`Sheet height`,staticBackdrop:R=!1,confirmDiscard:z,dirty:B=!1,headerClassName:V=``,bodyClassName:H=``,footer:U,className:W=``,style:G,children:K,...q}=_;a(`AppDrawer`,q),i(`AppDrawer`,`side`,T,d),i(`AppDrawer`,`size`,E,f),i(`AppDrawer`,`snapPoints`,m(k)?void 0:JSON.stringify(k),[`an array of numbers from 10 to 100`]);let J=s(null),Y=s(null),X=s(null),[Z,Q]=c(!1);Y.current={onClose:y,onSnapChange:M,onOpened:N,onClosed:P,confirmDiscard:z,dirty:B},o(()=>{v||Q(!1)},[v]),o(()=>{Z&&X.current?.focus()},[Z]),o(()=>{if(v)return t()},[v]),o(()=>{let e=J.current;if(!e)return;let t=t=>{t.target===e&&(t.preventDefault(),Y.current.confirmDiscard&&Y.current.dirty?Q(!0):Y.current.onClose?.())},n=t=>{t.target===e&&Y.current.onSnapChange?.(t.detail.index,t.detail.percent)},r=t=>{t.target===e&&Y.current.onOpened?.()},i=t=>{t.target===e&&Y.current.onClosed?.()},a=n=>{n.target.closest?.(`[data-wui-dismiss]`)&&t({target:e,preventDefault(){}})};return e.addEventListener(`wui-drawer-close`,t),e.addEventListener(`wui-drawer-snap`,n),e.addEventListener(`wui-drawer-opened`,r),e.addEventListener(`wui-drawer-closed`,i),e.addEventListener(`click`,a),()=>{e.removeEventListener(`wui-drawer-close`,t),e.removeEventListener(`wui-drawer-snap`,n),e.removeEventListener(`wui-drawer-opened`,r),e.removeEventListener(`wui-drawer-closed`,i),e.removeEventListener(`click`,a)}},[]);let $=()=>{Q(!1),J.current?.dispatchEvent(new CustomEvent(`wui:drawer:discard`,{bubbles:!0})),Y.current.onClose?.()},ee=m(k)?k:p,te={...D&&{"--wui-drawer-width":D},...O&&{"--wui-drawer-max-width":O},...G};return/* @__PURE__ */ u(`wui-drawer`,{ref:J,...g,...q,class:[`wui-drawer`,W].filter(Boolean).join(` `),side:T,size:E,"snap-points":ee.join(`,`),"default-snap":String(A),static:R?``:void 0,"no-sheet":j?void 0:``,"confirm-discard":z||void 0,open:v?``:void 0,style:te,children:[/* @__PURE__ */ l(`div`,{className:`wui-drawer-backdrop`,"data-wui-drawer-backdrop":``,"aria-hidden":`true`}),/* @__PURE__ */ u(`div`,{className:`wui-drawer-panel`,role:`dialog`,"aria-modal":`true`,"aria-label":w||b||void 0,tabIndex:-1,children:[j&&/* @__PURE__ */ l(`div`,{className:`wui-drawer-grip`,"data-wui-drawer-grip":``,children:/* @__PURE__ */ l(`div`,{className:`wui-drawer-handle`,role:`slider`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":L})}),S===void 0?/* @__PURE__ */ u(`div`,{className:[`wui-drawer-header`,V].filter(Boolean).join(` `),"data-wui-drawer-grip":j?``:void 0,children:[/* @__PURE__ */ u(`div`,{className:`wui-drawer-headtext`,children:[b&&/* @__PURE__ */ u(`div`,{className:`wui-drawer-title`,children:[x&&/* @__PURE__ */ l(`span`,{className:`wui-drawer-title-ic`,children:/* @__PURE__ */ l(r,{name:x,size:18})}),b]}),C&&/* @__PURE__ */ l(`div`,{className:`wui-drawer-subtitle`,children:C})]}),F&&/* @__PURE__ */ l(`button`,{type:`button`,className:`wui-drawer-close`,"data-wui-drawer-close":``,"aria-label":I,children:/* @__PURE__ */ l(`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__ */ l(`path`,{d:`M18 6 6 18M6 6l12 12`})})})]}):S,/* @__PURE__ */ l(`div`,{className:[`wui-drawer-body`,H].filter(Boolean).join(` `),children:K}),(U||Z)&&/* @__PURE__ */ u(`div`,{className:Z?`wui-drawer-footer wui-drawer-discarding`:`wui-drawer-footer`,children:[Z&&/* @__PURE__ */ l(e,{text:z,confirmRef:X,onDiscard:$,onKeep:()=>Q(!1)}),U]})]})]})}export{h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../lib/FieldMessage.js";import t from"../lib/useFileDrop.js";import{splitMarkerProps as
|
|
1
|
+
import e from"../lib/FieldMessage.js";import t from"../lib/fillLabel.js";import n from"../lib/useFileDrop.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppIcon.js";import a from"./warnUnknownProps.js";import{DEFAULT_MAX_SIZE_MB as o,acceptDroppedFiles as s,acceptLabel as c}from"@webority/ui-elements/helpers";import{useId as l,useState as u}from"react";import{jsx as d,jsxs as f}from"react/jsx-runtime";function p(p){let{marker:m,props:h}=r(`AppDropZone`,p),{label:g,id:_,onChange:v,multiple:y=!1,accept:b=``,maxSizeMb:x=o,error:S,helperText:C,disabled:w=!1,className:T=``,fieldClassName:E=``,style:D,browseLabel:O=`Click to upload`,dropLabel:k=`or drag & drop`,anyTypeText:A=`Any file type`,maxSizeText:j=`up to {size} MB`,...M}=h;a(`AppDropZone`,M);let[N,P]=u(``),F=l(),I=_||F,L=S||N,R=L?`${I}-error`:void 0,z=C&&!L?`${I}-hint`:void 0,B=R||z,V=b?c(b):A,H={accept:b,maxSizeMb:x,multiple:y},U=e=>{P(``),v(y?e:e[0])},W=e=>P(e.message),{dragOver:G,dropProps:K}=n({...H,disabled:w,onFiles:U,onReject:W}),q=e=>{let{files:t,rejections:n}=s(e,H);(t.length||n.length)&&(t.length&&U(t),n.length&&W(n[0]))};return/* @__PURE__ */ f(`div`,{...m,className:`field${E?` ${E}`:``}`,children:[g?/* @__PURE__ */ d(`label`,{className:`label`,htmlFor:I,children:g}):null,/* @__PURE__ */ f(`div`,{className:`file-input file-input-tall${G?` dragging`:``}${L?` error`:``}${T?` ${T}`:``}`,style:D,"aria-disabled":w||void 0,...K,children:[/* @__PURE__ */ f(`label`,{htmlFor:I,className:`file-input-zone-label`,children:[/* @__PURE__ */ d(`span`,{className:`file-input-icon`,children:/* @__PURE__ */ d(i,{name:`upload`,size:24})}),/* @__PURE__ */ f(`span`,{className:`file-input-title`,children:[/* @__PURE__ */ d(`span`,{className:`browse`,children:O}),` ${k}`]}),/* @__PURE__ */ d(`span`,{className:`file-input-text`,children:x>0?`${V}, ${t(j,{size:x})}`:V})]}),/* @__PURE__ */ d(`input`,{id:I,type:`file`,"aria-describedby":B,accept:b,multiple:y||void 0,disabled:w||void 0,className:`visually-hidden`,onClick:e=>{e.currentTarget.value=``},onChange:e=>q(e.target.files),...M})]}),/* @__PURE__ */ d(e,{error:L,hint:C,errorId:R,hintId:z})]})}export{p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{devWarn as e}from"../lib/devWarn.js";import{shortcutAria as t,shortcutChip as n}from"../lib/shortcutChip.js";import{
|
|
1
|
+
import{devWarn as e}from"../lib/devWarn.js";import{shortcutAria as t,shortcutChip as n}from"../lib/shortcutChip.js";import{TONES as r}from"../lib/vocabulary.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./AppIcon.js";import o from"./renderIconProp.js";import s from"./warnInvalidValue.js";import c from"./warnUnknownProps.js";import l from"./withTooltip.js";import{Fragment as u,forwardRef as d,useEffect as f,useRef as p,useState as m}from"react";import{Dropdown as h}from"react-bootstrap";import{jsx as g,jsxs as _}from"react/jsx-runtime";var v=[`sm`,`md`,`lg`,`xl`],y=[`neutral`],b=[`sm`,`md`,`lg`],x=e=>{e.preventDefault(),e.stopPropagation()},S=d(function(e,t){return/* @__PURE__ */ g(`button`,{...e,ref:t,"aria-disabled":`true`})}),C=!1;function w(){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!C&&(C=!0,e("[@webority/ui-react] <AppDropdown> icon-only toggle has no accessible name — pass `label` or `ariaLabel`."))}function T(a){let{marker:d,props:C}=i(`AppDropdown`,a),{icon:T,iconSize:D,toggleClassName:O,toggleVariant:k,menuWidth:A,label:j,ariaLabel:M,align:N=`end`,items:P=[],menuClassName:F=``,linkComponent:I,children:L,trigger:R,open:z,onOpenChange:B,...V}=C;c(`AppDropdown`,V);for(let e of P)s(`AppDropdown`,`items[].hiddenFrom`,e.hiddenFrom,v),s(`AppDropdown`,`items[].tone`,e.tone,r);R||M||j||w(),s(`AppDropdown`,`toggleVariant`,k,y),s(`AppDropdown`,`menuWidth`,A,b),k&&!R&&e(`AppDropdown: toggleVariant needs a trigger; the icon toggle ignores it.`);let H=(O??(R?`wui-dropdown-trigger`:`topbar-icon-btn`))+(R&&k===`neutral`?` wui-dropdown-trigger-neutral`:``),U=[F,b.includes(A)?`wui-dropdown-menu-${A}`:``].filter(Boolean).join(` `),W=z!==void 0,[G,K]=m(!1),q=W?!!z:G,J=p(null);J.current=(e,t)=>{W||K(e),B?.(e,t)};let Y=p(null);return f(()=>{if(!q)return;let e=Y.current?.getBoundingClientRect(),t=()=>{let t=Y.current?.getBoundingClientRect();(!e||!t||Math.abs(t.top-e.top)>2||Math.abs(t.left-e.left)>2)&&J.current(!1,{source:`scroll`})},n=()=>J.current(!1,{source:`resize`});return window.addEventListener(`scroll`,t,{capture:!0,passive:!0}),window.addEventListener(`resize`,n),()=>{window.removeEventListener(`scroll`,t,{capture:!0}),window.removeEventListener(`resize`,n)}},[q]),/* @__PURE__ */ _(h,{ref:Y,align:N,show:q,onToggle:(e,t)=>J.current(e,t),...d,...V,children:[/* @__PURE__ */ g(h.Toggle,{as:E,icon:T,iconSize:D,btnClassName:H,trigger:R,title:j,"aria-label":M??(R?void 0:j)}),/* @__PURE__ */ g(h.Menu,{className:U,renderOnMount:!0,popperConfig:{strategy:`fixed`},children:L??P.map(e=>{if(e.header!=null)return/* @__PURE__ */ g(`div`,{className:`dropdown-header`,children:e.header},e.key);if(e.divider)return/* @__PURE__ */ g(h.Divider,{},e.key);if(e.disabled)return/* @__PURE__ */ g(u,{children:l(/* @__PURE__ */ _(h.Item,{as:S,type:`button`,className:[e.tone===`danger`&&`danger`,`wui-dropdown-item-disabled`].filter(Boolean).join(` `),onClick:x,children:[e.image?/* @__PURE__ */ g(`img`,{src:e.image,alt:``}):o(e.icon,{size:16}),e.label,e.disabledReason&&/* @__PURE__ */ _(`span`,{className:`visually-hidden wui-dropdown-item-reason`,children:[`: `,e.disabledReason]})]}),e.disabledReason,`auto`)},e.key);let r=e.to?I?{as:I,to:e.to}:{as:`a`,href:e.to}:{as:`button`,type:`button`},i=[e.tone===`danger`&&`danger`,v.includes(e.hiddenFrom)&&`wui-hidden-from-${e.hiddenFrom}`].filter(Boolean).join(` `)||void 0;return/* @__PURE__ */ _(h.Item,{...r,onClick:e.onClick,className:i,"aria-keyshortcuts":t(e.shortcut),children:[e.image?/* @__PURE__ */ g(`img`,{src:e.image,alt:``}):o(e.icon,{size:16}),e.label,n(e.shortcut)]},e.key)})})]})}var E=d(function({icon:e,iconSize:t=20,btnClassName:n=`topbar-icon-btn`,trigger:r,"aria-label":i,className:o,...s},c){return/* @__PURE__ */ g(`button`,{ref:c,type:`button`,className:n,"aria-label":i,...s,children:r??/* @__PURE__ */ g(a,{name:e,size:t})})});export{T as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{splitMarkerProps as
|
|
1
|
+
import e from"../lib/fillLabel.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./AppIcon.js";import r from"./warnInvalidValue.js";import i from"./warnUnknownProps.js";import{formatDate as a,toInstant as o}from"@webority/ui-elements/helpers";import{jsx as s,jsxs as c}from"react/jsx-runtime";var l=864e5,u=198e5,d=14,f=[`days`,`due`],p=e=>Math.floor((e+u)/l),m=(...e)=>e.filter(Boolean).join(` `),h=(t,n,r)=>t===`due`?n===0?r.dueTodayLabel:n===1?r.dueTomorrowLabel:e(r.dueInLabel,{days:n}):n===1?r.oneDayLeftLabel:e(r.daysLeftLabel,{days:n});function g(u){let{marker:g,props:_}=t(`AppDueDate`,u),{date:v,soonDays:y,soonWording:b=`days`,icon:x=!1,overdue:S=!1,overdueLabel:C,notSetLabel:w=`Not set`,dueTodayLabel:T=`Due today`,dueTomorrowLabel:E=`Due tomorrow`,dueInLabel:D=`Due in {days} days`,daysLeftLabel:O=`{days} days left`,oneDayLeftLabel:k=`1 day left`,overdueSinceLabel:A=`Overdue since {date}`,className:j=``,...M}=_;i(`AppDueDate`,M),r(`AppDueDate`,`soonWording`,b,f);let N=o(v);if(!Number.isFinite(N))return/* @__PURE__ */ s(`wui-due-date`,{class:m(`wui-due-date`,`wui-due-date-empty`,j),...g,...M,children:/* @__PURE__ */ s(`time`,{children:w})});let P=p(N),F=(/* @__PURE__ */ new Date(P*l)).toISOString().slice(0,10),I=P-p(Date.now()),L=x?/* @__PURE__ */ s(n,{name:`calendar`,size:d}):null;if(S){let t=a(N);return/* @__PURE__ */ c(`wui-due-date`,{class:m(`wui-due-date`,`wui-due-date-danger`,j),title:e(A,{date:t}),...g,...M,children:[/* @__PURE__ */ s(n,{name:`danger`,size:d}),L,/* @__PURE__ */ s(`time`,{dateTime:F,children:C||t})]})}return Number.isFinite(y)&&I>=0&&I<=y?/* @__PURE__ */ c(`wui-due-date`,{class:m(`wui-due-date`,`wui-due-date-warning`,j),...g,...M,children:[L,/* @__PURE__ */ s(`time`,{dateTime:F,children:h(b,I,{dueTodayLabel:T,dueTomorrowLabel:E,dueInLabel:D,daysLeftLabel:O,oneDayLeftLabel:k})})]}):/* @__PURE__ */ c(`wui-due-date`,{class:m(`wui-due-date`,j),...g,...M,children:[L,/* @__PURE__ */ s(`time`,{dateTime:F,children:a(N)})]})}export{g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{devWarn as e}from"../lib/devWarn.js";import t,{ILLUSTRATION_NAMES as n}from"../lib/emptyIllustration.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./renderIconProp.js";import a from"./warnInvalidValue.js";import o from"./warnUnknownProps.js";import{jsx as s,jsxs as c}from"react/jsx-runtime";var l=[`md`,`sm`],u=[`card`,`table`],d=!1;function f(f){let{marker:p,props:m}=r(`AppEmptyState`,f),{icon:h,illustration:g,iconSize:_=24,size:v=`md`,variant:y=`card`,title:b,
|
|
1
|
+
import{devWarn as e}from"../lib/devWarn.js";import t,{ILLUSTRATION_NAMES as n}from"../lib/emptyIllustration.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./renderIconProp.js";import a from"./warnInvalidValue.js";import o from"./warnUnknownProps.js";import{jsx as s,jsxs as c}from"react/jsx-runtime";var l=[`md`,`sm`],u=[`card`,`table`],d=!1;function f(f){let{marker:p,props:m}=r(`AppEmptyState`,f),{icon:h,illustration:g,iconSize:_=24,size:v=`md`,variant:y=`card`,title:b,description:x,action:S,className:C=``,style:w,...T}=m;o(`AppEmptyState`,T),a(`AppEmptyState`,`size`,v,l),a(`AppEmptyState`,`variant`,y,u),y===`table`&&v===`sm`&&!d&&(d=!0,e(`[@webority/ui-react] <AppEmptyState> size="sm" has no table look; variant="table" uses the md scale.`)),typeof g==`string`&&a(`AppEmptyState`,`illustration`,g,n);let E=typeof g==`string`&&n.includes(g),D=g!=null&&typeof g!=`string`?g:null,O=[`empty-state`,v===`sm`?`empty-state-sm`:``,y===`table`?`wui-empty-state-table`:``,C].filter(Boolean).join(` `);return/* @__PURE__ */ c(`div`,{className:O,style:w,...p,...T,children:[E?/* @__PURE__ */ s(t,{name:g,className:`wui-empty-illustration`}):null,D?/* @__PURE__ */ s(`span`,{className:`wui-empty-illustration wui-empty-illustration-custom`,"aria-hidden":`true`,children:D}):null,h&&!E&&!D?/* @__PURE__ */ s(`div`,{className:`empty-state-icon`,children:i(h,{size:_})}):null,b!=null&&/* @__PURE__ */ s(`div`,{className:`empty-state-title`,children:b}),x!=null&&/* @__PURE__ */ s(`div`,{className:`empty-state-message`,children:x}),S&&/* @__PURE__ */ s(`div`,{className:`empty-state-action`,children:S})]})}export{f as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"./AppButton.js";import t from"./AppRouteError.js";import n from"./warnUnknownProps.js";import{Component as r}from"react";import{jsx as i}from"react/jsx-runtime";var a=()=>window.location.reload(),o=(e=[],t=[])=>e.length===t.length&&e.every((e,n)=>Object.is(e,t[n])),s=class extends r{state={error:null,hasError:!1};static getDerivedStateFromError(e){return{error:e,hasError:!0}}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e){this.state.hasError&&!o(e.resetKeys,this.props.resetKeys)&&this.reset()}reset=()=>{this.props.onReset?.(),this.setState({error:null,hasError:!1})};render(){let{children:r,fallback:o,homeHref:s=`/`,brand:c,onError:l,onReset:u,resetKeys:d,...f}=this.props;return n(`AppErrorBoundary`,f),this.state.hasError?typeof o==`function`?o({error:this.state.error,reset:this.reset}):o===void 0?/* @__PURE__ */ i(t,{kind:`error`,fullPage:!1,homeHref:s,brand:c,onRetry:this.reset,children:/* @__PURE__ */ i(e,{variant:`ghost`,leftIcon:`refresh-cw`,onClick:a,children:`Reload the page`})}):o:r}};function c({children:e,fallback:t,onError:n,resetKeys:r,onReset:a,homeHref:o,brand:c}){return/* @__PURE__ */ i(s,{fallback:t,onError:n,resetKeys:r,onReset:a,homeHref:o,brand:c,children:e})}export{c as default};
|
|
@@ -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/useFileDrop.js";import{splitMarkerProps 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{linkTarget as u}from"../lib/linkTarget.js";import d from"../lib/useFileDrop.js";import{splitMarkerProps as f}from"../lib/wuiMarker.js";import p from"./AppIcon.js";import m from"./AppProgress.js";import h from"./warnUnknownProps.js";import{DEFAULT_IMAGE_ACCEPT as g,DEFAULT_MAX_SIZE_MB as _,acceptDroppedFiles as v,acceptLabel as y,isImageFile as b,isImageOnlyAccept as x}from"@webority/ui-elements/helpers";import{useId as S,useState as C}from"react";import{Fragment as w,jsx as T,jsxs as E}from"react/jsx-runtime";function D(i){let{marker:a,props:o}=f(`AppFileAttachment`,i),{label:s=`Attachment`,value:c,name:l,onChange:u,multiple:m=!1,accept:y=g,maxSizeMb:D=_,optional:A=!1,validate:j=!0,error:M,id:N,linkComponent:P,browseLabel:F=`Browse`,removeLabel:I=`Remove attachment`,uploadingLabel:ee=`Uploading {name}`,maxSizeText:te=`Up to {size} MB`,typesAndMaxSizeText:ne=`{types}, up to {size} MB`,removeFileLabel:re=`Remove {name}`,optionalLabel:L=`(optional)`,dropTitle:R,...z}=o;h(`AppFileAttachment`,z);let B=S(),V=N||B,[H,U]=C(``),W=m&&Array.isArray(c)?c:c?[c]:[],G=x(y),K=e=>e instanceof File?b(e):G||b(e),q=!m&&W.length===1&&K(W[0])&&(W[0]instanceof File||r(W[0])!==null),J=O(y,D,te,ne),Y=j?{accept:y,maxSizeMb:D,multiple:m}:{accept:``,maxSizeMb:0,multiple:m};function X(e){if(U(``),m){let t=Array.isArray(c)?c:c?[c]:[],r=new Set(t.map(n)),i=t.concat(e.filter(e=>!r.has(n(e))));u(i)}else u(e[0])}function ie(e){if(!e.length)return;let{files:t,rejections:n}=v(e,Y);t.length&&X(t),U(n[0]?.message??``)}let{dragOver:ae,dropProps:oe}=d({...Y,disabled:z.disabled,onFiles:X,onReject:e=>U(e.message)});function se(e){let t=Array.from(e.target.files||[]);e.target.value=``,ie(t)}function Z(e){U(``),u(m?W.filter((t,n)=>n!==e):null)}let Q=M||H,ce=Q?`${V}-error`:void 0,le=m||W.length===0,$=G?`image`:`file`,ue=R??(m?`Add ${$}s`:`Add ${G?`an`:`a`} ${$}`);return/* @__PURE__ */ E(`div`,{...a,className:`field`,children:[/* @__PURE__ */ E(`label`,{className:`label`,htmlFor:V,children:[s,A&&/* @__PURE__ */ T(`span`,{className:`label-optional`,children:` ${L}`})]}),le&&/* @__PURE__ */ E(w,{children:[/* @__PURE__ */ E(`label`,{className:`attach-drop${ae?` dragging`:``}`,htmlFor:V,...oe,children:[/* @__PURE__ */ T(`span`,{className:`attach-drop-icon`,children:/* @__PURE__ */ T(p,{name:G?`image`:`file-text`,size:18})}),/* @__PURE__ */ E(`span`,{className:`attach-drop-copy`,children:[/* @__PURE__ */ T(`span`,{className:`attach-drop-title`,children:ue}),J&&/* @__PURE__ */ T(`span`,{className:`attach-drop-hint`,children:J})]}),/* @__PURE__ */ T(`span`,{className:`attach-drop-cta`,children:F})]}),/* @__PURE__ */ T(`input`,{id:V,type:`file`,className:`visually-hidden`,name:l,accept:y||void 0,multiple:m||void 0,"aria-describedby":ce,onChange:se,...z})]}),q?/* @__PURE__ */ T(k,{item:W[0],isImage:!0,linkComponent:P,onRemove:()=>Z(0),removeLabel:I,uploadingLabel:ee}):W.length>0&&/* @__PURE__ */ T(`div`,{className:`attach-list`,children:W.map((e,r)=>/* @__PURE__ */ T(t,{item:e,isImage:K(e),linkComponent:P,onRemove:()=>Z(r),removeFileLabel:re},n(e)))}),/* @__PURE__ */ T(e,{error:Q,errorId:`${V}-error`})]})}function O(e,t,n,r){let i=e?.trim()?y(e):``,a=t>0;return i&&a?l(r,{types:i,size:t}):a?l(n,{size:t}):i}function k({item:e,isImage:t,linkComponent:n,onRemove:d,removeLabel:f,uploadingLabel:h}){let g=c(e,t),_=i(e),v=a(e),y=s(e),b=o(e),x=r(e),{Tag:S,linkProps:C}=u(n,{to:e?.to,href:x,routeHref:!1});return/* @__PURE__ */ E(`div`,{className:b?`attach-preview wui-attach-failed`:`attach-preview`,children:[/* @__PURE__ */ E(`div`,{className:`attach-figure`,children:[/* @__PURE__ */ T(`img`,{src:g,alt:_}),/* @__PURE__ */ T(`button`,{type:`button`,className:`attach-remove`,"aria-label":f,onClick:d,children:/* @__PURE__ */ T(p,{name:`x`,size:18})})]}),/* @__PURE__ */ E(`div`,{className:`attach-meta`,children:[/* @__PURE__ */ T(`div`,{className:`attach-name`,children:x||e?.to?/* @__PURE__ */ T(S,{...C,children:_}):_}),v&&/* @__PURE__ */ T(`div`,{className:`attach-size`,children:v})]}),y!==null&&/* @__PURE__ */ T(m,{value:y,size:`sm`,label:l(h,{name:_}),className:`wui-attach-progress`}),b&&/* @__PURE__ */ T(`div`,{className:`wui-attach-error`,children:b})]})}export{D 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{
|
|
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 ee}from"../lib/wuiMarker.js";import s from"./AppIcon.js";import te from"./AppInfoTip.js";import ne from"./AppRequiredMark.js";import re from"./AppSpinner.js";import ie from"./warnInvalidValue.js";import ae from"./warnUnknownProps.js";import oe from"./withTooltip.js";import{DEFAULT_MAX_SIZE_MB as se,acceptDroppedFiles as ce,acceptLabel as c,isImageFile as l,isImageOnlyAccept as le,isPdfFile as ue}from"@webority/ui-elements/helpers";import{useEffect as u,useId as de,useRef as fe,useState as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";var pe=[`dropzone`,`button`],me={sm:` input-sm`,md:``,lg:` input-lg`};function m(m){let{marker:he,props:ge}=ee(`AppFilePicker`,m),{label:h,value:g,name:_e,id:ve,onChange:_,multiple:v=!1,variant:y=`dropzone`,buttonLabel:ye=`Add file`,browseLabel:be=`Click to upload`,dropLabel:xe=`or drag & drop`,maxSizeText:Se=`up to {size} MB`,optionalLabel:Ce=`(optional)`,changeImageLabel:we=`Change image`,changeFileLabel:Te=`Change file`,maxFilesText:Ee=`Up to {count} files.`,removeFileLabel:De=`Remove {name}`,maxFiles:b,accept:x=`.jpg,.jpeg,.png`,maxSizeMb:S=se,required:C,optional:Oe=!1,error:ke,helperText:w,help:T,helpLabel:Ae=`More information`,loading:E=!1,readOnly:D=!1,size:O=`md`,disabled:k=!1,className:A=``,fieldClassName:j=``,style:M,...N}=ge;ae(`AppFilePicker`,N),ie(`AppFilePicker`,`variant`,y,pe),ie(`AppFilePicker`,`size`,O,r);let P=me[O]??``,F=D?{"aria-readonly":`true`,"data-wui-readonly":``}:null,[je,I]=d(null),[Me,L]=d(null),[Ne,R]=d(``),z=fe(null),Pe=de(),B=ve||Pe,V=k||E;u(()=>{if(!v&&g instanceof File&&l(g)){let e=URL.createObjectURL(g);return I(e),()=>URL.revokeObjectURL(e)}I(null)},[g,v]);let H=!v&&g&&!l(g)&&ue(g)?g instanceof File?g:g.url:null;u(()=>{if(!H){L(null);return}let t=!0,n=null;return import(`@webority/ui-elements/file-viewer`).then(e=>e.renderPdfFirstPage(typeof H==`string`?{url:H}:H)).then(e=>{t&&(n=URL.createObjectURL(e),L(n))}).catch(t=>e(`[AppFilePicker] the PDF preview failed:`,t?.message)),()=>{t=!1,L(null),n&&URL.revokeObjectURL(n)}},[H]);let U=v?Array.isArray(g)?g:g?[g]:[]:[],W=ke||Ne,G=W?`${B}-error`:void 0,K=w&&!W?`${B}-hint`:void 0,Fe=G||K,q=le(x),Ie=y===`button`,Le=!v&&!!g,J=Le&&(g instanceof File?l(g):q||l(g)),Re=g?.name,ze=J?g?.url||je:Me,Y=J?`image`:`file`,Be=h?`Change ${h}`:`Change ${Y}`,X=h?`Remove ${h}`:`Remove ${Y}`,Ve=h?`${h} preview`:`Selected ${Y} preview`,He={accept:x,maxSizeMb:S,multiple:v},Ue=e=>{if(R(``),!v){_(e[0]);return}let t=Array.isArray(g)?g:g?[g]:[],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);b&&o.length>b&&(o=o.slice(0,b),R(a(Ee,{count:b}))),_(o)},Z=e=>R(e.message),{dragOver:We,dropProps:Ge}=o({...He,disabled:V||D,onFiles:Ue,onReject:Z}),Ke=e=>{if(D)return;let{files:t,rejections:n}=ce(e,He);t.length&&Ue(t),n.length&&Z(n[0])},qe=e=>Ke(e.target.files),Je=e=>{D||(R(``),_(U.filter((t,n)=>n!==e)))},Ye=()=>{D||z.current?.click()},Q=E?/* @__PURE__ */ f(`span`,{className:`wui-file-busy`,children:/* @__PURE__ */ f(re,{size:`sm`})}):null,$=/* @__PURE__ */ f(`input`,{id:B,name:_e,ref:z,type:`file`,"aria-describedby":Fe,accept:x,multiple:v||void 0,disabled:V||void 0,className:`visually-hidden`,onClick:e=>{D?e.preventDefault():e.currentTarget.value=``},onChange:qe,...N});return/* @__PURE__ */ p(`div`,{...he,className:`field${j?` ${j}`:``}`,children:[/* @__PURE__ */ p(`label`,{className:`label`,htmlFor:B,children:[h,Oe&&!C&&/* @__PURE__ */ f(`span`,{className:`label-optional`,children:` ${Ce}`}),C&&/* @__PURE__ */ f(ne,{}),T&&/* @__PURE__ */ f(te,{label:Ae,children:T})]}),Ie?/* @__PURE__ */ p(`div`,{className:`file-input wui-file-input-button-field${P}${W?` error`:``}${A?` ${A}`:``}`,style:M,"aria-busy":E||void 0,...F,children:[/* @__PURE__ */ p(`label`,{htmlFor:B,className:`btn btn-outline-primary btn-sm`,children:[/* @__PURE__ */ f(s,{name:`paperclip`,size:16}),ye]}),$,Q]}):Le?/* @__PURE__ */ p(`div`,{className:`file-preview${P}${W?` error`:``}${A?` ${A}`:``}`,style:M,"aria-busy":E||void 0,...F,children:[/* @__PURE__ */ p(`button`,{type:`button`,className:`file-preview-open`,"aria-label":Be,onClick:Ye,disabled:V||D,children:[ze?/* @__PURE__ */ f(`img`,{src:ze,alt:Ve,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:Re})]}),/* @__PURE__ */ f(`span`,{className:`file-preview-overlay`,children:/* @__PURE__ */ p(`span`,{className:`file-preview-cta`,children:[/* @__PURE__ */ f(s,{name:J?`image`:`file-text`,size:16}),` `,J?we:Te]})})]}),oe(/* @__PURE__ */ f(`button`,{type:`button`,className:`file-preview-remove`,"aria-label":X,onClick:()=>_(null),disabled:V||D,children:/* @__PURE__ */ f(s,{name:`x`,size:16})}),X),$,Q]}):/* @__PURE__ */ p(`div`,{className:`file-input file-input-tall${P}${We?` dragging`:``}${W?` error`:``}${v&&U.length>0?` has-files`:``}${A?` ${A}`:``}`,style:M,"aria-busy":E||void 0,"aria-disabled":k||void 0,...F,...Ge,children:[/* @__PURE__ */ p(`label`,{htmlFor:B,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:be}),` ${xe}`]}),/* @__PURE__ */ f(`span`,{className:`file-input-text`,children:S>0?`${c(x)}, ${a(Se,{size:S})}`:c(x)})]}),$,Q,v&&U.length>0&&/* @__PURE__ */ f(`div`,{className:`attach-list`,children:U.map((e,t)=>/* @__PURE__ */ f(n,{item:e,isImage:e instanceof File?l(e):q||l(e),noun:`file`,removeFileLabel:De,readOnly:D,onRemove:()=>Je(t)},i(e)))})]}),/* @__PURE__ */ f(t,{error:W,hint:w,errorId:G,hintId:K})]})}export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sizeLabelOf as e}from"../lib/fileItem.js";import{
|
|
1
|
+
import{sizeLabelOf as e}from"../lib/fileItem.js";import{linkTarget as t}from"../lib/linkTarget.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./warnUnknownProps.js";import{Fragment as i,jsx as a,jsxs as o}from"react/jsx-runtime";function s(e){let t=e.lastIndexOf(`.`),n=t>0?e.slice(t+1):``;return n.length>0?n.slice(0,4).toUpperCase():`FILE`}function c(t){let n=e({sizeBytes:t.sizeBytes});return n&&t.meta?/* @__PURE__ */ o(i,{children:[n,` · `,t.meta]}):n||t.meta||null}function l(e){let{marker:l,props:u}=n(`AppFileTiles`,e),{label:d,files:f=[],linkComponent:p,className:m=``,...h}=u;if(r(`AppFileTiles`,h),f.some(e=>!e.name))throw Error(`<AppFileTiles> each file needs a name.`);let g=[`wui-file-tiles`,m].filter(Boolean).join(` `);return/* @__PURE__ */ a(`ul`,{className:g,"aria-label":d,...l,...h,children:f.map(e=>{let{Tag:n,linkProps:r}=t(p,{to:e.to,href:e.href,routeHref:!1}),l=c(e),u=/* @__PURE__ */ o(i,{children:[/* @__PURE__ */ a(`span`,{className:`wui-file-tile-ext`,"aria-hidden":`true`,children:s(e.name)}),/* @__PURE__ */ o(`span`,{className:`wui-file-tile-text`,children:[/* @__PURE__ */ a(`span`,{className:`wui-file-tile-name`,children:e.name}),l?/* @__PURE__ */ a(`span`,{className:`wui-file-tile-meta`,children:l}):null]})]});return/* @__PURE__ */ a(`li`,{children:e.href||e.to?/* @__PURE__ */ a(n,{className:`wui-file-tile`,...r,children:u}):/* @__PURE__ */ a(`div`,{className:`wui-file-tile`,children:u})},e.key)})})}export{l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./AppButton.js";import o from"./AppChip.js";import s from"./AppDateRangePicker.js";import ee from"./AppIcon.js";import c from"./AppMultiSelect.js";import l from"./AppSearch.js";import u from"./AppSegmented.js";import d from"./AppSelect.js";import te from"./AppSwitch.js";import f from"./warnInvalidValue.js";import ne from"./warnUnknownProps.js";import{Fragment as re,useEffect as p,useId as ie,useRef as m,useState as ae,useSyncExternalStore as oe}from"react";import{Fragment as se,jsx as h,jsxs as g}from"react/jsx-runtime";import"@webority/ui-elements/elements/filter-popover";var _=`(max-width: 575.98px)`,ce=3,v=2,le=e=>{let t=window.matchMedia?.(_);return t?.addEventListener(`change`,e),()=>t?.removeEventListener(`change`,e)},ue=()=>window.matchMedia?.(_).matches??!1,de=[`enum`,`multiEnum`,`dateRange`,`text`],fe=[`sm`,`md`],y=4,pe=e=>(e.type===`enum`||e.type===`multiEnum`)&&!e.options?.length,b=(e,t)=>e.options?.find(e=>e.value===t)?.label??t,me=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function he(n,i,a){if(n.required||!t(n,i))return[];if(n.type===`enum`)return[{id:n.key,text:b(n,i),clear:()=>e(n)}];if(n.type===`multiEnum`)return i.map(e=>({id:`${n.key}:${e}`,text:b(n,e),clear:()=>i.filter(t=>t!==e)}));if(n.type===`dateRange`){let t=i.from&&i.to?r(a.range,{from:i.from,to:i.to}):i.from?r(a.from,{date:i.from}):r(a.until,{date:i.to});return[{id:n.key,text:t,clear:()=>e(n)}]}return[]}var x=/* @__PURE__ */ new Set;function ge(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!x.has(e)&&(x.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets allLabel, which only an enum facet uses.`))}var S=/* @__PURE__ */ new Set;function _e(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!S.has(e)&&(S.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets required, which only an enum facet uses.`))}var C=/* @__PURE__ */ new Set;function ve(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!C.has(e)&&(C.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets allLabel and required; a required facet has no All segment.`))}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 presets, which only a dateRange facet uses.`))}function T(n){let{marker:s,props:c}=i(`AppFilterBar`,n),{facets:l,value:u,onChange:d,inline:_=ce,floating:y=!1,apply:b=!1,size:x=`sm`,className:S=``,clearAllLabel:C=`Clear all`,filtersLabel:w=`Filters`,filtersActiveLabel:T=`Filters, {count} active`,keepOpenLabel:be=`Keep open`,appliesAtOnceText:xe=`Changes apply at once.`,applyLabel:Se=`Apply`,anyLabel:D=`Any`,removeChipLabel:Ce=`Remove {facet} filter {value}`,dateFromText:we=`From {date}`,dateUntilText:Te=`Until {date}`,dateRangeText:Ee=`{from} to {to}`,...O}=c;ne(`AppFilterBar`,O),f(`AppFilterBar`,`size`,x,fe);let k=x===`md`,De={range:Ee,from:we,until:Te},A=oe(le,ue,()=>!1),j=m(null),M=ie(),[N,P]=ae({}),F=m(u);for(let e of l)f(`AppFilterBar`,`facets[].type`,e.type,de);for(let e of l)e.allLabel!=null&&e.type!==`enum`&&ge(e.key),e.required&&e.type!==`enum`&&_e(e.key),e.required&&e.allLabel!=null&&ve(e.key),e.presets!=null&&e.type!==`dateRange`&&ye(e.key);let I=l.filter(e=>!pe(e)),L=I.flatMap(e=>he(e,u[e.key],De).map(t=>({...t,facet:e}))),R=I.filter(e=>!e.required&&t(e,u[e.key])),z=y||A?0:Math.max(0,_),B=I.slice(z),Oe=B.filter(e=>R.includes(e)).length,V=!y&&B.length>0;p(()=>{if(!V)return;let e=e=>{let t=j.current;t?.open&&(e.type===`keydown`?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)}},[V]),p(()=>{let e=F.current;F.current=u,P(t=>{let n=Object.entries(t).filter(([t])=>me(e[t],u[t]));return n.length===Object.keys(t).length?t:Object.fromEntries(n)})},[u]);let H=e=>b&&!y&&(e.type===`text`||e.type===`dateRange`),U=e=>H(e)&&Object.hasOwn(N,e.key)?N[e.key]:u[e.key],W=e=>t=>H(e)?P(n=>({...n,[e.key]:t})):d(e.key,t),G=()=>{for(let[e,t]of Object.entries(N))d(e,t);P({})},ke=e=>{e.key===`Enter`&&G()},Ae=e=>{e.preventDefault(),G()},K=(e,t)=>e.type===`text`&&H(e)?/* @__PURE__ */ h(`span`,{onKeyDownCapture:ke,children:t}):t,je=e=>/* @__PURE__ */ h(re,{children:K(e,/* @__PURE__ */ h(E,{facet:e,value:U(e),onChange:W(e),medium:k,anyLabel:D}))},e.key),q=e=>/* @__PURE__ */ g(`div`,{className:`wui-filter-popover-field`,children:[/* @__PURE__ */ h(`span`,{className:`label`,"aria-hidden":`true`,children:e.label}),K(e,/* @__PURE__ */ h(E,{facet:e,value:U(e),onChange:W(e),floating:!0,medium:k,anyLabel:D}))]},e.key),J=(e,t)=>t>0&&/* @__PURE__ */ h(`span`,{className:e,children:` (${t})`}),Y=e=>/* @__PURE__ */ h(o,{size:`sm`,label:`${e.facet.label}: ${e.text}`,removeLabel:r(Ce,{facet:e.facet.label,value:e.text}),onRemove:()=>d(e.facet.key,e.clear()),className:!y&&I.indexOf(e.facet)<z?`wui-filter-chip-inline`:void 0},e.id),X=/* @__PURE__ */ h(a,{variant:`ghost`,size:k?void 0:`sm`,onClick:()=>{for(let t of R)d(t.key,e(t));P({})},children:C});if(y){let e=L.slice(v),t=R.length;return/* @__PURE__ */ g(`div`,{className:`wui-filter-bar d-flex flex-wrap align-items-center gap-2${S?` ${S}`:``}`,...s,...O,children:[/* @__PURE__ */ g(`wui-filter-popover`,{class:`wui-filter-popover`,children:[/* @__PURE__ */ g(a,{variant:t>0?`outline`:`ghost`,size:k?void 0:`sm`,leftIcon:`filter`,className:`wui-filter-popover-trigger`,"aria-expanded":`false`,"aria-controls":M,"aria-label":t>0?r(T,{count:t}):void 0,children:[w,t>0&&/* @__PURE__ */ h(`span`,{className:`badge rounded-pill text-bg-primary ms-1`,children:t})]}),/* @__PURE__ */ g(`div`,{id:M,className:`wui-filter-popover-panel`,role:`dialog`,"aria-label":w,hidden:!0,children:[/* @__PURE__ */ g(`div`,{className:`wui-filter-popover-head`,children:[/* @__PURE__ */ h(`span`,{className:`wui-filter-popover-title`,children:w}),/* @__PURE__ */ h(te,{label:be,id:`${M}-pin`})]}),/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-grid`,children:I.map(q)}),/* @__PURE__ */ g(`div`,{className:`wui-filter-popover-foot`,children:[/* @__PURE__ */ h(`span`,{className:`wui-filter-popover-note`,children:xe}),t>0&&X]})]})]}),L.slice(0,v).map(Y),e.length>0&&/* @__PURE__ */ g(`span`,{className:`chip chip-sm wui-filter-popover-more`,title:e.map(e=>`${e.facet.label}: ${e.text}`).join(`, `),children:[`+`,e.length]})]})}let Z=`wui-filter-bar d-flex flex-wrap align-items-center gap-2${A&&V?` wui-filter-bar--folded`:``}`,Q=e=>`${e}${S?` ${S}`:``}`,$=/* @__PURE__ */ g(se,{children:[I.slice(0,z).map(je),V&&/* @__PURE__ */ g(`details`,{ref:j,className:`wui-filter-more`,children:[/* @__PURE__ */ g(`summary`,{className:`btn btn-outline-primary${k?``:` btn-sm`} wui-filter-more-trigger`,children:[/* @__PURE__ */ h(ee,{name:`filter`,size:14,className:`me-2`}),w,J(`wui-filter-count-desktop`,Oe),J(`wui-filter-count-phone`,R.length)]}),/* @__PURE__ */ g(`div`,{className:`wui-filter-more-panel`,children:[/* @__PURE__ */ h(`div`,{className:`wui-filter-more-head`,children:w}),B.map(q)]})]}),L.map(Y),R.length>0&&X]});return!b||!I.some(e=>e.type===`text`||e.type===`dateRange`)?/* @__PURE__ */ h(`div`,{className:Q(Z),...s,...O,children:$}):/* @__PURE__ */ g(`div`,{className:Q(`wui-filter-form d-flex flex-wrap align-items-center gap-2`),...s,...O,children:[/* @__PURE__ */ h(`div`,{className:Z,children:$}),/* @__PURE__ */ h(a,{type:`submit`,size:k?void 0:`sm`,onClick:Ae,children:Se})]})}function E({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<=y:o.length<y)?/* @__PURE__ */ h(u,{label:e.label,name:e.key,size:i?`md`:`sm`,value:t??``,onChange:n,options:e.required?o:[{value:``,label:e.allLabel||`All`},...o]}):/* @__PURE__ */ h(d,{"aria-label":e.label,name:e.key,placeholder:r?a:e.label,clearable:!e.required,size:i?void 0:`sm`,value:t??``,onChange:n,options:o})}return e.type===`multiEnum`?/* @__PURE__ */ h(c,{"aria-label":e.label,name:e.key,placeholder:r?a:e.label,size:i?void 0:`sm`,collapseChips:!0,values:t??[],onChange:n,options:e.options??[]}):e.type===`dateRange`?/* @__PURE__ */ h(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:t?.from??``,end:t?.to??``,onChange:e=>n({from:e.start??``,to:e.end??``})}):/* @__PURE__ */ h(l,{ariaLabel:e.label,name:e.key,placeholder:e.label,size:i?void 0:`sm`,value:t??``,onChange:n})}export{T as default};
|
|
@@ -0,0 +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"./warnInvalidValue.js";import s from"./warnUnknownProps.js";import{jsx as c}from"react/jsx-runtime";import{createPortal as l}from"react-dom";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__ */ c(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__ */ c(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?l(/* @__PURE__ */ c(`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 e from"../lib/FieldMessage.js";import t from"../lib/useFileDrop.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import ee from"./AppAlert.js";import r from"./AppButton.js";import i from"./AppIcon.js";import te from"./AppModal.js";import ne from"./AppRequiredMark.js";import a from"./warnInvalidValue.js";import re from"./warnUnknownProps.js";import ie from"./withTooltip.js";import{AVATAR_ACCEPT as ae,AVATAR_MAX_SIZE_MB as o,AVATAR_OUTPUT_SIZE as oe,AVATAR_OUTPUT_TYPE as s,AVATAR_PREVIEW_SIZES as se,AVATAR_TEXT as c,DEFAULT_IMAGE_ACCEPT as l,DEFAULT_MAX_SIZE_MB as ce,avatarUnreadableMessage as u,validateFile as le}from"@webority/ui-elements/helpers";import{useCallback as ue,useEffect as de,useId as fe,useRef as pe,useState as d}from"react";import{Fragment as me,jsx as f,jsxs as p}from"react/jsx-runtime";import"@webority/ui-elements/elements/image-crop";var he=[`logo`,`avatar`],ge=[`overlay`,`buttons`],_e=[`stacked`,`inline`,`profile`],ve=[`initials`,`avatar`],ye=[`circle`,`rounded`,`square`],be=[`keep`,`image/webp`],xe=se.join(` `),Se={logo:{controls:`overlay`,accept:l,maxSizeMb:ce,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:ae,maxSizeMb:o,crop:1,rotatable:!0,previews:!0,camera:!0,outputSize:oe,outputType:s,variant:`avatar`,sizes:{sm:64,md:96,lg:128}}},Ce=`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:Ce,unreadable:()=>we},Ee={dialogSize:void 0,dialogTitle:c.dialogTitle,dialogSubtitle:c.dialogSubtitle,save:c.save,cancel:c.cancel,cropFailed:c.cropFailed,unreadable:u};function m(ae){let{marker:o,props:oe}=n(`AppImagePicker`,ae),{kind:s=`logo`,controls:se,value:l,fallback:ce,variant:u,name:Ce,onPick:we,onRemove:m,removeName:h,loading:g=!1,disabled:De=!1,accept:Oe,maxSizeMb:ke,shape:_=`circle`,size:v=`md`,crop:Ae,rotatable:je,previews:Me,camera:Ne,outputSize:Pe,outputType:Fe,layout:y=`stacked`,title:Ie,subtitle:Le,overlayIcon:Re=`image`,overlayLabel:ze=`Update photo`,removeLabel:b=`Remove photo`,ariaLabel:Be,label:Ve,hint:x,error:He,required:Ue=!1,optional:We=!1,className:Ge=``,fieldClassName:S=``,style:C,...w}=oe;re(`AppImagePicker`,w),a(`AppImagePicker`,`kind`,s,he),a(`AppImagePicker`,`controls`,se,ge),a(`AppImagePicker`,`variant`,u,ve),a(`AppImagePicker`,`layout`,y,_e),a(`AppImagePicker`,`shape`,_,ye),a(`AppImagePicker`,`outputType`,Fe,be);let T=Se[s]??Se.logo,E=s===`avatar`?Ee:Te,D=T.sizes;a(`AppImagePicker`,`size`,typeof v==`string`?v:null,Object.keys(D));let Ke=(se??T.controls)===`overlay`,qe=u??T.variant,O=Oe??T.accept,k=ke??T.maxSizeMb,Je=Pe??T.outputSize,Ye=Fe??T.outputType,Xe=je??T.rotatable,Ze=Me??T.previews,Qe=Ne??T.camera,A=Ae??T.crop,j=A===`free`?null:typeof A==`number`&&Number.isFinite(A)&&A>0?A:void 0;A!=null&&j===void 0&&a(`AppImagePicker`,`crop`,String(A),[`free`,`a positive number`]);let M=j!==void 0&&Je===void 0,N=pe(null),$e=pe(null),P=pe(null),F=fe(),[I,L]=d(null),[et,R]=d(!1),[tt,z]=d(!1),[nt,B]=d(``),[V,H]=d(null),[U,rt]=d(!1),[W,G]=d(`loading`),[it,K]=d(``),at=ue(e=>{if(P.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),P.current=null}},[]);de(()=>()=>V&&URL.revokeObjectURL(V.url),[V]),de(()=>()=>I&&URL.revokeObjectURL(I),[I]);let[ot,st]=d(l);l!==ot&&(st(l),L(null),R(!1),z(!1));let q=g||De,J=et?null:I||(l&&!tt?l:null),ct=!!J,Y=He||nt,X=x&&!Y?`${F}-hint`:void 0,Z=Y?`${F}-error`:void 0,lt=Z||X,ut=!q&&ct&&(!!I||!!m||!!h),dt=ct?c.change:c.choose,ft=typeof v==`number`?v:D[v]??D.md,pt=()=>{q||N.current?.click()},mt=()=>{q||$e.current?.click()},ht=e=>{if(Ce&&N.current&&typeof DataTransfer==`function`){let t=new DataTransfer;t.items.add(e),N.current.files=t.files}R(!1),z(!1),L(URL.createObjectURL(e)),we(e)},gt=e=>{let t=j!==void 0&&e.type!==`image/svg+xml`,n=le(e,{accept:O,maxSizeMb:t&&M?0:k});n?B(n):(B(``),t?(G(`loading`),K(``),H({file:e,url:URL.createObjectURL(e)})):ht(e))},{dragOver:_t,dropProps:vt}=t({accept:O,maxSizeMb:M?0:k,disabled:q,onFiles:e=>gt(e[0]),onReject:({message:e})=>B(e)}),yt=e=>{let t=Ye===`keep`?e.type:Ye;return Je===void 0?{name:e.name,type:t,maxBytes:k>0?k*1024*1024:0}:{name:e.name||`photo`,type:t,size:Je}},bt=async()=>{let{file:e}=V;rt(!0),K(``);let t=null;try{t=await P.current?.toFile(yt(e))}catch{t=null}if(rt(!1),!t)K(E.cropFailed);else if(H(null),M){let e=le(t,{accept:O,maxSizeMb:k});e?B(e):ht(t)}else ht(t)},xt=()=>{U||H(null)},St=e=>{let t=e.target.files?.[0];e.target.value=``,t&>(t)},Ct=()=>{L(null),R(!0),B(``),N.current&&(N.current.value=``),m?.()},Q=j!==void 0&&/* @__PURE__ */ p(te,{open:!!V,title:E.dialogTitle,subtitle:E.dialogSubtitle,size:E.dialogSize,staticBackdrop:!0,dismissible:!U,onClose:xt,footer:/* @__PURE__ */ p(me,{children:[/* @__PURE__ */ f(r,{type:`button`,variant:`secondary`,disabled:U,onClick:xt,children:E.cancel}),/* @__PURE__ */ f(r,{type:`button`,variant:`primary`,loading:U,disabled:W!==`ready`,onClick:bt,children:E.save})]}),children:[W===`error`&&V&&/* @__PURE__ */ f(ee,{tone:`danger`,children:E.unreadable(V.file)}),it&&/* @__PURE__ */ f(ee,{tone:`danger`,children:it}),V&&W!==`error`&&/* @__PURE__ */ f(`wui-image-crop`,{ref:at,src:V.url,aspect:j??`free`,round:j===1&&_===`circle`,rotatable:Xe,previews:Ze?xe:void 0})]}),wt=h&&/* @__PURE__ */ f(`input`,{type:`hidden`,name:h,value:`true`,disabled:!et}),$=Ve&&/* @__PURE__ */ p(`label`,{className:`label`,htmlFor:F,children:[Ve,We&&!Ue&&/* @__PURE__ */ f(`span`,{className:`label-optional`,children:` (optional)`}),Ue&&/* @__PURE__ */ f(ne,{})]}),Tt=/* @__PURE__ */ f(`input`,{id:F,ref:N,type:`file`,name:Ce,hidden:!0,accept:O,disabled:q,onChange:St});if(!Ke){let t=ft,n=Qe&&/* @__PURE__ */ p(`button`,{type:`button`,className:`btn btn-secondary btn-sm wui-image-picker-buttons-camera`,disabled:q,onClick:mt,children:[/* @__PURE__ */ f(i,{name:`camera`,size:16}),c.camera]});return/* @__PURE__ */ p(`div`,{...o,className:`field wui-image-picker-field${S?` ${S}`:``}`,children:[$,/* @__PURE__ */ p(`div`,{className:`wui-image-picker-buttons${_t?` is-dragging`:``}${Ge?` ${Ge}`:``}`,style:{"--wui-avatar-size":`${t}px`,...C},...vt,children:[/* @__PURE__ */ p(`button`,{type:`button`,className:`wui-image-picker-buttons-face`,tabIndex:-1,"aria-label":Be??dt,"aria-describedby":lt,"aria-busy":g||void 0,disabled:q,onClick:pt,...w,children:[J?/* @__PURE__ */ f(`img`,{className:`wui-image-picker-buttons-img`,src:J,alt:``,onError:()=>z(!0)}):/* @__PURE__ */ f(`span`,{className:`wui-image-picker-buttons-placeholder`,"aria-hidden":`true`,children:ce||/* @__PURE__ */ f(i,{name:`user`,size:Math.round(t*.5)})}),/* @__PURE__ */ f(`span`,{className:`wui-image-picker-buttons-badge`,"aria-hidden":`true`,children:g?/* @__PURE__ */ f(i,{name:`refresh-cw`,size:14,className:`wui-spin`}):/* @__PURE__ */ f(i,{name:`camera`,size:14})})]}),/* @__PURE__ */ p(`div`,{className:`wui-image-picker-buttons-actions`,children:[/* @__PURE__ */ f(r,{variant:`secondary`,size:`sm`,disabled:q,"aria-describedby":lt,onClick:pt,children:dt}),n,/* @__PURE__ */ f(r,{variant:`secondary-danger`,size:`sm`,"data-wui-image-picker-remove":!0,hidden:!ut,onClick:Ct,children:b})]}),Tt,Qe&&/* @__PURE__ */ f(`input`,{ref:$e,type:`file`,hidden:!0,accept:`image/*`,capture:`user`,disabled:q,onChange:St}),wt]}),/* @__PURE__ */ f(e,{error:Y,hint:x,errorId:Z,hintId:X}),Q]})}let Et=ft,Dt=Math.max(14,Math.round(Et*.18)),Ot=Math.round(Et*.5),kt=`wui-image-picker${qe===`avatar`?` wui-image-picker-avatar`:``}${_===`rounded`?` wui-image-picker-rounded`:_===`square`?` wui-image-picker-square`:``}${_t?` is-dragging`:``}`,At=y===`inline`,jt=y===`profile`,Mt=[`field`,`wui-image-picker-field`,At&&`wui-image-picker-field-inline`,jt&&`wui-image-picker-field-profile`,Ge,S].filter(Boolean).join(` `),Nt=/* @__PURE__ */ p(`div`,{className:`wui-image-picker-shell`,style:{"--wui-logo-size":`${Et}px`},children:[/* @__PURE__ */ f(`button`,{type:`button`,className:kt,onClick:pt,disabled:q,"aria-busy":g||void 0,"aria-label":Be??`Upload photo`,"aria-describedby":Z||X,...vt,...w,children:/* @__PURE__ */ p(`span`,{className:`wui-image-picker-ring`,"data-overlay-label":ze,children:[J?/* @__PURE__ */ f(`img`,{className:`wui-image-picker-img`,src:J,alt:``,onError:()=>z(!0)}):/* @__PURE__ */ f(`span`,{className:`wui-image-picker-logo`,children:ce||qe===`avatar`&&/* @__PURE__ */ f(i,{name:`user`,size:Ot})}),g?/* @__PURE__ */ f(`span`,{className:`wui-image-picker-overlay is-loading`,"aria-hidden":`true`,children:/* @__PURE__ */ f(i,{name:`refresh-cw`,size:Dt,className:`wui-spin`})}):!De&&/* @__PURE__ */ p(`span`,{className:`wui-image-picker-overlay`,children:[/* @__PURE__ */ f(i,{name:Re,size:Dt}),/* @__PURE__ */ f(`span`,{children:ze})]})]})}),ie(/* @__PURE__ */ f(`button`,{type:`button`,className:`wui-image-picker-remove`,hidden:!ut,"aria-label":b,"data-wui-image-picker-remove":!0,onClick:Ct,children:/* @__PURE__ */ f(i,{name:`x`,size:14})}),ut?b:null),Tt,wt]}),Pt=x&&!Y?/* @__PURE__ */ f(`div`,{className:`wui-image-picker-hint`,id:X,children:x}):null,Ft=Y?/* @__PURE__ */ f(e,{error:Y,errorId:Z}):null,It=/* @__PURE__ */ p(`div`,{className:`wui-image-picker-meta`,children:[Ie&&/* @__PURE__ */ f(`div`,{className:`wui-image-picker-title`,children:Ie}),Le&&/* @__PURE__ */ f(`div`,{className:`wui-image-picker-subtitle`,children:Le}),Pt,Ft]});return At?/* @__PURE__ */ p(`div`,{...o,className:Mt,style:C,children:[$,/* @__PURE__ */ p(`div`,{className:`wui-image-picker-row`,children:[Nt,It]}),Q]}):jt?/* @__PURE__ */ p(`div`,{...o,className:Mt,style:C,children:[$,Nt,It,Q]}):/* @__PURE__ */ p(`div`,{...o,className:Mt,style:C,children:[$,Nt,Pt,Ft,Q]})}export{m as default};
|
|
1
|
+
import e from"../lib/FieldMessage.js";import t from"../lib/fillLabel.js";import n from"../lib/useFileDrop.js";import{splitMarkerProps as ee}from"../lib/wuiMarker.js";import te from"./AppAlert.js";import r from"./AppButton.js";import i from"./AppIcon.js";import ne from"./AppModal.js";import re from"./AppRequiredMark.js";import a from"./warnInvalidValue.js";import ie from"./warnUnknownProps.js";import ae from"./withTooltip.js";import{AVATAR_ACCEPT as oe,AVATAR_MAX_SIZE_MB as o,AVATAR_OUTPUT_SIZE as se,AVATAR_OUTPUT_TYPE as s,AVATAR_PREVIEW_SIZES as ce,AVATAR_TEXT as c,DEFAULT_IMAGE_ACCEPT as l,DEFAULT_MAX_SIZE_MB as u,avatarUnreadableMessage as d,validateFile as le}from"@webority/ui-elements/helpers";import{useCallback as ue,useEffect as de,useId as fe,useRef as f,useState as p}from"react";import{Fragment as pe,jsx as m,jsxs as h}from"react/jsx-runtime";import"@webority/ui-elements/elements/image-crop";var me=[`logo`,`avatar`],he=[`overlay`,`buttons`],ge=[`stacked`,`inline`,`profile`],_e=[`initials`,`avatar`],ve=[`circle`,`rounded`,`square`],ye=[`keep`,`image/webp`],be=ce.join(` `),xe={logo:{controls:`overlay`,accept:l,maxSizeMb:u,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:oe,maxSizeMb:o,crop:1,rotatable:!0,previews:!0,camera:!0,outputSize:se,outputType:s,variant:`avatar`,sizes:{sm:64,md:96,lg:128}}},Se=`That image could not be cropped. Choose another one.`,Ce=`That image could not be opened. Choose another one.`,we={dialogSize:`lg`,dialogTitle:`Crop photo`,dialogSubtitle:`Drag the frame and zoom to choose what to keep.`,save:`Apply`,cancel:`Cancel`,cropFailed:Se,unreadable:()=>Ce},Te={dialogSize:void 0,dialogTitle:c.dialogTitle,dialogSubtitle:c.dialogSubtitle,save:c.save,cancel:c.cancel,cropFailed:c.cropFailed,unreadable:d};function g(oe){let{marker:o,props:se}=ee(`AppImagePicker`,oe),{kind:s=`logo`,controls:ce,value:l,fallback:u,variant:d,name:Se,onChange:Ce,onRemove:g,removeName:_,loading:v=!1,disabled:Ee=!1,accept:De,maxSizeMb:Oe,shape:y=`circle`,size:b=`md`,crop:ke,rotatable:Ae,previews:je,camera:Me,outputSize:Ne,outputType:Pe,layout:x=`stacked`,title:Fe,subtitle:Ie,overlayIcon:Le=`image`,overlayLabel:Re=`Update photo`,removeLabel:ze=`Remove photo`,ariaLabel:Be,label:Ve,helperText:S,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:tt=``,fieldClassName:C=``,style:w,...T}=se;ie(`AppImagePicker`,T),a(`AppImagePicker`,`kind`,s,me),a(`AppImagePicker`,`controls`,ce,he),a(`AppImagePicker`,`variant`,d,_e),a(`AppImagePicker`,`layout`,x,ge),a(`AppImagePicker`,`shape`,y,ve),a(`AppImagePicker`,`outputType`,Pe,ye);let E=xe[s]??xe.logo,nt=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)),D={...s===`avatar`?Te:we,...nt},O=E.sizes;a(`AppImagePicker`,`size`,typeof b==`string`?b:null,Object.keys(O));let rt=(ce??E.controls)===`overlay`,it=d??E.variant,k=De??E.accept,A=Oe??E.maxSizeMb,at=Ne??E.outputSize,ot=Pe??E.outputType,st=Ae??E.rotatable,ct=je??E.previews,lt=Me??E.camera,j=ke??E.crop,M=j===`free`?null:typeof j==`number`&&Number.isFinite(j)&&j>0?j:void 0;j!=null&&M===void 0&&a(`AppImagePicker`,`crop`,String(j),[`free`,`a positive number`]);let ut=M!==void 0&&at===void 0,N=f(null),dt=f(null),P=f(null),F=fe(),[I,L]=p(null),[ft,R]=p(!1),[pt,z]=p(!1),[mt,B]=p(``),[V,H]=p(null),[U,ht]=p(!1),[W,G]=p(`loading`),[gt,K]=p(``),_t=ue(e=>{if(P.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),P.current=null}},[]);de(()=>()=>V&&URL.revokeObjectURL(V.url),[V]),de(()=>()=>I&&URL.revokeObjectURL(I),[I]);let[vt,yt]=p(l);l!==vt&&(yt(l),L(null),R(!1),z(!1));let q=v||Ee,J=ft?null:I||(l&&!pt?l:null),bt=!!J,Y=He||mt,X=S&&!Y?`${F}-hint`:void 0,Z=Y?`${F}-error`:void 0,xt=Z||X,St=!q&&bt&&(!!I||!!g||!!_),Ct=bt?$e??c.change:Qe??c.choose,wt=typeof b==`number`?b:O[b]??O.md,Tt=()=>{q||N.current?.click()},Et=()=>{q||dt.current?.click()},Dt=e=>{if(Se&&N.current&&typeof DataTransfer==`function`){let t=new DataTransfer;t.items.add(e),N.current.files=t.files}R(!1),z(!1),L(URL.createObjectURL(e)),Ce(e)},Ot=e=>{let t=M!==void 0&&e.type!==`image/svg+xml`,n=le(e,{accept:k,maxSizeMb:t&&ut?0:A});n?B(n):(B(``),t?(G(`loading`),K(``),H({file:e,url:URL.createObjectURL(e)})):Dt(e))},{dragOver:kt,dropProps:At}=n({accept:k,maxSizeMb:ut?0:A,disabled:q,onFiles:e=>Ot(e[0]),onReject:({message:e})=>B(e)}),jt=e=>{let t=ot===`keep`?e.type:ot;return at===void 0?{name:e.name,type:t,maxBytes:A>0?A*1024*1024:0}:{name:e.name||`photo`,type:t,size:at}},Mt=async()=>{let{file:e}=V;ht(!0),K(``);let t=null;try{t=await P.current?.toFile(jt(e))}catch{t=null}if(ht(!1),!t)K(D.cropFailed);else if(H(null),ut){let e=le(t,{accept:k,maxSizeMb:A});e?B(e):Dt(t)}else Dt(t)},Nt=()=>{U||H(null)},Pt=e=>{let t=e.target.files?.[0];e.target.value=``,t&&Ot(t)},Ft=()=>{L(null),R(!0),B(``),N.current&&(N.current.value=``),g?.()},Q=M!==void 0&&/* @__PURE__ */ h(ne,{open:!!V,title:D.dialogTitle,subtitle:D.dialogSubtitle,size:D.dialogSize,staticBackdrop:!0,dismissible:!U,onClose:Nt,footer:/* @__PURE__ */ h(pe,{children:[/* @__PURE__ */ m(r,{type:`button`,variant:`soft`,disabled:U,onClick:Nt,children:D.cancel}),/* @__PURE__ */ m(r,{type:`button`,loading:U,disabled:W!==`ready`,onClick:Mt,children:D.save})]}),children:[W===`error`&&V&&/* @__PURE__ */ m(te,{tone:`danger`,children:D.unreadable(V.file)}),gt&&/* @__PURE__ */ m(te,{tone:`danger`,children:gt}),V&&W!==`error`&&/* @__PURE__ */ m(`wui-image-crop`,{ref:_t,src:V.url,aspect:M??`free`,round:M===1&&y===`circle`,rotatable:st,previews:ct?be:void 0})]}),It=_&&/* @__PURE__ */ m(`input`,{type:`hidden`,name:_,value:`true`,disabled:!ft}),$=Ve&&/* @__PURE__ */ h(`label`,{className:`label`,htmlFor:F,children:[Ve,We&&!Ue&&/* @__PURE__ */ m(`span`,{className:`label-optional`,children:` ${Ge}`}),Ue&&/* @__PURE__ */ m(re,{})]}),Lt=/* @__PURE__ */ m(`input`,{id:F,ref:N,type:`file`,name:Se,hidden:!0,accept:k,disabled:q,onChange:Pt});if(!rt){let t=wt,n=lt&&/* @__PURE__ */ h(`button`,{type:`button`,className:`btn btn-soft-primary btn-sm wui-image-picker-buttons-camera`,disabled:q,onClick:Et,children:[/* @__PURE__ */ m(i,{name:`camera`,size:16}),et??c.camera]});return/* @__PURE__ */ h(`div`,{...o,className:`field wui-image-picker-field${C?` ${C}`:``}`,children:[$,/* @__PURE__ */ h(`div`,{className:`wui-image-picker-buttons${kt?` is-dragging`:``}${tt?` ${tt}`:``}`,style:{"--wui-avatar-size":`${t}px`,...w},...At,children:[/* @__PURE__ */ h(`button`,{type:`button`,className:`wui-image-picker-buttons-face`,tabIndex:-1,"aria-label":Be??Ct,"aria-describedby":xt,"aria-busy":v||void 0,disabled:q,onClick:Tt,...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:u||/* @__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":xt,onClick:Tt,children:Ct}),n,/* @__PURE__ */ m(r,{tone:`danger`,variant:`soft`,size:`sm`,"data-wui-image-picker-remove":!0,hidden:!St,onClick:Ft,children:ze})]}),Lt,lt&&/* @__PURE__ */ m(`input`,{ref:dt,type:`file`,hidden:!0,accept:`image/*`,capture:`user`,disabled:q,onChange:Pt}),It]}),/* @__PURE__ */ m(e,{error:Y,hint:S,errorId:Z,hintId:X}),Q]})}let Rt=wt,zt=Math.max(14,Math.round(Rt*.18)),Bt=Math.round(Rt*.5),Vt=`wui-image-picker${it===`avatar`?` wui-image-picker-avatar`:``}${y===`rounded`?` wui-image-picker-rounded`:y===`square`?` wui-image-picker-square`:``}${kt?` is-dragging`:``}`,Ht=x===`inline`,Ut=x===`profile`,Wt=[`field`,`wui-image-picker-field`,Ht&&`wui-image-picker-field-inline`,Ut&&`wui-image-picker-field-profile`,tt,C].filter(Boolean).join(` `),Gt=/* @__PURE__ */ h(`div`,{className:`wui-image-picker-shell`,style:{"--wui-logo-size":`${Rt}px`},children:[/* @__PURE__ */ m(`button`,{type:`button`,className:Vt,onClick:Tt,disabled:q,"aria-busy":v||void 0,"aria-label":Be??`Upload photo`,"aria-describedby":Z||X,...At,...T,children:/* @__PURE__ */ h(`span`,{className:`wui-image-picker-ring`,"data-overlay-label":Re,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:u||it===`avatar`&&/* @__PURE__ */ m(i,{name:`user`,size:Bt})}),v?/* @__PURE__ */ m(`span`,{className:`wui-image-picker-overlay is-loading`,"aria-hidden":`true`,children:/* @__PURE__ */ m(i,{name:`refresh-cw`,size:zt,className:`wui-spin`})}):!Ee&&/* @__PURE__ */ h(`span`,{className:`wui-image-picker-overlay`,children:[/* @__PURE__ */ m(i,{name:Le,size:zt}),/* @__PURE__ */ m(`span`,{children:Re})]})]})}),ae(/* @__PURE__ */ m(`button`,{type:`button`,className:`wui-image-picker-remove`,hidden:!St,"aria-label":ze,"data-wui-image-picker-remove":!0,onClick:Ft,children:/* @__PURE__ */ m(i,{name:`x`,size:14})}),St?ze:null),Lt,It]}),Kt=S&&!Y?/* @__PURE__ */ m(`div`,{className:`wui-image-picker-hint`,id:X,children:S}):null,qt=Y?/* @__PURE__ */ m(e,{error:Y,errorId:Z}):null,Jt=/* @__PURE__ */ h(`div`,{className:`wui-image-picker-meta`,children:[Fe&&/* @__PURE__ */ m(`div`,{className:`wui-image-picker-title`,children:Fe}),Ie&&/* @__PURE__ */ m(`div`,{className:`wui-image-picker-subtitle`,children:Ie}),Kt,qt]});return Ht?/* @__PURE__ */ h(`div`,{...o,className:Wt,style:w,children:[$,/* @__PURE__ */ h(`div`,{className:`wui-image-picker-row`,children:[Gt,Jt]}),Q]}):Ut?/* @__PURE__ */ h(`div`,{...o,className:Wt,style:w,children:[$,Gt,Jt,Q]}):/* @__PURE__ */ h(`div`,{...o,className:Wt,style:w,children:[$,Gt,Kt,qt,Q]})}export{g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{splitMarkerProps as e}from"../lib/wuiMarker.js";import t from"./AppIcon.js";import n from"./AppPopover.js";import r from"./warnInvalidValue.js";import i from"./warnUnknownProps.js";import{useState as a}from"react";import{jsx as o}from"react/jsx-runtime";var s={sm:` infotip-popover-sm`,md:``,lg:` infotip-popover-lg`,xl:` infotip-popover-xl`};function c(c){let{marker:l,props:u}=e(`AppInfoTip`,c),{label:d,children:f,placement:p=`auto`,width:m=`md`,className:h=``,...g}=u;i(`AppInfoTip`,g),r(`AppInfoTip`,`width`,m,Object.keys(s));let[_,v]=a(!1),y=!!d;return!y&&!f?null:/* @__PURE__ */ o(`span`,{className:`infotip${h?` ${h}`:``}`,...l,...g,children:/* @__PURE__ */ o(n,{trigger:/* @__PURE__ */ o(`button`,{type:`button`,className:`infotip-btn`,"aria-label":d||`More information`,children:/* @__PURE__ */ o(t,{name:`info`,size:16})}),title:y?d:void 0,placement:p,triggerType:[`hover`,`focus`],className:`infotip-popover${s[m]??``}`,
|
|
1
|
+
import{splitMarkerProps as e}from"../lib/wuiMarker.js";import t from"./AppIcon.js";import n from"./AppPopover.js";import r from"./warnInvalidValue.js";import i from"./warnUnknownProps.js";import{useState as a}from"react";import{jsx as o}from"react/jsx-runtime";var s={sm:` infotip-popover-sm`,md:``,lg:` infotip-popover-lg`,xl:` infotip-popover-xl`};function c(c){let{marker:l,props:u}=e(`AppInfoTip`,c),{label:d,children:f,placement:p=`auto`,width:m=`md`,className:h=``,...g}=u;i(`AppInfoTip`,g),r(`AppInfoTip`,`width`,m,Object.keys(s));let[_,v]=a(!1),y=!!d;return!y&&!f?null:/* @__PURE__ */ o(`span`,{className:`infotip${h?` ${h}`:``}`,...l,...g,children:/* @__PURE__ */ o(n,{trigger:/* @__PURE__ */ o(`button`,{type:`button`,className:`infotip-btn`,"aria-label":d||`More information`,children:/* @__PURE__ */ o(t,{name:`info`,size:16})}),title:y?d:void 0,placement:p,triggerType:[`hover`,`focus`],className:`infotip-popover${s[m]??``}`,onOpenChange:v,"aria-expanded":_,children:f})})}export{c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{splitMarkerProps as e}from"../lib/wuiMarker.js";import t from"./AppIcon.js";import n from"./AppSelect.js";import r from"./warnInvalidValue.js";import i from"./warnUnknownProps.js";import{useEffect as a,useId as o,useRef as s,useState as c}from"react";import{jsx as l,jsxs as u}from"react/jsx-runtime";import"@webority/ui-elements/elements/datepicker";import{INLINE_EDIT_TEXT as d,INLINE_EDIT_TYPES as f,inlineEditText as p}from"@webority/ui-elements/elements/inline-edit";var m=e=>e==null?``:String(e),h=(e,t)=>t===`number`?e===``?null:Number(e):e;function g(g){let{marker:_,props:v}=e(`AppInlineEdit`,g),{value:y,onSave:b,type:x,options:S=[],label:C,placeholder:w,validate:T,renderValue:E,
|
|
1
|
+
import{splitMarkerProps as e}from"../lib/wuiMarker.js";import t from"./AppIcon.js";import n from"./AppSelect.js";import r from"./warnInvalidValue.js";import i from"./warnUnknownProps.js";import{useEffect as a,useId as o,useRef as s,useState as c}from"react";import{jsx as l,jsxs as u}from"react/jsx-runtime";import"@webority/ui-elements/elements/datepicker";import{INLINE_EDIT_TEXT as d,INLINE_EDIT_TYPES as f,inlineEditText as p}from"@webority/ui-elements/elements/inline-edit";var m=e=>e==null?``:String(e),h=(e,t)=>t===`number`?e===``?null:Number(e):e;function g(g){let{marker:_,props:v}=e(`AppInlineEdit`,g),{value:y,onSave:b,type:x,options:S=[],label:C,placeholder:w,validate:T,renderValue:E,wrap:D=!0,disabled:O=!1,className:k=``,id:A,...j}=v;i(`AppInlineEdit`,j),r(`AppInlineEdit`,`type`,x,f);let M=f.includes(x)?x:`text`,N=o(),P=A||`inline-edit-${N.replace(/[^a-zA-Z0-9_-]/g,``)}`,F=`${P}-error`,I=`${P}-control`,L=s(null),R=m(y),[z,B]=c(R),[V,H]=c(R);z!==R&&(B(R),H(R));let[U,W]=c(null),G=s(null);G.current={onSave:b,validate:T,kind:M},a(()=>{let e=L.current;if(e)return e.save=async e=>{W(e);try{await G.current.onSave?.(h(e,G.current.kind)),H(e)}finally{W(null)}},e.validate=e=>G.current.validate?.(h(e,G.current.kind))||null,()=>{e.save=void 0,e.validate=void 0}},[]);let K=U??V,q=p(K,{type:M,options:S,placeholder:w}),J=E&&!q.empty?E(h(K,M)):q.text,Y={id:I,"data-wui-control":``,"aria-label":C},X;if(M===`select`){let e=S.map(e=>({value:String(e.value),label:m(e.label??e.value)}));X=/* @__PURE__ */ l(n,{id:I,"data-wui-control":``,"aria-label":C,size:`sm`,placeholder:w||void 0,options:e})}else X=M===`date`?/* @__PURE__ */ l(`wui-datepicker`,{...Y,size:`sm`,"aria-describedby":F,placeholder:w||void 0}):M===`textarea`?/* @__PURE__ */ l(`textarea`,{...Y,className:`form-control textarea`,rows:3,"aria-describedby":F,placeholder:w||void 0}):/* @__PURE__ */ l(`input`,{...Y,type:M===`number`?`number`:`text`,inputMode:M===`number`?`decimal`:void 0,className:`form-control input input-sm`,"aria-describedby":F,placeholder:w||void 0});let Z=[`wui-inline-edit`,D===!1?`wui-inline-edit--nowrap`:``,k].filter(Boolean).join(` `);return/* @__PURE__ */ u(`wui-inline-edit`,{ref:L,id:P,class:Z,type:M,label:C,value:V,placeholder:w||void 0,disabled:O?``:void 0,controlled:``,..._,...j,children:[/* @__PURE__ */ u(`button`,{type:`button`,className:`wui-inline-edit-display`,"data-wui-display":``,"aria-describedby":F,disabled:O,children:[/* @__PURE__ */ l(`span`,{className:`visually-hidden`,children:O?d.readOnly(C):d.edit(C)}),/* @__PURE__ */ l(`span`,{className:`wui-inline-edit-value`,"data-wui-value":``,"data-wui-empty":q.empty?``:void 0,children:J}),/* @__PURE__ */ l(`span`,{className:`wui-inline-edit-icon`,"aria-hidden":`true`,children:/* @__PURE__ */ l(t,{name:`edit`,size:14})})]}),/* @__PURE__ */ l(`span`,{className:`wui-inline-edit-editor`,"data-wui-editor":``,hidden:!0,children:X}),/* @__PURE__ */ u(`span`,{className:`wui-inline-edit-status`,"aria-hidden":`true`,children:[/* @__PURE__ */ l(`span`,{className:`wui-inline-edit-spinner spinner-border spinner-border-sm`}),/* @__PURE__ */ l(`span`,{className:`wui-inline-edit-saved`,children:/* @__PURE__ */ l(t,{name:`tick-circle`,size:16})})]}),/* @__PURE__ */ l(`span`,{className:`wui-inline-edit-error`,id:F,"data-wui-error":``,hidden:!0}),/* @__PURE__ */ l(`span`,{className:`visually-hidden`,"data-wui-live":``,"aria-live":`polite`,"aria-atomic":`true`})]})}export{g as default};
|