@webority/ui-react 0.127.0 → 0.129.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.
Files changed (186) hide show
  1. package/dist/canvas-kit/kit.js +28735 -24316
  2. package/dist/canvas-kit/manifest.json +3223 -163
  3. package/dist/canvas-kit/release.json +6 -6
  4. package/dist/components/AppAccountSwitcher.js +1 -0
  5. package/dist/components/AppAsyncBlock.js +1 -1
  6. package/dist/components/AppAuthLayout.js +1 -0
  7. package/dist/components/AppAutocomplete.js +1 -1
  8. package/dist/components/AppAvatar.js +1 -1
  9. package/dist/components/AppAvatarGroup.js +1 -1
  10. package/dist/components/AppBanner.js +1 -1
  11. package/dist/components/AppButton.js +1 -1
  12. package/dist/components/AppCalendar.js +1 -1
  13. package/dist/components/AppCard.js +1 -1
  14. package/dist/components/AppCell.js +1 -0
  15. package/dist/components/AppChart.js +1 -1
  16. package/dist/components/AppChartCard.js +1 -1
  17. package/dist/components/AppCheckbox.js +1 -1
  18. package/dist/components/AppChoiceCard.js +1 -1
  19. package/dist/components/AppChoiceChip.js +1 -1
  20. package/dist/components/AppColorField.js +1 -1
  21. package/dist/components/AppCommandPalette.js +1 -1
  22. package/dist/components/AppCommentThread.js +1 -1
  23. package/dist/components/AppCompareTable.js +1 -1
  24. package/dist/components/AppConfirmDialog.js +1 -1
  25. package/dist/components/AppCopyButton.js +1 -1
  26. package/dist/components/AppCountrySelect.js +1 -1
  27. package/dist/components/AppDataTable.js +1 -1
  28. package/dist/components/AppDatePicker.js +1 -1
  29. package/dist/components/AppDateRangePicker.js +1 -1
  30. package/dist/components/AppDescriptions.js +1 -1
  31. package/dist/components/AppDrawer.js +1 -1
  32. package/dist/components/AppDropZone.js +1 -1
  33. package/dist/components/AppDueDate.js +1 -1
  34. package/dist/components/AppErrorBoundary.js +1 -0
  35. package/dist/components/AppFileAttachment.js +1 -1
  36. package/dist/components/AppFilePicker.js +1 -1
  37. package/dist/components/AppFileTiles.js +1 -1
  38. package/dist/components/AppFilterBar.js +1 -1
  39. package/dist/components/AppFloatingButton.js +1 -0
  40. package/dist/components/AppImagePicker.js +1 -1
  41. package/dist/components/AppInlineEdit.js +1 -1
  42. package/dist/components/AppInput.js +1 -1
  43. package/dist/components/AppKanban.js +1 -1
  44. package/dist/components/AppLeadPopup.js +1 -0
  45. package/dist/components/AppLink.js +1 -1
  46. package/dist/components/AppMarkdown.js +1 -1
  47. package/dist/components/AppMentionInput.js +1 -1
  48. package/dist/components/AppMetricStrip.js +1 -1
  49. package/dist/components/AppModal.js +1 -1
  50. package/dist/components/AppMultiSelect.js +1 -1
  51. package/dist/components/AppNotificationCenter.js +1 -1
  52. package/dist/components/AppNumberInput.js +1 -1
  53. package/dist/components/AppOtpInput.js +1 -1
  54. package/dist/components/AppPhoneNumberInput.js +1 -1
  55. package/dist/components/AppPopover.js +1 -1
  56. package/dist/components/AppProgress.js +1 -1
  57. package/dist/components/AppRadio.js +1 -1
  58. package/dist/components/AppRadioGroup.js +1 -1
  59. package/dist/components/AppRating.js +1 -1
  60. package/dist/components/AppRichText.js +1 -1
  61. package/dist/components/AppRouteError.js +1 -1
  62. package/dist/components/AppScoreScale.js +1 -1
  63. package/dist/components/AppSearch.js +1 -1
  64. package/dist/components/AppSectionLeadCapture.js +1 -1
  65. package/dist/components/AppSectionLogos.js +1 -1
  66. package/dist/components/AppSegmented.js +1 -1
  67. package/dist/components/AppSelect.js +1 -1
  68. package/dist/components/AppShell.js +1 -1
  69. package/dist/components/AppSlider.js +1 -1
  70. package/dist/components/AppSortableList.js +1 -1
  71. package/dist/components/AppSparkline.js +1 -1
  72. package/dist/components/AppSplitButton.js +1 -1
  73. package/dist/components/AppSplitView.js +1 -1
  74. package/dist/components/AppStepper.js +1 -1
  75. package/dist/components/AppSwitch.js +1 -1
  76. package/dist/components/AppTablePagination.js +1 -1
  77. package/dist/components/AppTableToolbar.js +1 -1
  78. package/dist/components/AppTagInput.js +1 -1
  79. package/dist/components/AppTextarea.js +1 -1
  80. package/dist/components/AppTimePicker.js +1 -1
  81. package/dist/components/AppTimeline.js +1 -1
  82. package/dist/components/AppToast.js +1 -1
  83. package/dist/components/AppUpdateBar.js +1 -1
  84. package/dist/components/AppWhatsNew.js +1 -1
  85. package/dist/components/AppWorkspaceSwitcher.js +1 -1
  86. package/dist/components/iconCatalogNames.g.js +1 -1
  87. package/dist/components/iconGlyphs.g.js +1 -1
  88. package/dist/components/iconVariants.g.js +1 -1
  89. package/dist/components/useWuiControl.js +1 -1
  90. package/dist/guidance.json +235 -2
  91. package/dist/lib/CheckField.js +1 -1
  92. package/dist/lib/FileItemRow.js +1 -1
  93. package/dist/lib/fieldState.js +1 -0
  94. package/dist/lib/fillLabel.js +1 -0
  95. package/dist/lib/labelWithHelp.js +1 -0
  96. package/dist/lib/linkTarget.js +1 -0
  97. package/dist/markdown-core/dist/links.js +1 -1
  98. package/dist/types/components/AppAccountSwitcher.d.ts +41 -0
  99. package/dist/types/components/AppAsyncBlock.d.ts +24 -0
  100. package/dist/types/components/AppAuthLayout.d.ts +45 -0
  101. package/dist/types/components/AppAutocomplete.d.ts +22 -2
  102. package/dist/types/components/AppAvatar.d.ts +6 -0
  103. package/dist/types/components/AppAvatarGroup.d.ts +6 -0
  104. package/dist/types/components/AppBanner.d.ts +6 -0
  105. package/dist/types/components/AppButton.d.ts +1 -0
  106. package/dist/types/components/AppCalendar.d.ts +3 -1
  107. package/dist/types/components/AppCard.d.ts +13 -1
  108. package/dist/types/components/AppCell.d.ts +36 -0
  109. package/dist/types/components/AppChart.d.ts +7 -0
  110. package/dist/types/components/AppChartCard.d.ts +60 -0
  111. package/dist/types/components/AppCheckbox.d.ts +22 -0
  112. package/dist/types/components/AppChoiceCard.d.ts +21 -0
  113. package/dist/types/components/AppChoiceChip.d.ts +21 -0
  114. package/dist/types/components/AppColorField.d.ts +43 -4
  115. package/dist/types/components/AppCommandPalette.d.ts +6 -0
  116. package/dist/types/components/AppCommentThread.d.ts +102 -3
  117. package/dist/types/components/AppCompareTable.d.ts +24 -0
  118. package/dist/types/components/AppConfirmDialog.d.ts +6 -0
  119. package/dist/types/components/AppCountrySelect.d.ts +5 -0
  120. package/dist/types/components/AppDataTable.d.ts +1 -1
  121. package/dist/types/components/AppDatePicker.d.ts +24 -0
  122. package/dist/types/components/AppDateRangePicker.d.ts +31 -1
  123. package/dist/types/components/AppDescriptions.d.ts +4 -1
  124. package/dist/types/components/AppDrawer.d.ts +6 -0
  125. package/dist/types/components/AppDropZone.d.ts +24 -0
  126. package/dist/types/components/AppDueDate.d.ts +42 -0
  127. package/dist/types/components/AppErrorBoundary.d.ts +39 -0
  128. package/dist/types/components/AppFileAttachment.d.ts +54 -1
  129. package/dist/types/components/AppFilePicker.d.ts +75 -0
  130. package/dist/types/components/AppFileTiles.d.ts +6 -3
  131. package/dist/types/components/AppFilterBar.d.ts +73 -0
  132. package/dist/types/components/AppFloatingButton.d.ts +64 -0
  133. package/dist/types/components/AppImagePicker.d.ts +60 -0
  134. package/dist/types/components/AppInlineEdit.d.ts +6 -0
  135. package/dist/types/components/AppInput.d.ts +37 -2
  136. package/dist/types/components/AppKanban.d.ts +32 -0
  137. package/dist/types/components/AppLeadPopup.d.ts +122 -0
  138. package/dist/types/components/AppLink.d.ts +3 -0
  139. package/dist/types/components/AppMentionInput.d.ts +17 -0
  140. package/dist/types/components/AppMetricStrip.d.ts +2 -0
  141. package/dist/types/components/AppModal.d.ts +6 -0
  142. package/dist/types/components/AppMultiSelect.d.ts +18 -1
  143. package/dist/types/components/AppNotificationCenter.d.ts +2 -0
  144. package/dist/types/components/AppNumberInput.d.ts +24 -2
  145. package/dist/types/components/AppOtpInput.d.ts +29 -0
  146. package/dist/types/components/AppPhoneNumberInput.d.ts +26 -0
  147. package/dist/types/components/AppProgress.d.ts +2 -2
  148. package/dist/types/components/AppRadio.d.ts +22 -0
  149. package/dist/types/components/AppRadioGroup.d.ts +24 -0
  150. package/dist/types/components/AppRating.d.ts +39 -0
  151. package/dist/types/components/AppRichText.d.ts +7 -0
  152. package/dist/types/components/AppRouteError.d.ts +54 -0
  153. package/dist/types/components/AppScoreScale.d.ts +6 -0
  154. package/dist/types/components/AppSearch.d.ts +17 -2
  155. package/dist/types/components/AppSectionLeadCapture.d.ts +48 -0
  156. package/dist/types/components/AppSectionLogos.d.ts +2 -0
  157. package/dist/types/components/AppSegmented.d.ts +27 -3
  158. package/dist/types/components/AppSelect.d.ts +22 -2
  159. package/dist/types/components/AppShell.d.ts +165 -0
  160. package/dist/types/components/AppSlider.d.ts +28 -0
  161. package/dist/types/components/AppSortableList.d.ts +5 -0
  162. package/dist/types/components/AppSparkline.d.ts +24 -0
  163. package/dist/types/components/AppSplitView.d.ts +68 -0
  164. package/dist/types/components/AppStepper.d.ts +6 -0
  165. package/dist/types/components/AppSwitch.d.ts +22 -0
  166. package/dist/types/components/AppTablePagination.d.ts +44 -2
  167. package/dist/types/components/AppTableToolbar.d.ts +30 -0
  168. package/dist/types/components/AppTagInput.d.ts +18 -1
  169. package/dist/types/components/AppTextarea.d.ts +20 -0
  170. package/dist/types/components/AppTimePicker.d.ts +17 -0
  171. package/dist/types/components/AppTimeline.d.ts +8 -0
  172. package/dist/types/components/AppToast.d.ts +6 -0
  173. package/dist/types/components/AppUpdateBar.d.ts +18 -0
  174. package/dist/types/components/AppWhatsNew.d.ts +2 -0
  175. package/dist/types/components/AppWorkspaceSwitcher.d.ts +18 -0
  176. package/dist/types/components/iconGlyphs.g.d.ts +1 -0
  177. package/dist/types/components/iconVariants.g.d.ts +5 -0
  178. package/dist/types/components/useWuiControl.d.ts +3 -1
  179. package/dist/types/index.d.ts +6 -0
  180. package/dist/types/lib/FileItemRow.d.ts +9 -2
  181. package/dist/types/lib/fieldState.d.ts +3 -0
  182. package/dist/types/lib/fillLabel.d.ts +1 -0
  183. package/dist/types/lib/labelWithHelp.d.ts +10 -0
  184. package/dist/types/lib/linkTarget.d.ts +30 -0
  185. package/dist/ui-react.js +1 -1
  186. package/package.json +8 -8
@@ -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"./AppRequiredMark.js";import i from"./useWuiControl.js";import a from"./warnInvalidValue.js";import o from"./warnUnknownProps.js";import{cloneElement as s,forwardRef as c,useId as l}from"react";import{jsx as u,jsxs as d}from"react/jsx-runtime";import"@webority/ui-elements/elements/datepicker";var f=[`sm`,`md`,`lg`],p=c(function(c,p){let{marker:m,props:h}=n(`AppDatePicker`,c),{value:g,onChange:_,label:v,required:y=!1,optional:b=!1,hint:x,error:S,name:C,min:w,max:T,placeholder:E=`Choose a date`,disabled:D,size:O,firstDay:k,displayFormat:A,id:j,ariaLabel:M,className:N=``,fieldClassName:P=``,...F}=h;o(`AppDatePicker`,F),a(`AppDatePicker`,`size`,O,f),typeof A==`string`&&A!==``&&/DD|YYYY|YY/.test(A)&&e(`[@webority/ui-react] <AppDatePicker> displayFormat "${A}" uses uppercase day or year tokens, which print as written; the tokens are yyyy, MMMM, MMM, MM, dd and d.`);let I=l(),L=j||I,{setRef:R}=i({ref:p,value:g??``,onChange:_}),z=!v&&!S&&!x,B=S?`${L}-error`:void 0,V=x?`${L}-hint`:void 0,H=/* @__PURE__ */ u(`wui-datepicker`,{ref:R,value:g||void 0,id:L,name:C,min:w,max:T,placeholder:E,size:O||void 0,"first-day":k==null?void 0:String(k),"display-format":A||void 0,"aria-label":M||(typeof v==`string`?v:void 0),"aria-describedby":B||V,"aria-invalid":S?`true`:void 0,disabled:D?``:void 0,required:y?``:void 0,className:N||void 0,...F});return z?s(H,m):/* @__PURE__ */ d(`div`,{...m,className:`field${P?` ${P}`:``}`,children:[v&&/* @__PURE__ */ d(`label`,{className:`label`,htmlFor:L,children:[v,b&&!y&&/* @__PURE__ */ u(`span`,{className:`label-optional`,children:` (optional)`}),y&&/* @__PURE__ */ u(r,{})]}),H,/* @__PURE__ */ u(t,{error:S,hint:x,errorId:B,hintId:V})]})});export{p as default};
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)`,hint: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"./AppRequiredMark.js";import r from"./useWuiControl.js";import i from"./warnInvalidValue.js";import a from"./warnUnknownProps.js";import{cloneElement as o,forwardRef as s,useEffect as c,useId as l}from"react";import{jsx as u,jsxs as d}from"react/jsx-runtime";import"@webority/ui-elements/elements/date-range";var f=[`sm`,`md`,`lg`],p=e=>{if(e?.length)return e.every(e=>typeof e==`string`)?e.join(`,`):JSON.stringify(e)},m=s(function(s,m){let{marker:h,props:g}=t(`AppDateRangePicker`,s),{start:_,end:v,onChange:y,label:b,required:x=!1,optional:S=!1,hint:C,error:w,startName:T,endName:E,min:D,max:O,placeholder:k=`Start to End`,disabled:A,size:j,firstDay:M,presets:N,id:P,ariaLabel:F,className:I=``,fieldClassName:L=``,...R}=g;a(`AppDateRangePicker`,R),i(`AppDateRangePicker`,`size`,j,f);let z=l(),B=P||z,{setRef:V,innerRef:H}=r({ref:m,onChange:y});c(()=>{let e=H.current;if(!e)return;let t=_===void 0?e.value.start:_,n=v===void 0?e.value.end:v;(e.value.start!==t||e.value.end!==n)&&(e.value={start:t,end:n})},[_,v,H]);let U=!b&&!w&&!C,W=w?`${B}-error`:void 0,G=C?`${B}-hint`:void 0,K=W||G,q=/* @__PURE__ */ u(`wui-date-range`,{ref:V,id:B,"start-name":T,"end-name":E,min:D,max:O,placeholder:k,size:j||void 0,"first-day":M==null?void 0:String(M),presets:p(N),"aria-label":F||(typeof b==`string`?b:void 0),"aria-describedby":K,"aria-invalid":w?`true`:void 0,disabled:A?``:void 0,required:x?``:void 0,className:I||void 0,...R});return U?o(q,h):/* @__PURE__ */ d(`div`,{...h,className:`field${L?` ${L}`:``}`,children:[b&&/* @__PURE__ */ d(`label`,{className:`label`,htmlFor:B,children:[b,S&&!x&&/* @__PURE__ */ u(`span`,{className:`label-optional`,children:` (optional)`}),x&&/* @__PURE__ */ u(n,{})]}),q,/* @__PURE__ */ u(e,{error:w,hint:C,errorId:W,hintId:G})]})});export{m as default};
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)`,hint: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{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./renderIconProp.js";import r from"./warnInvalidValue.js";import i from"./warnUnknownProps.js";import{jsx as a,jsxs as o}from"react/jsx-runtime";var s=[`sm`,`md`],c=[`grid`,`summary`,`list`],l=[1,2,3,4];function u(u){let{marker:d,props:f}=t(`AppDescriptions`,u),{items:p=[],columns:m=2,size:h=`md`,bordered:g=!1,layout:_=`grid`,title:v,className:y=``,...b}=f;i(`AppDescriptions`,b),r(`AppDescriptions`,`columns`,m,l),r(`AppDescriptions`,`size`,h,s),r(`AppDescriptions`,`layout`,_,c);let x=[`descs`,`descs-col-${m}`,h&&h!==`md`?`descs-${h}`:``,g?`descs-bordered`:``,_===`summary`?`wui-descs-summary`:``,_===`list`?`wui-descs-list`:``,m===4?`wui-descs-col-4`:``,y].filter(Boolean).join(` `)||void 0;return/* @__PURE__ */ o(`div`,{className:x,...d,...b,children:[v&&/* @__PURE__ */ a(`div`,{className:`descs-title`,children:v}),/* @__PURE__ */ a(`dl`,{className:`descs-list`,children:p.map((t,r)=>{let i=e(t.value),s=Math.min(12,Math.max(1,t.span??1)),c=t.key??`${t.label}-${r}`,l=i?`-`:t.value;return/* @__PURE__ */ o(`div`,{className:`descs-item${t.emphasis?` wui-descs-emphasis`:``} wui-descs-span-${s}`,children:[t.icon&&/* @__PURE__ */ a(`span`,{className:`wui-descs-icon`,children:n(t.icon,{size:16})}),/* @__PURE__ */ a(`dt`,{className:`descs-label`,children:t.label}),/* @__PURE__ */ a(`dd`,{className:`descs-value${i?` is-empty`:``}`,children:t.href?/* @__PURE__ */ a(`a`,{className:`wui-descs-link`,href:t.href,children:l}):l})]},c)})})]})}export{u as default};
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:L=!1,confirmDiscard:R,dirty:z=!1,headerClassName:B=``,bodyClassName:V=``,footer:H,className:U=``,style:W,children:G,...K}=_;a(`AppDrawer`,K),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 q=s(null),J=s(null),Y=s(null),[X,Z]=c(!1);J.current={onClose:y,onSnapChange:M,onOpened:N,onClosed:P,confirmDiscard:R,dirty:z},o(()=>{v||Z(!1)},[v]),o(()=>{X&&Y.current?.focus()},[X]),o(()=>{if(v)return t()},[v]),o(()=>{let e=q.current;if(!e)return;let t=t=>{t.target===e&&(t.preventDefault(),J.current.confirmDiscard&&J.current.dirty?Z(!0):J.current.onClose?.())},n=t=>{t.target===e&&J.current.onSnapChange?.(t.detail.index,t.detail.percent)},r=t=>{t.target===e&&J.current.onOpened?.()},i=t=>{t.target===e&&J.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=()=>{Z(!1),q.current?.dispatchEvent(new CustomEvent(`wui:drawer:discard`,{bubbles:!0})),J.current.onClose?.()},$=m(k)?k:p,ee={...D&&{"--wui-drawer-width":D},...O&&{"--wui-drawer-max-width":O},...W};return/* @__PURE__ */ u(`wui-drawer`,{ref:q,...g,...K,class:[`wui-drawer`,U].filter(Boolean).join(` `),side:T,size:E,"snap-points":$.join(`,`),"default-snap":String(A),static:L?``:void 0,"no-sheet":j?void 0:``,"confirm-discard":R||void 0,open:v?``:void 0,style:ee,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":`Sheet height`})}),S===void 0?/* @__PURE__ */ u(`div`,{className:[`wui-drawer-header`,B].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`,V].filter(Boolean).join(` `),children:G}),(H||X)&&/* @__PURE__ */ u(`div`,{className:X?`wui-drawer-footer wui-drawer-discarding`:`wui-drawer-footer`,children:[X&&/* @__PURE__ */ l(e,{text:R,confirmRef:Y,onDiscard:Q,onKeep:()=>Z(!1)}),H]})]})]})}export{h as default};
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 n}from"../lib/wuiMarker.js";import r from"./AppIcon.js";import i from"./warnUnknownProps.js";import{DEFAULT_MAX_SIZE_MB as a,acceptDroppedFiles as o,acceptLabel as s}from"@webority/ui-elements/helpers";import{useId as c,useState as l}from"react";import{jsx as u,jsxs as d}from"react/jsx-runtime";function f(f){let{marker:p,props:m}=n(`AppDropZone`,f),{label:h,id:g,onChange:_,multiple:v=!1,accept:y=``,maxSizeMb:b=a,error:x,hint:S,disabled:C=!1,className:w=``,fieldClassName:T=``,style:E,...D}=m;i(`AppDropZone`,D);let[O,k]=l(``),A=c(),j=g||A,M=x||O,N=M?`${j}-error`:void 0,P=S&&!M?`${j}-hint`:void 0,F=N||P,I=y?s(y):`Any file type`,L={accept:y,maxSizeMb:b,multiple:v},R=e=>{k(``),_(v?e:e[0])},z=e=>k(e.message),{dragOver:B,dropProps:V}=t({...L,disabled:C,onFiles:R,onReject:z}),H=e=>{let{files:t,rejections:n}=o(e,L);(t.length||n.length)&&(t.length&&R(t),n.length&&z(n[0]))};return/* @__PURE__ */ d(`div`,{...p,className:`field${T?` ${T}`:``}`,children:[h?/* @__PURE__ */ u(`label`,{className:`label`,htmlFor:j,children:h}):null,/* @__PURE__ */ d(`div`,{className:`file-input file-input-tall${B?` dragging`:``}${M?` error`:``}${w?` ${w}`:``}`,style:E,"aria-disabled":C||void 0,...V,children:[/* @__PURE__ */ d(`label`,{htmlFor:j,className:`file-input-zone-label`,children:[/* @__PURE__ */ u(`span`,{className:`file-input-icon`,children:/* @__PURE__ */ u(r,{name:`upload`,size:24})}),/* @__PURE__ */ d(`span`,{className:`file-input-title`,children:[/* @__PURE__ */ u(`span`,{className:`browse`,children:`Click to upload`}),` or drag & drop`]}),/* @__PURE__ */ u(`span`,{className:`file-input-text`,children:b>0?`${I}, up to ${b} MB`:I})]}),/* @__PURE__ */ u(`input`,{id:j,type:`file`,"aria-describedby":F,accept:y,multiple:v||void 0,disabled:C||void 0,className:`visually-hidden`,onClick:e=>{e.currentTarget.value=``},onChange:e=>H(e.target.files),...D})]}),/* @__PURE__ */ u(e,{error:M,hint:S,errorId:N,hintId:P})]})}export{f as default};
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,hint: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{splitMarkerProps as e}from"../lib/wuiMarker.js";import t from"./AppIcon.js";import n from"./warnInvalidValue.js";import r from"./warnUnknownProps.js";import{formatDate as i,toInstant as a}from"@webority/ui-elements/helpers";import{jsx as o,jsxs as s}from"react/jsx-runtime";var c=864e5,l=198e5,u=14,d=[`days`,`due`],f=e=>Math.floor((e+l)/c),p=(...e)=>e.filter(Boolean).join(` `),m=(e,t)=>e===`due`?t===0?`Due today`:t===1?`Due tomorrow`:`Due in ${t} days`:t===1?`1 day left`:`${t} days left`;function h(l){let{marker:h,props:g}=e(`AppDueDate`,l),{date:_,soonDays:v,soonWording:y=`days`,icon:b=!1,overdue:x=!1,overdueLabel:S,className:C=``,...w}=g;r(`AppDueDate`,w),n(`AppDueDate`,`soonWording`,y,d);let T=a(_);if(!Number.isFinite(T))return/* @__PURE__ */ o(`wui-due-date`,{class:p(`wui-due-date`,`wui-due-date-empty`,C),...h,...w,children:/* @__PURE__ */ o(`time`,{children:`Not set`})});let E=f(T),D=(/* @__PURE__ */ new Date(E*c)).toISOString().slice(0,10),O=E-f(Date.now()),k=b?/* @__PURE__ */ o(t,{name:`calendar`,size:u}):null;if(x){let e=i(T);return/* @__PURE__ */ s(`wui-due-date`,{class:p(`wui-due-date`,`wui-due-date-danger`,C),title:`Overdue since ${e}`,...h,...w,children:[/* @__PURE__ */ o(t,{name:`danger`,size:u}),k,/* @__PURE__ */ o(`time`,{dateTime:D,children:S||e})]})}return Number.isFinite(v)&&O>=0&&O<=v?/* @__PURE__ */ s(`wui-due-date`,{class:p(`wui-due-date`,`wui-due-date-warning`,C),...h,...w,children:[k,/* @__PURE__ */ o(`time`,{dateTime:D,children:m(y,O)})]}):/* @__PURE__ */ s(`wui-due-date`,{class:p(`wui-due-date`,C),...h,...w,children:[k,/* @__PURE__ */ o(`time`,{dateTime:D,children:i(T)})]})}export{h as default};
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};
@@ -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 u}from"../lib/wuiMarker.js";import d from"./AppIcon.js";import f from"./AppProgress.js";import p from"./warnUnknownProps.js";import{DEFAULT_IMAGE_ACCEPT as m,DEFAULT_MAX_SIZE_MB as h,acceptDroppedFiles as g,acceptLabel as _,isImageFile as v,isImageOnlyAccept as y}from"@webority/ui-elements/helpers";import{useId as b,useState as ee}from"react";import{Fragment as x,jsx as S,jsxs as C}from"react/jsx-runtime";function w(i){let{marker:a,props:o}=u(`AppFileAttachment`,i),{label:s=`Attachment`,value:c,name:f,onChange:_,multiple:w=!1,accept:D=m,maxSizeMb:O=h,optional:k=!1,validate:A=!0,error:j,id:M,...N}=o;p(`AppFileAttachment`,N);let P=b(),F=M||P,[I,L]=ee(``),R=w&&Array.isArray(c)?c:c?[c]:[],z=y(D),B=e=>e instanceof File?v(e):z||v(e),V=!w&&R.length===1&&B(R[0])&&(R[0]instanceof File||r(R[0])!==null),H=T(D,O),U=A?{accept:D,maxSizeMb:O,multiple:w}:{accept:``,maxSizeMb:0,multiple:w};function W(e){if(L(``),w){let t=Array.isArray(c)?c:c?[c]:[],r=new Set(t.map(n)),i=t.concat(e.filter(e=>!r.has(n(e))));_(i)}else _(e[0])}function G(e){if(!e.length)return;let{files:t,rejections:n}=g(e,U);t.length&&W(t),L(n[0]?.message??``)}let{dragOver:K,dropProps:q}=l({...U,disabled:N.disabled,onFiles:W,onReject:e=>L(e.message)});function J(e){let t=Array.from(e.target.files||[]);e.target.value=``,G(t)}function Y(e){L(``),_(w?R.filter((t,n)=>n!==e):null)}let X=j||I,Z=X?`${F}-error`:void 0,Q=w||R.length===0,$=z?`image`:`file`,te=w?`Add ${$}s`:`Add ${z?`an`:`a`} ${$}`;return/* @__PURE__ */ C(`div`,{...a,className:`field`,children:[/* @__PURE__ */ C(`label`,{className:`label`,htmlFor:F,children:[s,k&&/* @__PURE__ */ S(`span`,{className:`label-optional`,children:` (optional)`})]}),Q&&/* @__PURE__ */ C(x,{children:[/* @__PURE__ */ C(`label`,{className:`attach-drop${K?` dragging`:``}`,htmlFor:F,...q,children:[/* @__PURE__ */ S(`span`,{className:`attach-drop-icon`,children:/* @__PURE__ */ S(d,{name:z?`image`:`file-text`,size:18})}),/* @__PURE__ */ C(`span`,{className:`attach-drop-copy`,children:[/* @__PURE__ */ S(`span`,{className:`attach-drop-title`,children:te}),H&&/* @__PURE__ */ S(`span`,{className:`attach-drop-hint`,children:H})]}),/* @__PURE__ */ S(`span`,{className:`attach-drop-cta`,children:`Browse`})]}),/* @__PURE__ */ S(`input`,{id:F,type:`file`,className:`visually-hidden`,name:f,accept:D||void 0,multiple:w||void 0,"aria-describedby":Z,onChange:J,...N})]}),V?/* @__PURE__ */ S(E,{item:R[0],isImage:!0,onRemove:()=>Y(0)}):R.length>0&&/* @__PURE__ */ S(`div`,{className:`attach-list`,children:R.map((e,r)=>/* @__PURE__ */ S(t,{item:e,isImage:B(e),onRemove:()=>Y(r)},n(e)))}),/* @__PURE__ */ S(e,{error:X,errorId:`${F}-error`})]})}function T(e,t){let n=e?.trim()?_(e):``,r=t>0?`up to ${t} MB`:``;return n&&r?`${n}, ${r}`:r?`Up to ${t} MB`:n}function E({item:e,isImage:t,onRemove:n}){let l=c(e,t),u=i(e),p=a(e),m=s(e),h=o(e),g=r(e);return/* @__PURE__ */ C(`div`,{className:h?`attach-preview wui-attach-failed`:`attach-preview`,children:[/* @__PURE__ */ C(`div`,{className:`attach-figure`,children:[/* @__PURE__ */ S(`img`,{src:l,alt:u}),/* @__PURE__ */ S(`button`,{type:`button`,className:`attach-remove`,"aria-label":`Remove attachment`,onClick:n,children:/* @__PURE__ */ S(d,{name:`x`,size:18})})]}),/* @__PURE__ */ C(`div`,{className:`attach-meta`,children:[/* @__PURE__ */ S(`div`,{className:`attach-name`,children:g?/* @__PURE__ */ S(`a`,{href:g,children:u}):u}),p&&/* @__PURE__ */ S(`div`,{className:`attach-size`,children:p})]}),m!==null&&/* @__PURE__ */ S(f,{value:m,size:`sm`,label:`Uploading ${u}`,className:`wui-attach-progress`}),h&&/* @__PURE__ */ S(`div`,{className:`wui-attach-error`,children:h})]})}export{w as default};
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{keyOf as r}from"../lib/fileItem.js";import i from"../lib/useFileDrop.js";import{splitMarkerProps as a}from"../lib/wuiMarker.js";import o from"./AppIcon.js";import ee from"./AppRequiredMark.js";import te from"./AppSpinner.js";import ne from"./warnInvalidValue.js";import s from"./warnUnknownProps.js";import re from"./withTooltip.js";import{DEFAULT_MAX_SIZE_MB as ie,acceptDroppedFiles as ae,acceptLabel as c,isImageFile as l,isImageOnlyAccept as oe,isPdfFile as se}from"@webority/ui-elements/helpers";import{useEffect as u,useId as ce,useRef as le,useState as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";var m=[`dropzone`,`button`];function h(h){let{marker:ue,props:de}=a(`AppFilePicker`,h),{label:g,value:_,name:fe,id:pe,onPick:v,multiple:y=!1,variant:b=`dropzone`,buttonLabel:me=`Add file`,maxFiles:x,accept:S=`.jpg,.jpeg,.png`,maxSizeMb:C=ie,required:w,optional:T=!1,error:he,hint:E,loading:D=!1,className:O=``,fieldClassName:k=``,style:A,...j}=de;s(`AppFilePicker`,j),ne(`AppFilePicker`,`variant`,b,m);let[ge,M]=d(null),[_e,N]=d(null),[P,F]=d(``),I=le(null),ve=ce(),L=pe||ve;u(()=>{if(!y&&_ instanceof File&&l(_)){let e=URL.createObjectURL(_);return M(e),()=>URL.revokeObjectURL(e)}M(null)},[_,y]);let R=!y&&_&&!l(_)&&se(_)?_ instanceof File?_:_.url:null;u(()=>{if(!R){N(null);return}let t=!0,n=null;return import(`@webority/ui-elements/file-viewer`).then(e=>e.renderPdfFirstPage(typeof R==`string`?{url:R}:R)).then(e=>{t&&(n=URL.createObjectURL(e),N(n))}).catch(t=>e(`[AppFilePicker] the PDF preview failed:`,t?.message)),()=>{t=!1,N(null),n&&URL.revokeObjectURL(n)}},[R]);let z=y?Array.isArray(_)?_:_?[_]:[]:[],B=he||P,V=B?`${L}-error`:void 0,H=E&&!B?`${L}-hint`:void 0,ye=V||H,U=oe(S),be=b===`button`,W=!y&&!!_,G=W&&(_ instanceof File?l(_):U||l(_)),xe=_?.name,K=G?_?.url||ge:_e,q=G?`image`:`file`,Se=g?`Change ${g}`:`Change ${q}`,J=g?`Remove ${g}`:`Remove ${q}`,Ce=g?`${g} preview`:`Selected ${q} preview`,Y={accept:S,maxSizeMb:C,multiple:y},X=e=>{if(F(``),!y){v(e[0]);return}let t=Array.isArray(_)?_:_?[_]:[],n=new Set(t.map(r)),i=[];for(let t of e)n.has(r(t))||(n.add(r(t)),i.push(t));let a=t.concat(i);x&&a.length>x&&(a=a.slice(0,x),F(`Up to ${x} files.`)),v(a)},Z=e=>F(e.message),{dragOver:we,dropProps:Te}=i({...Y,disabled:D,onFiles:X,onReject:Z}),Ee=e=>{let{files:t,rejections:n}=ae(e,Y);t.length&&X(t),n.length&&Z(n[0])},De=e=>Ee(e.target.files),Oe=e=>{F(``),v(z.filter((t,n)=>n!==e))},ke=()=>I.current?.click(),Q=D?/* @__PURE__ */ f(`span`,{className:`wui-file-busy`,children:/* @__PURE__ */ f(te,{size:`sm`})}):null,$=/* @__PURE__ */ f(`input`,{id:L,name:fe,ref:I,type:`file`,"aria-describedby":ye,accept:S,multiple:y||void 0,disabled:D||void 0,className:`visually-hidden`,onClick:e=>{e.currentTarget.value=``},onChange:De,...j});return/* @__PURE__ */ p(`div`,{...ue,className:`field${k?` ${k}`:``}`,children:[/* @__PURE__ */ p(`label`,{className:`label`,htmlFor:L,children:[g,T&&!w&&/* @__PURE__ */ f(`span`,{className:`label-optional`,children:` (optional)`}),w&&/* @__PURE__ */ f(ee,{})]}),be?/* @__PURE__ */ p(`div`,{className:`file-input wui-file-input-button-field${B?` error`:``}${O?` ${O}`:``}`,style:A,"aria-busy":D||void 0,children:[/* @__PURE__ */ p(`label`,{htmlFor:L,className:`btn btn-outline-primary btn-sm`,children:[/* @__PURE__ */ f(o,{name:`paperclip`,size:16}),me]}),$,Q]}):W?/* @__PURE__ */ p(`div`,{className:`file-preview${B?` error`:``}${O?` ${O}`:``}`,style:A,"aria-busy":D||void 0,children:[/* @__PURE__ */ p(`button`,{type:`button`,className:`file-preview-open`,"aria-label":Se,onClick:ke,disabled:D,children:[K?/* @__PURE__ */ f(`img`,{src:K,alt:Ce,className:`file-preview-img`}):/* @__PURE__ */ p(`span`,{className:`file-preview-file`,children:[/* @__PURE__ */ f(o,{name:`file-text`,size:28}),/* @__PURE__ */ f(`span`,{className:`file-preview-file-name`,children:xe})]}),/* @__PURE__ */ f(`span`,{className:`file-preview-overlay`,children:/* @__PURE__ */ p(`span`,{className:`file-preview-cta`,children:[/* @__PURE__ */ f(o,{name:G?`image`:`file-text`,size:16}),` `,G?`Change image`:`Change file`]})})]}),re(/* @__PURE__ */ f(`button`,{type:`button`,className:`file-preview-remove`,"aria-label":J,onClick:()=>v(null),disabled:D,children:/* @__PURE__ */ f(o,{name:`x`,size:16})}),J),$,Q]}):/* @__PURE__ */ p(`div`,{className:`file-input file-input-tall${we?` dragging`:``}${B?` error`:``}${y&&z.length>0?` has-files`:``}${O?` ${O}`:``}`,style:A,"aria-busy":D||void 0,...Te,children:[/* @__PURE__ */ p(`label`,{htmlFor:L,className:`file-input-zone-label`,children:[/* @__PURE__ */ f(`span`,{className:`file-input-icon`,children:/* @__PURE__ */ f(o,{name:`upload`,size:24})}),/* @__PURE__ */ p(`span`,{className:`file-input-title`,children:[/* @__PURE__ */ f(`span`,{className:`browse`,children:`Click to upload`}),` or drag & drop`]}),/* @__PURE__ */ f(`span`,{className:`file-input-text`,children:C>0?`${c(S)}, up to ${C} MB`:c(S)})]}),$,Q,y&&z.length>0&&/* @__PURE__ */ f(`div`,{className:`attach-list`,children:z.map((e,t)=>/* @__PURE__ */ f(n,{item:e,isImage:e instanceof File?l(e):U||l(e),noun:`file`,onRemove:()=>Oe(t)},r(e)))})]}),/* @__PURE__ */ f(t,{error:B,hint:E,errorId:V,hintId:H})]})}export{h as default};
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,onPick:_,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,hint: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{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./warnUnknownProps.js";import{Fragment as r,jsx as i,jsxs as a}from"react/jsx-runtime";function o(e){let t=e.lastIndexOf(`.`),n=t>0?e.slice(t+1):``;return n.length>0?n.slice(0,4).toUpperCase():`FILE`}function s(t){let n=e({sizeBytes:t.sizeBytes});return n&&t.meta?/* @__PURE__ */ a(r,{children:[n,` · `,t.meta]}):n||t.meta||null}function c(e){let{marker:c,props:l}=t(`AppFileTiles`,e),{label:u,files:d=[],className:f=``,...p}=l;if(n(`AppFileTiles`,p),d.some(e=>!e.name))throw Error(`<AppFileTiles> each file needs a name.`);let m=[`wui-file-tiles`,f].filter(Boolean).join(` `);return/* @__PURE__ */ i(`ul`,{className:m,"aria-label":u,...c,...p,children:d.map(e=>{let t=s(e),n=/* @__PURE__ */ a(r,{children:[/* @__PURE__ */ i(`span`,{className:`wui-file-tile-ext`,"aria-hidden":`true`,children:o(e.name)}),/* @__PURE__ */ a(`span`,{className:`wui-file-tile-text`,children:[/* @__PURE__ */ i(`span`,{className:`wui-file-tile-name`,children:e.name}),t?/* @__PURE__ */ i(`span`,{className:`wui-file-tile-meta`,children:t}):null]})]});return/* @__PURE__ */ i(`li`,{children:e.href?/* @__PURE__ */ i(`a`,{className:`wui-file-tile`,href:e.href,children:n}):/* @__PURE__ */ i(`div`,{className:`wui-file-tile`,children:n})},e.key)})})}export{c as default};
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{devWarn as e}from"../lib/devWarn.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./AppButton.js";import r from"./AppChip.js";import i from"./AppDateRangePicker.js";import ee from"./AppIcon.js";import a from"./AppMultiSelect.js";import o from"./AppSearch.js";import s from"./AppSegmented.js";import c from"./AppSelect.js";import te from"./AppSwitch.js";import ne from"./warnInvalidValue.js";import l from"./warnUnknownProps.js";import{Fragment as u,useEffect as d,useId as f,useRef as p,useState as re,useSyncExternalStore as ie}from"react";import{Fragment as m,jsx as h,jsxs as g}from"react/jsx-runtime";import"@webority/ui-elements/elements/filter-popover";import{emptyFacetValue as _,isFacetActive as v}from"@webority/ui-elements/listQuery";var y=`(max-width: 575.98px)`,b=3,x=2,S=e=>{let t=window.matchMedia?.(y);return t?.addEventListener(`change`,e),()=>t?.removeEventListener(`change`,e)},ae=()=>window.matchMedia?.(y).matches??!1,oe=[`enum`,`multiEnum`,`dateRange`,`text`],C=4,se=e=>(e.type===`enum`||e.type===`multiEnum`)&&!e.options?.length,w=(e,t)=>e.options?.find(e=>e.value===t)?.label??t,ce=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function le(e,t){if(e.required||!v(e,t))return[];if(e.type===`enum`)return[{id:e.key,text:w(e,t),clear:()=>_(e)}];if(e.type===`multiEnum`)return t.map(n=>({id:`${e.key}:${n}`,text:w(e,n),clear:()=>t.filter(e=>e!==n)}));if(e.type===`dateRange`){let n=t.from&&t.to?`${t.from} to ${t.to}`:t.from?`From ${t.from}`:`Until ${t.to}`;return[{id:e.key,text:n,clear:()=>_(e)}]}return[]}var T=/* @__PURE__ */ new Set;function E(t){let n=!0;try{n=process.env.NODE_ENV!==`production`}catch{n=!0}n&&!T.has(t)&&(T.add(t),e(`[@webority/ui-react] <AppFilterBar> facet "${t}" sets allLabel, which only an enum facet uses.`))}var D=/* @__PURE__ */ new Set;function ue(t){let n=!0;try{n=process.env.NODE_ENV!==`production`}catch{n=!0}n&&!D.has(t)&&(D.add(t),e(`[@webority/ui-react] <AppFilterBar> facet "${t}" sets required, which only an enum facet uses.`))}var O=/* @__PURE__ */ new Set;function de(t){let n=!0;try{n=process.env.NODE_ENV!==`production`}catch{n=!0}n&&!O.has(t)&&(O.add(t),e(`[@webority/ui-react] <AppFilterBar> facet "${t}" sets allLabel and required; a required facet has no All segment.`))}var k=/* @__PURE__ */ new Set;function fe(t){let n=!0;try{n=process.env.NODE_ENV!==`production`}catch{n=!0}n&&!k.has(t)&&(k.add(t),e(`[@webority/ui-react] <AppFilterBar> facet "${t}" sets presets, which only a dateRange facet uses.`))}function A(e){let{marker:i,props:a}=t(`AppFilterBar`,e),{facets:o,value:s,onChange:c,inline:y=b,floating:C=!1,apply:w=!1,className:T=``,...D}=a;l(`AppFilterBar`,D);let O=ie(S,ae,()=>!1),k=p(null),A=f(),[M,N]=re({}),P=p(s);for(let e of o)ne(`AppFilterBar`,`facets[].type`,e.type,oe);for(let e of o)e.allLabel!=null&&e.type!==`enum`&&E(e.key),e.required&&e.type!==`enum`&&ue(e.key),e.required&&e.allLabel!=null&&de(e.key),e.presets!=null&&e.type!==`dateRange`&&fe(e.key);let F=o.filter(e=>!se(e)),I=F.flatMap(e=>le(e,s[e.key]).map(t=>({...t,facet:e}))),L=F.filter(e=>!e.required&&v(e,s[e.key])),R=C||O?0:Math.max(0,y),z=F.slice(R),B=z.filter(e=>L.includes(e)).length,V=!C&&z.length>0;d(()=>{if(!V)return;let e=e=>{let t=k.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]),d(()=>{let e=P.current;P.current=s,N(t=>{let n=Object.entries(t).filter(([t])=>ce(e[t],s[t]));return n.length===Object.keys(t).length?t:Object.fromEntries(n)})},[s]);let H=e=>w&&!C&&(e.type===`text`||e.type===`dateRange`),U=e=>H(e)&&Object.hasOwn(M,e.key)?M[e.key]:s[e.key],W=e=>t=>H(e)?N(n=>({...n,[e.key]:t})):c(e.key,t),G=()=>{for(let[e,t]of Object.entries(M))c(e,t);N({})},pe=e=>{e.key===`Enter`&&G()},me=e=>{e.preventDefault(),G()},K=(e,t)=>e.type===`text`&&H(e)?/* @__PURE__ */ h(`span`,{onKeyDownCapture:pe,children:t}):t,he=e=>/* @__PURE__ */ h(u,{children:K(e,/* @__PURE__ */ h(j,{facet:e,value:U(e),onChange:W(e)}))},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(j,{facet:e,value:U(e),onChange:W(e),floating:!0}))]},e.key),J=(e,t)=>t>0&&/* @__PURE__ */ h(`span`,{className:e,children:` (${t})`}),Y=e=>/* @__PURE__ */ h(r,{size:`sm`,label:`${e.facet.label}: ${e.text}`,removeLabel:`Remove ${e.facet.label} filter ${e.text}`,onRemove:()=>c(e.facet.key,e.clear()),className:!C&&F.indexOf(e.facet)<R?`wui-filter-chip-inline`:void 0},e.id),X=/* @__PURE__ */ h(n,{variant:`ghost`,size:`sm`,onClick:()=>{for(let e of L)c(e.key,_(e));N({})},children:`Clear all`});if(C){let e=I.slice(x),t=L.length;return/* @__PURE__ */ g(`div`,{className:`wui-filter-bar d-flex flex-wrap align-items-center gap-2${T?` ${T}`:``}`,...i,...D,children:[/* @__PURE__ */ g(`wui-filter-popover`,{class:`wui-filter-popover`,children:[/* @__PURE__ */ g(n,{variant:t>0?`outline`:`ghost`,size:`sm`,leftIcon:`filter`,className:`wui-filter-popover-trigger`,"aria-expanded":`false`,"aria-controls":A,"aria-label":t>0?`Filters, ${t} active`:void 0,children:[`Filters`,t>0&&/* @__PURE__ */ h(`span`,{className:`badge rounded-pill text-bg-primary ms-1`,children:t})]}),/* @__PURE__ */ g(`div`,{id:A,className:`wui-filter-popover-panel`,role:`dialog`,"aria-label":`Filters`,hidden:!0,children:[/* @__PURE__ */ g(`div`,{className:`wui-filter-popover-head`,children:[/* @__PURE__ */ h(`span`,{className:`wui-filter-popover-title`,children:`Filters`}),/* @__PURE__ */ h(te,{label:`Keep open`,id:`${A}-pin`})]}),/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-grid`,children:F.map(q)}),/* @__PURE__ */ g(`div`,{className:`wui-filter-popover-foot`,children:[/* @__PURE__ */ h(`span`,{className:`wui-filter-popover-note`,children:`Changes apply at once.`}),t>0&&X]})]})]}),I.slice(0,x).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${O&&V?` wui-filter-bar--folded`:``}`,Q=e=>`${e}${T?` ${T}`:``}`,$=/* @__PURE__ */ g(m,{children:[F.slice(0,R).map(he),V&&/* @__PURE__ */ g(`details`,{ref:k,className:`wui-filter-more`,children:[/* @__PURE__ */ g(`summary`,{className:`btn btn-outline-primary btn-sm wui-filter-more-trigger`,children:[/* @__PURE__ */ h(ee,{name:`filter`,size:14,className:`me-2`}),`Filters`,J(`wui-filter-count-desktop`,B),J(`wui-filter-count-phone`,L.length)]}),/* @__PURE__ */ g(`div`,{className:`wui-filter-more-panel`,children:[/* @__PURE__ */ h(`div`,{className:`wui-filter-more-head`,children:`Filters`}),z.map(q)]})]}),I.map(Y),L.length>0&&X]});return!w||!F.some(e=>e.type===`text`||e.type===`dateRange`)?/* @__PURE__ */ h(`div`,{className:Q(Z),...i,...D,children:$}):/* @__PURE__ */ g(`div`,{className:Q(`wui-filter-form d-flex flex-wrap align-items-center gap-2`),...i,...D,children:[/* @__PURE__ */ h(`div`,{className:Z,children:$}),/* @__PURE__ */ h(n,{type:`submit`,size:`sm`,onClick:me,children:`Apply`})]})}function j({facet:e,value:t,onChange:n,floating:r=!1}){if(e.type===`enum`){let i=e.options??[];return(e.required?i.length<=C:i.length<C)?/* @__PURE__ */ h(s,{label:e.label,name:e.key,size:`sm`,value:t??``,onChange:n,options:e.required?i:[{value:``,label:e.allLabel||`All`},...i]}):/* @__PURE__ */ h(c,{"aria-label":e.label,name:e.key,placeholder:r?`Any`:e.label,clearable:!e.required,size:`sm`,value:t??``,onChange:n,options:i})}return e.type===`multiEnum`?/* @__PURE__ */ h(a,{"aria-label":e.label,name:e.key,placeholder:r?`Any`:e.label,size:`sm`,collapseChips:!0,values:t??[],onChange:n,options:e.options??[]}):e.type===`dateRange`?/* @__PURE__ */ h(i,{ariaLabel:e.label,startName:`${e.key}From`,endName:`${e.key}To`,placeholder:r?`Any`:e.label,size:`sm`,presets:e.presets,start:t?.from??``,end:t?.to??``,onChange:e=>n({from:e.start??``,to:e.end??``})}):/* @__PURE__ */ h(o,{ariaLabel:e.label,name:e.key,placeholder:e.label,size:`sm`,value:t??``,onChange:n})}export{A as default};
1
+ import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/fillLabel.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppButton.js";import i from"./AppChip.js";import a from"./AppDateRangePicker.js";import o from"./AppIcon.js";import s from"./AppMultiSelect.js";import c from"./AppSearch.js";import l from"./AppSegmented.js";import u from"./AppSelect.js";import ee from"./AppSwitch.js";import d from"./warnInvalidValue.js";import te from"./warnUnknownProps.js";import{Fragment as ne,useEffect as f,useId as re,useRef as p,useState as ie,useSyncExternalStore as ae}from"react";import{Fragment as oe,jsx as m,jsxs as h}from"react/jsx-runtime";import"@webority/ui-elements/elements/filter-popover";import{emptyFacetValue as g,isFacetActive as _}from"@webority/ui-elements/listQuery";var v=`(max-width: 575.98px)`,se=3,y=2,ce=e=>{let t=window.matchMedia?.(v);return t?.addEventListener(`change`,e),()=>t?.removeEventListener(`change`,e)},le=()=>window.matchMedia?.(v).matches??!1,ue=[`enum`,`multiEnum`,`dateRange`,`text`],de=[`sm`,`md`],b=4,fe=e=>(e.type===`enum`||e.type===`multiEnum`)&&!e.options?.length,x=(e,t)=>e.options?.find(e=>e.value===t)?.label??t,pe=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function me(e,n,r){if(e.required||!_(e,n))return[];if(e.type===`enum`)return[{id:e.key,text:x(e,n),clear:()=>g(e)}];if(e.type===`multiEnum`)return n.map(t=>({id:`${e.key}:${t}`,text:x(e,t),clear:()=>n.filter(e=>e!==t)}));if(e.type===`dateRange`){let i=n.from&&n.to?t(r.range,{from:n.from,to:n.to}):n.from?t(r.from,{date:n.from}):t(r.until,{date:n.to});return[{id:e.key,text:i,clear:()=>g(e)}]}return[]}var S=/* @__PURE__ */ new Set;function he(t){let n=!0;try{n=process.env.NODE_ENV!==`production`}catch{n=!0}n&&!S.has(t)&&(S.add(t),e(`[@webority/ui-react] <AppFilterBar> facet "${t}" sets allLabel, which only an enum facet uses.`))}var C=/* @__PURE__ */ new Set;function ge(t){let n=!0;try{n=process.env.NODE_ENV!==`production`}catch{n=!0}n&&!C.has(t)&&(C.add(t),e(`[@webority/ui-react] <AppFilterBar> facet "${t}" sets required, which only an enum facet uses.`))}var w=/* @__PURE__ */ new Set;function _e(t){let n=!0;try{n=process.env.NODE_ENV!==`production`}catch{n=!0}n&&!w.has(t)&&(w.add(t),e(`[@webority/ui-react] <AppFilterBar> facet "${t}" sets allLabel and required; a required facet has no All segment.`))}var T=/* @__PURE__ */ new Set;function ve(t){let n=!0;try{n=process.env.NODE_ENV!==`production`}catch{n=!0}n&&!T.has(t)&&(T.add(t),e(`[@webority/ui-react] <AppFilterBar> facet "${t}" sets presets, which only a dateRange facet uses.`))}function E(e){let{marker:a,props:s}=n(`AppFilterBar`,e),{facets:c,value:l,onChange:u,inline:v=se,floating:b=!1,apply:x=!1,size:S=`sm`,className:C=``,clearAllLabel:w=`Clear all`,filtersLabel:T=`Filters`,filtersActiveLabel:E=`Filters, {count} active`,keepOpenLabel:ye=`Keep open`,appliesAtOnceText:be=`Changes apply at once.`,applyLabel:xe=`Apply`,anyLabel:O=`Any`,removeChipLabel:Se=`Remove {facet} filter {value}`,dateFromText:Ce=`From {date}`,dateUntilText:we=`Until {date}`,dateRangeText:Te=`{from} to {to}`,...k}=s;te(`AppFilterBar`,k),d(`AppFilterBar`,`size`,S,de);let A=S===`md`,Ee={range:Te,from:Ce,until:we},j=ae(ce,le,()=>!1),M=p(null),N=re(),[P,F]=ie({}),I=p(l);for(let e of c)d(`AppFilterBar`,`facets[].type`,e.type,ue);for(let e of c)e.allLabel!=null&&e.type!==`enum`&&he(e.key),e.required&&e.type!==`enum`&&ge(e.key),e.required&&e.allLabel!=null&&_e(e.key),e.presets!=null&&e.type!==`dateRange`&&ve(e.key);let L=c.filter(e=>!fe(e)),R=L.flatMap(e=>me(e,l[e.key],Ee).map(t=>({...t,facet:e}))),z=L.filter(e=>!e.required&&_(e,l[e.key])),B=b||j?0:Math.max(0,v),V=L.slice(B),De=V.filter(e=>z.includes(e)).length,H=!b&&V.length>0;f(()=>{if(!H)return;let e=e=>{let t=M.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)}},[H]),f(()=>{let e=I.current;I.current=l,F(t=>{let n=Object.entries(t).filter(([t])=>pe(e[t],l[t]));return n.length===Object.keys(t).length?t:Object.fromEntries(n)})},[l]);let U=e=>x&&!b&&(e.type===`text`||e.type===`dateRange`),W=e=>U(e)&&Object.hasOwn(P,e.key)?P[e.key]:l[e.key],G=e=>t=>U(e)?F(n=>({...n,[e.key]:t})):u(e.key,t),K=()=>{for(let[e,t]of Object.entries(P))u(e,t);F({})},Oe=e=>{e.key===`Enter`&&K()},ke=e=>{e.preventDefault(),K()},q=(e,t)=>e.type===`text`&&U(e)?/* @__PURE__ */ m(`span`,{onKeyDownCapture:Oe,children:t}):t,Ae=e=>/* @__PURE__ */ m(ne,{children:q(e,/* @__PURE__ */ m(D,{facet:e,value:W(e),onChange:G(e),medium:A,anyLabel:O}))},e.key),J=e=>/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-field`,children:[/* @__PURE__ */ m(`span`,{className:`label`,"aria-hidden":`true`,children:e.label}),q(e,/* @__PURE__ */ m(D,{facet:e,value:W(e),onChange:G(e),floating:!0,medium:A,anyLabel:O}))]},e.key),Y=(e,t)=>t>0&&/* @__PURE__ */ m(`span`,{className:e,children:` (${t})`}),X=e=>/* @__PURE__ */ m(i,{size:`sm`,label:`${e.facet.label}: ${e.text}`,removeLabel:t(Se,{facet:e.facet.label,value:e.text}),onRemove:()=>u(e.facet.key,e.clear()),className:!b&&L.indexOf(e.facet)<B?`wui-filter-chip-inline`:void 0},e.id),Z=/* @__PURE__ */ m(r,{variant:`ghost`,size:A?void 0:`sm`,onClick:()=>{for(let e of z)u(e.key,g(e));F({})},children:w});if(b){let e=R.slice(y),n=z.length;return/* @__PURE__ */ h(`div`,{className:`wui-filter-bar d-flex flex-wrap align-items-center gap-2${C?` ${C}`:``}`,...a,...k,children:[/* @__PURE__ */ h(`wui-filter-popover`,{class:`wui-filter-popover`,children:[/* @__PURE__ */ h(r,{variant:n>0?`outline`:`ghost`,size:A?void 0:`sm`,leftIcon:`filter`,className:`wui-filter-popover-trigger`,"aria-expanded":`false`,"aria-controls":N,"aria-label":n>0?t(E,{count:n}):void 0,children:[T,n>0&&/* @__PURE__ */ m(`span`,{className:`badge rounded-pill text-bg-primary ms-1`,children:n})]}),/* @__PURE__ */ h(`div`,{id:N,className:`wui-filter-popover-panel`,role:`dialog`,"aria-label":T,hidden:!0,children:[/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-head`,children:[/* @__PURE__ */ m(`span`,{className:`wui-filter-popover-title`,children:T}),/* @__PURE__ */ m(ee,{label:ye,id:`${N}-pin`})]}),/* @__PURE__ */ m(`div`,{className:`wui-filter-popover-grid`,children:L.map(J)}),/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-foot`,children:[/* @__PURE__ */ m(`span`,{className:`wui-filter-popover-note`,children:be}),n>0&&Z]})]})]}),R.slice(0,y).map(X),e.length>0&&/* @__PURE__ */ h(`span`,{className:`chip chip-sm wui-filter-popover-more`,title:e.map(e=>`${e.facet.label}: ${e.text}`).join(`, `),children:[`+`,e.length]})]})}let Q=`wui-filter-bar d-flex flex-wrap align-items-center gap-2${j&&H?` wui-filter-bar--folded`:``}`,$=e=>`${e}${C?` ${C}`:``}`,je=/* @__PURE__ */ h(oe,{children:[L.slice(0,B).map(Ae),H&&/* @__PURE__ */ h(`details`,{ref:M,className:`wui-filter-more`,children:[/* @__PURE__ */ h(`summary`,{className:`btn btn-outline-primary${A?``:` btn-sm`} wui-filter-more-trigger`,children:[/* @__PURE__ */ m(o,{name:`filter`,size:14,className:`me-2`}),T,Y(`wui-filter-count-desktop`,De),Y(`wui-filter-count-phone`,z.length)]}),/* @__PURE__ */ h(`div`,{className:`wui-filter-more-panel`,children:[/* @__PURE__ */ m(`div`,{className:`wui-filter-more-head`,children:T}),V.map(J)]})]}),R.map(X),z.length>0&&Z]});return!x||!L.some(e=>e.type===`text`||e.type===`dateRange`)?/* @__PURE__ */ m(`div`,{className:$(Q),...a,...k,children:je}):/* @__PURE__ */ h(`div`,{className:$(`wui-filter-form d-flex flex-wrap align-items-center gap-2`),...a,...k,children:[/* @__PURE__ */ m(`div`,{className:Q,children:je}),/* @__PURE__ */ m(r,{type:`submit`,size:A?void 0:`sm`,onClick:ke,children:xe})]})}function D({facet:e,value:t,onChange:n,floating:r=!1,medium:i=!1,anyLabel:o}){if(e.type===`enum`){let a=e.options??[];return(e.required?a.length<=b:a.length<b)?/* @__PURE__ */ m(l,{label:e.label,name:e.key,size:i?`md`:`sm`,value:t??``,onChange:n,options:e.required?a:[{value:``,label:e.allLabel||`All`},...a]}):/* @__PURE__ */ m(u,{"aria-label":e.label,name:e.key,placeholder:r?o:e.label,clearable:!e.required,size:i?void 0:`sm`,value:t??``,onChange:n,options:a})}return e.type===`multiEnum`?/* @__PURE__ */ m(s,{"aria-label":e.label,name:e.key,placeholder:r?o:e.label,size:i?void 0:`sm`,collapseChips:!0,values:t??[],onChange:n,options:e.options??[]}):e.type===`dateRange`?/* @__PURE__ */ m(a,{ariaLabel:e.label,startName:`${e.key}From`,endName:`${e.key}To`,placeholder:r?o: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__ */ m(c,{ariaLabel:e.label,name:e.key,placeholder:e.label,size:i?void 0:`sm`,value:t??``,onChange:n})}export{E as default};
@@ -0,0 +1 @@
1
+ import{useFloatingStack as e}from"../lib/useFloatingStack.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n,{BUTTON_VARIANTS as r}from"./AppButton.js";import i from"./AppIcon.js";import a from"./warnInvalidValue.js";import o from"./warnUnknownProps.js";import{jsx as s}from"react/jsx-runtime";import{createPortal as c}from"react-dom";var l={sm:22,md:24,lg:28},u={sm:` wui-floating-btn--sm`,md:``,lg:` wui-floating-btn--lg`};function d(d){let{marker:f,props:p}=t(`AppFloatingButton`,d),{icon:m,label:h,onClick:g,position:_=`end`,order:v=`primary`,size:y=`md`,variant:b=`primary`,stacked:x=!0,disabled:S=!1,className:C=``,style:w,...T}=p;o(`AppFloatingButton`,T),a(`AppFloatingButton`,`position`,_,[`end`,`start`]),a(`AppFloatingButton`,`order`,v,[`primary`,`secondary`]),a(`AppFloatingButton`,`size`,y,Object.keys(l)),a(`AppFloatingButton`,`variant`,b,r);let E=e(_,x),D=typeof m==`string`?/* @__PURE__ */ s(i,{name:m,size:l[y]}):m,O=`wui-floating-btn`+(u[y]??``)+(v===`secondary`?` wui-floating-btn--secondary`:``)+(!x&&C?` ${C}`:``),k=e=>/* @__PURE__ */ s(n,{variant:b,className:O,disabled:S,onClick:g,"aria-label":h,tooltip:h,tooltipPlacement:_===`start`?`end`:`start`,...T,...f,...e,children:D});return x?E?c(/* @__PURE__ */ s(`span`,{className:[`wui-floating-stack-item`,`wui-floating-stack-item--${v}`,C].filter(Boolean).join(` `),style:w,children:k()}),E):null:k({style:w})}export{d 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&&gt(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,onPick: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,hint: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:`secondary`,disabled:U,onClick:Nt,children:D.cancel}),/* @__PURE__ */ m(r,{type:`button`,variant:`primary`,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-secondary 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:`secondary`,size:`sm`,disabled:q,"aria-describedby":xt,onClick:Tt,children:Ct}),n,/* @__PURE__ */ m(r,{variant:`secondary-danger`,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"./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,disabled:D=!1,className:O=``,id:k,...A}=v;i(`AppInlineEdit`,A),r(`AppInlineEdit`,`type`,x,f);let j=f.includes(x)?x:`text`,M=o(),N=k||`inline-edit-${M.replace(/[^a-zA-Z0-9_-]/g,``)}`,P=`${N}-error`,F=`${N}-control`,I=s(null),L=m(y),[R,z]=c(L),[B,V]=c(L);R!==L&&(z(L),V(L));let[H,U]=c(null),W=s(null);W.current={onSave:b,validate:T,kind:j},a(()=>{let e=I.current;if(e)return e.save=async e=>{U(e);try{await W.current.onSave?.(h(e,W.current.kind)),V(e)}finally{U(null)}},e.validate=e=>W.current.validate?.(h(e,W.current.kind))||null,()=>{e.save=void 0,e.validate=void 0}},[]);let G=H??B,K=p(G,{type:j,options:S,placeholder:w}),q=E&&!K.empty?E(h(G,j)):K.text,J={id:F,"data-wui-control":``,"aria-label":C},Y;if(j===`select`){let e=S.map(e=>({value:String(e.value),label:m(e.label??e.value)}));Y=/* @__PURE__ */ l(n,{id:F,"data-wui-control":``,"aria-label":C,size:`sm`,placeholder:w||void 0,options:e})}else Y=j===`date`?/* @__PURE__ */ l(`wui-datepicker`,{...J,size:`sm`,"aria-describedby":P,placeholder:w||void 0}):j===`textarea`?/* @__PURE__ */ l(`textarea`,{...J,className:`form-control textarea`,rows:3,"aria-describedby":P,placeholder:w||void 0}):/* @__PURE__ */ l(`input`,{...J,type:j===`number`?`number`:`text`,inputMode:j===`number`?`decimal`:void 0,className:`form-control input input-sm`,"aria-describedby":P,placeholder:w||void 0});return/* @__PURE__ */ u(`wui-inline-edit`,{ref:I,id:N,class:O?`wui-inline-edit ${O}`:`wui-inline-edit`,type:j,label:C,value:B,placeholder:w||void 0,disabled:D?``:void 0,controlled:``,..._,...A,children:[/* @__PURE__ */ u(`button`,{type:`button`,className:`wui-inline-edit-display`,"data-wui-display":``,"aria-describedby":P,disabled:D,children:[/* @__PURE__ */ l(`span`,{className:`visually-hidden`,children:D?d.readOnly(C):d.edit(C)}),/* @__PURE__ */ l(`span`,{className:`wui-inline-edit-value`,"data-wui-value":``,"data-wui-empty":K.empty?``:void 0,children:q}),/* @__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:Y}),/* @__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:P,"data-wui-error":``,hidden:!0}),/* @__PURE__ */ l(`span`,{className:`visually-hidden`,"data-wui-live":``,"aria-live":`polite`,"aria-atomic":`true`})]})}export{g as default};
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};
@@ -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"./AppIcon.js";import ee from"./AppInfoTip.js";import te from"./AppPopover.js";import i from"./AppRequiredMark.js";import a from"./warnInvalidValue.js";import ne from"./warnUnknownProps.js";import{MASK_INPUT_TYPES as re,MASK_NAMES as ie,attachInputMask as ae,evaluatePassword as oe,formatMasked as o,isMaskPattern as se,postedMasked as ce}from"@webority/ui-elements/helpers";import{forwardRef as le,useEffect as s,useId as ue,useRef as c,useState as l}from"react";import{Form as u}from"react-bootstrap";import{jsx as d,jsxs as f}from"react/jsx-runtime";var de=[`sm`,`md`,`lg`,`xl`],fe=[`bare`],pe=[`off`,`border`,`above`],me=[`off`,`shown`],p=le(function(le,p){let{marker:he,props:ge}=n(`AppInput`,le),{label:m,required:h=!1,optional:g=!1,error:_e,hint:ve,help:ye,helpLabel:be=`More information`,type:_=`text`,size:v=`md`,leftIcon:y,rightIcon:b,onRightIconClick:xe,rightIconLabel:Se,unit:x,id:Ce,name:we,className:Te=``,fieldClassName:S=``,disabled:C=!1,readOnly:w=!1,clearable:T=!1,showCount:E=!1,maxLength:D,prefix:O,suffix:k,action:A,floatingLabel:j=`off`,variant:M,passwordRequirements:N=`off`,passwordPolicy:Ee,requirementsPlacement:P=`auto`,mask:F,postFormatted:I=!1,onMaskChange:L,...R}=ge;ne(`AppInput`,R),a(`AppInput`,`size`,v,de),a(`AppInput`,`variant`,M,fe),a(`AppInput`,`floatingLabel`,j,pe),a(`AppInput`,`passwordRequirements`,N,me),s(()=>{g&&h&&typeof process<`u`&&process.env.NODE_ENV!==`production`&&e(`AppInput: optional and required together; optional ignored`)},[g,h]),F!=null&&!se(F)&&a(`AppInput`,`mask`,F,ie),F!=null&&a(`AppInput`,`type`,_,re);let[z,De]=l(!1),[Oe,ke]=l(``),B=_e||Oe,Ae=ue(),V=Ce||Ae,H=_===`password`,je=H&&z?`text`:_,U=c(null),Me=e=>{U.current=e,typeof p==`function`?p(e):p&&(p.current=e)},W=String(R.value??R.defaultValue??``),[Ne,G]=l(()=>!!W),[Pe,Fe]=l(()=>W.length),Ie=T&&!C&&!w,K=T||E,q=H&&N===`shown`,[Le,Re]=l(W);s(()=>{q&&R.value!==void 0&&Re(String(R.value??``))},[R.value,q]),s(()=>{if(!K||R.value===void 0)return;let e=String(R.value??``);G(!!e),Fe(e.length)},[R.value,K]);let ze=e=>{G(!!e.target.value),Fe(e.target.value.length),R.onInput?.(e)},Be=e=>{q&&Re(e.target.value),K?ze(e):R.onInput?.(e)},Ve=F?{...R.value!==void 0&&{value:o(F,R.value)},...R.defaultValue!==void 0&&{defaultValue:o(F,R.defaultValue)}}:null,He=c(L);He.current=L,s(()=>{let e=U.current;if(F&&e)return ae(e,{mask:F,postFormatted:I,onChange:(e,t)=>He.current?.(e,t),onInvalidChange:ke})},[F,I]);let J=e=>F&&!I&&e?t=>{let n=t.target,r=new Proxy(n,{get:(e,t)=>{if(t===`value`)return ce(F,e.value);let n=Reflect.get(e,t,e);return typeof n==`function`?n.bind(e):n}});e(Object.create(t,{target:{value:r}}))}:e,Ue=Ie?/* @__PURE__ */ d(`button`,{type:`button`,className:`input-clear`,onClick:()=>{let e=U.current;if(!e)return;let t=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,`value`)?.set;t?t.call(e,``):e.value=``,e.dispatchEvent(new Event(`input`,{bubbles:!0})),G(!1),e.focus()},"aria-label":`Clear`,tabIndex:-1,hidden:!Ne,children:/* @__PURE__ */ d(r,{name:`x`,size:16})}):null,We=B&&V?`${V}-error`:void 0,Ge=ve&&V?`${V}-hint`:void 0,Y=q&&P===`inline`,Ke=Y&&V?`${V}-requirements`:void 0,qe=We||(Y?Ke:Ge),Je=[`input`,v===`sm`?`input-sm`:``,v===`lg`?`input-lg`:``,v===`xl`?`wui-input-xl`:``,B?`error`:``,H?`pw`:``,x?`num-input`:``,!(j!==`off`&&m||O||k||x||H||b)&&T&&Ie?`has-clear`:``,M===`bare`?`input-bare`:``,Te].filter(Boolean).join(` `),X=/* @__PURE__ */ d(u.Control,{id:V,name:we,type:je,className:Je,disabled:C,readOnly:w,required:h,"aria-invalid":B?`true`:`false`,"aria-describedby":qe,maxLength:D,...R,onChange:J(R.onChange),onBlur:J(R.onBlur),...Ve,placeholder:j===`off`?R.placeholder:` `,ref:Me,onInput:K||q?Be:R.onInput}),Z=Ee??!0,Ye=Z&&typeof Z==`object`&&Z.title||`Password requirements`,Xe=q?oe(Le,Z):null,Q=q?/* @__PURE__ */ d(`ul`,{className:`pw-criteria`,"aria-live":`polite`,id:Ke,"aria-label":Y?Ye:void 0,children:Xe.map(e=>/* @__PURE__ */ f(`li`,{className:`pw-rule ${e.met?`met`:`unmet`}`,children:[/* @__PURE__ */ d(`span`,{className:`pw-mark`,"aria-hidden":`true`}),/* @__PURE__ */ d(`span`,{className:`pw-rule-text`,children:e.label}),/* @__PURE__ */ d(`span`,{className:`visually-hidden`,children:e.met?`: met`:`: not met`})]},e.key))}):null,$;if(j!==`off`&&m&&!H)$=/* @__PURE__ */ f(`div`,{className:j===`above`?`field-float wui-float-above`:`field-float`,children:[X,/* @__PURE__ */ f(`label`,{className:`float-label`,htmlFor:V,children:[m,h&&/* @__PURE__ */ d(i,{})]})]});else if(A)$=/* @__PURE__ */ f(`div`,{className:`input-action-row`,children:[/* @__PURE__ */ f(`div`,{className:y?`input-icon`:`input-wrap`,children:[y&&/* @__PURE__ */ d(`span`,{className:`ic`,children:/* @__PURE__ */ d(r,{name:y,size:16})}),X]}),/* @__PURE__ */ d(`div`,{className:`input-action`,children:A})]});else if(O||k)$=/* @__PURE__ */ f(`div`,{className:`input-affixed`,children:[O!=null&&/* @__PURE__ */ d(`span`,{className:`affix affix-pre`,children:O}),X,k!=null&&/* @__PURE__ */ d(`span`,{className:`affix affix-suf`,children:k})]});else if(x)$=/* @__PURE__ */ f(`div`,{className:`input-with-unit`,children:[X,/* @__PURE__ */ d(`span`,{className:`unit`,children:x})]});else if(H){let e=/* @__PURE__ */ f(`button`,{type:`button`,className:`pw-toggle${z?` pw-revealed`:``}`,onClick:()=>De(e=>!e),"aria-label":z?`Hide password`:`Show password`,tabIndex:-1,children:[/* @__PURE__ */ d(r,{name:`eye`,size:18,className:`pw-eye`}),/* @__PURE__ */ d(r,{name:`eye-off`,size:18,className:`pw-eye-off`})]}),t=j!==`off`&&m?/* @__PURE__ */ d(`div`,{className:j===`above`?`field-float wui-float-above`:`field-float`,children:/* @__PURE__ */ f(`div`,{className:`input-wrap`,children:[X,e,/* @__PURE__ */ f(`label`,{className:`float-label`,htmlFor:V,children:[m,h&&/* @__PURE__ */ d(i,{})]})]})}):/* @__PURE__ */ f(`div`,{className:y?`input-icon`:`input-wrap`,children:[y&&/* @__PURE__ */ d(`span`,{className:`ic`,children:/* @__PURE__ */ d(r,{name:y,size:16})}),X,e]});$=q&&!Y?/* @__PURE__ */ d(te,{trigger:t,triggerType:`focus`,placement:P,title:Ye,className:`pw-popover`,children:Q}):t}else $=b?/* @__PURE__ */ f(`div`,{className:`input-wrap`,children:[X,/* @__PURE__ */ d(`button`,{type:`button`,className:`pw-toggle`,onClick:xe,disabled:!xe,tabIndex:-1,"aria-label":Se||b,children:/* @__PURE__ */ d(r,{name:b,size:18})})]}):T?/* @__PURE__ */ f(`div`,{className:y?`input-icon`:`input-wrap`,children:[y&&/* @__PURE__ */ d(`span`,{className:`ic`,children:/* @__PURE__ */ d(r,{name:y,size:16})}),X,Ue]}):y?/* @__PURE__ */ f(`div`,{className:`input-icon`,children:[/* @__PURE__ */ d(`span`,{className:`ic`,children:/* @__PURE__ */ d(r,{name:y,size:16})}),X]}):X;return/* @__PURE__ */ f(u.Group,{...he,className:`field${S?` ${S}`:``}`,children:[m&&j===`off`&&/* @__PURE__ */ f(u.Label,{className:`label`,htmlFor:V,children:[m,g&&!h&&/* @__PURE__ */ d(`span`,{className:`label-optional`,children:` (optional)`}),h&&/* @__PURE__ */ d(i,{}),ye&&/* @__PURE__ */ d(ee,{label:be,children:ye})]}),$,Y&&/* @__PURE__ */ d(`div`,{className:`wui-pw-inline`,children:Q}),/* @__PURE__ */ d(t,{error:B,hint:Y?null:ve,errorId:We,hintId:Ge}),E&&/* @__PURE__ */ f(`div`,{className:`field-count${D&&Pe>=D?` at-limit`:``}`,children:[Pe,D?` / ${D}`:``]})]})});export{p as default};
1
+ import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import{FIELD_BUSY_CLASS as n,blockWhenReadOnly as r}from"../lib/fieldState.js";import{splitMarkerProps as ee}from"../lib/wuiMarker.js";import i from"./AppIcon.js";import te from"./AppInfoTip.js";import ne from"./AppPopover.js";import a from"./AppRequiredMark.js";import o from"./warnInvalidValue.js";import re from"./warnUnknownProps.js";import{MASK_INPUT_TYPES as ie,MASK_NAMES as ae,attachInputMask as oe,evaluatePassword as se,formatMasked as ce,isMaskPattern as le,postedMasked as ue}from"@webority/ui-elements/helpers";import{forwardRef as s,useEffect as c,useId as de,useRef as l,useState as u}from"react";import{Form as d}from"react-bootstrap";import{jsx as f,jsxs as p}from"react/jsx-runtime";var fe=[`sm`,`md`,`lg`],pe=[`bare`],me=[`off`,`border`,`above`],he=[`off`,`shown`],m=s(function(s,m){let{marker:ge,props:_e}=ee(`AppInput`,s),{label:h,required:g=!1,optional:_=!1,error:ve,hint:ye,help:be,helpLabel:xe=`More information`,type:v=`text`,size:y=`md`,leftIcon:b,rightIcon:x,onRightIconClick:Se,rightIconLabel:Ce,unit:S,id:we,name:Te,className:Ee=``,fieldClassName:C=``,disabled:w=!1,readOnly:T=!1,loading:E=!1,clearable:D=!1,clearLabel:De=`Clear`,optionalLabel:Oe=`(optional)`,requirementsTitle:ke=`Password requirements`,showPasswordLabel:Ae=`Show password`,hidePasswordLabel:je=`Hide password`,showCount:O=!1,maxLength:k,monospace:Me=!1,prefix:A,suffix:j,action:M,floatingLabel:N=`off`,variant:P,passwordRequirements:F=`off`,passwordPolicy:Ne,requirementsPlacement:I=`auto`,mask:L,postFormatted:R=!1,onMaskChange:z,...B}=_e;re(`AppInput`,B),o(`AppInput`,`size`,y,fe),o(`AppInput`,`variant`,P,pe),o(`AppInput`,`floatingLabel`,N,me),o(`AppInput`,`passwordRequirements`,F,he),c(()=>{_&&g&&typeof process<`u`&&process.env.NODE_ENV!==`production`&&e(`AppInput: optional and required together; optional ignored`)},[_,g]),L!=null&&!le(L)&&o(`AppInput`,`mask`,L,ae),L!=null&&o(`AppInput`,`type`,v,ie);let[V,Pe]=u(!1),[Fe,Ie]=u(``),H=ve||Fe,Le=de(),U=we||Le,W=v===`password`,Re=W&&V?`text`:v,G=l(null),ze=e=>{G.current=e,typeof m==`function`?m(e):m&&(m.current=e)},K=String(B.value??B.defaultValue??``),[Be,q]=u(()=>!!K),[Ve,He]=u(()=>K.length),Ue=D&&!w&&!T&&!E,J=D||O,Y=W&&F===`shown`,[We,Ge]=u(K);c(()=>{Y&&B.value!==void 0&&Ge(String(B.value??``))},[B.value,Y]),c(()=>{if(!J||B.value===void 0)return;let e=String(B.value??``);q(!!e),He(e.length)},[B.value,J]);let Ke=e=>{q(!!e.target.value),He(e.target.value.length),B.onInput?.(e)},qe=e=>{Y&&Ge(e.target.value),J?Ke(e):B.onInput?.(e)},Je=L?{...B.value!==void 0&&{value:ce(L,B.value)},...B.defaultValue!==void 0&&{defaultValue:ce(L,B.defaultValue)}}:null,Ye=l(z);Ye.current=z,c(()=>{let e=G.current;if(L&&e)return oe(e,{mask:L,postFormatted:R,onChange:(e,t)=>Ye.current?.(e,t),onInvalidChange:Ie})},[L,R]);let Xe=e=>L&&!R&&e?t=>{let n=t.target,r=new Proxy(n,{get:(e,t)=>{if(t===`value`)return ue(L,e.value);let n=Reflect.get(e,t,e);return typeof n==`function`?n.bind(e):n}});e(Object.create(t,{target:{value:r}}))}:e,Ze=Ue?/* @__PURE__ */ f(`button`,{type:`button`,className:`input-clear`,onClick:()=>{let e=G.current;if(!e)return;let t=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,`value`)?.set;t?t.call(e,``):e.value=``,e.dispatchEvent(new Event(`input`,{bubbles:!0})),q(!1),e.focus()},"aria-label":De,tabIndex:-1,hidden:!Be,children:/* @__PURE__ */ f(i,{name:`x`,size:16})}):null,Qe=H&&U?`${U}-error`:void 0,$e=ye&&U?`${U}-hint`:void 0,X=Y&&I===`inline`,et=X&&U?`${U}-requirements`:void 0,tt=Qe||(X?et:$e),nt=[`input`,y===`sm`?`input-sm`:``,y===`lg`?`input-lg`:``,H?`error`:``,W?`pw`:``,S?`num-input`:``,!(N!==`off`&&h||A||j||S||W||x)&&D&&Ue?`has-clear`:``,P===`bare`?`input-bare`:``,Me?`wui-mono`:``,E?n:``,Ee].filter(Boolean).join(` `),rt=r(T||E),it=rt?e=>{rt(e),B.onClick?.(e)}:B.onClick,Z=/* @__PURE__ */ f(d.Control,{id:U,name:Te,type:Re,className:nt,disabled:w,readOnly:T||E,"aria-busy":E||void 0,required:g,"aria-invalid":H?`true`:`false`,"aria-describedby":tt,maxLength:k,...B,onClick:it,onChange:Xe(B.onChange),onBlur:Xe(B.onBlur),...Je,placeholder:N===`off`?B.placeholder:` `,ref:ze,onInput:J||Y?qe:B.onInput}),Q=Ne??!0,at=Q&&typeof Q==`object`&&Q.title||ke,ot=Y?se(We,Q):null,st=Y?/* @__PURE__ */ f(`ul`,{className:`pw-criteria`,"aria-live":`polite`,id:et,"aria-label":X?at:void 0,children:ot.map(e=>/* @__PURE__ */ p(`li`,{className:`pw-rule ${e.met?`met`:`unmet`}`,children:[/* @__PURE__ */ f(`span`,{className:`pw-mark`,"aria-hidden":`true`}),/* @__PURE__ */ f(`span`,{className:`pw-rule-text`,children:e.label}),/* @__PURE__ */ f(`span`,{className:`visually-hidden`,children:e.met?`: met`:`: not met`})]},e.key))}):null,$;if(N!==`off`&&h&&!W)$=/* @__PURE__ */ p(`div`,{className:N===`above`?`field-float wui-float-above`:`field-float`,children:[Z,/* @__PURE__ */ p(`label`,{className:`float-label`,htmlFor:U,children:[h,g&&/* @__PURE__ */ f(a,{})]})]});else if(M)$=/* @__PURE__ */ p(`div`,{className:`input-action-row`,children:[/* @__PURE__ */ p(`div`,{className:b?`input-icon`:`input-wrap`,children:[b&&/* @__PURE__ */ f(`span`,{className:`ic`,children:/* @__PURE__ */ f(i,{name:b,size:16})}),Z]}),/* @__PURE__ */ f(`div`,{className:`input-action`,children:M})]});else if(A||j)$=/* @__PURE__ */ p(`div`,{className:`input-affixed`,children:[A!=null&&/* @__PURE__ */ f(`span`,{className:`affix affix-pre`,children:A}),Z,j!=null&&/* @__PURE__ */ f(`span`,{className:`affix affix-suf`,children:j})]});else if(S)$=/* @__PURE__ */ p(`div`,{className:`input-with-unit`,children:[Z,/* @__PURE__ */ f(`span`,{className:`unit`,children:S})]});else if(W){let e=/* @__PURE__ */ p(`button`,{type:`button`,className:`pw-toggle${V?` pw-revealed`:``}`,onClick:()=>Pe(e=>!e),"aria-label":V?je:Ae,tabIndex:-1,children:[/* @__PURE__ */ f(i,{name:`eye`,size:18,className:`pw-eye`}),/* @__PURE__ */ f(i,{name:`eye-off`,size:18,className:`pw-eye-off`})]}),t=N!==`off`&&h?/* @__PURE__ */ f(`div`,{className:N===`above`?`field-float wui-float-above`:`field-float`,children:/* @__PURE__ */ p(`div`,{className:`input-wrap`,children:[Z,e,/* @__PURE__ */ p(`label`,{className:`float-label`,htmlFor:U,children:[h,g&&/* @__PURE__ */ f(a,{})]})]})}):/* @__PURE__ */ p(`div`,{className:b?`input-icon`:`input-wrap`,children:[b&&/* @__PURE__ */ f(`span`,{className:`ic`,children:/* @__PURE__ */ f(i,{name:b,size:16})}),Z,e]});$=Y&&!X?/* @__PURE__ */ f(ne,{trigger:t,triggerType:`focus`,placement:I,title:at,className:`pw-popover`,children:st}):t}else $=x?/* @__PURE__ */ p(`div`,{className:`input-wrap`,children:[Z,/* @__PURE__ */ f(`button`,{type:`button`,className:`pw-toggle`,onClick:Se,disabled:!Se,tabIndex:-1,"aria-label":Ce||x,children:/* @__PURE__ */ f(i,{name:x,size:18})})]}):D?/* @__PURE__ */ p(`div`,{className:b?`input-icon`:`input-wrap`,children:[b&&/* @__PURE__ */ f(`span`,{className:`ic`,children:/* @__PURE__ */ f(i,{name:b,size:16})}),Z,Ze]}):b?/* @__PURE__ */ p(`div`,{className:`input-icon`,children:[/* @__PURE__ */ f(`span`,{className:`ic`,children:/* @__PURE__ */ f(i,{name:b,size:16})}),Z]}):Z;return/* @__PURE__ */ p(d.Group,{...ge,className:`field${C?` ${C}`:``}`,children:[h&&N===`off`&&/* @__PURE__ */ p(d.Label,{className:`label`,htmlFor:U,children:[h,_&&!g&&/* @__PURE__ */ f(`span`,{className:`label-optional`,children:` ${Oe}`}),g&&/* @__PURE__ */ f(a,{}),be&&/* @__PURE__ */ f(te,{label:xe,children:be})]}),$,X&&/* @__PURE__ */ f(`div`,{className:`wui-pw-inline`,children:st}),/* @__PURE__ */ f(t,{error:H,hint:X?null:ye,errorId:Qe,hintId:$e}),O&&/* @__PURE__ */ p(`div`,{className:`field-count${k&&Ve>=k?` at-limit`:``}`,children:[Ve,k?` / ${k}`:``]})]})});export{m as default};
@@ -1 +1 @@
1
- import{splitMarkerProps as e}from"../lib/wuiMarker.js";import t from"./AppIcon.js";import{errorToast as n}from"./toast.js";import r from"./warnInvalidValue.js";import i from"./warnUnknownProps.js";import{formatValue as a}from"@webority/ui-elements/helpers";import{useEffect as o,useId as s,useMemo as c,useRef as l,useState as u}from"react";import{jsx as d,jsxs as f}from"react/jsx-runtime";import{KANBAN_SUMMARY_FORMATS as p,KANBAN_TEXT as m,KANBAN_TONES as h,kanbanOverflow as g,kanbanSummaryFormat as _,kanbanVisibleLimit as v,sumKanbanValues as ee}from"@webority/ui-elements/elements/kanban";var te=e=>e.key??e.id,y=e=>e.column,b=[`rupees`,`paise`],ne=[`inline`,`stacked`];function x(x){let{marker:S,props:C}=e(`AppKanban`,x),{columns:w,cards:T,renderCard:E,renderColumnActions:D,getCardKey:O=te,getCardColumn:k=y,getCardValue:A,cardLabel:j,isCardLocked:re,onLocked:ie,onMove:ae,accept:oe,filter:se,boardId:ce,ariaLabel:le=`Board`,emptyText:ue=m.empty,readOnly:de=!1,swipeHint:M=!1,fill:N=!1,columnWidth:P,fillOffset:F,activeCardKey:I,headLayout:L=`inline`,summaryFormat:R,summaryUnit:z,className:B=``,id:V,...H}=C;if(!Array.isArray(w))throw Error(`<AppKanban> columns is required: pass the board's stage columns.`);if(!Array.isArray(T))throw Error(`<AppKanban> cards is required: pass the cards, an empty array for an empty board.`);i(`AppKanban`,H),r(`AppKanban`,`summaryFormat`,R,p),r(`AppKanban`,`summaryUnit`,z,b),r(`AppKanban`,`headLayout`,L,ne);for(let e of w)r(`AppKanban`,`columns[].tone`,e.tone,h);let fe=s(),U=V||`kanban-${fe.replace(/[^a-zA-Z0-9_-]/g,``)}`,W=l(null),[G,K]=u(()=>/* @__PURE__ */ new Map),[q,pe]=u(()=>/* @__PURE__ */ new Set),[me,J]=u(()=>/* @__PURE__ */ new Set),he=c(()=>new Map(T.map(e=>[String(O(e)),e])),[T,O]),Y=l(null);Y.current={accept:oe,onMove:ae,onLocked:ie,byKey:he,columns:w};let X=R&&p.includes(R)&&(z==null||b.includes(z))?_(R,z):null,Z=c(()=>{let e=new Map(w.map(e=>[e.key,[]])),t=[];for(let n of T){let r=String(O(n)),i=G.get(r);i?t.push([n,i]):e.get(k(n))?.push(n)}for(let[n,r]of t){let t=e.get(r.to);t&&t.splice(Math.min(r.index,t.length),0,n)}return e},[w,T,G,O,k]);o(()=>{let e=W.current;if(!e)return;e.accept=(e,t,n)=>{let r=Y.current.accept;return!r||r(Y.current.byKey.get(e.getAttribute(`data-wui-card`)),t,n)};let t=e=>{let{key:t,from:r,to:i,index:a}=e.detail,o=Y.current.onMove,s=Y.current.byKey.get(t);if(!o||!s)return;let c=Y.current.columns.find(e=>e.key===i)?.visibleLimit!=null;c&&J(e=>new Set(e).add(t)),K(e=>new Map(e).set(t,{to:i,index:a}));let l=()=>K(e=>{let n=new Map(e);return n.delete(t),n}),u;try{u=o({card:s,key:t,from:r,to:i,index:a})}catch(e){u=Promise.reject(e)}Promise.resolve(u).then(l,e=>{l(),c&&J(e=>{let n=new Set(e);return n.delete(t),n}),n(e?.message||m.failed.server)})},r=e=>{let{key:t,reason:n}=e.detail,r=Y.current.byKey.get(t);r&&Y.current.onLocked?.({card:r,key:t,reason:n})};return e.addEventListener(`wui:kanban:move`,t),e.addEventListener(`wui:kanban:locked`,r),()=>{e.removeEventListener(`wui:kanban:move`,t),e.removeEventListener(`wui:kanban:locked`,r),e.accept=void 0}},[]);let Q=e=>se?.(e)!==!1,ge=(e,t)=>{q.has(e)&&J(e=>{let n=new Set(e);for(let e of t)n.delete(String(O(e)));return n}),pe(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},$={};return P!=null&&($[`--wui-kanban-column-width`]=`${P}px`),F!=null&&($[`--wui-kanban-fill-offset`]=`${F}px`),/* @__PURE__ */ f(`wui-kanban`,{ref:W,id:U,class:B?`wui-kanban ${B}`:`wui-kanban`,role:`region`,"aria-label":le,"board-id":ce||void 0,"summary-format":X?R:void 0,"summary-unit":X&&z?z:void 0,readonly:de?``:void 0,fill:N?``:void 0,"data-head-layout":L===`stacked`?`stacked`:void 0,style:$,controlled:``,...S,...H,children:[/* @__PURE__ */ d(`nav`,{className:`wui-kanban-switcher`,"aria-label":`Board columns`,children:w.map((e,t)=>/* @__PURE__ */ f(`button`,{type:`button`,className:`wui-kanban-switch`,"data-wui-switch":e.key,"aria-controls":`${U}-${e.key}`,"aria-current":t===0?`true`:void 0,children:[/* @__PURE__ */ d(`span`,{className:`wui-kanban-switch-title`,children:e.title}),/* @__PURE__ */ d(`span`,{className:`wui-kanban-count`,"data-wui-count":``,children:(Z.get(e.key)||[]).filter(Q).length})]},e.key))}),M&&/* @__PURE__ */ f(`p`,{className:`wui-kanban-hint`,"aria-hidden":`true`,children:[/* @__PURE__ */ d(t,{name:`arrow-swap-horizontal`,size:14}),m.swipeHint]}),/* @__PURE__ */ d(`div`,{className:`wui-kanban-board`,"data-wui-scroller":``,children:w.map(e=>{let n=`${U}-${e.key}`,r=Z.get(e.key)||[],i=r.filter(Q),o=!!(e.collapsible&&e.collapsed),s=v(e.visibleLimit),c=q.has(e.key),l=g(i.map(e=>String(O(e))),s,c,me),u=typeof e.summary==`function`?e.summary(i):e.summary;X&&(u=a(ee(i.map(e=>A?.(e))),X));let p=D?.(e,i);return/* @__PURE__ */ f(`section`,{className:`wui-kanban-column`,id:n,"data-wui-column":e.key,"data-tone":e.tone&&h.includes(e.tone)?e.tone:`neutral`,"aria-labelledby":`${n}-title`,"data-accept-from":e.acceptFrom?e.acceptFrom.join(` `):void 0,"data-collapsible":e.collapsible?``:void 0,"data-collapsed":o?``:void 0,children:[/* @__PURE__ */ f(`header`,{className:`wui-kanban-head`,children:[/* @__PURE__ */ d(`span`,{className:`wui-kanban-dot`,"aria-hidden":`true`}),/* @__PURE__ */ d(`h2`,{className:`wui-kanban-title`,id:`${n}-title`,children:e.href?/* @__PURE__ */ d(`a`,{href:e.href,children:e.title}):e.title}),/* @__PURE__ */ d(`span`,{className:`wui-kanban-count`,"data-wui-count":``,children:i.length}),e.collapsible&&/* @__PURE__ */ d(`span`,{className:`wui-kanban-lock`,"aria-hidden":`true`,children:/* @__PURE__ */ d(t,{name:`lock`,size:14})}),p!=null&&p!==!1&&/* @__PURE__ */ d(`div`,{className:`wui-kanban-actions`,"data-wui-no-drag":``,children:p}),e.collapsible&&/* @__PURE__ */ d(`button`,{type:`button`,className:`wui-kanban-collapse`,"data-wui-collapse":``,"aria-expanded":o?`false`:`true`,"aria-controls":`${n}-body`,"aria-label":o?m.expand(e.title):m.collapse(e.title),children:/* @__PURE__ */ d(t,{name:`chevron-left`,size:16})}),u!=null&&/* @__PURE__ */ d(`div`,{className:`wui-kanban-summary`,"data-wui-summary":``,children:u})]}),/* @__PURE__ */ d(`p`,{className:`wui-kanban-drop-note`,"data-wui-drop-note":``,hidden:!0}),/* @__PURE__ */ d(`div`,{className:`wui-kanban-body`,id:`${n}-body`,"data-wui-body":``,children:r.map(e=>{let t=String(O(e)),n=G.has(t);return/* @__PURE__ */ d(`article`,{className:`wui-kanban-card`,"data-wui-card":t,tabIndex:0,"aria-label":j?j(e):void 0,"data-wui-locked":re?.(e)?``:void 0,"data-wui-value":A?A(e)??void 0:void 0,"aria-current":I!=null&&t===String(I)?`true`:void 0,"aria-busy":n?`true`:void 0,"data-wui-saving":n?``:void 0,"data-wui-overflow":l.has(t)?``:void 0,hidden:!Q(e),children:E?.(e)},t)})}),s!=null&&/* @__PURE__ */ d(`button`,{type:`button`,className:`wui-kanban-more`,"data-wui-more":``,"aria-controls":`${n}-body`,"aria-expanded":c?`true`:`false`,hidden:c?i.length<=s:l.size===0,onClick:()=>ge(e.key,r),children:c?m.fewer:m.more(l.size)}),/* @__PURE__ */ d(`p`,{className:`wui-kanban-empty`,"data-wui-empty":``,hidden:i.length>0,children:e.emptyText??ue})]},e.key)})}),/* @__PURE__ */ d(`p`,{className:`visually-hidden`,id:`${U}-help`,"data-wui-help":``,children:m.help}),/* @__PURE__ */ d(`div`,{className:`visually-hidden`,"data-wui-live":``,"aria-live":`polite`,"aria-atomic":`true`})]})}export{x as default};
1
+ import e from"../lib/fillLabel.js";import{linkTarget as t}from"../lib/linkTarget.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppIcon.js";import{errorToast as i}from"./toast.js";import a from"./warnInvalidValue.js";import o from"./warnUnknownProps.js";import{formatValue as s}from"@webority/ui-elements/helpers";import{useEffect as c,useId as l,useMemo as u,useRef as d,useState as f}from"react";import{jsx as p,jsxs as m}from"react/jsx-runtime";import{KANBAN_SUMMARY_FORMATS as h,KANBAN_TEXT as g,KANBAN_TONES as _,kanbanOverflow as ee,kanbanSummaryFormat as v,kanbanVisibleLimit as te,sumKanbanValues as ne}from"@webority/ui-elements/elements/kanban";var y=e=>e.key??e.id,re=e=>e.column,b=[`rupees`,`paise`],ie=[`inline`,`stacked`];function x(x){let{marker:ae,props:S}=n(`AppKanban`,x),{columns:C,cards:w,renderCard:oe,renderColumnActions:se,getCardKey:T=y,getCardColumn:E=re,getCardValue:D,cardLabel:O,isCardLocked:ce,onLocked:le,onMove:ue,accept:de,filter:fe,boardId:pe,ariaLabel:me=`Board`,columnsLabel:he=`Board columns`,expandLabel:ge=`Expand {title}`,collapseLabel:_e=`Collapse {title}`,emptyText:ve=g.empty,helpText:k=g.help,readOnly:A=!1,swipeHint:j=!1,swipeHintText:M=g.swipeHint,fill:N=!1,columnWidth:P,fillOffset:F,activeCardKey:I,headLayout:L=`inline`,summaryFormat:R,summaryUnit:z,className:B=``,id:ye,linkComponent:be,...V}=S;if(!Array.isArray(C))throw Error(`<AppKanban> columns is required: pass the board's stage columns.`);if(!Array.isArray(w))throw Error(`<AppKanban> cards is required: pass the cards, an empty array for an empty board.`);o(`AppKanban`,V),a(`AppKanban`,`summaryFormat`,R,h),a(`AppKanban`,`summaryUnit`,z,b),a(`AppKanban`,`headLayout`,L,ie);for(let e of C)a(`AppKanban`,`columns[].tone`,e.tone,_);let xe=l(),H=ye||`kanban-${xe.replace(/[^a-zA-Z0-9_-]/g,``)}`,U=d(null),[W,G]=f(()=>/* @__PURE__ */ new Map),[K,Se]=f(()=>/* @__PURE__ */ new Set),[q,J]=f(()=>/* @__PURE__ */ new Set),Ce=u(()=>new Map(w.map(e=>[String(T(e)),e])),[w,T]),Y=d(null);Y.current={accept:de,onMove:ue,onLocked:le,byKey:Ce,columns:C};let X=R&&h.includes(R)&&(z==null||b.includes(z))?v(R,z):null,Z=u(()=>{let e=new Map(C.map(e=>[e.key,[]])),t=[];for(let n of w){let r=String(T(n)),i=W.get(r);i?t.push([n,i]):e.get(E(n))?.push(n)}for(let[n,r]of t){let t=e.get(r.to);t&&t.splice(Math.min(r.index,t.length),0,n)}return e},[C,w,W,T,E]);c(()=>{let e=U.current;if(!e)return;e.accept=(e,t,n)=>{let r=Y.current.accept;return!r||r(Y.current.byKey.get(e.getAttribute(`data-wui-card`)),t,n)};let t=e=>{let{key:t,from:n,to:r,index:a}=e.detail,o=Y.current.onMove,s=Y.current.byKey.get(t);if(!o||!s)return;let c=Y.current.columns.find(e=>e.key===r)?.visibleLimit!=null;c&&J(e=>new Set(e).add(t)),G(e=>new Map(e).set(t,{to:r,index:a}));let l=()=>G(e=>{let n=new Map(e);return n.delete(t),n}),u;try{u=o({card:s,key:t,from:n,to:r,index:a})}catch(e){u=Promise.reject(e)}Promise.resolve(u).then(l,e=>{l(),c&&J(e=>{let n=new Set(e);return n.delete(t),n}),i(e?.message||g.failed.server)})},n=e=>{let{key:t,reason:n}=e.detail,r=Y.current.byKey.get(t);r&&Y.current.onLocked?.({card:r,key:t,reason:n})};return e.addEventListener(`wui:kanban:move`,t),e.addEventListener(`wui:kanban:locked`,n),()=>{e.removeEventListener(`wui:kanban:move`,t),e.removeEventListener(`wui:kanban:locked`,n),e.accept=void 0}},[]);let Q=e=>fe?.(e)!==!1,we=(e,t)=>{K.has(e)&&J(e=>{let n=new Set(e);for(let e of t)n.delete(String(T(e)));return n}),Se(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},$={};return P!=null&&($[`--wui-kanban-column-width`]=`${P}px`),F!=null&&($[`--wui-kanban-fill-offset`]=`${F}px`),/* @__PURE__ */ m(`wui-kanban`,{ref:U,id:H,class:B?`wui-kanban ${B}`:`wui-kanban`,role:`region`,"aria-label":me,"board-id":pe||void 0,"summary-format":X?R:void 0,"summary-unit":X&&z?z:void 0,readonly:A?``:void 0,fill:N?``:void 0,"data-head-layout":L===`stacked`?`stacked`:void 0,style:$,controlled:``,...ae,...V,children:[/* @__PURE__ */ p(`nav`,{className:`wui-kanban-switcher`,"aria-label":he,children:C.map((e,t)=>/* @__PURE__ */ m(`button`,{type:`button`,className:`wui-kanban-switch`,"data-wui-switch":e.key,"aria-controls":`${H}-${e.key}`,"aria-current":t===0?`true`:void 0,children:[/* @__PURE__ */ p(`span`,{className:`wui-kanban-switch-title`,children:e.title}),/* @__PURE__ */ p(`span`,{className:`wui-kanban-count`,"data-wui-count":``,children:(Z.get(e.key)||[]).filter(Q).length})]},e.key))}),j&&/* @__PURE__ */ m(`p`,{className:`wui-kanban-hint`,"aria-hidden":`true`,children:[/* @__PURE__ */ p(r,{name:`arrow-swap-horizontal`,size:14}),M]}),/* @__PURE__ */ p(`div`,{className:`wui-kanban-board`,"data-wui-scroller":``,children:C.map(n=>{let{Tag:i,linkProps:a}=t(be,{href:n.href}),o=`${H}-${n.key}`,c=Z.get(n.key)||[],l=c.filter(Q),u=!!(n.collapsible&&n.collapsed),d=te(n.visibleLimit),f=K.has(n.key),h=ee(l.map(e=>String(T(e))),d,f,q),v=typeof n.summary==`function`?n.summary(l):n.summary;X&&(v=s(ne(l.map(e=>D?.(e))),X));let y=se?.(n,l);return/* @__PURE__ */ m(`section`,{className:`wui-kanban-column`,id:o,"data-wui-column":n.key,"data-tone":n.tone&&_.includes(n.tone)?n.tone:`neutral`,"aria-labelledby":`${o}-title`,"data-accept-from":n.acceptFrom?n.acceptFrom.join(` `):void 0,"data-collapsible":n.collapsible?``:void 0,"data-collapsed":u?``:void 0,children:[/* @__PURE__ */ m(`header`,{className:`wui-kanban-head`,children:[/* @__PURE__ */ p(`span`,{className:`wui-kanban-dot`,"aria-hidden":`true`}),/* @__PURE__ */ p(`h2`,{className:`wui-kanban-title`,id:`${o}-title`,children:n.href?/* @__PURE__ */ p(i,{...a,children:n.title}):n.title}),/* @__PURE__ */ p(`span`,{className:`wui-kanban-count`,"data-wui-count":``,children:l.length}),n.collapsible&&/* @__PURE__ */ p(`span`,{className:`wui-kanban-lock`,"aria-hidden":`true`,children:/* @__PURE__ */ p(r,{name:`lock`,size:14})}),y!=null&&y!==!1&&/* @__PURE__ */ p(`div`,{className:`wui-kanban-actions`,"data-wui-no-drag":``,children:y}),n.collapsible&&/* @__PURE__ */ p(`button`,{type:`button`,className:`wui-kanban-collapse`,"data-wui-collapse":``,"aria-expanded":u?`false`:`true`,"aria-controls":`${o}-body`,"aria-label":e(u?ge:_e,{title:n.title}),children:/* @__PURE__ */ p(r,{name:`chevron-left`,size:16})}),v!=null&&/* @__PURE__ */ p(`div`,{className:`wui-kanban-summary`,"data-wui-summary":``,children:v})]}),/* @__PURE__ */ p(`p`,{className:`wui-kanban-drop-note`,"data-wui-drop-note":``,hidden:!0}),/* @__PURE__ */ p(`div`,{className:`wui-kanban-body`,id:`${o}-body`,"data-wui-body":``,children:c.map(e=>{let t=String(T(e)),n=W.has(t);return/* @__PURE__ */ p(`article`,{className:`wui-kanban-card`,"data-wui-card":t,tabIndex:0,"aria-label":O?O(e):void 0,"data-wui-locked":ce?.(e)?``:void 0,"data-wui-value":D?D(e)??void 0:void 0,"aria-current":I!=null&&t===String(I)?`true`:void 0,"aria-busy":n?`true`:void 0,"data-wui-saving":n?``:void 0,"data-wui-overflow":h.has(t)?``:void 0,hidden:!Q(e),children:oe?.(e)},t)})}),d!=null&&/* @__PURE__ */ p(`button`,{type:`button`,className:`wui-kanban-more`,"data-wui-more":``,"aria-controls":`${o}-body`,"aria-expanded":f?`true`:`false`,hidden:f?l.length<=d:h.size===0,onClick:()=>we(n.key,c),children:f?g.fewer:g.more(h.size)}),/* @__PURE__ */ p(`p`,{className:`wui-kanban-empty`,"data-wui-empty":``,hidden:l.length>0,children:n.emptyText??ve})]},n.key)})}),/* @__PURE__ */ p(`p`,{className:`visually-hidden`,id:`${H}-help`,"data-wui-help":``,children:k}),/* @__PURE__ */ p(`div`,{className:`visually-hidden`,"data-wui-live":``,"aria-live":`polite`,"aria-atomic":`true`})]})}export{x as default};
@@ -0,0 +1 @@
1
+ import{splitMarkerProps as e}from"../lib/wuiMarker.js";import t from"./useWuiControl.js";import n from"./warnInvalidValue.js";import r from"./warnUnknownProps.js";import{forwardRef as i,useEffect as a}from"react";import{jsx as o}from"react/jsx-runtime";import"@webority/ui-elements/elements/lead-popup";var s=[`name`,`email`,`phone`,`company`,`message`],c=[`exit`,`delay`,`scroll`,`pages`],l=e=>e?.length?e.join(` `):void 0,u=e=>{let t=Object.entries(e??{});return t.length?t.map(([e,t])=>`${e}=${t}`).join(`;`):void 0},d=i(function(i,d){let{marker:f,props:p}=e(`AppLeadPopup`,i),{action:m,publicForm:h,heading:g,description:_,fields:v=[`name`,`email`],required:y=[],fieldPrefix:b,fieldNames:x,labels:S,maxLengths:C,submitLabel:w,successTitle:T,successText:E,errorText:D,closeLabel:O,secondaryLabel:k,secondaryHref:A,secondaryDivider:j,triggers:M=[],delaySeconds:N,scrollPercent:P,pagesViewed:F,storageKey:I,dismissDays:L,submittedDays:R,successCloseSeconds:z,preview:B=!1,onShown:V,onBeforeSubmit:H,onSubmitted:U,onError:W,onClosed:G,className:K=``,style:q,...J}=p;r(`AppLeadPopup`,J);for(let e of v)n(`AppLeadPopup`,`fields`,e,s);for(let e of y)n(`AppLeadPopup`,`required`,e,s);for(let e of M)n(`AppLeadPopup`,`triggers`,e,c);let{setRef:Y,innerRef:X}=t({ref:d});return a(()=>{let e=X.current;if(!e)return;let t=[[`wui-lead-popup-shown`,e=>V?.(e.detail)],[`wui-lead-popup-before-submit`,e=>H?.(e.detail.formData)],[`wui-lead-popup-submitted`,e=>U?.(e.detail)],[`wui-lead-popup-error`,e=>W?.(e.detail)],[`wui-lead-popup-closed`,e=>G?.(e.detail.reason)]];for(let[n,r]of t)e.addEventListener(n,r);return()=>{for(let[n,r]of t)e.removeEventListener(n,r)}},[X,V,H,U,W,G]),/* @__PURE__ */ o(`wui-lead-popup`,{ref:Y,action:m||void 0,"public-form":h||void 0,heading:g||void 0,description:_||void 0,fields:l(v),required:l(y),"field-prefix":b||void 0,"field-names":u(x),labels:u(S),"max-lengths":u(C),"submit-label":w||void 0,"success-title":T||void 0,"success-text":E||void 0,"error-text":D||void 0,"close-label":O||void 0,"secondary-label":k||void 0,"secondary-href":A||void 0,"secondary-divider":j||void 0,triggers:l(M),"delay-seconds":N??void 0,"scroll-percent":P??void 0,"pages-viewed":F??void 0,"storage-key":I||void 0,"dismiss-days":L??void 0,"submitted-days":R??void 0,"success-close-seconds":z??void 0,preview:B||void 0,class:K||void 0,style:q,...f,...J})});export{d 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"./warnInvalidValue.js";import i from"./warnUnknownProps.js";import{Fragment as a,jsx as o,jsxs as s}from"react/jsx-runtime";var c={sm:13,md:15,lg:18},l=[`underline`,`underline-center`,`static`,`slide`,`icon`,`highlight`,`bracket`,`fade`,`grow`,`glow`,`shine`,`none`];function u(e,t,r){if(!e)return null;let i=`wui-link__ic wui-link__ic--${t}`;return typeof e==`string`?/* @__PURE__ */ o(`span`,{className:i,children:/* @__PURE__ */ o(n,{name:e,size:c[r]??c.md})}):/* @__PURE__ */ o(`span`,{className:i,children:e})}function d(n){let{marker:d,props:f}=t(`AppLink`,n),{children:p,label:m,href:h,animation:g=`underline`,leftIcon:_=null,rightIcon:v=null,size:y=`md`,surface:b=`default`,external:x=!1,disabled:S=!1,linkComponent:C,className:w=``,...T}=f;i(`AppLink`,T),r(`AppLink`,`animation`,g,l),r(`AppLink`,`size`,y,Object.keys(c)),r(`AppLink`,`surface`,b,[`default`,`dark`]),!h&&T.onClick&&!C&&e(`[@webority/ui-react] AppLink has onClick but no href, so it renders an anchor that keyboards cannot reach. Use AppButton for an action, or pass href.`);let E=l.includes(g)?g:`underline`,D=E===`icon`&&!v&&!_?`arrow-right`:v,O=[`wui-link`,`wui-link--${E}`,y===`md`?``:`wui-link--${y}`,S?`is-disabled`:``,b===`dark`?`wui-link--surface-dark`:``,w].filter(Boolean).join(` `),k=/* @__PURE__ */ s(a,{children:[u(_,`left`,y),/* @__PURE__ */ o(`span`,{className:`wui-link__label`,children:p??m}),u(D,`right`,y)]});if(S){let e={...T};return delete e.onClick,delete e.type,/* @__PURE__ */ o(`span`,{className:O,"aria-disabled":`true`,...d,...e,children:k})}return C&&!x?/* @__PURE__ */ o(C,{className:O,to:h,...d,...T,children:k}):/* @__PURE__ */ o(`a`,{className:O,href:h,target:x?`_blank`:void 0,rel:x?`noopener noreferrer`:void 0,...d,...T,children:k})}export{d 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"./warnInvalidValue.js";import i from"./warnUnknownProps.js";import{Fragment as a,jsx as o,jsxs as s}from"react/jsx-runtime";var c={sm:13,md:15,lg:18},l=[`underline`,`underline-center`,`static`,`slide`,`icon`,`highlight`,`bracket`,`fade`,`grow`,`glow`,`shine`,`none`];function u(e,t,r){if(!e)return null;let i=`wui-link__ic wui-link__ic--${t}`;return typeof e==`string`?/* @__PURE__ */ o(`span`,{className:i,children:/* @__PURE__ */ o(n,{name:e,size:c[r]??c.md})}):/* @__PURE__ */ o(`span`,{className:i,children:e})}function d(n){let{marker:d,props:f}=t(`AppLink`,n),{children:p,label:m,href:h,animation:g=`underline`,leftIcon:_=null,rightIcon:v=null,size:y=`md`,surface:b=`default`,external:x=!1,disabled:S=!1,linkComponent:C,maxLines:w=null,className:T=``,...E}=f;i(`AppLink`,E),r(`AppLink`,`animation`,g,l),r(`AppLink`,`size`,y,Object.keys(c)),r(`AppLink`,`surface`,b,[`default`,`dark`]);let D=Number.isInteger(w)&&w>=1?w:null;w!=null&&D===null&&e(`[@webority/ui-react] AppLink maxLines must be a whole number of 1 or more; got ${String(w)}. The label is not clamped.`),!h&&E.onClick&&!C&&e(`[@webority/ui-react] AppLink has onClick but no href, so it renders an anchor that keyboards cannot reach. Use AppButton for an action, or pass href.`);let O=l.includes(g)?g:`underline`,k=O===`icon`&&!v&&!_?`arrow-right`:v,A=[`wui-link`,`wui-link--${O}`,y===`md`?``:`wui-link--${y}`,S?`is-disabled`:``,b===`dark`?`wui-link--surface-dark`:``,D===null?``:`wui-link--clamp`,T].filter(Boolean).join(` `),j=/* @__PURE__ */ s(a,{children:[u(_,`left`,y),/* @__PURE__ */ o(`span`,{className:`wui-link__label`,style:D===null?void 0:{"--wui-link-max-lines":D},children:p??m}),u(k,`right`,y)]});if(S){let e={...E};return delete e.onClick,delete e.type,/* @__PURE__ */ o(`span`,{className:A,"aria-disabled":`true`,...d,...e,children:j})}return C&&!x?/* @__PURE__ */ o(C,{className:A,to:h,...d,...E,children:j}):/* @__PURE__ */ o(`a`,{className:A,href:h,target:x?`_blank`:void 0,rel:x?`noopener noreferrer`:void 0,...d,...E,children:j})}export{d as default};
@@ -1 +1 @@
1
- import{linkTarget as e,webRoute as t}from"../markdown-core/dist/links.js";import{parseInline as n}from"../markdown-core/dist/inline.js";import{parseMarkdown as r}from"../markdown-core/dist/parse.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./AppChip.js";import o from"./AppCodeBlock.js";import s from"./AppLink.js";import c from"./warnInvalidValue.js";import l from"./warnUnknownProps.js";import{Fragment as u,useMemo as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import"@webority/ui-elements/elements/markdown";var m=[`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`css`];function h(e){let{marker:t,props:n}=i(`AppMarkdown`,e),{value:a,className:o=``,linkComponent:s,resolveLink:u,isCitation:p,onOpenCitation:m,links:h=`web`,headings:g=`outline`,..._}=n;l(`AppMarkdown`,_),c(`AppMarkdown`,`links`,h,[`app`,`web`]),c(`AppMarkdown`,`headings`,g,[`outline`,`text`]);let v=d(()=>r(a),[a]),y={links:h,headings:g,resolveLink:u,linkComponent:s,isCitation:p,onOpenCitation:m};return/* @__PURE__ */ f(`wui-markdown`,{class:[`wui-markdown`,o].filter(Boolean).join(` `),...t,..._,children:v.map(e=>/* @__PURE__ */ f(C,{block:e,options:y},e.key))})}function g({token:n,options:r}){let i=/* @__PURE__ */ f(_,{tokens:n.children,options:r}),a=e(n.href,r.links,r.resolveLink);if(a?.kind===`app`){let e=t(a.target);return e?/* @__PURE__ */ f(s,{href:e,linkComponent:r.linkComponent,animation:`static`,children:i}):i}return a?.kind===`web`?/* @__PURE__ */ f(s,{href:a.href,external:!0,animation:`static`,children:i}):a?.kind===`contact`?/* @__PURE__ */ f(s,{href:a.href,animation:`static`,children:i}):i}function _({tokens:e,options:t}){return e.map(e=>{switch(e.type){case`code`:return/* @__PURE__ */ f(`code`,{children:e.text},e.key);case`strong`:return/* @__PURE__ */ f(`strong`,{children:/* @__PURE__ */ f(_,{tokens:e.children,options:t})},e.key);case`em`:return/* @__PURE__ */ f(`em`,{children:/* @__PURE__ */ f(_,{tokens:e.children,options:t})},e.key);case`strike`:return/* @__PURE__ */ f(`del`,{children:/* @__PURE__ */ f(_,{tokens:e.children,options:t})},e.key);case`image`:return/* @__PURE__ */ p(u,{children:[`[`,/* @__PURE__ */ f(_,{tokens:e.children,options:t}),`]`]},e.key);case`link`:return/* @__PURE__ */ f(g,{token:e,options:t},e.key);case`citation`:return/* @__PURE__ */ f(a,{label:e.text,size:`sm`,tone:`primary`,variant:`outline`,"aria-label":e.text,className:`wui-markdown-citation`,onClick:t.onOpenCitation?()=>t.onOpenCitation(e.text):void 0},e.key);default:return/* @__PURE__ */ f(u,{children:e.text},e.key)}})}function v({text:e,options:t}){return/* @__PURE__ */ f(_,{tokens:n(e,{isCitation:t.isCitation}),options:t})}function y({lines:e,options:t}){return e.map((e,n)=>/* @__PURE__ */ p(u,{children:[n>0&&/* @__PURE__ */ f(`br`,{}),/* @__PURE__ */ f(v,{text:e,options:t})]},n))}function b({block:e,options:t}){let n=e=>/* @__PURE__ */ f(v,{text:e,options:t});return/* @__PURE__ */ f(`div`,{className:`table-responsive`,children:/* @__PURE__ */ p(`table`,{className:`table`,children:[/* @__PURE__ */ f(`thead`,{children:/* @__PURE__ */ f(`tr`,{children:e.header.map((e,t)=>/* @__PURE__ */ f(`th`,{scope:`col`,children:n(e)},t))})}),/* @__PURE__ */ f(`tbody`,{children:e.rows.map((t,r)=>/* @__PURE__ */ f(`tr`,{children:e.header.map((e,r)=>/* @__PURE__ */ f(`td`,{children:n(t[r]??``)},r))},r))})]})})}function x(e,t,n){let{items:r}=e,{depth:i,ordered:a,number:o}=r[t],s=[],c=t;for(;c<r.length&&r[c].depth>=i;)if(r[c].depth>i){let t=x(e,c,n);s[s.length-1].nested=t.node,c=t.next}else s.push({item:r[c],index:c,nested:null}),c+=1;let l=s.map(({item:t,index:r,nested:i})=>/* @__PURE__ */ p(`li`,{children:[/* @__PURE__ */ f(v,{text:t.text,options:n}),i]},`${e.key}-${r}`));return{node:a?/* @__PURE__ */ f(`ol`,{start:a&&o!==1?o:void 0,children:l},`${e.key}-${t}`):/* @__PURE__ */ f(`ul`,{children:l},`${e.key}-${t}`),next:c}}function S(e,t){let n=[],r=0;for(;r<e.items.length;){let i=x(e,r,t);n.push(i.node),r=i.next}return n}function C({block:e,options:t}){switch(e.type){case`paragraph`:return/* @__PURE__ */ f(`p`,{children:/* @__PURE__ */ f(y,{lines:e.lines,options:t})});case`quote`:return/* @__PURE__ */ f(`blockquote`,{children:/* @__PURE__ */ f(y,{lines:e.lines,options:t})});case`heading`:{let n=/* @__PURE__ */ f(v,{text:e.text,options:t});return t.headings===`text`?/* @__PURE__ */ f(`p`,{className:`fw-semibold`,children:n}):/* @__PURE__ */ f(`h2`,{children:n})}case`list`:return S(e,t);case`table`:return/* @__PURE__ */ f(b,{block:e,options:t});case`code`:return/* @__PURE__ */ f(o,{code:e.text,language:m.includes(e.language)?e.language:`text`});case`rule`:return/* @__PURE__ */ f(`hr`,{});default:return null}}export{h as default};
1
+ import{linkTarget as e,webRoute as t}from"../markdown-core/dist/links.js";import{parseInline as n}from"../markdown-core/dist/inline.js";import{parseMarkdown as r}from"../markdown-core/dist/parse.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./AppChip.js";import o from"./AppCodeBlock.js";import s from"./AppLink.js";import c from"./warnInvalidValue.js";import l from"./warnUnknownProps.js";import{Fragment as u,useMemo as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import"@webority/ui-elements/elements/markdown";var m=[`text`,`json`,`js`,`cs`,`sql`,`bash`,`http`,`html`,`css`];function h(e){let{marker:t,props:n}=i(`AppMarkdown`,e),{value:a,className:o=``,linkComponent:s,resolveLink:u,isCitation:p,onOpenCitation:m,links:h=`web`,headings:g=`outline`,..._}=n;l(`AppMarkdown`,_),c(`AppMarkdown`,`links`,h,[`app`,`web`]),c(`AppMarkdown`,`headings`,g,[`outline`,`text`]);let v=d(()=>r(a),[a]),y={links:h,headings:g,resolveLink:u,linkComponent:s,isCitation:p,onOpenCitation:m};return/* @__PURE__ */ f(`wui-markdown`,{class:[`wui-markdown`,o].filter(Boolean).join(` `),...t,..._,children:v.map(e=>/* @__PURE__ */ f(C,{block:e,options:y},e.key))})}function g({token:n,options:r}){let i=/* @__PURE__ */ f(_,{tokens:n.children,options:r}),a=e(n.href,r.links,r.resolveLink,globalThis.location?.origin);if(a?.kind===`app`){let e=t(a.target);return e?/* @__PURE__ */ f(s,{href:e,linkComponent:r.linkComponent,animation:`static`,children:i}):i}return a?.kind===`page`?/* @__PURE__ */ f(s,{href:a.href,linkComponent:r.linkComponent,animation:`static`,children:i}):a?.kind===`web`?/* @__PURE__ */ f(s,{href:a.href,external:!0,animation:`static`,children:i}):a?.kind===`contact`?/* @__PURE__ */ f(s,{href:a.href,animation:`static`,children:i}):i}function _({tokens:e,options:t}){return e.map(e=>{switch(e.type){case`code`:return/* @__PURE__ */ f(`code`,{children:e.text},e.key);case`strong`:return/* @__PURE__ */ f(`strong`,{children:/* @__PURE__ */ f(_,{tokens:e.children,options:t})},e.key);case`em`:return/* @__PURE__ */ f(`em`,{children:/* @__PURE__ */ f(_,{tokens:e.children,options:t})},e.key);case`strike`:return/* @__PURE__ */ f(`del`,{children:/* @__PURE__ */ f(_,{tokens:e.children,options:t})},e.key);case`image`:return/* @__PURE__ */ p(u,{children:[`[`,/* @__PURE__ */ f(_,{tokens:e.children,options:t}),`]`]},e.key);case`link`:return/* @__PURE__ */ f(g,{token:e,options:t},e.key);case`citation`:return/* @__PURE__ */ f(a,{label:e.text,size:`sm`,tone:`primary`,variant:`outline`,"aria-label":e.text,className:`wui-markdown-citation`,onClick:t.onOpenCitation?()=>t.onOpenCitation(e.text):void 0},e.key);default:return/* @__PURE__ */ f(u,{children:e.text},e.key)}})}function v({text:e,options:t}){return/* @__PURE__ */ f(_,{tokens:n(e,{isCitation:t.isCitation}),options:t})}function y({lines:e,options:t}){return e.map((e,n)=>/* @__PURE__ */ p(u,{children:[n>0&&/* @__PURE__ */ f(`br`,{}),/* @__PURE__ */ f(v,{text:e,options:t})]},n))}function b({block:e,options:t}){let n=e=>/* @__PURE__ */ f(v,{text:e,options:t});return/* @__PURE__ */ f(`div`,{className:`table-responsive`,children:/* @__PURE__ */ p(`table`,{className:`table`,children:[/* @__PURE__ */ f(`thead`,{children:/* @__PURE__ */ f(`tr`,{children:e.header.map((e,t)=>/* @__PURE__ */ f(`th`,{scope:`col`,children:n(e)},t))})}),/* @__PURE__ */ f(`tbody`,{children:e.rows.map((t,r)=>/* @__PURE__ */ f(`tr`,{children:e.header.map((e,r)=>/* @__PURE__ */ f(`td`,{children:n(t[r]??``)},r))},r))})]})})}function x(e,t,n){let{items:r}=e,{depth:i,ordered:a,number:o}=r[t],s=[],c=t;for(;c<r.length&&r[c].depth>=i;)if(r[c].depth>i){let t=x(e,c,n);s[s.length-1].nested=t.node,c=t.next}else s.push({item:r[c],index:c,nested:null}),c+=1;let l=s.map(({item:t,index:r,nested:i})=>/* @__PURE__ */ p(`li`,{children:[/* @__PURE__ */ f(v,{text:t.text,options:n}),i]},`${e.key}-${r}`));return{node:a?/* @__PURE__ */ f(`ol`,{start:a&&o!==1?o:void 0,children:l},`${e.key}-${t}`):/* @__PURE__ */ f(`ul`,{children:l},`${e.key}-${t}`),next:c}}function S(e,t){let n=[],r=0;for(;r<e.items.length;){let i=x(e,r,t);n.push(i.node),r=i.next}return n}function C({block:e,options:t}){switch(e.type){case`paragraph`:return/* @__PURE__ */ f(`p`,{children:/* @__PURE__ */ f(y,{lines:e.lines,options:t})});case`quote`:return/* @__PURE__ */ f(`blockquote`,{children:/* @__PURE__ */ f(y,{lines:e.lines,options:t})});case`heading`:{let n=/* @__PURE__ */ f(v,{text:e.text,options:t});return t.headings===`text`?/* @__PURE__ */ f(`p`,{className:`fw-semibold`,children:n}):/* @__PURE__ */ f(`h2`,{children:n})}case`list`:return S(e,t);case`table`:return/* @__PURE__ */ f(b,{block:e,options:t});case`code`:return/* @__PURE__ */ f(o,{code:e.text,language:m.includes(e.language)?e.language:`text`});case`rule`:return/* @__PURE__ */ f(`hr`,{});default:return null}}export{h as default};
@@ -1 +1 @@
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"./warnUnknownProps.js";import"@webority/ui-elements/elements/mention-input";import{forwardRef as o,useEffect as s,useId as c}from"react";import{jsx as l,jsxs as u}from"react/jsx-runtime";var d=o(function(o,d){let{marker:f,props:p}=t(`AppMentionInput`,o),{value:m,onChange:h,people:g,loadPeople:_,minChars:v,debounce:y,onSubmit:b,rows:x=3,placeholder:S,disabled:C=!1,name:w,id:T,label:E,error:D,hint:O,required:k=!1,help:A,helpLabel:j=`More information`,className:M=``,fieldClassName:N=``,...P}=p;a(`AppMentionInput`,P);let F=typeof _==`function`,I=c(),L=T||`mention-${I.replace(/[^a-zA-Z0-9_-]/g,``)}`,R=D?`${L}-error`:O?`${L}-hint`:void 0,{setRef:z,innerRef:B}=i({ref:d,value:m??``,on:{change:e=>{e.target===e.currentTarget&&h?.(e.currentTarget.value,{mentions:e.currentTarget.mentions})},"wui:mention-input:submit":()=>b?.()}});return s(()=>{let e=B.current;e&&!F&&(e.people=g||[])},[g,F,B]),s(()=>{let e=B.current;if(!e||!F)return;let t=0,n=null,r=async r=>{let i=++t;n?.abort(),n=typeof AbortController==`function`?new AbortController:null,e.loading=!0;try{let a=await _(r.detail.query,{signal:n?.signal});i===t&&(e.people=a||[])}catch{i===t&&(e.people=[])}finally{i===t&&(e.loading=!1)}};return e.addEventListener(`search`,r),()=>{t=-1,n?.abort(),e.removeEventListener(`search`,r),e.loading=!1}},[F,_,B]),/* @__PURE__ */ u(`div`,{...f,className:`field${N?` ${N}`:``}`,children:[E&&/* @__PURE__ */ u(`label`,{className:`label`,htmlFor:`${L}-text`,children:[E,k&&/* @__PURE__ */ l(r,{}),A&&/* @__PURE__ */ l(n,{label:j,children:A})]}),/* @__PURE__ */ l(`wui-mention-input`,{ref:z,id:L,class:M?`wui-mention-input ${M}`:`wui-mention-input`,label:typeof E==`string`?E:void 0,placeholder:S||void 0,rows:String(x),name:w||void 0,remote:F?``:void 0,"min-chars":v==null?void 0:String(v),debounce:y==null?void 0:String(y),disabled:C?``:void 0,"aria-describedby":R,"aria-invalid":D?`true`:void 0,...P}),/* @__PURE__ */ l(e,{error:D,hint:O,errorId:`${L}-error`,hintId:`${L}-hint`})]})});export{d as default};
1
+ import e from"../lib/FieldMessage.js";import{FIELD_SIZES as t}from"../lib/fieldState.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"@webority/ui-elements/elements/mention-input";import{forwardRef as c,useEffect as l,useId as u,useRef as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";var m=c(function(c,m){let{marker:h,props:g}=n(`AppMentionInput`,c),{value:_,defaultValue:v,onChange:y,people:b,loadPeople:x,minChars:S,debounce:C,onSubmit:w,rows:T=3,placeholder:E,disabled:D=!1,readOnly:O=!1,loading:k=!1,size:A=`md`,name:j,id:M,label:N,error:P,hint:F,required:I=!1,help:L,helpLabel:R=`More information`,className:z=``,fieldClassName:B=``,...V}=g;s(`AppMentionInput`,V),o(`AppMentionInput`,`size`,A,t);let H=typeof x==`function`,U=u(),W=M||`mention-${U.replace(/[^a-zA-Z0-9_-]/g,``)}`,G=P?`${W}-error`:F?`${W}-hint`:void 0,K=d(k),q=d(!1),{setRef:J,innerRef:Y}=a({ref:m,value:_??(v===void 0?``:void 0),defaultValue:v,on:{change:e=>{e.target===e.currentTarget&&y?.(e.currentTarget.value,{mentions:e.currentTarget.mentions})},"wui:mention-input:submit":()=>w?.()}});return l(()=>{let e=Y.current;e&&!H&&(e.people=b||[])},[b,H,Y]),l(()=>{K.current=k;let e=Y.current;e&&!q.current&&(e.loading=k)},[k,Y]),l(()=>{let e=Y.current;if(!e||!H)return;let t=0,n=null,r=async r=>{let i=++t;n?.abort(),n=typeof AbortController==`function`?new AbortController:null,q.current=!0,e.loading=!0;try{let a=await x(r.detail.query,{signal:n?.signal});i===t&&(e.people=a||[])}catch{i===t&&(e.people=[])}finally{i===t&&(q.current=!1,e.loading=K.current)}};return e.addEventListener(`search`,r),()=>{t=-1,n?.abort(),e.removeEventListener(`search`,r),q.current=!1,e.loading=K.current}},[H,x,Y]),/* @__PURE__ */ p(`div`,{...h,className:`field${B?` ${B}`:``}`,children:[N&&/* @__PURE__ */ p(`label`,{className:`label`,htmlFor:`${W}-text`,children:[N,I&&/* @__PURE__ */ f(i,{}),L&&/* @__PURE__ */ f(r,{label:R,children:L})]}),/* @__PURE__ */ f(`wui-mention-input`,{ref:J,id:W,class:z?`wui-mention-input ${z}`:`wui-mention-input`,label:typeof N==`string`?N:void 0,placeholder:E||void 0,rows:String(T),name:j||void 0,remote:H?``:void 0,"min-chars":S==null?void 0:String(S),debounce:C==null?void 0:String(C),disabled:D?``:void 0,readonly:O?``:void 0,loading:k?``:void 0,size:A===`md`?void 0:A,"aria-describedby":G,"aria-invalid":P?`true`:void 0,...V}),/* @__PURE__ */ f(e,{error:P,hint:F,errorId:`${W}-error`,hintId:`${W}-hint`})]})});export{m as default};