@univerjs/sheets-data-validation-ui 0.7.0-nightly.202505021607 → 0.7.0-nightly.202505031606

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 CHANGED
@@ -20,7 +20,7 @@
20
20
  `,onClick:()=>c(!s),children:[t.t("dataValidation.panel.options"),s?v.jsx(Dt,{className:"univer-ml-1 univer-text-[8px]"}):v.jsx(yt,{className:"univer-ml-1 univer-text-[8px]"})]}),s&&v.jsxs(v.Fragment,{children:[l?v.jsx(l,{value:n,onChange:i}):null,v.jsx(b.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:v.jsxs(b.RadioGroup,{value:`${(d=n.errorStyle)!=null?d:o.DataValidationErrorStyle.WARNING}`,onChange:h=>i({...n,errorStyle:+h}),children:[v.jsx(b.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),v.jsx(b.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),v.jsx(b.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:v.jsx(b.Checkbox,{checked:n.showErrorMessage,onChange:()=>i({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?v.jsx(b.FormLayout,{children:v.jsx(b.Input,{value:n.error,onChange:h=>i({...n,error:h})})}):null]})]})}const Mn=e=>o.debounce(async(t,a,n,i)=>{const r=await e.executeCommand(t,a,n);i==null||i(r)},1e3);function bn(e,t,a){var n,i,r,s;return t?((i=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:i.getSheetId())||"":((s=(r=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function Tn(){var x,K;const[e,t]=M.useState(0),a=w.useDependency(ue),n=w.useObservable(a.activeRule$,a.activeRule),{unitId:i,subUnitId:r,rule:s}=n||{},c=s.uid,l=w.useDependency(Y.DataValidatorRegistryService),d=w.useDependency(o.IUniverInstanceService),h=w.useDependency(w.ComponentManager),g=w.useDependency(o.ICommandService),u=w.useDependency(Y.DataValidationModel),C=w.useDependency(o.LocaleService),[p,T]=M.useState(s),E=l.getValidatorItem(p.type),[m,S]=M.useState(!1),f=l.getValidatorsByScope(Y.DataValidatorRegistryScope.SHEET),[D,R]=M.useState(()=>p.ranges.map(I=>({unitId:"",sheetId:"",range:I}))),y=M.useMemo(()=>Mn(g),[g]),[V,P]=M.useState(!1),[k,A]=M.useState(!1),F=M.useRef(null),U=w.useDependency(W.SheetsSelectionsService);if(M.useEffect(()=>()=>{const I=U.getCurrentLastSelection();I&&U.setSelections([I])},[U]),M.useEffect(()=>{g.onCommandExecuted(I=>{(I.id===o.UndoCommand.id||I.id===o.RedoCommand.id)&&setTimeout(()=>{const B=u.getRuleById(i,r,c);t(z=>z+1),B&&(T(B),R(B.ranges.map(z=>({unitId:"",sheetId:"",range:z}))))},20)})},[g,u,c,r,i]),!E)return null;const N=E.operators,L=E.operatorNames,$=p.operator?Y.TWO_FORMULA_OPERATOR_COUNT.includes(p.operator):!1,X=()=>{var I,B,z;(B=(I=F.current)==null?void 0:I.editor)!=null&&B.isFocus()&&G((z=F.current)==null?void 0:z.getValue()),!(!p.ranges.length||V)&&(E.validatorFormula(p,i,r).success?a.setActiveRule(null):S(!0))},G=w.useEvent(I=>{const B=I.split(",").filter(Boolean).map(at.deserializeRangeWithSheet).map(Q=>{const ht=Q.sheetName;if(ht){const Lt=bn(d,Q.unitId,ht);return{...Q,sheetId:Lt}}return{...Q,sheetId:""}});if(o.isUnitRangesEqual(B,D))return;R(B);const z=B.filter(Q=>(!Q.unitId||Q.unitId===i)&&(!Q.sheetId||Q.sheetId===r)).map(Q=>Q.range);if(T({...p,ranges:z}),z.length===0)return;const ge={unitId:i,subUnitId:r,ruleId:c,ranges:z};y(_.UpdateSheetDataValidationRangeCommand.id,ge)}),J=I=>{if(o.shallowEqual(I,Y.getRuleSetting(p)))return;T({...p,...I});const B={unitId:i,subUnitId:r,ruleId:c,setting:I};y(_.UpdateSheetDataValidationSettingCommand.id,B,void 0)},q=async()=>{await g.executeCommand(_.RemoveSheetDataValidationCommand.id,{ruleId:c,unitId:i,subUnitId:r}),a.setActiveRule(null)},ee={type:p.type,operator:p.operator,formula1:p.formula1,formula2:p.formula2,allowBlank:p.allowBlank},le=I=>{const B=l.getValidatorItem(I);if(!B)return;const z=B.operators,ge=u.getRuleById(i,r,c),Q=I===(ge==null?void 0:ge.type)||I.includes("list")&&(ge!=null&&ge.type.includes("list"))?{...ge,type:I}:{...p,type:I,operator:z[0],formula1:void 0,formula2:void 0};T(Q),g.executeCommand(_.UpdateSheetDataValidationSettingCommand.id,{unitId:i,subUnitId:r,ruleId:p.uid,setting:Y.getRuleSetting(Q)})},ie=h.get(E.formulaInput),te=M.useMemo(()=>D.map(I=>at.serializeRange(I.range)).join(","),[]),re=Y.getRuleOptions(p),he=I=>{o.shallowEqual(I,Y.getRuleOptions(p))||(T({...p,...I}),y(_.UpdateSheetDataValidationOptionsCommand.id,{unitId:i,subUnitId:r,ruleId:c,options:I}))},ce=N.length&&!p.operator;return v.jsxs("div",{className:"univer-py-4",children:[v.jsx(b.FormLayout,{label:C.t("dataValidation.panel.range"),error:!p.ranges.length||V?C.t("dataValidation.panel.rangeError"):"",children:v.jsx(lt.RangeSelector,{selectorRef:F,unitId:i,subUnitId:r,initialValue:te,onChange:(I,B)=>{var z;!k&&((z=F.current)!=null&&z.verify())&&G(B)},onFocusChange:(I,B)=>{var z;A(I),!I&&B&&((z=F.current)!=null&&z.verify())&&G(B)},onVerify:I=>P(!I)})}),v.jsx(b.FormLayout,{label:C.t("dataValidation.panel.type"),children:v.jsx(b.Select,{className:"univer-w-full",value:p.type,options:(x=f==null?void 0:f.sort((I,B)=>I.order-B.order))==null?void 0:x.map(I=>({label:C.t(I.title),value:I.id})),onChange:le})}),N!=null&&N.length?v.jsx(b.FormLayout,{label:C.t("dataValidation.panel.operator"),children:v.jsx(b.Select,{className:"univer-w-full",value:`${p.operator}`,options:[{value:"",label:C.t("dataValidation.operators.legal")},...N.map((I,B)=>({value:`${I}`,label:L[B]}))],onChange:I=>{J({...ee,operator:I})}})}):null,ie&&!ce?v.jsx(b.FormLayout,{children:v.jsx(ie,{isTwoFormula:$,value:{formula1:p.formula1,formula2:p.formula2},onChange:I=>{J({...ee,...I})},showError:m,validResult:E.validatorFormula(p,i,r),unitId:i,subUnitId:r,ruleId:c},e+p.type)}):null,v.jsx(b.FormLayout,{children:v.jsx(b.Checkbox,{checked:(K=p.allowBlank)!=null?K:!0,onChange:()=>{var I;return J({...ee,allowBlank:!((I=p.allowBlank)==null||I)})},children:C.t("dataValidation.panel.allowBlank")})}),v.jsx(En,{value:re,onChange:he,extraComponent:E.optionsInput}),v.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[v.jsx(b.Button,{className:"univer-ml-3",onClick:q,children:C.t("dataValidation.panel.removeRule")}),v.jsx(b.Button,{className:"univer-ml-3",variant:"primary",onClick:X,children:C.t("dataValidation.panel.done")})]})]})}const On=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:i,disable:r}=e,s=w.useDependency(Y.DataValidatorRegistryService),c=w.useDependency(o.ICommandService),l=w.useDependency(H.IMarkSelectionService),d=s.getValidatorItem(t.type),h=M.useRef(void 0),[g,u]=M.useState(!1),C=w.useDependency(o.ThemeService),p=w.useObservable(C.currentTheme$),T=M.useMemo(()=>{var f;const m=(f=p==null?void 0:p.loopColor2)!=null?f:"#49B811",S=new o.ColorKit(m).toRgb();return{fill:`rgba(${S.r}, ${S.g}, ${S.b}, 0.1)`,stroke:m}},[p]),E=m=>{c.executeCommand(_.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:i}),m.stopPropagation()};return M.useEffect(()=>()=>{var m;h.current&&((m=h.current)==null||m.forEach(S=>{S&&l.removeShape(S)}))},[l]),v.jsxs("div",{className:b.clsx(`
21
21
  univer-rounded-md univer-bg-secondary univer-relative univer--ml-2 univer--mr-2 univer-box-border
22
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
23
+ univer-overflow-hidden univer-p-2 univer-pr-9
24
24
  `,{"hover:univer-bg-gray-50":!r,"univer-opacity-50":r}),onClick:a,onMouseEnter:()=>{r||(u(!0),h.current=t.ranges.map(m=>l.addShape({range:m,style:T,primary:null})))},onMouseLeave:()=>{var m;u(!1),(m=h.current)==null||m.forEach(S=>{S&&l.removeShape(S)}),h.current=void 0},children:[v.jsx("div",{className:`
25
25
  univer-overflow-hidden univer-text-ellipsis univer-text-sm univer-font-medium univer-leading-[22px]
26
26
  univer-text-black
package/lib/es/index.js CHANGED
@@ -2061,7 +2061,7 @@ const Oi = (e) => {
2061
2061
  `
2062
2062
  univer-rounded-md univer-bg-secondary univer-relative univer--ml-2 univer--mr-2 univer-box-border
2063
2063
  univer-flex univer-w-[287px] univer-cursor-pointer univer-flex-col univer-justify-between
2064
- univer-overflow-hidden univer-rounded-lg univer-p-2 univer-pr-9
2064
+ univer-overflow-hidden univer-p-2 univer-pr-9
2065
2065
  `,
2066
2066
  {
2067
2067
  "hover:univer-bg-gray-50": !i,
package/lib/index.css CHANGED
@@ -1 +1 @@
1
- .univer-absolute{position:absolute}.univer-relative{position:relative}.univer-right-2{right:8px}.univer-top-\[19px\]{top:19px}.-univer-mt-2{margin-top:-8px}.univer--ml-2{margin-left:-8px}.univer--mr-2{margin-right:-8px}.univer-mb-1{margin-bottom:4px}.univer-mb-2{margin-bottom:8px}.univer-mb-3{margin-bottom:12px}.univer-ml-1{margin-left:4px}.univer-ml-3{margin-left:12px}.univer-mr-1{margin-right:4px}.univer-mr-2{margin-right:8px}.univer-mt-4{margin-top:16px}.univer-mt-5{margin-top:20px}.univer-box-border{box-sizing:border-box}.univer-flex{display:flex}.univer-h-4{height:16px}.univer-h-5{height:20px}.univer-w-28{width:112px}.univer-w-4{width:16px}.univer-w-5{width:20px}.univer-w-\[287px\]{width:287px}.univer-w-\[92px\]{width:92px}.univer-w-fit{width:-moz-fit-content;width:fit-content}.univer-w-full{width:100%}.univer-cursor-move{cursor:move}.univer-cursor-pointer{cursor:pointer}.univer-flex-row{flex-direction:row}.univer-flex-col{flex-direction:column}.univer-flex-wrap{flex-wrap:wrap}.univer-items-center{align-items:center}.univer-justify-end{justify-content:flex-end}.univer-justify-center{justify-content:center}.univer-justify-between{justify-content:space-between}.univer-gap-2{gap:8px}.univer-overflow-hidden{overflow:hidden}.univer-text-ellipsis{text-overflow:ellipsis}.univer-rounded{border-radius:4px}.univer-rounded-lg{border-radius:8px}.univer-rounded-md{border-radius:6px}.univer-border{border-width:1px}.univer-border-gray-200{--tw-border-opacity: 1;border-color:#e3e5ea;border-color:rgba(227,229,234,var(--tw-border-opacity, 1))}.univer-bg-gray-50{--tw-bg-opacity: 1;background-color:#f9fafb;background-color:rgba(249,250,251,var(--tw-bg-opacity, 1))}.univer-p-1{padding:4px}.univer-p-2{padding:8px}.univer-p-3{padding:12px}.univer-px-2{padding-left:8px;padding-right:8px}.univer-py-4{padding-top:16px;padding-bottom:16px}.univer-pb-0\.5{padding-bottom:2px}.univer-pb-4{padding-bottom:16px}.univer-pl-3{padding-left:12px}.univer-pr-9{padding-right:36px}.univer-text-\[8px\]{font-size:8px}.univer-text-base{font-size:16px;line-height:24px}.univer-text-sm{font-size:14px;line-height:20px}.univer-text-xs{font-size:12px;line-height:16px}.univer-font-medium{font-weight:500}.univer-leading-\[18px\]{line-height:18px}.univer-leading-\[22px\]{line-height:22px}.univer-text-black{--tw-text-opacity: 1;color:#000;color:rgba(0,0,0,var(--tw-text-opacity, 1))}.univer-text-gray-400{--tw-text-opacity: 1;color:#7d8698;color:rgba(125,134,152,var(--tw-text-opacity, 1))}.univer-opacity-50{opacity:.5}.hover\:univer-bg-gray-200:hover{--tw-bg-opacity: 1;background-color:#e3e5ea;background-color:rgba(227,229,234,var(--tw-bg-opacity, 1))}.hover\:univer-bg-gray-50:hover{--tw-bg-opacity: 1;background-color:#f9fafb;background-color:rgba(249,250,251,var(--tw-bg-opacity, 1))}.hover\:univer-bg-primary-600\/5:hover{background-color:#2c53f10d}
1
+ .univer-absolute{position:absolute}.univer-relative{position:relative}.univer-right-2{right:8px}.univer-top-\[19px\]{top:19px}.-univer-mt-2{margin-top:-8px}.univer--ml-2{margin-left:-8px}.univer--mr-2{margin-right:-8px}.univer-mb-1{margin-bottom:4px}.univer-mb-2{margin-bottom:8px}.univer-mb-3{margin-bottom:12px}.univer-ml-1{margin-left:4px}.univer-ml-3{margin-left:12px}.univer-mr-1{margin-right:4px}.univer-mr-2{margin-right:8px}.univer-mt-4{margin-top:16px}.univer-mt-5{margin-top:20px}.univer-box-border{box-sizing:border-box}.univer-flex{display:flex}.univer-h-4{height:16px}.univer-h-5{height:20px}.univer-w-28{width:112px}.univer-w-4{width:16px}.univer-w-5{width:20px}.univer-w-\[287px\]{width:287px}.univer-w-\[92px\]{width:92px}.univer-w-fit{width:-moz-fit-content;width:fit-content}.univer-w-full{width:100%}.univer-cursor-move{cursor:move}.univer-cursor-pointer{cursor:pointer}.univer-flex-row{flex-direction:row}.univer-flex-col{flex-direction:column}.univer-flex-wrap{flex-wrap:wrap}.univer-items-center{align-items:center}.univer-justify-end{justify-content:flex-end}.univer-justify-center{justify-content:center}.univer-justify-between{justify-content:space-between}.univer-gap-2{gap:8px}.univer-overflow-hidden{overflow:hidden}.univer-text-ellipsis{text-overflow:ellipsis}.univer-rounded{border-radius:4px}.univer-rounded-md{border-radius:6px}.univer-border{border-width:1px}.univer-border-gray-200{--tw-border-opacity: 1;border-color:#e3e5ea;border-color:rgba(227,229,234,var(--tw-border-opacity, 1))}.univer-bg-gray-50{--tw-bg-opacity: 1;background-color:#f9fafb;background-color:rgba(249,250,251,var(--tw-bg-opacity, 1))}.univer-p-1{padding:4px}.univer-p-2{padding:8px}.univer-p-3{padding:12px}.univer-px-2{padding-left:8px;padding-right:8px}.univer-py-4{padding-top:16px;padding-bottom:16px}.univer-pb-0\.5{padding-bottom:2px}.univer-pb-4{padding-bottom:16px}.univer-pl-3{padding-left:12px}.univer-pr-9{padding-right:36px}.univer-text-\[8px\]{font-size:8px}.univer-text-base{font-size:16px;line-height:24px}.univer-text-sm{font-size:14px;line-height:20px}.univer-text-xs{font-size:12px;line-height:16px}.univer-font-medium{font-weight:500}.univer-leading-\[18px\]{line-height:18px}.univer-leading-\[22px\]{line-height:22px}.univer-text-black{--tw-text-opacity: 1;color:#000;color:rgba(0,0,0,var(--tw-text-opacity, 1))}.univer-text-gray-400{--tw-text-opacity: 1;color:#7d8698;color:rgba(125,134,152,var(--tw-text-opacity, 1))}.univer-opacity-50{opacity:.5}.hover\:univer-bg-gray-200:hover{--tw-bg-opacity: 1;background-color:#e3e5ea;background-color:rgba(227,229,234,var(--tw-bg-opacity, 1))}.hover\:univer-bg-gray-50:hover{--tw-bg-opacity: 1;background-color:#f9fafb;background-color:rgba(249,250,251,var(--tw-bg-opacity, 1))}.hover\:univer-bg-primary-600\/5:hover{background-color:#2c53f10d}
package/lib/index.js CHANGED
@@ -2061,7 +2061,7 @@ const Oi = (e) => {
2061
2061
  `
2062
2062
  univer-rounded-md univer-bg-secondary univer-relative univer--ml-2 univer--mr-2 univer-box-border
2063
2063
  univer-flex univer-w-[287px] univer-cursor-pointer univer-flex-col univer-justify-between
2064
- univer-overflow-hidden univer-rounded-lg univer-p-2 univer-pr-9
2064
+ univer-overflow-hidden univer-p-2 univer-pr-9
2065
2065
  `,
2066
2066
  {
2067
2067
  "hover:univer-bg-gray-50": !i,
package/lib/umd/index.js CHANGED
@@ -20,7 +20,7 @@
20
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
21
  univer-rounded-md univer-bg-secondary univer-relative univer--ml-2 univer--mr-2 univer-box-border
22
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
23
+ univer-overflow-hidden univer-p-2 univer-pr-9
24
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
25
  univer-overflow-hidden univer-text-ellipsis univer-text-sm univer-font-medium univer-leading-[22px]
26
26
  univer-text-black
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-data-validation-ui",
3
- "version": "0.7.0-nightly.202505021607",
3
+ "version": "0.7.0-nightly.202505031606",
4
4
  "private": false,
5
5
  "description": "Data validation UI for Univer Sheets",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -56,17 +56,17 @@
56
56
  "dependencies": {
57
57
  "@flatten-js/interval-tree": "^1.1.3",
58
58
  "@univerjs/icons": "^0.3.24",
59
- "@univerjs/core": "0.7.0-nightly.202505021607",
60
- "@univerjs/data-validation": "0.7.0-nightly.202505021607",
61
- "@univerjs/design": "0.7.0-nightly.202505021607",
62
- "@univerjs/engine-render": "0.7.0-nightly.202505021607",
63
- "@univerjs/engine-formula": "0.7.0-nightly.202505021607",
64
- "@univerjs/sheets": "0.7.0-nightly.202505021607",
65
- "@univerjs/sheets-data-validation": "0.7.0-nightly.202505021607",
66
- "@univerjs/sheets-numfmt": "0.7.0-nightly.202505021607",
67
- "@univerjs/sheets-ui": "0.7.0-nightly.202505021607",
68
- "@univerjs/ui": "0.7.0-nightly.202505021607",
69
- "@univerjs/sheets-formula-ui": "0.7.0-nightly.202505021607"
59
+ "@univerjs/core": "0.7.0-nightly.202505031606",
60
+ "@univerjs/data-validation": "0.7.0-nightly.202505031606",
61
+ "@univerjs/design": "0.7.0-nightly.202505031606",
62
+ "@univerjs/engine-formula": "0.7.0-nightly.202505031606",
63
+ "@univerjs/sheets": "0.7.0-nightly.202505031606",
64
+ "@univerjs/sheets-formula-ui": "0.7.0-nightly.202505031606",
65
+ "@univerjs/engine-render": "0.7.0-nightly.202505031606",
66
+ "@univerjs/sheets-numfmt": "0.7.0-nightly.202505031606",
67
+ "@univerjs/sheets-data-validation": "0.7.0-nightly.202505031606",
68
+ "@univerjs/sheets-ui": "0.7.0-nightly.202505031606",
69
+ "@univerjs/ui": "0.7.0-nightly.202505031606"
70
70
  },
71
71
  "devDependencies": {
72
72
  "postcss": "^8.5.3",