{"version":3,"file":"PivotPanel-eNbcIwjo.cjs","names":["PivotPanelChrome","IconButton","MenuItem","Stack","TextField","Typography","NO_SHRINK","flex","slots","Surface","children","className","rest","Zone","label","zone","m","minInlineSize","px","pt","pb","border","borderColor","borderRadius","Field","onMoveUp","onMoveDown","onRemove","moveUpLabel","moveDownLabel","removeLabel","aggregation","alignItems","flexWrap","minWidth","Add","options","onAdd","length","htmlInput","event","target","value","map","option","key","Agg","onChange","width","PivotPanel","props","$","_c","t0"],"sources":["../src/components/PivotPanel.tsx"],"sourcesContent":["/** The pivot configuration panel, in MUI. */\nimport {\n  type PivotAddProps,\n  type PivotAggProps,\n  type PivotFieldProps,\n  PivotPanelChrome,\n  type PivotPanelChromeProps,\n  type PivotPanelSlots,\n  type PivotPanelSurfaceProps,\n  type PivotZoneProps,\n} from \"@adapttable/core/adapter\";\nimport {\n  IconButton,\n  MenuItem,\n  Stack,\n  TextField,\n  Typography,\n} from \"@mui/material\";\n\n/** A control keeps the width of its own caption on a wrapping row. */\nconst NO_SHRINK = { flex: \"0 0 auto\" } as const;\n\nconst slots: PivotPanelSlots = {\n  Surface: ({ children, className, ...rest }: PivotPanelSurfaceProps) => (\n    <Stack spacing={1.5} className={className} {...rest}>\n      {children}\n    </Stack>\n  ),\n  // The fieldset groups the zone's fields for a screen reader; the outlined\n  // box is the one MUI already draws around a legend — the same border, radius\n  // and divider colour an outlined input uses — so the zone reads as a piece\n  // of the kit rather than the browser's default frame.\n  Zone: ({ label, children, zone, ...rest }: PivotZoneProps) => (\n    <Stack\n      component=\"fieldset\"\n      spacing={0.5}\n      data-pivot-zone={zone}\n      sx={{\n        m: 0,\n        minInlineSize: 0,\n        px: 1.5,\n        pt: 0.5,\n        pb: 1.5,\n        border: 1,\n        borderColor: \"divider\",\n        borderRadius: 1,\n      }}\n      {...rest}\n    >\n      <Typography\n        component=\"legend\"\n        variant=\"caption\"\n        color=\"text.secondary\"\n        sx={{ px: 0.5 }}\n      >\n        {label}\n      </Typography>\n      {children}\n    </Stack>\n  ),\n  Field: ({\n    label,\n    onMoveUp,\n    onMoveDown,\n    onRemove,\n    moveUpLabel,\n    moveDownLabel,\n    removeLabel,\n    aggregation,\n    ...rest\n  }: PivotFieldProps) => (\n    // A panel is as often in a sidebar as in a page, so the row wraps rather\n    // than squeezing: a field name and an aggregation that shrink to \"s…\" say\n    // less than the same controls on two lines.\n    <Stack\n      direction=\"row\"\n      spacing={0.5}\n      useFlexGap\n      sx={{ alignItems: \"center\", flexWrap: \"wrap\", minWidth: 0 }}\n      {...rest}\n    >\n      <Typography variant=\"body2\" sx={{ flex: \"1 1 auto\", minWidth: 0 }}>\n        {label}\n      </Typography>\n      {aggregation}\n      {/* Glyph-only controls are MUI's IconButton, not a text Button held to\n          its 64px minimum: three of those and an aggregation do not fit a\n          sidebar, and the field they belong to is what gets squeezed. */}\n      <IconButton\n        size=\"small\"\n        sx={NO_SHRINK}\n        aria-label={`${moveUpLabel}: ${label}`}\n        disabled={!onMoveUp}\n        onClick={onMoveUp}\n      >\n        {\"↑\"}\n      </IconButton>\n      <IconButton\n        size=\"small\"\n        sx={NO_SHRINK}\n        aria-label={`${moveDownLabel}: ${label}`}\n        disabled={!onMoveDown}\n        onClick={onMoveDown}\n      >\n        {\"↓\"}\n      </IconButton>\n      <IconButton\n        size=\"small\"\n        sx={NO_SHRINK}\n        aria-label={`${removeLabel}: ${label}`}\n        onClick={onRemove}\n      >\n        {\"✕\"}\n      </IconButton>\n    </Stack>\n  ),\n  Add: ({ label, options, onAdd }: PivotAddProps) => (\n    <TextField\n      select\n      size=\"small\"\n      label={label}\n      value=\"\"\n      disabled={options.length === 0}\n      slotProps={{ htmlInput: { \"aria-label\": label } }}\n      onChange={(event) => {\n        if (event.target.value) onAdd(event.target.value);\n      }}\n    >\n      {options.map((option) => (\n        <MenuItem key={option.key} value={option.key}>\n          {option.label}\n        </MenuItem>\n      ))}\n    </TextField>\n  ),\n  Agg: ({ label, value, options, onChange }: PivotAggProps) => (\n    <TextField\n      select\n      size=\"small\"\n      value={value}\n      sx={{ width: 100, ...NO_SHRINK }}\n      slotProps={{ htmlInput: { \"aria-label\": label } }}\n      onChange={(event) => {\n        onChange(event.target.value as (typeof options)[number]);\n      }}\n    >\n      {options.map((option) => (\n        <MenuItem key={option} value={option}>\n          {option}\n        </MenuItem>\n      ))}\n    </TextField>\n  ),\n};\n\n/** Configure a pivot: three zones, and buttons that move fields between them. */\nexport function PivotPanel(\n  props: Readonly<Omit<PivotPanelChromeProps, \"slots\">>\n) {\n  return <PivotPanelChrome {...props} slots={slots} />;\n}\n"],"mappings":";;;;;;;;AAoBA,MAAMM,YAAY,EAAEC,MAAM,WAAW;AAErC,MAAMC,QAAyB;CAC7BC,UAAU,EAAEC,UAAUC,WAAW,GAAGC,WAClC,iBAAA,GAAA,kBAAA,IAAA,CAAC,cAAA,OAAD;EAAO,SAAS;EAAgBD;EAAW,GAAIC;EAC5CF;CACI,CAAA;CAMTG,OAAO,EAAEC,OAAOJ,UAAUK,MAAM,GAAGH,WACjC,iBAAA,GAAA,kBAAA,KAAA,CAAC,cAAA,OAAD;EACE,WAAU;EACV,SAAS;EACT,mBAAiBG;EACjB,IAAI;GACFC,GAAG;GACHC,eAAe;GACfC,IAAI;GACJC,IAAI;GACJC,IAAI;GACJC,QAAQ;GACRC,aAAa;GACbC,cAAc;EAChB;EACA,GAAIX;YAdN,CAgBE,iBAAA,GAAA,kBAAA,IAAA,CAAC,cAAA,YAAD;GACE,WAAU;GACV,SAAQ;GACR,OAAM;GACN,IAAI,EAAEM,IAAI,GAAI;aAEbJ;EACS,CAAA,GACXJ,QACI;;CAETc,QAAQ,EACNV,OACAW,UACAC,YACAC,UACAC,aACAC,eACAC,aACAC,aACA,GAAGnB,WAKH,iBAAA,GAAA,kBAAA,KAAA,CAAC,cAAA,OAAD;EACE,WAAU;EACV,SAAS;EACT,YAAA;EACA,IAAI;GAAEoB,YAAY;GAAUC,UAAU;GAAQC,UAAU;EAAE;EAC1D,GAAItB;YALN;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