@bluemarble/bi 0.6.6 → 0.7.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.
@@ -1,7 +1,7 @@
1
1
  import { 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_OPERATORS, E as VALUE_RULE_OPERATORS, S as NUMERIC_OPERATORS, T as UNARY_OPERATORS, a as FILTER_FIELDS, b as COLUMN_ALIGNS, c as chartColumns, f as filterReferences, g as percentColumn, h as layoutModelWarnings, i as CARD_FIELDS, l as chartOfType, n as CANVAS_PRESETS, o as cardsGap, r as CARDS_FIELDS, t as BUILTIN_CHART_TYPES, u as chartReferences, v as tableColumns, w as RULE_OPERATOR_LABEL, x as COLUMN_VERTICAL_ALIGNS, y as validateLayout } from "./layout-CrZ00tB0.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-DUGFHBo-.js";
3
+ import { C as DEFAULT_SCALE_MIN_COLOR, D as UNARY_OPERATORS, E as RULE_OPERATOR_LABEL, O as VALUE_RULE_OPERATORS, S as COLUMN_VERTICAL_ALIGNS, T as RULE_OPERATORS, a as FILTER_FIELDS, b as COLOR_SCALE_TARGETS, c as chartColumns, f as filterReferences, g as percentColumn, h as layoutModelWarnings, i as CARD_FIELDS, l as chartOfType, n as CANVAS_PRESETS, o as cardsGap, r as CARDS_FIELDS, t as BUILTIN_CHART_TYPES, u as chartReferences, v as tableColumns, w as NUMERIC_OPERATORS, x as COLUMN_ALIGNS, y as validateLayout } from "./layout-BS3nO6OT.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-Cw4sa8tW.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";
@@ -2182,6 +2182,11 @@ function FieldsForm({ fields, values, onSet: set, onSetMany, model, formatters,
2182
2182
  model,
2183
2183
  onChange: (rules) => set(key, rules.length ? rules : void 0)
2184
2184
  });
2185
+ case "colorScales": return /* @__PURE__ */ jsx(ColorScalesInput, {
2186
+ scales: value ?? [],
2187
+ columnOptions: columnOptionsOf(columns.filter((name) => model.dimensions[name]?.type !== "string")),
2188
+ onChange: (scales) => set(key, scales.length ? scales : void 0)
2189
+ });
2185
2190
  case "formatters": {
2186
2191
  const map = value ?? {};
2187
2192
  if (!chosenDimensions.length) return /* @__PURE__ */ jsx(Typography, {
@@ -2254,7 +2259,7 @@ function FieldsForm({ fields, values, onSet: set, onSetMany, model, formatters,
2254
2259
  ...pairedFormatters
2255
2260
  ].filter(Boolean));
2256
2261
  const sections = [...new Set(entries.filter(([key]) => !hidden.has(key)).map(([, spec]) => spec.section))];
2257
- const fullRow = (spec) => spec.kind === "dimensions" || spec.kind === "measures" || spec.kind === "formatters" || spec.kind === "formatRules" || spec.kind === "colors" || spec.kind === "valueRule";
2262
+ const fullRow = (spec) => spec.kind === "dimensions" || spec.kind === "measures" || spec.kind === "formatters" || spec.kind === "formatRules" || spec.kind === "colorScales" || spec.kind === "colors" || spec.kind === "valueRule";
2258
2263
  const gridColumn = (spec, key) => fullRow(spec) ? "1 / -1" : key === "title" && formColumns > 1 ? "span 2" : void 0;
2259
2264
  return /* @__PURE__ */ jsx(Fragment, { children: sections.map((section) => {
2260
2265
  const inSection = entries.filter(([, spec]) => spec.section === section);
@@ -2590,6 +2595,202 @@ function FormatRulesInput({ rules, fieldOptions, columnOptions, model, onChange
2590
2595
  })]
2591
2596
  });
2592
2597
  }
2598
+ const COLOR_SCALE_TARGET_LABEL = {
2599
+ background: "o fundo",
2600
+ text: "o texto"
2601
+ };
2602
+ const DEFAULT_SCALE_COLOR = "#2e7d32";
2603
+ /**
2604
+ * Escalas de cor (gradiente), uma por cartão: "pinta <o fundo | o texto> de <coluna> de <cor
2605
+ * mínima> (em <mínimo>) a <cor máxima> (em <máximo>)". Mínimo/máximo vazios = da própria coluna.
2606
+ */
2607
+ function ColorScalesInput({ scales, columnOptions, onChange }) {
2608
+ const update = (index, change) => onChange(scales.map((scale, i) => i === index ? change(scale) : scale));
2609
+ const columns = columnOptions.map((option) => option.name);
2610
+ const parseNumber = (text) => {
2611
+ const number = Number(text.trim().replace(",", "."));
2612
+ return text.trim() && Number.isFinite(number) ? number : void 0;
2613
+ };
2614
+ return /* @__PURE__ */ jsxs(Box, {
2615
+ sx: {
2616
+ display: "flex",
2617
+ flexDirection: "column",
2618
+ gap: .75,
2619
+ maxWidth: 760
2620
+ },
2621
+ children: [scales.map((scale, index) => {
2622
+ const minColor = scale.minColor ?? "#ffffff";
2623
+ const inverted = scale.min !== void 0 && scale.max !== void 0 && scale.min >= scale.max;
2624
+ return /* @__PURE__ */ jsxs(Box, {
2625
+ sx: {
2626
+ border: 1,
2627
+ borderColor: "divider",
2628
+ borderRadius: 1,
2629
+ p: .75,
2630
+ display: "flex",
2631
+ flexDirection: "column",
2632
+ gap: .5,
2633
+ "&:hover .row-actions": { visibility: "visible" }
2634
+ },
2635
+ children: [
2636
+ /* @__PURE__ */ jsxs(Box, {
2637
+ sx: {
2638
+ display: "flex",
2639
+ gap: .5,
2640
+ alignItems: "center",
2641
+ flexWrap: "wrap"
2642
+ },
2643
+ children: [
2644
+ /* @__PURE__ */ jsxs(Typography, {
2645
+ sx: {
2646
+ fontSize: 12,
2647
+ color: "text.secondary"
2648
+ },
2649
+ children: [index + 1, ". Pinta"]
2650
+ }),
2651
+ /* @__PURE__ */ jsx(TextField, {
2652
+ select: true,
2653
+ size: "small",
2654
+ value: scale.target ?? "background",
2655
+ onChange: (e) => update(index, (current) => withField(current, "target", e.target.value === "background" ? void 0 : e.target.value)),
2656
+ sx: {
2657
+ ...inputSx$1,
2658
+ flex: "1 1 100px"
2659
+ },
2660
+ children: COLOR_SCALE_TARGETS.map((target) => /* @__PURE__ */ jsx(MenuItem, {
2661
+ value: target,
2662
+ children: COLOR_SCALE_TARGET_LABEL[target]
2663
+ }, target))
2664
+ }),
2665
+ /* @__PURE__ */ jsx(Typography, {
2666
+ sx: {
2667
+ fontSize: 12,
2668
+ color: "text.secondary"
2669
+ },
2670
+ children: "de"
2671
+ }),
2672
+ /* @__PURE__ */ jsx(Box, {
2673
+ sx: { flex: "2 1 140px" },
2674
+ children: /* @__PURE__ */ jsx(NameSelect, {
2675
+ value: scale.column,
2676
+ options: columnOptions,
2677
+ required: true,
2678
+ onChange: (column) => update(index, (current) => ({
2679
+ ...current,
2680
+ column
2681
+ }))
2682
+ })
2683
+ }),
2684
+ /* @__PURE__ */ jsx(Box, {
2685
+ title: "Prévia do gradiente",
2686
+ sx: {
2687
+ flex: "1 1 80px",
2688
+ height: 20,
2689
+ border: 1,
2690
+ borderColor: "divider",
2691
+ borderRadius: .5,
2692
+ background: `linear-gradient(to right, ${minColor}, ${scale.color})`
2693
+ }
2694
+ }),
2695
+ /* @__PURE__ */ jsxs(Box, {
2696
+ className: "row-actions",
2697
+ sx: {
2698
+ display: "flex",
2699
+ visibility: "hidden"
2700
+ },
2701
+ children: [
2702
+ /* @__PURE__ */ jsx(SmallButton, {
2703
+ title: "Subir",
2704
+ disabled: index === 0,
2705
+ onClick: () => onChange(moveTo(scales, index, index - 1)),
2706
+ children: "↑"
2707
+ }),
2708
+ /* @__PURE__ */ jsx(SmallButton, {
2709
+ title: "Descer",
2710
+ disabled: index === scales.length - 1,
2711
+ onClick: () => onChange(moveTo(scales, index, index + 2)),
2712
+ children: "↓"
2713
+ }),
2714
+ /* @__PURE__ */ jsx(SmallButton, {
2715
+ title: "Remover",
2716
+ onClick: () => onChange(scales.filter((_, i) => i !== index)),
2717
+ children: "×"
2718
+ })
2719
+ ]
2720
+ })
2721
+ ]
2722
+ }),
2723
+ scale.column && !columns.includes(scale.column) && /* @__PURE__ */ jsxs(Typography, {
2724
+ sx: {
2725
+ fontSize: 11,
2726
+ color: "warning.main"
2727
+ },
2728
+ children: [
2729
+ "\"",
2730
+ scale.column,
2731
+ "\" não é coluna numérica do gráfico: nada é pintado"
2732
+ ]
2733
+ }),
2734
+ /* @__PURE__ */ jsxs(Box, {
2735
+ sx: {
2736
+ display: "grid",
2737
+ gap: .5,
2738
+ gridTemplateColumns: "repeat(auto-fit, minmax(130px, 1fr))",
2739
+ alignItems: "end"
2740
+ },
2741
+ children: [
2742
+ field("Cor mínima", /* @__PURE__ */ jsx(ColorInput, {
2743
+ value: scale.minColor,
2744
+ fallback: DEFAULT_SCALE_MIN_COLOR,
2745
+ onCommit: (color) => update(index, (current) => withField(current, "minColor", color === "#ffffff" ? void 0 : color))
2746
+ })),
2747
+ field("Mínimo", /* @__PURE__ */ jsx(CommitText, {
2748
+ value: scale.min === void 0 ? "" : String(scale.min),
2749
+ placeholder: "menor da coluna",
2750
+ error: inverted,
2751
+ onCommit: (text) => update(index, (current) => withField(current, "min", parseNumber(text)))
2752
+ })),
2753
+ field("Cor máxima", /* @__PURE__ */ jsx(ColorInput, {
2754
+ value: scale.color,
2755
+ fallback: DEFAULT_SCALE_COLOR,
2756
+ onCommit: (color) => update(index, (current) => ({
2757
+ ...current,
2758
+ color: color ?? DEFAULT_SCALE_COLOR
2759
+ }))
2760
+ })),
2761
+ field("Máximo", /* @__PURE__ */ jsx(CommitText, {
2762
+ value: scale.max === void 0 ? "" : String(scale.max),
2763
+ placeholder: "maior da coluna",
2764
+ error: inverted,
2765
+ onCommit: (text) => update(index, (current) => withField(current, "max", parseNumber(text)))
2766
+ }))
2767
+ ]
2768
+ }),
2769
+ inverted && /* @__PURE__ */ jsx(Typography, {
2770
+ sx: {
2771
+ fontSize: 11,
2772
+ color: "error.main"
2773
+ },
2774
+ children: "O mínimo precisa ser menor que o máximo"
2775
+ })
2776
+ ]
2777
+ }, index);
2778
+ }), /* @__PURE__ */ jsx(Button, {
2779
+ size: "small",
2780
+ variant: "outlined",
2781
+ disabled: !columnOptions.length,
2782
+ onClick: () => onChange([...scales, {
2783
+ column: columns.find((name) => !scales.some((scale) => scale.column === name)) ?? columns[0] ?? "",
2784
+ color: DEFAULT_SCALE_COLOR
2785
+ }]),
2786
+ sx: {
2787
+ alignSelf: "flex-start",
2788
+ textTransform: "none"
2789
+ },
2790
+ children: "+ escala"
2791
+ })]
2792
+ });
2793
+ }
2593
2794
  /** Campo de texto que só manda o valor no Enter ou ao sair (número parcial não vira valor). */
2594
2795
  function CommitText({ value, placeholder, error, onCommit }) {
2595
2796
  const [typing, setTyping] = useState(null);
@@ -8381,4 +8582,4 @@ function ToggleButton$1({ draft, loading, problems, inspecting, onOpen }) {
8381
8582
  //#endregion
8382
8583
  export { DashboardDevtools as default };
8383
8584
 
8384
- //# sourceMappingURL=DashboardDevtools-I00Iz0Z8.js.map
8585
+ //# sourceMappingURL=DashboardDevtools-D0pzwSgn.js.map