@univerjs/sheets-data-validation-ui 0.8.0-nightly.202506041607 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +176 -0
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +282 -277
- package/lib/index.js +282 -277
- package/lib/umd/index.js +1 -1
- package/package.json +13 -13
package/lib/umd/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
(function(F,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/sheets-data-validation"),require("react/jsx-runtime"),require("@univerjs/design"),require("@univerjs/ui"),require("react"),require("@univerjs/sheets-formula-ui"),require("@univerjs/data-validation"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/engine-formula")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-data-validation","react/jsx-runtime","@univerjs/design","@univerjs/ui","react","@univerjs/sheets-formula-ui","@univerjs/data-validation","rxjs","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/engine-formula"],o):(F=typeof globalThis<"u"?globalThis:F||self,o(F.UniverSheetsDataValidationUi={},F.UniverCore,F.UniverSheetsDataValidation,F.React,F.UniverDesign,F.UniverUi,F.React,F.UniverSheetsFormulaUi,F.UniverDataValidation,F.rxjs,F.UniverEngineRender,F.UniverSheets,F.UniverSheetsNumfmt,F.UniverSheetsUi,F.UniverEngineFormula))})(this,function(F,o,f,v,M,b,R,ze,X,ie,P,$,Lt,B,Ke){"use strict";var lr=Object.defineProperty;var dr=(F,o,f)=>o in F?lr(F,o,{enumerable:!0,configurable:!0,writable:!0,value:f}):F[o]=f;var A=(F,o,f)=>dr(F,typeof o!="symbol"?o+"":o,f);var Ye,Xe;const Pt=e=>{const{isTwoFormula:t=!1,value:r,onChange:n,showError:a,validResult:i}=e,s=b.useDependency(o.LocaleService),d=a?i==null?void 0:i.formula1:"",l=a?i==null?void 0:i.formula2:"";return t?v.jsxs(v.Fragment,{children:[v.jsx(M.FormLayout,{error:d,children:v.jsx(M.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:r==null?void 0:r.formula1,onChange:c=>{n==null||n({...r,formula1:c})}})}),v.jsx("div",{className:"-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400",children:s.t("dataValidation.panel.formulaAnd")}),v.jsx(M.FormLayout,{error:l,children:v.jsx(M.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:r==null?void 0:r.formula2,onChange:c=>{n==null||n({...r,formula2:c})}})})]}):v.jsx(M.FormLayout,{error:d,children:v.jsx(M.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:r==null?void 0:r.formula1,onChange:c=>{n==null||n({formula1:c})}})})};function kt(e){const{value:t,onChange:r,showError:n,validResult:a}=e,i=b.useDependency(o.LocaleService),s=n?a==null?void 0:a.formula1:"",d=n?a==null?void 0:a.formula2:"",[l,c]=R.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return v.jsxs(v.Fragment,{children:[v.jsx(M.FormLayout,{children:v.jsx(M.Checkbox,{checked:l,onChange:h=>{h?c(!0):(c(!1),r==null||r({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),l?v.jsx(M.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:v.jsx(M.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{r==null||r({...t,formula1:h||void 0})}})}):null,l?v.jsx(M.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:d,children:v.jsx(M.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{r==null||r({...t,formula2:h||void 0})}})}):null]})}function Ft(e){var p;const{unitId:t,subUnitId:r,value:n,onChange:a,showError:i,validResult:s}=e,d=i?s==null?void 0:s.formula1:void 0,l=R.useRef(null),[c,h]=R.useState(!1);return b.useSidebarClick(u=>{var g;((g=l.current)==null?void 0:g.isClickOutSide(u))&&h(!1)}),v.jsx(M.FormLayout,{error:d,children:v.jsx(ze.FormulaEditor,{ref:l,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",M.borderClassName),initValue:(p=n==null?void 0:n.formula1)!=null?p:"=",unitId:t,subUnitId:r,isFocus:c,isSupportAcrossSheet:!0,onChange:u=>{const I=(u!=null?u:"").trim();I!==(n==null?void 0:n.formula1)&&(a==null||a({...n,formula1:I}))},onFocus:()=>h(!0)})})}var oe=function(){return oe=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},oe.apply(this,arguments)},Ut=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r},ge=R.forwardRef(function(e,t){var r=e.icon,n=e.id,a=e.className,i=e.extend,s=Ut(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(a||"").trim(),l=R.useRef("_".concat(Bt()));return vt(r,"".concat(n),{defIds:r.defIds,idSuffix:l.current},oe({ref:t,className:d},s),i)});function vt(e,t,r,n,a){return R.createElement(e.tag,oe(oe({key:t},Nt(e,r,a)),n),(jt(e,r).children||[]).map(function(i,s){return vt(i,"".concat(t,"-").concat(e.tag,"-").concat(s),r,void 0,a)}))}function Nt(e,t,r){var n=oe({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];s==="mask"&&typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var a=t.defIds;return!a||a.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function jt(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?oe(oe({},e),{children:e.children.map(function(a){return typeof a.attrs.id=="string"&&n&&n.includes(a.attrs.id)?oe(oe({},a),{attrs:oe(oe({},a.attrs),{id:a.attrs.id+t.idSuffix})}):a})}):e}function Bt(){return Math.random().toString(36).substring(2,8)}ge.displayName="UniverIcon";var Wt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.4917 3.07803C1.4917 2.19437 2.20804 1.47803 3.0917 1.47803H5.6917C6.57536 1.47803 7.2917 2.19437 7.2917 3.07803V5.67803C7.2917 6.56168 6.57535 7.27803 5.6917 7.27803H3.0917C2.20804 7.27803 1.4917 6.56168 1.4917 5.67803V3.07803ZM3.0917 2.67803C2.87078 2.67803 2.6917 2.85711 2.6917 3.07803V5.67803C2.6917 5.89894 2.87079 6.07803 3.0917 6.07803H5.6917C5.91261 6.07803 6.0917 5.89894 6.0917 5.67803V3.07803C6.0917 2.85711 5.91261 2.67803 5.6917 2.67803H3.0917Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.6175 2.45279C14.8518 2.68711 14.8518 3.06701 14.6175 3.30132L11.6151 6.30365C11.3957 6.52307 11.0451 6.53897 10.8067 6.34031L8.80915 4.67566C8.55458 4.46352 8.52019 4.08518 8.73233 3.83062C8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767L13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217L14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046C13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703L10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046C9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217L9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746C9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732L13.269 9.19746C13.5033 8.96315 13.8832 8.96315 14.1175 9.19746Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.0917 8.72168C2.20804 8.72168 1.4917 9.43802 1.4917 10.3217V12.9217C1.4917 13.8053 2.20804 14.5217 3.0917 14.5217H5.6917C6.57535 14.5217 7.2917 13.8053 7.2917 12.9217V10.3217C7.2917 9.43802 6.57536 8.72168 5.6917 8.72168H3.0917ZM2.6917 10.3217C2.6917 10.1008 2.87078 9.92168 3.0917 9.92168H5.6917C5.91261 9.92168 6.0917 10.1008 6.0917 10.3217V12.9217C6.0917 13.1426 5.91261 13.3217 5.6917 13.3217H3.0917C2.87079 13.3217 2.6917 13.1426 2.6917 12.9217V10.3217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},pt=R.forwardRef(function(e,t){return R.createElement(ge,Object.assign({},e,{id:"data-validation-icon",ref:t,icon:Wt}))});pt.displayName="DataValidationIcon";var Ht={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ze=R.forwardRef(function(e,t){return R.createElement(ge,Object.assign({},e,{id:"delete-icon",ref:t,icon:Ht}))});Ze.displayName="DeleteIcon";var xt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},gt=R.forwardRef(function(e,t){return R.createElement(ge,Object.assign({},e,{id:"increase-icon",ref:t,icon:xt}))});gt.displayName="IncreaseIcon";var $t={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ge=R.forwardRef(function(e,t){return R.createElement(ge,Object.assign({},e,{id:"more-down-icon",ref:t,icon:$t}))});Ge.displayName="MoreDownIcon";var Yt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.64645 9.85355C4.45118 9.65829 4.45118 9.34171 4.64645 9.14645L7.64645 6.14645C7.84171 5.95118 8.15829 5.95118 8.35355 6.14645L11.3536 9.14645C11.5488 9.34171 11.5488 9.65829 11.3536 9.85355C11.1583 10.0488 10.8417 10.0488 10.6464 9.85355L8 7.20711L5.35355 9.85355C5.15829 10.0488 4.84171 10.0488 4.64645 9.85355Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ft=R.forwardRef(function(e,t){return R.createElement(ge,Object.assign({},e,{id:"more-up-icon",ref:t,icon:Yt}))});ft.displayName="MoreUpIcon";var Xt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]}]},mt=R.forwardRef(function(e,t){return R.createElement(ge,Object.assign({},e,{id:"sequence-icon",ref:t,icon:Xt}))});mt.displayName="SequenceIcon";const Ce="#ECECEC",zt=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],Kt=e=>{const{value:t,onChange:r,disabled:n}=e,[a,i]=R.useState(!1);return v.jsx(M.Dropdown,{align:"start",disabled:n,open:a,onOpenChange:i,overlay:v.jsx("div",{className:"univer-box-border univer-grid univer-w-fit univer-grid-cols-6 univer-flex-wrap univer-gap-2 univer-p-1.5",children:zt.map(s=>v.jsx("div",{className:M.clsx("univer-box-border univer-size-4 univer-cursor-pointer univer-rounded",M.borderClassName),style:{background:s},onClick:()=>{r(s),i(!1)}},s))}),children:v.jsxs("div",{className:M.clsx("univer-box-border univer-inline-flex univer-h-8 univer-w-16 univer-cursor-pointer univer-items-center univer-justify-between univer-gap-2 univer-rounded-lg univer-bg-white univer-px-2.5 univer-transition-colors univer-duration-200 dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",M.borderClassName),children:[v.jsx("div",{className:"univer-box-border univer-h-4 univer-w-4 univer-rounded univer-text-base",style:{background:t}}),v.jsx(Ge,{})]})})},St=e=>{const{item:t,commonProps:r,className:n}=e,{onItemChange:a,onItemDelete:i}=r;return v.jsxs("div",{className:M.clsx("univer-flex univer-items-center univer-gap-2",n),children:[!t.isRef&&v.jsx("div",{className:M.clsx("univer-cursor-move","draggableHandle"),children:v.jsx(mt,{})}),v.jsx(Kt,{value:t.color,onChange:s=>{a(t.id,t.label,s)}}),v.jsx(M.Input,{disabled:t.isRef,value:t.label,onChange:s=>{a(t.id,s,t.color)}}),t.isRef?null:v.jsx("div",{className:"univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200",children:v.jsx(Ze,{onClick:()=>i(t.id)})})]})};function Zt(e){const{value:t,onChange:r=()=>{},unitId:n,subUnitId:a,validResult:i,showError:s,ruleId:d}=e,{formula1:l="",formula2:c=""}=t||{},[h,p]=R.useState(()=>o.isFormulaString(l)?"1":"0"),[u,I]=R.useState(h==="1"?l:"="),[g,V]=R.useState(h==="1"?l:"="),T=b.useDependency(o.LocaleService),m=b.useDependency(X.DataValidatorRegistryService),y=b.useDependency(X.DataValidationModel),S=b.useDependency(f.DataValidationFormulaController),[D,w]=R.useState(()=>c.split(",")),C=m.getValidatorItem(o.DataValidationType.LIST),[E,W]=R.useState([]),[x,O]=R.useState(""),U=s?i==null?void 0:i.formula1:"",k=R.useMemo(()=>y.ruleChange$.pipe(ie.debounceTime(16)),[]),N=b.useObservable(k),H=b.useEvent(r);R.useEffect(()=>{(async()=>{await new Promise(_=>{setTimeout(()=>_(!0),100)});const L=y.getRuleById(n,a,d),Y=L==null?void 0:L.formula1;if(o.isFormulaString(Y)&&C&&L){const _=await C.getListAsync(L,n,a);W(_)}})()},[y,N,C,d,a,n]),R.useEffect(()=>{o.isFormulaString(l)&&l!==g&&(I(l),V(g))},[g,l]);const[Z,K]=R.useState(()=>{const L=h!=="1"?f.deserializeListOptions(l):[],Y=c.split(",");return L.map((_,j)=>({label:_,color:Y[j]||Ce,isRef:!1,id:o.Tools.generateRandomId(4)}))}),te=(L,Y,_)=>{const j=Z.find(z=>z.id===L);j&&(j.label=Y,j.color=_,K([...Z]))},ae=L=>{const Y=Z.findIndex(_=>_.id===L);Y!==-1&&(Z.splice(Y,1),K([...Z]))},se=c.split(","),ce=R.useMemo(()=>E.map((L,Y)=>({label:L,color:se[Y]||Ce,id:`${Y}`,isRef:!0})),[se,E]),J=(L,Y,_)=>{const j=[...D];j[+L]=_,w(j),H({formula1:l,formula2:j.join(",")})},q=()=>{K([...Z,{label:"",color:Ce,isRef:!1,id:o.Tools.generateRandomId(4)}])};R.useEffect(()=>{if(h==="1")return;const L=new Set,Y=[];Z.map(_=>({labelList:_.label.split(","),item:_})).forEach(({item:_,labelList:j})=>{j.forEach(z=>{L.has(z)||(L.add(z),Y.push({label:z,color:_.color}))})}),H({formula1:f.serializeListOptions(Y.map(_=>_.label)),formula2:Y.map(_=>_.color===Ce?"":_.color).join(",")})},[Z,H,h,g,D]);const ve=b.useEvent(async L=>{if(!o.isFormulaString(L)){H==null||H({formula1:"",formula2:c});return}S.getFormulaRefCheck(L)?(H==null||H({formula1:o.isFormulaString(L)?L:"",formula2:c}),O("")):(H==null||H({formula1:"",formula2:c}),I("="),O(T.t("dataValidation.validFail.formulaError")))}),ne=R.useRef(null),[ee,Q]=R.useState(!1);return b.useSidebarClick(L=>{var _;((_=ne.current)==null?void 0:_.isClickOutSide(L))&&Q(!1)}),v.jsxs(v.Fragment,{children:[v.jsx(M.FormLayout,{label:T.t("dataValidation.list.options"),children:v.jsxs(M.RadioGroup,{value:h,onChange:L=>{p(L),I(g),L==="1"&&H({formula1:g==="="?"":g,formula2:D.join(",")})},children:[v.jsx(M.Radio,{value:"0",children:T.t("dataValidation.list.customOptions")}),v.jsx(M.Radio,{value:"1",children:T.t("dataValidation.list.refOptions")})]})}),h==="1"?v.jsxs(M.FormLayout,{error:U||x||void 0,children:[v.jsx(ze.FormulaEditor,{ref:ne,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",M.borderClassName),initValue:u,unitId:n,subUnitId:a,isFocus:ee,isSupportAcrossSheet:!0,onFocus:()=>Q(!0),onChange:(L="")=>{const Y=(L!=null?L:"").trim();V(Y),ve(Y)}}),ce.length>0&&v.jsx("div",{className:"univer-mt-3",children:ce.map(L=>v.jsx(St,{className:"univer-mb-3",item:L,commonProps:{onItemChange:J}},L.id))})]}):v.jsx(M.FormLayout,{error:U,children:v.jsxs("div",{className:"-univer-mt-3",children:[v.jsx(M.DraggableList,{list:Z,onListChange:K,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:L=>v.jsx(St,{item:L,commonProps:{onItemChange:te,onItemDelete:ae}},L.id),idKey:"id"}),v.jsxs("a",{className:"univer-flex univer-w-fit univer-cursor-pointer univer-flex-row univer-items-center univer-rounded univer-p-1 univer-px-2 univer-text-sm univer-text-primary dark:hover:!univer-bg-gray-800 hover:univer-bg-primary-50",onClick:q,children:[v.jsx(gt,{className:"univer-mr-1"}),T.t("dataValidation.list.add")]})]})})]})}const Gt=[[f.CUSTOM_FORMULA_INPUT_NAME,Ft],[f.BASE_FORMULA_INPUT_NAME,Pt],[f.LIST_FORMULA_INPUT_NAME,Zt],[f.CHECKBOX_FORMULA_INPUT_NAME,kt]];var qt=Object.getOwnPropertyDescriptor,Jt=(e,t,r,n)=>{for(var a=n>1?void 0:n?qt(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Qt=(e,t)=>(r,n)=>t(r,n,e);F.BaseSheetDataValidatorView=class{constructor(t){A(this,"canvasRender",null);A(this,"dropdownType");A(this,"optionsInput");A(this,"formulaInput",f.LIST_FORMULA_INPUT_NAME);this.injector=t}},F.BaseSheetDataValidatorView=Jt([Qt(0,o.Inject(o.Injector))],F.BaseSheetDataValidatorView);var en=Object.getOwnPropertyDescriptor,tn=(e,t,r,n)=>{for(var a=n>1?void 0:n?en(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},_t=(e,t)=>(r,n)=>t(r,n,e);let ue=class extends o.Disposable{constructor(t,r){super();A(this,"_open$",new ie.BehaviorSubject(!1));A(this,"open$",this._open$.pipe(ie.distinctUntilChanged()));A(this,"_activeRule");A(this,"_activeRule$",new ie.BehaviorSubject(void 0));A(this,"activeRule$",this._activeRule$.asObservable());A(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=r,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(ie.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===ke&&(n.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=o.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ue=tn([_t(0,o.IUniverInstanceService),_t(1,b.ISidebarService)],ue);const qe="sheets-data-validation-ui.config",Pe={};var nn=Object.getOwnPropertyDescriptor,rn=(e,t,r,n)=>{for(var a=n>1?void 0:n?nn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ye=(e,t)=>(r,n)=>t(r,n,e);let we=class extends o.Disposable{constructor(e,t,r,n,a,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=r,this._dialogService=n,this._localeService=a,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept($.VALIDATE_CELL,{handler:async(e,t,r)=>{const n=await e,{row:a,col:i,unitId:s,subUnitId:d}=t,l=this._dataValidationModel.getRuleIdByLocation(s,d,a,i),c=l?this._dataValidationModel.getRuleById(s,d,l):void 0;if(n===!1)return r(Promise.resolve(!1));if(!c||c.errorStyle!==o.DataValidationErrorStyle.STOP)return r(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(c.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,d,a,i)===o.DataValidationStatus.VALID?r(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:h.getRuleFinalError(c,{row:a,col:i,unitId:s,subUnitId:d})},footer:{title:R.createElement(M.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),r(Promise.resolve(!1)))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:R.createElement(M.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};we=rn([ye(0,o.Inject($.SheetInterceptorService)),ye(1,o.Inject(f.SheetDataValidationModel)),ye(2,o.Inject(X.DataValidatorRegistryService)),ye(3,b.IDialogService),ye(4,o.Inject(o.LocaleService)),ye(5,o.Inject(f.SheetsDataValidationValidatorService))],we);var an=Object.getOwnPropertyDescriptor,on=(e,t,r,n)=>{for(var a=n>1?void 0:n?an(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},le=(e,t)=>(r,n)=>t(r,n,e);const Je=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return o.dayjs(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=o.dayjs(e);if(t.isValid())return t};function sn(e,t){const r=Lt.getPatternType(t);if(e===r)return t;switch(e){case"datetime":return"yyyy-MM-dd hh:mm:ss";case"date":return"yyyy-MM-dd";case"time":return"HH:mm:ss"}}let fe=class extends o.Disposable{constructor(t,r,n,a,i,s,d,l,c,h,p){super();A(this,"_activeDropdown");A(this,"_activeDropdown$",new ie.Subject);A(this,"_currentPopup",null);A(this,"activeDropdown$",this._activeDropdown$.asObservable());A(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=r,this._zenZoneService=n,this._dataValidationModel=a,this._sheetsSelectionsService=i,this._cellDropdownManagerService=s,this._sheetDataValidationModel=d,this._commandService=l,this._editorBridgeService=c,this._injector=h,this._configService=p,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,r,n,a){const i=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=r?i.getSheetBySheetId(r):i.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),n,a);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(r=>!(r.primary&&this._getDropdownByCell(r.primary.unitId,r.primary.sheetId,r.primary.actualRow,r.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var V,T,m,y;const{location:r}=t,{row:n,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=r;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const c=this._sheetDataValidationModel.getRuleByLocation(i,s,n,a);if(!c)return;const h=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!(h!=null&&h.dropdownType))return;let p;const u=async(S,D)=>{var k,N,H;if(!S)return!0;const w=S,C=l.getCell(n,a),E=w.format(D==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),W=(k=o.numfmt.parseDate(E))==null?void 0:k.v,x=D==="time"?W%1:W,O=d.getStyles().getStyleByCell(C),U=(H=(N=O==null?void 0:O.n)==null?void 0:N.pattern)!=null?H:"";return c.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:x,unitId:i,subUnitId:s,row:n,column:a,worksheet:l,workbook:d,interceptValue:E.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},c)?(await this._commandService.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),await this._commandService.executeCommand($.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:x,t:2,p:null,f:null,si:null,s:{n:{pattern:sn(D,U)}}}}),!0):(this._injector.has(we)&&this._injector.get(we).showReject(h.getRuleFinalError(c,{row:n,col:a,unitId:i,subUnitId:s})),!1)};let I;switch(h.dropdownType){case X.DataValidatorDropdownType.DATE:{const S=f.getCellValueOrigin(l.getCellRaw(n,a)),D=Je(S),w=!!((V=c.bizInfo)!=null&&V.showTime);I={location:r,type:"datepicker",props:{showTime:w,onChange:C=>u(C,w?"datetime":"date"),defaultValue:D,patternType:"date"}};break}case X.DataValidatorDropdownType.TIME:{const S=f.getCellValueOrigin(l.getCellRaw(n,a)),D=Je(S);I={location:r,type:"datepicker",props:{onChange:w=>u(w,"time"),defaultValue:D,patternType:"time"}};break}case X.DataValidatorDropdownType.DATETIME:{const S=f.getCellValueOrigin(l.getCellRaw(n,a)),D=Je(S);I={location:r,type:"datepicker",props:{onChange:w=>u(w,"datetime"),defaultValue:D,patternType:"datetime"}};break}case X.DataValidatorDropdownType.LIST:case X.DataValidatorDropdownType.MULTIPLE_LIST:{const S=h.dropdownType===X.DataValidatorDropdownType.MULTIPLE_LIST,D=async O=>{const U=f.serializeListOptions(O),k={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:U,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),this._commandService.executeCommand($.SetRangeValuesCommand.id,k),!S},w=(c==null?void 0:c.renderMode)===o.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,C=h.getListWithColor(c,i,s),E=f.getDataValidationCellValue(l.getCellRaw(n,a)),W=()=>{this._commandService.executeCommand(me.id,{ruleId:c.uid}),p==null||p.dispose()},x=C.map(O=>({label:O.label,value:O.label,color:w||O.color?O.color:"transparent"}));I={location:r,type:"list",props:{onChange:O=>D(O),options:x,onEdit:W,defaultValue:E,multiple:S,showEdit:(m=(T=this._configService.getConfig(qe))==null?void 0:T.showEditOnDropdown)!=null?m:!0}};break}case X.DataValidatorDropdownType.CASCADE:{I={type:"cascader",props:{onChange:D=>{const w={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:D.join("/"),p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),this._commandService.syncExecuteCommand($.SetRangeValuesCommand.id,w),!0},defaultValue:f.getDataValidationCellValue(l.getCellRaw(n,a)).split("/"),options:JSON.parse((y=c.formula1)!=null?y:"[]")},location:r};break}case X.DataValidatorDropdownType.COLOR:{I={type:"color",props:{onChange:D=>{const w={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:D,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),this._commandService.syncExecuteCommand($.SetRangeValuesCommand.id,w),!0},defaultValue:f.getDataValidationCellValue(l.getCellRaw(n,a))},location:r};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(p=this._cellDropdownManagerService.showDropdown(I),!p)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const g=new o.DisposableCollection;g.add(p),g.add({dispose:()=>{var S,D;(D=(S=this._activeDropdown)==null?void 0:S.onHide)==null||D.call(S)}}),this._currentPopup=g}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,r,n,a,i){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(r);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,a);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!c||!c.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:n,col:a,unitId:t,subUnitId:r},onHide:i})}};fe=on([le(0,o.IUniverInstanceService),le(1,o.Inject(X.DataValidatorRegistryService)),le(2,b.IZenZoneService),le(3,o.Inject(f.SheetDataValidationModel)),le(4,o.Inject($.SheetsSelectionsService)),le(5,o.Inject(B.ISheetCellDropdownManagerService)),le(6,o.Inject(f.SheetDataValidationModel)),le(7,o.ICommandService),le(8,B.IEditorBridgeService),le(9,o.Inject(o.Injector)),le(10,o.IConfigService)],fe);const ke="DataValidationPanel",me={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:r,isAdd:n}=t,a=e.get(ue),i=e.get(X.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(b.ISidebarService),l=$.getSheetCommandTarget(s);if(!l)return!1;const{unitId:c,subUnitId:h}=l,p=r?i.getRuleById(c,h,r):void 0;a.open(),a.setActiveRule(p&&{unitId:c,subUnitId:h,rule:p});const u=d.open({id:ke,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:ke},width:312,onClose:()=>a.close()});return a.setCloseDisposable(u),!0}},Qe={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},It={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),r=e.get(ue);return r.open(),r.isOpen?t.executeCommand(Qe.id):t.executeCommand(me.id),!0}},Fe={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const r=e.get(fe),{unitId:n,subUnitId:a,row:i,column:s}=t,d=r.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===a&&l.row===i&&l.col===s||r.showDataValidationDropdown(n,a,i,s),!0}},Ct={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(fe).hideDropdown(),!0):!1}},Ue={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),r=$.getSheetCommandTarget(t);if(!r)return!1;const{workbook:n,worksheet:a}=r,i=f.createDefaultNewRule(e),s=e.get(o.ICommandService),d=n.getUnitId(),l=a.getSheetId(),c={rule:i,unitId:d,subUnitId:l};return s.syncExecuteCommand(f.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(me.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var ln=Object.getOwnPropertyDescriptor,dn=(e,t,r,n)=>{for(var a=n>1?void 0:n?ln(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},De=(e,t)=>(r,n)=>t(r,n,e);const Se="SHEET_DATA_VALIDATION_ALERT";let Ae=class extends o.Disposable{constructor(e,t,r,n,a,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=r,this._localeService=n,this._zenZoneService=a,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ie.debounceTime(100)).subscribe(e=>{var t;if(e){const r=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),n=r.getSheetBySheetId(e.location.subUnitId);if(!n)return;const a=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!a){this._cellAlertManagerService.removeAlert(Se);return}if(this._dataValidationModel.validator(a,{...e.location,workbook:r,worksheet:n})===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Se),d=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(d&&d.row===e.location.row&&d.col===e.location.col&&d.subUnitId===e.location.subUnitId&&d.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(Se);return}const l=this._dataValidationModel.getValidator(a.type);if(!l){this._cellAlertManagerService.removeAlert(Se);return}this._cellAlertManagerService.showAlert({type:B.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(a,e.location),location:e.location,width:200,height:74,key:Se});return}}this._cellAlertManagerService.removeAlert(Se)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(Se)}))}};Ae=dn([De(0,o.Inject(B.HoverManagerService)),De(1,o.Inject(B.CellAlertManagerService)),De(2,o.IUniverInstanceService),De(3,o.Inject(o.LocaleService)),De(4,b.IZenZoneService),De(5,o.Inject(f.SheetDataValidationModel))],Ae);var cn=Object.getOwnPropertyDescriptor,un=(e,t,r,n)=>{for(var a=n>1?void 0:n?cn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},et=(e,t)=>(r,n)=>t(r,n,e);let Ee=class extends o.Disposable{constructor(e,t,r){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=r,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,a)=>{const{source:i,target:s,unitId:d,subUnitId:l}=n,c=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),h=B.virtualizeDiscreteRanges([i,s]),[p,u]=h.ranges,{mapFunc:I}=h,g={row:p.startRow,col:p.startColumn},V=B.getAutoFillRepeatRange(p,u),T=new o.ObjectMatrix,m=new Set;V.forEach(C=>{const E=C.repeatStartCell,W=C.relativeRange,x={startRow:g.row,startColumn:g.col,endColumn:g.col,endRow:g.row},O={startRow:E.row,startColumn:E.col,endColumn:E.col,endRow:E.row};o.Range.foreach(W,(U,k)=>{const N=o.Rectangle.getPositionRange({startRow:U,startColumn:k,endColumn:k,endRow:U},x),{row:H,col:Z}=I(N.startRow,N.startColumn),K=this._sheetDataValidationModel.getRuleIdByLocation(d,l,H,Z)||"",te=o.Rectangle.getPositionRange({startRow:U,startColumn:k,endColumn:k,endRow:U},O),{row:ae,col:se}=I(te.startRow,te.startColumn);T.setValue(ae,se,K),m.add(K)})});const y=Array.from(m).map(C=>({id:C,ranges:o.queryObjectMatrix(T,E=>E===C)}));c.addRangeRules(y);const S=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:D,undoMutations:w}=f.getDataValidationDiffMutations(d,l,S,this._injector,"patched",a===B.APPLY_TYPE.ONLY_FORMAT);return{undos:w,redos:D}},r={id:f.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:a,unitId:i,subUnitId:s}=n;for(const d of a.rows)for(const l of a.cols){const c=this._sheetDataValidationModel.getRuleByLocation(i,s,d,l);if(c&&c.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(B.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,a,i)=>i===B.APPLY_TYPE.COPY||i===B.APPLY_TYPE.ONLY_FORMAT||i===B.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(r))}};Ee=un([et(0,B.IAutoFillService),et(1,o.Inject(f.SheetDataValidationModel)),et(2,o.Inject(o.Injector))],Ee);var hn=Object.getOwnPropertyDescriptor,vn=(e,t,r,n)=>{for(var a=n>1?void 0:n?hn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},tt=(e,t)=>(r,n)=>t(r,n,e);let Me=class extends o.Disposable{constructor(t,r,n){super();A(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=r,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:f.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,r,n)=>this._collect(t,r,n),onPasteCells:(t,r,n,a)=>{const{copyType:i=B.COPY_TYPE.COPY,pasteType:s}=a,{range:d}=t||{},{range:l,unitId:c,subUnitId:h}=r;return this._generateMutations(l,{copyType:i,pasteType:s,copyRange:d,unitId:c,subUnitId:h})}})}_collect(t,r,n){const a=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:r,matrix:a};const i=this._injector.invoke(l=>$.rangeToDiscreteRange(n,l,t,r));if(!i)return;const{rows:s,cols:d}=i;s.forEach((l,c)=>{d.forEach((h,p)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,r,l,h);a.setValue(c,p,u!=null?u:"")})})}_generateMutations(t,r){if(!this._copyInfo)return{redos:[],undos:[]};if(r.copyType===B.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!r.copyRange)return{redos:[],undos:[]};if([B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(r.pasteType))return{redos:[],undos:[]};const{unitId:a,subUnitId:i}=this._copyInfo;if(r.unitId!==a||i!==r.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(r.unitId,r.subUnitId).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:p}=B.virtualizeDiscreteRanges([r.copyRange,t]),u=B.getRepeatRange(c,h,!0),I=new Map;u.forEach(({startRange:m})=>{var y;(y=this._copyInfo)==null||y.matrix.forValue((S,D,w)=>{const C=o.Rectangle.getPositionRange({startRow:S,endRow:S,startColumn:D,endColumn:D},m),E=`${i}-${w}`,W=this._sheetDataValidationModel.getRuleById(a,i,w);!this._sheetDataValidationModel.getRuleById(r.unitId,r.subUnitId,E)&&W&&I.set(E,{...W,uid:E});const{row:x,col:O}=p(C.startRow,C.startColumn);l.add(E),d.setValue(x,O,E)})});const g=Array.from(l).map(m=>({id:m,ranges:o.queryObjectMatrix(d,y=>y===m)}));s.addRangeRules(g);const{redoMutations:V,undoMutations:T}=f.getDataValidationDiffMutations(r.unitId,r.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(r.unitId,r.subUnitId),I.values()),this._injector,"patched",!1);return{redos:V,undos:T}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(a,i).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:p}=B.virtualizeDiscreteRanges([r.copyRange,t]);B.getRepeatRange(c,h,!0).forEach(({startRange:T})=>{var m;(m=this._copyInfo)==null||m.matrix.forValue((y,S,D)=>{const w=o.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:S,endColumn:S},T),{row:C,col:E}=p(w.startRow,w.startColumn);d.setValue(C,E,D),l.add(D)})});const I=Array.from(l).map(T=>({id:T,ranges:o.queryObjectMatrix(d,m=>m===T)}));s.addRangeRules(I);const{redoMutations:g,undoMutations:V}=f.getDataValidationDiffMutations(a,i,s.diff(this._sheetDataValidationModel.getRules(a,i)),this._injector,"patched",!1);return{redos:g,undos:V}}}};Me=vn([tt(0,B.ISheetClipboardService),tt(1,o.Inject(f.SheetDataValidationModel)),tt(2,o.Inject(o.Injector))],Me);var pn=Object.getOwnPropertyDescriptor,gn=(e,t,r,n)=>{for(var a=n>1?void 0:n?pn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},nt=(e,t)=>(r,n)=>t(r,n,e);let be=class extends o.Disposable{constructor(e,t,r){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=r,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===f.AddSheetDataValidationCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[$.WorkbookEditablePermission],rangeTypes:[$.RangeProtectionPermissionEditPoint],worksheetTypes:[$.WorksheetEditPermission,$.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===f.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[$.WorkbookEditablePermission],rangeTypes:[$.RangeProtectionPermissionEditPoint],worksheetTypes:[$.WorksheetEditPermission,$.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};be=gn([nt(0,o.Inject(o.LocaleService)),nt(1,o.ICommandService),nt(2,o.Inject($.SheetPermissionCheckController))],be);const yt="sheet.menu.data-validation";function fn(e){return{id:yt,type:b.MenuItemType.SUBITEMS,icon:"DataValidationIcon",tooltip:"dataValidation.title",hidden$:b.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:B.getCurrentRangeDisable$(e,{workbookTypes:[$.WorkbookEditablePermission],worksheetTypes:[$.WorksheetSetCellStylePermission,$.WorksheetEditPermission],rangeTypes:[$.RangeProtectionPermissionEditPoint]})}}function mn(e){return{id:me.id,title:"dataValidation.panel.title",type:b.MenuItemType.BUTTON}}function Sn(e){return{id:Ue.id,title:"dataValidation.panel.add",type:b.MenuItemType.BUTTON}}const _n={[b.RibbonDataGroup.RULES]:{[yt]:{order:0,menuItemFactory:fn,[me.id]:{order:0,menuItemFactory:mn},[Ue.id]:{order:1,menuItemFactory:Sn}}}};var In=Object.getOwnPropertyDescriptor,wt=(e,t,r,n)=>{for(var a=n>1?void 0:n?In(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},G=(e,t)=>(r,n)=>t(r,n,e);const Dt={tr:{size:6,color:"#fe4b4b"}};let Te=class extends o.RxDisposable{constructor(e,t,r,n,a,i,s,d,l,c,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=r,this._univerInstanceService=n,this._autoHeightController=a,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=c,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(_n)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var r;if(!e.visible){((r=this._dropdownManagerService.activeDropdown)==null?void 0:r.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:a,row:i,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,a,i,s);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(c!=null&&c.dropdownType))return;const h=d.getActiveSheet();if(!h)return;const p=this._dropdownManagerService.activeDropdown,u=p==null?void 0:p.location;if(u&&u.unitId===n&&u.subUnitId===a&&u.row===i&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:a,row:i,col:s,workbook:d,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept($.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:$.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,r)=>{var m,y,S,D,w;const{row:n,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,a);if(!c)return r(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return r(e);const p=(m=this._dataValidationCacheService.getValue(i,s,n,a))!=null?m:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),I=t.rawData;let g;const V={get value(){var C;return g!==void 0||(g=(C=f.getCellValueOrigin(I))!=null?C:null),g}},T={get value(){var C;return`${(C=V.value)!=null?C:""}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...p===o.DataValidationStatus.INVALID?Dt:null},e.customRender=[...(y=e==null?void 0:e.customRender)!=null?y:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((S=e==null?void 0:e.fontRenderExtension)==null?void 0:S.isSkip)||((D=u==null?void 0:u.skipDefaultFontRender)==null?void 0:D.call(u,h,V.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,T.value,{get style(){const C=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?C.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,a)},e.interceptorAutoHeight=()=>{var x,O,U,k,N,H;const C=(O=(x=this._renderManagerService.getRenderById(i))==null?void 0:x.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:O.skeleton;if(!C)return;const E=C.worksheet.getMergedCell(n,a),W={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((U=E==null?void 0:E.startRow)!=null?U:n,(k=E==null?void 0:E.startColumn)!=null?k:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(H=(N=u==null?void 0:u.canvasRender)==null?void 0:N.calcCellAutoHeight)==null?void 0:H.call(N,W)},e.interceptorAutoWidth=()=>{var x,O,U,k,N,H;const C=(O=(x=this._renderManagerService.getRenderById(i))==null?void 0:x.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:O.skeleton;if(!C)return;const E=C.worksheet.getMergedCell(n,a),W={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((U=E==null?void 0:E.startRow)!=null?U:n,(k=E==null?void 0:E.startColumn)!=null?k:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(H=(N=u==null?void 0:u.canvasRender)==null?void 0:N.calcCellAutoWidth)==null?void 0:H.call(N,W)},e.coverable=((w=e==null?void 0:e.coverable)!=null?w:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),r(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(r=>{var n;(r.rule.type===o.DataValidationType.LIST_MULTIPLE||r.rule.type===o.DataValidationType.LIST)&&(n=r.rule)!=null&&n.ranges&&t.push(...r.rule.ranges)}),t.length){const r=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(r.redos,this._commandService)}})}};Te=wt([G(0,o.ICommandService),G(1,b.IMenuManagerService),G(2,P.IRenderManagerService),G(3,o.IUniverInstanceService),G(4,o.Inject(B.AutoHeightController)),G(5,o.Inject(fe)),G(6,o.Inject(f.SheetDataValidationModel)),G(7,o.Inject(X.DataValidatorRegistryService)),G(8,o.Inject($.SheetInterceptorService)),G(9,o.Inject(f.DataValidationCacheService)),G(10,o.Optional(B.IEditorBridgeService))],Te);let Et=class extends o.RxDisposable{constructor(e,t,r,n,a,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=r,this._dataValidatorRegistryService=n,this._sheetInterceptorService=a,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept($.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:$.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,r)=>{var T,m,y,S,D;const{row:n,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,a);if(!c)return r(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return r(e);const p=(T=this._dataValidationCacheService.getValue(i,s,n,a))!=null?T:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),I=l.getCellRaw(n,a),g=f.getCellValueOrigin(I),V=`${g!=null?g:""}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...p===o.DataValidationStatus.INVALID?Dt:null},e.customRender=[...(m=e==null?void 0:e.customRender)!=null?m:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((y=e==null?void 0:e.fontRenderExtension)==null?void 0:y.isSkip)||((S=u==null?void 0:u.skipDefaultFontRender)==null?void 0:S.call(u,h,g,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,V,{get style(){const w=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?w.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,a)},e.interceptorAutoHeight=()=>{var W,x,O,U,k,N;const w=(x=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:x.skeleton;if(!w)return;const C=w.worksheet.getMergedCell(n,a),E={data:e,style:w.getStyles().getStyleByCell(e),primaryWithCoord:w.getCellWithCoordByIndex((O=C==null?void 0:C.startRow)!=null?O:n,(U=C==null?void 0:C.startColumn)!=null?U:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(N=(k=u==null?void 0:u.canvasRender)==null?void 0:k.calcCellAutoHeight)==null?void 0:N.call(k,E)},e.interceptorAutoWidth=()=>{var W,x,O,U,k,N;const w=(x=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:x.skeleton;if(!w)return;const C=w.worksheet.getMergedCell(n,a),E={data:e,style:w.getStyles().getStyleByCell(e),primaryWithCoord:w.getCellWithCoordByIndex((O=C==null?void 0:C.startRow)!=null?O:n,(U=C==null?void 0:C.startColumn)!=null?U:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(N=(k=u==null?void 0:u.canvasRender)==null?void 0:k.calcCellAutoWidth)==null?void 0:N.call(k,E)},e.coverable=((D=e==null?void 0:e.coverable)!=null?D:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),r(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(r=>{var n;(r.rule.type===o.DataValidationType.LIST_MULTIPLE||r.rule.type===o.DataValidationType.LIST)&&(n=r.rule)!=null&&n.ranges&&t.push(...r.rule.ranges)}),t.length){const r=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(r.redos,this._commandService)}})}};Et=wt([G(0,o.ICommandService),G(1,P.IRenderManagerService),G(2,o.Inject(B.AutoHeightController)),G(3,o.Inject(X.DataValidatorRegistryService)),G(4,o.Inject($.SheetInterceptorService)),G(5,o.Inject(f.SheetDataValidationModel)),G(6,o.Inject(f.DataValidationCacheService))],Et);var Cn=Object.getOwnPropertyDescriptor,yn=(e,t,r,n)=>{for(var a=n>1?void 0:n?Cn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Mt=(e,t)=>(r,n)=>t(r,n,e);let Ne=class extends o.Disposable{constructor(e,t,r){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=r,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const r=new Set;t.forEach(a=>{r.add(a.subUnitId)}),r.forEach(a=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(a))==null||i.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};Ne=yn([Mt(1,o.Inject(f.SheetDataValidationModel)),Mt(2,o.Inject(B.SheetSkeletonManagerService))],Ne);function wn(e){var c;const t=b.useDependency(o.LocaleService),r=b.useDependency(b.ComponentManager),{value:n,onChange:a,extraComponent:i}=e,[s,d]=R.useState(!1),l=i?r.get(i):null;return v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-gray-900 dark:!univer-text-white",onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?v.jsx(ft,{className:"univer-ml-1"}):v.jsx(Ge,{className:"univer-ml-1"})]}),s&&v.jsxs(v.Fragment,{children:[l?v.jsx(l,{value:n,onChange:a}):null,v.jsx(M.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:v.jsxs(M.RadioGroup,{value:`${(c=n.errorStyle)!=null?c:o.DataValidationErrorStyle.WARNING}`,onChange:h=>a({...n,errorStyle:+h}),children:[v.jsx(M.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),v.jsx(M.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),v.jsx(M.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:v.jsx(M.Checkbox,{checked:n.showErrorMessage,onChange:()=>a({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?v.jsx(M.FormLayout,{children:v.jsx(M.Input,{value:n.error,onChange:h=>a({...n,error:h})})}):null]})]})}const Dn=e=>o.debounce(async(t,r,n,a)=>{const i=await e.executeCommand(t,r,n);a==null||a(i)},1e3);function En(e,t,r){var n,a,i,s;return t?((a=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(r))==null?void 0:a.getSheetId())||"":((s=(i=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(r))==null?void 0:s.getSheetId())||""}function Mn(){var L,Y;const[e,t]=R.useState(0),r=b.useDependency(ue),n=b.useObservable(r.activeRule$,r.activeRule),{unitId:a,subUnitId:i,rule:s}=n||{},d=s.uid,l=b.useDependency(X.DataValidatorRegistryService),c=b.useDependency(o.IUniverInstanceService),h=b.useDependency(b.ComponentManager),p=b.useDependency(o.ICommandService),u=b.useDependency(X.DataValidationModel),I=b.useDependency(o.LocaleService),[g,V]=R.useState(s),T=l.getValidatorItem(g.type),[m,y]=R.useState(!1),S=l.getValidatorsByScope(X.DataValidatorRegistryScope.SHEET),[D,w]=R.useState(()=>g.ranges.map(_=>({unitId:"",sheetId:"",range:_}))),C=R.useMemo(()=>Dn(p),[p]),[E,W]=R.useState(!1),[x,O]=R.useState(!1),U=R.useRef(null),k=b.useDependency($.SheetsSelectionsService);if(R.useEffect(()=>()=>{const _=k.getCurrentLastSelection();_&&k.setSelections([_])},[k]),R.useEffect(()=>{p.onCommandExecuted(_=>{(_.id===o.UndoCommand.id||_.id===o.RedoCommand.id)&&setTimeout(()=>{const j=u.getRuleById(a,i,d);t(z=>z+1),j&&(V(j),w(j.ranges.map(z=>({unitId:"",sheetId:"",range:z}))))},20)})},[p,u,d,i,a]),!T)return null;const N=T.operators,H=T.operatorNames,Z=g.operator?X.TWO_FORMULA_OPERATOR_COUNT.includes(g.operator):!1,K=()=>{var _,j,z;(j=(_=U.current)==null?void 0:_.editor)!=null&&j.isFocus()&&te((z=U.current)==null?void 0:z.getValue()),!(!g.ranges.length||E)&&(T.validatorFormula(g,a,i).success?r.setActiveRule(null):y(!0))},te=b.useEvent(_=>{const j=_.split(",").filter(Boolean).map(Ke.deserializeRangeWithSheet).map(re=>{const At=re.sheetName;if(At){const sr=En(c,re.unitId,At);return{...re,sheetId:sr}}return{...re,sheetId:""}});if(o.isUnitRangesEqual(j,D))return;w(j);const z=j.filter(re=>(!re.unitId||re.unitId===a)&&(!re.sheetId||re.sheetId===i)).map(re=>re.range);if(V({...g,ranges:z}),z.length===0)return;const pe={unitId:a,subUnitId:i,ruleId:d,ranges:z};C(f.UpdateSheetDataValidationRangeCommand.id,pe)}),ae=_=>{if(o.shallowEqual(_,X.getRuleSetting(g)))return;V({...g,..._});const j={unitId:a,subUnitId:i,ruleId:d,setting:_};C(f.UpdateSheetDataValidationSettingCommand.id,j,void 0)},se=async()=>{await p.executeCommand(f.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:a,subUnitId:i}),r.setActiveRule(null)},ce={type:g.type,operator:g.operator,formula1:g.formula1,formula2:g.formula2,allowBlank:g.allowBlank},J=_=>{const j=l.getValidatorItem(_);if(!j)return;const z=j.operators,pe=u.getRuleById(a,i,d),re=_===(pe==null?void 0:pe.type)||_.includes("list")&&(pe!=null&&pe.type.includes("list"))?{...pe,type:_}:{...g,type:_,operator:z[0],formula1:void 0,formula2:void 0};V(re),p.executeCommand(f.UpdateSheetDataValidationSettingCommand.id,{unitId:a,subUnitId:i,ruleId:g.uid,setting:X.getRuleSetting(re)})},q=h.get(T.formulaInput),ve=R.useMemo(()=>D.map(_=>Ke.serializeRange(_.range)).join(","),[]),ne=X.getRuleOptions(g),ee=_=>{o.shallowEqual(_,X.getRuleOptions(g))||(V({...g,..._}),C(f.UpdateSheetDataValidationOptionsCommand.id,{unitId:a,subUnitId:i,ruleId:d,options:_}))},Q=N.length&&!g.operator;return v.jsxs("div",{"data-u-comp":"data-validation-detail",className:"univer-py-2",children:[v.jsx(M.FormLayout,{label:I.t("dataValidation.panel.range"),error:!g.ranges.length||E?I.t("dataValidation.panel.rangeError"):"",children:v.jsx(ze.RangeSelector,{selectorRef:U,unitId:a,subUnitId:i,initialValue:ve,onChange:(_,j)=>{var z;!x&&((z=U.current)!=null&&z.verify())&&te(j)},onFocusChange:(_,j)=>{var z;O(_),!_&&j&&((z=U.current)!=null&&z.verify())&&te(j)},onVerify:_=>W(!_)})}),v.jsx(M.FormLayout,{label:I.t("dataValidation.panel.type"),children:v.jsx(M.Select,{className:"univer-w-full",value:g.type,options:(L=S==null?void 0:S.sort((_,j)=>_.order-j.order))==null?void 0:L.map(_=>({label:I.t(_.title),value:_.id})),onChange:J})}),N!=null&&N.length?v.jsx(M.FormLayout,{label:I.t("dataValidation.panel.operator"),children:v.jsx(M.Select,{className:"univer-w-full",value:`${g.operator}`,options:[{value:"",label:I.t("dataValidation.operators.legal")},...N.map((_,j)=>({value:`${_}`,label:H[j]}))],onChange:_=>{ae({...ce,operator:_})}})}):null,q&&!Q?v.jsx(q,{isTwoFormula:Z,value:{formula1:g.formula1,formula2:g.formula2},onChange:_=>{ae({...ce,..._})},showError:m,validResult:T.validatorFormula(g,a,i),unitId:a,subUnitId:i,ruleId:d},e+g.type):null,v.jsx(M.FormLayout,{children:v.jsx(M.Checkbox,{checked:(Y=g.allowBlank)!=null?Y:!0,onChange:()=>{var _;return ae({...ce,allowBlank:!((_=g.allowBlank)==null||_)})},children:I.t("dataValidation.panel.allowBlank")})}),v.jsx(wn,{value:ne,onChange:ee,extraComponent:T.optionsInput}),v.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[v.jsx(M.Button,{className:"univer-ml-3",onClick:se,children:I.t("dataValidation.panel.removeRule")}),v.jsx(M.Button,{className:"univer-ml-3",variant:"primary",onClick:K,children:I.t("dataValidation.panel.done")})]})]})}const bn=e=>{const{rule:t,onClick:r,unitId:n,subUnitId:a,disable:i}=e,s=b.useDependency(X.DataValidatorRegistryService),d=b.useDependency(o.ICommandService),l=b.useDependency(B.IMarkSelectionService),c=s.getValidatorItem(t.type),h=R.useRef(void 0),[p,u]=R.useState(!1),I=b.useDependency(o.ThemeService),g=b.useObservable(I.currentTheme$),V=R.useMemo(()=>{var w;const m=I.getColorFromTheme("primary.600"),y=I.getColorFromTheme("loop-color.2"),S=(w=I.getColorFromTheme(y))!=null?w:m,D=new o.ColorKit(S).toRgb();return{fill:`rgba(${D.r}, ${D.g}, ${D.b}, 0.1)`,stroke:S}},[g]),T=m=>{d.executeCommand(f.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:a}),m.stopPropagation()};return R.useEffect(()=>()=>{var m;h.current&&((m=h.current)==null||m.forEach(y=>{y&&l.removeShape(y)}))},[l]),v.jsxs("div",{className:M.clsx(`
|
1
|
+
(function(F,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/sheets-data-validation"),require("react/jsx-runtime"),require("@univerjs/design"),require("@univerjs/ui"),require("react"),require("@univerjs/sheets-formula-ui"),require("@univerjs/data-validation"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/engine-formula")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-data-validation","react/jsx-runtime","@univerjs/design","@univerjs/ui","react","@univerjs/sheets-formula-ui","@univerjs/data-validation","rxjs","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/engine-formula"],o):(F=typeof globalThis<"u"?globalThis:F||self,o(F.UniverSheetsDataValidationUi={},F.UniverCore,F.UniverSheetsDataValidation,F.React,F.UniverDesign,F.UniverUi,F.React,F.UniverSheetsFormulaUi,F.UniverDataValidation,F.rxjs,F.UniverEngineRender,F.UniverSheets,F.UniverSheetsNumfmt,F.UniverSheetsUi,F.UniverEngineFormula))})(this,function(F,o,f,v,M,b,R,ze,X,ie,P,$,Lt,B,Ke){"use strict";var lr=Object.defineProperty;var dr=(F,o,f)=>o in F?lr(F,o,{enumerable:!0,configurable:!0,writable:!0,value:f}):F[o]=f;var A=(F,o,f)=>dr(F,typeof o!="symbol"?o+"":o,f);var Ye,Xe;const Pt=e=>{const{isTwoFormula:t=!1,value:r,onChange:n,showError:a,validResult:i}=e,s=b.useDependency(o.LocaleService),d=a?i==null?void 0:i.formula1:"",l=a?i==null?void 0:i.formula2:"";return t?v.jsxs(v.Fragment,{children:[v.jsx(M.FormLayout,{error:d,children:v.jsx(M.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:r==null?void 0:r.formula1,onChange:c=>{n==null||n({...r,formula1:c})}})}),v.jsx("div",{className:"-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400",children:s.t("dataValidation.panel.formulaAnd")}),v.jsx(M.FormLayout,{error:l,children:v.jsx(M.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:r==null?void 0:r.formula2,onChange:c=>{n==null||n({...r,formula2:c})}})})]}):v.jsx(M.FormLayout,{error:d,children:v.jsx(M.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:r==null?void 0:r.formula1,onChange:c=>{n==null||n({formula1:c})}})})};function kt(e){const{value:t,onChange:r,showError:n,validResult:a}=e,i=b.useDependency(o.LocaleService),s=n?a==null?void 0:a.formula1:"",d=n?a==null?void 0:a.formula2:"",[l,c]=R.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return v.jsxs(v.Fragment,{children:[v.jsx(M.FormLayout,{children:v.jsx(M.Checkbox,{checked:l,onChange:h=>{h?c(!0):(c(!1),r==null||r({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),l?v.jsx(M.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:v.jsx(M.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{r==null||r({...t,formula1:h||void 0})}})}):null,l?v.jsx(M.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:d,children:v.jsx(M.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{r==null||r({...t,formula2:h||void 0})}})}):null]})}function Ft(e){var p;const{unitId:t,subUnitId:r,value:n,onChange:a,showError:i,validResult:s}=e,d=i?s==null?void 0:s.formula1:void 0,l=R.useRef(null),[c,h]=R.useState(!1);return b.useSidebarClick(u=>{var g;((g=l.current)==null?void 0:g.isClickOutSide(u))&&h(!1)}),v.jsx(M.FormLayout,{error:d,children:v.jsx(ze.FormulaEditor,{ref:l,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",M.borderClassName),initValue:(p=n==null?void 0:n.formula1)!=null?p:"=",unitId:t,subUnitId:r,isFocus:c,isSupportAcrossSheet:!0,onChange:u=>{const I=(u!=null?u:"").trim();I!==(n==null?void 0:n.formula1)&&(a==null||a({...n,formula1:I}))},onFocus:()=>h(!0)})})}var oe=function(){return oe=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},oe.apply(this,arguments)},Ut=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r},ge=R.forwardRef(function(e,t){var r=e.icon,n=e.id,a=e.className,i=e.extend,s=Ut(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(a||"").trim(),l=R.useRef("_".concat(Bt()));return vt(r,"".concat(n),{defIds:r.defIds,idSuffix:l.current},oe({ref:t,className:d},s),i)});function vt(e,t,r,n,a){return R.createElement(e.tag,oe(oe({key:t},Nt(e,r,a)),n),(jt(e,r).children||[]).map(function(i,s){return vt(i,"".concat(t,"-").concat(e.tag,"-").concat(s),r,void 0,a)}))}function Nt(e,t,r){var n=oe({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];s==="mask"&&typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var a=t.defIds;return!a||a.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function jt(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?oe(oe({},e),{children:e.children.map(function(a){return typeof a.attrs.id=="string"&&n&&n.includes(a.attrs.id)?oe(oe({},a),{attrs:oe(oe({},a.attrs),{id:a.attrs.id+t.idSuffix})}):a})}):e}function Bt(){return Math.random().toString(36).substring(2,8)}ge.displayName="UniverIcon";var Wt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.4917 3.07803C1.4917 2.19437 2.20804 1.47803 3.0917 1.47803H5.6917C6.57536 1.47803 7.2917 2.19437 7.2917 3.07803V5.67803C7.2917 6.56168 6.57535 7.27803 5.6917 7.27803H3.0917C2.20804 7.27803 1.4917 6.56168 1.4917 5.67803V3.07803ZM3.0917 2.67803C2.87078 2.67803 2.6917 2.85711 2.6917 3.07803V5.67803C2.6917 5.89894 2.87079 6.07803 3.0917 6.07803H5.6917C5.91261 6.07803 6.0917 5.89894 6.0917 5.67803V3.07803C6.0917 2.85711 5.91261 2.67803 5.6917 2.67803H3.0917Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.6175 2.45279C14.8518 2.68711 14.8518 3.06701 14.6175 3.30132L11.6151 6.30365C11.3957 6.52307 11.0451 6.53897 10.8067 6.34031L8.80915 4.67566C8.55458 4.46352 8.52019 4.08518 8.73233 3.83062C8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767L13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217L14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046C13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703L10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046C9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217L9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746C9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732L13.269 9.19746C13.5033 8.96315 13.8832 8.96315 14.1175 9.19746Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.0917 8.72168C2.20804 8.72168 1.4917 9.43802 1.4917 10.3217V12.9217C1.4917 13.8053 2.20804 14.5217 3.0917 14.5217H5.6917C6.57535 14.5217 7.2917 13.8053 7.2917 12.9217V10.3217C7.2917 9.43802 6.57536 8.72168 5.6917 8.72168H3.0917ZM2.6917 10.3217C2.6917 10.1008 2.87078 9.92168 3.0917 9.92168H5.6917C5.91261 9.92168 6.0917 10.1008 6.0917 10.3217V12.9217C6.0917 13.1426 5.91261 13.3217 5.6917 13.3217H3.0917C2.87079 13.3217 2.6917 13.1426 2.6917 12.9217V10.3217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},pt=R.forwardRef(function(e,t){return R.createElement(ge,Object.assign({},e,{id:"data-validation-icon",ref:t,icon:Wt}))});pt.displayName="DataValidationIcon";var Ht={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ze=R.forwardRef(function(e,t){return R.createElement(ge,Object.assign({},e,{id:"delete-icon",ref:t,icon:Ht}))});Ze.displayName="DeleteIcon";var xt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},gt=R.forwardRef(function(e,t){return R.createElement(ge,Object.assign({},e,{id:"increase-icon",ref:t,icon:xt}))});gt.displayName="IncreaseIcon";var $t={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ge=R.forwardRef(function(e,t){return R.createElement(ge,Object.assign({},e,{id:"more-down-icon",ref:t,icon:$t}))});Ge.displayName="MoreDownIcon";var Yt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.64645 9.85355C4.45118 9.65829 4.45118 9.34171 4.64645 9.14645L7.64645 6.14645C7.84171 5.95118 8.15829 5.95118 8.35355 6.14645L11.3536 9.14645C11.5488 9.34171 11.5488 9.65829 11.3536 9.85355C11.1583 10.0488 10.8417 10.0488 10.6464 9.85355L8 7.20711L5.35355 9.85355C5.15829 10.0488 4.84171 10.0488 4.64645 9.85355Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ft=R.forwardRef(function(e,t){return R.createElement(ge,Object.assign({},e,{id:"more-up-icon",ref:t,icon:Yt}))});ft.displayName="MoreUpIcon";var Xt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]}]},mt=R.forwardRef(function(e,t){return R.createElement(ge,Object.assign({},e,{id:"sequence-icon",ref:t,icon:Xt}))});mt.displayName="SequenceIcon";const Ce="#ECECEC",zt=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],Kt=e=>{const{value:t,onChange:r,disabled:n}=e,[a,i]=R.useState(!1);return v.jsx(M.Dropdown,{align:"start",disabled:n,open:a,onOpenChange:i,overlay:v.jsx("div",{className:"univer-box-border univer-grid univer-w-fit univer-grid-cols-6 univer-flex-wrap univer-gap-2 univer-p-1.5",children:zt.map(s=>v.jsx("div",{className:M.clsx("univer-box-border univer-size-4 univer-cursor-pointer univer-rounded",M.borderClassName),style:{background:s},onClick:()=>{r(s),i(!1)}},s))}),children:v.jsxs("div",{className:M.clsx("univer-box-border univer-inline-flex univer-h-8 univer-w-16 univer-cursor-pointer univer-items-center univer-justify-between univer-gap-2 univer-rounded-lg univer-bg-white univer-px-2.5 univer-transition-colors univer-duration-200 dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",M.borderClassName),children:[v.jsx("div",{className:"univer-box-border univer-h-4 univer-w-4 univer-rounded univer-text-base",style:{background:t}}),v.jsx(Ge,{})]})})},St=e=>{const{item:t,commonProps:r,className:n}=e,{onItemChange:a,onItemDelete:i}=r;return v.jsxs("div",{className:M.clsx("univer-flex univer-items-center univer-gap-2",n),children:[!t.isRef&&v.jsx("div",{className:M.clsx("univer-cursor-move","draggableHandle"),children:v.jsx(mt,{})}),v.jsx(Kt,{value:t.color,onChange:s=>{a(t.id,t.label,s)}}),v.jsx(M.Input,{disabled:t.isRef,value:t.label,onChange:s=>{a(t.id,s,t.color)}}),t.isRef?null:v.jsx("div",{className:"univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200",children:v.jsx(Ze,{onClick:()=>i(t.id)})})]})};function Zt(e){const{value:t,onChange:r=()=>{},unitId:n,subUnitId:a,validResult:i,showError:s,ruleId:d}=e,{formula1:l="",formula2:c=""}=t||{},[h,p]=R.useState(()=>o.isFormulaString(l)?"1":"0"),[u,I]=R.useState(h==="1"?l:"="),[g,V]=R.useState(h==="1"?l:"="),T=b.useDependency(o.LocaleService),m=b.useDependency(X.DataValidatorRegistryService),y=b.useDependency(X.DataValidationModel),S=b.useDependency(f.DataValidationFormulaController),[D,w]=R.useState(()=>c.split(",")),C=m.getValidatorItem(o.DataValidationType.LIST),[E,W]=R.useState([]),[x,O]=R.useState(""),U=s?i==null?void 0:i.formula1:"",k=R.useMemo(()=>y.ruleChange$.pipe(ie.debounceTime(16)),[]),N=b.useObservable(k),H=b.useEvent(r);R.useEffect(()=>{(async()=>{await new Promise(_=>{setTimeout(()=>_(!0),100)});const L=y.getRuleById(n,a,d),Y=L==null?void 0:L.formula1;if(o.isFormulaString(Y)&&C&&L){const _=await C.getListAsync(L,n,a);W(_)}})()},[y,N,C,d,a,n]),R.useEffect(()=>{o.isFormulaString(l)&&l!==g&&(I(l),V(g))},[g,l]);const[Z,K]=R.useState(()=>{const L=h!=="1"?f.deserializeListOptions(l):[],Y=c.split(",");return L.map((_,j)=>({label:_,color:Y[j]||Ce,isRef:!1,id:o.Tools.generateRandomId(4)}))}),te=(L,Y,_)=>{const j=Z.find(z=>z.id===L);j&&(j.label=Y,j.color=_,K([...Z]))},ae=L=>{const Y=Z.findIndex(_=>_.id===L);Y!==-1&&(Z.splice(Y,1),K([...Z]))},se=c.split(","),ce=R.useMemo(()=>E.map((L,Y)=>({label:L,color:se[Y]||Ce,id:`${Y}`,isRef:!0})),[se,E]),J=(L,Y,_)=>{const j=[...D];j[+L]=_,w(j),H({formula1:l,formula2:j.join(",")})},q=()=>{K([...Z,{label:"",color:Ce,isRef:!1,id:o.Tools.generateRandomId(4)}])};R.useEffect(()=>{if(h==="1")return;const L=new Set,Y=[];Z.map(_=>({labelList:_.label.split(","),item:_})).forEach(({item:_,labelList:j})=>{j.forEach(z=>{L.has(z)||(L.add(z),Y.push({label:z,color:_.color}))})}),H({formula1:f.serializeListOptions(Y.map(_=>_.label)),formula2:Y.map(_=>_.color===Ce?"":_.color).join(",")})},[Z,H,h,g,D]);const ve=b.useEvent(async L=>{if(!o.isFormulaString(L)){H==null||H({formula1:"",formula2:c});return}S.getFormulaRefCheck(L)?(H==null||H({formula1:o.isFormulaString(L)?L:"",formula2:c}),O("")):(H==null||H({formula1:"",formula2:c}),I("="),O(T.t("dataValidation.validFail.formulaError")))}),ne=R.useRef(null),[ee,Q]=R.useState(!1);return b.useSidebarClick(L=>{var _;((_=ne.current)==null?void 0:_.isClickOutSide(L))&&Q(!1)}),v.jsxs(v.Fragment,{children:[v.jsx(M.FormLayout,{label:T.t("dataValidation.list.options"),children:v.jsxs(M.RadioGroup,{value:h,onChange:L=>{p(L),I(g),L==="1"&&H({formula1:g==="="?"":g,formula2:D.join(",")})},children:[v.jsx(M.Radio,{value:"0",children:T.t("dataValidation.list.customOptions")}),v.jsx(M.Radio,{value:"1",children:T.t("dataValidation.list.refOptions")})]})}),h==="1"?v.jsxs(M.FormLayout,{error:U||x||void 0,children:[v.jsx(ze.FormulaEditor,{ref:ne,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",M.borderClassName),initValue:u,unitId:n,subUnitId:a,isFocus:ee,isSupportAcrossSheet:!0,onFocus:()=>Q(!0),onChange:(L="")=>{const Y=(L!=null?L:"").trim();V(Y),ve(Y)}}),ce.length>0&&v.jsx("div",{className:"univer-mt-3",children:ce.map(L=>v.jsx(St,{className:"univer-mb-3",item:L,commonProps:{onItemChange:J}},L.id))})]}):v.jsx(M.FormLayout,{error:U,children:v.jsxs("div",{className:"-univer-mt-3",children:[v.jsx(M.DraggableList,{list:Z,onListChange:K,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:L=>v.jsx(St,{item:L,commonProps:{onItemChange:te,onItemDelete:ae}},L.id),idKey:"id"}),v.jsxs("a",{className:"univer-flex univer-w-fit univer-cursor-pointer univer-flex-row univer-items-center univer-rounded univer-p-1 univer-px-2 univer-text-sm univer-text-primary dark:hover:!univer-bg-gray-800 hover:univer-bg-primary-50",onClick:q,children:[v.jsx(gt,{className:"univer-mr-1"}),T.t("dataValidation.list.add")]})]})})]})}const Gt=[[f.CUSTOM_FORMULA_INPUT_NAME,Ft],[f.BASE_FORMULA_INPUT_NAME,Pt],[f.LIST_FORMULA_INPUT_NAME,Zt],[f.CHECKBOX_FORMULA_INPUT_NAME,kt]];var qt=Object.getOwnPropertyDescriptor,Jt=(e,t,r,n)=>{for(var a=n>1?void 0:n?qt(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Qt=(e,t)=>(r,n)=>t(r,n,e);F.BaseSheetDataValidatorView=class{constructor(t){A(this,"canvasRender",null);A(this,"dropdownType");A(this,"optionsInput");A(this,"formulaInput",f.LIST_FORMULA_INPUT_NAME);this.injector=t}},F.BaseSheetDataValidatorView=Jt([Qt(0,o.Inject(o.Injector))],F.BaseSheetDataValidatorView);var en=Object.getOwnPropertyDescriptor,tn=(e,t,r,n)=>{for(var a=n>1?void 0:n?en(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},_t=(e,t)=>(r,n)=>t(r,n,e);let ue=class extends o.Disposable{constructor(t,r){super();A(this,"_open$",new ie.BehaviorSubject(!1));A(this,"open$",this._open$.pipe(ie.distinctUntilChanged()));A(this,"_activeRule");A(this,"_activeRule$",new ie.BehaviorSubject(void 0));A(this,"activeRule$",this._activeRule$.asObservable());A(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=r,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(ie.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===ke&&(n.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=o.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ue=tn([_t(0,o.IUniverInstanceService),_t(1,b.ISidebarService)],ue);const qe="sheets-data-validation-ui.config",Pe={};var nn=Object.getOwnPropertyDescriptor,rn=(e,t,r,n)=>{for(var a=n>1?void 0:n?nn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ye=(e,t)=>(r,n)=>t(r,n,e);let we=class extends o.Disposable{constructor(e,t,r,n,a,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=r,this._dialogService=n,this._localeService=a,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept($.VALIDATE_CELL,{handler:async(e,t,r)=>{const n=await e,{row:a,col:i,unitId:s,subUnitId:d}=t,l=this._dataValidationModel.getRuleIdByLocation(s,d,a,i),c=l?this._dataValidationModel.getRuleById(s,d,l):void 0;if(n===!1)return r(Promise.resolve(!1));if(!c||c.errorStyle!==o.DataValidationErrorStyle.STOP)return r(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(c.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,d,a,i)===o.DataValidationStatus.VALID?r(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:h.getRuleFinalError(c,{row:a,col:i,unitId:s,subUnitId:d})},footer:{title:R.createElement(M.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),r(Promise.resolve(!1)))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:R.createElement(M.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};we=rn([ye(0,o.Inject($.SheetInterceptorService)),ye(1,o.Inject(f.SheetDataValidationModel)),ye(2,o.Inject(X.DataValidatorRegistryService)),ye(3,b.IDialogService),ye(4,o.Inject(o.LocaleService)),ye(5,o.Inject(f.SheetsDataValidationValidatorService))],we);var an=Object.getOwnPropertyDescriptor,on=(e,t,r,n)=>{for(var a=n>1?void 0:n?an(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},le=(e,t)=>(r,n)=>t(r,n,e);const Je=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return o.dayjs(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=o.dayjs(e);if(t.isValid())return t};function sn(e,t){const r=Lt.getPatternType(t);if(e===r)return t;switch(e){case"datetime":return"yyyy-MM-dd hh:mm:ss";case"date":return"yyyy-MM-dd";case"time":return"HH:mm:ss"}}let fe=class extends o.Disposable{constructor(t,r,n,a,i,s,d,l,c,h,p){super();A(this,"_activeDropdown");A(this,"_activeDropdown$",new ie.Subject);A(this,"_currentPopup",null);A(this,"activeDropdown$",this._activeDropdown$.asObservable());A(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=r,this._zenZoneService=n,this._dataValidationModel=a,this._sheetsSelectionsService=i,this._cellDropdownManagerService=s,this._sheetDataValidationModel=d,this._commandService=l,this._editorBridgeService=c,this._injector=h,this._configService=p,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,r,n,a){const i=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=r?i.getSheetBySheetId(r):i.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),n,a);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(r=>!(r.primary&&this._getDropdownByCell(r.primary.unitId,r.primary.sheetId,r.primary.actualRow,r.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var V,T,m,y;const{location:r}=t,{row:n,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=r;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const c=this._sheetDataValidationModel.getRuleByLocation(i,s,n,a);if(!c)return;const h=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!(h!=null&&h.dropdownType))return;let p;const u=async(S,D)=>{var k,N,H;if(!S)return!0;const w=S,C=l.getCell(n,a),E=w.format(D==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),W=(k=o.numfmt.parseDate(E))==null?void 0:k.v,x=D==="time"?W%1:W,O=d.getStyles().getStyleByCell(C),U=(H=(N=O==null?void 0:O.n)==null?void 0:N.pattern)!=null?H:"";return c.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:x,unitId:i,subUnitId:s,row:n,column:a,worksheet:l,workbook:d,interceptValue:E.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},c)?(await this._commandService.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),await this._commandService.executeCommand($.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:x,t:2,p:null,f:null,si:null,s:{n:{pattern:sn(D,U)}}}}),!0):(this._injector.has(we)&&this._injector.get(we).showReject(h.getRuleFinalError(c,{row:n,col:a,unitId:i,subUnitId:s})),!1)};let I;switch(h.dropdownType){case X.DataValidatorDropdownType.DATE:{const S=f.getCellValueOrigin(l.getCellRaw(n,a)),D=Je(S),w=!!((V=c.bizInfo)!=null&&V.showTime);I={location:r,type:"datepicker",props:{showTime:w,onChange:C=>u(C,w?"datetime":"date"),defaultValue:D,patternType:"date"}};break}case X.DataValidatorDropdownType.TIME:{const S=f.getCellValueOrigin(l.getCellRaw(n,a)),D=Je(S);I={location:r,type:"datepicker",props:{onChange:w=>u(w,"time"),defaultValue:D,patternType:"time"}};break}case X.DataValidatorDropdownType.DATETIME:{const S=f.getCellValueOrigin(l.getCellRaw(n,a)),D=Je(S);I={location:r,type:"datepicker",props:{onChange:w=>u(w,"datetime"),defaultValue:D,patternType:"datetime"}};break}case X.DataValidatorDropdownType.LIST:case X.DataValidatorDropdownType.MULTIPLE_LIST:{const S=h.dropdownType===X.DataValidatorDropdownType.MULTIPLE_LIST,D=async O=>{const U=f.serializeListOptions(O),k={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:U,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),this._commandService.executeCommand($.SetRangeValuesCommand.id,k),!S},w=(c==null?void 0:c.renderMode)===o.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,C=h.getListWithColor(c,i,s),E=f.getDataValidationCellValue(l.getCellRaw(n,a)),W=()=>{this._commandService.executeCommand(me.id,{ruleId:c.uid}),p==null||p.dispose()},x=C.map(O=>({label:O.label,value:O.label,color:w||O.color?O.color:"transparent"}));I={location:r,type:"list",props:{onChange:O=>D(O),options:x,onEdit:W,defaultValue:E,multiple:S,showEdit:(m=(T=this._configService.getConfig(qe))==null?void 0:T.showEditOnDropdown)!=null?m:!0}};break}case X.DataValidatorDropdownType.CASCADE:{I={type:"cascader",props:{onChange:D=>{const w={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:D.join("/"),p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),this._commandService.syncExecuteCommand($.SetRangeValuesCommand.id,w),!0},defaultValue:f.getDataValidationCellValue(l.getCellRaw(n,a)).split("/"),options:JSON.parse((y=c.formula1)!=null?y:"[]")},location:r};break}case X.DataValidatorDropdownType.COLOR:{I={type:"color",props:{onChange:D=>{const w={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:D,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),this._commandService.syncExecuteCommand($.SetRangeValuesCommand.id,w),!0},defaultValue:f.getDataValidationCellValue(l.getCellRaw(n,a))},location:r};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(p=this._cellDropdownManagerService.showDropdown({...I,onHide:()=>{this._activeDropdown=null,this._activeDropdown$.next(null)}}),!p)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const g=new o.DisposableCollection;g.add(p),g.add({dispose:()=>{var S,D;(D=(S=this._activeDropdown)==null?void 0:S.onHide)==null||D.call(S)}}),this._currentPopup=g}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,r,n,a,i){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(r);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,a);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!c||!c.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:n,col:a,unitId:t,subUnitId:r},onHide:i})}};fe=on([le(0,o.IUniverInstanceService),le(1,o.Inject(X.DataValidatorRegistryService)),le(2,b.IZenZoneService),le(3,o.Inject(f.SheetDataValidationModel)),le(4,o.Inject($.SheetsSelectionsService)),le(5,o.Inject(B.ISheetCellDropdownManagerService)),le(6,o.Inject(f.SheetDataValidationModel)),le(7,o.ICommandService),le(8,B.IEditorBridgeService),le(9,o.Inject(o.Injector)),le(10,o.IConfigService)],fe);const ke="DataValidationPanel",me={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:r,isAdd:n}=t,a=e.get(ue),i=e.get(X.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(b.ISidebarService),l=$.getSheetCommandTarget(s);if(!l)return!1;const{unitId:c,subUnitId:h}=l,p=r?i.getRuleById(c,h,r):void 0;a.open(),a.setActiveRule(p&&{unitId:c,subUnitId:h,rule:p});const u=d.open({id:ke,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:ke},width:312,onClose:()=>a.close()});return a.setCloseDisposable(u),!0}},Qe={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},It={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),r=e.get(ue);return r.open(),r.isOpen?t.executeCommand(Qe.id):t.executeCommand(me.id),!0}},Fe={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const r=e.get(fe),{unitId:n,subUnitId:a,row:i,column:s}=t,d=r.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===a&&l.row===i&&l.col===s||r.showDataValidationDropdown(n,a,i,s),!0}},Ct={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(fe).hideDropdown(),!0):!1}},Ue={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),r=$.getSheetCommandTarget(t);if(!r)return!1;const{workbook:n,worksheet:a}=r,i=f.createDefaultNewRule(e),s=e.get(o.ICommandService),d=n.getUnitId(),l=a.getSheetId(),c={rule:i,unitId:d,subUnitId:l};return s.syncExecuteCommand(f.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(me.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var ln=Object.getOwnPropertyDescriptor,dn=(e,t,r,n)=>{for(var a=n>1?void 0:n?ln(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},De=(e,t)=>(r,n)=>t(r,n,e);const Se="SHEET_DATA_VALIDATION_ALERT";let Ae=class extends o.Disposable{constructor(e,t,r,n,a,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=r,this._localeService=n,this._zenZoneService=a,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ie.debounceTime(100)).subscribe(e=>{var t;if(e){const r=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),n=r.getSheetBySheetId(e.location.subUnitId);if(!n)return;const a=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!a){this._cellAlertManagerService.removeAlert(Se);return}if(this._dataValidationModel.validator(a,{...e.location,workbook:r,worksheet:n})===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Se),d=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(d&&d.row===e.location.row&&d.col===e.location.col&&d.subUnitId===e.location.subUnitId&&d.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(Se);return}const l=this._dataValidationModel.getValidator(a.type);if(!l){this._cellAlertManagerService.removeAlert(Se);return}this._cellAlertManagerService.showAlert({type:B.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(a,e.location),location:e.location,width:200,height:74,key:Se});return}}this._cellAlertManagerService.removeAlert(Se)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(Se)}))}};Ae=dn([De(0,o.Inject(B.HoverManagerService)),De(1,o.Inject(B.CellAlertManagerService)),De(2,o.IUniverInstanceService),De(3,o.Inject(o.LocaleService)),De(4,b.IZenZoneService),De(5,o.Inject(f.SheetDataValidationModel))],Ae);var cn=Object.getOwnPropertyDescriptor,un=(e,t,r,n)=>{for(var a=n>1?void 0:n?cn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},et=(e,t)=>(r,n)=>t(r,n,e);let Ee=class extends o.Disposable{constructor(e,t,r){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=r,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,a)=>{const{source:i,target:s,unitId:d,subUnitId:l}=n,c=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),h=B.virtualizeDiscreteRanges([i,s]),[p,u]=h.ranges,{mapFunc:I}=h,g={row:p.startRow,col:p.startColumn},V=B.getAutoFillRepeatRange(p,u),T=new o.ObjectMatrix,m=new Set;V.forEach(C=>{const E=C.repeatStartCell,W=C.relativeRange,x={startRow:g.row,startColumn:g.col,endColumn:g.col,endRow:g.row},O={startRow:E.row,startColumn:E.col,endColumn:E.col,endRow:E.row};o.Range.foreach(W,(U,k)=>{const N=o.Rectangle.getPositionRange({startRow:U,startColumn:k,endColumn:k,endRow:U},x),{row:H,col:Z}=I(N.startRow,N.startColumn),K=this._sheetDataValidationModel.getRuleIdByLocation(d,l,H,Z)||"",te=o.Rectangle.getPositionRange({startRow:U,startColumn:k,endColumn:k,endRow:U},O),{row:ae,col:se}=I(te.startRow,te.startColumn);T.setValue(ae,se,K),m.add(K)})});const y=Array.from(m).map(C=>({id:C,ranges:o.queryObjectMatrix(T,E=>E===C)}));c.addRangeRules(y);const S=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:D,undoMutations:w}=f.getDataValidationDiffMutations(d,l,S,this._injector,"patched",a===B.APPLY_TYPE.ONLY_FORMAT);return{undos:w,redos:D}},r={id:f.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:a,unitId:i,subUnitId:s}=n;for(const d of a.rows)for(const l of a.cols){const c=this._sheetDataValidationModel.getRuleByLocation(i,s,d,l);if(c&&c.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(B.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,a,i)=>i===B.APPLY_TYPE.COPY||i===B.APPLY_TYPE.ONLY_FORMAT||i===B.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(r))}};Ee=un([et(0,B.IAutoFillService),et(1,o.Inject(f.SheetDataValidationModel)),et(2,o.Inject(o.Injector))],Ee);var hn=Object.getOwnPropertyDescriptor,vn=(e,t,r,n)=>{for(var a=n>1?void 0:n?hn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},tt=(e,t)=>(r,n)=>t(r,n,e);let Me=class extends o.Disposable{constructor(t,r,n){super();A(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=r,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:f.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,r,n)=>this._collect(t,r,n),onPasteCells:(t,r,n,a)=>{const{copyType:i=B.COPY_TYPE.COPY,pasteType:s}=a,{range:d}=t||{},{range:l,unitId:c,subUnitId:h}=r;return this._generateMutations(l,{copyType:i,pasteType:s,copyRange:d,unitId:c,subUnitId:h})}})}_collect(t,r,n){const a=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:r,matrix:a};const i=this._injector.invoke(l=>$.rangeToDiscreteRange(n,l,t,r));if(!i)return;const{rows:s,cols:d}=i;s.forEach((l,c)=>{d.forEach((h,p)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,r,l,h);a.setValue(c,p,u!=null?u:"")})})}_generateMutations(t,r){if(!this._copyInfo)return{redos:[],undos:[]};if(r.copyType===B.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!r.copyRange)return{redos:[],undos:[]};if([B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(r.pasteType))return{redos:[],undos:[]};const{unitId:a,subUnitId:i}=this._copyInfo;if(r.unitId!==a||i!==r.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(r.unitId,r.subUnitId).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:p}=B.virtualizeDiscreteRanges([r.copyRange,t]),u=B.getRepeatRange(c,h,!0),I=new Map;u.forEach(({startRange:m})=>{var y;(y=this._copyInfo)==null||y.matrix.forValue((S,D,w)=>{const C=o.Rectangle.getPositionRange({startRow:S,endRow:S,startColumn:D,endColumn:D},m),E=`${i}-${w}`,W=this._sheetDataValidationModel.getRuleById(a,i,w);!this._sheetDataValidationModel.getRuleById(r.unitId,r.subUnitId,E)&&W&&I.set(E,{...W,uid:E});const{row:x,col:O}=p(C.startRow,C.startColumn);l.add(E),d.setValue(x,O,E)})});const g=Array.from(l).map(m=>({id:m,ranges:o.queryObjectMatrix(d,y=>y===m)}));s.addRangeRules(g);const{redoMutations:V,undoMutations:T}=f.getDataValidationDiffMutations(r.unitId,r.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(r.unitId,r.subUnitId),I.values()),this._injector,"patched",!1);return{redos:V,undos:T}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(a,i).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:p}=B.virtualizeDiscreteRanges([r.copyRange,t]);B.getRepeatRange(c,h,!0).forEach(({startRange:T})=>{var m;(m=this._copyInfo)==null||m.matrix.forValue((y,S,D)=>{const w=o.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:S,endColumn:S},T),{row:C,col:E}=p(w.startRow,w.startColumn);d.setValue(C,E,D),l.add(D)})});const I=Array.from(l).map(T=>({id:T,ranges:o.queryObjectMatrix(d,m=>m===T)}));s.addRangeRules(I);const{redoMutations:g,undoMutations:V}=f.getDataValidationDiffMutations(a,i,s.diff(this._sheetDataValidationModel.getRules(a,i)),this._injector,"patched",!1);return{redos:g,undos:V}}}};Me=vn([tt(0,B.ISheetClipboardService),tt(1,o.Inject(f.SheetDataValidationModel)),tt(2,o.Inject(o.Injector))],Me);var pn=Object.getOwnPropertyDescriptor,gn=(e,t,r,n)=>{for(var a=n>1?void 0:n?pn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},nt=(e,t)=>(r,n)=>t(r,n,e);let be=class extends o.Disposable{constructor(e,t,r){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=r,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===f.AddSheetDataValidationCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[$.WorkbookEditablePermission],rangeTypes:[$.RangeProtectionPermissionEditPoint],worksheetTypes:[$.WorksheetEditPermission,$.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===f.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[$.WorkbookEditablePermission],rangeTypes:[$.RangeProtectionPermissionEditPoint],worksheetTypes:[$.WorksheetEditPermission,$.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};be=gn([nt(0,o.Inject(o.LocaleService)),nt(1,o.ICommandService),nt(2,o.Inject($.SheetPermissionCheckController))],be);const yt="sheet.menu.data-validation";function fn(e){return{id:yt,type:b.MenuItemType.SUBITEMS,icon:"DataValidationIcon",tooltip:"dataValidation.title",hidden$:b.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:B.getCurrentRangeDisable$(e,{workbookTypes:[$.WorkbookEditablePermission],worksheetTypes:[$.WorksheetSetCellStylePermission,$.WorksheetEditPermission],rangeTypes:[$.RangeProtectionPermissionEditPoint]})}}function mn(e){return{id:me.id,title:"dataValidation.panel.title",type:b.MenuItemType.BUTTON}}function Sn(e){return{id:Ue.id,title:"dataValidation.panel.add",type:b.MenuItemType.BUTTON}}const _n={[b.RibbonDataGroup.RULES]:{[yt]:{order:0,menuItemFactory:fn,[me.id]:{order:0,menuItemFactory:mn},[Ue.id]:{order:1,menuItemFactory:Sn}}}};var In=Object.getOwnPropertyDescriptor,wt=(e,t,r,n)=>{for(var a=n>1?void 0:n?In(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},G=(e,t)=>(r,n)=>t(r,n,e);const Dt={tr:{size:6,color:"#fe4b4b"}};let Te=class extends o.RxDisposable{constructor(e,t,r,n,a,i,s,d,l,c,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=r,this._univerInstanceService=n,this._autoHeightController=a,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=c,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(_n)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var r;if(!e.visible){((r=this._dropdownManagerService.activeDropdown)==null?void 0:r.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:a,row:i,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,a,i,s);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(c!=null&&c.dropdownType))return;const h=d.getActiveSheet();if(!h)return;const p=this._dropdownManagerService.activeDropdown,u=p==null?void 0:p.location;if(u&&u.unitId===n&&u.subUnitId===a&&u.row===i&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:a,row:i,col:s,workbook:d,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept($.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:$.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,r)=>{var m,y,S,D,w;const{row:n,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,a);if(!c)return r(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return r(e);const p=(m=this._dataValidationCacheService.getValue(i,s,n,a))!=null?m:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),I=t.rawData;let g;const V={get value(){var C;return g!==void 0||(g=(C=f.getCellValueOrigin(I))!=null?C:null),g}},T={get value(){var C;return`${(C=V.value)!=null?C:""}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...p===o.DataValidationStatus.INVALID?Dt:null},e.customRender=[...(y=e==null?void 0:e.customRender)!=null?y:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((S=e==null?void 0:e.fontRenderExtension)==null?void 0:S.isSkip)||((D=u==null?void 0:u.skipDefaultFontRender)==null?void 0:D.call(u,h,V.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,T.value,{get style(){const C=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?C.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,a)},e.interceptorAutoHeight=()=>{var x,O,U,k,N,H;const C=(O=(x=this._renderManagerService.getRenderById(i))==null?void 0:x.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:O.skeleton;if(!C)return;const E=C.worksheet.getMergedCell(n,a),W={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((U=E==null?void 0:E.startRow)!=null?U:n,(k=E==null?void 0:E.startColumn)!=null?k:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(H=(N=u==null?void 0:u.canvasRender)==null?void 0:N.calcCellAutoHeight)==null?void 0:H.call(N,W)},e.interceptorAutoWidth=()=>{var x,O,U,k,N,H;const C=(O=(x=this._renderManagerService.getRenderById(i))==null?void 0:x.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:O.skeleton;if(!C)return;const E=C.worksheet.getMergedCell(n,a),W={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((U=E==null?void 0:E.startRow)!=null?U:n,(k=E==null?void 0:E.startColumn)!=null?k:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(H=(N=u==null?void 0:u.canvasRender)==null?void 0:N.calcCellAutoWidth)==null?void 0:H.call(N,W)},e.coverable=((w=e==null?void 0:e.coverable)!=null?w:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),r(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(r=>{var n;(r.rule.type===o.DataValidationType.LIST_MULTIPLE||r.rule.type===o.DataValidationType.LIST)&&(n=r.rule)!=null&&n.ranges&&t.push(...r.rule.ranges)}),t.length){const r=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(r.redos,this._commandService)}})}};Te=wt([G(0,o.ICommandService),G(1,b.IMenuManagerService),G(2,P.IRenderManagerService),G(3,o.IUniverInstanceService),G(4,o.Inject(B.AutoHeightController)),G(5,o.Inject(fe)),G(6,o.Inject(f.SheetDataValidationModel)),G(7,o.Inject(X.DataValidatorRegistryService)),G(8,o.Inject($.SheetInterceptorService)),G(9,o.Inject(f.DataValidationCacheService)),G(10,o.Optional(B.IEditorBridgeService))],Te);let Et=class extends o.RxDisposable{constructor(e,t,r,n,a,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=r,this._dataValidatorRegistryService=n,this._sheetInterceptorService=a,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept($.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:$.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,r)=>{var T,m,y,S,D;const{row:n,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,a);if(!c)return r(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return r(e);const p=(T=this._dataValidationCacheService.getValue(i,s,n,a))!=null?T:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),I=l.getCellRaw(n,a),g=f.getCellValueOrigin(I),V=`${g!=null?g:""}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...p===o.DataValidationStatus.INVALID?Dt:null},e.customRender=[...(m=e==null?void 0:e.customRender)!=null?m:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((y=e==null?void 0:e.fontRenderExtension)==null?void 0:y.isSkip)||((S=u==null?void 0:u.skipDefaultFontRender)==null?void 0:S.call(u,h,g,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,V,{get style(){const w=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?w.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,a)},e.interceptorAutoHeight=()=>{var W,x,O,U,k,N;const w=(x=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:x.skeleton;if(!w)return;const C=w.worksheet.getMergedCell(n,a),E={data:e,style:w.getStyles().getStyleByCell(e),primaryWithCoord:w.getCellWithCoordByIndex((O=C==null?void 0:C.startRow)!=null?O:n,(U=C==null?void 0:C.startColumn)!=null?U:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(N=(k=u==null?void 0:u.canvasRender)==null?void 0:k.calcCellAutoHeight)==null?void 0:N.call(k,E)},e.interceptorAutoWidth=()=>{var W,x,O,U,k,N;const w=(x=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:x.skeleton;if(!w)return;const C=w.worksheet.getMergedCell(n,a),E={data:e,style:w.getStyles().getStyleByCell(e),primaryWithCoord:w.getCellWithCoordByIndex((O=C==null?void 0:C.startRow)!=null?O:n,(U=C==null?void 0:C.startColumn)!=null?U:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(N=(k=u==null?void 0:u.canvasRender)==null?void 0:k.calcCellAutoWidth)==null?void 0:N.call(k,E)},e.coverable=((D=e==null?void 0:e.coverable)!=null?D:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),r(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(r=>{var n;(r.rule.type===o.DataValidationType.LIST_MULTIPLE||r.rule.type===o.DataValidationType.LIST)&&(n=r.rule)!=null&&n.ranges&&t.push(...r.rule.ranges)}),t.length){const r=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(r.redos,this._commandService)}})}};Et=wt([G(0,o.ICommandService),G(1,P.IRenderManagerService),G(2,o.Inject(B.AutoHeightController)),G(3,o.Inject(X.DataValidatorRegistryService)),G(4,o.Inject($.SheetInterceptorService)),G(5,o.Inject(f.SheetDataValidationModel)),G(6,o.Inject(f.DataValidationCacheService))],Et);var Cn=Object.getOwnPropertyDescriptor,yn=(e,t,r,n)=>{for(var a=n>1?void 0:n?Cn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Mt=(e,t)=>(r,n)=>t(r,n,e);let Ne=class extends o.Disposable{constructor(e,t,r){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=r,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const r=new Set;t.forEach(a=>{r.add(a.subUnitId)}),r.forEach(a=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(a))==null||i.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};Ne=yn([Mt(1,o.Inject(f.SheetDataValidationModel)),Mt(2,o.Inject(B.SheetSkeletonManagerService))],Ne);function wn(e){var c;const t=b.useDependency(o.LocaleService),r=b.useDependency(b.ComponentManager),{value:n,onChange:a,extraComponent:i}=e,[s,d]=R.useState(!1),l=i?r.get(i):null;return v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-gray-900 dark:!univer-text-white",onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?v.jsx(ft,{className:"univer-ml-1"}):v.jsx(Ge,{className:"univer-ml-1"})]}),s&&v.jsxs(v.Fragment,{children:[l?v.jsx(l,{value:n,onChange:a}):null,v.jsx(M.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:v.jsxs(M.RadioGroup,{value:`${(c=n.errorStyle)!=null?c:o.DataValidationErrorStyle.WARNING}`,onChange:h=>a({...n,errorStyle:+h}),children:[v.jsx(M.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),v.jsx(M.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),v.jsx(M.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:v.jsx(M.Checkbox,{checked:n.showErrorMessage,onChange:()=>a({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?v.jsx(M.FormLayout,{children:v.jsx(M.Input,{value:n.error,onChange:h=>a({...n,error:h})})}):null]})]})}const Dn=e=>o.debounce(async(t,r,n,a)=>{const i=await e.executeCommand(t,r,n);a==null||a(i)},1e3);function En(e,t,r){var n,a,i,s;return t?((a=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(r))==null?void 0:a.getSheetId())||"":((s=(i=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(r))==null?void 0:s.getSheetId())||""}function Mn(){var L,Y;const[e,t]=R.useState(0),r=b.useDependency(ue),n=b.useObservable(r.activeRule$,r.activeRule),{unitId:a,subUnitId:i,rule:s}=n||{},d=s.uid,l=b.useDependency(X.DataValidatorRegistryService),c=b.useDependency(o.IUniverInstanceService),h=b.useDependency(b.ComponentManager),p=b.useDependency(o.ICommandService),u=b.useDependency(X.DataValidationModel),I=b.useDependency(o.LocaleService),[g,V]=R.useState(s),T=l.getValidatorItem(g.type),[m,y]=R.useState(!1),S=l.getValidatorsByScope(X.DataValidatorRegistryScope.SHEET),[D,w]=R.useState(()=>g.ranges.map(_=>({unitId:"",sheetId:"",range:_}))),C=R.useMemo(()=>Dn(p),[p]),[E,W]=R.useState(!1),[x,O]=R.useState(!1),U=R.useRef(null),k=b.useDependency($.SheetsSelectionsService);if(R.useEffect(()=>()=>{const _=k.getCurrentLastSelection();_&&k.setSelections([_])},[k]),R.useEffect(()=>{p.onCommandExecuted(_=>{(_.id===o.UndoCommand.id||_.id===o.RedoCommand.id)&&setTimeout(()=>{const j=u.getRuleById(a,i,d);t(z=>z+1),j&&(V(j),w(j.ranges.map(z=>({unitId:"",sheetId:"",range:z}))))},20)})},[p,u,d,i,a]),!T)return null;const N=T.operators,H=T.operatorNames,Z=g.operator?X.TWO_FORMULA_OPERATOR_COUNT.includes(g.operator):!1,K=()=>{var _,j,z;(j=(_=U.current)==null?void 0:_.editor)!=null&&j.isFocus()&&te((z=U.current)==null?void 0:z.getValue()),!(!g.ranges.length||E)&&(T.validatorFormula(g,a,i).success?r.setActiveRule(null):y(!0))},te=b.useEvent(_=>{const j=_.split(",").filter(Boolean).map(Ke.deserializeRangeWithSheet).map(re=>{const At=re.sheetName;if(At){const sr=En(c,re.unitId,At);return{...re,sheetId:sr}}return{...re,sheetId:""}});if(o.isUnitRangesEqual(j,D))return;w(j);const z=j.filter(re=>(!re.unitId||re.unitId===a)&&(!re.sheetId||re.sheetId===i)).map(re=>re.range);if(V({...g,ranges:z}),z.length===0)return;const pe={unitId:a,subUnitId:i,ruleId:d,ranges:z};C(f.UpdateSheetDataValidationRangeCommand.id,pe)}),ae=_=>{if(o.shallowEqual(_,X.getRuleSetting(g)))return;V({...g,..._});const j={unitId:a,subUnitId:i,ruleId:d,setting:_};C(f.UpdateSheetDataValidationSettingCommand.id,j,void 0)},se=async()=>{await p.executeCommand(f.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:a,subUnitId:i}),r.setActiveRule(null)},ce={type:g.type,operator:g.operator,formula1:g.formula1,formula2:g.formula2,allowBlank:g.allowBlank},J=_=>{const j=l.getValidatorItem(_);if(!j)return;const z=j.operators,pe=u.getRuleById(a,i,d),re=_===(pe==null?void 0:pe.type)||_.includes("list")&&(pe!=null&&pe.type.includes("list"))?{...pe,type:_}:{...g,type:_,operator:z[0],formula1:void 0,formula2:void 0};V(re),p.executeCommand(f.UpdateSheetDataValidationSettingCommand.id,{unitId:a,subUnitId:i,ruleId:g.uid,setting:X.getRuleSetting(re)})},q=h.get(T.formulaInput),ve=R.useMemo(()=>D.map(_=>Ke.serializeRange(_.range)).join(","),[]),ne=X.getRuleOptions(g),ee=_=>{o.shallowEqual(_,X.getRuleOptions(g))||(V({...g,..._}),C(f.UpdateSheetDataValidationOptionsCommand.id,{unitId:a,subUnitId:i,ruleId:d,options:_}))},Q=N.length&&!g.operator;return v.jsxs("div",{"data-u-comp":"data-validation-detail",className:"univer-py-2",children:[v.jsx(M.FormLayout,{label:I.t("dataValidation.panel.range"),error:!g.ranges.length||E?I.t("dataValidation.panel.rangeError"):"",children:v.jsx(ze.RangeSelector,{selectorRef:U,unitId:a,subUnitId:i,initialValue:ve,onChange:(_,j)=>{var z;!x&&((z=U.current)!=null&&z.verify())&&te(j)},onFocusChange:(_,j)=>{var z;O(_),!_&&j&&((z=U.current)!=null&&z.verify())&&te(j)},onVerify:_=>W(!_)})}),v.jsx(M.FormLayout,{label:I.t("dataValidation.panel.type"),children:v.jsx(M.Select,{className:"univer-w-full",value:g.type,options:(L=S==null?void 0:S.sort((_,j)=>_.order-j.order))==null?void 0:L.map(_=>({label:I.t(_.title),value:_.id})),onChange:J})}),N!=null&&N.length?v.jsx(M.FormLayout,{label:I.t("dataValidation.panel.operator"),children:v.jsx(M.Select,{className:"univer-w-full",value:`${g.operator}`,options:[{value:"",label:I.t("dataValidation.operators.legal")},...N.map((_,j)=>({value:`${_}`,label:H[j]}))],onChange:_=>{ae({...ce,operator:_})}})}):null,q&&!Q?v.jsx(q,{isTwoFormula:Z,value:{formula1:g.formula1,formula2:g.formula2},onChange:_=>{ae({...ce,..._})},showError:m,validResult:T.validatorFormula(g,a,i),unitId:a,subUnitId:i,ruleId:d},e+g.type):null,v.jsx(M.FormLayout,{children:v.jsx(M.Checkbox,{checked:(Y=g.allowBlank)!=null?Y:!0,onChange:()=>{var _;return ae({...ce,allowBlank:!((_=g.allowBlank)==null||_)})},children:I.t("dataValidation.panel.allowBlank")})}),v.jsx(wn,{value:ne,onChange:ee,extraComponent:T.optionsInput}),v.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[v.jsx(M.Button,{className:"univer-ml-3",onClick:se,children:I.t("dataValidation.panel.removeRule")}),v.jsx(M.Button,{className:"univer-ml-3",variant:"primary",onClick:K,children:I.t("dataValidation.panel.done")})]})]})}const bn=e=>{const{rule:t,onClick:r,unitId:n,subUnitId:a,disable:i}=e,s=b.useDependency(X.DataValidatorRegistryService),d=b.useDependency(o.ICommandService),l=b.useDependency(B.IMarkSelectionService),c=s.getValidatorItem(t.type),h=R.useRef(void 0),[p,u]=R.useState(!1),I=b.useDependency(o.ThemeService),g=b.useObservable(I.currentTheme$),V=R.useMemo(()=>{var w;const m=I.getColorFromTheme("primary.600"),y=I.getColorFromTheme("loop-color.2"),S=(w=I.getColorFromTheme(y))!=null?w:m,D=new o.ColorKit(S).toRgb();return{fill:`rgba(${D.r}, ${D.g}, ${D.b}, 0.1)`,stroke:S}},[g]),T=m=>{d.executeCommand(f.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:a}),m.stopPropagation()};return R.useEffect(()=>()=>{var m;h.current&&((m=h.current)==null||m.forEach(y=>{y&&l.removeShape(y)}))},[l]),v.jsxs("div",{className:M.clsx(`
|
2
2
|
univer-rounded-md univer-bg-secondary univer-relative univer--ml-2 univer--mr-2 univer-box-border
|
3
3
|
univer-flex univer-w-[287px] univer-cursor-pointer univer-flex-col univer-justify-between
|
4
4
|
univer-overflow-hidden univer-p-2 univer-pr-9
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@univerjs/sheets-data-validation-ui",
|
3
|
-
"version": "0.8.0
|
3
|
+
"version": "0.8.0",
|
4
4
|
"private": false,
|
5
5
|
"description": "Data validation UI for Univer Sheets",
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
@@ -56,17 +56,17 @@
|
|
56
56
|
"dependencies": {
|
57
57
|
"@flatten-js/interval-tree": "^1.1.3",
|
58
58
|
"@univerjs/icons": "^0.4.4",
|
59
|
-
"@univerjs/core": "0.8.0
|
60
|
-
"@univerjs/
|
61
|
-
"@univerjs/
|
62
|
-
"@univerjs/
|
63
|
-
"@univerjs/
|
64
|
-
"@univerjs/data-validation": "0.8.0
|
65
|
-
"@univerjs/sheets
|
66
|
-
"@univerjs/sheets-formula-ui": "0.8.0
|
67
|
-
"@univerjs/sheets-numfmt": "0.8.0
|
68
|
-
"@univerjs/sheets-ui": "0.8.0
|
69
|
-
"@univerjs/ui": "0.8.0
|
59
|
+
"@univerjs/core": "0.8.0",
|
60
|
+
"@univerjs/data-validation": "0.8.0",
|
61
|
+
"@univerjs/design": "0.8.0",
|
62
|
+
"@univerjs/engine-formula": "0.8.0",
|
63
|
+
"@univerjs/engine-render": "0.8.0",
|
64
|
+
"@univerjs/sheets-data-validation": "0.8.0",
|
65
|
+
"@univerjs/sheets": "0.8.0",
|
66
|
+
"@univerjs/sheets-formula-ui": "0.8.0",
|
67
|
+
"@univerjs/sheets-numfmt": "0.8.0",
|
68
|
+
"@univerjs/sheets-ui": "0.8.0",
|
69
|
+
"@univerjs/ui": "0.8.0"
|
70
70
|
},
|
71
71
|
"devDependencies": {
|
72
72
|
"postcss": "^8.5.3",
|
@@ -76,7 +76,7 @@
|
|
76
76
|
"typescript": "^5.8.3",
|
77
77
|
"vite": "^6.3.5",
|
78
78
|
"vitest": "^3.1.4",
|
79
|
-
"@univerjs-infra/shared": "0.8.0
|
79
|
+
"@univerjs-infra/shared": "0.8.0"
|
80
80
|
},
|
81
81
|
"scripts": {
|
82
82
|
"dev": "vite",
|