"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[4756],{14756(L,b,s){s.d(b,{PartitionByValuesEditor:()=>g});var l=s(74848),n=s(96540),t=s(52358),c=s(45270),O=s(34788),P=s(68763),h=s(61191),d=s(72480),o=s(6634),m=s(23820),_=s(48368);function g({input:u,options:a,onChange:r}){const D=(0,_.sE)(u),f=(0,_.Av)(D),v=(0,n.useMemo)(()=>{const e=new Set(a.fields);return e.size<1?f:f.filter(i=>!e.has(i.value))},[f,a]),M=(0,n.useCallback)(e=>{if(!e.value)return;const i=new Set(a.fields);i.add(e.value),r({...a,fields:[...i]})},[r,a]);let E;(e=>{e[e.asLabels=0]="asLabels",e[e.frameName=1]="frameName"})(E||(E={}));const y=[{label:(0,t.t)("transformers.partition-by-values-editor.naming-modes-options.label.as-label","As label"),value:0},{label:(0,t.t)("transformers.partition-by-values-editor.naming-modes-options.label.as-frame-name","As frame name"),value:1}],p=[{label:(0,t.t)("transformers.partition-by-values-editor.keep-fields-options.label.yes","Yes"),value:!0},{label:(0,t.t)("transformers.partition-by-values-editor.keep-fields-options.label.no","No"),value:!1}],C=(0,n.useCallback)(e=>{if(!e)return;const i=new Set(a.fields);i.delete(e),r({...a,fields:[...i]})},[r,a]);if(u.length>1)return(0,l.jsx)(h.P,{children:(0,l.jsx)(t.x6,{i18nKey:"transformers.partition-by-values-editor.partition-values-works-single-frame",children:"Partition by values only works with a single frame."})});const x=[...new Set(a.fields)];return(0,l.jsxs)("div",{children:[(0,l.jsx)(o.C,{children:(0,l.jsx)(d.I,{label:(0,t.t)("transformers.partition-by-values-editor.label-field","Field"),labelWidth:10,grow:!0,children:(0,l.jsxs)(P.B,{children:[x.map(e=>(0,l.jsx)(c.$n,{icon:"times",variant:"secondary",size:"md",onClick:()=>C(e),children:e},e)),v.length&&(0,l.jsx)(O.i,{variant:"secondary",size:"md",options:v,onChange:M,label:(0,t.t)("transformers.partition-by-values-editor.label-select-field","Select field"),icon:"plus",isFullWidth:!1})]})})}),(0,l.jsx)(o.C,{children:(0,l.jsx)(d.I,{tooltip:(0,t.t)("transformers.partion-by-values-editor.tooltip-naming","Sets how the names of the selected fields are displayed. As frame name is usually better for tabular data"),label:(0,t.t)("transformers.partition-by-values-editor.label-naming","Naming"),labelWidth:10,children:(0,l.jsx)(m.z,{options:y,value:a.naming?.asLabels===void 0||a.naming.asLabels?0:1,onChange:e=>r({...a,naming:{...a.naming,asLabels:e===0}})})})}),(0,l.jsx)(o.C,{children:(0,l.jsx)(d.I,{tooltip:(0,t.t)("transformers.partition-by-values-editor.tooltip-keeps-partition-fields-frames","Keeps the partition fields in the frames"),label:(0,t.t)("transformers.partition-by-values-editor.label-keep-fields","Keep fields"),labelWidth:16,children:(0,l.jsx)(m.z,{options:p,value:a.keepFields,onChange:e=>r({...a,keepFields:e})})})})]})}}}]);

//# sourceMappingURL=4756.d3aae7df659812d4b857.js.map