@univerjs/sheets-data-validation-ui 0.6.10 → 0.7.0-beta.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/lib/cjs/index.js +33 -1
- package/lib/es/index.js +1630 -1572
- package/lib/index.css +1 -1
- package/lib/index.js +1630 -1572
- package/lib/types/services/dropdown-manager.service.d.ts +3 -2
- package/lib/umd/index.js +33 -1
- package/package.json +16 -16
- /package/lib/types/views/components/formula-input/{base-formula-input.d.ts → BaseFormulaInput.d.ts} +0 -0
- /package/lib/types/views/components/formula-input/{checkbox-formula-input.d.ts → CheckboxFormulaInput.d.ts} +0 -0
- /package/lib/types/views/components/formula-input/{custom-formula-input.d.ts → CustomFormulaInput.d.ts} +0 -0
- /package/lib/types/views/components/formula-input/{list-formula-input.d.ts → ListFormulaInput.d.ts} +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Nullable, Disposable, ICommandService, Injector, IUniverInstanceService } from '@univerjs/core';
|
1
|
+
import { Nullable, Disposable, ICommandService, IConfigService, Injector, IUniverInstanceService } from '@univerjs/core';
|
2
2
|
import { ISheetLocation, SheetsSelectionsService } from '@univerjs/sheets';
|
3
3
|
import { DataValidatorRegistryService } from '@univerjs/data-validation';
|
4
4
|
import { SheetDataValidationModel } from '@univerjs/sheets-data-validation';
|
@@ -26,13 +26,14 @@ export declare class DataValidationDropdownManagerService extends Disposable {
|
|
26
26
|
private readonly _commandService;
|
27
27
|
private readonly _editorBridgeService;
|
28
28
|
private readonly _injector;
|
29
|
+
private readonly _configService;
|
29
30
|
private _activeDropdown;
|
30
31
|
private _activeDropdown$;
|
31
32
|
private _currentPopup;
|
32
33
|
activeDropdown$: import('rxjs').Observable<Nullable<IDataValidationDropdownParam>>;
|
33
34
|
private _zenVisible;
|
34
35
|
get activeDropdown(): Nullable<IDataValidationDropdownParam>;
|
35
|
-
constructor(_univerInstanceService: IUniverInstanceService, _dataValidatorRegistryService: DataValidatorRegistryService, _zenZoneService: IZenZoneService, _dataValidationModel: SheetDataValidationModel, _sheetsSelectionsService: SheetsSelectionsService, _cellDropdownManagerService: ISheetCellDropdownManagerService, _sheetDataValidationModel: SheetDataValidationModel, _commandService: ICommandService, _editorBridgeService: IEditorBridgeService, _injector: Injector);
|
36
|
+
constructor(_univerInstanceService: IUniverInstanceService, _dataValidatorRegistryService: DataValidatorRegistryService, _zenZoneService: IZenZoneService, _dataValidationModel: SheetDataValidationModel, _sheetsSelectionsService: SheetsSelectionsService, _cellDropdownManagerService: ISheetCellDropdownManagerService, _sheetDataValidationModel: SheetDataValidationModel, _commandService: ICommandService, _editorBridgeService: IEditorBridgeService, _injector: Injector, _configService: IConfigService);
|
36
37
|
private _init;
|
37
38
|
private _getDropdownByCell;
|
38
39
|
private _initSelectionChange;
|
package/lib/umd/index.js
CHANGED
@@ -1 +1,33 @@
|
|
1
|
-
(function(A,r){typeof exports=="object"&&typeof module<"u"?r(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"],r):(A=typeof globalThis<"u"?globalThis:A||self,r(A.UniverSheetsDataValidationUi={},A.UniverCore,A.UniverSheetsDataValidation,A.React,A.UniverDesign,A.UniverUi,A.React,A.UniverSheetsFormulaUi,A.UniverDataValidation,A.rxjs,A.UniverEngineRender,A.UniverSheets,A.UniverSheetsNumfmt,A.UniverSheetsUi,A.UniverEngineFormula))})(this,function(A,r,S,m,O,D,M,Je,x,ae,P,Y,jt,N,Qe){"use strict";var vn=Object.defineProperty;var fn=(A,r,S)=>r in A?vn(A,r,{enumerable:!0,configurable:!0,writable:!0,value:S}):A[r]=S;var L=(A,r,S)=>fn(A,typeof r!="symbol"?r+"":r,S);var qe,Ze;const ee={dataValidationFormula:"univer-data-validation-formula",dataValidationFormulaAnd:"univer-data-validation-formula-and",dataValidationFormulaListItem:"univer-data-validation-formula-list-item",dataValidationFormulaListItemIcon:"univer-data-validation-formula-list-item-icon",dataValidationFormulaListItemDrag:"univer-data-validation-formula-list-item-drag",dataValidationFormulaListAdd:"univer-data-validation-formula-list-add",dataValidationFormulaColorSelect:"univer-data-validation-formula-color-select",dataValidationFormulaColorSelectPanel:"univer-data-validation-formula-color-select-panel",dataValidationFormulaColorItem:"univer-data-validation-formula-color-item"},Ht=e=>{const{isTwoFormula:t=!1,value:n,onChange:a,showError:i,validResult:o}=e,s=D.useDependency(r.LocaleService),d=i?o==null?void 0:o.formula1:"",l=i?o==null?void 0:o.formula2:"";return t?m.jsxs(m.Fragment,{children:[m.jsx(O.FormLayout,{error:d,children:m.jsx(O.Input,{className:ee.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:c=>{a==null||a({...n,formula1:c})}})}),m.jsx("div",{className:ee.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),m.jsx(O.FormLayout,{error:l,children:m.jsx(O.Input,{className:ee.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula2,onChange:c=>{a==null||a({...n,formula2:c})}})})]}):m.jsx(O.FormLayout,{error:d,children:m.jsx(O.Input,{className:ee.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:c=>{a==null||a({formula1:c})}})})};function Wt(e){const{value:t,onChange:n,showError:a,validResult:i}=e,o=D.useDependency(r.LocaleService),s=a?i==null?void 0:i.formula1:"",d=a?i==null?void 0:i.formula2:"",[l,c]=M.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return m.jsxs(m.Fragment,{children:[m.jsx(O.FormLayout,{children:m.jsx(O.Checkbox,{checked:l,onChange:h=>{h?c(!0):(c(!1),n==null||n({...t,formula1:void 0,formula2:void 0}))},children:o.t("dataValidation.checkbox.tips")})}),l?m.jsx(O.FormLayout,{label:o.t("dataValidation.checkbox.checked"),error:s,children:m.jsx(O.Input,{className:ee.dataValidationFormula,placeholder:o.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{n==null||n({...t,formula1:h||void 0})}})}):null,l?m.jsx(O.FormLayout,{label:o.t("dataValidation.checkbox.unchecked"),error:d,children:m.jsx(O.Input,{className:ee.dataValidationFormula,placeholder:o.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{n==null||n({...t,formula2:h||void 0})}})}):null]})}function $t(e){var v;const{unitId:t,subUnitId:n,value:a,onChange:i,showError:o,validResult:s}=e,d=o?s==null?void 0:s.formula1:void 0,l=M.useRef(null),[c,h]=M.useState(!1);return D.useSidebarClick(u=>{var p;((p=l.current)==null?void 0:p.isClickOutSide(u))&&h(!1)}),m.jsx(Je.FormulaEditor,{initValue:(v=a==null?void 0:a.formula1)!=null?v:"=",unitId:t,subUnitId:n,isFocus:c,onChange:u=>{const I=(u!=null?u:"").trim();I!==(a==null?void 0:a.formula1)&&(i==null||i({...a,formula1:I}))},errorText:d,onFocus:()=>h(!0),isSupportAcrossSheet:!0,ref:l})}var ne=function(){return ne=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},ne.apply(this,arguments)},Yt=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,a=Object.getOwnPropertySymbols(e);i<a.length;i++)t.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(n[a[i]]=e[a[i]]);return n},ve=M.forwardRef(function(e,t){var n=e.icon,a=e.id,i=e.className,o=e.extend,s=Yt(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(a," ").concat(i||"").trim(),l=M.useRef("_".concat(zt()));return ft(n,"".concat(a),{defIds:n.defIds,idSuffix:l.current},ne({ref:t,className:d},s),o)});function ft(e,t,n,a,i){return M.createElement(e.tag,ne(ne({key:t},xt(e,n,i)),a),(Xt(e,n).children||[]).map(function(o,s){return ft(o,"".concat(t,"-").concat(e.tag,"-").concat(s),n,void 0,i)}))}function xt(e,t,n){var a=ne({},e.attrs);n!=null&&n.colorChannel1&&a.fill==="colorChannel1"&&(a.fill=n.colorChannel1),e.tag==="mask"&&a.id&&(a.id=a.id+t.idSuffix),Object.entries(a).forEach(function(o){var s=o[0],d=o[1];s==="mask"&&typeof d=="string"&&(a[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&a["xlink:href"]&&(a["xlink:href"]=a["xlink:href"]+t.idSuffix),Object.entries(a).forEach(function(o){var s=o[0],d=o[1];typeof d=="string"&&(a[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),a}function Xt(e,t){var n,a=t.defIds;return!a||a.length===0?e:e.tag==="defs"&&(!((n=e.children)===null||n===void 0)&&n.length)?ne(ne({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&a&&a.indexOf(i.attrs.id)>-1?ne(ne({},i),{attrs:ne(ne({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function zt(){return Math.random().toString(36).substring(2,8)}ve.displayName="UniverIcon";var Kt={tag:"svg",attrs:{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.83062 8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767 13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279zM14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217 14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046 13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703 10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046 9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217 9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746 9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732 13.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"}}]},St=M.forwardRef(function(e,t){return M.createElement(ve,Object.assign({},e,{id:"data-validation-single",ref:t,icon:Kt}))});St.displayName="DataValidationSingle";var Gt={tag:"svg",attrs:{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.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.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.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.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"}}]},et=M.forwardRef(function(e,t){return M.createElement(ve,Object.assign({},e,{id:"delete-single",ref:t,icon:Gt}))});et.displayName="DeleteSingle";var qt={tag:"svg",attrs:{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"}}]},_t=M.forwardRef(function(e,t){return M.createElement(ve,Object.assign({},e,{id:"increase-single",ref:t,icon:qt}))});_t.displayName="IncreaseSingle";var Zt={tag:"svg",attrs:{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"}}]},It=M.forwardRef(function(e,t){return M.createElement(ve,Object.assign({},e,{id:"more-down-single",ref:t,icon:Zt}))});It.displayName="MoreDownSingle";var Jt={tag:"svg",attrs:{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"}}]},Ct=M.forwardRef(function(e,t){return M.createElement(ve,Object.assign({},e,{id:"more-up-single",ref:t,icon:Jt}))});Ct.displayName="MoreUpSingle";var Qt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},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 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},yt=M.forwardRef(function(e,t){return M.createElement(ve,Object.assign({},e,{id:"sequence-single",ref:t,icon:Qt}))});yt.displayName="SequenceSingle";const ye="#ECECEC",ea=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],ta=e=>{const{value:t,onChange:n,disabled:a}=e,[i,o]=M.useState(!1);return m.jsx(O.Select,{disabled:a,open:i,onDropdownVisibleChange:o,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:ee.dataValidationFormulaColorSelect,value:t,onChange:n,labelRender:s=>m.jsx("div",{className:ee.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>m.jsx("div",{className:ee.dataValidationFormulaColorSelectPanel,children:ea.map(s=>m.jsx("div",{onClick:()=>{n(s),o(!1)},className:ee.dataValidationFormulaColorItem,style:{background:s}},s))})})},Vt=e=>{const{item:t,commonProps:n,style:a}=e,{onItemChange:i,onItemDelete:o}=n;return m.jsxs("div",{className:ee.dataValidationFormulaListItem,style:a,children:[t.isRef?null:m.jsx("div",{className:O.clsx(ee.dataValidationFormulaListItemDrag,"draggableHandle"),children:m.jsx(yt,{})}),m.jsx(ta,{value:t.color,onChange:s=>{i(t.id,t.label,s)}}),m.jsx(O.Input,{disabled:t.isRef,value:t.label,onChange:s=>{i(t.id,s,t.color)},inputStyle:{height:28}}),t.isRef?null:m.jsx("div",{className:ee.dataValidationFormulaListItemIcon,children:m.jsx(et,{onClick:()=>o(t.id)})})]})};function aa(e){const{value:t,onChange:n=()=>{},unitId:a,subUnitId:i,validResult:o,showError:s,ruleId:d}=e,{formula1:l="",formula2:c=""}=t||{},[h,v]=M.useState(()=>r.isFormulaString(l)?"1":"0"),[u,I]=M.useState(h==="1"?l:"="),[p,R]=M.useState(h==="1"?l:"="),w=D.useDependency(r.LocaleService),g=D.useDependency(x.DataValidatorRegistryService),f=D.useDependency(x.DataValidationModel),C=D.useDependency(S.DataValidationFormulaController),[T,E]=M.useState(()=>c.split(",")),y=g.getValidatorItem(r.DataValidationType.LIST),[V,b]=M.useState([]),[H,$]=M.useState(""),k=s?o==null?void 0:o.formula1:"",B=M.useMemo(()=>f.ruleChange$.pipe(ae.debounceTime(16)),[]),W=D.useObservable(B),U=D.useEvent(n);M.useEffect(()=>{(async()=>{await new Promise(_=>{setTimeout(()=>_(!0),100)});const F=f.getRuleById(a,i,d),G=F==null?void 0:F.formula1;if(r.isFormulaString(G)&&y&&F){const _=await y.getListAsync(F,a,i);b(_)}})()},[f,W,y,d,i,a]),M.useEffect(()=>{r.isFormulaString(l)&&l!==p&&(I(l),R(p))},[p,l]);const[X,z]=M.useState(()=>{const F=h!=="1"?S.deserializeListOptions(l):[],G=c.split(",");return F.map((_,j)=>({label:_,color:G[j]||ye,isRef:!1,id:r.Tools.generateRandomId(4)}))}),Z=(F,G,_)=>{const j=X.find(K=>K.id===F);j&&(j.label=G,j.color=_,z([...X]))},Q=F=>{const G=X.findIndex(_=>_.id===F);G!==-1&&(X.splice(G,1),z([...X]))},J=c.split(","),ie=M.useMemo(()=>V.map((F,G)=>({label:F,color:J[G]||ye,id:`${G}`,isRef:!0})),[J,V]),he=(F,G,_)=>{const j=[...T];j[+F]=_,E(j),U({formula1:l,formula2:j.join(",")})},se=()=>{z([...X,{label:"",color:ye,isRef:!1,id:r.Tools.generateRandomId(4)}])};M.useEffect(()=>{if(h==="1")return;const F=new Set,G=[];X.map(_=>({labelList:_.label.split(","),item:_})).forEach(({item:_,labelList:j})=>{j.forEach(K=>{F.has(K)||(F.add(K),G.push({label:K,color:_.color}))})}),U({formula1:S.serializeListOptions(G.map(_=>_.label)),formula2:G.map(_=>_.color===ye?"":_.color).join(",")})},[X,U,h,p,T]);const oe=D.useEvent(async F=>{if(!r.isFormulaString(F)){U==null||U({formula1:"",formula2:c});return}C.getFormulaRefCheck(F)?(U==null||U({formula1:r.isFormulaString(F)?F:"",formula2:c}),$("")):(U==null||U({formula1:"",formula2:c}),I("="),$(w.t("dataValidation.validFail.formulaError")))}),le=M.useRef(null),[me,pe]=M.useState(!1);return D.useSidebarClick(F=>{var _;((_=le.current)==null?void 0:_.isClickOutSide(F))&&pe(!1)}),m.jsxs(m.Fragment,{children:[m.jsx(O.FormLayout,{label:w.t("dataValidation.list.options"),children:m.jsxs(O.RadioGroup,{value:h,onChange:F=>{v(F),I(p),F==="1"&&U({formula1:p==="="?"":p,formula2:T.join(",")})},children:[m.jsx(O.Radio,{value:"0",children:w.t("dataValidation.list.customOptions")}),m.jsx(O.Radio,{value:"1",children:w.t("dataValidation.list.refOptions")})]})}),h==="1"?m.jsxs(m.Fragment,{children:[m.jsx(Je.FormulaEditor,{initValue:u,unitId:a,subUnitId:i,isFocus:me,onChange:(F="")=>{const G=(F!=null?F:"").trim();R(G),oe(G)},errorText:k||H||void 0,onFocus:()=>pe(!0),isSupportAcrossSheet:!0,ref:le}),ie.length>0&&m.jsx("div",{style:{marginTop:"12px"},children:ie.map(F=>m.jsx(Vt,{item:F,commonProps:{onItemChange:he},style:{marginBottom:12}},F.id))})]}):m.jsx(O.FormLayout,{error:k,children:m.jsxs("div",{style:{marginTop:"-12px"},children:[m.jsx(O.DraggableList,{list:X,onListChange:z,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:F=>m.jsx(Vt,{item:F,commonProps:{onItemChange:Z,onItemDelete:Q}},F.id),idKey:"id"}),m.jsxs("a",{className:ee.dataValidationFormulaListAdd,onClick:se,children:[m.jsx(_t,{}),w.t("dataValidation.list.add")]})]})})]})}const na=[[S.CUSTOM_FORMULA_INPUT_NAME,$t],[S.BASE_FORMULA_INPUT_NAME,Ht],[S.LIST_FORMULA_INPUT_NAME,aa],[S.CHECKBOX_FORMULA_INPUT_NAME,Wt]];var ia=Object.getOwnPropertyDescriptor,oa=(e,t,n,a)=>{for(var i=a>1?void 0:a?ia(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},ra=(e,t)=>(n,a)=>t(n,a,e);A.BaseSheetDataValidatorView=class{constructor(t){L(this,"canvasRender",null);L(this,"dropdownType");L(this,"optionsInput");L(this,"formulaInput",S.LIST_FORMULA_INPUT_NAME);this.injector=t}},A.BaseSheetDataValidatorView=oa([ra(0,r.Inject(r.Injector))],A.BaseSheetDataValidatorView);var sa=Object.getOwnPropertyDescriptor,la=(e,t,n,a)=>{for(var i=a>1?void 0:a?sa(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Dt=(e,t)=>(n,a)=>t(n,a,e);let de=class extends r.Disposable{constructor(t,n){super();L(this,"_open$",new ae.BehaviorSubject(!1));L(this,"open$",this._open$.pipe(ae.distinctUntilChanged()));L(this,"_activeRule");L(this,"_activeRule$",new ae.BehaviorSubject(void 0));L(this,"activeRule$",this._activeRule$.asObservable());L(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=n,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).pipe(ae.filter(a=>!a)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(a=>{a.id===Ue&&(a.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=r.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};de=la([Dt(0,r.IUniverInstanceService),Dt(1,D.ISidebarService)],de);var da=Object.getOwnPropertyDescriptor,ca=(e,t,n,a)=>{for(var i=a>1?void 0:a?da(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Ve=(e,t)=>(n,a)=>t(n,a,e);let De=class extends r.Disposable{constructor(e,t,n,a,i,o){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=n,this._dialogService=a,this._localeService=i,this._sheetsDataValidationValidatorService=o,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(Y.VALIDATE_CELL,{handler:async(e,t,n)=>{const a=await e,{row:i,col:o,unitId:s,subUnitId:d}=t,l=this._dataValidationModel.getRuleIdByLocation(s,d,i,o),c=l?this._dataValidationModel.getRuleById(s,d,l):void 0;if(a===!1)return n(Promise.resolve(!1));if(!c||c.errorStyle!==r.DataValidationErrorStyle.STOP)return n(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(c.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,d,i,o)===r.DataValidationStatus.VALID?n(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:i,col:o,unitId:s,subUnitId:d})},footer:{title:M.createElement(O.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),n(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:M.createElement(O.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};De=ca([Ve(0,r.Inject(Y.SheetInterceptorService)),Ve(1,r.Inject(S.SheetDataValidationModel)),Ve(2,r.Inject(x.DataValidatorRegistryService)),Ve(3,D.IDialogService),Ve(4,r.Inject(r.LocaleService)),Ve(5,r.Inject(S.SheetsDataValidationValidatorService))],De);var ua=Object.getOwnPropertyDescriptor,ha=(e,t,n,a)=>{for(var i=a>1?void 0:a?ua(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},ce=(e,t)=>(n,a)=>t(n,a,e);const tt=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return r.dayjs(r.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=r.dayjs(e);if(t.isValid())return t};function pa(e,t){const n=jt.getPatternType(t);if(e===n)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 r.Disposable{constructor(t,n,a,i,o,s,d,l,c,h){super();L(this,"_activeDropdown");L(this,"_activeDropdown$",new ae.Subject);L(this,"_currentPopup",null);L(this,"activeDropdown$",this._activeDropdown$.asObservable());L(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=n,this._zenZoneService=a,this._dataValidationModel=i,this._sheetsSelectionsService=o,this._cellDropdownManagerService=s,this._sheetDataValidationModel=d,this._commandService=l,this._editorBridgeService=c,this._injector=h,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,n,a,i){const o=t?this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET);if(!o)return;const s=n?o.getSheetBySheetId(n):o.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(o.getUnitId(),s.getSheetId(),a,i);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(n=>!(n.primary&&this._getDropdownByCell(n.primary.unitId,n.primary.sheetId,n.primary.actualRow,n.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var R,w;const{location:n}=t,{row:a,col:i,unitId:o,subUnitId:s,workbook:d,worksheet:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const c=this._sheetDataValidationModel.getRuleByLocation(o,s,a,i);if(!c)return;const h=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!(h!=null&&h.dropdownType))return;let v;const u=async(g,f)=>{var $,k,B;if(!g)return!0;const C=g,T=l.getCell(a,i),E=C.format(f==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),y=($=r.numfmt.parseDate(E))==null?void 0:$.v,V=f==="time"?y%1:y,b=d.getStyles().getStyleByCell(T),H=(B=(k=b==null?void 0:b.n)==null?void 0:k.pattern)!=null?B:"";return c.errorStyle!==r.DataValidationErrorStyle.STOP||await h.validator({value:V,unitId:o,subUnitId:s,row:a,column:i,worksheet:l,workbook:d,interceptValue:E.replace("Z","").replace("T"," "),t:r.CellValueType.NUMBER},c)?(await this._commandService.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:o,keycode:D.KeyCode.ESC}),await this._commandService.executeCommand(Y.SetRangeValuesCommand.id,{unitId:o,subUnitId:s,range:{startColumn:i,endColumn:i,startRow:a,endRow:a},value:{v:V,t:2,p:null,f:null,si:null,s:{n:{pattern:pa(f,H)}}}}),!0):(this._injector.has(De)&&this._injector.get(De).showReject(h.getRuleFinalError(c,{row:a,col:i,unitId:o,subUnitId:s})),!1)};let I;switch(h.dropdownType){case x.DataValidatorDropdownType.DATE:{const g=S.getCellValueOrigin(l.getCellRaw(a,i)),f=tt(g),C=!!((R=c.bizInfo)!=null&&R.showTime);I={location:n,type:"datepicker",props:{showTime:C,onChange:T=>u(T,C?"datetime":"date"),defaultValue:f,patternType:"date"}};break}case x.DataValidatorDropdownType.TIME:{const g=S.getCellValueOrigin(l.getCellRaw(a,i)),f=tt(g);I={location:n,type:"datepicker",props:{onChange:C=>u(C,"time"),defaultValue:f,patternType:"time"}};break}case x.DataValidatorDropdownType.DATETIME:{const g=S.getCellValueOrigin(l.getCellRaw(a,i)),f=tt(g);I={location:n,type:"datepicker",props:{onChange:C=>u(C,"datetime"),defaultValue:f,patternType:"datetime"}};break}case x.DataValidatorDropdownType.LIST:case x.DataValidatorDropdownType.MULTIPLE_LIST:{const g=h.dropdownType===x.DataValidatorDropdownType.MULTIPLE_LIST,f=async b=>{const H=S.serializeListOptions(b),$={unitId:o,subUnitId:s,range:{startColumn:i,endColumn:i,startRow:a,endRow:a},value:{v:H,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:o,keycode:D.KeyCode.ESC}),this._commandService.executeCommand(Y.SetRangeValuesCommand.id,$),!g},C=(c==null?void 0:c.renderMode)===r.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,T=h.getListWithColor(c,o,s),E=S.getDataValidationCellValue(l.getCellRaw(a,i)),y=()=>{this._commandService.executeCommand(Se.id,{ruleId:c.uid}),v==null||v.dispose()},V=T.map(b=>({label:b.label,value:b.label,color:C||b.color?b.color:"transparent"}));I={location:n,type:"list",props:{onChange:b=>f(b),options:V,onEdit:y,defaultValue:E,multiple:g}};break}case x.DataValidatorDropdownType.CASCADE:{I={type:"cascader",props:{onChange:f=>{const C={unitId:o,subUnitId:s,range:{startColumn:i,endColumn:i,startRow:a,endRow:a},value:{v:f.join("/"),p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:o,keycode:D.KeyCode.ESC}),this._commandService.syncExecuteCommand(Y.SetRangeValuesCommand.id,C),!0},defaultValue:S.getDataValidationCellValue(l.getCellRaw(a,i)).split("/"),options:JSON.parse((w=c.formula1)!=null?w:"[]")},location:n};break}case x.DataValidatorDropdownType.COLOR:{I={type:"color",props:{onChange:f=>{const C={unitId:o,subUnitId:s,range:{startColumn:i,endColumn:i,startRow:a,endRow:a},value:{v:f,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:o,keycode:D.KeyCode.ESC}),this._commandService.syncExecuteCommand(Y.SetRangeValuesCommand.id,C),!0},defaultValue:S.getDataValidationCellValue(l.getCellRaw(a,i))},location:n};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(v=this._cellDropdownManagerService.showDropdown(I),!v)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const p=new r.DisposableCollection;p.add(v),p.add({dispose:()=>{var g,f;(f=(g=this._activeDropdown)==null?void 0:g.onHide)==null||f.call(g)}}),this._currentPopup=p}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,n,a,i,o){const s=this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(n);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),a,i);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:a,col:i,unitId:t,subUnitId:n},onHide:o})}};fe=ha([ce(0,r.IUniverInstanceService),ce(1,r.Inject(x.DataValidatorRegistryService)),ce(2,D.IZenZoneService),ce(3,r.Inject(S.SheetDataValidationModel)),ce(4,r.Inject(Y.SheetsSelectionsService)),ce(5,r.Inject(N.ISheetCellDropdownManagerService)),ce(6,r.Inject(S.SheetDataValidationModel)),ce(7,r.ICommandService),ce(8,N.IEditorBridgeService),ce(9,r.Inject(r.Injector))],fe);const Ue="DataValidationPanel",Se={id:"data-validation.operation.open-validation-panel",type:r.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:n,isAdd:a}=t,i=e.get(de),o=e.get(x.DataValidationModel),s=e.get(r.IUniverInstanceService),d=e.get(D.ISidebarService),l=Y.getSheetCommandTarget(s);if(!l)return!1;const{unitId:c,subUnitId:h}=l,v=n?o.getRuleById(c,h,n):void 0;i.open(),i.setActiveRule(v&&{unitId:c,subUnitId:h,rule:v});const u=d.open({id:Ue,header:{title:a?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Ue},width:312,onClose:()=>i.close()});return i.setCloseDisposable(u),!0}},at={id:"data-validation.operation.close-validation-panel",type:r.CommandType.OPERATION,handler(e){return e.get(de).close(),!0}},wt={id:"data-validation.operation.toggle-validation-panel",type:r.CommandType.OPERATION,handler(e){const t=e.get(r.ICommandService),n=e.get(de);return n.open(),n.isOpen?t.executeCommand(at.id):t.executeCommand(Se.id),!0}},Ne={type:r.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const n=e.get(fe),{unitId:a,subUnitId:i,row:o,column:s}=t,d=n.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===a&&l.subUnitId===i&&l.row===o&&l.col===s||n.showDataValidationDropdown(a,i,o,s),!0}},Et={type:r.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(fe).hideDropdown(),!0):!1}},ke={type:r.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(r.IUniverInstanceService),n=Y.getSheetCommandTarget(t);if(!n)return!1;const{workbook:a,worksheet:i}=n,o=S.createDefaultNewRule(e),s=e.get(r.ICommandService),d=a.getUnitId(),l=i.getSheetId(),c={rule:o,unitId:d,subUnitId:l};return s.syncExecuteCommand(S.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(Se.id,{ruleId:o.uid,isAdd:!0}),!0):!1}},Mt="sheets-data-validation-ui.config",Be={};var ma=Object.getOwnPropertyDescriptor,ga=(e,t,n,a)=>{for(var i=a>1?void 0:a?ma(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},we=(e,t)=>(n,a)=>t(n,a,e);const _e="SHEET_DATA_VALIDATION_ALERT";let Pe=class extends r.Disposable{constructor(e,t,n,a,i,o){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=n,this._localeService=a,this._zenZoneService=i,this._dataValidationModel=o,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ae.debounceTime(100)).subscribe(e=>{var t;if(e){const n=this._univerInstanceService.getUnit(e.location.unitId,r.UniverInstanceType.UNIVER_SHEET),a=n.getSheetBySheetId(e.location.subUnitId);if(!a)return;const i=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!i){this._cellAlertManagerService.removeAlert(_e);return}if(this._dataValidationModel.validator(i,{...e.location,workbook:n,worksheet:a})===r.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(_e),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(_e);return}const l=this._dataValidationModel.getValidator(i.type);if(!l){this._cellAlertManagerService.removeAlert(_e);return}this._cellAlertManagerService.showAlert({type:N.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(i,e.location),location:e.location,width:200,height:74,key:_e});return}}this._cellAlertManagerService.removeAlert(_e)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(_e)}))}};Pe=ga([we(0,r.Inject(N.HoverManagerService)),we(1,r.Inject(N.CellAlertManagerService)),we(2,r.IUniverInstanceService),we(3,r.Inject(r.LocaleService)),we(4,D.IZenZoneService),we(5,r.Inject(S.SheetDataValidationModel))],Pe);var va=Object.getOwnPropertyDescriptor,fa=(e,t,n,a)=>{for(var i=a>1?void 0:a?va(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},nt=(e,t)=>(n,a)=>t(n,a,e);let Ee=class extends r.Disposable{constructor(e,t,n){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(a,i)=>{const{source:o,target:s,unitId:d,subUnitId:l}=a,c=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),h=N.virtualizeDiscreteRanges([o,s]),[v,u]=h.ranges,{mapFunc:I}=h,p={row:v.startRow,col:v.startColumn},R=N.getAutoFillRepeatRange(v,u),w=new r.ObjectMatrix,g=new Set;R.forEach(y=>{const V=y.repeatStartCell,b=y.relativeRange,H={startRow:p.row,startColumn:p.col,endColumn:p.col,endRow:p.row},$={startRow:V.row,startColumn:V.col,endColumn:V.col,endRow:V.row};r.Range.foreach(b,(k,B)=>{const W=r.Rectangle.getPositionRange({startRow:k,startColumn:B,endColumn:B,endRow:k},H),{row:U,col:X}=I(W.startRow,W.startColumn),z=this._sheetDataValidationModel.getRuleIdByLocation(d,l,U,X)||"",Z=r.Rectangle.getPositionRange({startRow:k,startColumn:B,endColumn:B,endRow:k},$),{row:Q,col:J}=I(Z.startRow,Z.startColumn);w.setValue(Q,J,z),g.add(z)})});const f=Array.from(g).map(y=>({id:y,ranges:r.queryObjectMatrix(w,V=>V===y)}));c.addRangeRules(f);const C=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:T,undoMutations:E}=S.getDataValidationDiffMutations(d,l,C,this._injector,"patched",i===N.APPLY_TYPE.ONLY_FORMAT);return{undos:E,redos:T}},n={id:S.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:a=>{const{source:i,unitId:o,subUnitId:s}=a;for(const d of i.rows)for(const l of i.cols){const c=this._sheetDataValidationModel.getRuleByLocation(o,s,d,l);if(c&&c.type===r.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(N.APPLY_TYPE.SERIES,!0);return}}},onFillData:(a,i,o)=>o===N.APPLY_TYPE.COPY||o===N.APPLY_TYPE.ONLY_FORMAT||o===N.APPLY_TYPE.SERIES?t(a,o):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};Ee=fa([nt(0,N.IAutoFillService),nt(1,r.Inject(S.SheetDataValidationModel)),nt(2,r.Inject(r.Injector))],Ee);var Sa=Object.getOwnPropertyDescriptor,_a=(e,t,n,a)=>{for(var i=a>1?void 0:a?Sa(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},it=(e,t)=>(n,a)=>t(n,a,e);let Me=class extends r.Disposable{constructor(t,n,a){super();L(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=n,this._injector=a,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:S.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,n,a)=>this._collect(t,n,a),onPasteCells:(t,n,a,i)=>{const{copyType:o=N.COPY_TYPE.COPY,pasteType:s}=i,{range:d}=t||{},{range:l,unitId:c,subUnitId:h}=n;return this._generateMutations(l,{copyType:o,pasteType:s,copyRange:d,unitId:c,subUnitId:h})}})}_collect(t,n,a){const i=new r.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:n,matrix:i};const o=this._injector.invoke(l=>Y.rangeToDiscreteRange(a,l,t,n));if(!o)return;const{rows:s,cols:d}=o;s.forEach((l,c)=>{d.forEach((h,v)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,n,l,h);i.setValue(c,v,u!=null?u:"")})})}_generateMutations(t,n){if(!this._copyInfo)return{redos:[],undos:[]};if(n.copyType===N.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:i,subUnitId:o}=this._copyInfo;if(n.unitId!==i||o!==n.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(n.unitId,n.subUnitId).clone(),d=new r.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:v}=N.virtualizeDiscreteRanges([n.copyRange,t]),u=N.getRepeatRange(c,h,!0),I=new Map;u.forEach(({startRange:g})=>{var f;(f=this._copyInfo)==null||f.matrix.forValue((C,T,E)=>{const y=r.Rectangle.getPositionRange({startRow:C,endRow:C,startColumn:T,endColumn:T},g),V=`${o}-${E}`,b=this._sheetDataValidationModel.getRuleById(i,o,E);!this._sheetDataValidationModel.getRuleById(n.unitId,n.subUnitId,V)&&b&&I.set(V,{...b,uid:V});const{row:H,col:$}=v(y.startRow,y.startColumn);l.add(V),d.setValue(H,$,V)})});const p=Array.from(l).map(g=>({id:g,ranges:r.queryObjectMatrix(d,f=>f===g)}));s.addRangeRules(p);const{redoMutations:R,undoMutations:w}=S.getDataValidationDiffMutations(n.unitId,n.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(n.unitId,n.subUnitId),I.values()),this._injector,"patched",!1);return{redos:R,undos:w}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(i,o).clone(),d=new r.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:v}=N.virtualizeDiscreteRanges([n.copyRange,t]);N.getRepeatRange(c,h,!0).forEach(({startRange:w})=>{var g;(g=this._copyInfo)==null||g.matrix.forValue((f,C,T)=>{const E=r.Rectangle.getPositionRange({startRow:f,endRow:f,startColumn:C,endColumn:C},w),{row:y,col:V}=v(E.startRow,E.startColumn);d.setValue(y,V,T),l.add(T)})});const I=Array.from(l).map(w=>({id:w,ranges:r.queryObjectMatrix(d,g=>g===w)}));s.addRangeRules(I);const{redoMutations:p,undoMutations:R}=S.getDataValidationDiffMutations(i,o,s.diff(this._sheetDataValidationModel.getRules(i,o)),this._injector,"patched",!1);return{redos:p,undos:R}}}};Me=_a([it(0,N.ISheetClipboardService),it(1,r.Inject(S.SheetDataValidationModel)),it(2,r.Inject(r.Injector))],Me);var Ia=Object.getOwnPropertyDescriptor,Ca=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ia(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},ot=(e,t)=>(n,a)=>t(n,a,e);let Te=class extends r.Disposable{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===S.AddSheetDataValidationCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[Y.WorkbookEditablePermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint],worksheetTypes:[Y.WorksheetEditPermission,Y.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===S.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[Y.WorkbookEditablePermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint],worksheetTypes:[Y.WorksheetEditPermission,Y.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Te=Ca([ot(0,r.Inject(r.LocaleService)),ot(1,r.ICommandService),ot(2,r.Inject(Y.SheetPermissionCheckController))],Te);const Tt="data-validation-single",bt="sheet.menu.data-validation";function ya(e){return{id:bt,type:D.MenuItemType.SUBITEMS,icon:Tt,tooltip:"dataValidation.title",hidden$:D.getMenuHiddenObservable(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[Y.WorkbookEditablePermission],worksheetTypes:[Y.WorksheetSetCellStylePermission,Y.WorksheetEditPermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint]})}}function Va(e){return{id:Se.id,title:"dataValidation.panel.title",type:D.MenuItemType.BUTTON}}function Da(e){return{id:ke.id,title:"dataValidation.panel.add",type:D.MenuItemType.BUTTON}}const wa={[D.RibbonStartGroup.FORMULAS_INSERT]:{[bt]:{order:9,menuItemFactory:ya,[Se.id]:{order:0,menuItemFactory:Va},[ke.id]:{order:1,menuItemFactory:Da}}}};var Ea=Object.getOwnPropertyDescriptor,Ot=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ea(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},q=(e,t)=>(n,a)=>t(n,a,e);const Rt={tr:{size:6,color:"#fe4b4b"}};let be=class extends r.RxDisposable{constructor(e,t,n,a,i,o,s,d,l,c,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=n,this._univerInstanceService=a,this._autoHeightController=i,this._dropdownManagerService=o,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(wa)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var n;if(!e.visible){((n=this._dropdownManagerService.activeDropdown)==null?void 0:n.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:a,sheetId:i,row:o,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(a);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(a,i,o,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 v=this._dropdownManagerService.activeDropdown,u=v==null?void 0:v.location;if(u&&u.unitId===a&&u.subUnitId===i&&u.row===o&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:a,subUnitId:i,row:o,col:s,workbook:d,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(Y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:Y.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var g,f,C,T,E;const{row:a,col:i,unitId:o,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(o,s,a,i);if(!c)return n(e);const h=this._sheetDataValidationModel.getRuleById(o,s,c);if(!h)return n(e);const v=(g=this._dataValidationCacheService.getValue(o,s,a,i))!=null?g:r.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),I=t.rawData;let p;const R={get value(){var y;return p!==void 0||(p=(y=S.getCellValueOrigin(I))!=null?y:null),p}},w={get value(){var y;return`${(y=R.value)!=null?y:""}`}};return n({...e,markers:{...e==null?void 0:e.markers,...v===r.DataValidationStatus.INVALID?Rt:null},customRender:[...(f=e==null?void 0:e.customRender)!=null?f:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((C=e==null?void 0:e.fontRenderExtension)==null?void 0:C.isSkip)||((T=u==null?void 0:u.skipDefaultFontRender)==null?void 0:T.call(u,h,R.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,w.value,{get style(){const y=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?y.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},a,i)},interceptorAutoHeight:()=>{var H,$,k,B,W,U;const y=($=(H=this._renderManagerService.getRenderById(o))==null?void 0:H.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:$.skeleton;if(!y)return;const V=y.worksheet.getMergedCell(a,i),b={data:e,style:y.getStyles().getStyleByCell(e),primaryWithCoord:y.getCellWithCoordByIndex((k=V==null?void 0:V.startRow)!=null?k:a,(B=V==null?void 0:V.startColumn)!=null?B:i),unitId:o,subUnitId:s,row:a,col:i,workbook:d,worksheet:l};return(U=(W=u==null?void 0:u.canvasRender)==null?void 0:W.calcCellAutoHeight)==null?void 0:U.call(W,b)},interceptorAutoWidth:()=>{var H,$,k,B,W,U;const y=($=(H=this._renderManagerService.getRenderById(o))==null?void 0:H.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:$.skeleton;if(!y)return;const V=y.worksheet.getMergedCell(a,i),b={data:e,style:y.getStyles().getStyleByCell(e),primaryWithCoord:y.getCellWithCoordByIndex((k=V==null?void 0:V.startRow)!=null?k:a,(B=V==null?void 0:V.startColumn)!=null?B:i),unitId:o,subUnitId:s,row:a,col:i,workbook:d,worksheet:l};return(U=(W=u==null?void 0:u.canvasRender)==null?void 0:W.calcCellAutoWidth)==null?void 0:U.call(W,b)},coverable:((E=e==null?void 0:e.coverable)!=null?E:!0)&&!(h.type===r.DataValidationType.LIST||h.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ae.filter(e=>e.source==="command"),ae.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(n=>{var a;(n.rule.type===r.DataValidationType.LIST_MULTIPLE||n.rule.type===r.DataValidationType.LIST)&&(a=n.rule)!=null&&a.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);r.sequenceExecute(n.redos,this._commandService)}})}};be=Ot([q(0,r.ICommandService),q(1,D.IMenuManagerService),q(2,P.IRenderManagerService),q(3,r.IUniverInstanceService),q(4,r.Inject(N.AutoHeightController)),q(5,r.Inject(fe)),q(6,r.Inject(S.SheetDataValidationModel)),q(7,r.Inject(x.DataValidatorRegistryService)),q(8,r.Inject(Y.SheetInterceptorService)),q(9,r.Inject(S.DataValidationCacheService)),q(10,r.Optional(N.IEditorBridgeService))],be);let Lt=class extends r.RxDisposable{constructor(e,t,n,a,i,o,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=n,this._dataValidatorRegistryService=a,this._sheetInterceptorService=i,this._sheetDataValidationModel=o,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(Y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:Y.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var w,g,f,C,T;const{row:a,col:i,unitId:o,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(o,s,a,i);if(!c)return n(e);const h=this._sheetDataValidationModel.getRuleById(o,s,c);if(!h)return n(e);const v=(w=this._dataValidationCacheService.getValue(o,s,a,i))!=null?w:r.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),I=l.getCellRaw(a,i),p=S.getCellValueOrigin(I),R=`${p!=null?p:""}`;return n({...e,markers:{...e==null?void 0:e.markers,...v===r.DataValidationStatus.INVALID?Rt:null},customRender:[...(g=e==null?void 0:e.customRender)!=null?g:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((f=e==null?void 0:e.fontRenderExtension)==null?void 0:f.isSkip)||((C=u==null?void 0:u.skipDefaultFontRender)==null?void 0:C.call(u,h,p,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,R,{get style(){const E=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?E.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},a,i)},interceptorAutoHeight:()=>{var b,H,$,k,B,W;const E=(H=(b=this._renderManagerService.getRenderById(o))==null?void 0:b.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:H.skeleton;if(!E)return;const y=E.worksheet.getMergedCell(a,i),V={data:e,style:E.getStyles().getStyleByCell(e),primaryWithCoord:E.getCellWithCoordByIndex(($=y==null?void 0:y.startRow)!=null?$:a,(k=y==null?void 0:y.startColumn)!=null?k:i),unitId:o,subUnitId:s,row:a,col:i,workbook:d,worksheet:l};return(W=(B=u==null?void 0:u.canvasRender)==null?void 0:B.calcCellAutoHeight)==null?void 0:W.call(B,V)},coverable:((T=e==null?void 0:e.coverable)!=null?T:!0)&&!(h.type===r.DataValidationType.LIST||h.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ae.filter(e=>e.source==="command"),ae.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(n=>{var a;(a=n.rule)!=null&&a.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);r.sequenceExecute(n.redos,this._commandService)}})}};Lt=Ot([q(0,r.ICommandService),q(1,P.IRenderManagerService),q(2,r.Inject(N.AutoHeightController)),q(3,r.Inject(x.DataValidatorRegistryService)),q(4,r.Inject(Y.SheetInterceptorService)),q(5,r.Inject(S.SheetDataValidationModel)),q(6,r.Inject(S.DataValidationCacheService))],Lt);var Ma=Object.getOwnPropertyDescriptor,Ta=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ma(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},At=(e,t)=>(n,a)=>t(n,a,e);let je=class extends r.Disposable{constructor(e,t,n){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=n,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var a;if(!t.length)return;const n=new Set;t.forEach(i=>{n.add(i.subUnitId)}),n.forEach(i=>{var o;(o=this._sheetSkeletonManagerService.getSkeletonParam(i))==null||o.skeleton.makeDirty(!0)}),(a=this._context.mainComponent)==null||a.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(r.bufferDebounceTime(16)).subscribe(e))}};je=Ta([At(1,r.Inject(S.SheetDataValidationModel)),At(2,r.Inject(N.SheetSkeletonManagerService))],je);const rt={dataValidationOptionsButton:"univer-data-validation-options-button",dataValidationOptionsButtonIcon:"univer-data-validation-options-button-icon"};function ba(e){var c;const t=D.useDependency(r.LocaleService),n=D.useDependency(D.ComponentManager),{value:a,onChange:i,extraComponent:o}=e,[s,d]=M.useState(!1),l=o?n.get(o):null;return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:rt.dataValidationOptionsButton,onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?m.jsx(Ct,{className:rt.dataValidationOptionsButtonIcon}):m.jsx(It,{className:rt.dataValidationOptionsButtonIcon})]}),s&&m.jsxs(m.Fragment,{children:[l?m.jsx(l,{value:a,onChange:i}):null,m.jsx(O.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:m.jsxs(O.RadioGroup,{value:`${(c=a.errorStyle)!=null?c:r.DataValidationErrorStyle.WARNING}`,onChange:h=>i({...a,errorStyle:+h}),children:[m.jsx(O.Radio,{value:`${r.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),m.jsx(O.Radio,{value:`${r.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),m.jsx(O.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:m.jsx(O.Checkbox,{checked:a.showErrorMessage,onChange:()=>i({...a,showErrorMessage:!a.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),a.showErrorMessage?m.jsx(O.FormLayout,{children:m.jsx(O.Input,{value:a.error,onChange:h=>i({...a,error:h})})}):null]})]})}const Oe={dataValidationDetail:"univer-data-validation-detail",dataValidationDetailFormItem:"univer-data-validation-detail-form-item",dataValidationDetailButtons:"univer-data-validation-detail-buttons",dataValidationDetailButton:"univer-data-validation-detail-button"},Oa=e=>r.debounce(async(t,n,a,i)=>{const o=await e.executeCommand(t,n,a);i==null||i(o)},1e3);function Ra(e,t,n){var a,i,o,s;return t?((i=(a=e.getUnit(t))==null?void 0:a.getSheetBySheetName(n))==null?void 0:i.getSheetId())||"":((s=(o=e.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:o.getSheetBySheetName(n))==null?void 0:s.getSheetId())||""}function La(){var F,G;const[e,t]=M.useState(0),n=D.useDependency(de),a=D.useObservable(n.activeRule$,n.activeRule),{unitId:i,subUnitId:o,rule:s}=a||{},d=s.uid,l=D.useDependency(x.DataValidatorRegistryService),c=D.useDependency(r.IUniverInstanceService),h=D.useDependency(D.ComponentManager),v=D.useDependency(r.ICommandService),u=D.useDependency(x.DataValidationModel),I=D.useDependency(r.LocaleService),[p,R]=M.useState(s),w=l.getValidatorItem(p.type),[g,f]=M.useState(!1),C=l.getValidatorsByScope(x.DataValidatorRegistryScope.SHEET),[T,E]=M.useState(()=>p.ranges.map(_=>({unitId:"",sheetId:"",range:_}))),y=M.useMemo(()=>Oa(v),[v]),[V,b]=M.useState(!1),[H,$]=M.useState(!1),k=M.useRef(null),B=D.useDependency(Y.SheetsSelectionsService);if(M.useEffect(()=>()=>{const _=B.getCurrentLastSelection();_&&B.setSelections([_])},[B]),M.useEffect(()=>{v.onCommandExecuted(_=>{(_.id===r.UndoCommand.id||_.id===r.RedoCommand.id)&&setTimeout(()=>{const j=u.getRuleById(i,o,d);t(K=>K+1),j&&(R(j),E(j.ranges.map(K=>({unitId:"",sheetId:"",range:K}))))},20)})},[v,u,d,o,i]),!w)return null;const W=w.operators,U=w.operatorNames,X=p.operator?x.TWO_FORMULA_OPERATOR_COUNT.includes(p.operator):!1,z=()=>{var _,j,K;(j=(_=k.current)==null?void 0:_.editor)!=null&&j.isFocus()&&Z((K=k.current)==null?void 0:K.getValue()),!(!p.ranges.length||V)&&(w.validatorFormula(p,i,o).success?n.setActiveRule(null):f(!0))},Z=D.useEvent(_=>{const j=_.split(",").filter(Boolean).map(Qe.deserializeRangeWithSheet).map(te=>{const Bt=te.sheetName;if(Bt){const gn=Ra(c,te.unitId,Bt);return{...te,sheetId:gn}}return{...te,sheetId:""}});if(r.isUnitRangesEqual(j,T))return;E(j);const K=j.filter(te=>(!te.unitId||te.unitId===i)&&(!te.sheetId||te.sheetId===o)).map(te=>te.range);if(R({...p,ranges:K}),K.length===0)return;const ge={unitId:i,subUnitId:o,ruleId:d,ranges:K};y(S.UpdateSheetDataValidationRangeCommand.id,ge)}),Q=_=>{if(r.shallowEqual(_,x.getRuleSetting(p)))return;R({...p,..._});const j={unitId:i,subUnitId:o,ruleId:d,setting:_};y(S.UpdateSheetDataValidationSettingCommand.id,j,void 0)},J=async()=>{await v.executeCommand(S.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:i,subUnitId:o}),n.setActiveRule(null)},ie={type:p.type,operator:p.operator,formula1:p.formula1,formula2:p.formula2,allowBlank:p.allowBlank},he=_=>{const j=l.getValidatorItem(_);if(!j)return;const K=j.operators,ge=u.getRuleById(i,o,d),te=_===(ge==null?void 0:ge.type)||_.includes("list")&&(ge!=null&&ge.type.includes("list"))?{...ge,type:_}:{...p,type:_,operator:K[0],formula1:void 0,formula2:void 0};R(te),v.executeCommand(S.UpdateSheetDataValidationSettingCommand.id,{unitId:i,subUnitId:o,ruleId:p.uid,setting:x.getRuleSetting(te)})},se=h.get(w.formulaInput),oe=M.useMemo(()=>T.map(_=>Qe.serializeRange(_.range)).join(","),[]),le=x.getRuleOptions(p),me=_=>{r.shallowEqual(_,x.getRuleOptions(p))||(R({...p,..._}),y(S.UpdateSheetDataValidationOptionsCommand.id,{unitId:i,subUnitId:o,ruleId:d,options:_}))},pe=W.length&&!p.operator;return m.jsxs("div",{className:Oe.dataValidationDetail,children:[m.jsx(O.FormLayout,{label:I.t("dataValidation.panel.range"),error:!p.ranges.length||V?I.t("dataValidation.panel.rangeError"):"",children:m.jsx(Je.RangeSelector,{selectorRef:k,unitId:i,subUnitId:o,initialValue:oe,onChange:(_,j)=>{var K;!H&&((K=k.current)!=null&&K.verify())&&Z(j)},onFocusChange:(_,j)=>{var K;$(_),!_&&j&&((K=k.current)!=null&&K.verify())&&Z(j)},onVerify:_=>b(!_)})}),m.jsx(O.FormLayout,{label:I.t("dataValidation.panel.type"),children:m.jsx(O.Select,{options:(F=C==null?void 0:C.sort((_,j)=>_.order-j.order))==null?void 0:F.map(_=>({label:I.t(_.title),value:_.id})),value:p.type,onChange:he,className:Oe.dataValidationDetailFormItem})}),W!=null&&W.length?m.jsx(O.FormLayout,{label:I.t("dataValidation.panel.operator"),children:m.jsx(O.Select,{options:[{value:"",label:I.t("dataValidation.operators.legal")},...W.map((_,j)=>({value:`${_}`,label:U[j]}))],value:`${p.operator}`,onChange:_=>{Q({...ie,operator:_})},className:Oe.dataValidationDetailFormItem})}):null,se&&!pe?m.jsx(O.FormLayout,{children:m.jsx(se,{isTwoFormula:X,value:{formula1:p.formula1,formula2:p.formula2},onChange:_=>{Q({...ie,..._})},showError:g,validResult:w.validatorFormula(p,i,o),unitId:i,subUnitId:o,ruleId:d},e+p.type)}):null,m.jsx(O.FormLayout,{children:m.jsx(O.Checkbox,{checked:(G=p.allowBlank)!=null?G:!0,onChange:()=>{var _;return Q({...ie,allowBlank:!((_=p.allowBlank)==null||_)})},children:I.t("dataValidation.panel.allowBlank")})}),m.jsx(ba,{value:le,onChange:me,extraComponent:w.optionsInput}),m.jsxs("div",{className:Oe.dataValidationDetailButtons,children:[m.jsx(O.Button,{className:Oe.dataValidationDetailButton,onClick:J,children:I.t("dataValidation.panel.removeRule")}),m.jsx(O.Button,{className:Oe.dataValidationDetailButton,variant:"primary",onClick:z,children:I.t("dataValidation.panel.done")})]})]})}const He={dataValidationItemContainer:"univer-data-validation-item-container",dataValidationItemTitle:"univer-data-validation-item-title",dataValidationItemContent:"univer-data-validation-item-content",dataValidationItemIcon:"univer-data-validation-item-icon"},Aa=e=>{const{rule:t,onClick:n,unitId:a,subUnitId:i,disable:o}=e,s=D.useDependency(x.DataValidatorRegistryService),d=D.useDependency(r.ICommandService),l=D.useDependency(N.IMarkSelectionService),c=s.getValidatorItem(t.type),h=M.useRef(void 0),[v,u]=M.useState(!1),I=D.useDependency(r.ThemeService),p=D.useObservable(I.currentTheme$),R=M.useMemo(()=>{var C;const g=(C=p==null?void 0:p.loopColor2)!=null?C:"#49B811",f=new r.ColorKit(g).toRgb();return{fill:`rgba(${f.r}, ${f.g}, ${f.b}, 0.1)`,stroke:g}},[p]),w=g=>{d.executeCommand(S.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:a,subUnitId:i}),g.stopPropagation()};return M.useEffect(()=>()=>{var g;h.current&&((g=h.current)==null||g.forEach(f=>{f&&l.removeShape(f)}))},[l]),m.jsxs("div",{className:He.dataValidationItemContainer,onClick:n,onMouseEnter:()=>{o||(u(!0),h.current=t.ranges.map(g=>l.addShape({range:g,style:R,primary:null})))},onMouseLeave:()=>{var g;u(!1),(g=h.current)==null||g.forEach(f=>{f&&l.removeShape(f)}),h.current=void 0},children:[m.jsx("div",{className:He.dataValidationItemTitle,children:c==null?void 0:c.generateRuleName(t)}),m.jsx("div",{className:He.dataValidationItemContent,children:t.ranges.map(g=>Qe.serializeRange(g)).join(",")}),v?m.jsx("div",{className:He.dataValidationItemIcon,onClick:w,children:m.jsx(et,{})}):null]})},We={dataValidationList:"univer-data-validation-list",dataValidationListButtons:"univer-data-validation-list-buttons",dataValidationListButton:"univer-data-validation-list-button"};function Pa(e){const t=D.useDependency(S.SheetDataValidationModel),n=D.useDependency(r.IUniverInstanceService),a=D.useDependency(r.ICommandService),i=D.useDependency(r.Injector),o=D.useDependency(de),s=D.useDependency(r.LocaleService),[d,l]=M.useState([]),{workbook:c}=e,h=D.useObservable(c.activeSheet$,void 0,!0),v=c.getUnitId(),u=h==null?void 0:h.getSheetId();M.useEffect(()=>{l(t.getRules(v,u));const f=t.ruleChange$.subscribe(C=>{C.unitId===v&&C.subUnitId===u&&l(t.getRules(v,u))});return()=>{f.unsubscribe()}},[v,u,t]);const I=async()=>{const f=S.createDefaultNewRule(i),C={unitId:v,subUnitId:u,rule:f};await a.executeCommand(S.AddSheetDataValidationCommand.id,C),o.setActiveRule({unitId:v,subUnitId:u,rule:f})},p=()=>{a.executeCommand(S.RemoveSheetAllDataValidationCommand.id,{unitId:v,subUnitId:u})},w=(f=>{const C=n.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET),T=C.getActiveSheet(),E=C.getUnitId(),y=T.getSheetId();return f.map(b=>Y.checkRangesEditablePermission(i,E,y,b.ranges)?{...b}:{...b,disable:!0})})(d),g=w==null?void 0:w.some(f=>f.disable);return m.jsxs("div",{className:We.dataValidationList,children:[w==null?void 0:w.map(f=>{var C;return m.jsx(Aa,{unitId:v,subUnitId:u,onClick:()=>{f.disable||o.setActiveRule({unitId:v,subUnitId:u,rule:f})},rule:f,disable:(C=f.disable)!=null?C:!1},f.uid)}),m.jsxs("div",{className:We.dataValidationListButtons,children:[d.length&&!g?m.jsx(O.Button,{className:We.dataValidationListButton,onClick:p,children:s.t("dataValidation.panel.removeAll")}):null,m.jsx(O.Button,{className:We.dataValidationListButton,variant:"primary",onClick:I,children:s.t("dataValidation.panel.add")})]})]})}const Fa=()=>{const e=D.useDependency(de),t=D.useObservable(e.activeRule$,e.activeRule),n=D.useDependency(r.IUniverInstanceService),a=D.useObservable(()=>n.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),i=D.useObservable(()=>{var o;return(o=a==null?void 0:a.activeSheet$)!=null?o:ae.of(null)},void 0,void 0,[]);return!a||!i?null:t&&t.subUnitId===i.getSheetId()?m.jsx(La,{},t.rule.uid):m.jsx(Pa,{workbook:a})},Ua="LIST_RENDER_MODE_OPTION_INPUT";function $e(e){var i;const{value:t,onChange:n}=e,a=D.useDependency(r.LocaleService);return m.jsx(O.FormLayout,{label:a.t("dataValidation.renderMode.label"),children:m.jsxs(O.RadioGroup,{value:`${(i=t.renderMode)!=null?i:r.DataValidationRenderMode.CUSTOM}`,onChange:o=>n({...t,renderMode:+o}),children:[m.jsx(O.Radio,{value:`${r.DataValidationRenderMode.CUSTOM}`,children:a.t("dataValidation.renderMode.chip")}),m.jsx(O.Radio,{value:`${r.DataValidationRenderMode.ARROW}`,children:a.t("dataValidation.renderMode.arrow")}),m.jsx(O.Radio,{value:`${r.DataValidationRenderMode.TEXT}`,children:a.t("dataValidation.renderMode.text")})]})})}$e.componentKey=Ua;const Na="DATE_SHOW_TIME_OPTION";function Ye(e){var i;const{value:t,onChange:n}=e,a=D.useDependency(r.LocaleService);return m.jsx(O.FormLayout,{children:m.jsx(O.Checkbox,{checked:(i=t.bizInfo)==null?void 0:i.showTime,onChange:o=>{n({...t,bizInfo:{...t.bizInfo,showTime:o}})},children:a.t("dataValidation.showTime.label")})})}Ye.componentKey=Na;var ka=Object.getOwnPropertyDescriptor,Ba=(e,t,n,a)=>{for(var i=a>1?void 0:a?ka(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Re=(e,t)=>(n,a)=>t(n,a,e);const xe=6;let st=class{constructor(e,t,n,a,i,o){this._commandService=e,this._univerInstanceService=t,this._formulaService=n,this._themeService=a,this._renderManagerService=i,this._dataValidationModel=o}_calc(e,t){var c,h,v;const{vt:n,ht:a}=t||{},i=e.endX-e.startX-xe*2,o=e.endY-e.startY,s=((c=t==null?void 0:t.fs)!=null?c:10)*1.6;let d=0,l=0;switch(n){case r.VerticalAlign.TOP:l=0;break;case r.VerticalAlign.BOTTOM:l=0+(o-s);break;default:l=0+(o-s)/2;break}switch(a){case r.HorizontalAlign.LEFT:d=xe;break;case r.HorizontalAlign.RIGHT:d=xe+(i-s);break;default:d=xe+(i-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((v=t==null?void 0:t.fs)!=null?v:10)*1.6}}calcCellAutoHeight(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}calcCellAutoWidth(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}async _parseFormula(e,t,n){var c,h,v,u,I,p,R,w,g;const{formula1:a=S.CHECKBOX_FORMULA_1,formula2:i=S.CHECKBOX_FORMULA_2}=e,o=await this._formulaService.getRuleFormulaResult(t,n,e.uid),s=S.getFormulaResult((v=(h=(c=o==null?void 0:o[0])==null?void 0:c.result)==null?void 0:h[0])==null?void 0:v[0]),d=S.getFormulaResult((p=(I=(u=o==null?void 0:o[1])==null?void 0:u.result)==null?void 0:I[0])==null?void 0:p[0]),l=S.isLegalFormulaResult(String(s))&&S.isLegalFormulaResult(String(d));return{formula1:r.isFormulaString(a)?S.getFormulaResult((g=(w=(R=o==null?void 0:o[0])==null?void 0:R.result)==null?void 0:w[0])==null?void 0:g[0]):a,formula2:r.isFormulaString(i)?d:i,isFormulaValid:l}}drawWith(e,t){var B,W,U,X;const{style:n,primaryWithCoord:a,unitId:i,subUnitId:o,worksheet:s,row:d,col:l}=t,c=a.isMergedMainCell?a.mergeInfo:a,h=S.getCellValueOrigin(s.getCellRaw(d,l)),v=this._dataValidationModel.getRuleByLocation(i,o,d,l);if(!v)return;const u=this._dataValidationModel.getValidator(v.type);if(!u)return;const I=this._themeService.getCurrentTheme();if(!((B=u.skipDefaultFontRender)!=null&&B.call(u,v,h,{unitId:i,subUnitId:o,row:d,column:l})))return;const p=u.parseFormulaSync(v,i,o),{formula1:R}=p,w=this._calc(c,n),{a:g,d:f}=e.getTransform(),C=P.fixLineWidthByScale(w.left,g),T=P.fixLineWidthByScale(w.top,f),E=P.Transform.create().composeMatrix({left:C,top:T,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),y=c.endX-c.startX,V=c.endY-c.startY;e.save(),e.beginPath(),e.rect(c.startX,c.startY,y,V),e.clip();const b=E.getMatrix();e.transform(b[0],b[1],b[2],b[3],b[4],b[5]);const H=((W=n==null?void 0:n.fs)!=null?W:10)*1.6,$=String(h)===String(R),k=I.hyacinth500;P.CheckboxShape.drawWith(e,{checked:$,width:H,height:H,fill:(X=(U=n==null?void 0:n.cl)==null?void 0:U.rgb)!=null?X:k}),e.restore()}isHit(e,t){const n=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,a=this._calc(n,t.style),i=a.top,o=a.top+a.height,s=a.left,d=a.left+a.width,{x:l,y:c}=e;return l<=d&&l>=s&&c<=o&&c>=i}async onPointerDown(e,t){var p;if(t.button===2)return;const{primaryWithCoord:n,unitId:a,subUnitId:i,worksheet:o,row:s,col:d}=e,l=S.getCellValueOrigin(o.getCellRaw(s,d)),c=this._dataValidationModel.getRuleByLocation(a,i,s,d);if(!c)return;const h=this._dataValidationModel.getValidator(c.type);if(!h||!((p=h.skipDefaultFontRender)!=null&&p.call(h,c,l,{unitId:a,subUnitId:i,row:s,column:d})))return;const{formula1:v,formula2:u}=await this._parseFormula(c,a,i),I={range:{startColumn:n.actualColumn,endColumn:n.actualColumn,startRow:n.actualRow,endRow:n.actualRow},value:{v:String(l)===S.transformCheckboxValue(String(v))?u:v,p:null}};this._commandService.executeCommand(Y.SetRangeValuesCommand.id,I)}onPointerEnter(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.DEFAULT)}};st=Ba([Re(0,r.ICommandService),Re(1,r.IUniverInstanceService),Re(2,r.Inject(S.DataValidationFormulaService)),Re(3,r.Inject(r.ThemeService)),Re(4,r.Inject(P.IRenderManagerService)),Re(5,r.Inject(S.SheetDataValidationModel))],st);class ja extends A.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",r.DataValidationType.CHECKBOX);L(this,"canvasRender",this.injector.createInstance(st));L(this,"formulaInput",S.CHECKBOX_FORMULA_INPUT_NAME)}}class Ha extends A.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",r.DataValidationType.CUSTOM);L(this,"formulaInput",S.CUSTOM_FORMULA_INPUT_NAME)}}const Wa="data-validation.formula-input";class $a extends A.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",r.DataValidationType.DATE);L(this,"formulaInput",Wa);L(this,"optionsInput",Ye.componentKey);L(this,"dropdownType",x.DataValidatorDropdownType.DATE)}}class Ya extends A.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",r.DataValidationType.DECIMAL);L(this,"formulaInput",S.BASE_FORMULA_INPUT_NAME)}}const Pt=4,xa=0,lt=4,Ft=4,dt=6,Xe=6,Ie=14;function Xa(e,t){const n=P.FontCache.getTextSize(e,t),a=n.width+Pt*2,{ba:i,bd:o}=n,s=i+o;return{width:a,height:s+xa*2,ba:i}}function ct(e,t,n,a){const i=Ie+dt*2,o=n-i,s=a-Xe*2,d=e.map(u=>({layout:Xa(u,t),text:u}));let l;const c=[];d.forEach(u=>{const{layout:I}=u,{width:p,height:R}=I;!l||l.width+p+lt>o?(l={width:p,height:R,items:[{...u,left:0}]},c.push(l)):(l.items.push({...u,left:l.width+lt}),l.width=l.width+p+lt)});let h=0,v=0;return c.forEach((u,I)=>{v=Math.max(v,u.width),I===c.length-1?h+=u.height:h+=u.height+Ft}),{lines:c,totalHeight:h,contentWidth:o,contentHeight:s,cellAutoHeight:h+Xe*2,calcAutoWidth:v+i}}const za=8;class Ka extends P.Shape{static drawWith(t,n){const{fontString:a,info:i,fill:o,color:s}=n,{layout:d,text:l}=i;t.save(),P.Rect.drawWith(t,{width:d.width,height:d.height,radius:za,fill:o||ye}),t.translateWithPrecision(Pt,d.ba),t.font=a,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var Ga=Object.getOwnPropertyDescriptor,qa=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ga(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},ze=(e,t)=>(n,a)=>t(n,a,e);const Za=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let ut=class{constructor(e,t,n,a){L(this,"zIndex");L(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,this._dataValidationModel=a}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,a,i){const o=n-Ie+4;let s=4;switch(i){case r.VerticalAlign.MIDDLE:s=(a-Ie)/2+4;break;case r.VerticalAlign.BOTTOM:s=a-Ie+4;break}e.save(),e.translateWithPrecision(t.startX+o,t.startY+s),e.fillStyle="#565656",e.fill(Za),e.restore()}drawWith(e,t,n,a){var Q,J;const{primaryWithCoord:i,row:o,col:s,style:d,data:l,subUnitId:c}=t,h=i.isMergedMainCell?i.mergeInfo:i,v=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:I=0,topOffset:p=0,downOffset:R=0}=v||{},w=this._ensureMap(c),g=this._generateKey(o,s),f=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,o,s);if(!f)return;const C=this._dataValidationModel.getValidator(f.type);if(!C)return;const T={startX:h.startX+u,endX:h.endX-I,startY:h.startY+p,endY:h.endY-R},E=T.endX-T.startX,y=T.endY-T.startY,{cl:V}=d||{},b=(Q=typeof V=="object"?V==null?void 0:V.rgb:V)!=null?Q:"#000",H=P.getFontStyleString(d!=null?d:void 0),{vt:$,ht:k}=d||{},B=$!=null?$:r.VerticalAlign.MIDDLE,W=(J=S.getCellValueOrigin(l))!=null?J:"",U=C.parseCellValue(W),X=C.getListWithColorMap(f),z=ct(U,H,E,y);this._drawDownIcon(e,T,E,y,B),e.save(),e.translateWithPrecision(T.startX,T.startY),e.beginPath(),e.rect(0,0,E-Ie,y),e.clip(),e.translateWithPrecision(dt,Xe);let Z=0;switch(B){case r.VerticalAlign.MIDDLE:Z=(z.contentHeight-z.totalHeight)/2;break;case r.VerticalAlign.BOTTOM:Z=z.contentHeight-z.totalHeight;break}e.translateWithPrecision(0,Z),z.lines.forEach((ie,he)=>{e.save();const{width:se,height:oe,items:le}=ie;let me=0;switch(k){case r.HorizontalAlign.RIGHT:me=z.contentWidth-se;break;case r.HorizontalAlign.CENTER:me=(z.contentWidth-se)/2;break}e.translate(me,he*(oe+Ft)),le.forEach(pe=>{e.save(),e.translateWithPrecision(pe.left,0),Ka.drawWith(e,{...H,info:pe,color:b,fill:X[pe.text]}),e.restore()}),e.restore()}),e.restore(),w.set(g,{left:T.startX,top:T.startY,width:z.contentWidth+dt+Ie,height:z.contentHeight+Xe*2})}calcCellAutoHeight(e){var E;const{primaryWithCoord:t,style:n,data:a,row:i,col:o}=e,s=a==null?void 0:a.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,u={startX:v.startX+d,endX:v.endX-l,startY:v.startY+c,endY:v.endY-h},I=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,o);if(!I)return;const p=this._dataValidationModel.getValidator(I.type);if(!p)return;const R=u.endX-u.startX,w=u.endY-u.startY,g=(E=S.getCellValueOrigin(a))!=null?E:"",f=p.parseCellValue(g),C=P.getFontStyleString(n!=null?n:void 0);return ct(f,C,R,w).cellAutoHeight}calcCellAutoWidth(e){var E;const{primaryWithCoord:t,style:n,data:a,row:i,col:o}=e,s=a==null?void 0:a.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,u={startX:v.startX+d,endX:v.endX-l,startY:v.startY+c,endY:v.endY-h},I=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,o);if(!I)return;const p=this._dataValidationModel.getValidator(I.type);if(!p)return;const R=u.endX-u.startX,w=u.endY-u.startY,g=(E=S.getCellValueOrigin(a))!=null?E:"",f=p.parseCellValue(g),C=P.getFontStyleString(n!=null?n:void 0);return ct(f,C,R,w).calcAutoWidth}isHit(e,t){const{primaryWithCoord:n}=t,a=n.isMergedMainCell?n.mergeInfo:n,{endX:i}=a,{x:o}=e;return o>=i-Ie&&o<=i}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:a,row:i,col:o}=e,s={unitId:n,subUnitId:a,row:i,column:o};this._commandService.executeCommand(Ne.id,s)}onPointerEnter(e,t){var n,a;return(a=(n=P.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:a.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;return(a=(n=P.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:a.setCursor(P.CURSOR_TYPE.DEFAULT)}};ut=qa([ze(0,r.ICommandService),ze(1,r.IUniverInstanceService),ze(2,r.Inject(P.IRenderManagerService)),ze(3,r.Inject(S.SheetDataValidationModel))],ut);class Ja extends A.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",r.DataValidationType.LIST_MULTIPLE);L(this,"canvasRender",this.injector.createInstance(ut));L(this,"dropdownType",x.DataValidatorDropdownType.MULTIPLE_LIST)}}var Qa=Object.getOwnPropertyDescriptor,en=(e,t,n,a)=>{for(var i=a>1?void 0:a?Qa(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Fe=(e,t)=>(n,a)=>t(n,a,e);const Ce=4,Ke=4,re=14,ue=6,Le=4,ht=8,tn="#565656",Ut=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function an(e,t){const n=e.length;return{id:"d",body:{dataStream:`${e}${r.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:r.BooleanNumber.FALSE,bl:r.BooleanNumber.FALSE,ul:{s:r.BooleanNumber.FALSE},st:{s:r.BooleanNumber.FALSE},ol:{s:r.BooleanNumber.FALSE},cl:void 0,...t,bg:void 0,bd:void 0},st:0,ed:n}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function Nt(e,t,n){const a=an(e,n),i=new r.DocumentDataModel(a),o=new P.DocumentViewModel(i);return{documentSkeleton:P.DocumentSkeleton.create(o,t),docModel:i,docViewModel:o}}function Ge(e,t,n){const{documentSkeleton:a,docModel:i,docViewModel:o}=Nt(e,t,n);return{documents:new P.Documents(`DOCUMENTS_${r.Tools.generateRandomId()}`,a,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:a,docModel:i,docViewModel:o}}function kt(e,t,n,a,i,o,s=!0){let d=0;const l=s?Le:0;switch(i){case r.VerticalAlign.BOTTOM:d=t-a-l;break;case r.VerticalAlign.MIDDLE:d=(t-a)/2;break;default:d=l;break}d=Math.max(Le,d);let c=0;switch(o){case r.HorizontalAlign.CENTER:c=(e-n)/2;break;case r.HorizontalAlign.RIGHT:c=e-n;break}return c=Math.max(ue,c),{paddingLeft:c,paddingTop:d}}let pt=class{constructor(e,t,n,a,i){L(this,"_dropdownInfoMap",new Map);L(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=n,this._renderManagerService=a,this._dataValidationModel=i}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,a,i,o,s){const{t:d=r.DEFAULT_STYLES.pd.t,b:l=r.DEFAULT_STYLES.pd.b}=s,c=n-re;let h;switch(o){case r.VerticalAlign.MIDDLE:h=(a-Ke)/2;break;case r.VerticalAlign.BOTTOM:h=a-l-i-Le+(i/2-Ke/2);break;default:h=d+Le+(i/2-Ke/2);break}e.save(),e.translateWithPrecision(t.startX+c,t.startY+h),e.fillStyle="#565656",e.fill(Ut),e.restore()}drawWith(e,t,n){const{primaryWithCoord:a,row:i,col:o,style:s,data:d,subUnitId:l}=t,c=a.isMergedMainCell?a.mergeInfo:a,h=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,o);if(!h)return;const v=this._dataValidationModel.getValidator(h.type);if(!v)return;const u=d==null?void 0:d.fontRenderExtension,{leftOffset:I=0,rightOffset:p=0,topOffset:R=0,downOffset:w=0}=u||{};if(!h||!v||!v||v.id.indexOf(r.DataValidationType.LIST)!==0||!v.skipDefaultFontRender(h))return;const g={startX:c.startX+I,endX:c.endX-p,startY:c.startY+R,endY:c.endY-w},f=g.endX-g.startX,C=g.endY-g.startY,T=this._ensureMap(l),E=this._generateKey(i,o),y=v.getListWithColor(h),V=S.getCellValueOrigin(d),b=`${V!=null?V:""}`,H=y.find(U=>U.label===b);let{tb:$,vt:k,ht:B,pd:W}=s||{};if($=$!=null?$:r.WrapStrategy.WRAP,k=k!=null?k:r.VerticalAlign.BOTTOM,B=B!=null?B:r.DEFAULT_STYLES.ht,W=W!=null?W:r.DEFAULT_STYLES.pd,h.renderMode===r.DataValidationRenderMode.ARROW){const{l:U=r.DEFAULT_STYLES.pd.l,t:X=r.DEFAULT_STYLES.pd.t,r:z=r.DEFAULT_STYLES.pd.r,b:Z=r.DEFAULT_STYLES.pd.b}=W,Q=f-U-z-re-4,{documentSkeleton:J,documents:ie,docModel:he}=Ge(b,this._localeService,s);$===r.WrapStrategy.WRAP&&he.updateDocumentDataPageSize(Math.max(Q,1)),J.calculate(),J.getActualSize();const se=P.getDocsSkeletonPageSize(J),{height:oe,width:le}=se,{paddingTop:me,paddingLeft:pe}=kt(Q,C-X-Z,le,oe,k,B,!0);this._drawDownIcon(e,g,f,C,oe,k,W),e.save(),e.translateWithPrecision(g.startX+U,g.startY+X),e.beginPath(),e.rect(0,0,f-U-z,C-X-Z),e.clip(),e.translateWithPrecision(0,me),e.save(),e.translateWithPrecision(Ce,0),e.beginPath(),e.rect(0,0,Q,oe),e.clip(),ie.render(e),e.translateWithPrecision(pe,0),e.restore(),e.restore(),T.set(E,{left:g.endX+U+n.rowHeaderWidth-re,top:g.startY+X+n.columnHeaderHeight,width:re,height:C-X-Z})}else{e.save(),e.translateWithPrecision(g.startX,g.startY),e.beginPath(),e.rect(0,0,f,C),e.clip();const U=f-ue*2-Ce-re-4,{documentSkeleton:X,documents:z,docModel:Z}=Ge(b,this._localeService,s);$===r.WrapStrategy.WRAP&&Z.updateDocumentDataPageSize(Math.max(U,1)),X.calculate();const Q=P.getDocsSkeletonPageSize(X),{height:J,width:ie}=Q,{paddingTop:he,paddingLeft:se}=kt(U,C,ie,J,k,B);e.translateWithPrecision(ue,he);const oe=Math.max(f-ue*2,1),le=J;P.Rect.drawWith(e,{width:oe,height:le,fill:(H==null?void 0:H.color)||ye,radius:ht}),e.save(),e.translateWithPrecision(Ce,0),e.beginPath(),e.rect(0,0,U,J),e.clip(),e.translateWithPrecision(se,0),z.render(e),e.restore(),e.translateWithPrecision(U+Ce+4,(J-Ke)/2),e.fillStyle=tn,e.fill(Ut),e.restore(),T.set(E,{left:g.startX+ue+n.rowHeaderWidth,top:g.startY+he+n.columnHeaderHeight,width:oe,height:le})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:n,data:a,row:i,col:o}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=a==null?void 0:a.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:v=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,o);if(!u||u.renderMode===r.DataValidationRenderMode.TEXT)return;const I={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-v},p=I.endX-I.startX,R=S.getCellValueOrigin(a),w=`${R!=null?R:""}`;let{tb:g,pd:f}=n||{};const{t:C=r.DEFAULT_STYLES.pd.t,b:T=r.DEFAULT_STYLES.pd.b}=f!=null?f:{};if(g=g!=null?g:r.WrapStrategy.WRAP,u.renderMode===r.DataValidationRenderMode.ARROW){const E=p-re,{documentSkeleton:y,docModel:V}=Ge(w,this._localeService,n);g===r.WrapStrategy.WRAP&&V.updateDocumentDataPageSize(Math.max(E,1)),y.calculate(),y.getActualSize();const b=P.getDocsSkeletonPageSize(y),{height:H}=b;return H+C+T+Le*2}else{const E=p-ue*2-Ce-re,{documentSkeleton:y,docModel:V}=Nt(w,this._localeService,n);g===r.WrapStrategy.WRAP&&V.updateDocumentDataPageSize(Math.max(E,1)),y.calculate();const b=P.getDocsSkeletonPageSize(y),{height:H}=b;return H+Le*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:n,data:a,row:i,col:o}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=a==null?void 0:a.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:v=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,o);if(!u||u.renderMode===r.DataValidationRenderMode.TEXT)return;const I={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-v},p=I.endX-I.startX,R=S.getCellValueOrigin(a),w=`${R!=null?R:""}`;let{tb:g,pd:f}=n||{};const{l:C=r.DEFAULT_STYLES.pd.l,r:T=r.DEFAULT_STYLES.pd.r}=f!=null?f:{};g=g!=null?g:r.WrapStrategy.WRAP;let E=ue*2+re;switch(u.renderMode){case r.DataValidationRenderMode.ARROW:E=re+ue*2+T+C;break;case r.DataValidationRenderMode.CUSTOM:E=re+ue*2+Ce*2+T+C+ht/2+1;break;default:E=re+ue*2+Ce*2+T+C+ht/2+1}const y=p-E,{documentSkeleton:V,docModel:b}=Ge(w,this._localeService,n);return g===r.WrapStrategy.WRAP&&b.updateDocumentDataPageSize(Math.max(y,1)),V.calculate(),V.getActualSize(),P.getDocsSkeletonPageSize(V).width+E}isHit(e,t){const{subUnitId:n,row:a,col:i}=t,s=this._ensureMap(n).get(this._generateKey(a,i)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,a,i);if(!d||!s||d.renderMode===r.DataValidationRenderMode.TEXT)return!1;const{top:l,left:c,width:h,height:v}=s,{x:u,y:I}=e;return u>=c&&u<=c+h&&I>=l&&I<=l+v}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:a,row:i,col:o}=e,s={unitId:n,subUnitId:a,row:i,column:o};this._commandService.executeCommand(Ne.id,s)}onPointerEnter(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.DEFAULT)}};pt=en([Fe(0,r.IUniverInstanceService),Fe(1,r.Inject(r.LocaleService)),Fe(2,r.ICommandService),Fe(3,r.Inject(P.IRenderManagerService)),Fe(4,r.Inject(S.SheetDataValidationModel))],pt);class nn extends A.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",r.DataValidationType.LIST);L(this,"canvasRender",this.injector.createInstance(pt));L(this,"dropdownType",x.DataValidatorDropdownType.LIST);L(this,"optionsInput",$e.componentKey);L(this,"formulaInput",S.LIST_FORMULA_INPUT_NAME)}}class on extends A.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",r.DataValidationType.TEXT_LENGTH);L(this,"formulaInput",S.BASE_FORMULA_INPUT_NAME)}}class rn extends A.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",r.DataValidationType.WHOLE);L(this,"formulaInput",S.BASE_FORMULA_INPUT_NAME)}}var sn=Object.getOwnPropertyDescriptor,ln=(e,t,n,a)=>{for(var i=a>1?void 0:a?sn(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},mt=(e,t)=>(n,a)=>t(n,a,e);let Ae=class extends r.RxDisposable{constructor(e,t,n){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=n,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[Tt,St],[Ue,Fa],[$e.componentKey,$e],[Ye.componentKey,Ye],...na].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Ya,rn,on,$a,ja,nn,Ja,Ha].forEach(e=>{const t=this._injector.createInstance(e),n=this._dataValidatorRegistryService.getValidatorItem(t.id);n&&(n.formulaInput=t.formulaInput,n.canvasRender=t.canvasRender,n.dropdownType=t.dropdownType,n.optionsInput=t.optionsInput)})}};Ae=ln([mt(0,r.Inject(r.Injector)),mt(1,r.Inject(D.ComponentManager)),mt(2,r.Inject(x.DataValidatorRegistryService))],Ae);var dn=Object.getOwnPropertyDescriptor,cn=(e,t,n,a)=>{for(var i=a>1?void 0:a?dn(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},gt=(e,t)=>(n,a)=>t(n,a,e);const un="SHEET_DATA_VALIDATION_UI_PLUGIN";A.UniverSheetsDataValidationUIPlugin=(qe=class extends r.Plugin{constructor(t=Be,n,a,i){super(),this._config=t,this._injector=n,this._commandService=a,this._configService=i;const{menu:o,...s}=r.merge({},Be,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Mt,s)}onStarting(){[[de],[fe],[Pe],[Ee],[be],[Te],[Me],[De],[Ae]].forEach(t=>{this._injector.add(t)}),[ke,Ne,Et,at,Se,wt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Me),this._injector.get(Te),this._injector.get(De),this._injector.get(Pe),this._injector.get(P.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[je])}onRendered(){this._injector.get(Ae),this._injector.get(be)}onSteady(){this._injector.get(Ee)}},L(qe,"pluginName",un),L(qe,"type",r.UniverInstanceType.UNIVER_SHEET),qe),A.UniverSheetsDataValidationUIPlugin=cn([gt(1,r.Inject(r.Injector)),gt(2,r.ICommandService),gt(3,r.IConfigService)],A.UniverSheetsDataValidationUIPlugin);var hn=Object.getOwnPropertyDescriptor,pn=(e,t,n,a)=>{for(var i=a>1?void 0:a?hn(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},vt=(e,t)=>(n,a)=>t(n,a,e);const mn="SHEET_DATA_VALIDATION_UI_PLUGIN";A.UniverSheetsDataValidationMobileUIPlugin=(Ze=class extends r.Plugin{constructor(t=Be,n,a,i){super(),this._config=t,this._injector=n,this._commandService=a,this._configService=i;const{menu:o,...s}=r.merge({},Be,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Mt,s)}onStarting(){[[de],[fe],[Pe],[Ee],[be],[Te],[Me],[Ae]].forEach(t=>{this._injector.add(t)}),[ke,Ne,Et,at,Se,wt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Me),this._injector.get(Te),this._injector.get(P.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[je])}onRendered(){this._injector.get(Ae),this._injector.get(be)}onSteady(){this._injector.get(Ee)}},L(Ze,"pluginName",mn),L(Ze,"type",r.UniverInstanceType.UNIVER_SHEET),Ze),A.UniverSheetsDataValidationMobileUIPlugin=pn([vt(1,r.Inject(r.Injector)),vt(2,r.ICommandService),vt(3,r.IConfigService)],A.UniverSheetsDataValidationMobileUIPlugin),Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
|
1
|
+
(function(U,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):(U=typeof globalThis<"u"?globalThis:U||self,o(U.UniverSheetsDataValidationUi={},U.UniverCore,U.UniverSheetsDataValidation,U.React,U.UniverDesign,U.UniverUi,U.React,U.UniverSheetsFormulaUi,U.UniverDataValidation,U.rxjs,U.UniverEngineRender,U.UniverSheets,U.UniverSheetsNumfmt,U.UniverSheetsUi,U.UniverEngineFormula))})(this,function(U,o,m,g,V,M,T,Ke,Y,te,F,$,Ut,H,Ge){"use strict";var ur=Object.defineProperty;var hr=(U,o,m)=>o in U?ur(U,o,{enumerable:!0,configurable:!0,writable:!0,value:m}):U[o]=m;var R=(U,o,m)=>hr(U,typeof o!="symbol"?o+"":o,m);var Xe,ze;const Ft=e=>{const{isTwoFormula:t=!1,value:r,onChange:n,showError:a,validResult:i}=e,s=M.useDependency(o.LocaleService),d=a?i==null?void 0:i.formula1:"",l=a?i==null?void 0:i.formula2:"";return t?g.jsxs(g.Fragment,{children:[g.jsx(V.FormLayout,{error:d,children:g.jsx(V.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})}})}),g.jsx("div",{className:"-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400",children:s.t("dataValidation.panel.formulaAnd")}),g.jsx(V.FormLayout,{error:l,children:g.jsx(V.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})}})})]}):g.jsx(V.FormLayout,{error:d,children:g.jsx(V.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 Nt(e){const{value:t,onChange:r,showError:n,validResult:a}=e,i=M.useDependency(o.LocaleService),s=n?a==null?void 0:a.formula1:"",d=n?a==null?void 0:a.formula2:"",[l,c]=T.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return g.jsxs(g.Fragment,{children:[g.jsx(V.FormLayout,{children:g.jsx(V.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?g.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:g.jsx(V.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?g.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:d,children:g.jsx(V.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 kt(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=T.useRef(null),[c,h]=T.useState(!1);return M.useSidebarClick(u=>{var v;((v=l.current)==null?void 0:v.isClickOutSide(u))&&h(!1)}),g.jsx(Ke.FormulaEditor,{initValue:(p=n==null?void 0:n.formula1)!=null?p:"=",unitId:t,subUnitId:r,isFocus:c,onChange:u=>{const C=(u!=null?u:"").trim();C!==(n==null?void 0:n.formula1)&&(a==null||a({...n,formula1:C}))},errorText:d,onFocus:()=>h(!0),isSupportAcrossSheet:!0,ref:l})}var ne=function(){return ne=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},ne.apply(this,arguments)},jt=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=T.forwardRef(function(e,t){var r=e.icon,n=e.id,a=e.className,i=e.extend,s=jt(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(a||"").trim(),l=T.useRef("_".concat(Wt()));return pt(r,"".concat(n),{defIds:r.defIds,idSuffix:l.current},ne({ref:t,className:d},s),i)});function pt(e,t,r,n,a){return T.createElement(e.tag,ne(ne({key:t},Bt(e,r,a)),n),(Ht(e,r).children||[]).map(function(i,s){return pt(i,"".concat(t,"-").concat(e.tag,"-").concat(s),r,void 0,a)}))}function Bt(e,t,r){var n=ne({},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 Ht(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)?ne(ne({},e),{children:e.children.map(function(a){return typeof a.attrs.id=="string"&&n&&n.indexOf(a.attrs.id)>-1?ne(ne({},a),{attrs:ne(ne({},a.attrs),{id:a.attrs.id+t.idSuffix})}):a})}):e}function Wt(){return Math.random().toString(36).substring(2,8)}ge.displayName="UniverIcon";var xt={tag:"svg",attrs:{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.83062 8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767 13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279zM14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217 14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046 13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703 10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046 9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217 9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746 9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732 13.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"}}]},vt=T.forwardRef(function(e,t){return T.createElement(ge,Object.assign({},e,{id:"data-validation-single",ref:t,icon:xt}))});vt.displayName="DataValidationSingle";var $t={tag:"svg",attrs:{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.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.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.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.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"}}]},qe=T.forwardRef(function(e,t){return T.createElement(ge,Object.assign({},e,{id:"delete-single",ref:t,icon:$t}))});qe.displayName="DeleteSingle";var Yt={tag:"svg",attrs:{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=T.forwardRef(function(e,t){return T.createElement(ge,Object.assign({},e,{id:"increase-single",ref:t,icon:Yt}))});gt.displayName="IncreaseSingle";var Xt={tag:"svg",attrs:{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"}}]},ft=T.forwardRef(function(e,t){return T.createElement(ge,Object.assign({},e,{id:"more-down-single",ref:t,icon:Xt}))});ft.displayName="MoreDownSingle";var zt={tag:"svg",attrs:{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"}}]},mt=T.forwardRef(function(e,t){return T.createElement(ge,Object.assign({},e,{id:"more-up-single",ref:t,icon:zt}))});mt.displayName="MoreUpSingle";var Kt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},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 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},St=T.forwardRef(function(e,t){return T.createElement(ge,Object.assign({},e,{id:"sequence-single",ref:t,icon:Kt}))});St.displayName="SequenceSingle";const Ce="#ECECEC",Gt=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],qt=e=>{const{value:t,onChange:r,disabled:n}=e,[a,i]=T.useState(!1);return g.jsx(V.LegacySelect,{disabled:n,open:a,onDropdownVisibleChange:i,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:"univer-ml-1 univer-mr-2 univer-w-[92px]",value:t,onChange:r,labelRender:s=>g.jsx("div",{className:`
|
2
|
+
univer-box-border univer-h-4 univer-w-4 univer-rounded univer-border univer-border-gray-200
|
3
|
+
univer-text-base
|
4
|
+
`,style:{background:s.value,marginTop:5}}),dropdownRender:()=>g.jsx("div",{className:`
|
5
|
+
univer-box-border univer-flex univer-w-28 univer-flex-row univer-flex-wrap
|
6
|
+
univer-justify-between univer-p-3 univer-pl-3
|
7
|
+
`,children:Gt.map(s=>g.jsx("div",{onClick:()=>{r(s),i(!1)},className:`
|
8
|
+
univer-mb-2 univer-mr-2 univer-box-border univer-box-border univer-h-4 univer-w-4
|
9
|
+
univer-cursor-pointer univer-rounded univer-border univer-border-gray-200
|
10
|
+
univer-text-base
|
11
|
+
`,style:{background:s}},s))})})},_t=e=>{const{item:t,commonProps:r,style:n}=e,{onItemChange:a,onItemDelete:i}=r;return g.jsxs("div",{className:"univer-flex univer-items-center univer-pb-0.5",style:n,children:[t.isRef?null:g.jsx("div",{className:V.clsx("univer-cursor-move","draggableHandle"),children:g.jsx(St,{})}),g.jsx(qt,{value:t.color,onChange:s=>{a(t.id,t.label,s)}}),g.jsx(V.Input,{disabled:t.isRef,value:t.label,onChange:s=>{a(t.id,s,t.color)},inputStyle:{height:28}}),t.isRef?null:g.jsx("div",{className:`
|
12
|
+
univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base
|
13
|
+
hover:univer-bg-gray-200
|
14
|
+
`,children:g.jsx(qe,{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]=T.useState(()=>o.isFormulaString(l)?"1":"0"),[u,C]=T.useState(h==="1"?l:"="),[v,O]=T.useState(h==="1"?l:"="),b=M.useDependency(o.LocaleService),f=M.useDependency(Y.DataValidatorRegistryService),_=M.useDependency(Y.DataValidationModel),S=M.useDependency(m.DataValidationFormulaController),[w,D]=T.useState(()=>c.split(",")),y=f.getValidatorItem(o.DataValidationType.LIST),[E,P]=T.useState([]),[W,A]=T.useState(""),j=s?i==null?void 0:i.formula1:"",k=T.useMemo(()=>_.ruleChange$.pipe(te.debounceTime(16)),[]),B=M.useObservable(k),L=M.useEvent(r);T.useEffect(()=>{(async()=>{await new Promise(I=>{setTimeout(()=>I(!0),100)});const N=_.getRuleById(n,a,d),G=N==null?void 0:N.formula1;if(o.isFormulaString(G)&&y&&N){const I=await y.getListAsync(N,n,a);P(I)}})()},[_,B,y,d,a,n]),T.useEffect(()=>{o.isFormulaString(l)&&l!==v&&(C(l),O(v))},[v,l]);const[X,z]=T.useState(()=>{const N=h!=="1"?m.deserializeListOptions(l):[],G=c.split(",");return N.map((I,x)=>({label:I,color:G[x]||Ce,isRef:!1,id:o.Tools.generateRandomId(4)}))}),Z=(N,G,I)=>{const x=X.find(K=>K.id===N);x&&(x.label=G,x.color=I,z([...X]))},Q=N=>{const G=X.findIndex(I=>I.id===N);G!==-1&&(X.splice(G,1),z([...X]))},J=c.split(","),re=T.useMemo(()=>E.map((N,G)=>({label:N,color:J[G]||Ce,id:`${G}`,isRef:!0})),[J,E]),ue=(N,G,I)=>{const x=[...w];x[+N]=I,D(x),L({formula1:l,formula2:x.join(",")})},se=()=>{z([...X,{label:"",color:Ce,isRef:!1,id:o.Tools.generateRandomId(4)}])};T.useEffect(()=>{if(h==="1")return;const N=new Set,G=[];X.map(I=>({labelList:I.label.split(","),item:I})).forEach(({item:I,labelList:x})=>{x.forEach(K=>{N.has(K)||(N.add(K),G.push({label:K,color:I.color}))})}),L({formula1:m.serializeListOptions(G.map(I=>I.label)),formula2:G.map(I=>I.color===Ce?"":I.color).join(",")})},[X,L,h,v,w]);const ae=M.useEvent(async N=>{if(!o.isFormulaString(N)){L==null||L({formula1:"",formula2:c});return}S.getFormulaRefCheck(N)?(L==null||L({formula1:o.isFormulaString(N)?N:"",formula2:c}),A("")):(L==null||L({formula1:"",formula2:c}),C("="),A(b.t("dataValidation.validFail.formulaError")))}),le=T.useRef(null),[pe,he]=T.useState(!1);return M.useSidebarClick(N=>{var I;((I=le.current)==null?void 0:I.isClickOutSide(N))&&he(!1)}),g.jsxs(g.Fragment,{children:[g.jsx(V.FormLayout,{label:b.t("dataValidation.list.options"),children:g.jsxs(V.RadioGroup,{value:h,onChange:N=>{p(N),C(v),N==="1"&&L({formula1:v==="="?"":v,formula2:w.join(",")})},children:[g.jsx(V.Radio,{value:"0",children:b.t("dataValidation.list.customOptions")}),g.jsx(V.Radio,{value:"1",children:b.t("dataValidation.list.refOptions")})]})}),h==="1"?g.jsxs(g.Fragment,{children:[g.jsx(Ke.FormulaEditor,{initValue:u,unitId:n,subUnitId:a,isFocus:pe,onChange:(N="")=>{const G=(N!=null?N:"").trim();O(G),ae(G)},errorText:j||W||void 0,onFocus:()=>he(!0),isSupportAcrossSheet:!0,ref:le}),re.length>0&&g.jsx("div",{style:{marginTop:"12px"},children:re.map(N=>g.jsx(_t,{item:N,commonProps:{onItemChange:ue},style:{marginBottom:12}},N.id))})]}):g.jsx(V.FormLayout,{error:j,children:g.jsxs("div",{style:{marginTop:"-12px"},children:[g.jsx(V.DraggableList,{list:X,onListChange:z,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:N=>g.jsx(_t,{item:N,commonProps:{onItemChange:Z,onItemDelete:Q}},N.id),idKey:"id"}),g.jsxs("a",{className:`
|
15
|
+
univer-flex univer-w-fit univer-cursor-pointer univer-flex-row univer-items-center
|
16
|
+
univer-rounded univer-p-1 univer-px-2 univer-text-sm univer-text-primary
|
17
|
+
hover:univer-bg-primary-600/5
|
18
|
+
`,onClick:se,children:[g.jsx(gt,{className:"univer-mr-1"}),b.t("dataValidation.list.add")]})]})})]})}const Jt=[[m.CUSTOM_FORMULA_INPUT_NAME,kt],[m.BASE_FORMULA_INPUT_NAME,Ft],[m.LIST_FORMULA_INPUT_NAME,Zt],[m.CHECKBOX_FORMULA_INPUT_NAME,Nt]];var Qt=Object.getOwnPropertyDescriptor,en=(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},tn=(e,t)=>(r,n)=>t(r,n,e);U.BaseSheetDataValidatorView=class{constructor(t){R(this,"canvasRender",null);R(this,"dropdownType");R(this,"optionsInput");R(this,"formulaInput",m.LIST_FORMULA_INPUT_NAME);this.injector=t}},U.BaseSheetDataValidatorView=en([tn(0,o.Inject(o.Injector))],U.BaseSheetDataValidatorView);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},It=(e,t)=>(r,n)=>t(r,n,e);let de=class extends o.Disposable{constructor(t,r){super();R(this,"_open$",new te.BehaviorSubject(!1));R(this,"open$",this._open$.pipe(te.distinctUntilChanged()));R(this,"_activeRule");R(this,"_activeRule$",new te.BehaviorSubject(void 0));R(this,"activeRule$",this._activeRule$.asObservable());R(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=r,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(te.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===Ue&&(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)}};de=rn([It(0,o.IUniverInstanceService),It(1,M.ISidebarService)],de);const Ze="sheets-data-validation-ui.config",Le={};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},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:T.createElement(V.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:T.createElement(V.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};we=on([ye(0,o.Inject($.SheetInterceptorService)),ye(1,o.Inject(m.SheetDataValidationModel)),ye(2,o.Inject(Y.DataValidatorRegistryService)),ye(3,M.IDialogService),ye(4,o.Inject(o.LocaleService)),ye(5,o.Inject(m.SheetsDataValidationValidatorService))],we);var sn=Object.getOwnPropertyDescriptor,ln=(e,t,r,n)=>{for(var a=n>1?void 0:n?sn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ie=(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 dn(e,t){const r=Ut.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();R(this,"_activeDropdown");R(this,"_activeDropdown$",new te.Subject);R(this,"_currentPopup",null);R(this,"activeDropdown$",this._activeDropdown$.asObservable());R(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 O,b,f,_;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,w)=>{var k,B,L;if(!S)return!0;const D=S,y=l.getCell(n,a),E=D.format(w==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),P=(k=o.numfmt.parseDate(E))==null?void 0:k.v,W=w==="time"?P%1:P,A=d.getStyles().getStyleByCell(y),j=(L=(B=A==null?void 0:A.n)==null?void 0:B.pattern)!=null?L:"";return c.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:W,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(H.SetCellEditVisibleOperation.id,{visible:!1,eventType:F.DeviceInputEventType.Keyboard,unitId:i,keycode:M.KeyCode.ESC}),await this._commandService.executeCommand($.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:W,t:2,p:null,f:null,si:null,s:{n:{pattern:dn(w,j)}}}}),!0):(this._injector.has(we)&&this._injector.get(we).showReject(h.getRuleFinalError(c,{row:n,col:a,unitId:i,subUnitId:s})),!1)};let C;switch(h.dropdownType){case Y.DataValidatorDropdownType.DATE:{const S=m.getCellValueOrigin(l.getCellRaw(n,a)),w=Je(S),D=!!((O=c.bizInfo)!=null&&O.showTime);C={location:r,type:"datepicker",props:{showTime:D,onChange:y=>u(y,D?"datetime":"date"),defaultValue:w,patternType:"date"}};break}case Y.DataValidatorDropdownType.TIME:{const S=m.getCellValueOrigin(l.getCellRaw(n,a)),w=Je(S);C={location:r,type:"datepicker",props:{onChange:D=>u(D,"time"),defaultValue:w,patternType:"time"}};break}case Y.DataValidatorDropdownType.DATETIME:{const S=m.getCellValueOrigin(l.getCellRaw(n,a)),w=Je(S);C={location:r,type:"datepicker",props:{onChange:D=>u(D,"datetime"),defaultValue:w,patternType:"datetime"}};break}case Y.DataValidatorDropdownType.LIST:case Y.DataValidatorDropdownType.MULTIPLE_LIST:{const S=h.dropdownType===Y.DataValidatorDropdownType.MULTIPLE_LIST,w=async A=>{const j=m.serializeListOptions(A),k={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:j,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(H.SetCellEditVisibleOperation.id,{visible:!1,eventType:F.DeviceInputEventType.Keyboard,unitId:i,keycode:M.KeyCode.ESC}),this._commandService.executeCommand($.SetRangeValuesCommand.id,k),!S},D=(c==null?void 0:c.renderMode)===o.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,y=h.getListWithColor(c,i,s),E=m.getDataValidationCellValue(l.getCellRaw(n,a)),P=()=>{this._commandService.executeCommand(me.id,{ruleId:c.uid}),p==null||p.dispose()},W=y.map(A=>({label:A.label,value:A.label,color:D||A.color?A.color:"transparent"}));C={location:r,type:"list",props:{onChange:A=>w(A),options:W,onEdit:P,defaultValue:E,multiple:S,showEdit:(f=(b=this._configService.getConfig(Ze))==null?void 0:b.showEditOnDropdown)!=null?f:!0}};break}case Y.DataValidatorDropdownType.CASCADE:{C={type:"cascader",props:{onChange:w=>{const D={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:w.join("/"),p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(H.SetCellEditVisibleOperation.id,{visible:!1,eventType:F.DeviceInputEventType.Keyboard,unitId:i,keycode:M.KeyCode.ESC}),this._commandService.syncExecuteCommand($.SetRangeValuesCommand.id,D),!0},defaultValue:m.getDataValidationCellValue(l.getCellRaw(n,a)).split("/"),options:JSON.parse((_=c.formula1)!=null?_:"[]")},location:r};break}case Y.DataValidatorDropdownType.COLOR:{C={type:"color",props:{onChange:w=>{const D={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:w,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(H.SetCellEditVisibleOperation.id,{visible:!1,eventType:F.DeviceInputEventType.Keyboard,unitId:i,keycode:M.KeyCode.ESC}),this._commandService.syncExecuteCommand($.SetRangeValuesCommand.id,D),!0},defaultValue:m.getDataValidationCellValue(l.getCellRaw(n,a))},location:r};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(p=this._cellDropdownManagerService.showDropdown(C),!p)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const v=new o.DisposableCollection;v.add(p),v.add({dispose:()=>{var S,w;(w=(S=this._activeDropdown)==null?void 0:S.onHide)==null||w.call(S)}}),this._currentPopup=v}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=ln([ie(0,o.IUniverInstanceService),ie(1,o.Inject(Y.DataValidatorRegistryService)),ie(2,M.IZenZoneService),ie(3,o.Inject(m.SheetDataValidationModel)),ie(4,o.Inject($.SheetsSelectionsService)),ie(5,o.Inject(H.ISheetCellDropdownManagerService)),ie(6,o.Inject(m.SheetDataValidationModel)),ie(7,o.ICommandService),ie(8,H.IEditorBridgeService),ie(9,o.Inject(o.Injector)),ie(10,o.IConfigService)],fe);const Ue="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(de),i=e.get(Y.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(M.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:Ue,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Ue},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(de).close(),!0}},Ct={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),r=e.get(de);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}},yt={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(fe).hideDropdown(),!0):!1}},Ne={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=m.createDefaultNewRule(e),s=e.get(o.ICommandService),d=n.getUnitId(),l=a.getSheetId(),c={rule:i,unitId:d,subUnitId:l};return s.syncExecuteCommand(m.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(me.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};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},De=(e,t)=>(r,n)=>t(r,n,e);const Se="SHEET_DATA_VALIDATION_ALERT";let Pe=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(te.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:H.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)}))}};Pe=un([De(0,o.Inject(H.HoverManagerService)),De(1,o.Inject(H.CellAlertManagerService)),De(2,o.IUniverInstanceService),De(3,o.Inject(o.LocaleService)),De(4,M.IZenZoneService),De(5,o.Inject(m.SheetDataValidationModel))],Pe);var hn=Object.getOwnPropertyDescriptor,pn=(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},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=H.virtualizeDiscreteRanges([i,s]),[p,u]=h.ranges,{mapFunc:C}=h,v={row:p.startRow,col:p.startColumn},O=H.getAutoFillRepeatRange(p,u),b=new o.ObjectMatrix,f=new Set;O.forEach(y=>{const E=y.repeatStartCell,P=y.relativeRange,W={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},A={startRow:E.row,startColumn:E.col,endColumn:E.col,endRow:E.row};o.Range.foreach(P,(j,k)=>{const B=o.Rectangle.getPositionRange({startRow:j,startColumn:k,endColumn:k,endRow:j},W),{row:L,col:X}=C(B.startRow,B.startColumn),z=this._sheetDataValidationModel.getRuleIdByLocation(d,l,L,X)||"",Z=o.Rectangle.getPositionRange({startRow:j,startColumn:k,endColumn:k,endRow:j},A),{row:Q,col:J}=C(Z.startRow,Z.startColumn);b.setValue(Q,J,z),f.add(z)})});const _=Array.from(f).map(y=>({id:y,ranges:o.queryObjectMatrix(b,E=>E===y)}));c.addRangeRules(_);const S=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:w,undoMutations:D}=m.getDataValidationDiffMutations(d,l,S,this._injector,"patched",a===H.APPLY_TYPE.ONLY_FORMAT);return{undos:D,redos:w}},r={id:m.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(H.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,a,i)=>i===H.APPLY_TYPE.COPY||i===H.APPLY_TYPE.ONLY_FORMAT||i===H.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(r))}};Ee=pn([et(0,H.IAutoFillService),et(1,o.Inject(m.SheetDataValidationModel)),et(2,o.Inject(o.Injector))],Ee);var vn=Object.getOwnPropertyDescriptor,gn=(e,t,r,n)=>{for(var a=n>1?void 0:n?vn(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();R(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=r,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:m.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,r,n)=>this._collect(t,r,n),onPasteCells:(t,r,n,a)=>{const{copyType:i=H.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===H.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!r.copyRange)return{redos:[],undos:[]};if([H.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,H.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,H.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,H.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}=H.virtualizeDiscreteRanges([r.copyRange,t]),u=H.getRepeatRange(c,h,!0),C=new Map;u.forEach(({startRange:f})=>{var _;(_=this._copyInfo)==null||_.matrix.forValue((S,w,D)=>{const y=o.Rectangle.getPositionRange({startRow:S,endRow:S,startColumn:w,endColumn:w},f),E=`${i}-${D}`,P=this._sheetDataValidationModel.getRuleById(a,i,D);!this._sheetDataValidationModel.getRuleById(r.unitId,r.subUnitId,E)&&P&&C.set(E,{...P,uid:E});const{row:W,col:A}=p(y.startRow,y.startColumn);l.add(E),d.setValue(W,A,E)})});const v=Array.from(l).map(f=>({id:f,ranges:o.queryObjectMatrix(d,_=>_===f)}));s.addRangeRules(v);const{redoMutations:O,undoMutations:b}=m.getDataValidationDiffMutations(r.unitId,r.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(r.unitId,r.subUnitId),C.values()),this._injector,"patched",!1);return{redos:O,undos:b}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(a,i).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:p}=H.virtualizeDiscreteRanges([r.copyRange,t]);H.getRepeatRange(c,h,!0).forEach(({startRange:b})=>{var f;(f=this._copyInfo)==null||f.matrix.forValue((_,S,w)=>{const D=o.Rectangle.getPositionRange({startRow:_,endRow:_,startColumn:S,endColumn:S},b),{row:y,col:E}=p(D.startRow,D.startColumn);d.setValue(y,E,w),l.add(w)})});const C=Array.from(l).map(b=>({id:b,ranges:o.queryObjectMatrix(d,f=>f===b)}));s.addRangeRules(C);const{redoMutations:v,undoMutations:O}=m.getDataValidationDiffMutations(a,i,s.diff(this._sheetDataValidationModel.getRules(a,i)),this._injector,"patched",!1);return{redos:v,undos:O}}}};Me=gn([tt(0,H.ISheetClipboardService),tt(1,o.Inject(m.SheetDataValidationModel)),tt(2,o.Inject(o.Injector))],Me);var fn=Object.getOwnPropertyDescriptor,mn=(e,t,r,n)=>{for(var a=n>1?void 0:n?fn(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===m.AddSheetDataValidationCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[$.WorkbookEditablePermission],rangeTypes:[$.RangeProtectionPermissionEditPoint],worksheetTypes:[$.WorksheetEditPermission,$.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===m.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=mn([nt(0,o.Inject(o.LocaleService)),nt(1,o.ICommandService),nt(2,o.Inject($.SheetPermissionCheckController))],be);const wt="data-validation-single",Dt="sheet.menu.data-validation";function Sn(e){return{id:Dt,type:M.MenuItemType.SUBITEMS,icon:wt,tooltip:"dataValidation.title",hidden$:M.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:H.getCurrentRangeDisable$(e,{workbookTypes:[$.WorkbookEditablePermission],worksheetTypes:[$.WorksheetSetCellStylePermission,$.WorksheetEditPermission],rangeTypes:[$.RangeProtectionPermissionEditPoint]})}}function _n(e){return{id:me.id,title:"dataValidation.panel.title",type:M.MenuItemType.BUTTON}}function In(e){return{id:Ne.id,title:"dataValidation.panel.add",type:M.MenuItemType.BUTTON}}const Cn={[M.RibbonStartGroup.FORMULAS_INSERT]:{[Dt]:{order:9,menuItemFactory:Sn,[me.id]:{order:0,menuItemFactory:_n},[Ne.id]:{order:1,menuItemFactory:In}}}};var yn=Object.getOwnPropertyDescriptor,Et=(e,t,r,n)=>{for(var a=n>1?void 0:n?yn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},q=(e,t)=>(r,n)=>t(r,n,e);const Mt={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(Cn)}_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 f,_,S,w,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=(f=this._dataValidationCacheService.getValue(i,s,n,a))!=null?f:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),C=t.rawData;let v;const O={get value(){var y;return v!==void 0||(v=(y=m.getCellValueOrigin(C))!=null?y:null),v}},b={get value(){var y;return`${(y=O.value)!=null?y:""}`}};return r({...e,markers:{...e==null?void 0:e.markers,...p===o.DataValidationStatus.INVALID?Mt:null},customRender:[...(_=e==null?void 0:e.customRender)!=null?_:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((S=e==null?void 0:e.fontRenderExtension)==null?void 0:S.isSkip)||((w=u==null?void 0:u.skipDefaultFontRender)==null?void 0:w.call(u,h,O.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,b.value,{get style(){const y=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?y.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,a)},interceptorAutoHeight:()=>{var W,A,j,k,B,L;const y=(A=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(H.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:A.skeleton;if(!y)return;const E=y.worksheet.getMergedCell(n,a),P={data:e,style:y.getStyles().getStyleByCell(e),primaryWithCoord:y.getCellWithCoordByIndex((j=E==null?void 0:E.startRow)!=null?j:n,(k=E==null?void 0:E.startColumn)!=null?k:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(L=(B=u==null?void 0:u.canvasRender)==null?void 0:B.calcCellAutoHeight)==null?void 0:L.call(B,P)},interceptorAutoWidth:()=>{var W,A,j,k,B,L;const y=(A=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(H.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:A.skeleton;if(!y)return;const E=y.worksheet.getMergedCell(n,a),P={data:e,style:y.getStyles().getStyleByCell(e),primaryWithCoord:y.getCellWithCoordByIndex((j=E==null?void 0:E.startRow)!=null?j:n,(k=E==null?void 0:E.startColumn)!=null?k:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(L=(B=u==null?void 0:u.canvasRender)==null?void 0:B.calcCellAutoWidth)==null?void 0:L.call(B,P)},coverable:((D=e==null?void 0:e.coverable)!=null?D:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(te.filter(e=>e.source==="command"),te.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=Et([q(0,o.ICommandService),q(1,M.IMenuManagerService),q(2,F.IRenderManagerService),q(3,o.IUniverInstanceService),q(4,o.Inject(H.AutoHeightController)),q(5,o.Inject(fe)),q(6,o.Inject(m.SheetDataValidationModel)),q(7,o.Inject(Y.DataValidatorRegistryService)),q(8,o.Inject($.SheetInterceptorService)),q(9,o.Inject(m.DataValidationCacheService)),q(10,o.Optional(H.IEditorBridgeService))],Te);let bt=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 b,f,_,S,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=(b=this._dataValidationCacheService.getValue(i,s,n,a))!=null?b:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),C=l.getCellRaw(n,a),v=m.getCellValueOrigin(C),O=`${v!=null?v:""}`;return r({...e,markers:{...e==null?void 0:e.markers,...p===o.DataValidationStatus.INVALID?Mt:null},customRender:[...(f=e==null?void 0:e.customRender)!=null?f:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((_=e==null?void 0:e.fontRenderExtension)==null?void 0:_.isSkip)||((S=u==null?void 0:u.skipDefaultFontRender)==null?void 0:S.call(u,h,v,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,O,{get style(){const D=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?D.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,a)},interceptorAutoHeight:()=>{var P,W,A,j,k,B;const D=(W=(P=this._renderManagerService.getRenderById(i))==null?void 0:P.with(H.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:W.skeleton;if(!D)return;const y=D.worksheet.getMergedCell(n,a),E={data:e,style:D.getStyles().getStyleByCell(e),primaryWithCoord:D.getCellWithCoordByIndex((A=y==null?void 0:y.startRow)!=null?A:n,(j=y==null?void 0:y.startColumn)!=null?j:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(B=(k=u==null?void 0:u.canvasRender)==null?void 0:k.calcCellAutoHeight)==null?void 0:B.call(k,E)},coverable:((w=e==null?void 0:e.coverable)!=null?w:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(te.filter(e=>e.source==="command"),te.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(r=>{var n;(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)}})}};bt=Et([q(0,o.ICommandService),q(1,F.IRenderManagerService),q(2,o.Inject(H.AutoHeightController)),q(3,o.Inject(Y.DataValidatorRegistryService)),q(4,o.Inject($.SheetInterceptorService)),q(5,o.Inject(m.SheetDataValidationModel)),q(6,o.Inject(m.DataValidationCacheService))],bt);var wn=Object.getOwnPropertyDescriptor,Dn=(e,t,r,n)=>{for(var a=n>1?void 0:n?wn(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 ke=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))}};ke=Dn([Tt(1,o.Inject(m.SheetDataValidationModel)),Tt(2,o.Inject(H.SheetSkeletonManagerService))],ke);function En(e){var c;const t=M.useDependency(o.LocaleService),r=M.useDependency(M.ComponentManager),{value:n,onChange:a,extraComponent:i}=e,[s,d]=T.useState(!1),l=i?r.get(i):null;return g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:`
|
19
|
+
univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-black
|
20
|
+
`,onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?g.jsx(mt,{className:"univer-ml-1 univer-text-[8px]"}):g.jsx(ft,{className:"univer-ml-1 univer-text-[8px]"})]}),s&&g.jsxs(g.Fragment,{children:[l?g.jsx(l,{value:n,onChange:a}):null,g.jsx(V.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:g.jsxs(V.RadioGroup,{value:`${(c=n.errorStyle)!=null?c:o.DataValidationErrorStyle.WARNING}`,onChange:h=>a({...n,errorStyle:+h}),children:[g.jsx(V.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),g.jsx(V.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),g.jsx(V.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:g.jsx(V.Checkbox,{checked:n.showErrorMessage,onChange:()=>a({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?g.jsx(V.FormLayout,{children:g.jsx(V.Input,{value:n.error,onChange:h=>a({...n,error:h})})}):null]})]})}const Mn=e=>o.debounce(async(t,r,n,a)=>{const i=await e.executeCommand(t,r,n);a==null||a(i)},1e3);function bn(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 Tn(){var N,G;const[e,t]=T.useState(0),r=M.useDependency(de),n=M.useObservable(r.activeRule$,r.activeRule),{unitId:a,subUnitId:i,rule:s}=n||{},d=s.uid,l=M.useDependency(Y.DataValidatorRegistryService),c=M.useDependency(o.IUniverInstanceService),h=M.useDependency(M.ComponentManager),p=M.useDependency(o.ICommandService),u=M.useDependency(Y.DataValidationModel),C=M.useDependency(o.LocaleService),[v,O]=T.useState(s),b=l.getValidatorItem(v.type),[f,_]=T.useState(!1),S=l.getValidatorsByScope(Y.DataValidatorRegistryScope.SHEET),[w,D]=T.useState(()=>v.ranges.map(I=>({unitId:"",sheetId:"",range:I}))),y=T.useMemo(()=>Mn(p),[p]),[E,P]=T.useState(!1),[W,A]=T.useState(!1),j=T.useRef(null),k=M.useDependency($.SheetsSelectionsService);if(T.useEffect(()=>()=>{const I=k.getCurrentLastSelection();I&&k.setSelections([I])},[k]),T.useEffect(()=>{p.onCommandExecuted(I=>{(I.id===o.UndoCommand.id||I.id===o.RedoCommand.id)&&setTimeout(()=>{const x=u.getRuleById(a,i,d);t(K=>K+1),x&&(O(x),D(x.ranges.map(K=>({unitId:"",sheetId:"",range:K}))))},20)})},[p,u,d,i,a]),!b)return null;const B=b.operators,L=b.operatorNames,X=v.operator?Y.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,z=()=>{var I,x,K;(x=(I=j.current)==null?void 0:I.editor)!=null&&x.isFocus()&&Z((K=j.current)==null?void 0:K.getValue()),!(!v.ranges.length||E)&&(b.validatorFormula(v,a,i).success?r.setActiveRule(null):_(!0))},Z=M.useEvent(I=>{const x=I.split(",").filter(Boolean).map(Ge.deserializeRangeWithSheet).map(ee=>{const Lt=ee.sheetName;if(Lt){const cr=bn(c,ee.unitId,Lt);return{...ee,sheetId:cr}}return{...ee,sheetId:""}});if(o.isUnitRangesEqual(x,w))return;D(x);const K=x.filter(ee=>(!ee.unitId||ee.unitId===a)&&(!ee.sheetId||ee.sheetId===i)).map(ee=>ee.range);if(O({...v,ranges:K}),K.length===0)return;const ve={unitId:a,subUnitId:i,ruleId:d,ranges:K};y(m.UpdateSheetDataValidationRangeCommand.id,ve)}),Q=I=>{if(o.shallowEqual(I,Y.getRuleSetting(v)))return;O({...v,...I});const x={unitId:a,subUnitId:i,ruleId:d,setting:I};y(m.UpdateSheetDataValidationSettingCommand.id,x,void 0)},J=async()=>{await p.executeCommand(m.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:a,subUnitId:i}),r.setActiveRule(null)},re={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},ue=I=>{const x=l.getValidatorItem(I);if(!x)return;const K=x.operators,ve=u.getRuleById(a,i,d),ee=I===(ve==null?void 0:ve.type)||I.includes("list")&&(ve!=null&&ve.type.includes("list"))?{...ve,type:I}:{...v,type:I,operator:K[0],formula1:void 0,formula2:void 0};O(ee),p.executeCommand(m.UpdateSheetDataValidationSettingCommand.id,{unitId:a,subUnitId:i,ruleId:v.uid,setting:Y.getRuleSetting(ee)})},se=h.get(b.formulaInput),ae=T.useMemo(()=>w.map(I=>Ge.serializeRange(I.range)).join(","),[]),le=Y.getRuleOptions(v),pe=I=>{o.shallowEqual(I,Y.getRuleOptions(v))||(O({...v,...I}),y(m.UpdateSheetDataValidationOptionsCommand.id,{unitId:a,subUnitId:i,ruleId:d,options:I}))},he=B.length&&!v.operator;return g.jsxs("div",{className:"univer-py-4",children:[g.jsx(V.FormLayout,{label:C.t("dataValidation.panel.range"),error:!v.ranges.length||E?C.t("dataValidation.panel.rangeError"):"",children:g.jsx(Ke.RangeSelector,{selectorRef:j,unitId:a,subUnitId:i,initialValue:ae,onChange:(I,x)=>{var K;!W&&((K=j.current)!=null&&K.verify())&&Z(x)},onFocusChange:(I,x)=>{var K;A(I),!I&&x&&((K=j.current)!=null&&K.verify())&&Z(x)},onVerify:I=>P(!I)})}),g.jsx(V.FormLayout,{label:C.t("dataValidation.panel.type"),children:g.jsx(V.Select,{className:"univer-w-full",value:v.type,options:(N=S==null?void 0:S.sort((I,x)=>I.order-x.order))==null?void 0:N.map(I=>({label:C.t(I.title),value:I.id})),onChange:ue})}),B!=null&&B.length?g.jsx(V.FormLayout,{label:C.t("dataValidation.panel.operator"),children:g.jsx(V.Select,{className:"univer-w-full",value:`${v.operator}`,options:[{value:"",label:C.t("dataValidation.operators.legal")},...B.map((I,x)=>({value:`${I}`,label:L[x]}))],onChange:I=>{Q({...re,operator:I})}})}):null,se&&!he?g.jsx(V.FormLayout,{children:g.jsx(se,{isTwoFormula:X,value:{formula1:v.formula1,formula2:v.formula2},onChange:I=>{Q({...re,...I})},showError:f,validResult:b.validatorFormula(v,a,i),unitId:a,subUnitId:i,ruleId:d},e+v.type)}):null,g.jsx(V.FormLayout,{children:g.jsx(V.Checkbox,{checked:(G=v.allowBlank)!=null?G:!0,onChange:()=>{var I;return Q({...re,allowBlank:!((I=v.allowBlank)==null||I)})},children:C.t("dataValidation.panel.allowBlank")})}),g.jsx(En,{value:le,onChange:pe,extraComponent:b.optionsInput}),g.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[g.jsx(V.Button,{className:"univer-ml-3",onClick:J,children:C.t("dataValidation.panel.removeRule")}),g.jsx(V.Button,{className:"univer-ml-3",variant:"primary",onClick:z,children:C.t("dataValidation.panel.done")})]})]})}const Vn=e=>{const{rule:t,onClick:r,unitId:n,subUnitId:a,disable:i}=e,s=M.useDependency(Y.DataValidatorRegistryService),d=M.useDependency(o.ICommandService),l=M.useDependency(H.IMarkSelectionService),c=s.getValidatorItem(t.type),h=T.useRef(void 0),[p,u]=T.useState(!1),C=M.useDependency(o.ThemeService),v=M.useObservable(C.currentTheme$),O=T.useMemo(()=>{var S;const f=(S=v==null?void 0:v.loopColor2)!=null?S:"#49B811",_=new o.ColorKit(f).toRgb();return{fill:`rgba(${_.r}, ${_.g}, ${_.b}, 0.1)`,stroke:f}},[v]),b=f=>{d.executeCommand(m.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:a}),f.stopPropagation()};return T.useEffect(()=>()=>{var f;h.current&&((f=h.current)==null||f.forEach(_=>{_&&l.removeShape(_)}))},[l]),g.jsxs("div",{className:V.clsx(`
|
21
|
+
univer-rounded-md univer-bg-secondary univer-relative univer--ml-2 univer--mr-2 univer-box-border
|
22
|
+
univer-flex univer-w-[287px] univer-cursor-pointer univer-flex-col univer-justify-between
|
23
|
+
univer-overflow-hidden univer-rounded-lg univer-p-2 univer-pr-9
|
24
|
+
`,{"hover:univer-bg-gray-50":!i,"univer-opacity-50":i}),onClick:r,onMouseEnter:()=>{i||(u(!0),h.current=t.ranges.map(f=>l.addShape({range:f,style:O,primary:null})))},onMouseLeave:()=>{var f;u(!1),(f=h.current)==null||f.forEach(_=>{_&&l.removeShape(_)}),h.current=void 0},children:[g.jsx("div",{className:`
|
25
|
+
univer-overflow-hidden univer-text-ellipsis univer-text-sm univer-font-medium univer-leading-[22px]
|
26
|
+
univer-text-black
|
27
|
+
`,children:c==null?void 0:c.generateRuleName(t)}),g.jsx("div",{className:`
|
28
|
+
univer-text-secondary univer-overflow-hidden univer-text-ellipsis univer-text-xs univer-leading-[18px]
|
29
|
+
`,children:t.ranges.map(f=>Ge.serializeRange(f)).join(",")}),p?g.jsx("div",{className:`
|
30
|
+
univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-h-5 univer-w-5
|
31
|
+
univer-items-center univer-justify-center univer-rounded
|
32
|
+
hover:univer-bg-gray-200
|
33
|
+
`,onClick:b,children:g.jsx(qe,{})}):null]})};function On(e){const t=M.useDependency(m.SheetDataValidationModel),r=M.useDependency(o.IUniverInstanceService),n=M.useDependency(o.ICommandService),a=M.useDependency(o.Injector),i=M.useDependency(de),s=M.useDependency(o.LocaleService),[d,l]=T.useState([]),{workbook:c}=e,h=M.useObservable(c.activeSheet$,void 0,!0),p=c.getUnitId(),u=h==null?void 0:h.getSheetId();T.useEffect(()=>{l(t.getRules(p,u));const _=t.ruleChange$.subscribe(S=>{S.unitId===p&&S.subUnitId===u&&l(t.getRules(p,u))});return()=>{_.unsubscribe()}},[p,u,t]);const C=async()=>{const _=m.createDefaultNewRule(a),S={unitId:p,subUnitId:u,rule:_};await n.executeCommand(m.AddSheetDataValidationCommand.id,S),i.setActiveRule({unitId:p,subUnitId:u,rule:_})},v=()=>{n.executeCommand(m.RemoveSheetAllDataValidationCommand.id,{unitId:p,subUnitId:u})},b=(_=>{const S=r.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),w=S.getActiveSheet(),D=S.getUnitId(),y=w.getSheetId();return _.map(P=>$.checkRangesEditablePermission(a,D,y,P.ranges)?{...P}:{...P,disable:!0})})(d),f=b==null?void 0:b.some(_=>_.disable);return g.jsxs("div",{className:"univer-pb-4",children:[b==null?void 0:b.map(_=>{var S;return g.jsx(Vn,{unitId:p,subUnitId:u,onClick:()=>{_.disable||i.setActiveRule({unitId:p,subUnitId:u,rule:_})},rule:_,disable:(S=_.disable)!=null?S:!1},_.uid)}),g.jsxs("div",{className:"univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[d.length&&!f?g.jsx(V.Button,{onClick:v,children:s.t("dataValidation.panel.removeAll")}):null,g.jsx(V.Button,{variant:"primary",onClick:C,children:s.t("dataValidation.panel.add")})]})]})}const Rn=()=>{const e=M.useDependency(de),t=M.useObservable(e.activeRule$,e.activeRule),r=M.useDependency(o.IUniverInstanceService),n=M.useObservable(()=>r.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),a=M.useObservable(()=>{var i;return(i=n==null?void 0:n.activeSheet$)!=null?i:te.of(null)},void 0,void 0,[]);return!n||!a?null:t&&t.subUnitId===a.getSheetId()?g.jsx(Tn,{},t.rule.uid):g.jsx(On,{workbook:n})},Pn="LIST_RENDER_MODE_OPTION_INPUT";function je(e){var a;const{value:t,onChange:r}=e,n=M.useDependency(o.LocaleService);return g.jsx(V.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:g.jsxs(V.RadioGroup,{value:`${(a=t.renderMode)!=null?a:o.DataValidationRenderMode.CUSTOM}`,onChange:i=>r({...t,renderMode:+i}),children:[g.jsx(V.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),g.jsx(V.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),g.jsx(V.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}je.componentKey=Pn;const An="DATE_SHOW_TIME_OPTION";function Be(e){var a;const{value:t,onChange:r}=e,n=M.useDependency(o.LocaleService);return g.jsx(V.FormLayout,{children:g.jsx(V.Checkbox,{checked:(a=t.bizInfo)==null?void 0:a.showTime,onChange:i=>{r({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:n.t("dataValidation.showTime.label")})})}Be.componentKey=An;var Ln=Object.getOwnPropertyDescriptor,Un=(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},Ve=(e,t)=>(r,n)=>t(r,n,e);const He=6;let rt=class{constructor(e,t,r,n,a,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=r,this._themeService=n,this._renderManagerService=a,this._dataValidationModel=i}_calc(e,t){var c,h,p;const{vt:r,ht:n}=t||{},a=e.endX-e.startX-He*2,i=e.endY-e.startY,s=((c=t==null?void 0:t.fs)!=null?c:10)*1.6;let d=0,l=0;switch(r){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(i-s);break;default:l=0+(i-s)/2;break}switch(n){case o.HorizontalAlign.LEFT:d=He;break;case o.HorizontalAlign.RIGHT:d=He+(a-s);break;default:d=He+(a-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((p=t==null?void 0:t.fs)!=null?p:10)*1.6}}calcCellAutoHeight(e){var r;const{style:t}=e;return((r=t==null?void 0:t.fs)!=null?r:10)*1.6}calcCellAutoWidth(e){var r;const{style:t}=e;return((r=t==null?void 0:t.fs)!=null?r:10)*1.6}async _parseFormula(e,t,r){var c,h,p,u,C,v,O,b,f;const{formula1:n=m.CHECKBOX_FORMULA_1,formula2:a=m.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,r,e.uid),s=m.getFormulaResult((p=(h=(c=i==null?void 0:i[0])==null?void 0:c.result)==null?void 0:h[0])==null?void 0:p[0]),d=m.getFormulaResult((v=(C=(u=i==null?void 0:i[1])==null?void 0:u.result)==null?void 0:C[0])==null?void 0:v[0]),l=m.isLegalFormulaResult(String(s))&&m.isLegalFormulaResult(String(d));return{formula1:o.isFormulaString(n)?m.getFormulaResult((f=(b=(O=i==null?void 0:i[0])==null?void 0:O.result)==null?void 0:b[0])==null?void 0:f[0]):n,formula2:o.isFormulaString(a)?d:a,isFormulaValid:l}}drawWith(e,t){var k,B,L,X;const{style:r,primaryWithCoord:n,unitId:a,subUnitId:i,worksheet:s,row:d,col:l}=t,c=n.isMergedMainCell?n.mergeInfo:n,h=m.getCellValueOrigin(s.getCellRaw(d,l)),p=this._dataValidationModel.getRuleByLocation(a,i,d,l);if(!p)return;const u=this._dataValidationModel.getValidator(p.type);if(!u)return;const C=this._themeService.getCurrentTheme();if(!((k=u.skipDefaultFontRender)!=null&&k.call(u,p,h,{unitId:a,subUnitId:i,row:d,column:l})))return;const v=u.parseFormulaSync(p,a,i),{formula1:O}=v,b=this._calc(c,r),{a:f,d:_}=e.getTransform(),S=F.fixLineWidthByScale(b.left,f),w=F.fixLineWidthByScale(b.top,_),D=F.Transform.create().composeMatrix({left:S,top:w,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),y=c.endX-c.startX,E=c.endY-c.startY;e.save(),e.beginPath(),e.rect(c.startX,c.startY,y,E),e.clip();const P=D.getMatrix();e.transform(P[0],P[1],P[2],P[3],P[4],P[5]);const W=((B=r==null?void 0:r.fs)!=null?B:10)*1.6,A=String(h)===String(O),j=C.hyacinth500;F.CheckboxShape.drawWith(e,{checked:A,width:W,height:W,fill:(X=(L=r==null?void 0:r.cl)==null?void 0:L.rgb)!=null?X:j}),e.restore()}isHit(e,t){const r=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(r,t.style),a=n.top,i=n.top+n.height,s=n.left,d=n.left+n.width,{x:l,y:c}=e;return l<=d&&l>=s&&c<=i&&c>=a}async onPointerDown(e,t){var v;if(t.button===2)return;const{primaryWithCoord:r,unitId:n,subUnitId:a,worksheet:i,row:s,col:d}=e,l=m.getCellValueOrigin(i.getCellRaw(s,d)),c=this._dataValidationModel.getRuleByLocation(n,a,s,d);if(!c)return;const h=this._dataValidationModel.getValidator(c.type);if(!h||!((v=h.skipDefaultFontRender)!=null&&v.call(h,c,l,{unitId:n,subUnitId:a,row:s,column:d})))return;const{formula1:p,formula2:u}=await this._parseFormula(c,n,a),C={range:{startColumn:r.actualColumn,endColumn:r.actualColumn,startRow:r.actualRow,endRow:r.actualRow},value:{v:String(l)===m.transformCheckboxValue(String(p))?u:p,p:null}};this._commandService.executeCommand($.SetRangeValuesCommand.id,C)}onPointerEnter(e,t){var r,n;(n=(r=F.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:r.mainComponent)==null||n.setCursor(F.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var r,n;(n=(r=F.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:r.mainComponent)==null||n.setCursor(F.CURSOR_TYPE.DEFAULT)}};rt=Un([Ve(0,o.ICommandService),Ve(1,o.IUniverInstanceService),Ve(2,o.Inject(m.DataValidationFormulaService)),Ve(3,o.Inject(o.ThemeService)),Ve(4,o.Inject(F.IRenderManagerService)),Ve(5,o.Inject(m.SheetDataValidationModel))],rt);class Fn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);R(this,"id",o.DataValidationType.CHECKBOX);R(this,"canvasRender",this.injector.createInstance(rt));R(this,"formulaInput",m.CHECKBOX_FORMULA_INPUT_NAME)}}class Nn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);R(this,"id",o.DataValidationType.CUSTOM);R(this,"formulaInput",m.CUSTOM_FORMULA_INPUT_NAME)}}const kn="data-validation.formula-input";class jn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);R(this,"id",o.DataValidationType.DATE);R(this,"formulaInput",kn);R(this,"optionsInput",Be.componentKey);R(this,"dropdownType",Y.DataValidatorDropdownType.DATE)}}class Bn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);R(this,"id",o.DataValidationType.DECIMAL);R(this,"formulaInput",m.BASE_FORMULA_INPUT_NAME)}}const Vt=4,Hn=0,at=4,Ot=4,it=6,We=6,_e=14;function Wn(e,t){const r=F.FontCache.getTextSize(e,t),n=r.width+Vt*2,{ba:a,bd:i}=r,s=a+i;return{width:n,height:s+Hn*2,ba:a}}function ot(e,t,r,n){const a=_e+it*2,i=r-a,s=n-We*2,d=e.map(u=>({layout:Wn(u,t),text:u}));let l;const c=[];d.forEach(u=>{const{layout:C}=u,{width:v,height:O}=C;!l||l.width+v+at>i?(l={width:v,height:O,items:[{...u,left:0}]},c.push(l)):(l.items.push({...u,left:l.width+at}),l.width=l.width+v+at)});let h=0,p=0;return c.forEach((u,C)=>{p=Math.max(p,u.width),C===c.length-1?h+=u.height:h+=u.height+Ot}),{lines:c,totalHeight:h,contentWidth:i,contentHeight:s,cellAutoHeight:h+We*2,calcAutoWidth:p+a}}const xn=8;class $n extends F.Shape{static drawWith(t,r){const{fontString:n,info:a,fill:i,color:s}=r,{layout:d,text:l}=a;t.save(),F.Rect.drawWith(t,{width:d.width,height:d.height,radius:xn,fill:i||Ce}),t.translateWithPrecision(Vt,d.ba),t.font=n,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var Yn=Object.getOwnPropertyDescriptor,Xn=(e,t,r,n)=>{for(var a=n>1?void 0:n?Yn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},xe=(e,t)=>(r,n)=>t(r,n,e);const zn=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let st=class{constructor(e,t,r,n){R(this,"zIndex");R(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=r,this._dataValidationModel=n}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,r,n,a){const i=r-_e+4;let s=4;switch(a){case o.VerticalAlign.MIDDLE:s=(n-_e)/2+4;break;case o.VerticalAlign.BOTTOM:s=n-_e+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(zn),e.restore()}drawWith(e,t,r,n){var Q,J;const{primaryWithCoord:a,row:i,col:s,style:d,data:l,subUnitId:c}=t,h=a.isMergedMainCell?a.mergeInfo:a,p=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:C=0,topOffset:v=0,downOffset:O=0}=p||{},b=this._ensureMap(c),f=this._generateKey(i,s),_=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,s);if(!_)return;const S=this._dataValidationModel.getValidator(_.type);if(!S)return;const w={startX:h.startX+u,endX:h.endX-C,startY:h.startY+v,endY:h.endY-O},D=w.endX-w.startX,y=w.endY-w.startY,{cl:E}=d||{},P=(Q=typeof E=="object"?E==null?void 0:E.rgb:E)!=null?Q:"#000",W=F.getFontStyleString(d!=null?d:void 0),{vt:A,ht:j}=d||{},k=A!=null?A:o.VerticalAlign.MIDDLE,B=(J=m.getCellValueOrigin(l))!=null?J:"",L=S.parseCellValue(B),X=S.getListWithColorMap(_),z=ot(L,W,D,y);this._drawDownIcon(e,w,D,y,k),e.save(),e.translateWithPrecision(w.startX,w.startY),e.beginPath(),e.rect(0,0,D-_e,y),e.clip(),e.translateWithPrecision(it,We);let Z=0;switch(k){case o.VerticalAlign.MIDDLE:Z=(z.contentHeight-z.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:Z=z.contentHeight-z.totalHeight;break}e.translateWithPrecision(0,Z),z.lines.forEach((re,ue)=>{e.save();const{width:se,height:ae,items:le}=re;let pe=0;switch(j){case o.HorizontalAlign.RIGHT:pe=z.contentWidth-se;break;case o.HorizontalAlign.CENTER:pe=(z.contentWidth-se)/2;break}e.translate(pe,ue*(ae+Ot)),le.forEach(he=>{e.save(),e.translateWithPrecision(he.left,0),$n.drawWith(e,{...W,info:he,color:P,fill:X[he.text]}),e.restore()}),e.restore()}),e.restore(),b.set(f,{left:w.startX,top:w.startY,width:z.contentWidth+it+_e,height:z.contentHeight+We*2})}calcCellAutoHeight(e){var D;const{primaryWithCoord:t,style:r,data:n,row:a,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},p=t.isMergedMainCell?t.mergeInfo:t,u={startX:p.startX+d,endX:p.endX-l,startY:p.startY+c,endY:p.endY-h},C=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!C)return;const v=this._dataValidationModel.getValidator(C.type);if(!v)return;const O=u.endX-u.startX,b=u.endY-u.startY,f=(D=m.getCellValueOrigin(n))!=null?D:"",_=v.parseCellValue(f),S=F.getFontStyleString(r!=null?r:void 0);return ot(_,S,O,b).cellAutoHeight}calcCellAutoWidth(e){var D;const{primaryWithCoord:t,style:r,data:n,row:a,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},p=t.isMergedMainCell?t.mergeInfo:t,u={startX:p.startX+d,endX:p.endX-l,startY:p.startY+c,endY:p.endY-h},C=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!C)return;const v=this._dataValidationModel.getValidator(C.type);if(!v)return;const O=u.endX-u.startX,b=u.endY-u.startY,f=(D=m.getCellValueOrigin(n))!=null?D:"",_=v.parseCellValue(f),S=F.getFontStyleString(r!=null?r:void 0);return ot(_,S,O,b).calcAutoWidth}isHit(e,t){const{primaryWithCoord:r}=t,n=r.isMergedMainCell?r.mergeInfo:r,{endX:a}=n,{x:i}=e;return i>=a-_e&&i<=a}onPointerDown(e,t){if(t.button===2)return;const{unitId:r,subUnitId:n,row:a,col:i}=e,s={unitId:r,subUnitId:n,row:a,column:i};this._commandService.executeCommand(Fe.id,s)}onPointerEnter(e,t){var r,n;return(n=(r=F.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:r.mainComponent)==null?void 0:n.setCursor(F.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var r,n;return(n=(r=F.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:r.mainComponent)==null?void 0:n.setCursor(F.CURSOR_TYPE.DEFAULT)}};st=Xn([xe(0,o.ICommandService),xe(1,o.IUniverInstanceService),xe(2,o.Inject(F.IRenderManagerService)),xe(3,o.Inject(m.SheetDataValidationModel))],st);class Kn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);R(this,"id",o.DataValidationType.LIST_MULTIPLE);R(this,"canvasRender",this.injector.createInstance(st));R(this,"dropdownType",Y.DataValidatorDropdownType.MULTIPLE_LIST)}}var Gn=Object.getOwnPropertyDescriptor,qn=(e,t,r,n)=>{for(var a=n>1?void 0:n?Gn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Ae=(e,t)=>(r,n)=>t(r,n,e);const Ie=4,$e=4,oe=14,ce=6,Oe=4,lt=8,Zn="#565656",Rt=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function Jn(e,t){const r=e.length;return{id:"d",body:{dataStream:`${e}${o.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:o.BooleanNumber.FALSE,bl:o.BooleanNumber.FALSE,ul:{s:o.BooleanNumber.FALSE},st:{s:o.BooleanNumber.FALSE},ol:{s:o.BooleanNumber.FALSE},cl:void 0,...t,bg:void 0,bd:void 0},st:0,ed:r}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function Pt(e,t,r){const n=Jn(e,r),a=new o.DocumentDataModel(n),i=new F.DocumentViewModel(a);return{documentSkeleton:F.DocumentSkeleton.create(i,t),docModel:a,docViewModel:i}}function Ye(e,t,r){const{documentSkeleton:n,docModel:a,docViewModel:i}=Pt(e,t,r);return{documents:new F.Documents(`DOCUMENTS_${o.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:a,docViewModel:i}}function At(e,t,r,n,a,i,s=!0){let d=0;const l=s?Oe:0;switch(a){case o.VerticalAlign.BOTTOM:d=t-n-l;break;case o.VerticalAlign.MIDDLE:d=(t-n)/2;break;default:d=l;break}d=Math.max(Oe,d);let c=0;switch(i){case o.HorizontalAlign.CENTER:c=(e-r)/2;break;case o.HorizontalAlign.RIGHT:c=e-r;break}return c=Math.max(ce,c),{paddingLeft:c,paddingTop:d}}let dt=class{constructor(e,t,r,n,a){R(this,"_dropdownInfoMap",new Map);R(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=r,this._renderManagerService=n,this._dataValidationModel=a}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,r,n,a,i,s){const{t:d=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,c=r-oe;let h;switch(i){case o.VerticalAlign.MIDDLE:h=(n-$e)/2;break;case o.VerticalAlign.BOTTOM:h=n-l-a-Oe+(a/2-$e/2);break;default:h=d+Oe+(a/2-$e/2);break}e.save(),e.translateWithPrecision(t.startX+c,t.startY+h),e.fillStyle="#565656",e.fill(Rt),e.restore()}drawWith(e,t,r){const{primaryWithCoord:n,row:a,col:i,style:s,data:d,subUnitId:l}=t,c=n.isMergedMainCell?n.mergeInfo:n,h=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,a,i);if(!h)return;const p=this._dataValidationModel.getValidator(h.type);if(!p)return;const u=d==null?void 0:d.fontRenderExtension,{leftOffset:C=0,rightOffset:v=0,topOffset:O=0,downOffset:b=0}=u||{};if(!h||!p||!p||p.id.indexOf(o.DataValidationType.LIST)!==0||!p.skipDefaultFontRender(h))return;const f={startX:c.startX+C,endX:c.endX-v,startY:c.startY+O,endY:c.endY-b},_=f.endX-f.startX,S=f.endY-f.startY,w=this._ensureMap(l),D=this._generateKey(a,i),y=p.getListWithColor(h),E=m.getCellValueOrigin(d),P=`${E!=null?E:""}`,W=y.find(L=>L.label===P);let{tb:A,vt:j,ht:k,pd:B}=s||{};if(A=A!=null?A:o.WrapStrategy.WRAP,j=j!=null?j:o.VerticalAlign.BOTTOM,k=k!=null?k:o.DEFAULT_STYLES.ht,B=B!=null?B:o.DEFAULT_STYLES.pd,h.renderMode===o.DataValidationRenderMode.ARROW){const{l:L=o.DEFAULT_STYLES.pd.l,t:X=o.DEFAULT_STYLES.pd.t,r:z=o.DEFAULT_STYLES.pd.r,b:Z=o.DEFAULT_STYLES.pd.b}=B,Q=_-L-z-oe-4,{documentSkeleton:J,documents:re,docModel:ue}=Ye(P,this._localeService,s);A===o.WrapStrategy.WRAP&&ue.updateDocumentDataPageSize(Math.max(Q,1)),J.calculate(),J.getActualSize();const se=F.getDocsSkeletonPageSize(J),{height:ae,width:le}=se,{paddingTop:pe,paddingLeft:he}=At(Q,S-X-Z,le,ae,j,k,!0);this._drawDownIcon(e,f,_,S,ae,j,B),e.save(),e.translateWithPrecision(f.startX+L,f.startY+X),e.beginPath(),e.rect(0,0,_-L-z,S-X-Z),e.clip(),e.translateWithPrecision(0,pe),e.save(),e.translateWithPrecision(Ie,0),e.beginPath(),e.rect(0,0,Q,ae),e.clip(),re.render(e),e.translateWithPrecision(he,0),e.restore(),e.restore(),w.set(D,{left:f.endX+L+r.rowHeaderWidth-oe,top:f.startY+X+r.columnHeaderHeight,width:oe,height:S-X-Z})}else{e.save(),e.translateWithPrecision(f.startX,f.startY),e.beginPath(),e.rect(0,0,_,S),e.clip();const L=_-ce*2-Ie-oe-4,{documentSkeleton:X,documents:z,docModel:Z}=Ye(P,this._localeService,s);A===o.WrapStrategy.WRAP&&Z.updateDocumentDataPageSize(Math.max(L,1)),X.calculate();const Q=F.getDocsSkeletonPageSize(X),{height:J,width:re}=Q,{paddingTop:ue,paddingLeft:se}=At(L,S,re,J,j,k);e.translateWithPrecision(ce,ue);const ae=Math.max(_-ce*2,1),le=J;F.Rect.drawWith(e,{width:ae,height:le,fill:(W==null?void 0:W.color)||Ce,radius:lt}),e.save(),e.translateWithPrecision(Ie,0),e.beginPath(),e.rect(0,0,L,J),e.clip(),e.translateWithPrecision(se,0),z.render(e),e.restore(),e.translateWithPrecision(L+Ie+4,(J-$e)/2),e.fillStyle=Zn,e.fill(Rt),e.restore(),w.set(D,{left:f.startX+ce+r.rowHeaderWidth,top:f.startY+ue+r.columnHeaderHeight,width:ae,height:le})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:r,data:n,row:a,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:p=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const C={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-p},v=C.endX-C.startX,O=m.getCellValueOrigin(n),b=`${O!=null?O:""}`;let{tb:f,pd:_}=r||{};const{t:S=o.DEFAULT_STYLES.pd.t,b:w=o.DEFAULT_STYLES.pd.b}=_!=null?_:{};if(f=f!=null?f:o.WrapStrategy.WRAP,u.renderMode===o.DataValidationRenderMode.ARROW){const D=v-oe,{documentSkeleton:y,docModel:E}=Ye(b,this._localeService,r);f===o.WrapStrategy.WRAP&&E.updateDocumentDataPageSize(Math.max(D,1)),y.calculate(),y.getActualSize();const P=F.getDocsSkeletonPageSize(y),{height:W}=P;return W+S+w+Oe*2}else{const D=v-ce*2-Ie-oe,{documentSkeleton:y,docModel:E}=Pt(b,this._localeService,r);f===o.WrapStrategy.WRAP&&E.updateDocumentDataPageSize(Math.max(D,1)),y.calculate();const P=F.getDocsSkeletonPageSize(y),{height:W}=P;return W+Oe*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:r,data:n,row:a,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:p=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const C={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-p},v=C.endX-C.startX,O=m.getCellValueOrigin(n),b=`${O!=null?O:""}`;let{tb:f,pd:_}=r||{};const{l:S=o.DEFAULT_STYLES.pd.l,r:w=o.DEFAULT_STYLES.pd.r}=_!=null?_:{};f=f!=null?f:o.WrapStrategy.WRAP;let D=ce*2+oe;switch(u.renderMode){case o.DataValidationRenderMode.ARROW:D=oe+ce*2+w+S;break;case o.DataValidationRenderMode.CUSTOM:D=oe+ce*2+Ie*2+w+S+lt/2+1;break;default:D=oe+ce*2+Ie*2+w+S+lt/2+1}const y=v-D,{documentSkeleton:E,docModel:P}=Ye(b,this._localeService,r);return f===o.WrapStrategy.WRAP&&P.updateDocumentDataPageSize(Math.max(y,1)),E.calculate(),E.getActualSize(),F.getDocsSkeletonPageSize(E).width+D}isHit(e,t){const{subUnitId:r,row:n,col:a}=t,s=this._ensureMap(r).get(this._generateKey(n,a)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,a);if(!d||!s||d.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:c,width:h,height:p}=s,{x:u,y:C}=e;return u>=c&&u<=c+h&&C>=l&&C<=l+p}onPointerDown(e,t){if(t.button===2)return;const{unitId:r,subUnitId:n,row:a,col:i}=e,s={unitId:r,subUnitId:n,row:a,column:i};this._commandService.executeCommand(Fe.id,s)}onPointerEnter(e,t){var r,n;(n=(r=F.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:r.mainComponent)==null||n.setCursor(F.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var r,n;(n=(r=F.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:r.mainComponent)==null||n.setCursor(F.CURSOR_TYPE.DEFAULT)}};dt=qn([Ae(0,o.IUniverInstanceService),Ae(1,o.Inject(o.LocaleService)),Ae(2,o.ICommandService),Ae(3,o.Inject(F.IRenderManagerService)),Ae(4,o.Inject(m.SheetDataValidationModel))],dt);class Qn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);R(this,"id",o.DataValidationType.LIST);R(this,"canvasRender",this.injector.createInstance(dt));R(this,"dropdownType",Y.DataValidatorDropdownType.LIST);R(this,"optionsInput",je.componentKey);R(this,"formulaInput",m.LIST_FORMULA_INPUT_NAME)}}class er extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);R(this,"id",o.DataValidationType.TEXT_LENGTH);R(this,"formulaInput",m.BASE_FORMULA_INPUT_NAME)}}class tr extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);R(this,"id",o.DataValidationType.WHOLE);R(this,"formulaInput",m.BASE_FORMULA_INPUT_NAME)}}var nr=Object.getOwnPropertyDescriptor,rr=(e,t,r,n)=>{for(var a=n>1?void 0:n?nr(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ct=(e,t)=>(r,n)=>t(r,n,e);let Re=class extends o.RxDisposable{constructor(e,t,r){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=r,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[wt,vt],[Ue,Rn],[je.componentKey,je],[Be.componentKey,Be],...Jt].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Bn,tr,er,jn,Fn,Qn,Kn,Nn].forEach(e=>{const t=this._injector.createInstance(e),r=this._dataValidatorRegistryService.getValidatorItem(t.id);r&&(r.formulaInput=t.formulaInput,r.canvasRender=t.canvasRender,r.dropdownType=t.dropdownType,r.optionsInput=t.optionsInput)})}};Re=rr([ct(0,o.Inject(o.Injector)),ct(1,o.Inject(M.ComponentManager)),ct(2,o.Inject(Y.DataValidatorRegistryService))],Re);var ar=Object.getOwnPropertyDescriptor,ir=(e,t,r,n)=>{for(var a=n>1?void 0:n?ar(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ut=(e,t)=>(r,n)=>t(r,n,e);const or="SHEET_DATA_VALIDATION_UI_PLUGIN";U.UniverSheetsDataValidationUIPlugin=(Xe=class extends o.Plugin{constructor(t=Le,r,n,a){super(),this._config=t,this._injector=r,this._commandService=n,this._configService=a;const{menu:i,...s}=o.merge({},Le,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Ze,s)}onStarting(){[[de],[fe],[Pe],[Ee],[Te],[be],[Me],[we],[Re]].forEach(t=>{this._injector.add(t)}),[Ne,Fe,yt,Qe,me,Ct].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Me),this._injector.get(be),this._injector.get(we),this._injector.get(Pe),this._injector.get(F.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ke])}onRendered(){this._injector.get(Re),this._injector.get(Te)}onSteady(){this._injector.get(Ee)}},R(Xe,"pluginName",or),R(Xe,"type",o.UniverInstanceType.UNIVER_SHEET),Xe),U.UniverSheetsDataValidationUIPlugin=ir([ut(1,o.Inject(o.Injector)),ut(2,o.ICommandService),ut(3,o.IConfigService)],U.UniverSheetsDataValidationUIPlugin);var sr=Object.getOwnPropertyDescriptor,lr=(e,t,r,n)=>{for(var a=n>1?void 0:n?sr(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ht=(e,t)=>(r,n)=>t(r,n,e);const dr="SHEET_DATA_VALIDATION_UI_PLUGIN";U.UniverSheetsDataValidationMobileUIPlugin=(ze=class extends o.Plugin{constructor(t=Le,r,n,a){super(),this._config=t,this._injector=r,this._commandService=n,this._configService=a;const{menu:i,...s}=o.merge({},Le,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Ze,s)}onStarting(){[[de],[fe],[Pe],[Ee],[Te],[be],[Me],[Re]].forEach(t=>{this._injector.add(t)}),[Ne,Fe,yt,Qe,me,Ct].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Me),this._injector.get(be),this._injector.get(F.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ke])}onRendered(){this._injector.get(Re),this._injector.get(Te)}onSteady(){this._injector.get(Ee)}},R(ze,"pluginName",dr),R(ze,"type",o.UniverInstanceType.UNIVER_SHEET),ze),U.UniverSheetsDataValidationMobileUIPlugin=lr([ht(1,o.Inject(o.Injector)),ht(2,o.ICommandService),ht(3,o.IConfigService)],U.UniverSheetsDataValidationMobileUIPlugin),Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@univerjs/sheets-data-validation-ui",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.7.0-beta.0",
|
4
4
|
"private": false,
|
5
5
|
"description": "Data validation UI for Univer Sheets",
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
@@ -55,18 +55,18 @@
|
|
55
55
|
},
|
56
56
|
"dependencies": {
|
57
57
|
"@flatten-js/interval-tree": "^1.1.3",
|
58
|
-
"@univerjs/icons": "^0.3.
|
59
|
-
"@univerjs/core": "0.
|
60
|
-
"@univerjs/data-validation": "0.
|
61
|
-
"@univerjs/engine-
|
62
|
-
"@univerjs/
|
63
|
-
"@univerjs/
|
64
|
-
"@univerjs/sheets": "0.
|
65
|
-
"@univerjs/sheets-data-validation": "0.
|
66
|
-
"@univerjs/sheets-
|
67
|
-
"@univerjs/sheets-
|
68
|
-
"@univerjs/sheets-
|
69
|
-
"@univerjs/ui": "0.
|
58
|
+
"@univerjs/icons": "^0.3.22",
|
59
|
+
"@univerjs/core": "0.7.0-beta.0",
|
60
|
+
"@univerjs/data-validation": "0.7.0-beta.0",
|
61
|
+
"@univerjs/engine-formula": "0.7.0-beta.0",
|
62
|
+
"@univerjs/design": "0.7.0-beta.0",
|
63
|
+
"@univerjs/engine-render": "0.7.0-beta.0",
|
64
|
+
"@univerjs/sheets": "0.7.0-beta.0",
|
65
|
+
"@univerjs/sheets-data-validation": "0.7.0-beta.0",
|
66
|
+
"@univerjs/sheets-formula-ui": "0.7.0-beta.0",
|
67
|
+
"@univerjs/sheets-ui": "0.7.0-beta.0",
|
68
|
+
"@univerjs/sheets-numfmt": "0.7.0-beta.0",
|
69
|
+
"@univerjs/ui": "0.7.0-beta.0"
|
70
70
|
},
|
71
71
|
"devDependencies": {
|
72
72
|
"less": "^4.3.0",
|
@@ -75,9 +75,9 @@
|
|
75
75
|
"rxjs": "^7.8.1",
|
76
76
|
"tailwindcss": "^3.4.17",
|
77
77
|
"typescript": "^5.8.3",
|
78
|
-
"vite": "^6.3.
|
79
|
-
"vitest": "^3.1.
|
80
|
-
"@univerjs-infra/shared": "0.
|
78
|
+
"vite": "^6.3.3",
|
79
|
+
"vitest": "^3.1.2",
|
80
|
+
"@univerjs-infra/shared": "0.7.0-beta.0"
|
81
81
|
},
|
82
82
|
"scripts": {
|
83
83
|
"dev": "vite",
|
/package/lib/types/views/components/formula-input/{base-formula-input.d.ts → BaseFormulaInput.d.ts}
RENAMED
File without changes
|
File without changes
|
File without changes
|
/package/lib/types/views/components/formula-input/{list-formula-input.d.ts → ListFormulaInput.d.ts}
RENAMED
File without changes
|