@ya-grid/core 0.3.1 → 0.5.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.
package/dist/index.js CHANGED
@@ -65,7 +65,7 @@ var ColumnController = class {
65
65
  });
66
66
  this.columns = [...system, ...ordered];
67
67
  }
68
- setColumnDefs(columnDefs, defaultColDef, selectionConfig, masterDetail = false) {
68
+ setColumnDefs(columnDefs, defaultColDef, selectionConfig, masterDetail = false, columnTypes) {
69
69
  const usedIds = /* @__PURE__ */ new Set();
70
70
  const resolved = [];
71
71
  if (selectionConfig?.checkboxes) {
@@ -112,6 +112,22 @@ var ColumnController = class {
112
112
  }
113
113
  let leafIdx = 0;
114
114
  let groupCounter = 0;
115
+ const resolveTypeDefs = (typeSpec, visited = /* @__PURE__ */ new Set()) => {
116
+ if (!typeSpec || !columnTypes) return {};
117
+ const names = Array.isArray(typeSpec) ? typeSpec : [typeSpec];
118
+ let acc = {};
119
+ for (const name of names) {
120
+ if (visited.has(name)) continue;
121
+ const preset = columnTypes[name];
122
+ if (!preset) continue;
123
+ visited.add(name);
124
+ if (preset.type) {
125
+ acc = { ...acc, ...resolveTypeDefs(preset.type, visited) };
126
+ }
127
+ acc = { ...acc, ...preset };
128
+ }
129
+ return acc;
130
+ };
115
131
  const visit = (items, groupPath) => {
116
132
  for (const item of items) {
117
133
  if (isColGroupDef(item)) {
@@ -123,8 +139,10 @@ var ColumnController = class {
123
139
  visit(item.children, [...groupPath, groupMeta]);
124
140
  continue;
125
141
  }
142
+ const typeDef = resolveTypeDefs(item.type ?? defaultColDef?.type);
126
143
  const merged = {
127
144
  ...defaultColDef,
145
+ ...typeDef,
128
146
  ...item
129
147
  };
130
148
  const baseId = merged.colId ?? merged.field ?? `col_${leafIdx}`;
@@ -457,6 +475,525 @@ var ColumnController = class {
457
475
  }
458
476
  };
459
477
 
478
+ // src/columns/column-types.ts
479
+ var VANILLA_RENDERER_SYMBOL = /* @__PURE__ */ Symbol.for("ya-grid.vanilla-renderer");
480
+ function markVanillaRenderer(fn) {
481
+ Object.defineProperty(fn, VANILLA_RENDERER_SYMBOL, { value: true, configurable: true });
482
+ return fn;
483
+ }
484
+ function toFiniteNumber(value) {
485
+ if (typeof value === "number") return Number.isFinite(value) ? value : null;
486
+ if (typeof value === "string" && value.trim() !== "") {
487
+ const n = Number(value);
488
+ return Number.isFinite(n) ? n : null;
489
+ }
490
+ return null;
491
+ }
492
+ function signClassFor(value, colorizeSign) {
493
+ const classes = ["ya-col-numeric"];
494
+ if (!colorizeSign) return classes;
495
+ const n = toFiniteNumber(value);
496
+ if (n === null) return classes;
497
+ if (n > 0) classes.push("ya-num-pos");
498
+ else if (n < 0) classes.push("ya-num-neg");
499
+ else classes.push("ya-num-zero");
500
+ return classes;
501
+ }
502
+ function currencyColumn(options = {}) {
503
+ const {
504
+ locale = "en-US",
505
+ currency = "USD",
506
+ minimumFractionDigits = 0,
507
+ maximumFractionDigits = options.compact ? 1 : 2,
508
+ currencySign = "standard",
509
+ signDisplay = "auto",
510
+ compact = false,
511
+ colorizeSign = false,
512
+ align = "right"
513
+ } = options;
514
+ const formatter = new Intl.NumberFormat(locale, {
515
+ style: "currency",
516
+ currency,
517
+ minimumFractionDigits,
518
+ maximumFractionDigits,
519
+ currencySign,
520
+ signDisplay,
521
+ notation: compact ? "compact" : "standard"
522
+ });
523
+ return {
524
+ dataType: "number",
525
+ filter: "number",
526
+ cellEditor: "number",
527
+ align,
528
+ cellClass: ({ value }) => signClassFor(value, colorizeSign),
529
+ valueFormatter: ({ value }) => {
530
+ const n = toFiniteNumber(value);
531
+ return n === null ? "" : formatter.format(n);
532
+ }
533
+ };
534
+ }
535
+ function percentColumn(options = {}) {
536
+ const {
537
+ scale = "percent",
538
+ locale = "en-US",
539
+ minimumFractionDigits = 0,
540
+ maximumFractionDigits = 1,
541
+ signDisplay = "auto",
542
+ colorizeSign = false,
543
+ align = "right"
544
+ } = options;
545
+ const formatter = new Intl.NumberFormat(locale, {
546
+ style: "percent",
547
+ minimumFractionDigits,
548
+ maximumFractionDigits,
549
+ signDisplay
550
+ });
551
+ return {
552
+ dataType: "number",
553
+ filter: "number",
554
+ cellEditor: "number",
555
+ align,
556
+ cellClass: ({ value }) => signClassFor(value, colorizeSign),
557
+ valueFormatter: ({ value }) => {
558
+ const n = toFiniteNumber(value);
559
+ if (n === null) return "";
560
+ return formatter.format(scale === "percent" ? n / 100 : n);
561
+ }
562
+ };
563
+ }
564
+ function barColumn(options = {}) {
565
+ const {
566
+ min = 0,
567
+ max = 100,
568
+ showValue = true,
569
+ valueFormatter,
570
+ color,
571
+ thresholds,
572
+ height = 6
573
+ } = options;
574
+ const formatNum = (n) => {
575
+ if (valueFormatter) return valueFormatter(n);
576
+ if (min === 0 && max === 100) return `${Math.round(n)}%`;
577
+ return String(n);
578
+ };
579
+ const resolveTone = (n) => {
580
+ if (!thresholds) return "accent";
581
+ const { warn, danger, invert } = thresholds;
582
+ if (invert) {
583
+ if (danger !== void 0 && n <= danger) return "danger";
584
+ if (warn !== void 0 && n <= warn) return "warning";
585
+ return "success";
586
+ }
587
+ if (danger !== void 0 && n >= danger) return "danger";
588
+ if (warn !== void 0 && n >= warn) return "warning";
589
+ return "success";
590
+ };
591
+ const renderer = markVanillaRenderer(
592
+ ({ value, formattedValue }) => {
593
+ const n = toFiniteNumber(value);
594
+ if (n === null) return "";
595
+ const span = max - min;
596
+ const pct = span > 0 ? Math.min(100, Math.max(0, (n - min) / span * 100)) : 0;
597
+ const wrap = document.createElement("div");
598
+ wrap.className = "ya-bar-cell";
599
+ const track = document.createElement("div");
600
+ track.className = "ya-bar-track";
601
+ track.setAttribute("role", "progressbar");
602
+ track.setAttribute("aria-valuemin", String(min));
603
+ track.setAttribute("aria-valuemax", String(max));
604
+ track.setAttribute("aria-valuenow", String(n));
605
+ if (height !== 6) track.style.height = `${height}px`;
606
+ const fill = document.createElement("div");
607
+ fill.className = "ya-bar-fill";
608
+ fill.dataset.tone = resolveTone(n);
609
+ fill.style.width = `${pct.toFixed(1)}%`;
610
+ if (color) fill.style.backgroundColor = color;
611
+ track.appendChild(fill);
612
+ wrap.appendChild(track);
613
+ if (showValue) {
614
+ const label = document.createElement("span");
615
+ label.className = "ya-bar-value";
616
+ label.textContent = formattedValue || formatNum(n);
617
+ wrap.appendChild(label);
618
+ }
619
+ return wrap;
620
+ }
621
+ );
622
+ return {
623
+ dataType: "number",
624
+ filter: "number",
625
+ cellEditor: "number",
626
+ valueFormatter: ({ value }) => {
627
+ const n = toFiniteNumber(value);
628
+ return n === null ? "" : formatNum(n);
629
+ },
630
+ cellRenderer: renderer
631
+ };
632
+ }
633
+ function badgeColumn(options = {}) {
634
+ const { map = {}, defaultTone = "neutral", dot = false } = options;
635
+ const renderer = markVanillaRenderer(
636
+ ({ value, formattedValue }) => {
637
+ if (value === null || value === void 0 || value === "") return "";
638
+ const key = String(value);
639
+ const entry = map[key];
640
+ const cfg = typeof entry === "string" ? { tone: entry } : entry ?? {};
641
+ const tone = cfg.tone ?? defaultTone;
642
+ const text = cfg.label ?? (formattedValue || key);
643
+ const pill = document.createElement("span");
644
+ pill.className = "ya-badge";
645
+ pill.dataset.tone = tone;
646
+ if (cfg.bg) pill.style.backgroundColor = cfg.bg;
647
+ if (cfg.color) pill.style.color = cfg.color;
648
+ if (dot) {
649
+ const dotEl = document.createElement("span");
650
+ dotEl.className = "ya-badge-dot";
651
+ dotEl.setAttribute("aria-hidden", "true");
652
+ pill.appendChild(dotEl);
653
+ }
654
+ pill.appendChild(document.createTextNode(text));
655
+ return pill;
656
+ }
657
+ );
658
+ return {
659
+ filter: "set",
660
+ cellRenderer: renderer
661
+ };
662
+ }
663
+ var SVG_NS = "http://www.w3.org/2000/svg";
664
+ function booleanColumn(options = {}) {
665
+ const { style = "icon", trueLabel = "Yes", falseLabel = "No" } = options;
666
+ const renderer = markVanillaRenderer(
667
+ ({ value }) => {
668
+ if (value === null || value === void 0) return "";
669
+ const truthy = Boolean(value);
670
+ const label = truthy ? trueLabel : falseLabel;
671
+ if (style === "text") {
672
+ const span = document.createElement("span");
673
+ span.className = truthy ? "ya-bool-text ya-bool-true" : "ya-bool-text ya-bool-false";
674
+ span.textContent = label;
675
+ return span;
676
+ }
677
+ if (style === "pill") {
678
+ const pill = document.createElement("span");
679
+ pill.className = "ya-badge";
680
+ pill.dataset.tone = truthy ? "success" : "neutral";
681
+ pill.textContent = label;
682
+ return pill;
683
+ }
684
+ const wrap = document.createElement("span");
685
+ wrap.className = truthy ? "ya-bool-icon ya-bool-true" : "ya-bool-icon ya-bool-false";
686
+ wrap.setAttribute("role", "img");
687
+ wrap.setAttribute("aria-label", label);
688
+ wrap.title = label;
689
+ const svg = document.createElementNS(SVG_NS, "svg");
690
+ svg.setAttribute("width", "15");
691
+ svg.setAttribute("height", "15");
692
+ svg.setAttribute("viewBox", "0 0 16 16");
693
+ svg.setAttribute("fill", "none");
694
+ svg.setAttribute("aria-hidden", "true");
695
+ const path = document.createElementNS(SVG_NS, "path");
696
+ path.setAttribute("d", truthy ? "M3.5 8.5 6.5 11.5 12.5 4.5" : "M4.5 8h7");
697
+ path.setAttribute("stroke", "currentColor");
698
+ path.setAttribute("stroke-width", "2");
699
+ path.setAttribute("stroke-linecap", "round");
700
+ path.setAttribute("stroke-linejoin", "round");
701
+ svg.appendChild(path);
702
+ wrap.appendChild(svg);
703
+ return wrap;
704
+ }
705
+ );
706
+ return {
707
+ dataType: "boolean",
708
+ align: "center",
709
+ filter: "set",
710
+ cellEditor: "checkbox",
711
+ valueFormatter: ({ value }) => {
712
+ if (value === null || value === void 0) return "";
713
+ return value ? trueLabel : falseLabel;
714
+ },
715
+ cellRenderer: renderer
716
+ };
717
+ }
718
+ function extractSeries(value) {
719
+ if (!Array.isArray(value)) return [];
720
+ const nums = [];
721
+ for (const item of value) {
722
+ const n = toFiniteNumber(item);
723
+ if (n !== null) nums.push(n);
724
+ }
725
+ return nums;
726
+ }
727
+ function sparklineColumn(options = {}) {
728
+ const {
729
+ variant = "area",
730
+ width = 88,
731
+ height = 22,
732
+ strokeWidth = 1.6,
733
+ color,
734
+ trendColor = true,
735
+ showLastValue = false,
736
+ valueFormatter = (v) => String(Math.round(v * 10) / 10)
737
+ } = options;
738
+ const renderer = markVanillaRenderer(
739
+ ({ value }) => {
740
+ const series = extractSeries(value);
741
+ if (series.length === 0) return "";
742
+ const first = series[0];
743
+ const last = series[series.length - 1];
744
+ let minVal = first;
745
+ let maxVal = first;
746
+ for (let i = 1; i < series.length; i++) {
747
+ const v = series[i];
748
+ if (v < minVal) minVal = v;
749
+ if (v > maxVal) maxVal = v;
750
+ }
751
+ const trend = last > first ? "up" : last < first ? "down" : "flat";
752
+ const wrap = document.createElement("div");
753
+ wrap.className = "ya-sparkline-cell";
754
+ if (trendColor && !color) {
755
+ wrap.dataset.trend = trend;
756
+ }
757
+ if (color) {
758
+ wrap.style.color = color;
759
+ }
760
+ const svg = document.createElementNS(SVG_NS, "svg");
761
+ svg.setAttribute("class", "ya-sparkline-svg");
762
+ svg.setAttribute("width", String(width));
763
+ svg.setAttribute("height", String(height));
764
+ svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
765
+ svg.setAttribute("role", "img");
766
+ svg.setAttribute(
767
+ "aria-label",
768
+ `Trend: ${valueFormatter(first)} to ${valueFormatter(last)} (min ${valueFormatter(minVal)}, max ${valueFormatter(maxVal)})`
769
+ );
770
+ const padY = 2.5;
771
+ const innerH = Math.max(1, height - padY * 2);
772
+ const range = maxVal - minVal;
773
+ if (variant === "bar") {
774
+ const gap = 1.5;
775
+ const barW = Math.max(1.5, (width - gap * (series.length - 1)) / series.length);
776
+ const baseline = Math.min(minVal, 0);
777
+ const barSpan = Math.max(1e-6, maxVal - baseline);
778
+ for (let i = 0; i < series.length; i++) {
779
+ const v = series[i];
780
+ const h = Math.max(2, (v - baseline) / barSpan * innerH);
781
+ const rect = document.createElementNS(SVG_NS, "rect");
782
+ rect.setAttribute("x", (i * (barW + gap)).toFixed(1));
783
+ rect.setAttribute("y", (height - padY - h).toFixed(1));
784
+ rect.setAttribute("width", barW.toFixed(1));
785
+ rect.setAttribute("height", h.toFixed(1));
786
+ rect.setAttribute("rx", "1");
787
+ rect.setAttribute("fill", "currentColor");
788
+ rect.setAttribute("fill-opacity", i === series.length - 1 ? "1" : "0.68");
789
+ svg.appendChild(rect);
790
+ }
791
+ } else {
792
+ const padX = 2;
793
+ const innerW = Math.max(1, width - padX * 2);
794
+ const stepX = series.length > 1 ? innerW / (series.length - 1) : 0;
795
+ const points = series.map((v, i) => {
796
+ const x = series.length > 1 ? padX + i * stepX : width / 2;
797
+ const norm = range > 0 ? (v - minVal) / range : 0.5;
798
+ const y = padY + (1 - norm) * innerH;
799
+ return [x, y];
800
+ });
801
+ const linePath = points.map(([x, y], i) => `${i === 0 ? "M" : "L"}${x.toFixed(1)} ${y.toFixed(1)}`).join(" ");
802
+ if (variant === "area" && points.length > 1) {
803
+ const firstPt = points[0];
804
+ const lastPt2 = points[points.length - 1];
805
+ const area = document.createElementNS(SVG_NS, "path");
806
+ area.setAttribute(
807
+ "d",
808
+ `${linePath} L${lastPt2[0].toFixed(1)} ${(height - padY).toFixed(1)} L${firstPt[0].toFixed(1)} ${(height - padY).toFixed(1)} Z`
809
+ );
810
+ area.setAttribute("fill", "currentColor");
811
+ area.setAttribute("fill-opacity", "0.16");
812
+ svg.appendChild(area);
813
+ }
814
+ if (points.length > 1) {
815
+ const stroke = document.createElementNS(SVG_NS, "path");
816
+ stroke.setAttribute("d", linePath);
817
+ stroke.setAttribute("fill", "none");
818
+ stroke.setAttribute("stroke", "currentColor");
819
+ stroke.setAttribute("stroke-width", String(strokeWidth));
820
+ stroke.setAttribute("stroke-linecap", "round");
821
+ stroke.setAttribute("stroke-linejoin", "round");
822
+ svg.appendChild(stroke);
823
+ }
824
+ const lastPt = points[points.length - 1];
825
+ const dot = document.createElementNS(SVG_NS, "circle");
826
+ dot.setAttribute("cx", lastPt[0].toFixed(1));
827
+ dot.setAttribute("cy", lastPt[1].toFixed(1));
828
+ dot.setAttribute("r", "2.1");
829
+ dot.setAttribute("fill", "currentColor");
830
+ svg.appendChild(dot);
831
+ }
832
+ wrap.appendChild(svg);
833
+ if (showLastValue) {
834
+ const lbl = document.createElement("span");
835
+ lbl.className = "ya-sparkline-value";
836
+ lbl.textContent = valueFormatter(last);
837
+ wrap.appendChild(lbl);
838
+ }
839
+ return wrap;
840
+ }
841
+ );
842
+ return {
843
+ sortable: true,
844
+ filter: false,
845
+ comparator: (a, b) => {
846
+ const sa = extractSeries(a);
847
+ const sb = extractSeries(b);
848
+ const la = sa.length > 0 ? sa[sa.length - 1] : Number.NEGATIVE_INFINITY;
849
+ const lb = sb.length > 0 ? sb[sb.length - 1] : Number.NEGATIVE_INFINITY;
850
+ return la - lb;
851
+ },
852
+ valueFormatter: ({ value }) => {
853
+ const series = extractSeries(value);
854
+ return series.map(valueFormatter).join(", ");
855
+ },
856
+ cellRenderer: renderer
857
+ };
858
+ }
859
+ var ACTION_ICON_PATHS = {
860
+ edit: ["M11.5 2.5a1.414 1.414 0 0 1 2 2L5.5 12.5 2.5 13.5l1-3 8-8Z", "M10 4l2 2"],
861
+ delete: [
862
+ "M3 4.5h10",
863
+ "M6 4.5V3a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v1.5",
864
+ "M4.5 4.5l.6 8.2A1.2 1.2 0 0 0 6.3 13.8h3.4a1.2 1.2 0 0 0 1.2-1.1l.6-8.2",
865
+ "M6.75 7.25v4",
866
+ "M9.25 7.25v4"
867
+ ],
868
+ view: [
869
+ "M1.75 8S4.25 3.75 8 3.75 14.25 8 14.25 8 11.75 12.25 8 12.25 1.75 8 1.75 8Z",
870
+ "M8 9.75a1.75 1.75 0 1 0 0-3.5 1.75 1.75 0 0 0 0 3.5Z"
871
+ ],
872
+ copy: [
873
+ "M6 6h6.5a1 1 0 0 1 1 1v6.5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1Z",
874
+ "M3.5 10.5H3a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h6.5a1 1 0 0 1 1 1v.5"
875
+ ],
876
+ download: [
877
+ "M8 2.5v7.5",
878
+ "M5.25 7.5 8 10.25 10.75 7.5",
879
+ "M2.75 11.5v1.25a1 1 0 0 0 1 1h8.5a1 1 0 0 0 1-1V11.5"
880
+ ],
881
+ plus: ["M8 3.25v9.5", "M3.25 8h9.5"],
882
+ check: ["M3.25 8.5 6.5 11.75 12.75 4.5"],
883
+ external: [
884
+ "M9.5 2.5h4v4",
885
+ "M7 9l6.5-6.5",
886
+ "M12.5 9v3.5a1 1 0 0 1-1 1h-8a1 1 0 0 1-1-1v-8a1 1 0 0 1 1-1H7"
887
+ ],
888
+ more: ["M4 8h.01", "M8 8h.01", "M12 8h.01"]
889
+ };
890
+ function createActionIconNode(icon, params) {
891
+ if (!icon) return null;
892
+ if (typeof icon === "function") {
893
+ const custom = icon(params);
894
+ if (custom === null || custom === void 0) return null;
895
+ if (typeof custom === "string") {
896
+ const span2 = document.createElement("span");
897
+ span2.className = "ya-action-icon";
898
+ span2.setAttribute("aria-hidden", "true");
899
+ span2.textContent = custom;
900
+ return span2;
901
+ }
902
+ return custom;
903
+ }
904
+ const paths = ACTION_ICON_PATHS[icon];
905
+ if (paths) {
906
+ const svg = document.createElementNS(SVG_NS, "svg");
907
+ svg.setAttribute("class", "ya-action-icon");
908
+ svg.setAttribute("width", "14");
909
+ svg.setAttribute("height", "14");
910
+ svg.setAttribute("viewBox", "0 0 16 16");
911
+ svg.setAttribute("fill", "none");
912
+ svg.setAttribute("aria-hidden", "true");
913
+ for (const d of paths) {
914
+ const p = document.createElementNS(SVG_NS, "path");
915
+ p.setAttribute("d", d);
916
+ p.setAttribute("stroke", "currentColor");
917
+ p.setAttribute("stroke-width", icon === "more" ? "2.4" : "1.5");
918
+ p.setAttribute("stroke-linecap", "round");
919
+ p.setAttribute("stroke-linejoin", "round");
920
+ svg.appendChild(p);
921
+ }
922
+ return svg;
923
+ }
924
+ const span = document.createElement("span");
925
+ span.className = "ya-action-icon";
926
+ span.setAttribute("aria-hidden", "true");
927
+ span.textContent = icon;
928
+ return span;
929
+ }
930
+ function actionsColumn(options) {
931
+ const { actions, variant: defaultVariant = "ghost", align = "center", gap = 4 } = options;
932
+ const renderer = markVanillaRenderer(
933
+ (params) => {
934
+ const defs = typeof actions === "function" ? actions(params) : actions;
935
+ const wrap = document.createElement("div");
936
+ wrap.className = "ya-actions-cell";
937
+ if (gap !== 4) wrap.style.gap = `${gap}px`;
938
+ for (const action of defs) {
939
+ const isHidden = typeof action.hidden === "function" ? action.hidden(params) : Boolean(action.hidden);
940
+ if (isHidden) continue;
941
+ const isDisabled = typeof action.disabled === "function" ? action.disabled(params) : Boolean(action.disabled);
942
+ const btn = document.createElement("button");
943
+ btn.type = "button";
944
+ btn.className = action.iconOnly ? "ya-action-btn ya-action-btn-icon-only" : "ya-action-btn";
945
+ btn.dataset.yaAction = action.id;
946
+ btn.dataset.tone = action.tone ?? "default";
947
+ btn.dataset.variant = action.variant ?? defaultVariant;
948
+ btn.disabled = isDisabled;
949
+ if (action.iconOnly) {
950
+ btn.setAttribute("aria-label", action.label);
951
+ }
952
+ const tooltip = action.title ?? (action.iconOnly ? action.label : void 0);
953
+ if (tooltip) btn.title = tooltip;
954
+ const iconNode = createActionIconNode(action.icon, params);
955
+ if (iconNode) btn.appendChild(iconNode);
956
+ if (!action.iconOnly || !iconNode) {
957
+ const lbl = document.createElement("span");
958
+ lbl.className = "ya-action-label";
959
+ lbl.textContent = action.label;
960
+ btn.appendChild(lbl);
961
+ }
962
+ btn.addEventListener("dblclick", (event) => {
963
+ event.stopPropagation();
964
+ });
965
+ btn.addEventListener("click", (event) => {
966
+ event.stopPropagation();
967
+ if (btn.disabled) return;
968
+ action.onClick({ ...params, event });
969
+ });
970
+ wrap.appendChild(btn);
971
+ }
972
+ return wrap;
973
+ }
974
+ );
975
+ return {
976
+ sortable: false,
977
+ filter: false,
978
+ searchable: false,
979
+ editable: false,
980
+ align,
981
+ valueFormatter: () => "",
982
+ cellRenderer: renderer
983
+ };
984
+ }
985
+ function createBuiltInColumnTypes() {
986
+ return {
987
+ currency: currencyColumn(),
988
+ accounting: currencyColumn({ currencySign: "accounting", colorizeSign: true }),
989
+ percent: percentColumn(),
990
+ bar: barColumn(),
991
+ badge: badgeColumn(),
992
+ boolean: booleanColumn(),
993
+ sparkline: sparklineColumn()
994
+ };
995
+ }
996
+
460
997
  // src/editing/undo-redo-stack.ts
461
998
  var UndoRedoStack = class {
462
999
  undoStack = [];
@@ -4762,7 +5299,8 @@ var YaGridCore = class {
4762
5299
  options.columnDefs,
4763
5300
  options.defaultColDef,
4764
5301
  this.selectionController.getConfig(),
4765
- Boolean(options.masterDetail)
5302
+ Boolean(options.masterDetail),
5303
+ options.columnTypes
4766
5304
  );
4767
5305
  if (options.initialState?.columns) {
4768
5306
  this.columnController.applyColumnState(options.initialState.columns);
@@ -5395,7 +5933,8 @@ var YaGridCore = class {
5395
5933
  columnDefs,
5396
5934
  this.options.defaultColDef,
5397
5935
  this.selectionController.getConfig(),
5398
- Boolean(this.options.masterDetail)
5936
+ Boolean(this.options.masterDetail),
5937
+ this.options.columnTypes
5399
5938
  );
5400
5939
  const w = this.renderer.getViewportWidth();
5401
5940
  if (w > 0) this.columnController.setViewportWidth(w);
@@ -5405,6 +5944,7 @@ var YaGridCore = class {
5405
5944
  const prevRowData = this.options.rowData;
5406
5945
  const prevColDefs = this.options.columnDefs;
5407
5946
  const prevDefaultColDef = this.options.defaultColDef;
5947
+ const prevColumnTypes = this.options.columnTypes;
5408
5948
  const prevSelection = this.options.rowSelection;
5409
5949
  const prevMasterDetail = this.options.masterDetail;
5410
5950
  const prevPagination = this.options.pagination;
@@ -5468,12 +6008,13 @@ var YaGridCore = class {
5468
6008
  this.selectionController.setConfig(normalizeSelectionConfig(partial.rowSelection));
5469
6009
  structuralChange = true;
5470
6010
  }
5471
- if (partial.columnDefs !== void 0 && partial.columnDefs !== prevColDefs || partial.defaultColDef !== void 0 && !shallowEqual(partial.defaultColDef, prevDefaultColDef) || partial.rowSelection !== void 0 && !shallowEqual(partial.rowSelection, prevSelection) || partial.masterDetail !== void 0 && partial.masterDetail !== prevMasterDetail) {
6011
+ if (partial.columnDefs !== void 0 && partial.columnDefs !== prevColDefs || partial.defaultColDef !== void 0 && !shallowEqual(partial.defaultColDef, prevDefaultColDef) || partial.columnTypes !== void 0 && !shallowEqual(partial.columnTypes, prevColumnTypes) || partial.rowSelection !== void 0 && !shallowEqual(partial.rowSelection, prevSelection) || partial.masterDetail !== void 0 && partial.masterDetail !== prevMasterDetail) {
5472
6012
  this.columnController.setColumnDefs(
5473
6013
  this.options.columnDefs,
5474
6014
  this.options.defaultColDef,
5475
6015
  this.selectionController.getConfig(),
5476
- Boolean(this.options.masterDetail)
6016
+ Boolean(this.options.masterDetail),
6017
+ this.options.columnTypes
5477
6018
  );
5478
6019
  const w = this.renderer.getViewportWidth();
5479
6020
  if (w > 0) this.columnController.setViewportWidth(w);
@@ -5862,7 +6403,8 @@ var YaGridCore = class {
5862
6403
  this.options.columnDefs,
5863
6404
  this.options.defaultColDef,
5864
6405
  this.selectionController.getConfig(),
5865
- Boolean(this.options.masterDetail)
6406
+ Boolean(this.options.masterDetail),
6407
+ this.options.columnTypes
5866
6408
  );
5867
6409
  const w = this.renderer.getViewportWidth();
5868
6410
  if (w > 0) this.columnController.setViewportWidth(w);
@@ -5997,20 +6539,30 @@ export {
5997
6539
  SELECTION_COL_ID,
5998
6540
  SelectionController,
5999
6541
  UndoRedoStack,
6542
+ VANILLA_RENDERER_SYMBOL,
6000
6543
  YaGridCore,
6544
+ actionsColumn,
6545
+ badgeColumn,
6546
+ barColumn,
6547
+ booleanColumn,
6001
6548
  buildCsvString,
6002
6549
  buildQuickFilterHaystack,
6003
6550
  buildTsvString,
6551
+ createBuiltInColumnTypes,
6004
6552
  createGrid,
6553
+ currencyColumn,
6005
6554
  downloadCsvFile,
6006
6555
  filterRowNodes,
6007
6556
  getFormattedCellValue,
6008
6557
  getRawCellValue,
6009
6558
  isColGroupDef,
6559
+ markVanillaRenderer,
6010
6560
  matchesColumnFilter,
6011
6561
  normalizeSelectionConfig,
6012
6562
  parseQuickFilterTokens,
6563
+ percentColumn,
6013
6564
  resolveColumnFilterType,
6014
- sortRowNodes
6565
+ sortRowNodes,
6566
+ sparklineColumn
6015
6567
  };
6016
6568
  //# sourceMappingURL=index.js.map