@webority/ui-react 0.164.0 → 0.167.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 (167) hide show
  1. package/LICENSE +1 -1
  2. package/dist/canvas-kit/kit.js +225 -223
  3. package/dist/canvas-kit/manifest.json +1334 -435
  4. package/dist/canvas-kit/release.json +6 -6
  5. package/dist/components/AppAsyncBlock.js +1 -1
  6. package/dist/components/AppAvatar.js +1 -1
  7. package/dist/components/AppAvatarGroup.js +1 -1
  8. package/dist/components/AppBanner.js +1 -1
  9. package/dist/components/AppBreadcrumbs.js +1 -1
  10. package/dist/components/AppButton.js +1 -1
  11. package/dist/components/AppCalendar.js +1 -1
  12. package/dist/components/AppCard.js +1 -1
  13. package/dist/components/AppCarousel.js +1 -1
  14. package/dist/components/AppCell.js +1 -1
  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/AppChip.js +1 -1
  19. package/dist/components/AppChipGroup.js +1 -1
  20. package/dist/components/AppChoiceCard.js +1 -1
  21. package/dist/components/AppChoiceChip.js +1 -1
  22. package/dist/components/AppColorField.js +1 -1
  23. package/dist/components/AppColumnMenu.js +1 -1
  24. package/dist/components/AppCommandPalette.js +1 -1
  25. package/dist/components/AppCommentThread.js +1 -1
  26. package/dist/components/AppCompareTable.js +1 -1
  27. package/dist/components/AppConfirmDialog.js +1 -1
  28. package/dist/components/AppConfirmProvider.js +1 -1
  29. package/dist/components/AppContextMenu.js +1 -1
  30. package/dist/components/AppCopyButton.js +1 -1
  31. package/dist/components/AppDataTable.js +1 -1
  32. package/dist/components/AppDatePicker.js +1 -1
  33. package/dist/components/AppDateRangePicker.js +1 -1
  34. package/dist/components/AppDescriptions.js +1 -1
  35. package/dist/components/AppDrawer.js +1 -1
  36. package/dist/components/AppDropZone.js +1 -1
  37. package/dist/components/AppDropdown.js +1 -1
  38. package/dist/components/AppDueDate.js +1 -1
  39. package/dist/components/AppEntryGrid.js +1 -0
  40. package/dist/components/AppErrorBoundary.js +1 -1
  41. package/dist/components/AppErrorSummary.js +1 -1
  42. package/dist/components/AppFileAttachment.js +1 -1
  43. package/dist/components/AppFilePicker.js +1 -1
  44. package/dist/components/AppFilterBar.js +1 -1
  45. package/dist/components/AppFloatingDock.js +1 -1
  46. package/dist/components/AppForm.js +1 -1
  47. package/dist/components/AppFormulaSteps.js +1 -0
  48. package/dist/components/AppHoverCard.js +1 -1
  49. package/dist/components/AppImagePicker.js +1 -1
  50. package/dist/components/AppInfoTip.js +1 -1
  51. package/dist/components/AppInlineEdit.js +1 -1
  52. package/dist/components/AppInput.js +1 -1
  53. package/dist/components/AppInputGroup.js +1 -1
  54. package/dist/components/AppKanban.js +1 -1
  55. package/dist/components/AppMentionInput.js +1 -1
  56. package/dist/components/AppMetricStrip.js +1 -1
  57. package/dist/components/AppModal.js +1 -1
  58. package/dist/components/AppNavigationMenu.js +1 -1
  59. package/dist/components/AppNotificationCenter.js +1 -1
  60. package/dist/components/AppNumberInput.js +1 -1
  61. package/dist/components/AppOnboardingChecklist.js +1 -1
  62. package/dist/components/AppOrgTree.js +1 -1
  63. package/dist/components/AppOtpInput.js +1 -1
  64. package/dist/components/AppPageHeader.js +1 -1
  65. package/dist/components/AppPhoneNumberInput.js +1 -1
  66. package/dist/components/AppPopover.js +1 -1
  67. package/dist/components/AppPricingCard.js +1 -1
  68. package/dist/components/AppQrCode.js +1 -1
  69. package/dist/components/AppRadio.js +1 -1
  70. package/dist/components/AppRadioGroup.js +1 -1
  71. package/dist/components/AppRating.js +1 -1
  72. package/dist/components/AppRecordPager.js +1 -1
  73. package/dist/components/AppRelativeTime.js +1 -1
  74. package/dist/components/AppRepeater.js +1 -1
  75. package/dist/components/AppRichText.js +1 -1
  76. package/dist/components/AppRouteError.js +1 -1
  77. package/dist/components/AppRowActions.js +1 -0
  78. package/dist/components/AppScoreScale.js +1 -1
  79. package/dist/components/AppSearch.js +1 -1
  80. package/dist/components/AppSectionFeatures.js +1 -1
  81. package/dist/components/AppSectionLeadCapture.js +1 -1
  82. package/dist/components/AppSectionLogos.js +1 -1
  83. package/dist/components/AppSegmented.js +1 -1
  84. package/dist/components/AppSelect.js +1 -1
  85. package/dist/components/AppShell.js +1 -1
  86. package/dist/components/AppShortcutLegend.js +1 -1
  87. package/dist/components/AppShowMore.js +1 -1
  88. package/dist/components/AppSlider.js +1 -1
  89. package/dist/components/AppSortableList.js +1 -1
  90. package/dist/components/AppSparkline.js +1 -1
  91. package/dist/components/AppSpinner.js +1 -1
  92. package/dist/components/AppSplash.js +1 -1
  93. package/dist/components/AppSplitButton.js +1 -1
  94. package/dist/components/AppSplitView.js +1 -1
  95. package/dist/components/AppStatusBadge.js +1 -1
  96. package/dist/components/AppStepper.js +1 -1
  97. package/dist/components/AppSwitch.js +1 -1
  98. package/dist/components/AppTablePagination.js +1 -1
  99. package/dist/components/AppTableToolbar.js +1 -1
  100. package/dist/components/AppTabs.js +1 -1
  101. package/dist/components/AppTextarea.js +1 -1
  102. package/dist/components/AppThemeToggle.js +1 -1
  103. package/dist/components/AppTimePicker.js +1 -1
  104. package/dist/components/AppTimeline.js +1 -1
  105. package/dist/components/AppToast.js +1 -1
  106. package/dist/components/AppUpdateBar.js +1 -1
  107. package/dist/components/AppWhatsNew.js +1 -1
  108. package/dist/components/AppWizard.js +1 -1
  109. package/dist/components/AppWorkspaceSwitcher.js +1 -1
  110. package/dist/components/toast.js +1 -1
  111. package/dist/guidance.json +220 -140
  112. package/dist/hookForm/index.js +1 -0
  113. package/dist/lib/CheckField.js +1 -1
  114. package/dist/lib/FileItemRow.js +1 -1
  115. package/dist/lib/emptyValue.js +1 -1
  116. package/dist/lib/fieldState.js +1 -1
  117. package/dist/lib/formFields.js +1 -0
  118. package/dist/lib/useWuiText.js +1 -0
  119. package/dist/types/components/AppAsyncBlock.d.ts +3 -3
  120. package/dist/types/components/AppChart.d.ts +12 -4
  121. package/dist/types/components/AppColorField.d.ts +3 -3
  122. package/dist/types/components/AppDataTable.d.ts +29 -2
  123. package/dist/types/components/AppDatePicker.d.ts +2 -1
  124. package/dist/types/components/AppDateRangePicker.d.ts +5 -1
  125. package/dist/types/components/AppDescriptions.d.ts +6 -0
  126. package/dist/types/components/AppDropdown.d.ts +6 -0
  127. package/dist/types/components/AppEntryGrid.d.ts +164 -0
  128. package/dist/types/components/AppFilterBar.d.ts +12 -1
  129. package/dist/types/components/AppForm.d.ts +18 -0
  130. package/dist/types/components/AppFormulaSteps.d.ts +64 -0
  131. package/dist/types/components/AppInput.d.ts +4 -4
  132. package/dist/types/components/AppInputGroup.d.ts +1 -1
  133. package/dist/types/components/AppMentionInput.d.ts +2 -2
  134. package/dist/types/components/AppMetricStrip.d.ts +5 -0
  135. package/dist/types/components/AppModal.d.ts +5 -0
  136. package/dist/types/components/AppNumberInput.d.ts +9 -3
  137. package/dist/types/components/AppPhoneNumberInput.d.ts +1 -1
  138. package/dist/types/components/AppRowActions.d.ts +46 -0
  139. package/dist/types/components/AppSearch.d.ts +1 -1
  140. package/dist/types/components/AppSectionFeatures.d.ts +5 -1
  141. package/dist/types/components/AppSectionLogos.d.ts +1 -0
  142. package/dist/types/components/AppSelect.d.ts +3 -2
  143. package/dist/types/components/AppShell.d.ts +2 -0
  144. package/dist/types/components/AppSlider.d.ts +5 -0
  145. package/dist/types/components/AppTextarea.d.ts +2 -2
  146. package/dist/types/components/AppTimePicker.d.ts +1 -1
  147. package/dist/types/components/AppToast.d.ts +5 -0
  148. package/dist/types/hookForm/index.d.ts +14 -0
  149. package/dist/types/index.d.ts +8 -5
  150. package/dist/types/lib/emptyValue.d.ts +2 -2
  151. package/dist/types/lib/fieldState.d.ts +1 -0
  152. package/dist/types/lib/formFields.d.ts +12 -0
  153. package/dist/types/lib/useWuiText.d.ts +3 -0
  154. package/dist/ui-react.js +1 -1
  155. package/dist/web-core/dist/errors/extractApiError.js +2 -0
  156. package/dist/web-core/dist/errors/requestPlatform.js +1 -0
  157. package/package.json +21 -10
  158. package/dist/components/AppResizable.js +0 -1
  159. package/dist/components/AppResizableHandle.js +0 -1
  160. package/dist/components/AppResizablePanel.js +0 -1
  161. package/dist/components/AppRollingNumber.js +0 -1
  162. package/dist/components/AppRowSwitch.js +0 -1
  163. package/dist/types/components/AppResizable.d.ts +0 -37
  164. package/dist/types/components/AppResizableHandle.d.ts +0 -14
  165. package/dist/types/components/AppResizablePanel.d.ts +0 -14
  166. package/dist/types/components/AppRollingNumber.d.ts +0 -30
  167. package/dist/types/components/AppRowSwitch.d.ts +0 -18
@@ -1 +1 @@
1
- import{linkTarget as e}from"../lib/linkTarget.js";import{shortcutAria as t,shortcutChip as n}from"../lib/shortcutChip.js";import{TargetLink as r}from"../lib/TargetLink.js";import i from"../lib/useElementEntry.js";import{splitMarkerProps as a}from"../lib/wuiMarker.js";import o from"./renderIconProp.js";import s from"./warnUnknownProps.js";import{useEffect as c,useLayoutEffect as l,useRef as u}from"react";import{Fragment as d,jsx as f,jsxs as p}from"react/jsx-runtime";var m=()=>import(`@webority/ui-elements/elements/context-menu`);function h(e){i(`wui-context-menu`,m);let{marker:t,props:n}=a(`AppContextMenu`,e),{items:r=[],target:o,trigger:d,children:h,ariaLabel:_=`Context menu`,disabled:y=!1,open:b,onOpen:x,onBeforeOpen:S,menuClassName:C=``,linkComponent:w,...T}=n;s(`AppContextMenu`,T);let E=u(null);return c(()=>{let e=E.current;if(!e||!x)return;let t=e=>{if(!g(e))throw TypeError(`<wui-context-menu> dispatched wui-context-menu:open without a CustomEvent.`);x(e.detail)};return e.addEventListener(`wui-context-menu:open`,t),()=>e.removeEventListener(`wui-context-menu:open`,t)},[x]),c(()=>{let e=E.current;if(!e||!S)return;let t=e=>{if(!g(e))throw TypeError(`<wui-context-menu> dispatched wui-context-menu:beforeopen without a CustomEvent.`);S(e)};return e.addEventListener(`wui-context-menu:beforeopen`,t),()=>e.removeEventListener(`wui-context-menu:beforeopen`,t)},[S]),l(()=>{let e=E.current;if(!e)throw Error(`<AppContextMenu> has no menu element to open.`);e.toggleAttribute(`open`,!!b)},[b]),/* @__PURE__ */ p(`wui-context-menu`,{ref:E,target:o,trigger:d,disabled:y,...t,...T,children:[h,/* @__PURE__ */ f(`div`,{className:`dropdown-menu wui-context-menu-panel${C?` ${C}`:``}`,popover:`auto`,role:`menu`,"aria-label":_,tabIndex:-1,children:v(r,w)})]})}function g(e){return e instanceof CustomEvent}var _=e=>`dropdown-item${e.tone===`danger`?` danger`:``}${e.disabled?` disabled`:``}`;function v(i,a){return i.map(i=>{if(i.divider)return/* @__PURE__ */ f(`hr`,{className:`dropdown-divider`},i.key);if(i.items!=null){let e=i.searchPlaceholder||`Search`;return/* @__PURE__ */ p(`div`,{className:`wui-context-menu-sub`,role:`none`,"data-searchable":i.searchable?``:void 0,children:[/* @__PURE__ */ p(`button`,{type:`button`,className:_(i),role:`menuitem`,"aria-haspopup":`menu`,"aria-expanded":`false`,tabIndex:-1,"data-key":i.key,"aria-disabled":i.disabled?`true`:void 0,children:[o(i.icon,{size:16}),i.label,o(`chevron-right`,{size:14,className:`wui-context-menu-chevron`})]}),/* @__PURE__ */ p(`div`,{className:`dropdown-menu wui-context-menu-subpanel`,popover:`auto`,role:`menu`,"aria-label":i.label,tabIndex:-1,children:[i.searchable?/* @__PURE__ */ f(`input`,{type:`search`,className:`wui-context-menu-search`,autoComplete:`off`,placeholder:e,"aria-label":e}):null,v(i.items,a)]})]},i.key)}let s=!!i.to&&!i.disabled,c=/* @__PURE__ */ p(d,{children:[i.image?/* @__PURE__ */ f(`img`,{src:i.image,alt:``}):o(i.icon,{size:16}),i.label,n(i.shortcut)]}),l={className:_(i),role:`menuitem`,tabIndex:-1,"data-key":i.key,"aria-checked":i.checked||void 0,"data-hint":i.hint||void 0,"aria-keyshortcuts":t(i.shortcut),"aria-disabled":i.disabled||void 0,onClick:i.disabled?void 0:i.onClick,children:c};return s?/* @__PURE__ */ f(r,{link:e(a,{to:i.to}),...l},i.key):/* @__PURE__ */ f(`button`,{type:`button`,...l},i.key)})}export{h as default};
1
+ import{linkTarget as e}from"../lib/linkTarget.js";import{shortcutAria as t,shortcutChip as n}from"../lib/shortcutChip.js";import{TargetLink as r}from"../lib/TargetLink.js";import i from"../lib/useElementEntry.js";import a from"../lib/useWuiText.js";import{splitMarkerProps as o}from"../lib/wuiMarker.js";import s from"./renderIconProp.js";import c from"./warnUnknownProps.js";import{useEffect as l,useLayoutEffect as u,useRef as d}from"react";import{Fragment as f,jsx as p,jsxs as m}from"react/jsx-runtime";import{CONTEXT_MENU_TEXT as h}from"@webority/ui-elements/text";var g=()=>import(`@webority/ui-elements/elements/context-menu`);function _(e){i(`wui-context-menu`,g);let{marker:t,props:n}=o(`AppContextMenu`,e),r=a(`contextMenu`,h),{items:s=[],target:f,trigger:_,children:y,ariaLabel:x=r.ariaLabel,disabled:S=!1,open:C,onOpen:w,onBeforeOpen:T,menuClassName:E=``,linkComponent:D,...O}=n;c(`AppContextMenu`,O);let k=d(null);return l(()=>{let e=k.current;if(!e||!w)return;let t=e=>{if(!v(e))throw TypeError(`<wui-context-menu> dispatched wui-context-menu:open without a CustomEvent.`);w(e.detail)};return e.addEventListener(`wui-context-menu:open`,t),()=>e.removeEventListener(`wui-context-menu:open`,t)},[w]),l(()=>{let e=k.current;if(!e||!T)return;let t=e=>{if(!v(e))throw TypeError(`<wui-context-menu> dispatched wui-context-menu:beforeopen without a CustomEvent.`);T(e)};return e.addEventListener(`wui-context-menu:beforeopen`,t),()=>e.removeEventListener(`wui-context-menu:beforeopen`,t)},[T]),u(()=>{let e=k.current;if(!e)throw Error(`<AppContextMenu> has no menu element to open.`);e.toggleAttribute(`open`,!!C)},[C]),/* @__PURE__ */ m(`wui-context-menu`,{ref:k,target:f,trigger:_,disabled:S,...t,...O,children:[y,/* @__PURE__ */ p(`div`,{className:`dropdown-menu wui-context-menu-panel${E?` ${E}`:``}`,popover:`auto`,role:`menu`,"aria-label":x,tabIndex:-1,children:b(s,D,r.searchPlaceholder)})]})}function v(e){return e instanceof CustomEvent}var y=e=>`dropdown-item${e.tone===`danger`?` danger`:``}${e.disabled?` disabled`:``}`;function b(i,a,o){return i.map(i=>{if(i.divider)return/* @__PURE__ */ p(`hr`,{className:`dropdown-divider`},i.key);if(i.items!=null){let e=i.searchPlaceholder||o;return/* @__PURE__ */ m(`div`,{className:`wui-context-menu-sub`,role:`none`,"data-searchable":i.searchable?``:void 0,children:[/* @__PURE__ */ m(`button`,{type:`button`,className:y(i),role:`menuitem`,"aria-haspopup":`menu`,"aria-expanded":`false`,tabIndex:-1,"data-key":i.key,"aria-disabled":i.disabled?`true`:void 0,children:[s(i.icon,{size:16}),i.label,s(`chevron-right`,{size:14,className:`wui-context-menu-chevron`})]}),/* @__PURE__ */ m(`div`,{className:`dropdown-menu wui-context-menu-subpanel`,popover:`auto`,role:`menu`,"aria-label":i.label,tabIndex:-1,children:[i.searchable?/* @__PURE__ */ p(`input`,{type:`search`,className:`wui-context-menu-search`,autoComplete:`off`,placeholder:e,"aria-label":e}):null,b(i.items,a,o)]})]},i.key)}let c=!!i.to&&!i.disabled,l=/* @__PURE__ */ m(f,{children:[i.image?/* @__PURE__ */ p(`img`,{src:i.image,alt:``}):s(i.icon,{size:16}),i.label,n(i.shortcut)]}),u={className:y(i),role:`menuitem`,tabIndex:-1,"data-key":i.key,"aria-checked":i.checked||void 0,"data-hint":i.hint||void 0,"aria-keyshortcuts":t(i.shortcut),"aria-disabled":i.disabled||void 0,onClick:i.disabled?void 0:i.onClick,children:l};return c?/* @__PURE__ */ p(r,{link:e(a,{to:i.to}),...u},i.key):/* @__PURE__ */ p(`button`,{type:`button`,...u},i.key)})}export{_ as default};
@@ -1 +1 @@
1
- import{FILL_VARIANTS as e,TONES as t}from"../lib/vocabulary.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppActionIcon.js";import i from"./AppButton.js";import a from"./assertValidValue.js";import o from"./warnUnknownProps.js";import s from"./withTooltip.js";import{COPY_FEEDBACK_MS as c,copyTextToClipboard as l}from"@webority/ui-elements/helpers";import{useCallback as u,useEffect as d,useRef as f,useState as p}from"react";import{jsx as m}from"react/jsx-runtime";var h={sm:14,md:16,lg:20};function g(g){let{marker:_,props:v}=n(`AppCopyButton`,g),{text:y,label:b=`Copy`,copiedLabel:x=`Copied`,iconOnly:S=!1,size:C=`md`,tone:w=`primary`,variant:T=`ghost`,onCopied:E,className:D=``,tooltip:O,tooltipPlacement:k,...A}=v;o(`AppCopyButton`,A),a(`AppCopyButton`,`size`,C,Object.keys(h)),a(`AppCopyButton`,`tone`,w,t),a(`AppCopyButton`,`variant`,T,e);let[j,M]=p(!1),N=f(void 0);d(()=>()=>clearTimeout(N.current),[]);let P=u(async()=>{await l(y)&&(M(!0),clearTimeout(N.current),N.current=setTimeout(()=>M(!1),c),E?.())},[y,E]),F=j?x:b,I=j?`check`:`files`;return s(S?/* @__PURE__ */ m(r,{icon:I,label:F,size:h[C]??h.md,onClick:P,className:D,...A,..._}):/* @__PURE__ */ m(i,{leftIcon:I,tone:w,variant:T,size:C,onClick:P,className:D,"aria-live":`polite`,...A,..._,children:F}),O,k)}export{g as default};
1
+ import e from"../lib/useWuiText.js";import{FILL_VARIANTS as t,TONES as n}from"../lib/vocabulary.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppActionIcon.js";import a from"./AppButton.js";import o from"./assertValidValue.js";import s from"./warnUnknownProps.js";import c from"./withTooltip.js";import{COPY_FEEDBACK_MS as l,copyTextToClipboard as u}from"@webority/ui-elements/helpers";import{useCallback as d,useEffect as f,useRef as p,useState as m}from"react";import{jsx as h}from"react/jsx-runtime";import{COPY_BUTTON_TEXT as g}from"@webority/ui-elements/text";var _={sm:14,md:16,lg:20};function v(v){let{marker:y,props:b}=r(`AppCopyButton`,v),x=e(`copyButton`,g),{text:S,label:C=x.label,copiedLabel:w=x.copiedLabel,iconOnly:T=!1,size:E=`md`,tone:D=`primary`,variant:O=`ghost`,onCopied:k,className:A=``,tooltip:j,tooltipPlacement:M,...N}=b;s(`AppCopyButton`,N),o(`AppCopyButton`,`size`,E,Object.keys(_)),o(`AppCopyButton`,`tone`,D,n),o(`AppCopyButton`,`variant`,O,t);let[P,F]=m(!1),I=p(void 0);f(()=>()=>clearTimeout(I.current),[]);let L=d(async()=>{await u(S)&&(F(!0),clearTimeout(I.current),I.current=setTimeout(()=>F(!1),l),k?.())},[S,k]),R=P?w:C,z=P?`check`:`files`;return c(T?/* @__PURE__ */ h(i,{icon:z,label:R,size:_[E]??_.md,onClick:L,className:A,...N,...y}):/* @__PURE__ */ h(a,{leftIcon:z,tone:D,variant:O,size:E,onClick:L,className:A,"aria-live":`polite`,...N,...y,children:R}),j,M)}export{v as default};
@@ -1 +1 @@
1
- import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/useElementEntry.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppIcon.js";import i from"./AppSkeleton.js";import a from"./AppTablePagination.js";import o from"./assertValidValue.js";import s from"./warnUnknownProps.js";import{COLUMN_MAX_WIDTH as c,COLUMN_MIN_WIDTH as ee,DATA_TABLE_TEXT as l,PIN_AT_VAR as u,PIN_SIDES as d,ROW_HEIGHTS as te,ROW_MOVE_LIMIT as ne,ROW_SAVE_ERROR_CLASS as re,attachRowDrag as ie,attachScrollEdges as ae,groupCount as oe,groupItems as se,isImeSafeEnter as ce,measureRows as le,pinAtValue as ue,pinClasses as de,planPins as fe,playRowMoves as pe,rowOrderChanged as me,saveOutcomeText as he,settledRows as ge,syncTargets as _e,virtualRange as ve}from"@webority/ui-elements/helpers";import{Children as ye,Fragment as be,isValidElement as xe,useCallback as Se,useEffect as f,useLayoutEffect as Ce,useMemo as we,useRef as p,useState as m}from"react";import{Fragment as Te,jsx as h,jsxs as g}from"react/jsx-runtime";import{FORCED_STATE_CLASSES as Ee}from"@webority/theme/runtime";var De=()=>import(`@webority/ui-elements/elements/data-table`),Oe=[`comfortable`,`cozy`,`compact`],ke=[`auto`,`fixed`],Ae=[1,2,3,4];function _(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function je(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||xe(e)||Array.isArray(e))return e;throw Error(`AppDataTable: the value under "${t}" is not renderable; give that column a render function.`)}function Me(e,t){return je(_(e,t),t)}var v=()=>{try{return process.env.NODE_ENV!==`production`}catch{return!0}},y=/* @__PURE__ */ new Set;function b(t,n){!y.has(t)&&v()&&(y.add(t),e(`[@webority/ui-react] <AppDataTable> ${n}`))}var Ne=100,Pe=e=>{let t=typeof e==`object`&&e&&`id`in e?e.id:void 0;return typeof t==`string`||typeof t==`number`?t:void 0},Fe=()=>{},Ie=()=>({total:0,keys:[]}),Le=[],Re=(e,t,n)=>{let r=!!t?.(e),i=r?``:n?.(e)||``;return{state:r?`saving`:i?`error`:null,message:i}};function x(e){return e===`end`?`wui-cell-end`:e===`num`?`num`:e===`center`?`text-center`:``}function ze(e){return e===`center`?`44%`:e===`end`||e===`num`?`56%`:`60%`}function Be(e){return e==null||e===``?`-`:Array.isArray(e)?ye.toArray(e):typeof e==`boolean`?String(e):e}function Ve(e){if(!e||!(e.total>0))return!1;let t=e.pageSizes?.length?e.pageSizes:[e.pageSize];return e.total>Math.min(...t)}function He(e){t(`wui-data-table`,De);let{marker:ye,props:xe}=n(`AppDataTable`,e),{columns:v,rows:y=Le,rowKey:He=Pe,sort:Ue,onSort:We,loading:S=!1,skeletonRows:Ge=5,empty:Ke=`No records found.`,emptyFiltered:qe,sourceCount:Je,rowActions:C,rowActionsLabel:Ye,pagination:w,ariaLabel:Xe,className:Ze=``,wrapperClassName:Qe=``,selectable:T=!1,selectedIds:E,isRowSelectable:$e,onToggleRow:et,onToggleAll:tt,onSelectRange:nt,renderExpanded:rt,density:D=`comfortable`,tableLayout:it=`auto`,striped:at=!1,flush:ot=!1,pad:st,nameLines:O,headerTone:ct,rowDrag:k=!1,maxHeight:lt,stickyFirstColumn:ut=!1,stickyActions:dt=!1,stackOnMobile:A=!1,hiddenColumns:ft,rowStatus:pt,rowHref:j,onRowClick:mt,activeRowKey:ht,hoverRowKey:gt,resizableColumns:M=!1,viewKey:_t,groupBy:N,groupLabel:vt,virtual:P=!1,rowSaving:F,rowSaveError:I,...yt}=xe;s(`AppDataTable`,yt);let{style:bt,...xt}=yt,L=Se((e,t)=>{let n=He(e,t);if(n==null)throw Error(`AppDataTable: a row has no key. Pass rowKey, or give every row an id.`);return n},[He]),St=ft?.length?new Set(ft):null;v=St?v.filter(e=>!(e.hideable&&St.has(e.key))):v,o(`AppDataTable`,`density`,D,Oe),o(`AppDataTable`,`tableLayout`,it,ke),o(`AppDataTable`,`nameLines`,O,Ae);for(let e of v)o(`AppDataTable`,`column.pin`,e.pin,d);let Ct=[`table table-ledger`,D===`cozy`||D===`compact`?`wui-table-${D}`:``,at?`wui-table-striped`:``,ut?`wui-table-sticky-first`:``,dt?`wui-table-sticky-actions`:``,A?`wui-table-stack`:``,Ze].filter(Boolean).join(` `),R=typeof rt==`function`,[wt,Tt]=m(()=>/* @__PURE__ */ new Set),Et=e=>Tt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),Dt=v.some(e=>typeof e.footer==`function`),z=typeof j==`function`||typeof mt==`function`,Ot=e=>!!(e.target instanceof Element&&e.target.closest(`a, button, input, select, textarea, label, [role='menu'], [role='menuitem'], .dropdown`)),kt=(e,t)=>{if(Ot(t)||(mt&&mt(e),!j))return;let n=j(e);n&&(t.ctrlKey||t.metaKey||t.button===1?window.open(n,`_blank`,`noopener`):window.location.assign(n))},B=lt!==void 0,At=[`table-wrap`,B?`wui-table-scroll`:``,ot?`wui-table-flush`:``,Qe].filter(Boolean).join(` `),jt={maxHeight:B?lt:void 0,"--wui-table-pad":st!=null&&!ot?`${st}px`:void 0,"--wui-name-lines":P?`1`:O?.toString(),"--wui-table-header-bg":ct??void 0},Mt=Object.values(jt).some(e=>e!==void 0)||bt!==void 0?{...jt,...bt}:void 0,Nt=Math.max(1,v.length+ +!!C+ +!!T+ +!!R),Pt=v.some(e=>e.pin===`start`||e.pin===`end`),Ft=Pt||M||!!N||P,V=+!!R+ +!!T,It=Pt?fe([...R?[`lead`]:[],...T?[`lead`]:[],...v.map(e=>e.pin===`start`||e.pin===`end`?e.pin:null),...C?[null]:[]]):[],H=(e,t=``)=>{let n=It[e];return n?{className:`${t.trim()} ${de(n)}`.trim(),style:{[u]:ue(n.side,n.ordinal)}}:{className:t,style:void 0}},U=(e,t)=>It[e]?{...t,...H(e).style}:t,Lt=v.length-1+ +!!C;_t&&!M&&b(`view-key`,"`viewKey` remembers resized widths: add `resizableColumns`."),P&&!B&&b(`virtual-height`,"`virtual` needs `maxHeight`: without a scroll box every row renders."),P&&(R||A)&&b(`virtual-shape`,"`virtual` takes rows of one height, so it is off with `renderExpanded` or `stackOnMobile`."),P&&O!==void 0&&O!==1&&b(`virtual-name-lines`,"`nameLines` is ignored with `virtual`: a virtual table shows one line per name."),!P&&y?.length>500&&b(`rows-without-virtual`,`renders more than 500 rows without virtual: add virtual with maxHeight, or page the data.`);let W=P&&B&&!R&&!A&&!S&&y?.length>0,G=(e,t)=>!$e||!!$e(e,t),Rt=T&&y?y.reduce((e,t,n)=>e+ +!!G(t,n),0):0,K=T&&y?y.reduce((e,t,n)=>e+(G(t,n)&&E?.has(L(t,n))?1:0),0):0,zt=Rt>0&&K===Rt,Bt=K>0&&!zt,Vt=e=>{e&&(e.indeterminate=Bt)},Ht=p(null),Ut=(e,t)=>{let n=Ht.current;Ht.current=e;let r=t&&n!==null?y.findIndex((e,t)=>L(e,t)===n):-1,i=y.findIndex((t,n)=>L(t,n)===e);if(r<0||i<0||r===i){et?.(e);return}let a=!E?.has(e),o=Math.min(r,i),s=y.slice(o,Math.max(r,i)+1).map((e,t)=>[e,o+t]).filter(([e,t])=>G(e,t)).map(([e,t])=>L(e,t)).filter(e=>(E?.has(e)||!1)!==a);if(nt)nt(s,a);else for(let e of s)et?.(e)},Wt=e=>{$e?(y||[]).forEach((t,n)=>{let r=L(t,n);G(t,n)&&(E?.has(r)||!1)!==e&&et?.(r)}):tt?.(e)},[Gt,Kt]=m(()=>/* @__PURE__ */ new Set),qt=e=>Kt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),q=we(()=>{let e=(y||[]).map((e,t)=>({row:e,i:t}));return N?se(e,({row:e})=>String(_(e,N)??``)).flatMap(e=>[{group:e,open:!Gt.has(e.key)},...Gt.has(e.key)?[]:e.items]):e},[y,N,Gt]),Jt=p(null),[J,Yt]=m(null),Xt=Se(e=>{Jt.current=e,Yt(e)},[]),Zt=p(null);f(()=>{let e=J;if(!e)return;let t=e=>{let t=e.target instanceof Element?e.target.closest(`.u-name`):null;t&&!t.title&&(t.scrollWidth>t.clientWidth||t.scrollHeight>t.clientHeight)&&(t.title=(t.textContent??``).trim())},n=e=>{let t=e.target instanceof Element?e.target.closest(`tbody > tr[aria-rowindex]`)?.getAttribute(`aria-rowindex`):null;Zt.current=t?Number(t)-2:null},r=t=>{t.relatedTarget instanceof Node&&e.contains(t.relatedTarget)||(Zt.current=null)};e.addEventListener(`mouseover`,t),e.addEventListener(`focusin`,t),e.addEventListener(`focusin`,n),e.addEventListener(`focusout`,r);let i=ae(e);return()=>{e.removeEventListener(`mouseover`,t),e.removeEventListener(`focusin`,t),e.removeEventListener(`focusin`,n),e.removeEventListener(`focusout`,r),i()}},[J]),f(()=>{if(!k||!J)return;let e=ie(J);return _e(document),e},[k,J]);let Qt=p(Ie);Ce(()=>{Qt.current=()=>({total:y?.length??0,keys:y?y.flatMap((e,t)=>{let n=L(e,t);return G(e,t)&&E?.has(n)?[String(n)]:[]}):[]})});let $t=p(!1);f(()=>{if(!$t.current&&($t.current=!0,K===0))return;let{total:e,keys:t}=Qt.current();Jt.current?.querySelector(`table`)?.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:{selected:K,total:e,keys:t}}))},[K]);let[en,tn]=m({top:0,height:0}),[Y,nn]=m(te[D]??te.comfortable);f(()=>{let e=J;if(!W||!e)return;let t=0,n=()=>{t=0;let n=e.querySelector(`:scope > table > thead`)?.getBoundingClientRect().height||0,r={top:Math.max(0,e.scrollTop-n),height:e.clientHeight};tn(e=>e.top===r.top&&e.height===r.height?e:r)},r=()=>{t||=requestAnimationFrame(n)};e.addEventListener(`scroll`,r,{passive:!0});let i=typeof ResizeObserver<`u`?new ResizeObserver(r):null;return i?.observe(e),n(),()=>{e.removeEventListener(`scroll`,r),i?.disconnect(),t&&cancelAnimationFrame(t)}},[W,J]);let rn=p(null);Ce(()=>{if(!W){rn.current=null;return}let e=`${D}:${y?.length??0}`;if(rn.current===e)return;rn.current=e;let t=(Jt.current?.querySelector(`:scope > table > tbody > tr:not(.wui-virtual-spacer, .wui-group-row)`))?.getBoundingClientRect().height;t!==void 0&&t>0&&Math.abs(t-Y)>.5&&nn(t)});let X={start:0,end:q.length,before:0,after:0};if(W){X=ve({scrollTop:en.top,viewport:en.height||Number.parseFloat(String(lt))||0,rowHeight:Y,count:q.length});let e=Zt.current;e!==null&&e>=0&&e<q.length&&(e<X.start&&X.start-e<=Ne&&(X={...X,start:e,before:e*Y}),e>=X.end&&e-X.end<Ne&&(X={...X,end:e+1,after:(q.length-e-1)*Y}))}let an=p(null),on=p(null),sn=p(null),cn=!P&&!S&&y?.length>0&&y.length<=ne;Ce(()=>{let e=an.current;if(!cn||!e){on.current=null,sn.current=null;return}let t=y.map((e,t)=>L(e,t));me(sn.current,t)&&pe(e.rows,on.current),on.current=le(e.rows),sn.current=t});let Z=typeof F==`function`||typeof I==`function`,ln=p(null),un=p(null),dn=v[0]?.key;f(()=>{if(!Z){un.current=null;return}let e=/* @__PURE__ */ new Map;(y||[]).forEach((t,n)=>{let r=dn===void 0?void 0:_(t,dn),i=typeof r==`string`||typeof r==`number`?String(r):``;e.set(L(t,n),{...Re(t,F,I),label:i})});let t=he(ge(un.current,e));un.current=e,t&&ln.current&&(ln.current.textContent=t)},[y,F,I,L,Z,dn]);let fn=qe!==void 0&&(Je===void 0||Je>0)?qe:Ke,pn=({group:e,open:t},n)=>{let i=_(e.items[0]?.row,N??``),a=e.items.map(e=>e.row);return/* @__PURE__ */ h(`tr`,{className:`wui-group-row`,"data-group-key":e.key,"aria-rowindex":W?n+2:void 0,children:/* @__PURE__ */ h(`th`,{className:`wui-group-cell`,scope:`rowgroup`,colSpan:Nt,children:/* @__PURE__ */ g(`button`,{type:`button`,className:`wui-group-toggle`,"aria-expanded":t,onClick:()=>qt(e.key),children:[/* @__PURE__ */ h(r,{name:`chevron-down`,size:16}),/* @__PURE__ */ h(`span`,{className:`wui-group-label`,children:vt?vt(i,a):Be(je(i,N??``))}),/* @__PURE__ */ h(`span`,{className:`wui-group-count`,"aria-hidden":`true`,children:oe(e.items.length)}),/* @__PURE__ */ h(`span`,{className:`visually-hidden wui-group-rows`,children:`, ${l.rows(e.items.length)}`})]})})},`group:${e.key}`)},mn=({row:e,i:t},n)=>{let i=L(e,t),a=R&&wt.has(i),o=ht!=null&&String(ht)===String(i),s=gt!=null&&String(gt)===String(i),c=String(i).replace(/[^a-z0-9]/gi,`_`),ee=H(0,`wui-expand-cell`),l=H(+!!R,`wui-select-cell`),u=Z?Re(e,F,I):null,d=G(e,t);return/* @__PURE__ */ g(be,{children:[/* @__PURE__ */ g(`tr`,{className:[T&&d&&E?.has(i)?`is-selected`:``,z?`wui-row-link`:``,o?`wui-row-active`:``,s?Ee.hover:``].filter(Boolean).join(` `)||void 0,"aria-current":o?`true`:void 0,"aria-rowindex":W?n+2:void 0,"aria-busy":u?.state===`saving`?`true`:void 0,"data-wui-save-state":u?.state||void 0,"data-status":pt?.(e)||void 0,"data-href":j?.(e)||void 0,"data-row-key":k?String(i):void 0,tabIndex:z?0:void 0,onClick:z?t=>kt(e,t):void 0,onAuxClick:z&&j?t=>t.button===1&&kt(e,t):void 0,onKeyDown:z?t=>{ce(t.nativeEvent)&&t.target===t.currentTarget&&kt(e,t)}:void 0,children:[R&&/* @__PURE__ */ h(`td`,{className:ee.className,style:ee.style,children:/* @__PURE__ */ h(`button`,{type:`button`,className:`wui-expand-toggle${a?` is-open`:``}`,"aria-expanded":a,"aria-controls":a?`${c}-expanded`:void 0,"aria-label":a?`Collapse row`:`Expand row`,onClick:()=>Et(i),children:/* @__PURE__ */ h(r,{name:`chevron-down`,size:16})})}),T&&/* @__PURE__ */ h(`td`,{className:l.className,style:l.style,children:/* @__PURE__ */ h(`input`,{type:`checkbox`,className:`wui-check`,checked:d&&(E?.has(i)||!1),disabled:!d,onChange:e=>Ut(i,e.nativeEvent instanceof MouseEvent&&e.nativeEvent.shiftKey),onMouseDown:e=>{e.shiftKey&&e.preventDefault()},"aria-label":`Select row`})}),v.map((t,n)=>{let r=t.rowHeader?`th`:`td`;return/* @__PURE__ */ g(r,{scope:t.rowHeader?`row`:void 0,className:H(V+n,(n===0?`wui-name-cell `:``)+(t.rowHeader?`wui-row-header `:``)+(t.nowrap?`text-nowrap `:``)+x(t.align)+(t.cellClassName?` ${t.cellClassName}`:``)).className,style:U(V+n,t.cellStyle),"data-label":A&&typeof t.label==`string`?t.label:void 0,children:[t.render?t.render(e):Be(Me(e,t.key)),n===0&&u?.state===`error`&&/* @__PURE__ */ h(`span`,{className:re,children:u.message})]},t.key)}),C&&/* @__PURE__ */ h(`td`,{children:/* @__PURE__ */ h(`div`,{className:`u-row-actions`,children:C(e)})})]}),a&&/* @__PURE__ */ h(`tr`,{className:`wui-row-expanded`,children:/* @__PURE__ */ h(`td`,{id:`${c}-expanded`,colSpan:Nt,children:rt?.(e)})})]},i)},hn=(e,t)=>`group`in e?pn(e,t):mn(e,t),gn=(e,t)=>W?/* @__PURE__ */ h(`tr`,{className:`wui-virtual-spacer`,"aria-hidden":`true`,hidden:t===0,children:/* @__PURE__ */ h(`td`,{colSpan:Nt,style:{height:t}})},e):null,Q=H(0,`wui-expand-cell`),$=H(+!!R,`wui-select-cell`),_n=()=>Array.from({length:Ge},(e,t)=>`skeleton-${t}`).map(e=>/* @__PURE__ */ g(`tr`,{children:[R&&/* @__PURE__ */ h(`td`,{className:Q.className,style:Q.style}),T&&/* @__PURE__ */ h(`td`,{className:$.className,style:$.style}),v.map((e,t)=>/* @__PURE__ */ h(`td`,{className:H(V+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+x(e.align)).className,style:U(V+t,void 0),"data-label":A&&typeof e.label==`string`?e.label:void 0,children:/* @__PURE__ */ h(i,{width:ze(e.align),height:12,radius:6})},e.key)),C&&/* @__PURE__ */ h(`td`,{children:/* @__PURE__ */ h(`div`,{className:`u-row-actions`,children:/* @__PURE__ */ h(i,{width:`32px`,height:12,radius:6})})})]},e));return/* @__PURE__ */ g(Te,{children:[/* @__PURE__ */ g(Ft?`wui-data-table`:`div`,{ref:Xt,...Ft?{class:At,resizable:M?``:void 0,"view-key":_t||void 0,"data-wui-row-drag":k?``:void 0}:{className:At,"data-wui-row-drag":k?``:void 0},style:Mt,tabIndex:0,...ye,...xt,children:[/* @__PURE__ */ g(`table`,{className:Ct,"aria-label":Xe,"aria-rowcount":W?q.length+1:void 0,style:it===`fixed`?{tableLayout:`fixed`}:void 0,children:[/* @__PURE__ */ h(`thead`,{children:/* @__PURE__ */ g(`tr`,{"aria-rowindex":W?1:void 0,children:[R&&/* @__PURE__ */ h(`th`,{className:Q.className,style:Q.style,children:/* @__PURE__ */ h(`span`,{className:`visually-hidden`,children:`Expand`})}),T&&/* @__PURE__ */ h(`th`,{className:$.className,style:$.style,children:/* @__PURE__ */ h(`input`,{ref:Vt,type:`checkbox`,className:`wui-check`,checked:zt,disabled:S,onChange:e=>Wt(e.target.checked),"aria-label":`Select all rows`})}),v.map((e,t)=>{let n=e.sortable?We:void 0,i=n!==void 0,a=Ue&&Ue.key===e.key,o=e.align===`num`||e.align===`end`,s=i&&/* @__PURE__ */ h(`span`,{className:`sort-icon${o?` wui-sort-lead`:``}`,children:/* @__PURE__ */ h(r,{name:`chevrons-up-down`,size:14})}),u=M&&t!==Lt,d=e.width||e.minWidth?{width:e.width,minWidth:e.minWidth}:void 0;return/* @__PURE__ */ g(`th`,{className:H(V+t,(i?`sortable `:``)+(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+(e.grow?`wui-col-grow `:``)+(u?`wui-col-resizable `:``)+x(e.align)).className,style:U(V+t,d),"data-key":Ft?e.key:void 0,"aria-label":u&&typeof e.label==`string`?e.label:void 0,"data-pin":e.pin===`start`||e.pin===`end`?e.pin:void 0,tabIndex:i?0:void 0,"aria-sort":a?Ue?.dir===`asc`?`ascending`:`descending`:i?`none`:void 0,onClick:n?()=>{S||n(e.key)}:void 0,onKeyDown:n?t=>{t.target===t.currentTarget&&(ce(t.nativeEvent)||t.key===` `)&&(t.preventDefault(),S||n(e.key))}:void 0,children:[o&&s,e.label,!o&&s,u&&/* @__PURE__ */ h(`span`,{className:`wui-col-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":ee,"aria-valuemax":c,tabIndex:0,"aria-label":l.resize(typeof e.label==`string`?e.label:e.key)})]},e.key)}),C&&(Ye?/* @__PURE__ */ h(`th`,{className:`wui-cell-end`,children:Ye}):/* @__PURE__ */ h(`th`,{className:`wui-cell-end`,children:/* @__PURE__ */ h(`span`,{className:`visually-hidden`,children:`Actions`})}))]})}),/* @__PURE__ */ h(`tbody`,{ref:an,children:S?_n():y?.length?/* @__PURE__ */ g(Te,{children:[gn(`before`,X.before),q.slice(X.start,X.end).map((e,t)=>hn(e,X.start+t)),gn(`after`,X.after)]}):null}),Dt&&!S&&y?.length>0&&/* @__PURE__ */ h(`tfoot`,{children:/* @__PURE__ */ g(`tr`,{children:[R&&/* @__PURE__ */ h(`td`,{className:Q.className,style:Q.style}),T&&/* @__PURE__ */ h(`td`,{className:$.className,style:$.style}),v.map((e,t)=>/* @__PURE__ */ h(`td`,{className:H(V+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+x(e.align)).className,style:U(V+t,void 0),children:e.footer?e.footer(y):null},e.key)),C&&/* @__PURE__ */ h(`td`,{})]})})]}),!S&&!y?.length&&/* @__PURE__ */ h(`div`,{className:`tbl-empty-block`,children:typeof fn==`string`?/* @__PURE__ */ h(`div`,{className:`tbl-empty-plain`,children:fn}):fn})]}),Ve(w)&&/* @__PURE__ */ h(a,{page:w.page,totalPages:w.totalPages,total:w.total,pageSize:w.pageSize,onPageChange:S?Fe:w.setPage,onPageSizeChange:S?Fe:w.setPageSize,pageSizes:w.pageSizes,mode:w.mode,summary:w.summary}),Z&&/* @__PURE__ */ h(`div`,{ref:ln,className:`visually-hidden`,role:`status`,"aria-live":`polite`,"data-wui-table-status":``})]})}export{He as default};
1
+ import{devWarn as e}from"../lib/devWarn.js";import{emptyPlaceholder as t}from"../lib/emptyValue.js";import n from"../lib/useElementEntry.js";import r from"../lib/useWuiText.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./AppIcon.js";import o from"./AppInfoTip.js";import s from"./AppRowActions.js";import c from"./AppSkeleton.js";import l from"./AppTablePagination.js";import u from"./assertValidValue.js";import ee from"./warnUnknownProps.js";import{COLUMN_MAX_WIDTH as te,COLUMN_MIN_WIDTH as d,PIN_AT_VAR as f,PIN_SIDES as ne,ROW_HEIGHTS as p,ROW_MOVE_LIMIT as re,ROW_SAVE_ERROR_CLASS as ie,attachRowDrag as ae,attachScrollEdges as oe,groupCount as se,groupItems as ce,isImeSafeEnter as le,measureRows as ue,pinAtValue as de,pinClasses as fe,planPins as pe,playRowMoves as me,rowOrderChanged as he,saveOutcomeText as ge,settledRows as _e,syncTargets as ve,virtualRange as ye}from"@webority/ui-elements/helpers";import{Children as be,Fragment as xe,isValidElement as Se,useCallback as Ce,useEffect as m,useLayoutEffect as we,useMemo as Te,useRef as h,useState as g}from"react";import{Fragment as Ee,jsx as _,jsxs as v}from"react/jsx-runtime";import{DATA_TABLE_TEXT as De,ROW_ACTIONS_TEXT as Oe,fillText as ke,pluralText as Ae}from"@webority/ui-elements/text";import{FORCED_STATE_CLASSES as je}from"@webority/theme/runtime";var Me=()=>import(`@webority/ui-elements/elements/data-table`),Ne=[`comfortable`,`cozy`,`compact`],Pe=[`auto`,`fixed`],Fe=[1,2,3,4];function y(e,t){return typeof e==`object`&&e?Reflect.get(e,t):void 0}function Ie(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||Se(e)||Array.isArray(e))return e;throw Error(`AppDataTable: the value under "${t}" is not renderable; give that column a render function.`)}function Le(e,t){return Ie(y(e,t),t)}var Re=()=>{try{return process.env.NODE_ENV!==`production`}catch{return!0}},ze=/* @__PURE__ */ new Set;function b(t,n){!ze.has(t)&&Re()&&(ze.add(t),e(`[@webority/ui-react] <AppDataTable> ${n}`))}var Be=100,Ve=e=>{let t=typeof e==`object`&&e&&`id`in e?e.id:void 0;return typeof t==`string`||typeof t==`number`?t:void 0},He=()=>{},Ue=()=>({total:0,keys:[]}),We=[],Ge=(e,t,n)=>{let r=!!t?.(e),i=r?``:n?.(e)||``;return{state:r?`saving`:i?`error`:null,message:i}};function x(e){return e===`end`?`wui-cell-end`:e===`num`?`num`:e===`center`?`text-center`:``}function Ke(e){return e===`center`?`44%`:e===`end`||e===`num`?`56%`:`60%`}function qe(e){return e==null||e===``?t():Array.isArray(e)?be.toArray(e):typeof e==`boolean`?String(e):e}function Je(e){if(!e||!(e.total>0))return!1;let t=e.pageSizes?.length?e.pageSizes:[e.pageSize];return e.total>Math.min(...t)}function S(e){n(`wui-data-table`,Me);let t=r(`dataTable`,De),be=r(`rowActions`,Oe),Se=e=>e?ke(t.resizeColumnText,{label:e}):t.resizeColumnLabel,{marker:Re,props:ze}=i(`AppDataTable`,e),{columns:S,rows:C=We,rowKey:Ye=Ve,sort:Xe,onSort:Ze,loading:w=!1,refreshing:Qe=!1,skeletonRows:$e=5,empty:et=t.empty,emptyFiltered:tt,sourceCount:nt,rowActions:T,linkComponent:rt,rowActionsLabel:it,pagination:E,ariaLabel:at,className:ot=``,wrapperClassName:st=``,selectable:D=!1,selectedIds:O,isRowSelectable:ct,onToggleRow:lt,onToggleAll:ut,onSelectRange:dt,renderExpanded:ft,singleExpand:pt=!1,density:k=`comfortable`,tableLayout:mt=`auto`,striped:ht=!1,flush:gt=!1,pad:_t,nameLines:A,headerTone:vt,rowDrag:j=!1,maxHeight:yt,stickyFirstColumn:bt=!1,stickyActions:xt=!1,equalActions:St=!1,linkFirstColumn:Ct=!1,stackOnMobile:M=!1,hiddenColumns:wt,rowStatus:Tt,rowHref:N,onRowClick:Et,activeRowKey:Dt,hoverRowKey:Ot,resizableColumns:P=!1,viewKey:kt,groupBy:F,groupLabel:At,virtual:I=!1,rowSaving:L,rowSaveError:R,...jt}=ze;ee(`AppDataTable`,jt);let{style:Mt,...Nt}=jt,z=Ce((e,t)=>{let n=Ye(e,t);if(n==null)throw Error(`AppDataTable: a row has no key. Pass rowKey, or give every row an id.`);return n},[Ye]),Pt=wt?.length?new Set(wt):null;S=Pt?S.filter(e=>!(e.hideable&&Pt.has(e.key))):S,u(`AppDataTable`,`density`,k,Ne),u(`AppDataTable`,`tableLayout`,mt,Pe),u(`AppDataTable`,`nameLines`,A,Fe);for(let e of S)u(`AppDataTable`,`column.pin`,e.pin,ne);let B=typeof N==`function`||typeof Et==`function`,Ft=[`table table-ledger`,k===`cozy`||k===`compact`?`wui-table-${k}`:``,ht?`wui-table-striped`:``,bt?`wui-table-sticky-first`:``,xt?`wui-table-sticky-actions`:``,St?`wui-table-equal-actions`:``,M?`wui-table-stack`:``,Ct&&B?`wui-table-link-first`:``,ot].filter(Boolean).join(` `),V=typeof ft==`function`,[It,Lt]=g(()=>/* @__PURE__ */ new Set),Rt=e=>Lt(t=>{if(t.has(e)){let n=new Set(t);return n.delete(e),n}return pt?/* @__PURE__ */ new Set([e]):new Set(t).add(e)}),zt=S.some(e=>typeof e.footer==`function`),Bt=e=>!!(e.target instanceof Element&&e.target.closest(`a, button, input, select, textarea, label, [role='menu'], [role='menuitem'], .dropdown`)),Vt=(e,t)=>{if(Bt(t)||(Et&&Et(e),!N))return;let n=N(e);n&&(t.ctrlKey||t.metaKey||t.button===1?window.open(n,`_blank`,`noopener`):window.location.assign(n))},H=yt!==void 0,Ht=Qe&&!w&&C.length>0,Ut=[`table-wrap`,H?`wui-table-scroll`:``,gt?`wui-table-flush`:``,Ht?`wui-table-refreshing`:``,st].filter(Boolean).join(` `),Wt={maxHeight:H?yt:void 0,"--wui-table-pad":_t!=null&&!gt?`${_t}px`:void 0,"--wui-name-lines":I?`1`:A?.toString(),"--wui-table-header-bg":vt??void 0},Gt=Object.values(Wt).some(e=>e!==void 0)||Mt!==void 0?{...Wt,...Mt}:void 0,Kt=Math.max(1,S.length+ +!!T+ +!!D+ +!!V),qt=S.some(e=>e.pin===`start`||e.pin===`end`),Jt=qt||P||!!F||I,U=+!!V+ +!!D,Yt=qt?pe([...V?[`lead`]:[],...D?[`lead`]:[],...S.map(e=>e.pin===`start`||e.pin===`end`?e.pin:null),...T?[null]:[]]):[],W=(e,t=``)=>{let n=Yt[e];return n?{className:`${t.trim()} ${fe(n)}`.trim(),style:{[f]:de(n.side,n.ordinal)}}:{className:t,style:void 0}},Xt=(e,t)=>Yt[e]?{...t,...W(e).style}:t,Zt=S.length-1+ +!!T;kt&&!P&&b(`view-key`,"`viewKey` remembers resized widths: add `resizableColumns`."),I&&!H&&b(`virtual-height`,"`virtual` needs `maxHeight`: without a scroll box every row renders."),I&&(V||M)&&b(`virtual-shape`,"`virtual` takes rows of one height, so it is off with `renderExpanded` or `stackOnMobile`."),I&&A!==void 0&&A!==1&&b(`virtual-name-lines`,"`nameLines` is ignored with `virtual`: a virtual table shows one line per name."),Ct&&!B&&b(`link-first-column`,"`linkFirstColumn` needs rowHref or onRowClick: the row is what opens."),pt&&typeof ft!=`function`&&b(`single-expand`,"`singleExpand` needs renderExpanded: there are no rows to expand."),!I&&C?.length>500&&b(`rows-without-virtual`,`renders more than 500 rows without virtual: add virtual with maxHeight, or page the data.`);let G=I&&H&&!V&&!M&&!w&&C?.length>0,K=(e,t)=>!ct||!!ct(e,t),Qt=D&&C?C.reduce((e,t,n)=>e+ +!!K(t,n),0):0,q=D&&C?C.reduce((e,t,n)=>e+(K(t,n)&&O?.has(z(t,n))?1:0),0):0,$t=Qt>0&&q===Qt,en=q>0&&!$t,tn=e=>{e&&(e.indeterminate=en)},nn=h(null),rn=(e,t)=>{let n=nn.current;nn.current=e;let r=t&&n!==null?C.findIndex((e,t)=>z(e,t)===n):-1,i=C.findIndex((t,n)=>z(t,n)===e);if(r<0||i<0||r===i){lt?.(e);return}let a=!O?.has(e),o=Math.min(r,i),s=C.slice(o,Math.max(r,i)+1).map((e,t)=>[e,o+t]).filter(([e,t])=>K(e,t)).map(([e,t])=>z(e,t)).filter(e=>(O?.has(e)||!1)!==a);if(dt)dt(s,a);else for(let e of s)lt?.(e)},an=e=>{ct?(C||[]).forEach((t,n)=>{let r=z(t,n);K(t,n)&&(O?.has(r)||!1)!==e&&lt?.(r)}):ut?.(e)},[on,sn]=g(()=>/* @__PURE__ */ new Set),cn=e=>sn(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),J=Te(()=>{let e=(C||[]).map((e,t)=>({row:e,i:t}));return F?ce(e,({row:e})=>String(y(e,F)??``)).flatMap(e=>[{group:e,open:!on.has(e.key)},...on.has(e.key)?[]:e.items]):e},[C,F,on]),ln=h(null),[Y,un]=g(null),dn=Ce(e=>{ln.current=e,un(e)},[]),fn=h(null);m(()=>{let e=Y;if(!e)return;let t=e=>{let t=e.target instanceof Element?e.target.closest(`.u-name`):null;t&&!t.title&&(t.scrollWidth>t.clientWidth||t.scrollHeight>t.clientHeight)&&(t.title=(t.textContent??``).trim())},n=e=>{let t=e.target instanceof Element?e.target.closest(`tbody > tr[aria-rowindex]`)?.getAttribute(`aria-rowindex`):null;fn.current=t?Number(t)-2:null},r=t=>{t.relatedTarget instanceof Node&&e.contains(t.relatedTarget)||(fn.current=null)};e.addEventListener(`mouseover`,t),e.addEventListener(`focusin`,t),e.addEventListener(`focusin`,n),e.addEventListener(`focusout`,r);let i=oe(e);return()=>{e.removeEventListener(`mouseover`,t),e.removeEventListener(`focusin`,t),e.removeEventListener(`focusin`,n),e.removeEventListener(`focusout`,r),i()}},[Y]),m(()=>{if(!j||!Y)return;let e=ae(Y);return ve(document),e},[j,Y]);let pn=h(Ue);we(()=>{pn.current=()=>({total:C?.length??0,keys:C?C.flatMap((e,t)=>{let n=z(e,t);return K(e,t)&&O?.has(n)?[String(n)]:[]}):[]})});let mn=h(!1);m(()=>{if(!mn.current&&(mn.current=!0,q===0))return;let{total:e,keys:t}=pn.current();ln.current?.querySelector(`table`)?.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:{selected:q,total:e,keys:t}}))},[q]);let[hn,gn]=g({top:0,height:0}),[_n,vn]=g(p[k]??p.comfortable);m(()=>{let e=Y;if(!G||!e)return;let t=0,n=()=>{t=0;let n=e.querySelector(`:scope > table > thead`)?.getBoundingClientRect().height||0,r={top:Math.max(0,e.scrollTop-n),height:e.clientHeight};gn(e=>e.top===r.top&&e.height===r.height?e:r)},r=()=>{t||=requestAnimationFrame(n)};e.addEventListener(`scroll`,r,{passive:!0});let i=typeof ResizeObserver<`u`?new ResizeObserver(r):null;return i?.observe(e),n(),()=>{e.removeEventListener(`scroll`,r),i?.disconnect(),t&&cancelAnimationFrame(t)}},[G,Y]);let yn=h(null);we(()=>{if(!G){yn.current=null;return}let e=`${k}:${C?.length??0}`;if(yn.current===e)return;yn.current=e;let t=(ln.current?.querySelector(`:scope > table > tbody > tr:not(.wui-virtual-spacer, .wui-group-row)`))?.getBoundingClientRect().height;t!==void 0&&t>0&&Math.abs(t-_n)>.5&&vn(t)});let X={start:0,end:J.length,before:0,after:0};if(G){X=ye({scrollTop:hn.top,viewport:hn.height||Number.parseFloat(String(yt))||0,rowHeight:_n,count:J.length});let e=fn.current;e!==null&&e>=0&&e<J.length&&(e<X.start&&X.start-e<=Be&&(X={...X,start:e,before:e*_n}),e>=X.end&&e-X.end<Be&&(X={...X,end:e+1,after:(J.length-e-1)*_n}))}let bn=h(null),xn=h(null),Sn=h(null),Cn=!I&&!w&&C?.length>0&&C.length<=re;we(()=>{let e=bn.current;if(!Cn||!e){xn.current=null,Sn.current=null;return}let t=C.map((e,t)=>z(e,t));he(Sn.current,t)&&me(e.rows,xn.current),xn.current=ue(e.rows),Sn.current=t});let wn=typeof L==`function`||typeof R==`function`,Tn=h(null),En=h(null),Z=S[0]?.key;m(()=>{if(!wn){En.current=null;return}let e=/* @__PURE__ */ new Map;(C||[]).forEach((t,n)=>{let r=Z===void 0?void 0:y(t,Z),i=typeof r==`string`||typeof r==`number`?String(r):``;e.set(z(t,n),{...Ge(t,L,R),label:i})});let t=ge(_e(En.current,e));En.current=e,t&&Tn.current&&(Tn.current.textContent=t)},[C,L,R,z,wn,Z]);let Dn=tt!==void 0&&(nt===void 0||nt>0)?tt:et,On=({group:e,open:n},r)=>{let i=y(e.items[0]?.row,F??``),o=e.items.map(e=>e.row);return/* @__PURE__ */ _(`tr`,{className:`wui-group-row`,"data-group-key":e.key,"aria-rowindex":G?r+2:void 0,children:/* @__PURE__ */ _(`th`,{className:`wui-group-cell`,scope:`rowgroup`,colSpan:Kt,children:/* @__PURE__ */ v(`button`,{type:`button`,className:`wui-group-toggle`,"aria-expanded":n,onClick:()=>cn(e.key),children:[/* @__PURE__ */ _(a,{name:`chevron-down`,size:16}),/* @__PURE__ */ _(`span`,{className:`wui-group-label`,children:At?At(i,o):qe(Ie(i,F??``))}),/* @__PURE__ */ _(`span`,{className:`wui-group-count`,"aria-hidden":`true`,children:se(e.items.length)}),/* @__PURE__ */ _(`span`,{className:`visually-hidden wui-group-rows`,children:`, ${Ae(t,`groupRows`,e.items.length,{count:se(e.items.length)})}`})]})})},`group:${e.key}`)},kn=({row:e,i:n},r)=>{let i=z(e,n),o=V&&It.has(i),c=Dt!=null&&String(Dt)===String(i),l=Ot!=null&&String(Ot)===String(i),u=String(i).replace(/[^a-z0-9]/gi,`_`),ee=W(0,`wui-expand-cell`),te=W(+!!V,`wui-select-cell`),d=wn?Ge(e,L,R):null,f=K(e,n),ne=T?.(e);if(T&&!Array.isArray(ne))throw TypeError(`AppDataTable: rowActions returns a list of actions ({ key, label, icon, onClick or href }). It returned something else: restate the buttons as a list, see node scripts/codemods/row-actions.mjs --check.`);let p=Z===void 0?void 0:y(e,Z),re=typeof p==`string`||typeof p==`number`?ke(t.moreActionsForText,{firstValue:p}):be.menuLabel;return/* @__PURE__ */ v(xe,{children:[/* @__PURE__ */ v(`tr`,{className:[D&&f&&O?.has(i)?`is-selected`:``,B?`wui-row-link`:``,c?`wui-row-active`:``,l?je.hover:``].filter(Boolean).join(` `)||void 0,"aria-current":c?`true`:void 0,"aria-rowindex":G?r+2:void 0,"aria-busy":d?.state===`saving`?`true`:void 0,"data-wui-save-state":d?.state||void 0,"data-status":Tt?.(e)||void 0,"data-href":N?.(e)||void 0,"data-row-key":j?String(i):void 0,tabIndex:B?0:void 0,onClick:B?t=>Vt(e,t):void 0,onAuxClick:B&&N?t=>t.button===1&&Vt(e,t):void 0,onKeyDown:B?t=>{le(t.nativeEvent)&&t.target===t.currentTarget&&Vt(e,t)}:void 0,children:[V&&/* @__PURE__ */ _(`td`,{className:ee.className,style:ee.style,children:/* @__PURE__ */ _(`button`,{type:`button`,className:`wui-expand-toggle${o?` is-open`:``}`,"aria-expanded":o,"aria-controls":o?`${u}-expanded`:void 0,"aria-label":o?t.collapseRowLabel:t.expandRowLabel,onClick:()=>Rt(i),children:/* @__PURE__ */ _(a,{name:`chevron-down`,size:16})})}),D&&/* @__PURE__ */ _(`td`,{className:te.className,style:te.style,children:/* @__PURE__ */ _(`input`,{type:`checkbox`,className:`wui-check`,checked:f&&(O?.has(i)||!1),disabled:!f,onChange:e=>rn(i,e.nativeEvent instanceof MouseEvent&&e.nativeEvent.shiftKey),onMouseDown:e=>{e.shiftKey&&e.preventDefault()},"aria-label":t.selectRowLabel})}),S.map((t,n)=>{let r=t.rowHeader?`th`:`td`;return/* @__PURE__ */ v(r,{scope:t.rowHeader?`row`:void 0,className:W(U+n,(n===0?`wui-name-cell `:``)+(t.rowHeader?`wui-row-header `:``)+(t.nowrap?`text-nowrap `:``)+x(t.align)+(t.cellClassName?` ${t.cellClassName}`:``)).className,style:Xt(U+n,t.cellStyle),"data-label":M&&typeof t.label==`string`?t.label:void 0,children:[t.render?t.render(e):qe(Le(e,t.key)),n===0&&d?.state===`error`&&/* @__PURE__ */ _(`span`,{className:ie,children:d.message})]},t.key)}),T&&/* @__PURE__ */ _(`td`,{children:/* @__PURE__ */ _(s,{items:ne??[],menuLabel:re,linkComponent:rt})})]}),o&&/* @__PURE__ */ _(`tr`,{className:`wui-row-expanded`,children:/* @__PURE__ */ _(`td`,{id:`${u}-expanded`,colSpan:Kt,children:ft?.(e)})})]},i)},An=(e,t)=>`group`in e?On(e,t):kn(e,t),jn=(e,t)=>G?/* @__PURE__ */ _(`tr`,{className:`wui-virtual-spacer`,"aria-hidden":`true`,hidden:t===0,children:/* @__PURE__ */ _(`td`,{colSpan:Kt,style:{height:t}})},e):null,Q=W(0,`wui-expand-cell`),$=W(+!!V,`wui-select-cell`),Mn=()=>Array.from({length:$e},(e,t)=>`skeleton-${t}`).map(e=>/* @__PURE__ */ v(`tr`,{children:[V&&/* @__PURE__ */ _(`td`,{className:Q.className,style:Q.style}),D&&/* @__PURE__ */ _(`td`,{className:$.className,style:$.style}),S.map((e,t)=>/* @__PURE__ */ _(`td`,{className:W(U+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+x(e.align)).className,style:Xt(U+t,void 0),"data-label":M&&typeof e.label==`string`?e.label:void 0,children:/* @__PURE__ */ _(c,{width:Ke(e.align),height:12,radius:6})},e.key)),T&&/* @__PURE__ */ _(`td`,{children:/* @__PURE__ */ _(`div`,{className:`u-row-actions`,children:/* @__PURE__ */ _(c,{width:`32px`,height:12,radius:6})})})]},e));return/* @__PURE__ */ v(Ee,{children:[/* @__PURE__ */ v(Jt?`wui-data-table`:`div`,{ref:dn,...Jt?{class:Ut,resizable:P?``:void 0,"view-key":kt||void 0,"data-wui-row-drag":j?``:void 0,"aria-busy":Ht||void 0}:{className:Ut,"data-wui-row-drag":j?``:void 0,"aria-busy":Ht||void 0},style:Gt,tabIndex:0,...Re,...Nt,children:[/* @__PURE__ */ v(`table`,{className:Ft,"aria-label":at,"aria-rowcount":G?J.length+1:void 0,style:mt===`fixed`?{tableLayout:`fixed`}:void 0,children:[/* @__PURE__ */ _(`thead`,{children:/* @__PURE__ */ v(`tr`,{"aria-rowindex":G?1:void 0,children:[V&&/* @__PURE__ */ _(`th`,{className:Q.className,style:Q.style,children:/* @__PURE__ */ _(`span`,{className:`visually-hidden`,children:t.expandLabel})}),D&&/* @__PURE__ */ _(`th`,{className:$.className,style:$.style,children:/* @__PURE__ */ _(`input`,{ref:tn,type:`checkbox`,className:`wui-check`,checked:$t,disabled:w,onChange:e=>an(e.target.checked),"aria-label":t.selectAllRowsLabel})}),S.map((e,t)=>{let n=e.sortable?Ze:void 0,r=n!==void 0,i=Xe&&Xe.key===e.key,s=e.align===`num`||e.align===`end`,c=r&&/* @__PURE__ */ _(`span`,{className:`sort-icon${s?` wui-sort-lead`:``}`,children:/* @__PURE__ */ _(a,{name:`chevrons-up-down`,size:14})}),l=P&&t!==Zt,u=e.width||e.minWidth?{width:e.width,minWidth:e.minWidth}:void 0;return/* @__PURE__ */ v(`th`,{className:W(U+t,(r?`sortable `:``)+(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+(e.grow?`wui-col-grow `:``)+(l?`wui-col-resizable `:``)+x(e.align)).className,style:Xt(U+t,u),"data-key":Jt?e.key:void 0,"aria-label":l&&typeof e.label==`string`?e.label:void 0,"data-pin":e.pin===`start`||e.pin===`end`?e.pin:void 0,tabIndex:r?0:void 0,"aria-sort":i?Xe?.dir===`asc`?`ascending`:`descending`:r?`none`:void 0,onClick:n?t=>{t.target instanceof Element&&t.target.closest(`.infotip`)||w||n(e.key)}:void 0,onKeyDown:n?t=>{t.target===t.currentTarget&&(le(t.nativeEvent)||t.key===` `)&&(t.preventDefault(),w||n(e.key))}:void 0,children:[s&&c,e.label,!s&&c,e.help?/* @__PURE__ */ _(o,{label:typeof e.label==`string`?e.label:void 0,children:e.help}):null,l&&/* @__PURE__ */ _(`span`,{className:`wui-col-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":d,"aria-valuemax":te,tabIndex:0,"aria-label":Se(typeof e.label==`string`?e.label:e.key)})]},e.key)}),T&&(it?/* @__PURE__ */ _(`th`,{className:`wui-cell-end`,children:it}):/* @__PURE__ */ _(`th`,{className:`wui-cell-end`,children:/* @__PURE__ */ _(`span`,{className:`visually-hidden`,children:t.rowActionsLabel})}))]})}),/* @__PURE__ */ _(`tbody`,{ref:bn,children:w?Mn():C?.length?/* @__PURE__ */ v(Ee,{children:[jn(`before`,X.before),J.slice(X.start,X.end).map((e,t)=>An(e,X.start+t)),jn(`after`,X.after)]}):null}),zt&&!w&&C?.length>0&&/* @__PURE__ */ _(`tfoot`,{children:/* @__PURE__ */ v(`tr`,{children:[V&&/* @__PURE__ */ _(`td`,{className:Q.className,style:Q.style}),D&&/* @__PURE__ */ _(`td`,{className:$.className,style:$.style}),S.map((e,t)=>/* @__PURE__ */ _(`td`,{className:W(U+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+x(e.align)).className,style:Xt(U+t,void 0),children:e.footer?e.footer(C):null},e.key)),T&&/* @__PURE__ */ _(`td`,{})]})})]}),!w&&!C?.length&&/* @__PURE__ */ _(`div`,{className:`tbl-empty-block`,children:typeof Dn==`string`?/* @__PURE__ */ _(`div`,{className:`tbl-empty-plain`,children:Dn}):Dn})]}),Je(E)&&/* @__PURE__ */ _(l,{page:E.page,totalPages:E.totalPages,total:E.total,pageSize:E.pageSize,onPageChange:w?He:E.setPage,onPageSizeChange:w?He:E.setPageSize,pageSizes:E.pageSizes,mode:E.mode,summary:E.summary}),wn&&/* @__PURE__ */ _(`div`,{ref:Tn,className:`visually-hidden`,role:`status`,"aria-live":`polite`,"data-wui-table-status":``})]})}export{S as default};
@@ -1 +1 @@
1
- import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import n from"../lib/useElementEntry.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppInfoTip.js";import a from"./AppRequiredMark.js";import o from"./assertValidValue.js";import s from"./textOf.js";import c from"./useWuiControl.js";import l from"./warnUnknownProps.js";import{cloneElement as u,forwardRef as d,useId as f}from"react";import{jsx as p,jsxs as m}from"react/jsx-runtime";var h=[`sm`,`md`,`lg`],g=()=>import(`@webority/ui-elements/elements/datepicker`),_=d(function(d,_){let v=n(`wui-datepicker`,g),{marker:y,props:b}=r(`AppDatePicker`,d),{value:x,onChange:S,label:C,required:w=!1,optional:T=!1,optionalLabel:E=`(optional)`,helperText:D,error:O,name:k,min:A,max:j,placeholder:M=`Choose a date`,disabled:N,readOnly:P=!1,loading:F=!1,defaultValue:I,help:L,helpLabel:ee=`More information`,size:R,firstDay:z,displayFormat:B,id:V,ariaLabel:H,className:U=``,fieldClassName:W=``,...G}=b;l(`AppDatePicker`,G),o(`AppDatePicker`,`size`,R,h),typeof B==`string`&&B!==``&&/DD|YYYY|YY/.test(B)&&e(`[@webority/ui-react] <AppDatePicker> displayFormat "${B}" uses uppercase day or year tokens, which print as written; the tokens are yyyy, MMMM, MMM, MM, dd and d.`);let K=f(),q=V||K,{setRef:J}=c({ready:v,ref:_,value:x??(I===void 0?``:void 0),defaultValue:I,onChange:S}),Y=!C&&!O&&!D,X=O?`${q}-error`:void 0,Z=D?`${q}-hint`:void 0,Q=X||Z,$=/* @__PURE__ */ p(`wui-datepicker`,{ref:J,id:q,name:k,value:(x??I)||void 0,min:A,max:j,placeholder:M,size:R||void 0,"first-day":z==null?void 0:String(z),"display-format":B||void 0,"aria-label":H||s(C)||void 0,"aria-describedby":Q,"aria-invalid":O?`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 Y?u($,y):/* @__PURE__ */ m(`div`,{...y,className:`field${W?` ${W}`:``}`,children:[C&&/* @__PURE__ */ m(`label`,{className:`label`,htmlFor:q,children:[C,T&&!w&&/* @__PURE__ */ p(`span`,{className:`label-optional`,children:` ${E}`}),w&&/* @__PURE__ */ p(a,{}),L&&/* @__PURE__ */ p(i,{label:ee,children:L})]}),$,/* @__PURE__ */ p(t,{error:O,hint:D,errorId:X,hintId:Z})]})});export{_ as default};
1
+ import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import{useFieldError as ee}from"../lib/formFields.js";import n from"../lib/useElementEntry.js";import r from"../lib/useWuiText.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import te from"./AppInfoTip.js";import ne from"./AppRequiredMark.js";import a from"./assertValidValue.js";import o from"./textOf.js";import s from"./useWuiControl.js";import c from"./warnUnknownProps.js";import{cloneElement as l,forwardRef as u,useId as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{DATE_PICKER_TEXT as m}from"@webority/ui-elements/text";var h=[`sm`,`md`,`lg`,`xl`],g=()=>import(`@webority/ui-elements/elements/datepicker`),_=u(function(u,_){let re=n(`wui-datepicker`,g),v=r(`datePicker`,m),{marker:y,props:ie}=i(`AppDatePicker`,u),{value:b,onChange:x,label:S,required:C=!1,optional:w=!1,optionalLabel:T=v.optionalLabel,helperText:E,error:D,name:O,min:k,max:A,placeholder:j=v.placeholder,disabled:M,readOnly:N=!1,loading:P=!1,defaultValue:F,help:I,helpLabel:L=v.helpLabel,size:R,firstDay:z,displayFormat:B,id:V,ariaLabel:H,"aria-invalid":U,className:W=``,fieldClassName:G=``,...K}=ie,q=ee(O),J=D??q;c(`AppDatePicker`,K),a(`AppDatePicker`,`size`,R,h),typeof B==`string`&&B!==``&&/DD|YYYY|YY/.test(B)&&e(`[@webority/ui-react] <AppDatePicker> displayFormat "${B}" uses uppercase day or year tokens, which print as written; the tokens are yyyy, MMMM, MMM, MM, dd and d.`);let Y=d(),X=V||Y,{setRef:ae}=s({ready:re,ref:_,value:b??(F===void 0?``:void 0),defaultValue:F,onChange:x}),oe=!S&&!J&&!E,Z=J?`${X}-error`:void 0,Q=E?`${X}-hint`:void 0,se=Z||Q,$=/* @__PURE__ */ f(`wui-datepicker`,{ref:ae,id:X,name:O,value:(b??F)||void 0,min:k,max:A,placeholder:j,size:R||void 0,"first-day":z==null?void 0:String(z),"display-format":B||void 0,"aria-label":H||o(S)||void 0,"aria-describedby":se,"aria-invalid":U??(J?`true`:void 0),disabled:M?``:void 0,readonly:N?``:void 0,loading:P?``:void 0,required:C?``:void 0,className:W||void 0,...K});return oe?l($,y):/* @__PURE__ */ p(`div`,{...y,className:`field${G?` ${G}`:``}`,children:[S&&/* @__PURE__ */ p(`label`,{className:`label`,htmlFor:X,children:[S,w&&!C&&/* @__PURE__ */ f(`span`,{className:`label-optional`,children:` ${T}`}),C&&/* @__PURE__ */ f(ne,{}),I&&/* @__PURE__ */ f(te,{label:L,children:I})]}),$,/* @__PURE__ */ f(t,{error:J,hint:E,errorId:Z,hintId:Q})]})});export{_ as default};
@@ -1 +1 @@
1
- import e from"../lib/FieldMessage.js";import t from"../lib/useElementEntry.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import ee from"./AppInfoTip.js";import te from"./AppRequiredMark.js";import r from"./assertValidValue.js";import i from"./textOf.js";import a from"./useWuiControl.js";import o from"./warnUnknownProps.js";import{cloneElement as s,forwardRef as c,useEffect as ne,useId as re,useRef as ie}from"react";import{jsx as l,jsxs as u}from"react/jsx-runtime";var d=[`sm`,`md`,`lg`],f=()=>import(`@webority/ui-elements/elements/date-range`),p=e=>{if(e?.length)return e.every(e=>typeof e==`string`)?e.join(`,`):JSON.stringify(e)},m=c(function(c,m){let h=t(`wui-date-range`,f),{marker:g,props:_}=n(`AppDateRangePicker`,c),{start:v,end:y,defaultStart:b,defaultEnd:x,onChange:ae,label:S,help:C,helpLabel:w=`More information`,required:T=!1,optional:E=!1,optionalLabel:D=`(optional)`,helperText:O,error:k,startName:A,endName:j,min:M,max:N,placeholder:P=`Start to End`,disabled:F,readOnly:I=!1,loading:L=!1,size:R,firstDay:z,timeZone:oe,financialYearStart:B,presets:V,id:H,ariaLabel:U,className:W=``,fieldClassName:G=``,...K}=_;o(`AppDateRangePicker`,K),r(`AppDateRangePicker`,`size`,R,d);let q=re(),J=H||q,{setRef:se,innerRef:Y}=a({ready:h,ref:e=>{typeof m==`function`?m(e):m&&(m.current=e)},onChange:ae}),X=ie(!1);ne(()=>{if(!h)return;let e=Y.current;if(!e)return;let t=v===void 0?!X.current&&b!==void 0?b:e.value.start:v,n=y===void 0?!X.current&&x!==void 0?x:e.value.end:y;(e.value.start!==t||e.value.end!==n)&&(e.value={start:t,end:n}),X.current=!0},[h,v,y,b,x,Y]);let ce=!S&&!k&&!O,Z=k?`${J}-error`:void 0,Q=O?`${J}-hint`:void 0,le=Z||Q,$=/* @__PURE__ */ l(`wui-date-range`,{ref:se,id:J,"start-name":A,"end-name":j,min:M,max:N,placeholder:P,size:R||void 0,"first-day":z==null?void 0:String(z),"time-zone":oe||void 0,"financial-year-start":B==null?void 0:String(B),presets:p(V),"aria-label":U||i(S)||void 0,"aria-describedby":le,"aria-invalid":k?`true`:void 0,disabled:F?``:void 0,readonly:I?``:void 0,loading:L?``:void 0,required:T?``:void 0,className:W||void 0,...K});return ce?s($,g):/* @__PURE__ */ u(`div`,{...g,className:`field${G?` ${G}`:``}`,children:[S&&/* @__PURE__ */ u(`label`,{className:`label`,htmlFor:J,children:[S,E&&!T&&/* @__PURE__ */ l(`span`,{className:`label-optional`,children:` ${D}`}),T&&/* @__PURE__ */ l(te,{}),C&&/* @__PURE__ */ l(ee,{label:w,children:C})]}),$,/* @__PURE__ */ l(e,{error:k,hint:O,errorId:Z,hintId:Q})]})});export{m as default};
1
+ import e from"../lib/FieldMessage.js";import{useFieldError as t}from"../lib/formFields.js";import n from"../lib/useElementEntry.js";import ee from"../lib/useWuiText.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppInfoTip.js";import a from"./AppRequiredMark.js";import te from"./assertValidValue.js";import o from"./textOf.js";import s from"./useWuiControl.js";import c from"./warnUnknownProps.js";import{cloneElement as l,forwardRef as u,useEffect as d,useId as ne,useRef as f}from"react";import{jsx as p,jsxs as m}from"react/jsx-runtime";import{DATE_RANGE_PICKER_TEXT as re}from"@webority/ui-elements/text";var ie=[`sm`,`md`,`lg`,`xl`],ae=()=>import(`@webority/ui-elements/elements/date-range`),oe=e=>{if(e?.length)return e.every(e=>typeof e==`string`)?e.join(`,`):JSON.stringify(e)},h=u(function(u,h){let g=n(`wui-date-range`,ae),_=ee(`dateRangePicker`,re),{marker:v,props:se}=r(`AppDateRangePicker`,u),{start:y,end:b,defaultStart:x,defaultEnd:S,onChange:C,open:w,onOpenChange:T,label:E,help:D,helpLabel:ce=_.helpLabel,required:O=!1,optional:k=!1,optionalLabel:A=_.optionalLabel,helperText:j,error:M,startName:N,endName:P,min:F,max:I,placeholder:L=_.placeholder,disabled:R,readOnly:z=!1,loading:B=!1,size:V,firstDay:H,timeZone:le,financialYearStart:U,presets:W,id:ue,ariaLabel:de,className:fe=``,fieldClassName:G=``,...K}=se,pe=t(N),me=t(P),q=M??pe??me;c(`AppDateRangePicker`,K),te(`AppDateRangePicker`,`size`,V,ie);let he=ne(),J=ue||he,{setRef:ge,innerRef:Y}=s({ready:g,ref:e=>{typeof h==`function`?h(e):h&&(h.current=e)},onChange:C}),X=f(!1);d(()=>{if(!g)return;let e=Y.current;if(!e)return;let t=y===void 0?!X.current&&x!==void 0?x:e.value.start:y,n=b===void 0?!X.current&&S!==void 0?S:e.value.end:b;(e.value.start!==t||e.value.end!==n)&&(e.value={start:t,end:n}),X.current=!0},[g,y,b,x,S,Y]),d(()=>{if(!g||w===void 0)return;let e=Y.current;e&&e.open!==w&&(e.open=w)},[g,w,Y]),d(()=>{let e=Y.current;if(!g||!e||!T)return;let t=t=>{t instanceof CustomEvent&&t.target===e&&T(!!t.detail?.open)};return e.addEventListener(`wui-date-range:openchange`,t),()=>e.removeEventListener(`wui-date-range:openchange`,t)},[g,T,Y]);let _e=!E&&!q&&!j,Z=q?`${J}-error`:void 0,Q=j?`${J}-hint`:void 0,ve=Z||Q,$=/* @__PURE__ */ p(`wui-date-range`,{ref:ge,id:J,"start-name":N,"end-name":P,min:F,max:I,placeholder:L,size:V||void 0,"first-day":H==null?void 0:String(H),"time-zone":le||void 0,"financial-year-start":U==null?void 0:String(U),presets:oe(W),"aria-label":de||o(E)||void 0,"aria-describedby":ve,"aria-invalid":q?`true`:void 0,disabled:R?``:void 0,readonly:z?``:void 0,loading:B?``:void 0,required:O?``:void 0,className:fe||void 0,...K});return _e?l($,v):/* @__PURE__ */ m(`div`,{...v,className:`field${G?` ${G}`:``}`,children:[E&&/* @__PURE__ */ m(`label`,{className:`label`,htmlFor:J,children:[E,k&&!O&&/* @__PURE__ */ p(`span`,{className:`label-optional`,children:` ${A}`}),O&&/* @__PURE__ */ p(a,{}),D&&/* @__PURE__ */ p(i,{label:ce,children:D})]}),$,/* @__PURE__ */ p(e,{error:q,hint:j,errorId:Z,hintId:Q})]})});export{h as default};
@@ -1 +1 @@
1
- import{isEmpty as e}from"../lib/emptyValue.js";import{linkTarget as t}from"../lib/linkTarget.js";import{TargetLink as n}from"../lib/TargetLink.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./assertValidValue.js";import a from"./renderIconProp.js";import o from"./warnUnknownProps.js";import{jsx as s,jsxs as c}from"react/jsx-runtime";var l=[`sm`,`md`],u=[`grid`,`summary`,`list`],d=[1,2,3,4];function f(e,t){if(typeof e==`string`)return`${e}-${t}`;throw Error("<AppDescriptions> an item whose label is not text needs a `key`.")}function p(p){let{marker:m,props:h}=r(`AppDescriptions`,p),{items:g=[],columns:_=2,size:v=`md`,bordered:y=!1,layout:b=`grid`,title:x,linkComponent:S,className:C=``,...w}=h;o(`AppDescriptions`,w),i(`AppDescriptions`,`columns`,_,d),i(`AppDescriptions`,`size`,v,l),i(`AppDescriptions`,`layout`,b,u);let T=[`descs`,`descs-col-${_}`,v&&v!==`md`?`descs-${v}`:``,y?`descs-bordered`:``,b===`summary`?`wui-descs-summary`:``,b===`list`?`wui-descs-list`:``,_===4?`wui-descs-col-4`:``,C].filter(Boolean).join(` `)||void 0;return/* @__PURE__ */ c(`div`,{className:T,...m,...w,children:[x&&/* @__PURE__ */ s(`div`,{className:`descs-title`,children:x}),/* @__PURE__ */ s(`dl`,{className:`descs-list`,children:g.map((r,i)=>{let o=e(r.value),l=Math.min(12,Math.max(1,r.span??1)),u=r.key??f(r.label,i),d=o?`-`:r.value,p=t(S,{href:r.href});return/* @__PURE__ */ c(`div`,{className:`descs-item${r.emphasis?` wui-descs-emphasis`:``} wui-descs-span-${l}`,children:[r.icon&&/* @__PURE__ */ s(`span`,{className:`wui-descs-icon`,children:a(r.icon,{size:16})}),/* @__PURE__ */ s(`dt`,{className:`descs-label`,children:r.label}),/* @__PURE__ */ s(`dd`,{className:`descs-value${o?` is-empty`:``}${r.multiline&&!o?` wui-pre-line`:``}`,children:r.href?/* @__PURE__ */ s(n,{link:p,className:`wui-descs-link`,children:d}):d})]},u)})})]})}export{p as default};
1
+ import{emptyPlaceholder as e,isEmpty as t}from"../lib/emptyValue.js";import{linkTarget as n}from"../lib/linkTarget.js";import{TargetLink as r}from"../lib/TargetLink.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./assertValidValue.js";import o from"./renderIconProp.js";import s from"./warnUnknownProps.js";import{jsx as c,jsxs as l}from"react/jsx-runtime";var u=[`sm`,`md`],d=[`grid`,`summary`,`list`],f=[1,2,3,4];function p(e,t){if(typeof e==`string`)return`${e}-${t}`;throw Error("<AppDescriptions> an item whose label is not text needs a `key`.")}function m(m){let{marker:h,props:g}=i(`AppDescriptions`,m),{items:_=[],columns:v=2,size:y=`md`,bordered:b=!1,layout:x=`grid`,title:S,linkComponent:C,className:w=``,...T}=g;s(`AppDescriptions`,T),a(`AppDescriptions`,`columns`,v,f),a(`AppDescriptions`,`size`,y,u),a(`AppDescriptions`,`layout`,x,d);let E=[`descs`,`descs-col-${v}`,y&&y!==`md`?`descs-${y}`:``,b?`descs-bordered`:``,x===`summary`?`wui-descs-summary`:``,x===`list`?`wui-descs-list`:``,v===4?`wui-descs-col-4`:``,w].filter(Boolean).join(` `)||void 0;return/* @__PURE__ */ l(`div`,{className:E,...h,...T,children:[S&&/* @__PURE__ */ c(`div`,{className:`descs-title`,children:S}),/* @__PURE__ */ c(`dl`,{className:`descs-list`,children:_.map((i,a)=>{let s=t(i.value),u=Math.min(12,Math.max(1,i.span??1)),d=i.key??p(i.label,a),f=s?e():i.value,m=n(C,{href:i.href}),h=Object.fromEntries(Object.entries(i).filter(([e])=>e.startsWith(`data-`)));return/* @__PURE__ */ l(`div`,{className:`descs-item${i.emphasis?` wui-descs-emphasis`:``} wui-descs-span-${u}`,id:i.id,tabIndex:i.tabIndex,...h,children:[i.icon&&/* @__PURE__ */ c(`span`,{className:`wui-descs-icon`,children:o(i.icon,{size:16})}),/* @__PURE__ */ c(`dt`,{className:`descs-label`,children:i.label}),/* @__PURE__ */ c(`dd`,{className:`descs-value${s?` is-empty`:``}${i.multiline&&!s?` wui-pre-line`:``}`,children:i.href?/* @__PURE__ */ c(r,{link:m,className:`wui-descs-link`,children:f}):f})]},d)})})]})}export{m as default};
@@ -1 +1 @@
1
- import e from"../lib/DiscardPrompt.js";import t from"../lib/useElementEntry.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppIcon.js";import i from"./assertValidValue.js";import a from"./warnUnknownProps.js";import{useEffect as o,useId as s,useRef as c,useState as l}from"react";import{jsx as u,jsxs as d}from"react/jsx-runtime";var f=[`end`,`start`],p=[`sm`,`md`,`lg`,`xl`],m=[50,90],h=()=>import(`@webority/ui-elements/elements/drawer`),g=e=>Array.isArray(e)&&e.length>0&&e.every(e=>Number.isFinite(e)&&e>=10&&e<=100);function _(_){t(`wui-drawer`,h);let{marker:ee,props:te}=n(`AppDrawer`,_),{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=m,defaultSnap:A=0,sheet:j=!0,onSnapChange:M,onOpened:N,onClosed:ne,dismissible:P=!0,closeLabel:F=`Close`,sheetHeightLabel:I=`Sheet height`,staticBackdrop:L=!0,confirmDiscard:R,dirty:z=!1,headerClassName:B=``,bodyClassName:V=``,footer:H,className:U=``,style:W,children:G,...K}=te;a(`AppDrawer`,K),i(`AppDrawer`,`side`,T,f),i(`AppDrawer`,`size`,E,p),i(`AppDrawer`,`snapPoints`,g(k)?void 0:JSON.stringify(k),[`an array of numbers from 10 to 100`]);let q=s(),J=b!=null&&b!==!1&&b!==``,Y=c(null),X=c({dirty:!1}),Z=c(null),[Q,$]=l(!1);X.current={onClose:y,onSnapChange:M,onOpened:N,onClosed:ne,confirmDiscard:R,dirty:z},o(()=>{v||$(!1)},[v]),o(()=>{Q&&Z.current?.focus()},[Q]),o(()=>{let e=Y.current;if(!e)return;let t=t=>{t.target===e&&(t.preventDefault(),X.current.confirmDiscard&&X.current.dirty?$(!0):X.current.onClose?.())},n=t=>{if(t.target===e){if(!(t instanceof CustomEvent))throw TypeError(`<wui-drawer> snap arrived without its index and percent.`);X.current.onSnapChange?.(t.detail.index,t.detail.percent)}},r=t=>{t.target===e&&X.current.onOpened?.()},i=t=>{t.target===e&&X.current.onClosed?.()};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.removeEventListener(`wui-drawer-close`,t),e.removeEventListener(`wui-drawer-snap`,n),e.removeEventListener(`wui-drawer-opened`,r),e.removeEventListener(`wui-drawer-closed`,i)}},[]);let re=()=>{$(!1),Y.current?.dispatchEvent(new CustomEvent(`wui:drawer:discard`,{bubbles:!0})),X.current.onClose?.()},ie=g(k)?k:m,ae={...D&&{"--wui-drawer-width":D},...O&&{"--wui-drawer-max-width":O},...W};return/* @__PURE__ */ u(`wui-drawer`,{ref:Y,...ee,...K,class:[`wui-drawer`,U].filter(Boolean).join(` `),side:T,size:E,"snap-points":ie.join(`,`),"default-snap":String(A),static:L?``:void 0,"no-sheet":j?void 0:``,"no-dismiss":P?void 0:``,"confirm-discard":R||void 0,open:v?``:void 0,style:ae,children:/* @__PURE__ */ d(`dialog`,{className:`wui-drawer-panel`,"aria-label":w||void 0,"aria-labelledby":!w&&J&&S===void 0?q:void 0,children:[j&&/* @__PURE__ */ u(`div`,{className:`wui-drawer-grip`,"data-wui-drawer-grip":``,children:/* @__PURE__ */ u(`div`,{className:`wui-drawer-handle`,role:`slider`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":I})}),S===void 0?/* @__PURE__ */ d(`div`,{className:[`wui-drawer-header`,B].filter(Boolean).join(` `),"data-wui-drawer-grip":j?``:void 0,children:[/* @__PURE__ */ d(`div`,{className:`wui-drawer-headtext`,children:[J&&/* @__PURE__ */ d(`div`,{className:`wui-drawer-title`,id:q,children:[x&&/* @__PURE__ */ u(`span`,{className:`wui-drawer-title-ic`,children:/* @__PURE__ */ u(r,{name:x,size:18})}),b]}),C&&/* @__PURE__ */ u(`div`,{className:`wui-drawer-subtitle`,children:C})]}),P&&/* @__PURE__ */ u(`button`,{type:`button`,className:`wui-drawer-close`,"data-wui-dismiss":``,"aria-label":F,children:/* @__PURE__ */ u(`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__ */ u(`path`,{d:`M18 6 6 18M6 6l12 12`})})})]}):S,/* @__PURE__ */ u(`div`,{className:[`wui-drawer-body`,V].filter(Boolean).join(` `),children:G}),(H||Q)&&/* @__PURE__ */ d(`div`,{className:Q?`wui-drawer-footer wui-drawer-discarding`:`wui-drawer-footer`,children:[Q&&/* @__PURE__ */ u(e,{text:R,confirmRef:Z,onDiscard:re,onKeep:()=>$(!1)}),H]})]})})}export{_ as default};
1
+ import e from"../lib/DiscardPrompt.js";import t from"../lib/useElementEntry.js";import n from"../lib/useWuiText.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppIcon.js";import a from"./assertValidValue.js";import o from"./warnUnknownProps.js";import{useEffect as s,useId as c,useRef as l,useState as u}from"react";import{jsx as d,jsxs as f}from"react/jsx-runtime";import{DRAWER_TEXT as p}from"@webority/ui-elements/text";var ee=[`end`,`start`],te=[`sm`,`md`,`lg`,`xl`],m=[50,90],ne=()=>import(`@webority/ui-elements/elements/drawer`),h=e=>Array.isArray(e)&&e.length>0&&e.every(e=>Number.isFinite(e)&&e>=10&&e<=100);function g(g){t(`wui-drawer`,ne);let _=n(`drawer`,p),{marker:v,props:y}=r(`AppDrawer`,g),{open:b=!1,onClose:x,title:S,titleIcon:C,header:w,subtitle:T,ariaLabel:E,side:D=`end`,size:O=`md`,width:k,maxWidth:A,snapPoints:j=m,defaultSnap:re=0,sheet:M=!0,onSnapChange:ie,onOpened:ae,onClosed:N,dismissible:P=!0,closeLabel:F=_.closeLabel,sheetHeightLabel:I=_.sheetHeightLabel,staticBackdrop:L=!0,confirmDiscard:R,dirty:z=!1,headerClassName:B=``,bodyClassName:V=``,footer:H,className:U=``,style:W,children:G,...K}=y;o(`AppDrawer`,K),a(`AppDrawer`,`side`,D,ee),a(`AppDrawer`,`size`,O,te),a(`AppDrawer`,`snapPoints`,h(j)?void 0:JSON.stringify(j),[`an array of numbers from 10 to 100`]);let q=c(),J=S!=null&&S!==!1&&S!==``,Y=l(null),X=l({dirty:!1}),Z=l(null),[Q,$]=u(!1);X.current={onClose:x,onSnapChange:ie,onOpened:ae,onClosed:N,confirmDiscard:R,dirty:z},s(()=>{b||$(!1)},[b]),s(()=>{Q&&Z.current?.focus()},[Q]),s(()=>{let e=Y.current;if(!e)return;let t=t=>{t.target===e&&(t.preventDefault(),X.current.confirmDiscard&&X.current.dirty?$(!0):X.current.onClose?.())},n=t=>{if(t.target===e){if(!(t instanceof CustomEvent))throw TypeError(`<wui-drawer> snap arrived without its index and percent.`);X.current.onSnapChange?.(t.detail.index,t.detail.percent)}},r=t=>{t.target===e&&X.current.onOpened?.()},i=t=>{t.target===e&&X.current.onClosed?.()};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.removeEventListener(`wui-drawer-close`,t),e.removeEventListener(`wui-drawer-snap`,n),e.removeEventListener(`wui-drawer-opened`,r),e.removeEventListener(`wui-drawer-closed`,i)}},[]);let oe=()=>{$(!1),Y.current?.dispatchEvent(new CustomEvent(`wui:drawer:discard`,{bubbles:!0})),X.current.onClose?.()},se=h(j)?j:m,ce={...k&&{"--wui-drawer-width":k},...A&&{"--wui-drawer-max-width":A},...W};return/* @__PURE__ */ d(`wui-drawer`,{ref:Y,...v,...K,class:[`wui-drawer`,U].filter(Boolean).join(` `),side:D,size:O,"snap-points":se.join(`,`),"default-snap":String(re),static:L?``:void 0,"no-sheet":M?void 0:``,"no-dismiss":P?void 0:``,"confirm-discard":R||void 0,open:b?``:void 0,style:ce,children:/* @__PURE__ */ f(`dialog`,{className:`wui-drawer-panel`,"aria-label":E||void 0,"aria-labelledby":!E&&J&&w===void 0?q:void 0,children:[M&&/* @__PURE__ */ d(`div`,{className:`wui-drawer-grip`,"data-wui-drawer-grip":``,children:/* @__PURE__ */ d(`div`,{className:`wui-drawer-handle`,role:`slider`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":I})}),w===void 0?/* @__PURE__ */ f(`div`,{className:[`wui-drawer-header`,B].filter(Boolean).join(` `),"data-wui-drawer-grip":M?``:void 0,children:[/* @__PURE__ */ f(`div`,{className:`wui-drawer-headtext`,children:[J&&/* @__PURE__ */ f(`div`,{className:`wui-drawer-title`,id:q,children:[C&&/* @__PURE__ */ d(`span`,{className:`wui-drawer-title-ic`,children:/* @__PURE__ */ d(i,{name:C,size:18})}),S]}),T&&/* @__PURE__ */ d(`div`,{className:`wui-drawer-subtitle`,children:T})]}),P&&/* @__PURE__ */ d(`button`,{type:`button`,className:`wui-drawer-close`,"data-wui-dismiss":``,"aria-label":F,children:/* @__PURE__ */ d(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:/* @__PURE__ */ d(`path`,{d:`M18 6 6 18M6 6l12 12`})})})]}):w,/* @__PURE__ */ d(`div`,{className:[`wui-drawer-body`,V].filter(Boolean).join(` `),children:G}),(H||Q)&&/* @__PURE__ */ f(`div`,{className:Q?`wui-drawer-footer wui-drawer-discarding`:`wui-drawer-footer`,children:[Q&&/* @__PURE__ */ d(e,{text:R,confirmRef:Z,onDiscard:oe,onKeep:()=>$(!1)}),H]})]})})}export{g as default};
@@ -1 +1 @@
1
- import e from"../lib/FieldMessage.js";import t from"../lib/fillLabel.js";import n from"../lib/useFileDrop.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./AppIcon.js";import a from"./warnUnknownProps.js";import{DEFAULT_MAX_SIZE_MB as o,acceptDroppedFiles as s,acceptLabel as c}from"@webority/ui-elements/helpers";import{useId as l,useState as u}from"react";import{jsx as d,jsxs as f}from"react/jsx-runtime";function p(p){let{marker:m,props:h}=r(`AppDropZone`,p),{label:g,id:_,onChange:v,multiple:y=!1,accept:b=``,maxSizeMb:x=o,error:S,helperText:C,disabled:w=!1,className:T=``,fieldClassName:E=``,style:D,browseLabel:O=`Click to upload`,dropLabel:k=`or drag & drop`,anyTypeText:A=`Any file type`,maxSizeText:j=`up to {size} MB`,...M}=h;a(`AppDropZone`,M);let[N,P]=u(``),F=l(),I=_||F,L=S||N,R=L?`${I}-error`:void 0,z=C&&!L?`${I}-hint`:void 0,B=R||z,V=b?c(b):A,H={accept:b,maxSizeMb:x,multiple:y},U=e=>{P(``);let[t]=e;p.multiple?p.onChange(e):t&&p.onChange(t)},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);if(!t.length&&!n.length)return;t.length&&U(t);let[r]=n;r&&W(r)};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
+ import e from"../lib/FieldMessage.js";import{useFieldError as t}from"../lib/formFields.js";import n from"../lib/useFileDrop.js";import r from"../lib/useWuiText.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./AppIcon.js";import o from"./warnUnknownProps.js";import{DEFAULT_MAX_SIZE_MB as s,acceptDroppedFiles as c,acceptLabel as l}from"@webority/ui-elements/helpers";import{useId as u,useState as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{DROP_ZONE_TEXT as m,fillText as h}from"@webority/ui-elements/text";function g(g){let{marker:_,props:v}=i(`AppDropZone`,g),y=r(`dropZone`,m),{label:b,name:x,id:S,onChange:ee,multiple:C=!1,accept:w=``,maxSizeMb:T=s,error:E,helperText:D,disabled:O=!1,className:k=``,fieldClassName:A=``,style:j,browseLabel:M=y.browseLabel,dropLabel:N=y.dropLabel,anyTypeText:P=y.anyTypeText,maxSizeText:F=y.maxSizeText,...I}=v;o(`AppDropZone`,I);let L=t(x),R=E??L,[z,B]=d(``),V=u(),H=S||V,U=R||z,W=U?`${H}-error`:void 0,G=D&&!U?`${H}-hint`:void 0,K=W||G,q=w?l(w):P,J={accept:w,maxSizeMb:T,multiple:C},Y=e=>{B(``);let[t]=e;g.multiple?g.onChange(e):t&&g.onChange(t)},X=e=>B(e.message),{dragOver:Z,dropProps:Q}=n({...J,disabled:O,onFiles:Y,onReject:X}),$=e=>{let{files:t,rejections:n}=c(e,J);if(!t.length&&!n.length)return;t.length&&Y(t);let[r]=n;r&&X(r)};return/* @__PURE__ */ p(`div`,{..._,className:`field${A?` ${A}`:``}`,children:[b?/* @__PURE__ */ f(`label`,{className:`label`,htmlFor:H,children:b}):null,/* @__PURE__ */ p(`div`,{className:`file-input file-input-tall${Z?` dragging`:``}${U?` error`:``}${k?` ${k}`:``}`,style:j,"aria-disabled":O||void 0,...Q,children:[/* @__PURE__ */ p(`label`,{htmlFor:H,className:`file-input-zone-label`,children:[/* @__PURE__ */ f(`span`,{className:`file-input-icon`,children:/* @__PURE__ */ f(a,{name:`upload`,size:24})}),/* @__PURE__ */ p(`span`,{className:`file-input-title`,children:[/* @__PURE__ */ f(`span`,{className:`browse`,children:M}),` ${N}`]}),/* @__PURE__ */ f(`span`,{className:`file-input-text`,children:T>0?`${q}, ${h(F,{size:T})}`:q})]}),/* @__PURE__ */ f(`input`,{id:H,type:`file`,"aria-describedby":K,name:x,accept:w,multiple:C||void 0,disabled:O||void 0,className:`visually-hidden`,onClick:e=>{e.currentTarget.value=``},onChange:e=>$(e.target.files),...I})]}),/* @__PURE__ */ f(e,{error:U,hint:D,errorId:W,hintId:G})]})}export{g as default};
@@ -1 +1 @@
1
- import{devWarn as e}from"../lib/devWarn.js";import{linkTarget as t}from"../lib/linkTarget.js";import{shortcutAria as n,shortcutChip as ee}from"../lib/shortcutChip.js";import{TargetLink as r}from"../lib/TargetLink.js";import i from"../lib/useElementEntry.js";import{TONES as a}from"../lib/vocabulary.js";import{splitMarkerProps as o}from"../lib/wuiMarker.js";import s from"./AppIcon.js";import c from"./assertValidValue.js";import l from"./renderIconProp.js";import te from"./warnUnknownProps.js";import ne from"./withTooltip.js";import{Fragment as re,useEffect as u,useId as d,useRef as f,useState as p}from"react";import{Fragment as m,jsx as h,jsxs as g}from"react/jsx-runtime";var _=[`sm`,`md`,`lg`,`xl`],v=[`neutral`],y=[`sm`,`md`,`lg`,`fit`],ie=()=>import(`@webority/ui-elements/elements/dropdown`),b=e=>e.description?/* @__PURE__ */ g(`span`,{className:`wui-dropdown-item-body`,children:[/* @__PURE__ */ h(`span`,{className:`wui-dropdown-item-label`,children:e.label}),/* @__PURE__ */ h(`span`,{className:`wui-dropdown-item-desc`,children:e.description})]}):e.label,x=!1;function S(){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!x&&(x=!0,e("[@webority/ui-react] <AppDropdown> icon-only toggle has no accessible name — pass `label` or `ariaLabel`."))}function C(x){i(`wui-dropdown`,ie);let{marker:C,props:ae}=o(`AppDropdown`,x),{icon:oe,iconSize:se,toggleClassName:ce,toggleVariant:w,menuWidth:T,label:E,ariaLabel:D,align:O=`end`,items:k=[],menuClassName:A=``,linkComponent:j,children:M,trigger:N,open:P,onOpenChange:le,searchable:F,searchPlaceholder:I,noMatchText:L,...R}=ae;if(te(`AppDropdown`,R),F&&M!=null)throw Error(`<AppDropdown> searchable filters items, so it takes items and no children.`);if(!F&&(I!==void 0||L!==void 0))throw Error(`<AppDropdown> searchPlaceholder and noMatchText need searchable.`);for(let e of k)if(c(`AppDropdown`,`items[].hiddenFrom`,e.hiddenFrom,_),c(`AppDropdown`,`items[].tone`,e.tone,a),F&&e.label!=null&&typeof e.label!=`string`)throw RangeError(`<AppDropdown> searchable filters rows by their text, so every item label must be a string.`);N||D||E||S(),c(`AppDropdown`,`toggleVariant`,w,v),c(`AppDropdown`,`menuWidth`,T,y),w&&!N&&e(`AppDropdown: toggleVariant needs a trigger; the icon toggle ignores it.`);let z=(ce??(N?`wui-dropdown-trigger`:`topbar-icon-btn`))+(N&&w===`neutral`?` wui-dropdown-trigger-neutral`:``),B=[`dropdown-menu`,O===`end`?`dropdown-menu-end`:``,T&&y.includes(T)?`wui-dropdown-menu-${T}`:``,F?`wui-dropdown-menu-searchable`:``,A].filter(Boolean).join(` `),[V,H]=p(``),U=f(null),W=I??`Search`,G=L??`No matches.`,K=V.trim().toLowerCase(),q=K?k.filter(e=>!e.divider&&e.header==null&&(typeof e.label==`string`?e.label:``).toLowerCase().includes(K)):k,J=oe??(N?void 0:`more-horizontal`),Y=d(),X=P!==void 0,[ue,de]=p(!1),Z=X?!!P:ue,Q=f(null);Q.current=(e,t)=>{X||de(e),le?.(e,t)};let $=f(null);return u(()=>{let e=$.current;if(!e)return;let t=t=>{if(t.target===e){if(!(t instanceof CustomEvent))throw TypeError(`<wui-dropdown> toggle arrived without its detail.`);t.preventDefault(),Q.current?.(t.detail.open,{source:t.detail.source})}};return e.addEventListener(`wui-dropdown-toggle`,t),()=>e.removeEventListener(`wui-dropdown-toggle`,t)},[]),u(()=>{F&&Z&&U.current?.focus(),Z||H(``)},[Z,F]),u(()=>{let e=U.current;if(!F||!e)return;let t=t=>{if(t.key===`ArrowDown`||t.key===`ArrowUp`){t.preventDefault(),t.stopPropagation();let n=Array.from(e.closest(`.dropdown-menu`)?.querySelectorAll(`.dropdown-item`)??[]);(t.key===`ArrowDown`?n[0]:n[n.length-1])?.focus()}else t.key!==`Tab`&&t.key!==`Escape`&&t.stopPropagation()};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[F]),/* @__PURE__ */ g(`wui-dropdown`,{...C,...R,ref:$,class:[`dropdown`,R.className].filter(Boolean).join(` `),align:O,open:Z?``:void 0,children:[/* @__PURE__ */ h(`button`,{type:`button`,id:Y,"data-wui-dropdown-trigger":!0,"aria-expanded":Z?`true`:`false`,className:z,title:E,"aria-label":D??(N?void 0:E),children:N??(J===void 0?null:/* @__PURE__ */ h(s,{name:J,size:se??20}))}),/* @__PURE__ */ g(`div`,{className:B,"aria-labelledby":Y,"data-wui-dropdown-menu":!0,popover:`auto`,children:[F?/* @__PURE__ */ g(`div`,{className:`wui-dropdown-search`,children:[/* @__PURE__ */ h(s,{name:`search`,size:14}),/* @__PURE__ */ h(`input`,{ref:U,type:`search`,className:`wui-dropdown-search-input`,autoComplete:`off`,placeholder:W,"aria-label":W,value:V,onChange:e=>H(e.target.value)})]}):null,M??q.map(e=>{if(e.to&&e.href)throw RangeError(`AppDropdown: an item takes to or href, not both.`);if(e.header!=null)return/* @__PURE__ */ h(`div`,{className:`dropdown-header`,children:e.header},e.key);if(e.divider)return/* @__PURE__ */ h(`hr`,{className:`dropdown-divider`},e.key);if(e.disabled)return/* @__PURE__ */ h(re,{children:ne(/* @__PURE__ */ g(`button`,{type:`button`,className:[`dropdown-item`,e.tone===`danger`&&`danger`,`wui-dropdown-item-disabled`].filter(Boolean).join(` `),"aria-disabled":`true`,children:[e.image?/* @__PURE__ */ h(`img`,{src:e.image,alt:``}):l(e.icon,{size:16}),b(e),e.disabledReason&&/* @__PURE__ */ g(`span`,{className:`visually-hidden wui-dropdown-item-reason`,children:[`: `,e.disabledReason]})]}),e.disabledReason,`auto`)},e.key);let i=[`dropdown-item`,e.tone===`danger`&&`danger`,e.hiddenFrom&&_.includes(e.hiddenFrom)&&`wui-hidden-from-${e.hiddenFrom}`].filter(Boolean).join(` `)||void 0,a=/* @__PURE__ */ g(m,{children:[e.image?/* @__PURE__ */ h(`img`,{src:e.image,alt:``}):l(e.icon,{size:16}),b(e),ee(e.shortcut)]}),o={className:i,onClick:e.onClick,"aria-keyshortcuts":n(e.shortcut)};return e.to?/* @__PURE__ */ h(r,{link:t(j,{to:e.to}),...o,children:a},e.key):e.href?/* @__PURE__ */ h(r,{link:t(j,{href:e.href,external:!0}),...o,children:a},e.key):/* @__PURE__ */ h(`button`,{type:`button`,...o,children:a},e.key)}),F&&K&&q.length===0?/* @__PURE__ */ h(`div`,{className:`wui-dropdown-empty`,role:`status`,children:G}):null]})]})}export{C as default};
1
+ import{devWarn as e}from"../lib/devWarn.js";import{linkTarget as t}from"../lib/linkTarget.js";import{shortcutAria as n,shortcutChip as ee}from"../lib/shortcutChip.js";import{TargetLink as r}from"../lib/TargetLink.js";import i from"../lib/useElementEntry.js";import a from"../lib/useWuiText.js";import{TONES as o}from"../lib/vocabulary.js";import{splitMarkerProps as te}from"../lib/wuiMarker.js";import s from"./AppIcon.js";import c from"./assertValidValue.js";import l from"./renderIconProp.js";import ne from"./warnUnknownProps.js";import re from"./withTooltip.js";import{Fragment as ie,useEffect as u,useId as ae,useRef as d,useState as f}from"react";import{Fragment as oe,jsx as p,jsxs as m}from"react/jsx-runtime";import{DROPDOWN_TEXT as h}from"@webority/ui-elements/text";var g=[`sm`,`md`,`lg`,`xl`],se=[`neutral`],_=[`sm`,`md`,`lg`,`fit`],ce=[`_blank`,`_self`],le=/^data-[a-z0-9]+(?:-[a-z0-9]+)*$/,ue=()=>import(`@webority/ui-elements/elements/dropdown`),v=e=>e.description?/* @__PURE__ */ m(`span`,{className:`wui-dropdown-item-body`,children:[/* @__PURE__ */ p(`span`,{className:`wui-dropdown-item-label`,children:e.label}),/* @__PURE__ */ p(`span`,{className:`wui-dropdown-item-desc`,children:e.description})]}):e.label,y=!1;function de(){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!y&&(y=!0,e("[@webority/ui-react] <AppDropdown> icon-only toggle has no accessible name — pass `label` or `ariaLabel`."))}function b(y){i(`wui-dropdown`,ue);let b=a(`dropdown`,h),{marker:x,props:S}=te(`AppDropdown`,y),{icon:C,iconSize:w,toggleClassName:T,toggleVariant:E,menuWidth:D,label:O,ariaLabel:k,align:A=`end`,items:j=[],menuClassName:M=``,linkComponent:N,children:P,trigger:F,open:I,onOpenChange:L,searchable:R,searchPlaceholder:z,noMatchText:B,...V}=S;if(ne(`AppDropdown`,V),R&&P!=null)throw Error(`<AppDropdown> searchable filters items, so it takes items and no children.`);if(!R&&(z!==void 0||B!==void 0))throw Error(`<AppDropdown> searchPlaceholder and noMatchText need searchable.`);for(let e of j){if(c(`AppDropdown`,`items[].hiddenFrom`,e.hiddenFrom,g),c(`AppDropdown`,`items[].tone`,e.tone,o),c(`AppDropdown`,`items[].target`,e.target,ce),(e.target||e.rel)&&!e.href&&!e.to)throw RangeError(`<AppDropdown> item "${e.key}" takes target and rel only with href or to.`);for(let t of Object.keys(e.data??{}))if(!le.test(t))throw RangeError(`<AppDropdown> item "${e.key}" has a data key "${t}" that is not data-<name> in lowercase.`);if(R&&e.label!=null&&typeof e.label!=`string`)throw RangeError(`<AppDropdown> searchable filters rows by their text, so every item label must be a string.`)}F||k||O||de(),c(`AppDropdown`,`toggleVariant`,E,se),c(`AppDropdown`,`menuWidth`,D,_),E&&!F&&e(`AppDropdown: toggleVariant needs a trigger; the icon toggle ignores it.`);let fe=(T??(F?`wui-dropdown-trigger`:`topbar-icon-btn`))+(F&&E===`neutral`?` wui-dropdown-trigger-neutral`:``),pe=[`dropdown-menu`,A===`end`?`dropdown-menu-end`:``,D&&_.includes(D)?`wui-dropdown-menu-${D}`:``,R?`wui-dropdown-menu-searchable`:``,M].filter(Boolean).join(` `),[H,U]=f(``),W=d(null),G=z??b.searchPlaceholder,me=B??b.noMatchText,K=H.trim().toLowerCase(),q=K?j.filter(e=>!e.divider&&e.header==null&&(typeof e.label==`string`?e.label:``).toLowerCase().includes(K)):j,J=C??(F?void 0:`more-horizontal`),Y=ae(),X=I!==void 0,[he,ge]=f(!1),Z=X?!!I:he,Q=d(null);Q.current=(e,t)=>{X||ge(e),L?.(e,t)};let $=d(null);return u(()=>{let e=$.current;if(!e)return;let t=t=>{if(t.target===e){if(!(t instanceof CustomEvent))throw TypeError(`<wui-dropdown> toggle arrived without its detail.`);t.preventDefault(),Q.current?.(t.detail.open,{source:t.detail.source})}};return e.addEventListener(`wui-dropdown-toggle`,t),()=>e.removeEventListener(`wui-dropdown-toggle`,t)},[]),u(()=>{R&&Z&&W.current?.focus(),Z||U(``)},[Z,R]),u(()=>{let e=W.current;if(!R||!e)return;let t=t=>{if(t.key===`ArrowDown`||t.key===`ArrowUp`){t.preventDefault(),t.stopPropagation();let n=Array.from(e.closest(`.dropdown-menu`)?.querySelectorAll(`.dropdown-item`)??[]);(t.key===`ArrowDown`?n[0]:n[n.length-1])?.focus()}else t.key!==`Tab`&&t.key!==`Escape`&&t.stopPropagation()};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[R]),/* @__PURE__ */ m(`wui-dropdown`,{...x,...V,ref:$,class:[`dropdown`,V.className].filter(Boolean).join(` `),align:A,open:Z?``:void 0,children:[/* @__PURE__ */ p(`button`,{type:`button`,id:Y,"data-wui-dropdown-trigger":!0,"aria-expanded":Z?`true`:`false`,className:fe,title:O,"aria-label":k??(F?void 0:O),children:F??(J===void 0?null:/* @__PURE__ */ p(s,{name:J,size:w??20}))}),/* @__PURE__ */ m(`div`,{className:pe,"aria-labelledby":Y,"data-wui-dropdown-menu":!0,popover:`auto`,children:[R?/* @__PURE__ */ m(`div`,{className:`wui-dropdown-search`,children:[/* @__PURE__ */ p(s,{name:`search`,size:14}),/* @__PURE__ */ p(`input`,{ref:W,type:`search`,className:`wui-dropdown-search-input`,autoComplete:`off`,placeholder:G,"aria-label":G,value:H,onChange:e=>U(e.target.value)})]}):null,P??q.map(e=>{if(e.to&&e.href)throw RangeError(`AppDropdown: an item takes to or href, not both.`);if(e.header!=null)return/* @__PURE__ */ p(`div`,{className:`dropdown-header`,children:e.header},e.key);if(e.divider)return/* @__PURE__ */ p(`hr`,{className:`dropdown-divider`},e.key);if(e.disabled)return/* @__PURE__ */ p(ie,{children:re(/* @__PURE__ */ m(`button`,{type:`button`,className:[`dropdown-item`,e.tone===`danger`&&`danger`,`wui-dropdown-item-disabled`,e.hiddenFrom&&g.includes(e.hiddenFrom)&&`wui-hidden-from-${e.hiddenFrom}`].filter(Boolean).join(` `),"aria-disabled":`true`,...e.data,children:[e.image?/* @__PURE__ */ p(`img`,{src:e.image,alt:``}):l(e.icon,{size:16}),v(e),e.disabledReason&&/* @__PURE__ */ m(`span`,{className:`visually-hidden wui-dropdown-item-reason`,children:[`: `,e.disabledReason]})]}),e.disabledReason,`auto`)},e.key);let i=[`dropdown-item`,e.tone===`danger`&&`danger`,e.hiddenFrom&&g.includes(e.hiddenFrom)&&`wui-hidden-from-${e.hiddenFrom}`].filter(Boolean).join(` `)||void 0,a=/* @__PURE__ */ m(oe,{children:[e.image?/* @__PURE__ */ p(`img`,{src:e.image,alt:``}):l(e.icon,{size:16}),v(e),ee(e.shortcut)]}),o={className:i,onClick:e.onClick,"aria-keyshortcuts":n(e.shortcut),...e.data};return e.to?/* @__PURE__ */ p(r,{link:t(N,{to:e.to}),target:e.target,rel:e.rel,...o,children:a},e.key):e.href?/* @__PURE__ */ p(r,{link:t(N,{href:e.href,external:!0}),target:e.target,rel:e.rel,...o,children:a},e.key):/* @__PURE__ */ p(`button`,{type:`button`,...o,children:a},e.key)}),R&&K&&q.length===0?/* @__PURE__ */ p(`div`,{className:`wui-dropdown-empty`,role:`status`,children:me}):null]})]})}export{b as default};
@@ -1 +1 @@
1
- import e from"../lib/fillLabel.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./AppIcon.js";import r from"./assertValidValue.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)=>n===0?r.dueTodayLabel:t===`due`?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 y!==void 0&&Number.isFinite(y)&&I>=0&&I<=y?/* @__PURE__ */ c(`wui-due-date`,{class:m(`wui-due-date`,`wui-due-date-warning`,j),...g,...M,children:[L,/* @__PURE__ */ s(`time`,{dateTime:F,children:h(b,I,{dueTodayLabel:T,dueTomorrowLabel:E,dueInLabel:D,daysLeftLabel:O,oneDayLeftLabel:k})})]}):/* @__PURE__ */ c(`wui-due-date`,{class:m(`wui-due-date`,j),...g,...M,children:[L,/* @__PURE__ */ s(`time`,{dateTime:F,children:a(N)})]})}export{g as default};
1
+ import e from"../lib/useWuiText.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./AppIcon.js";import r from"./assertValidValue.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";import{DUE_DATE_TEXT as l,fillText as u}from"@webority/ui-elements/text";var d=864e5,f=198e5,p=14,m=[`days`,`due`],h=e=>Math.floor((e+f)/d),g=(...e)=>e.filter(Boolean).join(` `),_=(e,t,n)=>t===0?n.dueTodayLabel:e===`due`?t===1?n.dueTomorrowLabel:u(n.dueInLabel,{days:t}):t===1?n.oneDayLeftLabel:u(n.daysLeftLabel,{days:t});function v(f){let{marker:v,props:y}=t(`AppDueDate`,f),b=e(`dueDate`,l),{date:x,soonDays:S,soonWording:C=`days`,icon:w=!1,overdue:T=!1,overdueLabel:E,notSetLabel:D=b.notSetLabel,dueTodayLabel:O=b.dueTodayLabel,dueTomorrowLabel:k=b.dueTomorrowLabel,dueInLabel:A=b.dueInLabel,daysLeftLabel:j=b.daysLeftLabel,oneDayLeftLabel:M=b.oneDayLeftLabel,overdueSinceLabel:N=b.overdueSinceLabel,className:P=``,...F}=y;i(`AppDueDate`,F),r(`AppDueDate`,`soonWording`,C,m);let I=o(x);if(!Number.isFinite(I))return/* @__PURE__ */ s(`wui-due-date`,{class:g(`wui-due-date`,`wui-due-date-empty`,P),...v,...F,children:/* @__PURE__ */ s(`time`,{children:D})});let L=h(I),R=(/* @__PURE__ */ new Date(L*d)).toISOString().slice(0,10),z=L-h(Date.now()),B=w?/* @__PURE__ */ s(n,{name:`calendar`,size:p}):null;if(T){let e=a(I);return/* @__PURE__ */ c(`wui-due-date`,{class:g(`wui-due-date`,`wui-due-date-danger`,P),title:u(N,{date:e}),...v,...F,children:[/* @__PURE__ */ s(n,{name:`danger`,size:p}),B,/* @__PURE__ */ s(`time`,{dateTime:R,children:E||e})]})}return S!==void 0&&Number.isFinite(S)&&z>=0&&z<=S?/* @__PURE__ */ c(`wui-due-date`,{class:g(`wui-due-date`,`wui-due-date-warning`,P),...v,...F,children:[B,/* @__PURE__ */ s(`time`,{dateTime:R,children:_(C,z,{dueTodayLabel:O,dueTomorrowLabel:k,dueInLabel:A,daysLeftLabel:j,oneDayLeftLabel:M})})]}):/* @__PURE__ */ c(`wui-due-date`,{class:g(`wui-due-date`,P),...v,...F,children:[B,/* @__PURE__ */ s(`time`,{dateTime:R,children:a(I)})]})}export{v as default};
@@ -0,0 +1 @@
1
+ import e from"../lib/useElementEntry.js";import t from"../lib/useWuiText.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./AppIcon.js";import i from"./AppInfoTip.js";import a from"./AppKbd.js";import o from"./AppSkeleton.js";import s from"./AppSpinner.js";import c from"./AppTablePagination.js";import l from"./assertValidValue.js";import ee from"./warnUnknownProps.js";import{Fragment as u,useEffect as te,useRef as d}from"react";import{Fragment as f,jsx as p,jsxs as m}from"react/jsx-runtime";import{ENTRY_GRID_TEXT as h,KBD_TEXT as g}from"@webority/ui-elements/text";var _=[`text`,`number`],ne=[`start`],re=3,ie=[`clean`,`dirty`,`saving`,`saved`,`failed`],ae=e=>Array.isArray(e)&&e.every(e=>Array.isArray(e)&&e.every(e=>typeof e==`string`)),oe=()=>import(`@webority/ui-elements/elements/entry-grid`);function v(v){e(`wui-entry-grid`,oe);let y=t(`entryGrid`,h),b=t(`kbd`,g),{marker:se,props:x}=n(`AppEntryGrid`,v),{columns:S,rows:C,rowKey:w,activeRowKey:T,onActiveRowChange:E,renderCell:ce,rowState:D,rowError:O,onCommitRow:k,onDiscardRow:A,onAddRow:j,sort:M,onSort:N,onPasteRows:P,onRemoveRow:F,loading:I=!1,skeletonRows:L=re,emptyContent:R,rowProps:z,pagination:B,renderRowDetail:V,hint:H=!0,label:U=y.label,addLabel:W=y.addLabel,emptyLabel:G=y.emptyLabel,statusLabel:K=y.statusLabel,dirtyLabel:le=y.dirtyLabel,savingLabel:ue=y.savingLabel,savedLabel:de=y.savedLabel,failedLabel:fe=y.failedLabel,commitNextLabel:pe=y.commitNextLabel,commitStayLabel:me=y.commitStayLabel,discardLabel:he=y.discardLabel,moveLabel:ge=y.moveLabel,removeLineLabel:_e=y.removeLineLabel,className:ve=``,...q}=x;if(ee(`AppEntryGrid`,q),S.forEach((e,t)=>{if(l(`AppEntryGrid`,`columns[].kind`,e.kind,_),l(`AppEntryGrid`,`columns[].pin`,e.pin,ne),e.pin!==void 0&&t!==0)throw Error(`AppEntryGrid: only the first column can be pinned, but "${e.key}" has pin.`);if(e.sortable&&N===void 0)throw Error(`AppEntryGrid: column "${e.key}" is sortable, so the grid needs onSort.`)}),!Number.isInteger(L)||L<1)throw Error(`AppEntryGrid: skeletonRows must be a whole number of 1 or more, not ${L}.`);if(R!==void 0&&x.emptyLabel!==void 0)throw Error(`AppEntryGrid: give emptyLabel or emptyContent, not both.`);let ye=C.map(e=>{let t=D?D(e):`clean`;return l(`AppEntryGrid`,`rowState()`,t,ie),t}),J=d(null),Y=d({rows:C,rowKey:w,onCommitRow:k,onDiscardRow:A,onActiveRowChange:E,onAddRow:j,onSort:N,onPasteRows:P,onRemoveRow:F});Y.current={rows:C,rowKey:w,onCommitRow:k,onDiscardRow:A,onActiveRowChange:E,onAddRow:j,onSort:N,onPasteRows:P,onRemoveRow:F},te(()=>{let e=J.current;if(!e)return;let t=e=>{let t=e instanceof CustomEvent?e.detail?.rowKey:void 0,{rows:n,rowKey:r}=Y.current;return typeof t==`string`?n.find(e=>r(e)===t):void 0},n=e=>{let n=t(e),r=e instanceof CustomEvent?e.detail?.move:void 0;n!==void 0&&(r===`next`||r===`stay`)&&Y.current.onCommitRow?.(n,r)},r=e=>{let n=t(e);n!==void 0&&Y.current.onDiscardRow?.(n)},i=e=>{let n=t(e);n!==void 0&&Y.current.onActiveRowChange?.(Y.current.rowKey(n))},a=()=>Y.current.onAddRow?.(),o=e=>{let t=e instanceof CustomEvent?e.detail?.columnKey:void 0;typeof t==`string`&&Y.current.onSort?.(t)},s=e=>{let n=e instanceof CustomEvent?e.detail:void 0,r=t(e);r!==void 0&&typeof n?.columnKey==`string`&&ae(n.rows)&&Y.current.onPasteRows?.({rowKey:Y.current.rowKey(r),columnKey:n.columnKey,rows:n.rows})},c=e=>{let n=t(e);n!==void 0&&Y.current.onRemoveRow?.(Y.current.rowKey(n))};return e.addEventListener(`wui-entry-grid:commit`,n),e.addEventListener(`wui-entry-grid:discard`,r),e.addEventListener(`wui-entry-grid:active`,i),e.addEventListener(`wui-entry-grid:add`,a),e.addEventListener(`wui-entry-grid:sort`,o),e.addEventListener(`wui-entry-grid:paste`,s),e.addEventListener(`wui-entry-grid:remove`,c),()=>{e.removeEventListener(`wui-entry-grid:commit`,n),e.removeEventListener(`wui-entry-grid:discard`,r),e.removeEventListener(`wui-entry-grid:active`,i),e.removeEventListener(`wui-entry-grid:add`,a),e.removeEventListener(`wui-entry-grid:sort`,o),e.removeEventListener(`wui-entry-grid:paste`,s),e.removeEventListener(`wui-entry-grid:remove`,c)}},[]);let be=e=>e===`dirty`?/* @__PURE__ */ p(`span`,{className:`wui-entry-grid-dot`,role:`img`,"aria-label":le}):e===`saving`?/* @__PURE__ */ p(s,{size:`sm`,label:ue}):e===`saved`?/* @__PURE__ */ m(f,{children:[/* @__PURE__ */ p(r,{name:`tick-circle`,size:16}),/* @__PURE__ */ p(`span`,{className:`visually-hidden`,children:de})]}):e===`failed`?/* @__PURE__ */ m(f,{children:[/* @__PURE__ */ p(r,{name:`danger`,size:16}),/* @__PURE__ */ p(`span`,{className:`visually-hidden`,children:fe})]}):null,xe=S.some(e=>e.footer),X=S.length+1,Z=e=>e.kind===`number`?`text-end`:void 0,Se=e=>[e.sortable&&`sortable`,e.kind===`number`&&`text-end`].filter(Boolean).join(` `)||void 0,Q=S.some(e=>e.group!==void 0),$=[];for(let e of S){let t=$[$.length-1];e.group!==void 0&&t?.group===e.group?t.span+=1:$.push({key:e.key,group:e.group,span:1})}let Ce=e=>{if(e.sortable)return M?.key===e.key?M.dir===`asc`?`ascending`:`descending`:`none`},we=e=>{let t=z?.(e)??{};for(let e of Object.keys(t))if(!e.startsWith(`data-`)||e===`data-row-key`)throw Error(`AppEntryGrid: rowProps can only return data-* attributes other than data-row-key, not "${e}".`);return t};return/* @__PURE__ */ m(`wui-entry-grid`,{ref:J,class:[`wui-entry-grid`,ve].filter(Boolean).join(` `),"active-row":T??``,removable:F?``:void 0,...se,...q,children:[/* @__PURE__ */ p(`div`,{className:`table-responsive wui-entry-grid-scroll`,children:/* @__PURE__ */ m(`table`,{className:`table wui-entry-grid-table`,"aria-label":U,children:[/* @__PURE__ */ m(`thead`,{children:[Q?/* @__PURE__ */ m(`tr`,{children:[/* @__PURE__ */ p(`th`,{scope:`col`,className:`wui-entry-grid-status`,rowSpan:2,children:/* @__PURE__ */ p(`span`,{className:`visually-hidden`,children:K})}),$.map(e=>/* @__PURE__ */ p(`th`,{className:`wui-entry-grid-group`,scope:e.span>1?`colgroup`:`col`,colSpan:e.span>1?e.span:void 0,"data-pin":e.span===1?S.find(t=>t.key===e.key)?.pin:void 0,children:e.group},e.key))]}):null,/* @__PURE__ */ m(`tr`,{children:[Q?null:/* @__PURE__ */ p(`th`,{scope:`col`,className:`wui-entry-grid-status`,children:/* @__PURE__ */ p(`span`,{className:`visually-hidden`,children:K})}),S.map(e=>{let t=e.sortable?/* @__PURE__ */ p(`span`,{className:`sort-icon${e.kind===`number`?` wui-sort-lead`:``}`,children:/* @__PURE__ */ p(r,{name:`chevrons-up-down`,size:14})}):null;return/* @__PURE__ */ m(`th`,{scope:`col`,className:Se(e),style:e.width===void 0?void 0:{width:e.width},"data-column-key":e.key,"data-pin":e.pin,"data-sortable":e.sortable?`true`:void 0,tabIndex:e.sortable?0:void 0,"aria-sort":Ce(e),children:[e.kind===`number`?t:null,e.label,e.kind===`number`?null:t,e.help?/* @__PURE__ */ p(i,{label:typeof e.label==`string`?e.label:void 0,children:e.help}):null]},e.key)})]})]}),/* @__PURE__ */ m(`tbody`,{children:[I?Array.from({length:L},(e,t)=>`skeleton-${t}`).map(e=>/* @__PURE__ */ m(`tr`,{children:[/* @__PURE__ */ p(`td`,{className:`wui-entry-grid-status`}),S.map(e=>/* @__PURE__ */ p(`td`,{className:Z(e),"data-column-key":e.key,"data-pin":e.pin,children:/* @__PURE__ */ p(o,{width:e.kind===`number`?`56%`:`60%`,height:12,radius:6})},e.key))]},e)):C.map((e,t)=>{let n=w(e),r=ye[t]??`clean`,i=n===T,a=r===`failed`&&O!==void 0,o=i&&V!==void 0,s=[`wui-entry-grid-row`,i&&`is-active`,r!==`clean`&&`wui-entry-grid-row-${r}`].filter(Boolean).join(` `);return/* @__PURE__ */ m(u,{children:[/* @__PURE__ */ m(`tr`,{...we(e),className:s,"data-row-key":n,"aria-current":i?`true`:void 0,children:[/* @__PURE__ */ p(`td`,{className:`wui-entry-grid-status`,children:be(r)}),S.map(t=>/* @__PURE__ */ p(`td`,{className:Z(t),"data-kind":t.kind??`text`,"data-column-key":t.key,"data-pin":t.pin,children:ce(e,t,i)},t.key))]}),a||o?/* @__PURE__ */ p(`tr`,{className:`wui-entry-grid-detail`,children:/* @__PURE__ */ m(`td`,{colSpan:X,children:[a?/* @__PURE__ */ p(`div`,{className:`wui-entry-grid-error`,role:`alert`,children:O(e)}):null,o?V(e):null]})}):null]},n)}),!I&&C.length===0?/* @__PURE__ */ p(`tr`,{className:`wui-entry-grid-empty`,children:/* @__PURE__ */ p(`td`,{colSpan:X,children:R===void 0?G:R})}):null]}),xe?/* @__PURE__ */ p(`tfoot`,{className:`wui-entry-grid-footer`,children:/* @__PURE__ */ m(`tr`,{children:[/* @__PURE__ */ p(`td`,{}),S.map(e=>/* @__PURE__ */ p(`td`,{className:Z(e),children:e.footer?.(C)},e.key))]})}):null]})}),B?/* @__PURE__ */ p(c,{page:B.page,totalPages:B.totalPages,total:B.total,pageSize:B.pageSize,onPageChange:I?void 0:B.setPage,onPageSizeChange:I?void 0:B.setPageSize,pageSizes:B.pageSizes,mode:B.mode,summary:B.summary}):null,/* @__PURE__ */ m(`div`,{className:`wui-entry-grid-bar`,children:[j?/* @__PURE__ */ p(`button`,{type:`button`,className:`btn btn-sm btn-outline-primary wui-entry-grid-add`,children:W}):null,H?/* @__PURE__ */ m(`ul`,{className:`wui-entry-grid-hint`,children:[k?/* @__PURE__ */ m(f,{children:[/* @__PURE__ */ m(`li`,{children:[/* @__PURE__ */ p(a,{children:b.enterLabel}),` ${pe}`]}),/* @__PURE__ */ m(`li`,{children:[/* @__PURE__ */ p(a,{children:b.ctrlLabel}),`+`,/* @__PURE__ */ p(a,{children:`S`}),` ${me}`]})]}):null,/* @__PURE__ */ m(`li`,{children:[/* @__PURE__ */ p(a,{children:b.escLabel}),` ${he}`]}),/* @__PURE__ */ m(`li`,{children:[/* @__PURE__ */ p(a,{children:b.ctrlLabel}),`+`,/* @__PURE__ */ p(a,{children:`↑`}),`/`,/* @__PURE__ */ p(a,{children:`↓`}),` ${ge}`]}),F?/* @__PURE__ */ m(`li`,{children:[/* @__PURE__ */ p(a,{children:b.ctrlLabel}),`+`,/* @__PURE__ */ p(a,{children:`Delete`}),` ${_e}`]}):null]}):null]})]})}export{v as default};
@@ -1 +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
+ import e from"../lib/useWuiText.js";import t from"./AppButton.js";import n from"./AppRouteError.js";import r from"./warnUnknownProps.js";import{Component as i}from"react";import{jsx as a}from"react/jsx-runtime";import{ERROR_BOUNDARY_TEXT as o}from"@webority/ui-elements/text";var s=()=>window.location.reload(),c=(e=[],t=[])=>e.length===t.length&&e.every((e,n)=>Object.is(e,t[n])),l=class extends i{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&&!c(e.resetKeys,this.props.resetKeys)&&this.reset()}reset=()=>{this.props.onReset?.(),this.setState({error:null,hasError:!1})};render(){let{children:e,fallback:i,homeHref:o=`/`,brand:c,reloadLabel:l,onError:u,onReset:d,resetKeys:f,...p}=this.props;return r(`AppErrorBoundary`,p),this.state.hasError?typeof i==`function`?i({error:this.state.error,reset:this.reset}):i===void 0?/* @__PURE__ */ a(n,{kind:`error`,fullPage:!1,homeHref:o,brand:c,onRetry:this.reset,children:/* @__PURE__ */ a(t,{variant:`ghost`,leftIcon:`refresh-cw`,onClick:s,children:l})}):i:e}};function u({children:t,fallback:n,onError:r,resetKeys:i,onReset:s,homeHref:c,brand:u}){let d=e(`errorBoundary`,o);return/* @__PURE__ */ a(l,{fallback:n,onError:r,resetKeys:i,onReset:s,homeHref:c,brand:u,reloadLabel:d.reloadPageLabel,children:t})}export{u as default};
@@ -1 +1 @@
1
- import e from"../lib/focusField.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./warnUnknownProps.js";import{useEffect as r,useId as i,useRef as a}from"react";import{jsx as o,jsxs as s}from"react/jsx-runtime";function c(c){let{marker:l,props:u}=t(`AppErrorSummary`,c),{errors:d=[],title:f,autoFocus:p=!0,id:m,className:h=``,...g}=u;n(`AppErrorSummary`,g);let _=i(),v=m||_,y=a(null),b=a(0),x=d.length;return r(()=>{p&&x>0&&b.current===0&&y.current?.focus(),b.current=x},[x,p]),x?/* @__PURE__ */ s(`div`,{ref:y,className:[`alert alert-danger wui-error-summary`,h].filter(Boolean).join(` `),role:`alert`,tabIndex:-1,"aria-labelledby":`${v}-title`,id:v,"data-autofocus":p?``:void 0,...l,...g,children:[/* @__PURE__ */ o(`h2`,{className:`wui-error-summary-title`,id:`${v}-title`,children:f??`Fix ${x} field${x>1?`s`:``} to continue`}),/* @__PURE__ */ o(`ul`,{className:`wui-error-summary-list`,children:d.map(t=>/* @__PURE__ */ o(`li`,{children:/* @__PURE__ */ o(`a`,{href:`#${t.field}`,onClick:n=>{n.preventDefault(),e(t.field)},children:t.message})},`${t.field}:${t.message}`))})]}):null}export{c as default};
1
+ import e from"../lib/focusField.js";import t from"../lib/useWuiText.js";import{splitMarkerProps as n}from"../lib/wuiMarker.js";import r from"./warnUnknownProps.js";import{useEffect as i,useId as a,useRef as o}from"react";import{jsx as s,jsxs as c}from"react/jsx-runtime";import{ERROR_SUMMARY_TEXT as l,pluralText as u}from"@webority/ui-elements/text";function d(d){let{marker:f,props:p}=n(`AppErrorSummary`,d),m=t(`errorSummary`,l),{errors:h=[],title:g,autoFocus:_=!0,id:v,className:y=``,...b}=p;r(`AppErrorSummary`,b);let x=a(),S=v||x,C=o(null),w=o(0),T=h.length;return i(()=>{_&&T>0&&w.current===0&&C.current?.focus(),w.current=T},[T,_]),T?/* @__PURE__ */ c(`div`,{ref:C,className:[`alert alert-danger wui-error-summary`,y].filter(Boolean).join(` `),role:`alert`,tabIndex:-1,"aria-labelledby":`${S}-title`,id:S,"data-autofocus":_?``:void 0,...f,...b,children:[/* @__PURE__ */ s(`h2`,{className:`wui-error-summary-title`,id:`${S}-title`,children:g??u(m,`title`,T)}),/* @__PURE__ */ s(`ul`,{className:`wui-error-summary-list`,children:h.map(t=>/* @__PURE__ */ s(`li`,{children:/* @__PURE__ */ s(`a`,{href:`#${t.field}`,onClick:n=>{n.preventDefault(),e(t.field)},children:t.message})},`${t.field}:${t.message}`))})]}):null}export{d 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/fillLabel.js";import{linkTarget as ee}from"../lib/linkTarget.js";import{TargetLink as u}from"../lib/TargetLink.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{jsx as w,jsxs as T}from"react/jsx-runtime";function E(i){let{marker:a,props:o}=f(`AppFileAttachment`,i),{label:s=`Attachment`,value:c,name:l,onChange:ee,multiple:u=!1,accept:m=g,maxSizeMb:y=_,optional:E=!1,validate:A=!0,error:j,id:M,linkComponent:N,browseLabel:P=`Browse`,removeLabel:F=`Remove attachment`,uploadingLabel:te=`Uploading {name}`,maxSizeText:ne=`Up to {size} MB`,typesAndMaxSizeText:re=`{types}, up to {size} MB`,removeFileLabel:ie=`Remove {name}`,optionalLabel:ae=`(optional)`,dropTitle:oe,...I}=o;if(h(`AppFileAttachment`,I),!u&&Array.isArray(c))throw TypeError(`[@webority/ui-react] <AppFileAttachment> received a list of files as value without multiple. Pass one file (or null), or set multiple to take a list.`);let L=S(),R=M||L,[z,B]=C(``),V=Array.isArray(c)?c:c?[c]:[],H=x(m),U=e=>e instanceof File?b(e):H||b(O(e)),W=V[0],G=!u&&W!==void 0&&U(W)&&(W instanceof File||r(W)!==null)?W:void 0,K=D(m,y,ne,re),q=A?{accept:m,maxSizeMb:y,multiple:u}:{accept:``,maxSizeMb:0,multiple:u},J=e=>{i.multiple||i.onChange(e)},Y=e=>{i.multiple&&i.onChange(e)};function X(e){if(B(``),u){let t=Array.isArray(c)?c:c?[c]:[],r=new Set(t.map(n)),i=t.concat(e.filter(e=>!r.has(n(e))));Y(i)}else J(e[0]??null)}function se(e){if(!e.length)return;let{files:t,rejections:n}=v(e,q);t.length&&X(t),B(n[0]?.message??``)}let{dragOver:ce,dropProps:le}=d({...q,disabled:I.disabled,onFiles:X,onReject:e=>B(e.message)});function ue(e){let t=Array.from(e.target.files||[]);e.target.value=``,se(t)}function Z(e){B(``),u?Y(V.filter((t,n)=>n!==e)):J(null)}let Q=j||z,de=Q?`${R}-error`:void 0,fe=u||V.length===0,$=H?`image`:`file`,pe=oe??(u?`Add ${$}s`:`Add ${H?`an`:`a`} ${$}`);return/* @__PURE__ */ T(`div`,{...a,className:`field`,children:[/* @__PURE__ */ T(`label`,{className:`label`,htmlFor:R,children:[s,E&&/* @__PURE__ */ w(`span`,{className:`label-optional`,children:` ${ae}`})]}),/* @__PURE__ */ T(`label`,{className:`attach-drop${ce?` dragging`:``}`,htmlFor:R,style:fe?void 0:{display:`none`},...le,children:[/* @__PURE__ */ w(`span`,{className:`attach-drop-icon`,children:/* @__PURE__ */ w(p,{name:H?`image`:`file-text`,size:18})}),/* @__PURE__ */ T(`span`,{className:`attach-drop-copy`,children:[/* @__PURE__ */ w(`span`,{className:`attach-drop-title`,children:pe}),K&&/* @__PURE__ */ w(`span`,{className:`attach-drop-hint`,children:K})]}),/* @__PURE__ */ w(`span`,{className:`attach-drop-cta`,children:P})]}),/* @__PURE__ */ w(`input`,{id:R,type:`file`,className:`visually-hidden`,name:l,accept:m||void 0,multiple:u||void 0,"aria-describedby":de,onChange:ue,...I}),G?/* @__PURE__ */ w(k,{item:G,isImage:!0,linkComponent:N,onRemove:()=>Z(0),removeLabel:F,uploadingLabel:te}):V.length>0&&/* @__PURE__ */ w(`div`,{className:`attach-list`,children:V.map((e,r)=>/* @__PURE__ */ w(t,{item:e,isImage:U(e),linkComponent:N,onRemove:()=>Z(r),removeFileLabel:ie},n(e)))}),/* @__PURE__ */ w(e,{error:Q,errorId:`${R}-error`})]})}function D(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 O({name:e,url:t}){return{...e===void 0?null:{name:e},...t===void 0?null:{url:t}}}function k({item:e,isImage:t,linkComponent:n,onRemove:d,removeLabel:f,uploadingLabel:h}){let g=c(e,t),_=i(e),v=a(e),y=s(e),b=o(e),x=r(e),S=e instanceof File?void 0:e.to,C=ee(n,{to:S,href:x??void 0,routeHref:!1});return/* @__PURE__ */ T(`div`,{className:b?`attach-preview wui-attach-failed`:`attach-preview`,children:[/* @__PURE__ */ T(`div`,{className:`attach-figure`,children:[/* @__PURE__ */ w(`img`,{src:g??void 0,alt:_}),/* @__PURE__ */ w(`button`,{type:`button`,className:`attach-remove`,"aria-label":f,onClick:d,children:/* @__PURE__ */ w(p,{name:`x`,size:18})})]}),/* @__PURE__ */ T(`div`,{className:`attach-meta`,children:[/* @__PURE__ */ w(`div`,{className:`attach-name`,children:x||S?/* @__PURE__ */ w(u,{link:C,children:_}):_}),v&&/* @__PURE__ */ w(`div`,{className:`attach-size`,children:v})]}),y!==null&&/* @__PURE__ */ w(m,{value:y,size:`sm`,label:l(h,{name:_}),className:`wui-attach-progress`}),b&&/* @__PURE__ */ w(`div`,{className:`wui-attach-error`,children:b})]})}export{E 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{useFieldError as l}from"../lib/formFields.js";import{linkTarget as u}from"../lib/linkTarget.js";import{TargetLink as d}from"../lib/TargetLink.js";import f from"../lib/useFileDrop.js";import p from"../lib/useWuiText.js";import{splitMarkerProps as m}from"../lib/wuiMarker.js";import h from"./AppIcon.js";import g from"./AppProgress.js";import _ from"./warnUnknownProps.js";import{DEFAULT_IMAGE_ACCEPT as v,DEFAULT_MAX_SIZE_MB as y,acceptDroppedFiles as b,acceptLabel as x,isImageFile as S,isImageOnlyAccept as C}from"@webority/ui-elements/helpers";import{useId as ee,useState as te}from"react";import{jsx as w,jsxs as T}from"react/jsx-runtime";import{FILE_ATTACHMENT_TEXT as ne,fillText as E,pluralText as D}from"@webority/ui-elements/text";function O(i){let{marker:a,props:o}=m(`AppFileAttachment`,i),s=p(`fileAttachment`,ne),{label:c=s.label,value:u,name:d,onChange:g,multiple:x=!1,accept:E=v,maxSizeMb:O=y,optional:ie=!1,validate:ae=!0,error:oe,id:se,linkComponent:j,browseLabel:ce=s.browseLabel,removeLabel:le=s.removeLabel,uploadingLabel:ue=s.uploadingLabel,maxSizeText:de=s.maxSizeText,typesAndMaxSizeText:fe=s.typesAndMaxSizeText,removeFileLabel:pe=s.removeFileLabel,optionalLabel:M=s.optionalLabel,dropTitle:N,...P}=o,F=l(d),I=oe??F;if(_(`AppFileAttachment`,P),!x&&Array.isArray(u))throw TypeError(`[@webority/ui-react] <AppFileAttachment> received a list of files as value without multiple. Pass one file (or null), or set multiple to take a list.`);let L=ee(),R=se||L,[z,B]=te(``),V=Array.isArray(u)?u:u?[u]:[],H=C(E),U=e=>e instanceof File?S(e):H||S(A(e)),W=V[0],G=!x&&W!==void 0&&U(W)&&(W instanceof File||r(W)!==null)?W:void 0,K=k(E,O,de,fe),q=ae?{accept:E,maxSizeMb:O,multiple:x}:{accept:``,maxSizeMb:0,multiple:x},J=e=>{i.multiple||i.onChange(e)},Y=e=>{i.multiple&&i.onChange(e)};function X(e){if(B(``),x){let t=Array.isArray(u)?u:u?[u]:[],r=new Set(t.map(n)),i=t.concat(e.filter(e=>!r.has(n(e))));Y(i)}else J(e[0]??null)}function me(e){if(!e.length)return;let{files:t,rejections:n}=b(e,q);t.length&&X(t),B(n[0]?.message??``)}let{dragOver:he,dropProps:ge}=f({...q,disabled:P.disabled,onFiles:X,onReject:e=>B(e.message)});function Z(e){let t=Array.from(e.target.files||[]);e.target.value=``,me(t)}function Q(e){B(``),x?Y(V.filter((t,n)=>n!==e)):J(null)}let $=I||z,_e=$?`${R}-error`:void 0,ve=x||V.length===0,ye=N??(H?D(s,`dropImageTitle`,x?2:1):D(s,`dropFileTitle`,x?2:1));return/* @__PURE__ */ T(`div`,{...a,className:`field`,children:[/* @__PURE__ */ T(`label`,{className:`label`,htmlFor:R,children:[c,ie&&/* @__PURE__ */ w(`span`,{className:`label-optional`,children:` ${M}`})]}),/* @__PURE__ */ T(`label`,{className:`attach-drop${he?` dragging`:``}`,htmlFor:R,style:ve?void 0:{display:`none`},...ge,children:[/* @__PURE__ */ w(`span`,{className:`attach-drop-icon`,children:/* @__PURE__ */ w(h,{name:H?`image`:`file-text`,size:18})}),/* @__PURE__ */ T(`span`,{className:`attach-drop-copy`,children:[/* @__PURE__ */ w(`span`,{className:`attach-drop-title`,children:ye}),K&&/* @__PURE__ */ w(`span`,{className:`attach-drop-hint`,children:K})]}),/* @__PURE__ */ w(`span`,{className:`attach-drop-cta`,children:ce})]}),/* @__PURE__ */ w(`input`,{id:R,type:`file`,className:`visually-hidden`,name:d,accept:E||void 0,multiple:x||void 0,"aria-describedby":_e,onChange:Z,...P}),G?/* @__PURE__ */ w(re,{item:G,isImage:!0,linkComponent:j,onRemove:()=>Q(0),removeLabel:le,uploadingLabel:ue}):V.length>0&&/* @__PURE__ */ w(`div`,{className:`attach-list`,children:V.map((e,r)=>/* @__PURE__ */ w(t,{item:e,isImage:U(e),linkComponent:j,onRemove:()=>Q(r),removeFileLabel:pe},n(e)))}),/* @__PURE__ */ w(e,{error:$,errorId:`${R}-error`})]})}function k(e,t,n,r){let i=e?.trim()?x(e):``,a=t>0;return i&&a?E(r,{types:i,size:t}):a?E(n,{size:t}):i}function A({name:e,url:t}){return{...e===void 0?null:{name:e},...t===void 0?null:{url:t}}}function re({item:e,isImage:t,linkComponent:n,onRemove:l,removeLabel:f,uploadingLabel:p}){let m=c(e,t),_=i(e),v=a(e),y=s(e),b=o(e),x=r(e),S=e instanceof File?void 0:e.to,C=u(n,{to:S,href:x??void 0,routeHref:!1});return/* @__PURE__ */ T(`div`,{className:b?`attach-preview wui-attach-failed`:`attach-preview`,children:[/* @__PURE__ */ T(`div`,{className:`attach-figure`,children:[/* @__PURE__ */ w(`img`,{src:m??void 0,alt:_}),/* @__PURE__ */ w(`button`,{type:`button`,className:`attach-remove`,"aria-label":f,onClick:l,children:/* @__PURE__ */ w(h,{name:`x`,size:18})})]}),/* @__PURE__ */ T(`div`,{className:`attach-meta`,children:[/* @__PURE__ */ w(`div`,{className:`attach-name`,children:x||S?/* @__PURE__ */ w(d,{link:C,children:_}):_}),v&&/* @__PURE__ */ w(`div`,{className:`attach-size`,children:v})]}),y!==null&&/* @__PURE__ */ w(g,{value:y,size:`sm`,label:E(p,{name:_??``}),className:`wui-attach-progress`}),b&&/* @__PURE__ */ w(`div`,{className:`wui-attach-error`,children:b})]})}export{O as default};
@@ -1 +1 @@
1
- import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import n from"../lib/FileItemRow.js";import{FIELD_SIZES as r}from"../lib/fieldState.js";import{keyOf as i}from"../lib/fileItem.js";import a from"../lib/fillLabel.js";import o from"../lib/useFileDrop.js";import{splitMarkerProps as 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 c from"./assertValidValue.js";import ie from"./warnUnknownProps.js";import ae from"./withTooltip.js";import{DEFAULT_MAX_SIZE_MB as oe,acceptDroppedFiles as se,acceptLabel as l,isImageFile as u,isImageOnlyAccept as ce,isPdfFile as le}from"@webority/ui-elements/helpers";import{useEffect as d,useId as ue,useRef as de,useState as f}from"react";import{jsx as p,jsxs as m}from"react/jsx-runtime";var fe=[`dropzone`,`button`],pe={sm:` input-sm`,md:``,lg:` input-lg`},me={md:``,lg:` btn-lg`};function h(e){return e instanceof File?e:{url:e.url,...e.name===void 0?null:{name:e.name}}}function g(g){let{marker:he,props:ge}=ee(`AppFilePicker`,g),{label:_,value:v,name:_e,id:ve,onChange:ye,multiple:y=!1,variant:b=`dropzone`,buttonLabel:be=`Add file`,browseLabel:xe=`Click to upload`,dropLabel:Se=`or drag & drop`,maxSizeText:Ce=`up to {size} MB`,optionalLabel:we=`(optional)`,changeImageLabel:Te=`Change image`,changeFileLabel:Ee=`Change file`,maxFilesText:De=`Up to {count} files.`,removeFileLabel:Oe=`Remove {name}`,maxFiles:x,accept:S=`.jpg,.jpeg,.png`,maxSizeMb:C=oe,required:w,optional:ke=!1,error:Ae,helperText:T,help:E,helpLabel:je=`More information`,loading:D=!1,readOnly:O=!1,size:k,disabled:A=!1,className:j=``,fieldClassName:M=``,style:N,...P}=ge;if(ie(`AppFilePicker`,P),c(`AppFilePicker`,`variant`,b,fe),c(`AppFilePicker`,`size`,k,r),!y&&Array.isArray(v))throw TypeError(`[@webority/ui-react] <AppFilePicker> received a list of files as value without multiple. Pass one file (or null), or set multiple to take a list.`);let F=k===void 0?``:pe[k]??``,I=O?{"aria-readonly":`true`,"data-wui-readonly":``}:null,[Me,L]=f(null),[Ne,R]=f(null),[Pe,z]=f(``),B=de(null),Fe=ue(),V=ve||Fe,H=A||D;d(()=>{if(!y&&v instanceof File&&u(v)){let e=URL.createObjectURL(v);return L(e),()=>URL.revokeObjectURL(e)}L(null)},[v,y]);let U=y||Array.isArray(v)?void 0:v,W=U&&!u(h(U))&&le(h(U))?U instanceof File?U:U.url:null;d(()=>{if(!W){R(null);return}let t=!0,n=null;return import(`@webority/ui-elements/file-viewer`).then(e=>e.renderPdfFirstPage(typeof W==`string`?{url:W}:W)).then(e=>{t&&(n=URL.createObjectURL(e),R(n))}).catch(t=>e(`[AppFilePicker] the PDF preview failed:`,t?.message)),()=>{t=!1,R(null),n&&URL.revokeObjectURL(n)}},[W]);let G=y?Array.isArray(v)?v:v?[v]:[]:[],K=Ae||Pe,q=K?`${V}-error`:void 0,J=T&&!K?`${V}-hint`:void 0,Ie=q||J,Y=ce(S),Le=b===`button`,Re=`btn btn-outline-primary${(k===`md`||k===`lg`?me[k]:void 0)??` btn-sm`}`,ze=!y&&!!v,X=!!U&&(U instanceof File?u(U):Y||u(h(U))),Be=U?.name,Ve=U instanceof File?void 0:U?.url,He=X?Ve||Me:Ne,Z=X?`image`:`file`,Ue=_?`Change ${_}`:`Change ${Z}`,We=_?`Remove ${_}`:`Remove ${Z}`,Ge=_?`${_} preview`:`Selected ${Z} preview`,Ke={accept:S,maxSizeMb:C,multiple:y},qe=e=>{g.multiple||g.onChange(e)},Je=e=>{g.multiple&&g.onChange(e)},Ye=e=>{if(z(``),!y){qe(e[0]??null);return}let t=Array.isArray(v)?v:v?[v]:[],n=new Set(t.map(i)),r=[];for(let t of e)n.has(i(t))||(n.add(i(t)),r.push(t));let o=t.concat(r);x&&o.length>x&&(o=o.slice(0,x),z(a(De,{count:x}))),Je(o)},Xe=e=>z(e.message),{dragOver:Ze,dropProps:Qe}=o({...Ke,disabled:H||O,onFiles:Ye,onReject:Xe}),$e=e=>{if(O)return;let{files:t,rejections:n}=se(e,Ke);t.length&&Ye(t);let[r]=n;r&&Xe(r)},et=e=>$e(e.target.files),tt=e=>{O||(z(``),Je(G.filter((t,n)=>n!==e)))},nt=()=>{O||B.current?.click()},Q=D?/* @__PURE__ */ p(`span`,{className:`wui-file-busy`,children:/* @__PURE__ */ p(re,{size:`sm`})}):null,$=/* @__PURE__ */ p(`input`,{id:V,name:_e,ref:B,type:`file`,"aria-describedby":Ie,accept:S,multiple:y||void 0,disabled:H||void 0,className:`visually-hidden`,onClick:e=>{O?e.preventDefault():e.currentTarget.value=``},onChange:et,...P});return/* @__PURE__ */ m(`div`,{...he,className:`field${M?` ${M}`:``}`,children:[_?/* @__PURE__ */ m(`label`,{className:`label`,htmlFor:V,children:[_,ke&&!w&&/* @__PURE__ */ p(`span`,{className:`label-optional`,children:` ${we}`}),w&&/* @__PURE__ */ p(ne,{}),E&&/* @__PURE__ */ p(te,{label:je,children:E})]}):null,Le?/* @__PURE__ */ m(`div`,{className:`file-input wui-file-input-button-field${F}${K?` error`:``}${j?` ${j}`:``}`,style:N,"aria-busy":D||void 0,...I,children:[/* @__PURE__ */ m(`label`,{htmlFor:V,className:Re,children:[/* @__PURE__ */ p(s,{name:`paperclip`,size:16}),be]}),$,Q]}):ze?/* @__PURE__ */ m(`div`,{className:`file-preview${F}${K?` error`:``}${j?` ${j}`:``}`,style:N,"aria-busy":D||void 0,...I,children:[/* @__PURE__ */ m(`button`,{type:`button`,className:`file-preview-open`,"aria-label":Ue,onClick:nt,disabled:H||O,children:[He?/* @__PURE__ */ p(`img`,{src:He,alt:Ge,className:`file-preview-img`}):/* @__PURE__ */ m(`span`,{className:`file-preview-file`,children:[/* @__PURE__ */ p(s,{name:`file-text`,size:28}),/* @__PURE__ */ p(`span`,{className:`file-preview-file-name`,children:Be})]}),/* @__PURE__ */ p(`span`,{className:`file-preview-overlay`,children:/* @__PURE__ */ m(`span`,{className:`file-preview-cta`,children:[/* @__PURE__ */ p(s,{name:X?`image`:`file-text`,size:16}),` `,X?Te:Ee]})})]}),ae(/* @__PURE__ */ p(`button`,{type:`button`,className:`file-preview-remove`,"aria-label":We,onClick:()=>qe(null),disabled:H||O,children:/* @__PURE__ */ p(s,{name:`x`,size:16})}),We),$,Q]}):/* @__PURE__ */ m(`div`,{className:`file-input file-input-tall${F}${Ze?` dragging`:``}${K?` error`:``}${y&&G.length>0?` has-files`:``}${j?` ${j}`:``}`,style:N,"aria-busy":D||void 0,"aria-disabled":A||void 0,...I,...Qe,children:[/* @__PURE__ */ m(`label`,{htmlFor:V,className:`file-input-zone-label`,children:[/* @__PURE__ */ p(`span`,{className:`file-input-icon`,children:/* @__PURE__ */ p(s,{name:`upload`,size:24})}),/* @__PURE__ */ m(`span`,{className:`file-input-title`,children:[/* @__PURE__ */ p(`span`,{className:`browse`,children:xe}),` ${Se}`]}),/* @__PURE__ */ p(`span`,{className:`file-input-text`,children:C>0?`${l(S)}, ${a(Ce,{size:C})}`:l(S)})]}),$,Q,y&&G.length>0&&/* @__PURE__ */ p(`div`,{className:`attach-list`,children:G.map((e,t)=>/* @__PURE__ */ p(n,{item:e,isImage:e instanceof File?u(e):Y||u(h(e)),noun:`file`,removeFileLabel:Oe,readOnly:O,onRemove:()=>tt(t)},i(e)))})]}),/* @__PURE__ */ p(t,{error:K,hint:T,errorId:q,hintId:J})]})}export{g as default};
1
+ import{devWarn as e}from"../lib/devWarn.js";import t from"../lib/FieldMessage.js";import n from"../lib/FileItemRow.js";import{BOX_SIZES as r}from"../lib/fieldState.js";import{keyOf as i}from"../lib/fileItem.js";import{useFieldError as a}from"../lib/formFields.js";import ee from"../lib/useFileDrop.js";import te from"../lib/useWuiText.js";import{splitMarkerProps as ne}from"../lib/wuiMarker.js";import o from"./AppIcon.js";import re from"./AppInfoTip.js";import ie from"./AppRequiredMark.js";import ae from"./AppSpinner.js";import s from"./assertValidValue.js";import oe from"./warnUnknownProps.js";import se from"./withTooltip.js";import{DEFAULT_MAX_SIZE_MB as ce,acceptDroppedFiles as le,acceptLabel as c,isImageFile as l,isImageOnlyAccept as ue,isPdfFile as de}from"@webority/ui-elements/helpers";import{useEffect as u,useId as fe,useRef as pe,useState as d}from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{FILE_PICKER_TEXT as me,fillText as m}from"@webority/ui-elements/text";var he=[`dropzone`,`button`],ge={sm:` wui-input-sm`,md:``,lg:` wui-input-lg`},_e={md:``,lg:` btn-lg`};function h(e){return e instanceof File?e:{url:e.url,...e.name===void 0?null:{name:e.name}}}function g(g){let{marker:ve,props:ye}=ne(`AppFilePicker`,g),_=te(`filePicker`,me),{label:v,value:y,name:b,id:be,onChange:xe,multiple:x=!1,variant:S=`dropzone`,buttonLabel:Se=_.buttonLabel,browseLabel:Ce=_.browseLabel,dropLabel:we=_.dropLabel,maxSizeText:Te=_.maxSizeText,optionalLabel:Ee=_.optionalLabel,changeImageLabel:De=_.changeImageLabel,changeFileLabel:Oe=_.changeFileLabel,maxFilesText:ke=_.maxFilesText,removeFileLabel:Ae=_.removeFileLabel,maxFiles:C,accept:w=`.jpg,.jpeg,.png`,maxSizeMb:T=ce,required:E,optional:je=!1,error:Me,helperText:D,help:O,helpLabel:Ne=_.helpLabel,loading:k=!1,readOnly:A=!1,size:j,disabled:M=!1,className:N=``,fieldClassName:P=``,style:F,...I}=ye,Pe=a(b),Fe=Me??Pe;if(oe(`AppFilePicker`,I),s(`AppFilePicker`,`variant`,S,he),s(`AppFilePicker`,`size`,j,r),!x&&Array.isArray(y))throw TypeError(`[@webority/ui-react] <AppFilePicker> received a list of files as value without multiple. Pass one file (or null), or set multiple to take a list.`);let L=j===void 0?``:ge[j]??``,R=A?{"aria-readonly":`true`,"data-wui-readonly":``}:null,[Ie,z]=d(null),[Le,B]=d(null),[Re,V]=d(``),H=pe(null),ze=fe(),U=be||ze,W=M||k;u(()=>{if(!x&&y instanceof File&&l(y)){let e=URL.createObjectURL(y);return z(e),()=>URL.revokeObjectURL(e)}z(null)},[y,x]);let G=x||Array.isArray(y)?void 0:y,K=G&&!l(h(G))&&de(h(G))?G instanceof File?G:G.url:null;u(()=>{if(!K){B(null);return}let t=!0,n=null;return import(`@webority/ui-elements/file-viewer`).then(e=>e.renderPdfFirstPage(typeof K==`string`?{url:K}:K)).then(e=>{t&&(n=URL.createObjectURL(e),B(n))}).catch(t=>e(`[AppFilePicker] the PDF preview failed:`,t?.message)),()=>{t=!1,B(null),n&&URL.revokeObjectURL(n)}},[K]);let q=x?Array.isArray(y)?y:y?[y]:[]:[],J=Fe||Re,Y=J?`${U}-error`:void 0,Be=D&&!J?`${U}-hint`:void 0,Ve=Y||Be,He=ue(w),Ue=S===`button`,We=`btn btn-outline-primary${(j===`md`||j===`lg`?_e[j]:void 0)??` btn-sm`}`,Ge=!x&&!!y,X=!!G&&(G instanceof File?l(G):He||l(h(G))),Ke=G?.name,qe=G instanceof File?void 0:G?.url,Je=X?qe||Ie:Le,Z=X?_.imageLabel:_.fileLabel,Ye=m(_.changeNamedText,{label:v||Z}),Xe=m(_.removeNamedText,{label:v||Z}),Ze=v?m(_.previewAltText,{label:v}):m(_.selectedPreviewText,{noun:Z}),Qe={accept:w,maxSizeMb:T,multiple:x},$e=e=>{g.multiple||g.onChange(e)},et=e=>{g.multiple&&g.onChange(e)},tt=e=>{if(V(``),!x){$e(e[0]??null);return}let t=Array.isArray(y)?y:y?[y]:[],n=new Set(t.map(i)),r=[];for(let t of e)n.has(i(t))||(n.add(i(t)),r.push(t));let a=t.concat(r);C&&a.length>C&&(a=a.slice(0,C),V(m(ke,{count:C}))),et(a)},nt=e=>V(e.message),{dragOver:rt,dropProps:it}=ee({...Qe,disabled:W||A,onFiles:tt,onReject:nt}),at=e=>{if(A)return;let{files:t,rejections:n}=le(e,Qe);t.length&&tt(t);let[r]=n;r&&nt(r)},ot=e=>at(e.target.files),st=e=>{A||(V(``),et(q.filter((t,n)=>n!==e)))},ct=()=>{A||H.current?.click()},Q=k?/* @__PURE__ */ f(`span`,{className:`wui-file-busy`,children:/* @__PURE__ */ f(ae,{size:`sm`})}):null,$=/* @__PURE__ */ f(`input`,{id:U,name:b,ref:H,type:`file`,"aria-describedby":Ve,accept:w,multiple:x||void 0,disabled:W||void 0,className:`visually-hidden`,onClick:e=>{A?e.preventDefault():e.currentTarget.value=``},onChange:ot,...I});return/* @__PURE__ */ p(`div`,{...ve,className:`field${P?` ${P}`:``}`,children:[v?/* @__PURE__ */ p(`label`,{className:`label`,htmlFor:U,children:[v,je&&!E&&/* @__PURE__ */ f(`span`,{className:`label-optional`,children:` ${Ee}`}),E&&/* @__PURE__ */ f(ie,{}),O&&/* @__PURE__ */ f(re,{label:Ne,children:O})]}):null,Ue?/* @__PURE__ */ p(`div`,{className:`file-input wui-file-input-button-field${L}${J?` error`:``}${N?` ${N}`:``}`,style:F,"aria-busy":k||void 0,...R,children:[/* @__PURE__ */ p(`label`,{htmlFor:U,className:We,children:[/* @__PURE__ */ f(o,{name:`paperclip`,size:16}),Se]}),$,Q]}):Ge?/* @__PURE__ */ p(`div`,{className:`file-preview${L}${J?` error`:``}${N?` ${N}`:``}`,style:F,"aria-busy":k||void 0,...R,children:[/* @__PURE__ */ p(`button`,{type:`button`,className:`file-preview-open`,"aria-label":Ye,onClick:ct,disabled:W||A,children:[Je?/* @__PURE__ */ f(`img`,{src:Je,alt:Ze,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:Ke})]}),/* @__PURE__ */ f(`span`,{className:`file-preview-overlay`,children:/* @__PURE__ */ p(`span`,{className:`file-preview-cta`,children:[/* @__PURE__ */ f(o,{name:X?`image`:`file-text`,size:16}),` `,X?De:Oe]})})]}),se(/* @__PURE__ */ f(`button`,{type:`button`,className:`file-preview-remove`,"aria-label":Xe,onClick:()=>$e(null),disabled:W||A,children:/* @__PURE__ */ f(o,{name:`x`,size:16})}),Xe),$,Q]}):/* @__PURE__ */ p(`div`,{className:`file-input file-input-tall${L}${rt?` dragging`:``}${J?` error`:``}${x&&q.length>0?` has-files`:``}${N?` ${N}`:``}`,style:F,"aria-busy":k||void 0,"aria-disabled":M||void 0,...R,...it,children:[/* @__PURE__ */ p(`label`,{htmlFor:U,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:Ce}),` ${we}`]}),/* @__PURE__ */ f(`span`,{className:`file-input-text`,children:T>0?`${c(w)}, ${m(Te,{size:T})}`:c(w)})]}),$,Q,x&&q.length>0&&/* @__PURE__ */ f(`div`,{className:`attach-list`,children:q.map((e,t)=>/* @__PURE__ */ f(n,{item:e,isImage:e instanceof File?l(e):He||l(h(e)),noun:_.fileLabel,removeFileLabel:Ae,readOnly:A,onRemove:()=>st(t)},i(e)))})]}),/* @__PURE__ */ f(t,{error:J,hint:D,errorId:Y,hintId:Be})]})}export{g as default};
@@ -1 +1 @@
1
- import{emptyFacetValue as e,isFacetActive as t}from"../web-core/dist/query/listQuery.js";import{devWarn as n}from"../lib/devWarn.js";import r from"../lib/fillLabel.js";import i from"../lib/useElementEntry.js";import{splitMarkerProps as a}from"../lib/wuiMarker.js";import o from"./AppButton.js";import ee from"./AppChip.js";import s from"./AppDateRangePicker.js";import te from"./AppIcon.js";import c from"./AppSearch.js";import l from"./AppSegmented.js";import u from"./AppSelect.js";import ne from"./AppSwitch.js";import d from"./assertValidValue.js";import re from"./warnUnknownProps.js";import{isImeSafeEnter as ie}from"@webority/ui-elements/helpers";import{Fragment as ae,useEffect as f,useId as oe,useRef as p,useState as se,useSyncExternalStore as ce}from"react";import{Fragment as le,jsx as m,jsxs as h}from"react/jsx-runtime";var g=`(max-width: 575.98px)`,ue=3,_=2,de=e=>{let t=window.matchMedia?.(g);return t?.addEventListener(`change`,e),()=>t?.removeEventListener(`change`,e)},fe=()=>window.matchMedia?.(g).matches??!1,pe=[`enum`,`multiEnum`,`dateRange`,`text`],me=[`sm`,`md`],he=()=>import(`@webority/ui-elements/elements/filter-popover`),v=4,ge=e=>(e.type===`enum`||e.type===`multiEnum`)&&!e.options?.length,y=(e,t)=>e.options?.find(e=>e.value===t)?.label??t,_e=(e,t)=>JSON.stringify(e)===JSON.stringify(t),b=(e,t,n)=>/* @__PURE__ */ RangeError(`[@webority/ui-react] <AppFilterBar> facet "${e.key}" needs ${t}, received ${JSON.stringify(n)}.`),x=(e,t)=>{if(t==null)return``;if(typeof t==`string`)return t;throw b(e,`a string value`,t)},S=(e,t)=>{if(t==null)return[];if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return t;throw b(e,`an array of strings`,t)},C=(e,t)=>{if(t==null)return{from:``,to:``};if(typeof t==`object`&&!Array.isArray(t)&&!(t instanceof Date)){let{from:e,to:n}=t;if((e===void 0||typeof e==`string`)&&(n===void 0||typeof n==`string`))return{from:e,to:n}}throw b(e,`a { from, to } date range`,t)};function ve(n,i,a){if(n.required||!t(n,i))return[];if(n.type===`enum`)return[{id:n.key,text:y(n,x(n,i)),clear:()=>e(n)}];if(n.type===`multiEnum`){let e=S(n,i);return e.map(t=>({id:`${n.key}:${t}`,text:y(n,t),clear:()=>e.filter(e=>e!==t)}))}if(n.type===`dateRange`){let t=C(n,i),o=t.from&&t.to?r(a.range,{from:t.from,to:t.to}):t.from?r(a.from,{date:t.from}):r(a.until,{date:t.to});return[{id:n.key,text:o,clear:()=>e(n)}]}return[]}var w=/* @__PURE__ */ new Set;function ye(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!w.has(e)&&(w.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets allLabel, which only an enum facet uses.`))}var T=/* @__PURE__ */ new Set;function be(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!T.has(e)&&(T.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets required, which only an enum facet uses.`))}var E=/* @__PURE__ */ new Set;function xe(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!E.has(e)&&(E.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets allLabel and required; a required facet has no All segment.`))}var D=/* @__PURE__ */ new Set;function Se(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!D.has(e)&&(D.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets presets, which only a dateRange facet uses.`))}function O(n){i(`wui-filter-popover`,he);let{marker:s,props:c}=a(`AppFilterBar`,n),{facets:l,value:u,onChange:g,inline:v=ue,floating:y=!1,apply:b=!1,size:x=`sm`,className:S=``,clearAllLabel:C=`Clear all`,filtersLabel:w=`Filters`,filtersActiveLabel:T=`Filters, {count} active`,keepOpenLabel:E=`Keep open`,appliesAtOnceText:D=`Changes apply at once.`,applyLabel:O=`Apply`,anyLabel:A=`Any`,removeChipLabel:Ce=`Remove {facet} filter {value}`,dateFromText:we=`From {date}`,dateUntilText:Te=`Until {date}`,dateRangeText:Ee=`{from} to {to}`,...j}=c;re(`AppFilterBar`,j),d(`AppFilterBar`,`size`,x,me);let M=x===`md`,De={range:Ee,from:we,until:Te},N=ce(de,fe,()=>!1),P=p(null),F=p(null),Oe=e=>{let t=P.current,n=F.current;t&&n&&(e.preventDefault(),t.open=!t.open,n.classList.remove(`wui-filter-more-panel-end`),t.open&&n.getBoundingClientRect().right>window.innerWidth-8&&n.classList.add(`wui-filter-more-panel-end`))},I=oe(),[L,R]=se({}),z=p(u);for(let e of l)d(`AppFilterBar`,`facets[].type`,e.type,pe);for(let e of l)e.allLabel!=null&&e.type!==`enum`&&ye(e.key),e.required&&e.type!==`enum`&&be(e.key),e.required&&e.allLabel!=null&&xe(e.key),e.presets!=null&&e.type!==`dateRange`&&Se(e.key);let B=l.filter(e=>!ge(e)),V=B.flatMap(e=>ve(e,u[e.key],De).map(t=>({...t,facet:e}))),H=B.filter(e=>!e.required&&t(e,u[e.key])),U=y||N?0:Math.max(0,v),W=B.slice(U),ke=W.filter(e=>H.includes(e)).length,G=!y&&W.length>0;f(()=>{if(!G)return;let e=e=>{let t=P.current;t?.open&&(e.type===`keydown`?e instanceof KeyboardEvent&&e.key===`Escape`:!e.composedPath().includes(t))&&(t.open=!1)};return document.addEventListener(`click`,e),document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`click`,e),document.removeEventListener(`keydown`,e)}},[G]),f(()=>{let e=z.current;z.current=u,R(t=>{let n=Object.entries(t).filter(([t])=>_e(e[t],u[t]));return n.length===Object.keys(t).length?t:Object.fromEntries(n)})},[u]);let K=e=>b&&!y&&(e.type===`text`||e.type===`dateRange`),q=e=>K(e)&&Object.hasOwn(L,e.key)?L[e.key]:u[e.key],J=e=>t=>K(e)?R(n=>({...n,[e.key]:t})):g(e.key,t),Y=()=>{for(let[e,t]of Object.entries(L))g(e,t);R({})},Ae=e=>{ie(e.nativeEvent)&&Y()},je=e=>{e.preventDefault(),Y()},X=(e,t)=>e.type===`text`&&K(e)?/* @__PURE__ */ m(`span`,{onKeyDownCapture:Ae,children:t}):t,Me=e=>/* @__PURE__ */ m(ae,{children:X(e,/* @__PURE__ */ m(k,{facet:e,value:q(e),onChange:J(e),medium:M,anyLabel:A}))},e.key),Z=e=>/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-field`,children:[/* @__PURE__ */ m(`span`,{className:`label`,"aria-hidden":`true`,children:e.label}),X(e,/* @__PURE__ */ m(k,{facet:e,value:q(e),onChange:J(e),floating:!0,medium:M,anyLabel:A}))]},e.key),Q=(e,t)=>t>0&&/* @__PURE__ */ m(`span`,{className:e,children:` (${t})`}),Ne=e=>/* @__PURE__ */ m(ee,{size:`sm`,label:`${e.facet.label}: ${e.text}`,removeLabel:r(Ce,{facet:e.facet.label,value:e.text}),onRemove:()=>g(e.facet.key,e.clear()),className:!y&&B.indexOf(e.facet)<U?`wui-filter-chip-inline`:void 0},e.id),Pe=/* @__PURE__ */ m(o,{variant:`ghost`,size:M?void 0:`sm`,onClick:()=>{for(let t of H)g(t.key,e(t));R({})},children:C});if(y){let e=V.slice(_),t=H.length;return/* @__PURE__ */ h(`div`,{className:`wui-filter-bar d-flex flex-wrap align-items-center gap-2${S?` ${S}`:``}`,...s,...j,children:[/* @__PURE__ */ h(`wui-filter-popover`,{class:`wui-filter-popover`,children:[/* @__PURE__ */ h(o,{variant:t>0?`outline`:`ghost`,size:M?void 0:`sm`,leftIcon:`filter`,className:`wui-filter-popover-trigger`,"aria-expanded":`false`,"aria-controls":I,"aria-label":t>0?r(T,{count:t}):void 0,children:[w,t>0&&/* @__PURE__ */ m(`span`,{className:`badge rounded-pill text-bg-primary ms-1`,children:t})]}),/* @__PURE__ */ h(`div`,{id:I,className:`wui-filter-popover-panel`,popover:`auto`,role:`dialog`,"aria-label":w,children:[/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-head`,children:[/* @__PURE__ */ m(`span`,{className:`wui-filter-popover-title`,children:w}),/* @__PURE__ */ m(ne,{label:E,id:`${I}-pin`})]}),/* @__PURE__ */ m(`div`,{className:`wui-filter-popover-grid`,children:B.map(Z)}),/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-foot`,children:[/* @__PURE__ */ m(`span`,{className:`wui-filter-popover-note`,children:D}),t>0&&Pe]})]})]}),V.slice(0,_).map(Ne),e.length>0&&/* @__PURE__ */ h(`span`,{className:`chip chip-sm wui-filter-popover-more`,title:e.map(e=>`${e.facet.label}: ${e.text}`).join(`, `),children:[`+`,e.length]})]})}let Fe=`wui-filter-bar d-flex flex-wrap align-items-center gap-2${N&&G?` wui-filter-bar--folded`:``}`,Ie=e=>`${e}${S?` ${S}`:``}`,$=/* @__PURE__ */ h(le,{children:[B.slice(0,U).map(Me),G&&/* @__PURE__ */ h(`details`,{ref:P,className:`wui-filter-more`,children:[/* @__PURE__ */ h(`summary`,{className:`btn btn-outline-primary${M?``:` btn-sm`} wui-filter-more-trigger`,onClick:Oe,children:[/* @__PURE__ */ m(te,{name:`filter`,size:14,className:`me-2`}),w,Q(`wui-filter-count-desktop`,ke),Q(`wui-filter-count-phone`,H.length)]}),/* @__PURE__ */ h(`div`,{ref:F,className:`wui-filter-more-panel`,children:[/* @__PURE__ */ m(`div`,{className:`wui-filter-more-head`,children:w}),W.map(Z)]})]}),V.map(Ne),H.length>0&&Pe]});return!b||!B.some(e=>e.type===`text`||e.type===`dateRange`)?/* @__PURE__ */ m(`div`,{className:Ie(Fe),...s,...j,children:$}):/* @__PURE__ */ h(`div`,{className:Ie(`wui-filter-form d-flex flex-wrap align-items-center gap-2`),...s,...j,children:[/* @__PURE__ */ m(`div`,{className:Fe,children:$}),/* @__PURE__ */ m(o,{type:`submit`,size:M?void 0:`sm`,onClick:je,children:O})]})}function k({facet:e,value:t,onChange:n,floating:r=!1,medium:i=!1,anyLabel:a}){if(e.type===`enum`){let o=e.options??[];return(e.required?o.length<=v:o.length<v)?/* @__PURE__ */ m(l,{label:e.label,name:e.key,size:i?`md`:`sm`,value:x(e,t),onChange:n,options:e.required?o:[{value:``,label:e.allLabel||`All`},...o]}):/* @__PURE__ */ m(u,{"aria-label":e.label,name:e.key,placeholder:r?a:e.label,clearable:!e.required,size:i?void 0:`sm`,value:x(e,t),onChange:n,options:o})}return e.type===`multiEnum`?/* @__PURE__ */ m(u,{mode:`multiple`,"aria-label":e.label,name:e.key,placeholder:r?a:e.label,size:i?void 0:`sm`,collapseChips:!0,value:S(e,t),onChange:n,options:e.options??[]}):e.type===`dateRange`?/* @__PURE__ */ m(s,{ariaLabel:e.label,startName:`${e.key}From`,endName:`${e.key}To`,placeholder:r?a:e.label,size:i?void 0:`sm`,presets:e.presets,start:C(e,t).from,end:C(e,t).to,onChange:e=>n({from:e.start??``,to:e.end??``})}):/* @__PURE__ */ m(c,{ariaLabel:e.label,name:e.key,placeholder:e.label,size:i?void 0:`sm`,value:x(e,t),onChange:n})}export{O as default};
1
+ import{emptyFacetValue as e,isFacetActive as t}from"../web-core/dist/query/listQuery.js";import{devWarn as n}from"../lib/devWarn.js";import r from"../lib/useElementEntry.js";import i from"../lib/useWuiText.js";import{splitMarkerProps as a}from"../lib/wuiMarker.js";import o from"./AppButton.js";import s from"./AppChip.js";import c from"./AppDateRangePicker.js";import ee from"./AppIcon.js";import l from"./AppSearch.js";import te from"./AppSegmented.js";import u from"./AppSelect.js";import ne from"./AppSwitch.js";import d from"./assertValidValue.js";import re from"./warnUnknownProps.js";import{isImeSafeEnter as ie}from"@webority/ui-elements/helpers";import{Fragment as ae,useEffect as f,useId as oe,useRef as p,useState as se,useSyncExternalStore as ce}from"react";import{Fragment as le,jsx as m,jsxs as h}from"react/jsx-runtime";import{FILTER_BAR_TEXT as g,fillText as _}from"@webority/ui-elements/text";var v=`(max-width: 575.98px)`,ue=3,y=2,de=e=>{let t=window.matchMedia?.(v);return t?.addEventListener(`change`,e),()=>t?.removeEventListener(`change`,e)},fe=()=>window.matchMedia?.(v).matches??!1,pe=[`enum`,`multiEnum`,`dateRange`,`text`],me=[`sm`,`md`],he=()=>import(`@webority/ui-elements/elements/filter-popover`),b=4,ge=e=>(e.type===`enum`||e.type===`multiEnum`)&&!e.options?.length,x=(e,t)=>e.options?.find(e=>e.value===t)?.label??t,_e=(e,t)=>JSON.stringify(e)===JSON.stringify(t),S=(e,t,n)=>/* @__PURE__ */ RangeError(`[@webority/ui-react] <AppFilterBar> facet "${e.key}" needs ${t}, received ${JSON.stringify(n)}.`),C=(e,t)=>{if(t==null)return``;if(typeof t==`string`)return t;throw S(e,`a string value`,t)},w=(e,t)=>{if(t==null)return[];if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return t;throw S(e,`an array of strings`,t)},T=(e,t)=>{if(t==null)return{from:``,to:``};if(typeof t==`object`&&!Array.isArray(t)&&!(t instanceof Date)){let{from:e,to:n}=t;if((e===void 0||typeof e==`string`)&&(n===void 0||typeof n==`string`))return{from:e,to:n}}throw S(e,`a { from, to } date range`,t)};function ve(n,r,i){if(n.required||!t(n,r))return[];if(n.type===`enum`)return[{id:n.key,text:x(n,C(n,r)),clear:()=>e(n)}];if(n.type===`multiEnum`){let e=w(n,r);return e.map(t=>({id:`${n.key}:${t}`,text:x(n,t),clear:()=>e.filter(e=>e!==t)}))}if(n.type===`dateRange`){let t=T(n,r),a=t.from&&t.to?_(i.range,{from:t.from,to:t.to}):t.from?_(i.from,{date:t.from}):_(i.until,{date:t.to??``});return[{id:n.key,text:a,clear:()=>e(n)}]}return[]}var E=/* @__PURE__ */ new Set;function ye(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!E.has(e)&&(E.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets allLabel, which only an enum facet uses.`))}var D=/* @__PURE__ */ new Set;function be(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!D.has(e)&&(D.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets required, which only an enum facet uses.`))}var O=/* @__PURE__ */ new Set;function xe(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!O.has(e)&&(O.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets allLabel and required; a required facet has no All segment.`))}var k=/* @__PURE__ */ new Set;function Se(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!k.has(e)&&(k.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets presets, which only a dateRange facet uses.`))}var A=/* @__PURE__ */ new Set;function Ce(e){let t=!0;try{t=process.env.NODE_ENV!==`production`}catch{t=!0}t&&!A.has(e)&&(A.add(e),n(`[@webority/ui-react] <AppFilterBar> facet "${e}" sets count or icon on an option, which only an enum facet drawn as segments shows.`))}var we=e=>{let t=e.options?.length??0;return e.type===`enum`&&(e.required?t<=b:t<b)};function j(n){r(`wui-filter-popover`,he);let c=i(`filterBar`,g),{marker:l,props:te}=a(`AppFilterBar`,n),{facets:u,value:v,onChange:b,onChangeMany:x,inline:S=ue,facetLabels:C=!1,floating:w=!1,apply:T=!1,size:E=`sm`,className:D=``,clearAllLabel:O=c.clearAllLabel,filtersLabel:k=c.filtersLabel,filtersActiveLabel:A=c.filtersActiveLabel,keepOpenLabel:j=c.keepOpenLabel,appliesAtOnceText:Te=c.appliesAtOnceText,applyLabel:Ee=c.applyLabel,anyLabel:N=c.anyLabel,removeChipLabel:De=c.removeChipLabel,dateFromText:Oe=c.dateFromText,dateUntilText:ke=c.dateUntilText,dateRangeText:Ae=c.dateRangeText,...P}=te;re(`AppFilterBar`,P),d(`AppFilterBar`,`size`,E,me);let F=E===`md`,je={range:Ae,from:Oe,until:ke},I=ce(de,fe,()=>!1),L=p(null),R=p(null),Me=e=>{let t=L.current,n=R.current;t&&n&&(e.preventDefault(),t.open=!t.open,n.classList.remove(`wui-filter-more-panel-end`),t.open&&n.getBoundingClientRect().right>window.innerWidth-8&&n.classList.add(`wui-filter-more-panel-end`))},z=oe(),[B,V]=se({}),H=p(v);for(let e of u)d(`AppFilterBar`,`facets[].type`,e.type,pe);for(let e of u)e.allLabel!=null&&e.type!==`enum`&&ye(e.key),e.required&&e.type!==`enum`&&be(e.key),e.required&&e.allLabel!=null&&xe(e.key),e.presets!=null&&e.type!==`dateRange`&&Se(e.key),e.options?.some(e=>e.count!=null||e.icon!=null)&&!we(e)&&Ce(e.key);let U=u.filter(e=>!ge(e)),W=U.flatMap(e=>ve(e,v[e.key],je).map(t=>({...t,facet:e}))),G=U.filter(e=>!e.required&&t(e,v[e.key])),K=w||I?0:Math.max(0,S),q=U.slice(K),Ne=q.filter(e=>G.includes(e)).length,J=!w&&q.length>0;f(()=>{if(!J)return;let e=e=>{let t=L.current;t?.open&&(e.type===`keydown`?e instanceof KeyboardEvent&&e.key===`Escape`:!e.composedPath().includes(t))&&(t.open=!1)};return document.addEventListener(`click`,e),document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`click`,e),document.removeEventListener(`keydown`,e)}},[J]),f(()=>{let e=H.current;H.current=v,V(t=>{let n=Object.entries(t).filter(([t])=>_e(e[t],v[t]));return n.length===Object.keys(t).length?t:Object.fromEntries(n)})},[v]);let Y=e=>T&&!w&&(e.type===`text`||e.type===`dateRange`),X=e=>Y(e)&&Object.hasOwn(B,e.key)?B[e.key]:v[e.key],Z=e=>t=>Y(e)?V(n=>({...n,[e.key]:t})):b(e.key,t),Q=e=>{let t=Object.entries(e);if(t.length!==0){if(x)x(e);else for(let[e,n]of t)b(e,n)}},$=()=>{Q(B),V({})},Pe=e=>{ie(e.nativeEvent)&&$()},Fe=e=>{e.preventDefault(),$()},Ie=(e,t)=>e.type===`text`&&Y(e)?/* @__PURE__ */ m(`span`,{onKeyDownCapture:Pe,children:t}):t,Le=(e,t)=>C?/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-field wui-filter-facet`,children:[/* @__PURE__ */ m(`span`,{className:`label`,"aria-hidden":`true`,children:e.label}),t]},e.key):t,Re=e=>Le(e,/* @__PURE__ */ m(ae,{children:Ie(e,/* @__PURE__ */ m(M,{facet:e,value:X(e),onChange:Z(e),medium:F,anyLabel:N}))},e.key)),ze=e=>/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-field`,children:[/* @__PURE__ */ m(`span`,{className:`label`,"aria-hidden":`true`,children:e.label}),Ie(e,/* @__PURE__ */ m(M,{facet:e,value:X(e),onChange:Z(e),floating:!0,medium:F,anyLabel:N}))]},e.key),Be=(e,t)=>t>0&&/* @__PURE__ */ m(`span`,{className:e,children:` (${t})`}),Ve=e=>/* @__PURE__ */ m(s,{size:`sm`,label:`${e.facet.label}: ${e.text}`,removeLabel:_(De,{facet:e.facet.label,value:e.text}),onRemove:()=>b(e.facet.key,e.clear()),className:!w&&U.indexOf(e.facet)<K?`wui-filter-chip-inline`:void 0},e.id),He=/* @__PURE__ */ m(o,{variant:`ghost`,size:F?void 0:`sm`,onClick:()=>{Q(Object.fromEntries(G.map(t=>[t.key,e(t)]))),V({})},children:O});if(w){let e=W.slice(y),t=G.length;return/* @__PURE__ */ h(`div`,{className:`wui-filter-bar d-flex flex-wrap align-items-center gap-2${D?` ${D}`:``}`,...l,...P,children:[/* @__PURE__ */ h(`wui-filter-popover`,{class:`wui-filter-popover`,children:[/* @__PURE__ */ h(o,{variant:t>0?`outline`:`ghost`,size:F?void 0:`sm`,leftIcon:`filter`,className:`wui-filter-popover-trigger`,"aria-expanded":`false`,"aria-controls":z,"aria-label":t>0?_(A,{count:t}):void 0,children:[k,t>0&&/* @__PURE__ */ m(`span`,{className:`badge rounded-pill text-bg-primary ms-1`,children:t})]}),/* @__PURE__ */ h(`div`,{id:z,className:`wui-filter-popover-panel`,popover:`auto`,role:`dialog`,"aria-label":k,children:[/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-head`,children:[/* @__PURE__ */ m(`span`,{className:`wui-filter-popover-title`,children:k}),/* @__PURE__ */ m(ne,{label:j,id:`${z}-pin`})]}),/* @__PURE__ */ m(`div`,{className:`wui-filter-popover-grid`,children:U.map(ze)}),/* @__PURE__ */ h(`div`,{className:`wui-filter-popover-foot`,children:[/* @__PURE__ */ m(`span`,{className:`wui-filter-popover-note`,children:Te}),t>0&&He]})]})]}),W.slice(0,y).map(Ve),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 Ue=`wui-filter-bar d-flex flex-wrap align-items-center gap-2${I&&J?` wui-filter-bar--folded`:``}`,We=e=>`${e}${D?` ${D}`:``}`,Ge=/* @__PURE__ */ h(le,{children:[U.slice(0,K).map(Re),J&&/* @__PURE__ */ h(`details`,{ref:L,className:`wui-filter-more`,children:[/* @__PURE__ */ h(`summary`,{className:`btn btn-outline-primary${F?``:` btn-sm`} wui-filter-more-trigger`,onClick:Me,children:[/* @__PURE__ */ m(ee,{name:`filter`,size:14,className:`me-2`}),k,Be(`wui-filter-count-desktop`,Ne),Be(`wui-filter-count-phone`,G.length)]}),/* @__PURE__ */ h(`div`,{ref:R,className:`wui-filter-more-panel`,children:[/* @__PURE__ */ m(`div`,{className:`wui-filter-more-head`,children:k}),q.map(ze)]})]}),W.map(Ve),G.length>0&&He]});return!T||!U.some(e=>e.type===`text`||e.type===`dateRange`)?/* @__PURE__ */ m(`div`,{className:We(Ue),...l,...P,children:Ge}):/* @__PURE__ */ h(`div`,{className:We(`wui-filter-form d-flex flex-wrap align-items-center gap-2`),...l,...P,children:[/* @__PURE__ */ m(`div`,{className:Ue,children:Ge}),/* @__PURE__ */ m(o,{type:`submit`,size:F?void 0:`sm`,onClick:Fe,children:Ee})]})}function M({facet:e,value:t,onChange:n,floating:r=!1,medium:a=!1,anyLabel:o}){let s=i(`filterBar`,g);if(e.type===`enum`){let i=e.options??[];return(e.required?i.length<=b:i.length<b)?/* @__PURE__ */ m(te,{label:e.label,name:e.key,size:a?`md`:`sm`,value:C(e,t),onChange:n,options:e.required?i:[{value:``,label:e.allLabel||s.allLabel},...i]}):/* @__PURE__ */ m(u,{"aria-label":e.label,name:e.key,placeholder:r?o:e.label,clearable:!e.required,size:a?void 0:`sm`,value:C(e,t),onChange:n,options:i})}return e.type===`multiEnum`?/* @__PURE__ */ m(u,{mode:`multiple`,"aria-label":e.label,name:e.key,placeholder:r?o:e.label,size:a?void 0:`sm`,collapseChips:!0,value:w(e,t),onChange:n,options:e.options??[]}):e.type===`dateRange`?/* @__PURE__ */ m(c,{ariaLabel:e.label,startName:`${e.key}From`,endName:`${e.key}To`,placeholder:r?o:e.label,size:a?void 0:`sm`,presets:e.presets,start:T(e,t).from,end:T(e,t).to,onChange:e=>n({from:e.start??``,to:e.end??``})}):/* @__PURE__ */ m(l,{ariaLabel:e.label,name:e.key,placeholder:e.label,size:a?void 0:`sm`,value:C(e,t),onChange:n})}export{j as default};
@@ -1 +1 @@
1
- import{linkTarget as e}from"../lib/linkTarget.js";import{TargetLink as t}from"../lib/TargetLink.js";import n from"../lib/useElementEntry.js";import{splitMarkerProps as r}from"../lib/wuiMarker.js";import i from"./renderIconProp.js";import a from"./warnUnknownProps.js";import{Fragment as o,jsx as s,jsxs as c}from"react/jsx-runtime";var l=()=>import(`@webority/ui-elements/elements/dock`);function u(u){n(`wui-dock`,l);let{marker:d,props:f}=r(`AppFloatingDock`,u),{items:p=[],linkComponent:m,ariaLabel:h=`Quick navigation`,magnify:g=!0,maxScale:_,radius:v,className:y=``,...b}=f;return a(`AppFloatingDock`,b),/* @__PURE__ */ s(`wui-dock`,{role:`navigation`,"aria-label":h,static:g?void 0:``,"max-scale":_??void 0,radius:v??void 0,class:y||void 0,...d,...b,children:p.map((n,r)=>{let a=n.key??`${n.title}-${r}`,l=/* @__PURE__ */ c(o,{children:[/* @__PURE__ */ s(`span`,{className:`dock-item-tip`,"aria-hidden":`true`,children:n.title}),/* @__PURE__ */ s(`span`,{className:`dock-item-icon`,children:i(n.icon,{size:18})})]});if(n.to&&m){let r=e(m,{to:n.to});return/* @__PURE__ */ s(t,{link:r,className:`dock-item`,"aria-label":n.title,children:l},a)}let u=n.href??n.to;return u?/* @__PURE__ */ s(`a`,{className:`dock-item`,href:u,"aria-label":n.title,children:l},a):/* @__PURE__ */ s(`button`,{type:`button`,className:`dock-item`,onClick:n.onClick,"aria-label":n.title,children:l},a)})})}export{u as default};
1
+ import{linkTarget as e}from"../lib/linkTarget.js";import{TargetLink as t}from"../lib/TargetLink.js";import n from"../lib/useElementEntry.js";import r from"../lib/useWuiText.js";import{splitMarkerProps as i}from"../lib/wuiMarker.js";import a from"./renderIconProp.js";import o from"./warnUnknownProps.js";import{Fragment as s,jsx as c,jsxs as l}from"react/jsx-runtime";import{FLOATING_DOCK_TEXT as u}from"@webority/ui-elements/text";var d=()=>import(`@webority/ui-elements/elements/dock`);function f(f){n(`wui-dock`,d);let{marker:p,props:m}=i(`AppFloatingDock`,f),h=r(`floatingDock`,u),{items:g=[],linkComponent:_,ariaLabel:v=h.ariaLabel,magnify:y=!0,maxScale:b,radius:x,className:S=``,...C}=m;return o(`AppFloatingDock`,C),/* @__PURE__ */ c(`wui-dock`,{role:`navigation`,"aria-label":v,static:y?void 0:``,"max-scale":b??void 0,radius:x??void 0,class:S||void 0,...p,...C,children:g.map((n,r)=>{let i=n.key??`${n.title}-${r}`,o=/* @__PURE__ */ l(s,{children:[/* @__PURE__ */ c(`span`,{className:`dock-item-tip`,"aria-hidden":`true`,children:n.title}),/* @__PURE__ */ c(`span`,{className:`dock-item-icon`,children:a(n.icon,{size:18})})]});if(n.to&&_){let r=e(_,{to:n.to});return/* @__PURE__ */ c(t,{link:r,className:`dock-item`,"aria-label":n.title,children:o},i)}let u=n.href??n.to;return u?/* @__PURE__ */ c(`a`,{className:`dock-item`,href:u,"aria-label":n.title,children:o},i):/* @__PURE__ */ c(`button`,{type:`button`,className:`dock-item`,onClick:n.onClick,"aria-label":n.title,children:o},i)})})}export{f as default};
@@ -1 +1 @@
1
- import{newIdempotencyKey as e}from"../web-core/dist/api/idempotencyKey.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./warnUnknownProps.js";import{createContext as r,useCallback as i,useContext as a,useMemo as o,useRef as s,useState as c}from"react";import{jsx as l}from"react/jsx-runtime";var u=r(null);function d(){let e=a(u);if(e===null)throw Error(`useFormSubmit must be called inside an AppForm`);return e}function f(r){let{marker:a,props:d}=t(`AppForm`,r),{onSubmit:f,className:p,children:m,noValidate:h,action:g,method:_,encType:v,acceptCharset:y,...b}=d;n(`AppForm`,b);let[x,S]=c(!1),[C,w]=c(e),T=s(!1),E=i(async t=>{if(t.preventDefault(),!T.current){T.current=!0,S(!0);try{await f(t,{idempotencyKey:C})&&w(e())}finally{T.current=!1,S(!1)}}},[f,C]),D=o(()=>({submitting:x,idempotencyKey:C}),[x,C]);return/* @__PURE__ */ l(u.Provider,{value:D,children:/* @__PURE__ */ l(`form`,{...a,...b,noValidate:h,action:g,method:_,encType:v,acceptCharset:y,className:p,onSubmit:E,"aria-busy":x||void 0,children:m})})}export{u as FormSubmitContext,f as default,d as useFormSubmit};
1
+ import{newIdempotencyKey as e}from"../web-core/dist/api/idempotencyKey.js";import t from"../lib/focusField.js";import{FormFieldsContext as n,toFieldName as r}from"../lib/formFields.js";import i from"../lib/useWuiText.js";import{splitMarkerProps as a}from"../lib/wuiMarker.js";import o from"./AppConfirmDialog.js";import s from"./AppIcon.js";import c from"./warnUnknownProps.js";import{createContext as l,useCallback as u,useContext as d,useEffect as f,useMemo as p,useRef as m,useState as h}from"react";import{jsx as g,jsxs as _}from"react/jsx-runtime";import{UNSAVED_CHANGES_TEXT as v}from"@webority/ui-elements/text";var y=l(null);function b(){let e=d(y);if(e===null)throw Error(`useFormSubmit must be called inside an AppForm`);return e}var x=/* @__PURE__ */ new Set,S=/* @__PURE__ */ new Map;function C(l){let{marker:d,props:b}=a(`AppForm`,l),C=i(`unsavedChanges`,v),{onSubmit:w,onChange:T,className:ee,children:E,noValidate:D,action:O,method:k,encType:A,acceptCharset:j,fieldErrors:M,formErrors:te,unsavedChanges:N,unsavedChangesMessage:P,...F}=b;c(`AppForm`,F);let[I,L]=h(!1),[R,z]=h(e),B=m(!1),[V,H]=h(null),U=p(()=>new Map(Object.entries(M??{}).map(([e,t])=>[r(e),t])),[M]),W=JSON.stringify([...U].sort(([e],[t])=>e<t?-1:+(e>t))),[G,K]=h({key:W,names:x}),q=G.key===W?G.names:x,J=u(e=>{T?.(e);let t=e.target;if(!(t instanceof HTMLElement)||!(`name`in t)||typeof t.name!=`string`||t.name===``)return;let n=r(t.name);U.has(n)&&K(e=>{let t=e.key===W?e.names:x;return t.has(n)?e:{key:W,names:/* @__PURE__ */ new Set([...t,n])}})},[T,U,W]),[Y,X]=h(S),Z=u(e=>(X(t=>new Map(t).set(e,(t.get(e)??0)+1)),()=>{X(t=>{let n=new Map(t),r=(t.get(e)??0)-1;return r>0?n.set(e,r):n.delete(e),n})}),[]),Q=u(e=>q.has(e)?void 0:U.get(e),[q,U]),ne=p(()=>({errorOf:Q,claim:Z}),[Q,Z]),$=[.../* @__PURE__ */ new Set([...te??[],...[...U].filter(([e])=>!Y.has(e)).map(([,e])=>e)])],re=u(async t=>{if(t.preventDefault(),B.current)return;B.current=!0,L(!0);let n=t.currentTarget;try{await w(t,{idempotencyKey:R})?z(e()):H({form:n})}finally{B.current=!1,L(!1)}},[w,R]);f(()=>{if(V===null)return;let{form:e}=V;if(H(null),e.querySelector(`.wui-error-summary`)!==null)return;let n=[...e.querySelectorAll(`[name]`)].map(e=>e.getAttribute(`name`)).find(e=>e!==null&&U.has(r(e)));n!==void 0&&t(n)},[V,U]);let ie=p(()=>({submitting:I,idempotencyKey:R}),[I,R]);return/* @__PURE__ */ g(n.Provider,{value:ne,children:/* @__PURE__ */ _(y.Provider,{value:ie,children:[/* @__PURE__ */ _(`form`,{...d,...F,noValidate:D,action:O,method:k,encType:A,acceptCharset:j,className:ee,onChange:J,onSubmit:re,"aria-busy":I||void 0,children:[$.length>0?/* @__PURE__ */ _(`div`,{role:`alert`,className:`alert alert-danger alert-has-icon`,"data-wui-form-errors":``,children:[/* @__PURE__ */ g(`span`,{className:`alert-icon`,children:/* @__PURE__ */ g(s,{name:`x`,size:11})}),/* @__PURE__ */ g(`div`,{className:`alert-content`,children:$.length===1?$[0]:$.map(e=>/* @__PURE__ */ g(`div`,{children:e},e))})]}):null,E]}),N?.blocked?/* @__PURE__ */ g(o,{open:!0,title:C.title,description:P??C.message,confirmLabel:C.leaveLabel,onConfirm:N.discard,onClose:N.keep}):null]})})}export{y as FormSubmitContext,C as default,b as useFormSubmit};
@@ -0,0 +1 @@
1
+ import e from"../lib/useWuiText.js";import{splitMarkerProps as t}from"../lib/wuiMarker.js";import n from"./assertValidValue.js";import r from"./warnUnknownProps.js";import{jsx as i,jsxs as a}from"react/jsx-runtime";import{FORMULA_STEPS_TEXT as o}from"@webority/ui-elements/text";var s=[`plus`,`minus`,`times`,`divide`,`equal`],c={plus:`+`,minus:`−`,times:`×`,divide:`÷`,equal:`=`};function l(l){let u=e(`formulaSteps`,o),{marker:d,props:f}=t(`AppFormulaSteps`,l),{steps:p=[],label:m=u.label,plusLabel:h=u.plusLabel,minusLabel:g=u.minusLabel,timesLabel:_=u.timesLabel,divideLabel:v=u.divideLabel,equalLabel:y=u.equalLabel,className:b=``,...x}=f;r(`AppFormulaSteps`,x);for(let e of p)n(`AppFormulaSteps`,`steps[].sign`,e.sign,s);let S={plus:h,minus:g,times:_,divide:v,equal:y},C=[`wui-formula-steps`,b].filter(Boolean).join(` `);return/* @__PURE__ */ i(`ol`,{className:C,"aria-label":m,...d,...x,children:p.map((e,t)=>/* @__PURE__ */ a(`li`,{className:e.sign===`equal`?`wui-formula-step wui-formula-step-total`:`wui-formula-step`,children:[/* @__PURE__ */ i(`span`,{className:`wui-formula-sign`,"aria-hidden":`true`,children:e.sign?c[e.sign]:null}),e.sign?/* @__PURE__ */ i(`span`,{className:`visually-hidden`,children:`${S[e.sign]} `}):null,/* @__PURE__ */ i(`span`,{className:`wui-formula-label`,children:e.label}),e.working?/* @__PURE__ */ i(`span`,{className:`wui-formula-working`,children:e.working}):null,/* @__PURE__ */ i(`span`,{className:`wui-formula-result`,children:e.result}),e.note?/* @__PURE__ */ i(`span`,{className:`wui-formula-note`,children:e.note}):null]},e.key??`${e.label}-${t}`))})}export{l as default};