@mmlogic/components 0.5.13 → 0.5.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{cell-renderer-BBebjBVz.js → cell-renderer-CLVKTVVQ.js} +113 -1
- package/dist/cjs/{client-layout-CqVuJumR.js → client-layout-Eg2VwW-7.js} +2 -0
- package/dist/cjs/index.cjs.js +2 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mosterdcomponents.cjs.js +1 -1
- package/dist/cjs/{mrd-boolean-field_25.cjs.entry.js → mrd-boolean-field_28.cjs.entry.js} +1163 -356
- package/dist/cjs/mrd-merge-view.cjs.entry.js +4 -4
- package/dist/collection/collection-manifest.json +3 -0
- package/dist/collection/components/fields/mrd-textarea-field/mrd-textarea-field.js +47 -2
- package/dist/collection/components/form/mrd-form/mrd-form.css +29 -0
- package/dist/collection/components/form/mrd-form/mrd-form.js +44 -8
- package/dist/collection/components/layout/mrd-layout-section/mrd-layout-section.js +126 -13
- package/dist/collection/components/memo/mrd-memo-container/mrd-memo-container.css +204 -0
- package/dist/collection/components/memo/mrd-memo-container/mrd-memo-container.js +694 -0
- package/dist/collection/components/memo/mrd-memo-list/mrd-memo-list.css +150 -0
- package/dist/collection/components/memo/mrd-memo-list/mrd-memo-list.js +511 -0
- package/dist/collection/components/memo/mrd-memo-view/mrd-memo-view.css +108 -0
- package/dist/collection/components/memo/mrd-memo-view/mrd-memo-view.js +204 -0
- package/dist/collection/components/merge/mrd-merge-view/mrd-merge-view.js +2 -2
- package/dist/collection/components/table/mrd-table/mrd-table.css +36 -0
- package/dist/collection/components/table/mrd-table/mrd-table.js +146 -31
- package/dist/collection/components/table/mrd-table/table-parts.js +6 -2
- package/dist/collection/components/table/mrd-table/table-query.js +6 -0
- package/dist/collection/dev/app.js +17 -0
- package/dist/collection/types/client-layout.js +1 -0
- package/dist/collection/utils/i18n.js +112 -0
- package/dist/collection/utils/query-params.js +9 -0
- package/dist/components/client-layout.js +1 -1
- package/dist/components/i18n.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/mrd-form.js +1 -1
- package/dist/components/mrd-layout-section.js +1 -1
- package/dist/components/mrd-memo-container.d.ts +11 -0
- package/dist/components/mrd-memo-container.js +1 -0
- package/dist/components/mrd-memo-container2.js +1 -0
- package/dist/components/mrd-memo-list.d.ts +11 -0
- package/dist/components/mrd-memo-list.js +1 -0
- package/dist/components/mrd-memo-list2.js +1 -0
- package/dist/components/mrd-memo-view.d.ts +11 -0
- package/dist/components/mrd-memo-view.js +1 -0
- package/dist/components/mrd-memo-view2.js +1 -0
- package/dist/components/mrd-merge-view.js +1 -1
- package/dist/components/mrd-table2.js +1 -1
- package/dist/components/mrd-textarea-field2.js +1 -1
- package/dist/components/query-params.js +1 -1
- package/dist/components/table-query.js +1 -0
- package/dist/esm/{cell-renderer-CC8-MtvQ.js → cell-renderer-4NKEzZWw.js} +113 -1
- package/dist/esm/{client-layout-Bc42CfJB.js → client-layout-BJkVeSq6.js} +2 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mosterdcomponents.js +1 -1
- package/dist/esm/{mrd-boolean-field_25.entry.js → mrd-boolean-field_28.entry.js} +1161 -357
- package/dist/esm/mrd-merge-view.entry.js +4 -4
- package/dist/mosterdcomponents/index.esm.js +1 -1
- package/dist/mosterdcomponents/mosterdcomponents.esm.js +1 -1
- package/dist/mosterdcomponents/{p-Bc42CfJB.js → p-BJkVeSq6.js} +1 -1
- package/dist/mosterdcomponents/p-BMx6VAJ6.js +1 -0
- package/dist/mosterdcomponents/p-d64ba1f2.entry.js +3 -0
- package/dist/mosterdcomponents/{p-a7e8f6a3.entry.js → p-e68dfbb0.entry.js} +1 -1
- package/dist/types/components/fields/mrd-textarea-field/mrd-textarea-field.d.ts +10 -0
- package/dist/types/components/form/mrd-form/mrd-form.d.ts +6 -0
- package/dist/types/components/layout/mrd-layout-section/mrd-layout-section.d.ts +20 -1
- package/dist/types/components/memo/mrd-memo-container/mrd-memo-container.d.ts +152 -0
- package/dist/types/components/memo/mrd-memo-list/mrd-memo-list.d.ts +79 -0
- package/dist/types/components/memo/mrd-memo-view/mrd-memo-view.d.ts +33 -0
- package/dist/types/components/table/mrd-table/mrd-table.d.ts +48 -1
- package/dist/types/components/table/mrd-table/table-parts.d.ts +15 -0
- package/dist/types/components/table/mrd-table/table-query.d.ts +6 -0
- package/dist/types/components.d.ts +528 -1
- package/dist/types/types/client-layout.d.ts +1 -0
- package/dist/types/utils/query-params.d.ts +16 -0
- package/package.json +1 -1
- package/dist/mosterdcomponents/p-07b148b2.entry.js +0 -3
- package/dist/mosterdcomponents/p-D5ZPfX3-.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as r,r as e,c as i,H as o,g as d}from"./p-CDiBvvJU.js";import{a as t}from"./p-Bc42CfJB.js";import{t as a,C as s,a as m}from"./p-D5ZPfX3-.js";function n(r){return r.type===t.FIELD||r.type===t.RELATION&&!r.multiple}function l(r,e){var i,o,d,a,s;const m=null!==(i=r.name)&&void 0!==i?i:"";return r.type===t.RELATION?null!==(a=null===(d=null===(o=null==e?void 0:e._links)||void 0===o?void 0:o[m])||void 0===d?void 0:d.href)&&void 0!==a?a:null:null!==(s=null==e?void 0:e[m])&&void 0!==s?s:null}function c(r,e){return r.historyEnabled&&null!=e&&"object"==typeof e&&!Array.isArray(e)&&"current"in e?e.current:e}function v(r){return void 0===r||""===r?null:r}function g(r,e){const i=v(r),o=v(e);return i===o||null!==i&&null!==o&&JSON.stringify(i)===JSON.stringify(o)}function u(r){return null===v(r)}function h(r,e,i){const o=[],d=[];for(const t of r.filter(n)){const r=l(t,e),a=l(t,i),s=c(t,r),m=c(t,a);g(s,m)||(u(s)&&!u(m)?d.push({item:t,aValue:r,bValue:a}):o.push({item:t,aValue:r,bValue:a}))}return{conflicts:o,autoFilled:d}}function _(r){var e,i,o,d,t;return null!==(t=null!==(i=null!==(e=null==r?void 0:r.name)&&void 0!==e?e:null==r?void 0:r.label)&&void 0!==i?i:null===(d=null===(o=null==r?void 0:r._links)||void 0===o?void 0:o.self)||void 0===d?void 0:d.href)&&void 0!==t?t:""}function w(r,e){var i,o;return r.historyEnabled&&r.name&&null!==(o=null===(i=null==e?void 0:e[r.name])||void 0===i?void 0:i.history)&&void 0!==o?o:[]}const p=({locale:e,history:i,isOpen:o,onToggle:d})=>{if(0===i.length)return null;const t=[...i].sort(((r,e)=>e.until.localeCompare(r.until)));return r("span",{class:"mrd-merge-view__history-wrap"},r("button",{type:"button",class:"mrd-merge-view__history-btn",title:a("history_badge_tooltip",e),"aria-label":a("history_badge_tooltip",e),onClick:r=>{r.stopPropagation(),d()}},r("svg",{class:"mrd-merge-view__history-icon",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},r("path",{"fill-rule":"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm.75-13a.75.75 0 00-1.5 0v5c0 .207.085.394.22.53l2.5 2.5a.75.75 0 101.06-1.06L10.75 9.69V5z","clip-rule":"evenodd"}))),o&&r("div",{class:"mrd-merge-view__history-popover",role:"listbox"},t.map(((i,o)=>r("div",{key:String(o),class:"mrd-merge-view__history-entry"},i.value," (",a("history_until",e)," ",m(i.until,e),")")))))},b=({locale:e,searchQuery:i,searchResults:o,isLoading:d,onSearchInput:t,onSelect:s})=>r("div",{class:"mrd-merge-view__search-step"},r("p",{class:"mrd-merge-view__hint"},a("merge_search_hint",e)),r("div",{class:"mrd-merge-view__search-wrapper"},r("input",{class:"mrd-merge-view__search",type:"text",value:i,placeholder:a("search_placeholder",e),onInput:r=>t(r.target.value)}),d&&r("span",{class:"mrd-merge-view__spinner","aria-label":a("loading",e)})),i.trim().length>=2&&!d&&r("div",{class:"mrd-merge-view__results"},0===o.length?r("div",{class:"mrd-merge-view__no-results"},a("no_results",e)):o.map((i=>{var o,d,t;return r("div",{key:null!==(t=null===(d=null===(o=null==i?void 0:i._links)||void 0===o?void 0:o.self)||void 0===d?void 0:d.href)&&void 0!==t?t:_(i),class:"mrd-merge-view__result-item"},r("span",{class:"mrd-merge-view__result-label"},_(i)),r("button",{type:"button",class:"mrd-merge-view__btn mrd-merge-view__btn--secondary",onClick:()=>s(i)},a("merge_select",e)))})))),f=({locale:e,currentLabel:i,candidateLabel:o,conflicts:d,autoFilled:t,recordA:m,recordB:n,resolutions:l,openHistoryKey:c,onResolve:v,onToggleHistory:g,onChangeCandidate:u,onContinue:h})=>r("div",{class:"mrd-merge-view__compare-step"},r("h3",{class:"mrd-merge-view__heading"},a("merge_compare_heading",e)),0===d.length?r("p",{class:"mrd-merge-view__no-conflicts"},a("merge_no_conflicts",e)):r("table",{class:"mrd-merge-view__table"},r("thead",null,r("tr",null,r("th",{class:"mrd-merge-view__header"}),r("th",{class:"mrd-merge-view__header"},a("merge_column_a",e),r("span",{class:"mrd-merge-view__header-name"},i)),r("th",{class:"mrd-merge-view__header"},a("merge_column_b",e),r("span",{class:"mrd-merge-view__header-name"},o)))),r("tbody",null,d.map((({item:i})=>{var o,d,t;const a=null!==(o=i.name)&&void 0!==o?o:"",u=null!==(d=l[a])&&void 0!==d?d:"A",h=w(i,m),_=w(i,n),b=`${a}:A`,f=`${a}:B`;return r("tr",{key:a,class:"mrd-merge-view__row"},r("td",{class:"mrd-merge-view__cell mrd-merge-view__cell--label"},null!==(t=i.label)&&void 0!==t?t:a),r("td",{class:"mrd-merge-view__cell"},r("label",{class:"mrd-merge-view__option"},r("input",{type:"radio",name:`merge-${a}`,checked:"A"===u,onChange:()=>v(a,"A")}),r("span",null,s.render(i,m,e)||"—")),r(p,{locale:e,history:h,isOpen:c===b,onToggle:()=>g(c===b?null:b)})),r("td",{class:"mrd-merge-view__cell"},r("label",{class:"mrd-merge-view__option"},r("input",{type:"radio",name:`merge-${a}`,checked:"B"===u,onChange:()=>v(a,"B")}),r("span",null,s.render(i,n,e)||"—")),r(p,{locale:e,history:_,isOpen:c===f,onToggle:()=>g(c===f?null:f)})))})))),t.length>0&&r("div",{class:"mrd-merge-view__auto-note"},r("p",null,a("merge_auto_heading",e)),r("ul",null,t.map((({item:e})=>{var i;return r("li",{key:e.name},null!==(i=e.label)&&void 0!==i?i:e.name)})))),r("div",{class:"mrd-merge-view__actions"},r("button",{type:"button",class:"mrd-merge-view__btn mrd-merge-view__btn--secondary",onClick:u},a("merge_back",e)),r("button",{type:"button",class:"mrd-merge-view__btn mrd-merge-view__btn--primary",onClick:h},a("merge_continue",e)))),y=({locale:e,candidateLabel:i,conflicts:o,autoFilled:d,resolutions:t,recordB:m,openHistoryKey:n,onToggleHistory:l,onBack:c,onConfirm:v})=>{const g=[...d,...o.filter((({item:r})=>{var e;return"B"===t[null!==(e=r.name)&&void 0!==e?e:""]}))];return r("div",{class:"mrd-merge-view__confirm-step"},r("h3",{class:"mrd-merge-view__heading"},a("merge_confirm_heading",e)),0===g.length?r("p",{class:"mrd-merge-view__no-conflicts"},a("merge_no_conflicts",e)):r("ul",{class:"mrd-merge-view__summary-list"},g.map((({item:i})=>{var o;const d=`${i.name}:confirm`;return r("li",{key:i.name},null!==(o=i.label)&&void 0!==o?o:i.name,": ",s.render(i,m,e)||"—",r(p,{locale:e,history:w(i,m),isOpen:n===d,onToggle:()=>l(n===d?null:d)}))}))),r("p",{class:"mrd-merge-view__warning"},a("merge_confirm_warning",e)," (",i,")"),r("div",{class:"mrd-merge-view__actions"},r("button",{type:"button",class:"mrd-merge-view__btn mrd-merge-view__btn--secondary",onClick:c},a("merge_back",e)),r("button",{type:"button",class:"mrd-merge-view__btn mrd-merge-view__btn--danger",onClick:v},a("merge_confirm_button",e))))},k=class{constructor(r){e(this,r),this.mrdSearch=i(this,"mrdSearch"),this.mrdMerge=i(this,"mrdMerge"),this.locale=navigator.language,this.basicType="",this.mostSignificantClass="",this.fields=[],this.currentHref="",this.currentRecord={},this.currentLabel="",this.step="search",this.searchQuery="",this.searchResults=[],this.isLoading=!1,this.candidate=null,this.resolutions={},this.openHistoryKey=null,this.historyClickOutside=null,this.searchDebounce=null,this.handleSearchInput=r=>{this.searchQuery=r,this.searchDebounce&&clearTimeout(this.searchDebounce),r.trim().length>=2?(this.isLoading=!0,this.searchDebounce=setTimeout((()=>{this.mrdSearch.emit({query:r,basicType:this.basicType,mostSignificantClass:this.mostSignificantClass||void 0})}),300)):(this.searchResults=[],this.isLoading=!1)},this.handleSelect=r=>{this.candidate=r;const{conflicts:e}=h(this.fields,this.currentRecord,r),i={};e.forEach((({item:r})=>{var e;i[null!==(e=r.name)&&void 0!==e?e:""]="A"})),this.resolutions=i,this.openHistoryKey=null,this.step="compare"},this.handleChangeCandidate=()=>{this.candidate=null,this.resolutions={},this.openHistoryKey=null,this.step="search"},this.handleResolve=(r,e)=>{this.resolutions=Object.assign(Object.assign({},this.resolutions),{[r]:e})},this.handleToggleHistory=r=>{this.openHistoryKey=r},this.handleContinue=()=>{this.step="confirm"},this.handleBack=()=>{this.step="compare"},this.handleConfirm=()=>{var r,e,i,o;if(!this.candidate)return;const d=function(r,e){var i,o,d;const t={};for(const{item:e,bValue:o}of r.autoFilled)t[null!==(i=e.name)&&void 0!==i?i:""]=o;for(const{item:i,bValue:a}of r.conflicts)"B"===e[null!==(o=i.name)&&void 0!==o?o:""]&&(t[null!==(d=i.name)&&void 0!==d?d:""]=a);return t}(h(this.fields,this.currentRecord,this.candidate),this.resolutions),t=null!==(o=null===(i=null===(e=null===(r=this.candidate)||void 0===r?void 0:r._links)||void 0===e?void 0:e.self)||void 0===i?void 0:i.href)&&void 0!==o?o:"";this.mrdMerge.emit({winnerHref:this.currentHref,loserHref:t,patch:d})}}connectedCallback(){this.historyClickOutside=r=>{this.el.contains(r.target)||(this.openHistoryKey=null)},document.addEventListener("mousedown",this.historyClickOutside)}disconnectedCallback(){this.historyClickOutside&&(document.removeEventListener("mousedown",this.historyClickOutside),this.historyClickOutside=null)}async setSearchResults(r){this.searchResults=(null!=r?r:[]).filter((r=>{var e,i,o;return(null!==(o=null===(i=null===(e=null==r?void 0:r._links)||void 0===e?void 0:e.self)||void 0===i?void 0:i.href)&&void 0!==o?o:null)!==this.currentHref})),this.isLoading=!1}async setLoading(r){this.isLoading=r}render(){var e,i;let d;if("search"===this.step)d=r(b,{key:"3adb36fb46aa7260641a46a2cf27cc0ef320876f",locale:this.locale,searchQuery:this.searchQuery,searchResults:this.searchResults,isLoading:this.isLoading,onSearchInput:this.handleSearchInput,onSelect:this.handleSelect});else{const o=h(this.fields,this.currentRecord,this.candidate),t=_(this.candidate);d="compare"===this.step?r(f,{locale:this.locale,currentLabel:this.currentLabel,candidateLabel:t,conflicts:o.conflicts,autoFilled:o.autoFilled,recordA:this.currentRecord,recordB:null!==(e=this.candidate)&&void 0!==e?e:{},resolutions:this.resolutions,openHistoryKey:this.openHistoryKey,onResolve:this.handleResolve,onToggleHistory:this.handleToggleHistory,onChangeCandidate:this.handleChangeCandidate,onContinue:this.handleContinue}):r(y,{locale:this.locale,candidateLabel:t,conflicts:o.conflicts,autoFilled:o.autoFilled,resolutions:this.resolutions,recordB:null!==(i=this.candidate)&&void 0!==i?i:{},openHistoryKey:this.openHistoryKey,onToggleHistory:this.handleToggleHistory,onBack:this.handleBack,onConfirm:this.handleConfirm})}return r(o,{key:"e33a6d66a220b28cc9533da78dc274e2d7ec5c4a"},r("div",{key:"b5fb1390d86192f9f6f15e3ccb89e2d21d9c7c8b",class:"mrd-merge-view"},d))}get el(){return d(this)}};k.style=".sc-mrd-merge-view-h{display:block;width:100%}.mrd-merge-view.sc-mrd-merge-view{font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-900)}.mrd-merge-view__hint.sc-mrd-merge-view{margin:0 0 var(--mrd-space-4);color:var(--mrd-color-neutral-600)}.mrd-merge-view__heading.sc-mrd-merge-view{margin:0 0 var(--mrd-space-4);font-size:var(--mrd-font-size-lg);font-weight:var(--mrd-font-weight-semibold)}.mrd-merge-view__search-wrapper.sc-mrd-merge-view{position:relative;display:flex;align-items:center}.mrd-merge-view__search.sc-mrd-merge-view{width:100%;height:var(--mrd-input-height);padding:var(--mrd-input-padding-y) var(--mrd-input-padding-x);border:var(--mrd-border-width) solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);background:var(--mrd-input-bg);color:var(--mrd-input-color);font-size:var(--mrd-font-size-sm)}.mrd-merge-view__search.sc-mrd-merge-view:focus{outline:none;border-color:var(--mrd-border-color-focus);box-shadow:var(--mrd-shadow-focus)}.mrd-merge-view__spinner.sc-mrd-merge-view{position:absolute;right:var(--mrd-space-3);width:1rem;height:1rem;border:2px solid var(--mrd-color-neutral-300);border-top-color:var(--mrd-color-primary);border-radius:var(--mrd-border-radius-full);animation:mrd-merge-view-spin var(--mrd-transition-slow) linear infinite}.mrd-merge-view__results.sc-mrd-merge-view{margin-top:var(--mrd-space-2);border:var(--mrd-border-width) solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);overflow:hidden}.mrd-merge-view__no-results.sc-mrd-merge-view{padding:var(--mrd-space-3) var(--mrd-space-4);color:var(--mrd-color-neutral-500)}.mrd-merge-view__result-item.sc-mrd-merge-view{display:flex;align-items:center;justify-content:space-between;gap:var(--mrd-space-3);padding:var(--mrd-space-2) var(--mrd-space-4)}.mrd-merge-view__result-item.sc-mrd-merge-view:not(:last-child){border-bottom:var(--mrd-border-width) solid var(--mrd-border-color)}.mrd-merge-view__result-label.sc-mrd-merge-view{font-weight:var(--mrd-font-weight-medium)}.mrd-merge-view__no-conflicts.sc-mrd-merge-view{color:var(--mrd-color-neutral-600)}.mrd-merge-view__table.sc-mrd-merge-view{width:100%;border-collapse:collapse;margin-bottom:var(--mrd-space-4)}.mrd-merge-view__header.sc-mrd-merge-view{text-align:left;padding:var(--mrd-space-2) var(--mrd-space-3);border-bottom:2px solid var(--mrd-border-color);font-size:var(--mrd-font-size-xs);text-transform:uppercase;letter-spacing:0.04em;color:var(--mrd-color-neutral-600)}.mrd-merge-view__header-name.sc-mrd-merge-view{display:block;text-transform:none;letter-spacing:normal;font-size:var(--mrd-font-size-sm);font-weight:var(--mrd-font-weight-medium);color:var(--mrd-color-neutral-900);margin-top:var(--mrd-space-1)}.mrd-merge-view__row.sc-mrd-merge-view:nth-child(even){background:var(--mrd-color-neutral-50)}.mrd-merge-view__cell.sc-mrd-merge-view{padding:var(--mrd-space-2) var(--mrd-space-3);border-bottom:var(--mrd-border-width) solid var(--mrd-border-color);vertical-align:top}.mrd-merge-view__cell--label.sc-mrd-merge-view{font-weight:var(--mrd-font-weight-medium);white-space:nowrap}.mrd-merge-view__option.sc-mrd-merge-view{display:flex;align-items:flex-start;gap:var(--mrd-space-2);cursor:pointer}.mrd-merge-view__option.sc-mrd-merge-view input[type=radio].sc-mrd-merge-view{margin-top:0.2em}.mrd-merge-view__history-wrap.sc-mrd-merge-view{position:relative;display:inline-flex;align-items:center;margin-left:var(--mrd-space-1)}.mrd-merge-view__history-btn.sc-mrd-merge-view{display:inline-flex;align-items:center;justify-content:center;width:1.25rem;height:1.25rem;padding:0;background:transparent;border:none;border-radius:var(--mrd-border-radius-sm);color:var(--mrd-color-neutral-400);cursor:pointer;flex-shrink:0;transition:color var(--mrd-transition-fast), background-color var(--mrd-transition-fast)}.mrd-merge-view__history-btn.sc-mrd-merge-view:hover{color:var(--mrd-color-neutral-700);background-color:var(--mrd-color-neutral-100)}.mrd-merge-view__history-btn.sc-mrd-merge-view:focus{outline:none;box-shadow:var(--mrd-shadow-focus)}.mrd-merge-view__history-icon.sc-mrd-merge-view{width:0.875rem;height:0.875rem}.mrd-merge-view__history-popover.sc-mrd-merge-view{position:absolute;top:calc(100% + 0.25rem);left:0;min-width:18rem;max-width:18rem;background-color:var(--mrd-color-white);border:var(--mrd-border-width) solid var(--mrd-border-color);border-radius:var(--mrd-border-radius-md);box-shadow:var(--mrd-shadow-md);padding:var(--mrd-space-1) 0;z-index:var(--mrd-z-dropdown)}.mrd-merge-view__history-entry.sc-mrd-merge-view{font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-700);padding:var(--mrd-space-2) var(--mrd-space-3);line-height:var(--mrd-line-height-normal)}.mrd-merge-view__history-entry.sc-mrd-merge-view:not(:last-child){border-bottom:var(--mrd-border-width) solid var(--mrd-color-neutral-100)}.mrd-merge-view__auto-note.sc-mrd-merge-view{margin-bottom:var(--mrd-space-4);padding:var(--mrd-space-3) var(--mrd-space-4);background:var(--mrd-color-neutral-50);border:var(--mrd-border-width) solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);color:var(--mrd-color-neutral-700)}.mrd-merge-view__auto-note.sc-mrd-merge-view p.sc-mrd-merge-view{margin:0 0 var(--mrd-space-1);font-weight:var(--mrd-font-weight-medium)}.mrd-merge-view__auto-note.sc-mrd-merge-view ul.sc-mrd-merge-view{margin:0;padding-left:var(--mrd-space-5)}.mrd-merge-view__summary-list.sc-mrd-merge-view{margin:0 0 var(--mrd-space-4);padding-left:var(--mrd-space-5)}.mrd-merge-view__warning.sc-mrd-merge-view{padding:var(--mrd-space-3) var(--mrd-space-4);background:var(--mrd-color-danger-light);border:var(--mrd-border-width) solid var(--mrd-color-danger);border-radius:var(--mrd-border-radius);color:var(--mrd-color-danger-dark);margin-bottom:var(--mrd-space-4)}.mrd-merge-view__actions.sc-mrd-merge-view{display:flex;gap:var(--mrd-space-3)}.mrd-merge-view__btn.sc-mrd-merge-view{height:var(--mrd-input-height-sm);padding:0 var(--mrd-space-4);border-radius:var(--mrd-border-radius);border:var(--mrd-border-width) solid transparent;font-size:var(--mrd-font-size-sm);font-weight:var(--mrd-font-weight-medium);cursor:pointer;transition:background-color var(--mrd-transition-fast), border-color var(--mrd-transition-fast)}.mrd-merge-view__btn--primary.sc-mrd-merge-view{background:var(--mrd-color-primary);color:var(--mrd-color-white)}.mrd-merge-view__btn--primary.sc-mrd-merge-view:hover{background:var(--mrd-color-primary-hover)}.mrd-merge-view__btn--secondary.sc-mrd-merge-view{background:var(--mrd-color-white);border-color:var(--mrd-border-color);color:var(--mrd-color-neutral-700)}.mrd-merge-view__btn--secondary.sc-mrd-merge-view:hover{background:var(--mrd-color-neutral-50)}.mrd-merge-view__btn--danger.sc-mrd-merge-view{background:var(--mrd-color-danger);color:var(--mrd-color-white)}.mrd-merge-view__btn--danger.sc-mrd-merge-view:hover{background:var(--mrd-color-danger-dark)}@keyframes mrd-merge-view-spin{to{transform:rotate(360deg)}}";export{k as mrd_merge_view}
|
|
1
|
+
import{h as r,r as e,c as i,H as o,g as d}from"./p-CDiBvvJU.js";import{a as t}from"./p-BJkVeSq6.js";import{t as a,C as s,a as m}from"./p-BMx6VAJ6.js";function n(r){return r.type===t.FIELD||r.type===t.RELATION&&!r.multiple}function l(r,e){var i,o,d,a,s;const m=null!==(i=r.name)&&void 0!==i?i:"";return r.type===t.RELATION?null!==(a=null===(d=null===(o=null==e?void 0:e._links)||void 0===o?void 0:o[m])||void 0===d?void 0:d.href)&&void 0!==a?a:null:null!==(s=null==e?void 0:e[m])&&void 0!==s?s:null}function c(r,e){return r.historyEnabled&&null!=e&&"object"==typeof e&&!Array.isArray(e)&&"current"in e?e.current:e}function v(r){return void 0===r||""===r?null:r}function g(r,e){const i=v(r),o=v(e);return i===o||null!==i&&null!==o&&JSON.stringify(i)===JSON.stringify(o)}function u(r){return null===v(r)}function h(r,e,i){const o=[],d=[];for(const t of r.filter(n)){const r=l(t,e),a=l(t,i),s=c(t,r),m=c(t,a);g(s,m)||(u(s)&&!u(m)?d.push({item:t,aValue:r,bValue:a}):o.push({item:t,aValue:r,bValue:a}))}return{conflicts:o,autoFilled:d}}function _(r){var e,i,o,d,t;return null!==(t=null!==(i=null!==(e=null==r?void 0:r.name)&&void 0!==e?e:null==r?void 0:r.label)&&void 0!==i?i:null===(d=null===(o=null==r?void 0:r._links)||void 0===o?void 0:o.self)||void 0===d?void 0:d.href)&&void 0!==t?t:""}function w(r,e){var i,o;return r.historyEnabled&&r.name&&null!==(o=null===(i=null==e?void 0:e[r.name])||void 0===i?void 0:i.history)&&void 0!==o?o:[]}const p=({locale:e,history:i,isOpen:o,onToggle:d})=>{if(0===i.length)return null;const t=[...i].sort(((r,e)=>e.until.localeCompare(r.until)));return r("span",{class:"mrd-merge-view__history-wrap"},r("button",{type:"button",class:"mrd-merge-view__history-btn",title:a("history_badge_tooltip",e),"aria-label":a("history_badge_tooltip",e),onClick:r=>{r.stopPropagation(),d()}},r("svg",{class:"mrd-merge-view__history-icon",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},r("path",{"fill-rule":"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm.75-13a.75.75 0 00-1.5 0v5c0 .207.085.394.22.53l2.5 2.5a.75.75 0 101.06-1.06L10.75 9.69V5z","clip-rule":"evenodd"}))),o&&r("div",{class:"mrd-merge-view__history-popover",role:"listbox"},t.map(((i,o)=>r("div",{key:String(o),class:"mrd-merge-view__history-entry"},i.value," (",a("history_until",e)," ",m(i.until,e),")")))))},b=({locale:e,searchQuery:i,searchResults:o,isLoading:d,onSearchInput:t,onSelect:s})=>r("div",{class:"mrd-merge-view__search-step"},r("p",{class:"mrd-merge-view__hint"},a("merge_search_hint",e)),r("div",{class:"mrd-merge-view__search-wrapper"},r("input",{class:"mrd-merge-view__search",type:"text",value:i,placeholder:a("search_placeholder",e),onInput:r=>t(r.target.value)}),d&&r("span",{class:"mrd-merge-view__spinner","aria-label":a("loading",e)})),i.trim().length>=2&&!d&&r("div",{class:"mrd-merge-view__results"},0===o.length?r("div",{class:"mrd-merge-view__no-results"},a("no_results",e)):o.map((i=>{var o,d,t;return r("div",{key:null!==(t=null===(d=null===(o=null==i?void 0:i._links)||void 0===o?void 0:o.self)||void 0===d?void 0:d.href)&&void 0!==t?t:_(i),class:"mrd-merge-view__result-item"},r("span",{class:"mrd-merge-view__result-label"},_(i)),r("button",{type:"button",class:"mrd-merge-view__btn mrd-merge-view__btn--secondary",onClick:()=>s(i)},a("merge_select",e)))})))),f=({locale:e,currentLabel:i,candidateLabel:o,conflicts:d,autoFilled:t,recordA:m,recordB:n,resolutions:l,openHistoryKey:c,onResolve:v,onToggleHistory:g,onChangeCandidate:u,onContinue:h})=>r("div",{class:"mrd-merge-view__compare-step"},r("h3",{class:"mrd-merge-view__heading"},a("merge_compare_heading",e)),0===d.length?r("p",{class:"mrd-merge-view__no-conflicts"},a("merge_no_conflicts",e)):r("table",{class:"mrd-merge-view__table"},r("thead",null,r("tr",null,r("th",{class:"mrd-merge-view__header"}),r("th",{class:"mrd-merge-view__header"},a("merge_column_a",e),r("span",{class:"mrd-merge-view__header-name"},i)),r("th",{class:"mrd-merge-view__header"},a("merge_column_b",e),r("span",{class:"mrd-merge-view__header-name"},o)))),r("tbody",null,d.map((({item:i})=>{var o,d,t;const a=null!==(o=i.name)&&void 0!==o?o:"",u=null!==(d=l[a])&&void 0!==d?d:"A",h=w(i,m),_=w(i,n),b=`${a}:A`,f=`${a}:B`;return r("tr",{key:a,class:"mrd-merge-view__row"},r("td",{class:"mrd-merge-view__cell mrd-merge-view__cell--label"},null!==(t=i.label)&&void 0!==t?t:a),r("td",{class:"mrd-merge-view__cell"},r("label",{class:"mrd-merge-view__option"},r("input",{type:"radio",name:`merge-${a}`,checked:"A"===u,onChange:()=>v(a,"A")}),r("span",null,s.render(i,m,e)||"—")),r(p,{locale:e,history:h,isOpen:c===b,onToggle:()=>g(c===b?null:b)})),r("td",{class:"mrd-merge-view__cell"},r("label",{class:"mrd-merge-view__option"},r("input",{type:"radio",name:`merge-${a}`,checked:"B"===u,onChange:()=>v(a,"B")}),r("span",null,s.render(i,n,e)||"—")),r(p,{locale:e,history:_,isOpen:c===f,onToggle:()=>g(c===f?null:f)})))})))),t.length>0&&r("div",{class:"mrd-merge-view__auto-note"},r("p",null,a("merge_auto_heading",e)),r("ul",null,t.map((({item:e})=>{var i;return r("li",{key:e.name},null!==(i=e.label)&&void 0!==i?i:e.name)})))),r("div",{class:"mrd-merge-view__actions"},r("button",{type:"button",class:"mrd-merge-view__btn mrd-merge-view__btn--secondary",onClick:u},a("merge_back",e)),r("button",{type:"button",class:"mrd-merge-view__btn mrd-merge-view__btn--primary",onClick:h},a("merge_continue",e)))),y=({locale:e,candidateLabel:i,conflicts:o,autoFilled:d,resolutions:t,recordB:m,openHistoryKey:n,onToggleHistory:l,onBack:c,onConfirm:v})=>{const g=[...d,...o.filter((({item:r})=>{var e;return"B"===t[null!==(e=r.name)&&void 0!==e?e:""]}))];return r("div",{class:"mrd-merge-view__confirm-step"},r("h3",{class:"mrd-merge-view__heading"},a("merge_confirm_heading",e)),0===g.length?r("p",{class:"mrd-merge-view__no-conflicts"},a("merge_no_conflicts",e)):r("ul",{class:"mrd-merge-view__summary-list"},g.map((({item:i})=>{var o;const d=`${i.name}:confirm`;return r("li",{key:i.name},null!==(o=i.label)&&void 0!==o?o:i.name,": ",s.render(i,m,e)||"—",r(p,{locale:e,history:w(i,m),isOpen:n===d,onToggle:()=>l(n===d?null:d)}))}))),r("p",{class:"mrd-merge-view__warning"},a("merge_confirm_warning",e)," (",i,")"),r("div",{class:"mrd-merge-view__actions"},r("button",{type:"button",class:"mrd-merge-view__btn mrd-merge-view__btn--secondary",onClick:c},a("merge_back",e)),r("button",{type:"button",class:"mrd-merge-view__btn mrd-merge-view__btn--danger",onClick:v},a("merge_confirm_button",e))))},k=class{constructor(r){e(this,r),this.mrdSearch=i(this,"mrdSearch"),this.mrdMerge=i(this,"mrdMerge"),this.locale=navigator.language,this.basicType="",this.mostSignificantClass="",this.fields=[],this.currentHref="",this.currentRecord={},this.currentLabel="",this.step="search",this.searchQuery="",this.searchResults=[],this.isLoading=!1,this.candidate=null,this.resolutions={},this.openHistoryKey=null,this.historyClickOutside=null,this.searchDebounce=null,this.handleSearchInput=r=>{this.searchQuery=r,this.searchDebounce&&clearTimeout(this.searchDebounce),r.trim().length>=2?(this.isLoading=!0,this.searchDebounce=setTimeout((()=>{this.mrdSearch.emit({query:r,basicType:this.basicType,mostSignificantClass:this.mostSignificantClass||void 0})}),300)):(this.searchResults=[],this.isLoading=!1)},this.handleSelect=r=>{this.candidate=r;const{conflicts:e}=h(this.fields,this.currentRecord,r),i={};e.forEach((({item:r})=>{var e;i[null!==(e=r.name)&&void 0!==e?e:""]="A"})),this.resolutions=i,this.openHistoryKey=null,this.step="compare"},this.handleChangeCandidate=()=>{this.candidate=null,this.resolutions={},this.openHistoryKey=null,this.step="search"},this.handleResolve=(r,e)=>{this.resolutions=Object.assign(Object.assign({},this.resolutions),{[r]:e})},this.handleToggleHistory=r=>{this.openHistoryKey=r},this.handleContinue=()=>{this.step="confirm"},this.handleBack=()=>{this.step="compare"},this.handleConfirm=()=>{var r,e,i,o;if(!this.candidate)return;const d=function(r,e){var i,o,d;const t={};for(const{item:e,bValue:o}of r.autoFilled)t[null!==(i=e.name)&&void 0!==i?i:""]=o;for(const{item:i,bValue:a}of r.conflicts)"B"===e[null!==(o=i.name)&&void 0!==o?o:""]&&(t[null!==(d=i.name)&&void 0!==d?d:""]=a);return t}(h(this.fields,this.currentRecord,this.candidate),this.resolutions),t=null!==(o=null===(i=null===(e=null===(r=this.candidate)||void 0===r?void 0:r._links)||void 0===e?void 0:e.self)||void 0===i?void 0:i.href)&&void 0!==o?o:"";this.mrdMerge.emit({winnerHref:this.currentHref,loserHref:t,patch:d})}}connectedCallback(){this.historyClickOutside=r=>{this.el.contains(r.target)||(this.openHistoryKey=null)},document.addEventListener("mousedown",this.historyClickOutside)}disconnectedCallback(){this.historyClickOutside&&(document.removeEventListener("mousedown",this.historyClickOutside),this.historyClickOutside=null)}async setSearchResults(r){this.searchResults=(null!=r?r:[]).filter((r=>{var e,i,o;return(null!==(o=null===(i=null===(e=null==r?void 0:r._links)||void 0===e?void 0:e.self)||void 0===i?void 0:i.href)&&void 0!==o?o:null)!==this.currentHref})),this.isLoading=!1}async setLoading(r){this.isLoading=r}render(){var e,i;let d;if("search"===this.step)d=r(b,{key:"88ddac4f8f60a736bc6bc898b553e24771023b82",locale:this.locale,searchQuery:this.searchQuery,searchResults:this.searchResults,isLoading:this.isLoading,onSearchInput:this.handleSearchInput,onSelect:this.handleSelect});else{const o=h(this.fields,this.currentRecord,this.candidate),t=_(this.candidate);d="compare"===this.step?r(f,{locale:this.locale,currentLabel:this.currentLabel,candidateLabel:t,conflicts:o.conflicts,autoFilled:o.autoFilled,recordA:this.currentRecord,recordB:null!==(e=this.candidate)&&void 0!==e?e:{},resolutions:this.resolutions,openHistoryKey:this.openHistoryKey,onResolve:this.handleResolve,onToggleHistory:this.handleToggleHistory,onChangeCandidate:this.handleChangeCandidate,onContinue:this.handleContinue}):r(y,{locale:this.locale,candidateLabel:t,conflicts:o.conflicts,autoFilled:o.autoFilled,resolutions:this.resolutions,recordB:null!==(i=this.candidate)&&void 0!==i?i:{},openHistoryKey:this.openHistoryKey,onToggleHistory:this.handleToggleHistory,onBack:this.handleBack,onConfirm:this.handleConfirm})}return r(o,{key:"3606faba4c86ae1d981b7c40e4f1cb9cde19cf50"},r("div",{key:"9605009fec0a7c79a5cd32141d930ea04e5efaad",class:"mrd-merge-view"},d))}get el(){return d(this)}};k.style=".sc-mrd-merge-view-h{display:block;width:100%}.mrd-merge-view.sc-mrd-merge-view{font-family:var(--mrd-font-family);font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-900)}.mrd-merge-view__hint.sc-mrd-merge-view{margin:0 0 var(--mrd-space-4);color:var(--mrd-color-neutral-600)}.mrd-merge-view__heading.sc-mrd-merge-view{margin:0 0 var(--mrd-space-4);font-size:var(--mrd-font-size-lg);font-weight:var(--mrd-font-weight-semibold)}.mrd-merge-view__search-wrapper.sc-mrd-merge-view{position:relative;display:flex;align-items:center}.mrd-merge-view__search.sc-mrd-merge-view{width:100%;height:var(--mrd-input-height);padding:var(--mrd-input-padding-y) var(--mrd-input-padding-x);border:var(--mrd-border-width) solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);background:var(--mrd-input-bg);color:var(--mrd-input-color);font-size:var(--mrd-font-size-sm)}.mrd-merge-view__search.sc-mrd-merge-view:focus{outline:none;border-color:var(--mrd-border-color-focus);box-shadow:var(--mrd-shadow-focus)}.mrd-merge-view__spinner.sc-mrd-merge-view{position:absolute;right:var(--mrd-space-3);width:1rem;height:1rem;border:2px solid var(--mrd-color-neutral-300);border-top-color:var(--mrd-color-primary);border-radius:var(--mrd-border-radius-full);animation:mrd-merge-view-spin var(--mrd-transition-slow) linear infinite}.mrd-merge-view__results.sc-mrd-merge-view{margin-top:var(--mrd-space-2);border:var(--mrd-border-width) solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);overflow:hidden}.mrd-merge-view__no-results.sc-mrd-merge-view{padding:var(--mrd-space-3) var(--mrd-space-4);color:var(--mrd-color-neutral-500)}.mrd-merge-view__result-item.sc-mrd-merge-view{display:flex;align-items:center;justify-content:space-between;gap:var(--mrd-space-3);padding:var(--mrd-space-2) var(--mrd-space-4)}.mrd-merge-view__result-item.sc-mrd-merge-view:not(:last-child){border-bottom:var(--mrd-border-width) solid var(--mrd-border-color)}.mrd-merge-view__result-label.sc-mrd-merge-view{font-weight:var(--mrd-font-weight-medium)}.mrd-merge-view__no-conflicts.sc-mrd-merge-view{color:var(--mrd-color-neutral-600)}.mrd-merge-view__table.sc-mrd-merge-view{width:100%;border-collapse:collapse;margin-bottom:var(--mrd-space-4)}.mrd-merge-view__header.sc-mrd-merge-view{text-align:left;padding:var(--mrd-space-2) var(--mrd-space-3);border-bottom:2px solid var(--mrd-border-color);font-size:var(--mrd-font-size-xs);text-transform:uppercase;letter-spacing:0.04em;color:var(--mrd-color-neutral-600)}.mrd-merge-view__header-name.sc-mrd-merge-view{display:block;text-transform:none;letter-spacing:normal;font-size:var(--mrd-font-size-sm);font-weight:var(--mrd-font-weight-medium);color:var(--mrd-color-neutral-900);margin-top:var(--mrd-space-1)}.mrd-merge-view__row.sc-mrd-merge-view:nth-child(even){background:var(--mrd-color-neutral-50)}.mrd-merge-view__cell.sc-mrd-merge-view{padding:var(--mrd-space-2) var(--mrd-space-3);border-bottom:var(--mrd-border-width) solid var(--mrd-border-color);vertical-align:top}.mrd-merge-view__cell--label.sc-mrd-merge-view{font-weight:var(--mrd-font-weight-medium);white-space:nowrap}.mrd-merge-view__option.sc-mrd-merge-view{display:flex;align-items:flex-start;gap:var(--mrd-space-2);cursor:pointer}.mrd-merge-view__option.sc-mrd-merge-view input[type=radio].sc-mrd-merge-view{margin-top:0.2em}.mrd-merge-view__history-wrap.sc-mrd-merge-view{position:relative;display:inline-flex;align-items:center;margin-left:var(--mrd-space-1)}.mrd-merge-view__history-btn.sc-mrd-merge-view{display:inline-flex;align-items:center;justify-content:center;width:1.25rem;height:1.25rem;padding:0;background:transparent;border:none;border-radius:var(--mrd-border-radius-sm);color:var(--mrd-color-neutral-400);cursor:pointer;flex-shrink:0;transition:color var(--mrd-transition-fast), background-color var(--mrd-transition-fast)}.mrd-merge-view__history-btn.sc-mrd-merge-view:hover{color:var(--mrd-color-neutral-700);background-color:var(--mrd-color-neutral-100)}.mrd-merge-view__history-btn.sc-mrd-merge-view:focus{outline:none;box-shadow:var(--mrd-shadow-focus)}.mrd-merge-view__history-icon.sc-mrd-merge-view{width:0.875rem;height:0.875rem}.mrd-merge-view__history-popover.sc-mrd-merge-view{position:absolute;top:calc(100% + 0.25rem);left:0;min-width:18rem;max-width:18rem;background-color:var(--mrd-color-white);border:var(--mrd-border-width) solid var(--mrd-border-color);border-radius:var(--mrd-border-radius-md);box-shadow:var(--mrd-shadow-md);padding:var(--mrd-space-1) 0;z-index:var(--mrd-z-dropdown)}.mrd-merge-view__history-entry.sc-mrd-merge-view{font-size:var(--mrd-font-size-sm);color:var(--mrd-color-neutral-700);padding:var(--mrd-space-2) var(--mrd-space-3);line-height:var(--mrd-line-height-normal)}.mrd-merge-view__history-entry.sc-mrd-merge-view:not(:last-child){border-bottom:var(--mrd-border-width) solid var(--mrd-color-neutral-100)}.mrd-merge-view__auto-note.sc-mrd-merge-view{margin-bottom:var(--mrd-space-4);padding:var(--mrd-space-3) var(--mrd-space-4);background:var(--mrd-color-neutral-50);border:var(--mrd-border-width) solid var(--mrd-border-color);border-radius:var(--mrd-border-radius);color:var(--mrd-color-neutral-700)}.mrd-merge-view__auto-note.sc-mrd-merge-view p.sc-mrd-merge-view{margin:0 0 var(--mrd-space-1);font-weight:var(--mrd-font-weight-medium)}.mrd-merge-view__auto-note.sc-mrd-merge-view ul.sc-mrd-merge-view{margin:0;padding-left:var(--mrd-space-5)}.mrd-merge-view__summary-list.sc-mrd-merge-view{margin:0 0 var(--mrd-space-4);padding-left:var(--mrd-space-5)}.mrd-merge-view__warning.sc-mrd-merge-view{padding:var(--mrd-space-3) var(--mrd-space-4);background:var(--mrd-color-danger-light);border:var(--mrd-border-width) solid var(--mrd-color-danger);border-radius:var(--mrd-border-radius);color:var(--mrd-color-danger-dark);margin-bottom:var(--mrd-space-4)}.mrd-merge-view__actions.sc-mrd-merge-view{display:flex;gap:var(--mrd-space-3)}.mrd-merge-view__btn.sc-mrd-merge-view{height:var(--mrd-input-height-sm);padding:0 var(--mrd-space-4);border-radius:var(--mrd-border-radius);border:var(--mrd-border-width) solid transparent;font-size:var(--mrd-font-size-sm);font-weight:var(--mrd-font-weight-medium);cursor:pointer;transition:background-color var(--mrd-transition-fast), border-color var(--mrd-transition-fast)}.mrd-merge-view__btn--primary.sc-mrd-merge-view{background:var(--mrd-color-primary);color:var(--mrd-color-white)}.mrd-merge-view__btn--primary.sc-mrd-merge-view:hover{background:var(--mrd-color-primary-hover)}.mrd-merge-view__btn--secondary.sc-mrd-merge-view{background:var(--mrd-color-white);border-color:var(--mrd-border-color);color:var(--mrd-color-neutral-700)}.mrd-merge-view__btn--secondary.sc-mrd-merge-view:hover{background:var(--mrd-color-neutral-50)}.mrd-merge-view__btn--danger.sc-mrd-merge-view{background:var(--mrd-color-danger);color:var(--mrd-color-white)}.mrd-merge-view__btn--danger.sc-mrd-merge-view:hover{background:var(--mrd-color-danger-dark)}@keyframes mrd-merge-view-spin{to{transform:rotate(360deg)}}";export{k as mrd_merge_view}
|
|
@@ -8,6 +8,9 @@ export declare class MrdTextareaField implements ComponentDidLoad {
|
|
|
8
8
|
required: boolean;
|
|
9
9
|
disabled: boolean;
|
|
10
10
|
locale: string;
|
|
11
|
+
/** Focus the editor as soon as it's ready — opt-in, since auto-focusing every
|
|
12
|
+
* textarea field on mount would be wrong for a regular multi-field form. */
|
|
13
|
+
autofocus: boolean;
|
|
11
14
|
error: string;
|
|
12
15
|
editorReady: boolean;
|
|
13
16
|
mrdChange: EventEmitter<{
|
|
@@ -19,7 +22,14 @@ export declare class MrdTextareaField implements ComponentDidLoad {
|
|
|
19
22
|
value: string;
|
|
20
23
|
}>;
|
|
21
24
|
private editorEl;
|
|
25
|
+
private quill;
|
|
22
26
|
componentDidLoad(): void;
|
|
27
|
+
/** The host may reuse the same element for a different record (e.g. mrd-memo-
|
|
28
|
+
* container's quick-create/edit dialog editing a second memo without the
|
|
29
|
+
* dialog itself remounting) — Quill only reads `value` once at construction,
|
|
30
|
+
* so re-apply it here when it changes to something the editor doesn't already
|
|
31
|
+
* hold. Guarded against our own emitted mrdChange feeding back in as a no-op. */
|
|
32
|
+
valueChanged(newValue: string): void;
|
|
23
33
|
private initQuill;
|
|
24
34
|
private getSanitizedHtml;
|
|
25
35
|
render(): any;
|
|
@@ -25,6 +25,11 @@ export declare class MrdForm {
|
|
|
25
25
|
referenceClass: string;
|
|
26
26
|
/** When true, a cancel button is shown next to the submit button. */
|
|
27
27
|
showCancel: boolean;
|
|
28
|
+
/** When true, a delete button is shown next to the submit button (edit mode only —
|
|
29
|
+
* the host decides when a delete affordance makes sense, e.g. only for an existing
|
|
30
|
+
* record). Deletion itself (confirmation, the actual API call) is entirely the
|
|
31
|
+
* host's responsibility; mrd-form only emits the request via mrdDelete. */
|
|
32
|
+
showDelete: boolean;
|
|
28
33
|
/**
|
|
29
34
|
* The currently logged-in user, resolved by the host via /accounts/me.
|
|
30
35
|
* Used to pre-fill RELATION fields whose defaultValue is "@me".
|
|
@@ -37,6 +42,7 @@ export declare class MrdForm {
|
|
|
37
42
|
private initialValues;
|
|
38
43
|
mrdSubmit: EventEmitter<Record<string, unknown>>;
|
|
39
44
|
mrdCancel: EventEmitter<void>;
|
|
45
|
+
mrdDelete: EventEmitter<void>;
|
|
40
46
|
mrdSearch: EventEmitter<{
|
|
41
47
|
name: string;
|
|
42
48
|
query: string;
|
|
@@ -22,6 +22,11 @@ export declare class MrdLayoutSection {
|
|
|
22
22
|
* create ("+") action and the documents view's New folder / Upload are disabled
|
|
23
23
|
* with a tooltip explaining why, so it's clear at a glance the user can't mutate data. */
|
|
24
24
|
readOnly: boolean;
|
|
25
|
+
/** The active account's linked person record (userProfile.links.person), if any.
|
|
26
|
+
* Threaded to mrd-memo-container so a top-level memo VIEW (no parent record to
|
|
27
|
+
* attach a new memo to) can still offer "New memo" by falling back to the
|
|
28
|
+
* account's own record as the container. */
|
|
29
|
+
me: RelationSearchResult | null;
|
|
25
30
|
private searchQueryMap;
|
|
26
31
|
private searchResultsMap;
|
|
27
32
|
private imagePreviewUrl;
|
|
@@ -102,6 +107,11 @@ export declare class MrdLayoutSection {
|
|
|
102
107
|
href: string;
|
|
103
108
|
values: Record<string, unknown>;
|
|
104
109
|
}>;
|
|
110
|
+
/** Confirmed delete from an embedded memo dialog. Host DELETEs `href` — fire-
|
|
111
|
+
* and-forget, the row is already removed optimistically on the component side. */
|
|
112
|
+
mrdDeleteObject: EventEmitter<{
|
|
113
|
+
href: string;
|
|
114
|
+
}>;
|
|
105
115
|
/** An external file was dropped on a document view; host uploads and calls
|
|
106
116
|
* setViewFileReference(name, uri). */
|
|
107
117
|
mrdViewUpload: EventEmitter<{
|
|
@@ -138,7 +148,9 @@ export declare class MrdLayoutSection {
|
|
|
138
148
|
* can request creation of the new document (see mrdViewUpload). */
|
|
139
149
|
setViewFileReference(name: string, uri: string): Promise<void>;
|
|
140
150
|
/** Inject the created document's href after a file-drop create, so the
|
|
141
|
-
* optimistic row becomes navigable (see mrdCreateObject).
|
|
151
|
+
* optimistic row becomes navigable (see mrdCreateObject). For a memo
|
|
152
|
+
* quick-create there is no optimistic row to resolve — simply reload the
|
|
153
|
+
* container's current body so the new memo shows up. */
|
|
142
154
|
setViewCreatedObject(name: string, href: string): Promise<void>;
|
|
143
155
|
/** Provide a resolved URL for an IMAGE field. Shows as thumbnail; clicking opens the lightbox. */
|
|
144
156
|
setImagePreview(fieldName: string, url: string): Promise<void>;
|
|
@@ -156,6 +168,9 @@ export declare class MrdLayoutSection {
|
|
|
156
168
|
* swaps between the folder tree and the flat table. Events are re-emitted to
|
|
157
169
|
* the host with the view key, exactly as the raw list/table events were. */
|
|
158
170
|
private renderDocumentContainer;
|
|
171
|
+
/** Memo collection view: owns the view-switch + "New memo" and swaps between
|
|
172
|
+
* the card list and the flat table, mirroring renderDocumentContainer(). */
|
|
173
|
+
private renderMemoContainer;
|
|
159
174
|
private renderTable;
|
|
160
175
|
private renderItem;
|
|
161
176
|
private renderImageModal;
|
|
@@ -176,5 +191,9 @@ export declare class MrdLayoutSection {
|
|
|
176
191
|
/** Single-email view: the record's own type carries commons.email. Fully read-only —
|
|
177
192
|
* emails have no editable child collection, so this mirrors renderDocumentObject. */
|
|
178
193
|
private renderEmailObject;
|
|
194
|
+
/** Single-memo view: the record's own type carries commons.memo. Renders a
|
|
195
|
+
* recognisable memo (title/body prominent, author/date subtle) instead of
|
|
196
|
+
* generic fields, keeping any related views/searches below it. */
|
|
197
|
+
private renderMemoObject;
|
|
179
198
|
render(): any;
|
|
180
199
|
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { EventEmitter } from '../../../stencil-public-runtime';
|
|
2
|
+
import { ClientArchetype, ClientLayoutItem, ClientListValue, RelationSearchResult } from '../../../types/client-layout';
|
|
3
|
+
/**
|
|
4
|
+
* Owns a memo collection view: a single toolbar (view switch + "New memo") plus
|
|
5
|
+
* the two interchangeable bodies — the card list (`mrd-memo-list`) and the flat
|
|
6
|
+
* table (`mrd-table`). Mirrors `mrd-document-container`'s structure.
|
|
7
|
+
*
|
|
8
|
+
* There is no memo detail page: both "New memo" and clicking an existing memo
|
|
9
|
+
* (card or table row) open the same small dialog — just the fields a person
|
|
10
|
+
* actually fills in (body, and only the optional slots the archetype actually
|
|
11
|
+
* maps: title/labels/important). date/author/container are already known
|
|
12
|
+
* context and never shown. Create emits `mrdCreateObject` (same contract
|
|
13
|
+
* mrd-document-list already uses for its inline file-drop create); editing an
|
|
14
|
+
* existing memo emits `mrdUpdateObject` (same generic PATCH contract used
|
|
15
|
+
* elsewhere, e.g. mrd-document-list's drag-move) and optimistically patches the
|
|
16
|
+
* displayed row/card itself, since that PATCH is fire-and-forget on the host.
|
|
17
|
+
*
|
|
18
|
+
* `mrd-layout-section` renders one of these per memo VIEW / RELATED_VIEW and
|
|
19
|
+
* forwards the re-emitted load/action/create/update events to the host.
|
|
20
|
+
*/
|
|
21
|
+
export declare class MrdMemoContainer {
|
|
22
|
+
/** The VIEW or RELATED_VIEW layout item (dataClass, fromClass, view config). */
|
|
23
|
+
item: ClientLayoutItem | null;
|
|
24
|
+
/** Resolved `commons.memo` archetype binding. */
|
|
25
|
+
archetype: ClientArchetype;
|
|
26
|
+
/** Parent record id — required for RELATED_VIEW path building. */
|
|
27
|
+
parentId: string;
|
|
28
|
+
/** Canonical parent href — set when this is a RELATED_VIEW embedded under a
|
|
29
|
+
* parent record, which already gives a new memo something to attach to. */
|
|
30
|
+
containerHref: string;
|
|
31
|
+
/** Lookup key used for the embedded `data-view` attribute. */
|
|
32
|
+
viewKey: string;
|
|
33
|
+
locale: string;
|
|
34
|
+
/** listItems of the FIELD bound to the `labels` slot; forwarded to whichever
|
|
35
|
+
* body is mounted and used to render the dialog's label checkboxes. */
|
|
36
|
+
labelsListItems: ClientListValue[] | null;
|
|
37
|
+
/** When true, this dashboard is read-only: "New memo" is disabled with a
|
|
38
|
+
* tooltip, cards/rows are not clickable, and the embedded table's own
|
|
39
|
+
* create action is disabled too. */
|
|
40
|
+
readOnly: boolean;
|
|
41
|
+
/** The active account's linked person record (userProfile.links.person), if any.
|
|
42
|
+
* Used both to gate "New memo" (see effectiveContainerHref) and, on submit, to
|
|
43
|
+
* fill the author slot. */
|
|
44
|
+
me: RelationSearchResult | null;
|
|
45
|
+
mrdLoadPage: EventEmitter<{
|
|
46
|
+
page: number;
|
|
47
|
+
sort: string;
|
|
48
|
+
path: string;
|
|
49
|
+
qs: string;
|
|
50
|
+
}>;
|
|
51
|
+
mrdLoadAggregations: EventEmitter<{
|
|
52
|
+
path: string;
|
|
53
|
+
qs: string;
|
|
54
|
+
aggQs: string;
|
|
55
|
+
}>;
|
|
56
|
+
/** Only the embedded table's own toolbar (export, etc.) still routes through this. */
|
|
57
|
+
mrdAction: EventEmitter<{
|
|
58
|
+
action: string;
|
|
59
|
+
path?: string;
|
|
60
|
+
qs?: string;
|
|
61
|
+
parentPath?: string | null;
|
|
62
|
+
basicType?: string;
|
|
63
|
+
}>;
|
|
64
|
+
/** Quick-create submit. Host POSTs `values` to `path`, same as mrd-document-list's. */
|
|
65
|
+
mrdCreateObject: EventEmitter<{
|
|
66
|
+
path: string;
|
|
67
|
+
values: Record<string, unknown>;
|
|
68
|
+
}>;
|
|
69
|
+
/** Quick-edit submit. Host PATCHes `href` with `values`, same as mrd-document-list's drag-move. */
|
|
70
|
+
mrdUpdateObject: EventEmitter<{
|
|
71
|
+
href: string;
|
|
72
|
+
values: Record<string, unknown>;
|
|
73
|
+
}>;
|
|
74
|
+
/** Confirmed delete. Host DELETEs `href` — fire-and-forget, same as mrdUpdateObject;
|
|
75
|
+
* the row is removed optimistically here rather than waiting on a callback. */
|
|
76
|
+
mrdDeleteObject: EventEmitter<{
|
|
77
|
+
href: string;
|
|
78
|
+
}>;
|
|
79
|
+
/** Active body: card list or flat table. */
|
|
80
|
+
private mode;
|
|
81
|
+
private dialogOpen;
|
|
82
|
+
/** Href of the memo being edited; null while creating. */
|
|
83
|
+
private editingHref;
|
|
84
|
+
private dialogBody;
|
|
85
|
+
private dialogTitle;
|
|
86
|
+
private dialogLabels;
|
|
87
|
+
private dialogImportant;
|
|
88
|
+
private dialogTouched;
|
|
89
|
+
/** True while the dialog shows the delete confirmation step in place of the
|
|
90
|
+
* form fields — mirrors mrd-merge-view's MergeConfirmStep (same panel,
|
|
91
|
+
* swapped content) rather than stacking a second modal. */
|
|
92
|
+
private deleteConfirmOpen;
|
|
93
|
+
private listEl?;
|
|
94
|
+
private tableEl?;
|
|
95
|
+
/** Whether the currently mounted body has been init()'d. Reset on every mode switch. */
|
|
96
|
+
private listInited;
|
|
97
|
+
private tableInited;
|
|
98
|
+
private escapeHandler;
|
|
99
|
+
disconnectedCallback(): void;
|
|
100
|
+
/** Escape backs out of the delete-confirm step first (matches Cancel there),
|
|
101
|
+
* or closes the whole dialog. Bound to `document` — bubbling from inside the
|
|
102
|
+
* Quill editor is not reliable enough to rely on a local key handler. */
|
|
103
|
+
dialogOpenChanged(open: boolean): void;
|
|
104
|
+
private unbindEscape;
|
|
105
|
+
/** Neither body self-loads: like mrd-table, both wait for init(). mrd-layout-section
|
|
106
|
+
* init()s whichever is mounted at load time via its own querySelector pass; when the
|
|
107
|
+
* user switches mode here, the freshly mounted body needs the same treatment. */
|
|
108
|
+
componentDidRender(): void;
|
|
109
|
+
private setMode;
|
|
110
|
+
/** Re-request page 0 of whichever body is currently mounted — called by
|
|
111
|
+
* mrd-layout-section after a successful mrdCreateObject, and by this
|
|
112
|
+
* component itself after an edit to a table row (which has no per-row
|
|
113
|
+
* optimistic-patch method the way mrd-memo-list does). */
|
|
114
|
+
refresh(): Promise<void>;
|
|
115
|
+
/** `me` is typed as RelationSearchResult ({ id, label }) but hosts differ on
|
|
116
|
+
* which shape they actually populate: this repo's own dev preview resolves
|
|
117
|
+
* it via /accounts/me as a real { id, label } RelationSearchResult, while
|
|
118
|
+
* content-app feeds it from userProfile.links.person, the raw API link shape
|
|
119
|
+
* ({ href, name }). Both occur in practice — same dual tolerance as
|
|
120
|
+
* mrd-form's own getHref(). */
|
|
121
|
+
private meHref;
|
|
122
|
+
/** Value of a value-slot: reads row[field] via the slot→field map. */
|
|
123
|
+
private slotValue;
|
|
124
|
+
private get hasTitleSlot();
|
|
125
|
+
private get hasImportantSlot();
|
|
126
|
+
/** A parent record already gives a new memo somewhere to attach to (RELATED_VIEW);
|
|
127
|
+
* otherwise fall back to the account's own linked person (top-level VIEW). */
|
|
128
|
+
private get effectiveContainerHref();
|
|
129
|
+
/** The author slot is always filled from `me` (there is no author picker in
|
|
130
|
+
* the dialog), so without it there is nothing valid to create — regardless
|
|
131
|
+
* of whether a parent record already supplies a container. */
|
|
132
|
+
private get canAdd();
|
|
133
|
+
private openCreate;
|
|
134
|
+
/** Opens the same dialog pre-filled from an existing memo row/record —
|
|
135
|
+
* triggered by clicking a card or a table row. No separate detail page. */
|
|
136
|
+
private openEdit;
|
|
137
|
+
private closeDialog;
|
|
138
|
+
private openDeleteConfirm;
|
|
139
|
+
private cancelDeleteConfirm;
|
|
140
|
+
private confirmDelete;
|
|
141
|
+
/** Path for creating a new memo: `/{dataClass}` for a top-level VIEW, or
|
|
142
|
+
* `/{fromClass}/{parentId}/{dataClass}` when nested under a parent record. */
|
|
143
|
+
private buildCreatePath;
|
|
144
|
+
private submitDialog;
|
|
145
|
+
private renderToolbar;
|
|
146
|
+
private renderDeleteConfirm;
|
|
147
|
+
private renderForm;
|
|
148
|
+
private renderDialog;
|
|
149
|
+
private renderCards;
|
|
150
|
+
private renderTable;
|
|
151
|
+
render(): any;
|
|
152
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { EventEmitter } from '../../../stencil-public-runtime';
|
|
2
|
+
import { ClientArchetype, ClientLayoutItem, ClientListValue } from '../../../types/client-layout';
|
|
3
|
+
/**
|
|
4
|
+
* Card-view body for a `commons.memo` collection — the alternative to the flat
|
|
5
|
+
* `mrd-table` a `mrd-memo-container` can switch to. Deliberately simpler than
|
|
6
|
+
* `mrd-table`'s virtual-scroll internals: memo cards accumulate via a plain
|
|
7
|
+
* "load more" affordance rather than windowed rendering, since a bounded card
|
|
8
|
+
* list of notes doesn't need that complexity.
|
|
9
|
+
*
|
|
10
|
+
* Mirrors `mrd-table`'s external contract for the parts a host / mrd-layout-
|
|
11
|
+
* section already knows how to drive — `init()`, `setPage()`, the `mrdLoadPage`
|
|
12
|
+
* event shape `{ page, sort, path, qs }` — so no new host-side wiring is needed
|
|
13
|
+
* to feed it data.
|
|
14
|
+
*
|
|
15
|
+
* There is no separate memo detail page: clicking a card opens mrd-memo-
|
|
16
|
+
* container's quick-edit dialog directly (mrdEdit), the same dialog "New memo"
|
|
17
|
+
* uses for creation.
|
|
18
|
+
*/
|
|
19
|
+
export declare class MrdMemoList {
|
|
20
|
+
/** The VIEW or RELATED_VIEW layout item (dataClass, fromClass, view config). */
|
|
21
|
+
item: ClientLayoutItem | null;
|
|
22
|
+
/** Resolved `commons.memo` archetype binding. */
|
|
23
|
+
archetype: ClientArchetype;
|
|
24
|
+
/** Parent record id — required for RELATED_VIEW path building. */
|
|
25
|
+
parentId: string;
|
|
26
|
+
/** Records per page (must match API page size). */
|
|
27
|
+
pageSize: number;
|
|
28
|
+
locale: string;
|
|
29
|
+
/** When true, cards are not clickable (no mrdEdit) — matches mrd-table's own
|
|
30
|
+
* readOnly gating on its create action. */
|
|
31
|
+
readOnly: boolean;
|
|
32
|
+
/** listItems of the FIELD bound to the `labels` slot, resolved by mrd-layout-section
|
|
33
|
+
* from its own items array, same reason mrd-memo-view needs it. */
|
|
34
|
+
labelsListItems: ClientListValue[] | null;
|
|
35
|
+
/** Fired when a page needs fetching; same shape as mrd-table's mrdLoadPage minus `qs`'s
|
|
36
|
+
* column-filter support (cards have no filter UI) — host calls setPage() with the result. */
|
|
37
|
+
mrdLoadPage: EventEmitter<{
|
|
38
|
+
page: number;
|
|
39
|
+
sort: string;
|
|
40
|
+
path: string;
|
|
41
|
+
qs: string;
|
|
42
|
+
}>;
|
|
43
|
+
/** A card was clicked (and not read-only). mrd-memo-container opens its quick-
|
|
44
|
+
* edit dialog pre-filled from `row` — no navigation, no detail page. */
|
|
45
|
+
mrdEdit: EventEmitter<{
|
|
46
|
+
row: Record<string, unknown>;
|
|
47
|
+
}>;
|
|
48
|
+
private rows;
|
|
49
|
+
private loading;
|
|
50
|
+
private exhausted;
|
|
51
|
+
private started;
|
|
52
|
+
private expandedHrefs;
|
|
53
|
+
private nextPage;
|
|
54
|
+
private buildDataPath;
|
|
55
|
+
private sortParam;
|
|
56
|
+
private emitLoadPage;
|
|
57
|
+
/** Reset and request page 0. Call after setting all props, mirrors mrd-table.init(). */
|
|
58
|
+
init(): Promise<void>;
|
|
59
|
+
/** Inject the rows for a page (0-based); page 0 replaces, later pages append. */
|
|
60
|
+
setPage(pageNumber: number, rows: Record<string, unknown>[], hasNext?: boolean): Promise<void>;
|
|
61
|
+
/** Optimistically merge an edit into the matching row — mrdUpdateObject's PATCH
|
|
62
|
+
* is fire-and-forget on the host side, so this is what makes an edit visible
|
|
63
|
+
* immediately rather than only after the next full reload. */
|
|
64
|
+
patchRow(href: string, values: Record<string, unknown>): Promise<void>;
|
|
65
|
+
/** Optimistically drop a deleted row — mrdDeleteObject's DELETE is fire-and-
|
|
66
|
+
* forget on the host side, same reasoning as patchRow(). */
|
|
67
|
+
removeRow(href: string): Promise<void>;
|
|
68
|
+
private loadMore;
|
|
69
|
+
/** Value of a value-slot: reads row[field] via the slot→field map. */
|
|
70
|
+
private slotValue;
|
|
71
|
+
/** Relation link for a relation-slot: reads row._links[field]. */
|
|
72
|
+
private slotLink;
|
|
73
|
+
private plainTextLength;
|
|
74
|
+
private toggleExpanded;
|
|
75
|
+
private renderLabels;
|
|
76
|
+
private renderBody;
|
|
77
|
+
private renderCard;
|
|
78
|
+
render(): any;
|
|
79
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { EventEmitter } from '../../../stencil-public-runtime';
|
|
2
|
+
import { ClientArchetype, ClientListValue } from '../../../types/client-layout';
|
|
3
|
+
/**
|
|
4
|
+
* Archetype-driven single-memo view. Given a `commons.memo` binding and a data
|
|
5
|
+
* record, renders the memo the way a note should read: the title and body are
|
|
6
|
+
* the prominent content, author and timestamp sit below as a subtle metadata
|
|
7
|
+
* line — not the other way around.
|
|
8
|
+
*/
|
|
9
|
+
export declare class MrdMemoView {
|
|
10
|
+
/** Resolved `commons.memo` binding: slot name → concrete field/relation name. */
|
|
11
|
+
archetype: ClientArchetype;
|
|
12
|
+
/** The data record from the /data endpoint. Fields keyed by name; relations under `_links`. */
|
|
13
|
+
data: Record<string, unknown>;
|
|
14
|
+
locale: string;
|
|
15
|
+
/** listItems of the FIELD bound to the `labels` slot, resolved by mrd-layout-section
|
|
16
|
+
* from its own items array (archetype metadata does not publish listItems), so the
|
|
17
|
+
* label badges get a real label/color instead of the raw stored key. */
|
|
18
|
+
labelsListItems: ClientListValue[] | null;
|
|
19
|
+
/** Navigate to the author or the container. Host resolves the href and routes. */
|
|
20
|
+
mrdNavigate: EventEmitter<{
|
|
21
|
+
href?: string;
|
|
22
|
+
label: string;
|
|
23
|
+
}>;
|
|
24
|
+
/** Value of a value-slot: reads data[field] via the slot→field map. */
|
|
25
|
+
private slotValue;
|
|
26
|
+
/** Relation link for a relation-slot: reads data._links[field]. */
|
|
27
|
+
private slotLink;
|
|
28
|
+
private renderAuthor;
|
|
29
|
+
private renderContainer;
|
|
30
|
+
private renderLabels;
|
|
31
|
+
private renderBody;
|
|
32
|
+
render(): any;
|
|
33
|
+
}
|
|
@@ -15,6 +15,17 @@ export declare class MrdTable {
|
|
|
15
15
|
private keydownHandler;
|
|
16
16
|
private createPickerClickHandler;
|
|
17
17
|
private viewPopoverClickHandler;
|
|
18
|
+
/** Debounce timer for the free-text search box — separate from debounceTimer
|
|
19
|
+
* (pending-page requests), since typing and scrolling debounce independently. */
|
|
20
|
+
private searchDebounceTimer;
|
|
21
|
+
/** The rendered search <input>, captured so it can be focused the instant it mounts. */
|
|
22
|
+
private searchInputEl;
|
|
23
|
+
/** Set by toggleSearch() when the box just expanded; consumed and cleared in componentDidRender(). */
|
|
24
|
+
private searchNeedsFocus;
|
|
25
|
+
/** Column filters stashed by stashFiltersForSearch() while the search box is open — the
|
|
26
|
+
* backend can't combine `q` with column filters. Restored by restoreFiltersAfterSearch()
|
|
27
|
+
* on close, unless the user applied a fresh filter of their own in the meantime. */
|
|
28
|
+
private stashedFilters;
|
|
18
29
|
/** Watches the host for gaining a box (e.g. its tab pane being shown) — see componentDidLoad. */
|
|
19
30
|
private resizeObserver;
|
|
20
31
|
/** Guards against scheduling more than one column-width measurement per freeze. */
|
|
@@ -74,6 +85,10 @@ export declare class MrdTable {
|
|
|
74
85
|
sortDir: 'asc' | 'desc';
|
|
75
86
|
/** Active filters keyed by field name. */
|
|
76
87
|
activeFilters: Map<string, ColumnFilter>;
|
|
88
|
+
/** True while the toolbar's magnifying glass is expanded into the search input. */
|
|
89
|
+
private searchOpen;
|
|
90
|
+
/** Current free-text search query — sent as `q` on every mrdLoadPage/aggregations request. */
|
|
91
|
+
private searchQuery;
|
|
77
92
|
/** Field name of the currently open filter popup (null = closed). */
|
|
78
93
|
openFilterCol: string | null;
|
|
79
94
|
/** Filter state being edited in the open popup. */
|
|
@@ -258,7 +273,13 @@ export declare class MrdTable {
|
|
|
258
273
|
* VIEW: /{dataClass}
|
|
259
274
|
* RELATED_VIEW: /{fromClass}/{parentId}/{dataClass} */
|
|
260
275
|
private buildDataPath;
|
|
261
|
-
/** Build query params for a page request from current sort, view filters, filterClass and active column filters.
|
|
276
|
+
/** Build query params for a page request from current sort, view filters, filterClass and active column filters.
|
|
277
|
+
*
|
|
278
|
+
* `q` and column filters are mutually exclusive on the backend — combining them breaks
|
|
279
|
+
* the search. stashFiltersForSearch() already empties activeFilters for the duration of
|
|
280
|
+
* a search, but this guard is the actual guarantee: even if a filter is applied through
|
|
281
|
+
* a column header while the search box is still open (before the query is cleared),
|
|
282
|
+
* activeFilters is dropped from the request rather than sent alongside `q`. */
|
|
262
283
|
private buildQueryParams;
|
|
263
284
|
/** True when the table is in paginated / virtual-scroll mode rather than driven by the
|
|
264
285
|
* rows prop. Mirrors the branch taken in render().
|
|
@@ -306,9 +327,35 @@ export declare class MrdTable {
|
|
|
306
327
|
private closeJsonModal;
|
|
307
328
|
private setPending;
|
|
308
329
|
private togglePendingValue;
|
|
330
|
+
/** Common reload after activeFilters or searchQuery changed: drop stale aggregations
|
|
331
|
+
* (the next setPage(0) re-requests them, guarded against `q` in setPage() itself) and
|
|
332
|
+
* re-fetch page 0. Shared by the filter popup, clear-all, and free-text search. */
|
|
333
|
+
private reloadAfterQueryChange;
|
|
309
334
|
private applyFilter;
|
|
310
335
|
private clearFilter;
|
|
311
336
|
private clearAllFilters;
|
|
337
|
+
/** Search is a VIEW-only affordance — a RELATED_VIEW table is already scoped to
|
|
338
|
+
* its parent record, so a free-text box there would invite confusion about what
|
|
339
|
+
* it searches across. */
|
|
340
|
+
private get searchEnabled();
|
|
341
|
+
private toggleSearch;
|
|
342
|
+
/** Collapses the box back to the icon. Clearing a non-empty query and restoring any
|
|
343
|
+
* stashed filters can each independently require a reload — reloadAfterQueryChange()
|
|
344
|
+
* is called at most once here regardless of how many of the two actually changed. */
|
|
345
|
+
private closeSearch;
|
|
346
|
+
private handleSearchInput;
|
|
347
|
+
/** Reloads from page 0 with the current searchQuery, same reset as applyFilter(). */
|
|
348
|
+
private applySearch;
|
|
349
|
+
/** Column filters and the free-text `q` param are mutually exclusive on the backend —
|
|
350
|
+
* sending both breaks the search. Opening the search box stashes any active filters
|
|
351
|
+
* and clears them (the header filter icons and the clear-all button disappear along
|
|
352
|
+
* with activeFilters, so there is nothing extra to hide) and reloads unfiltered. */
|
|
353
|
+
private stashFiltersForSearch;
|
|
354
|
+
/** Restores filters stashed by stashFiltersForSearch(), unless the user applied a fresh
|
|
355
|
+
* filter of their own while the search box was open — that explicit choice wins over
|
|
356
|
+
* reinstating the old one. Returns whether activeFilters actually changed, so the
|
|
357
|
+
* caller can decide whether a reload is needed. */
|
|
358
|
+
private restoreFiltersAfterSearch;
|
|
312
359
|
private handleViewSwitch;
|
|
313
360
|
private toggleViewPopover;
|
|
314
361
|
private closeViewPopover;
|
|
@@ -6,6 +6,9 @@ import { AggregationResult, ClientCreateType } from '../../../types/client-layou
|
|
|
6
6
|
* component; these components receive plain values and callbacks.
|
|
7
7
|
*/
|
|
8
8
|
export declare const FilterIcon: FunctionalComponent;
|
|
9
|
+
export declare const SearchIcon: FunctionalComponent<{
|
|
10
|
+
class?: string;
|
|
11
|
+
}>;
|
|
9
12
|
export declare const TableCell: FunctionalComponent<{
|
|
10
13
|
col: TableColumn;
|
|
11
14
|
row: Record<string, any>;
|
|
@@ -43,6 +46,14 @@ export interface ToolbarCallbacks {
|
|
|
43
46
|
/** Emit the create action; basicType set when chosen from the create-type picker. */
|
|
44
47
|
onCreate: (basicType?: string) => void;
|
|
45
48
|
onAction: (action: string) => void;
|
|
49
|
+
/** Expand the collapsed magnifying-glass icon into the search input, or collapse it back. */
|
|
50
|
+
onToggleSearch: () => void;
|
|
51
|
+
/** Free-text search input changed; caller debounces before reloading. */
|
|
52
|
+
onSearchInput: (value: string) => void;
|
|
53
|
+
/** Clear the query and collapse the search box back to the icon. */
|
|
54
|
+
onCloseSearch: () => void;
|
|
55
|
+
/** Captures the rendered <input> so the caller can focus it the instant it mounts. */
|
|
56
|
+
onSearchInputRef: (el?: HTMLInputElement) => void;
|
|
46
57
|
}
|
|
47
58
|
export declare const Toolbar: FunctionalComponent<{
|
|
48
59
|
locale: string;
|
|
@@ -58,5 +69,9 @@ export declare const Toolbar: FunctionalComponent<{
|
|
|
58
69
|
/** True when a viewer-role user has read-only access: mutating actions are
|
|
59
70
|
* disabled and their tooltip explains why instead of just repeating the label. */
|
|
60
71
|
readOnly?: boolean;
|
|
72
|
+
/** True only for a top-level VIEW item — RELATED_VIEW tables never show free-text search. */
|
|
73
|
+
searchEnabled?: boolean;
|
|
74
|
+
searchOpen?: boolean;
|
|
75
|
+
searchQuery?: string;
|
|
61
76
|
cb: ToolbarCallbacks;
|
|
62
77
|
}>;
|
|
@@ -10,6 +10,10 @@ export declare const DATE_TYPES: Set<string>;
|
|
|
10
10
|
export declare const NO_FILTER_TYPES: Set<string>;
|
|
11
11
|
/** Column types that cannot be sorted or filtered (not stored in PostgreSQL). */
|
|
12
12
|
export declare const NON_INTERACTIVE_TYPES: Set<string>;
|
|
13
|
+
/** Wait this long (ms) after the user stops typing in the free-text search box
|
|
14
|
+
* before firing the search request — mirrors REQUEST_DEBOUNCE_MS's purpose
|
|
15
|
+
* (skip intermediate keystrokes) but is tuned for typing, not scrolling. */
|
|
16
|
+
export declare const SEARCH_DEBOUNCE_MS = 400;
|
|
13
17
|
export declare function parseDefaultSort(defaultSort: string): {
|
|
14
18
|
field: string;
|
|
15
19
|
dir: 'asc' | 'desc';
|
|
@@ -23,6 +27,8 @@ export declare function buildTableQueryParams(opts: {
|
|
|
23
27
|
filterClass?: string | null;
|
|
24
28
|
viewFilters?: ViewFilter[] | null;
|
|
25
29
|
activeFilters: Iterable<ColumnFilter>;
|
|
30
|
+
/** Free-text search query from the toolbar's search box (VIEW only). */
|
|
31
|
+
query?: string;
|
|
26
32
|
}): string;
|
|
27
33
|
/** Groups aggregate columns by function; null when the view has no aggregates. */
|
|
28
34
|
export declare function buildAggregationParams(columns: TableColumn[]): {
|