@bluemarble/bi 0.6.3 → 0.6.5

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.
@@ -1,7 +1,7 @@
1
- import { a as toModelCode, c as VALUE_FORMATS, f as validateModel, g as parseColumnRef, h as modelEdges, m as measureHome, o as AGGREGATIONS, s as AGGREGATION_LABEL, t as canonicalJson, u as isAggregate, v as referencedTables } from "./codegen-DkfI6UJr.js";
1
+ import { a as toModelCode, c as VALUE_FORMATS, f as validateModel, g as parseColumnRef, h as modelEdges, m as measureHome, o as AGGREGATIONS, s as AGGREGATION_LABEL, t as canonicalJson, u as isAggregate, v as referencedTables } from "./codegen-LoQzFAle.js";
2
2
  import { n as diffRows } from "./compare-DloZhg1T.js";
3
- import { C as RULE_OPERATOR_LABEL, S as RULE_OPERATORS, _ as tableColumns, a as FILTER_FIELDS, b as COLUMN_VERTICAL_ALIGNS, c as chartOfType, d as filterReferences, h as percentColumn, i as CARD_FIELDS, l as chartReferences, m as layoutModelWarnings, n as CANVAS_PRESETS, p as layoutFileContent, r as CARDS_FIELDS, s as chartColumns, t as BUILTIN_CHART_TYPES, v as validateLayout, w as UNARY_OPERATORS, x as NUMERIC_OPERATORS, y as COLUMN_ALIGNS } from "./layout-DAFeHIuP.js";
4
- import { d as useDashboard, f as errorMessage, h as parseLayoutItemKey, m as layoutItemKey, n as INSPECT_ATTRIBUTE, o as formatMeasure, p as LAYOUT_ITEM_ATTRIBUTE, t as ModelDictionary } from "./ModelDictionary-Dc3_LKqr.js";
3
+ import { C as RULE_OPERATOR_LABEL, S as RULE_OPERATORS, _ as tableColumns, a as FILTER_FIELDS, b as COLUMN_VERTICAL_ALIGNS, c as chartOfType, d as filterReferences, h as percentColumn, i as CARD_FIELDS, l as chartReferences, m as layoutModelWarnings, n as CANVAS_PRESETS, p as layoutFileContent, r as CARDS_FIELDS, s as chartColumns, t as BUILTIN_CHART_TYPES, v as validateLayout, w as UNARY_OPERATORS, x as NUMERIC_OPERATORS, y as COLUMN_ALIGNS } from "./layout-CBzYDoqE.js";
4
+ import { C as parseLayoutItemKey, S as layoutItemKey, b as errorMessage, f as SERIES_COLORS, n as INSPECT_ATTRIBUTE, o as formatMeasure, t as ModelDictionary, x as LAYOUT_ITEM_ATTRIBUTE, y as useDashboard } from "./ModelDictionary-CyeYU6ZJ.js";
5
5
  import { Alert, Autocomplete, Box, Button, Checkbox, Chip, CircularProgress, Collapse, Dialog, DialogActions, DialogContent, DialogTitle, Divider, FormControlLabel, IconButton, List, ListItemButton, ListSubheader, Menu, MenuItem, MenuList, Paper, Popover, Popper, Portal, Switch, Tab, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, TableSortLabel, Tabs, TextField, ThemeProvider, ToggleButton, ToggleButtonGroup, Tooltip, Typography, createTheme } from "@mui/material";
6
6
  import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
7
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -1910,6 +1910,8 @@ function FieldsForm({ fields, values, onSet: set, onSetMany, model, formatters,
1910
1910
  const formattersKey = columnOptions ? keyOf("formatters") : void 0;
1911
1911
  const single = (kind) => entries.filter(([, spec]) => spec.kind === kind);
1912
1912
  const formatterKey = columnOptions && single("dimension").length === 1 && single("formatter").length === 1 ? single("formatter")[0]?.[0] : void 0;
1913
+ const formatterOf = (fieldKey) => columnOptions && fieldKey && entries.find(([, spec]) => spec.kind === "formatter" && spec.of === fieldKey)?.[0] || formatterKey;
1914
+ const pairedFormatters = columnOptions ? entries.filter(([, spec]) => spec.kind === "formatter" && spec.of).map(([key]) => key) : [];
1913
1915
  const labels = labelsKey && values[labelsKey] || {};
1914
1916
  const formats = formatsKey && values[formatsKey] || {};
1915
1917
  const aligns = alignsKey && values[alignsKey] || {};
@@ -1930,8 +1932,9 @@ function FieldsForm({ fields, values, onSet: set, onSetMany, model, formatters,
1930
1932
  else for (const [key, value] of Object.entries(changes)) set(key, value);
1931
1933
  };
1932
1934
  const dimensionFormatters = formattersKey && values[formattersKey] || {};
1933
- const optionsButton = (kind, name) => {
1935
+ const optionsButton = (kind, name, fieldKey) => {
1934
1936
  if (!columnOptions || !name) return null;
1937
+ const formatterKey = formatterOf(fieldKey);
1935
1938
  if (kind === "percent") {
1936
1939
  if (!alignsKey && !verticalKey) return null;
1937
1940
  const column = percentColumn(name);
@@ -2152,6 +2155,11 @@ function FieldsForm({ fields, values, onSet: set, onSetMany, model, formatters,
2152
2155
  }
2153
2156
  });
2154
2157
  }
2158
+ case "colors": return /* @__PURE__ */ jsx(ColorsInput, {
2159
+ colors: value ?? {},
2160
+ measures: spec.values && values[spec.values] ? null : chosenMeasures,
2161
+ onChange: (next) => set(key, Object.keys(next).length ? next : void 0)
2162
+ });
2155
2163
  case "formatRules": return /* @__PURE__ */ jsx(FormatRulesInput, {
2156
2164
  rules: value ?? [],
2157
2165
  fieldOptions,
@@ -2206,7 +2214,7 @@ function FieldsForm({ fields, values, onSet: set, onSetMany, model, formatters,
2206
2214
  emptyLabel: spec.kind === "enum" && spec.default ? `padrão (${spec.labels?.[spec.default] ?? spec.default})` : void 0,
2207
2215
  onChange: (name) => set(key, name === spec.default ? void 0 : name)
2208
2216
  });
2209
- const button = spec.kind === "dimension" || spec.kind === "measure" ? optionsButton(spec.kind, value) : null;
2217
+ const button = spec.kind === "dimension" || spec.kind === "measure" ? optionsButton(spec.kind, value, key) : null;
2210
2218
  return button ? /* @__PURE__ */ jsxs(Box, {
2211
2219
  sx: {
2212
2220
  display: "flex",
@@ -2227,10 +2235,11 @@ function FieldsForm({ fields, values, onSet: set, onSetMany, model, formatters,
2227
2235
  alignsKey,
2228
2236
  verticalKey,
2229
2237
  formattersKey,
2230
- formatterKey
2238
+ formatterKey,
2239
+ ...pairedFormatters
2231
2240
  ].filter(Boolean));
2232
2241
  const sections = [...new Set(entries.filter(([key]) => !hidden.has(key)).map(([, spec]) => spec.section))];
2233
- const fullRow = (spec) => spec.kind === "dimensions" || spec.kind === "measures" || spec.kind === "formatters" || spec.kind === "formatRules";
2242
+ const fullRow = (spec) => spec.kind === "dimensions" || spec.kind === "measures" || spec.kind === "formatters" || spec.kind === "formatRules" || spec.kind === "colors";
2234
2243
  const gridColumn = (spec, key) => fullRow(spec) ? "1 / -1" : key === "title" && formColumns > 1 ? "span 2" : void 0;
2235
2244
  return /* @__PURE__ */ jsx(Fragment, { children: sections.map((section) => {
2236
2245
  const inSection = entries.filter(([, spec]) => spec.section === section);
@@ -2653,6 +2662,99 @@ function ColorInput({ value, fallback, onCommit }) {
2653
2662
  })]
2654
2663
  });
2655
2664
  }
2665
+ /**
2666
+ * Cor por série (`{ série: cor }`). `measures`: uma linha por medida do gráfico (padrão: a paleta,
2667
+ * na ordem); `null`: as séries são valores de uma dimensão, que o devtools não conhece — digita o
2668
+ * valor e adiciona.
2669
+ */
2670
+ function ColorsInput({ colors, measures, onChange }) {
2671
+ const [draft, setDraft] = useState("");
2672
+ const palette = (index) => SERIES_COLORS[index % SERIES_COLORS.length];
2673
+ const row = (name, fallback, remove) => /* @__PURE__ */ jsxs(Box, {
2674
+ sx: {
2675
+ display: "flex",
2676
+ gap: .5,
2677
+ alignItems: "center"
2678
+ },
2679
+ children: [
2680
+ /* @__PURE__ */ jsx(Typography, {
2681
+ title: name,
2682
+ sx: {
2683
+ fontFamily: MONO,
2684
+ fontSize: 12,
2685
+ minWidth: 90,
2686
+ maxWidth: 140,
2687
+ overflow: "hidden",
2688
+ textOverflow: "ellipsis",
2689
+ whiteSpace: "nowrap"
2690
+ },
2691
+ children: name
2692
+ }),
2693
+ /* @__PURE__ */ jsx(ColorInput, {
2694
+ value: colors[name],
2695
+ fallback,
2696
+ onCommit: (color) => onChange(withField(colors, name, color))
2697
+ }),
2698
+ remove && /* @__PURE__ */ jsx(IconButton, {
2699
+ size: "small",
2700
+ title: "Tirar a cor",
2701
+ onClick: () => onChange(withField(colors, name, void 0)),
2702
+ children: "✕"
2703
+ })
2704
+ ]
2705
+ }, name);
2706
+ const add = () => {
2707
+ const name = draft.trim();
2708
+ if (!name || colors[name]) return;
2709
+ onChange({
2710
+ ...colors,
2711
+ [name]: palette(Object.keys(colors).length)
2712
+ });
2713
+ setDraft("");
2714
+ };
2715
+ if (measures) return /* @__PURE__ */ jsx(Box, {
2716
+ sx: {
2717
+ display: "flex",
2718
+ flexDirection: "column",
2719
+ gap: .5
2720
+ },
2721
+ children: measures.length ? measures.map((measure, index) => row(measure, palette(index), false)) : /* @__PURE__ */ jsx(Typography, {
2722
+ sx: {
2723
+ fontSize: 12,
2724
+ color: "text.disabled"
2725
+ },
2726
+ children: "sem medidas"
2727
+ })
2728
+ });
2729
+ return /* @__PURE__ */ jsxs(Box, {
2730
+ sx: {
2731
+ display: "flex",
2732
+ flexDirection: "column",
2733
+ gap: .5
2734
+ },
2735
+ children: [Object.keys(colors).map((name, index) => row(name, palette(index), true)), /* @__PURE__ */ jsxs(Box, {
2736
+ sx: {
2737
+ display: "flex",
2738
+ gap: .5,
2739
+ alignItems: "center"
2740
+ },
2741
+ children: [/* @__PURE__ */ jsx(TextField, {
2742
+ size: "small",
2743
+ fullWidth: true,
2744
+ value: draft,
2745
+ placeholder: "Valor da série (ou \"(em branco)\", \"Outros\")",
2746
+ onChange: (e) => setDraft(e.target.value),
2747
+ onKeyDown: (e) => e.key === "Enter" && add(),
2748
+ sx: inputSx$1
2749
+ }), /* @__PURE__ */ jsx(Button, {
2750
+ size: "small",
2751
+ onClick: add,
2752
+ disabled: !draft.trim() || !!colors[draft.trim()],
2753
+ children: "+ cor"
2754
+ })]
2755
+ })]
2756
+ });
2757
+ }
2656
2758
  /** Sem as chaves de colunas que saíram do gráfico; vazio = `undefined` (sai do JSON). */
2657
2759
  function pruned(map, keep) {
2658
2760
  const next = Object.fromEntries(Object.entries(map).filter(([key]) => keep.includes(key)));
@@ -8193,4 +8295,4 @@ function ToggleButton$1({ draft, loading, problems, inspecting, onOpen }) {
8193
8295
  //#endregion
8194
8296
  export { DashboardDevtools as default };
8195
8297
 
8196
- //# sourceMappingURL=DashboardDevtools-Osu5V30U.js.map
8298
+ //# sourceMappingURL=DashboardDevtools-CMIuUYpw.js.map