@pequity/squirrel 7.1.5 → 7.2.1

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/cjs/index.js CHANGED
@@ -45,12 +45,12 @@ const pSkeletonLoader = require("./p-skeleton-loader.js");
45
45
  const pTable$1 = require("./p-table.js");
46
46
  const usePTableColResize = require("./usePTableColResize.js");
47
47
  const pTableHeaderCell = require("./p-table-header-cell.js");
48
+ const pTableTd = require("./p-table-td.js");
48
49
  const _pluginVue_exportHelper = require("./chunks/_plugin-vue_export-helper.js");
49
50
  const usePTableRowVirtualizer = require("./usePTableRowVirtualizer.js");
50
51
  const pTableFilterIcon = require("./p-table-filter-icon.js");
51
52
  const pTableLoader_vue_vue_type_script_setup_true_lang = require("./chunks/p-table-loader.js");
52
53
  const pTableSort = require("./p-table-sort.js");
53
- const pTableTd = require("./p-table-td.js");
54
54
  const pTabs_vue_vue_type_script_setup_true_lang = require("./chunks/p-tabs.js");
55
55
  const pTextarea_vue_vue_type_script_setup_true_lang = require("./chunks/p-textarea.js");
56
56
  const pToggle = require("./p-toggle.js");
@@ -79,7 +79,7 @@ const _hoisted_6$3 = {
79
79
  key: 1,
80
80
  class: "flex flex-col items-center"
81
81
  };
82
- const _hoisted_7 = { class: "mt-2 text-p-purple-60" };
82
+ const _hoisted_7$1 = { class: "mt-2 text-p-purple-60" };
83
83
  const _hoisted_8 = ["accept", "multiple", "disabled"];
84
84
  const _hoisted_9 = { class: "max-h-48 overflow-y-auto overflow-x-hidden" };
85
85
  const _hoisted_10 = ["title"];
@@ -270,7 +270,7 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
270
270
  width: "32",
271
271
  class: "text-primary"
272
272
  }),
273
- vue.createElementVNode("div", _hoisted_7, "Drop " + vue.toDisplayString(fileWord.value), 1)
273
+ vue.createElementVNode("div", _hoisted_7$1, "Drop " + vue.toDisplayString(fileWord.value), 1)
274
274
  ])),
275
275
  vue.createElementVNode("input", {
276
276
  ref_key: "fileInputRef",
@@ -668,7 +668,8 @@ const _hoisted_4$1 = {
668
668
  class: "min-w-[80px] bg-gradient-to-r from-white via-p-gray-10 to-p-gray-10"
669
669
  };
670
670
  const _hoisted_5$1 = { key: 0 };
671
- const _hoisted_6$1 = { key: 1 };
671
+ const _hoisted_6$1 = { class: "py-2" };
672
+ const _hoisted_7 = { key: 1 };
672
673
  const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
673
674
  ...{ name: "PTable" },
674
675
  __name: "p-table",
@@ -682,7 +683,8 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
682
683
  virtualizer: { default: () => ({
683
684
  paddingTop: 0,
684
685
  paddingBottom: 0
685
- }) }
686
+ }) },
687
+ data: { default: void 0 }
686
688
  },
687
689
  emits: ["scroll", "click-filter-icon", "col-resize"],
688
690
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -865,8 +867,32 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
865
867
  style: vue.normalizeStyle({ height: `${_ctx.virtualizer.paddingTop}px` })
866
868
  }, null, 4)
867
869
  ])) : vue.createCommentVNode("", true),
868
- vue.renderSlot(_ctx.$slots, "default", {}, void 0, true),
869
- _ctx.virtualizer.paddingBottom > 0 ? (vue.openBlock(), vue.createElementBlock("tr", _hoisted_6$1, [
870
+ vue.renderSlot(_ctx.$slots, "default", {}, () => [
871
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(props.data, (rowData, rowIndex) => {
872
+ return vue.openBlock(), vue.createElementBlock("tr", {
873
+ key: `row-${rowIndex}`
874
+ }, [
875
+ vue.renderSlot(_ctx.$slots, "row", vue.mergeProps({ ref_for: true }, { rowData, rowIndex }), () => [
876
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(props.cols, (col, colIndex) => {
877
+ return vue.openBlock(), vue.createBlock(pTableTd, {
878
+ key: `cell-${rowIndex}-${colIndex}`,
879
+ "col-index": colIndex
880
+ }, {
881
+ default: vue.withCtx(() => [
882
+ vue.renderSlot(_ctx.$slots, "cell", vue.mergeProps({ ref_for: true }, { col, colIndex, rowData, rowIndex, cellData: rowData[col.name] }), () => [
883
+ vue.renderSlot(_ctx.$slots, `cell-${vue.unref(lodashEs.kebabCase)(col.name)}`, vue.mergeProps({ ref_for: true }, { col, rowData, rowIndex, cellData: rowData[col.name] }), () => [
884
+ vue.createElementVNode("div", _hoisted_6$1, vue.toDisplayString(rowData[col.name]), 1)
885
+ ], true)
886
+ ], true)
887
+ ]),
888
+ _: 2
889
+ }, 1032, ["col-index"]);
890
+ }), 128))
891
+ ], true)
892
+ ]);
893
+ }), 128))
894
+ ], true),
895
+ _ctx.virtualizer.paddingBottom > 0 ? (vue.openBlock(), vue.createElementBlock("tr", _hoisted_7, [
870
896
  vue.createElementVNode("td", {
871
897
  style: vue.normalizeStyle({ height: `${_ctx.virtualizer.paddingBottom}px` })
872
898
  }, null, 4)
@@ -877,7 +903,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
877
903
  };
878
904
  }
879
905
  });
880
- const pTable = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main$1, [["__scopeId", "data-v-8560a8de"]]);
906
+ const pTable = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main$1, [["__scopeId", "data-v-80616550"]]);
881
907
  const _imports_0 = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_1019_75838)'%3e%3cpath%20d='M11.6533%203.37331L8.47329%200.18664C8.41131%200.124154%208.33758%200.074558%208.25634%200.0407122C8.1751%200.00686641%208.08796%20-0.0105591%207.99995%20-0.0105591C7.91194%20-0.0105591%207.82481%200.00686641%207.74357%200.0407122C7.66233%200.074558%207.58859%200.124154%207.52662%200.18664L4.34662%203.37331C4.253%203.46615%204.18902%203.58468%204.16277%203.71388C4.13651%203.84309%204.14916%203.97719%204.19911%204.09921C4.24906%204.22123%204.33407%204.3257%204.44339%204.39941C4.55271%204.47312%204.68144%204.51275%204.81329%204.51331H6.81329C6.83571%204.51054%206.85846%204.51235%206.88016%204.51865C6.90186%204.52494%206.92205%204.53559%206.93951%204.54993C6.95697%204.56427%206.97133%204.58201%206.98172%204.60207C6.99211%204.62214%206.99832%204.6441%206.99995%204.66664V14.9933C6.99995%2015.2585%207.10531%2015.5129%207.29285%2015.7004C7.48038%2015.888%207.73474%2015.9933%207.99995%2015.9933C8.26517%2015.9933%208.51952%2015.888%208.70706%2015.7004C8.8946%2015.5129%208.99995%2015.2585%208.99995%2014.9933V4.66664C8.99995%204.62244%209.01751%204.58004%209.04877%204.54879C9.08002%204.51753%209.12242%204.49997%209.16662%204.49997H11.1666C11.2985%204.49942%2011.4272%204.45978%2011.5365%204.38608C11.6458%204.31237%2011.7308%204.2079%2011.7808%204.08587C11.8307%203.96385%2011.8434%203.82976%2011.8171%203.70055C11.7909%203.57134%2011.7269%203.45282%2011.6333%203.35997L11.6533%203.37331Z'%20fill='%23424E6E'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_1019_75838'%3e%3crect%20width='16'%20height='16'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e";
882
908
  const _imports_1 = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_1019_80096)'%3e%3cpath%20d='M11.6533%203.37331L8.47329%200.18664C8.41131%200.124154%208.33758%200.074558%208.25634%200.0407122C8.1751%200.00686641%208.08796%20-0.0105591%207.99995%20-0.0105591C7.91194%20-0.0105591%207.82481%200.00686641%207.74357%200.0407122C7.66233%200.074558%207.58859%200.124154%207.52662%200.18664L4.34662%203.37331C4.253%203.46615%204.18902%203.58468%204.16277%203.71388C4.13651%203.84309%204.14916%203.97719%204.19911%204.09921C4.24906%204.22123%204.33407%204.3257%204.44339%204.39941C4.55271%204.47312%204.68144%204.51275%204.81329%204.51331H6.81329C6.83571%204.51054%206.85846%204.51235%206.88016%204.51865C6.90186%204.52494%206.92205%204.53559%206.93951%204.54993C6.95697%204.56427%206.97133%204.58201%206.98172%204.60207C6.99211%204.62214%206.99832%204.6441%206.99995%204.66664V14.9933C6.99995%2015.2585%207.10531%2015.5129%207.29285%2015.7004C7.48038%2015.888%207.73474%2015.9933%207.99995%2015.9933C8.26517%2015.9933%208.51952%2015.888%208.70706%2015.7004C8.8946%2015.5129%208.99995%2015.2585%208.99995%2014.9933V4.66664C8.99995%204.62244%209.01751%204.58004%209.04877%204.54879C9.08002%204.51753%209.12242%204.49997%209.16662%204.49997H11.1666C11.2985%204.49942%2011.4272%204.45978%2011.5365%204.38608C11.6458%204.31237%2011.7308%204.2079%2011.7808%204.08587C11.8307%203.96385%2011.8434%203.82976%2011.8171%203.70055C11.7909%203.57134%2011.7269%203.45282%2011.6333%203.35997L11.6533%203.37331Z'%20fill='%23323CEB'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_1019_80096'%3e%3crect%20width='16'%20height='16'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e";
883
909
  const _imports_2 = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_1019_75842)'%3e%3cpath%20d='M11.8%2011.8933C11.75%2011.7716%2011.665%2011.6674%2011.5559%2011.5938C11.4467%2011.5203%2011.3183%2011.4807%2011.1866%2011.48H9.18664C9.16473%2011.4828%209.14248%2011.4812%209.12119%2011.4753C9.0999%2011.4694%209.07999%2011.4594%209.06262%2011.4457C9.04525%2011.4321%209.03077%2011.4151%209.02001%2011.3958C9.00926%2011.3765%209.00245%2011.3553%208.99997%2011.3333V1C8.99997%200.734784%208.89462%200.48043%208.70708%200.292893C8.51954%200.105357%208.26519%200%207.99997%200C7.73476%200%207.4804%200.105357%207.29287%200.292893C7.10533%200.48043%206.99997%200.734784%206.99997%201V11.3333C6.99997%2011.3775%206.98241%2011.4199%206.95116%2011.4512C6.9199%2011.4824%206.87751%2011.5%206.83331%2011.5H4.83331C4.70146%2011.5006%204.57273%2011.5402%204.46341%2011.6139C4.35409%2011.6876%204.26908%2011.7921%204.21913%2011.9141C4.16918%2012.0361%204.15653%2012.1702%204.18279%2012.2994C4.20904%2012.4286%204.27302%2012.5472%204.36664%2012.64L7.54664%2015.8267C7.60861%2015.8892%207.68235%2015.9387%207.76359%2015.9726C7.84483%2016.0064%207.93196%2016.0239%208.01997%2016.0239C8.10798%2016.0239%208.19512%2016.0064%208.27636%2015.9726C8.3576%2015.9387%208.43133%2015.8892%208.49331%2015.8267L11.6733%2012.64C11.7677%2012.5431%2011.8303%2012.4198%2011.853%2012.2864C11.8756%2012.153%2011.8571%2012.0159%2011.8%2011.8933Z'%20fill='%23424E6E'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_1019_75842'%3e%3crect%20width='16'%20height='16'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e";
@@ -1000,11 +1026,11 @@ exports.isFirstColFixedInjectionKey = pTable$1.isFirstColFixedInjectionKey;
1000
1026
  exports.isLastColFixedInjectionKey = pTable$1.isLastColFixedInjectionKey;
1001
1027
  exports.usePTableColResize = usePTableColResize.usePTableColResize;
1002
1028
  exports.PTableHeaderCell = pTableHeaderCell;
1029
+ exports.PTableTd = pTableTd;
1003
1030
  exports.usePTableRowVirtualizer = usePTableRowVirtualizer.usePTableRowVirtualizer;
1004
1031
  exports.PFilterIcon = pTableFilterIcon;
1005
1032
  exports.PTableLoader = pTableLoader_vue_vue_type_script_setup_true_lang._sfc_main;
1006
1033
  exports.SORTING_TYPES = pTableSort.SORTING_TYPES;
1007
- exports.PTableTd = pTableTd;
1008
1034
  exports.PTabs = pTabs_vue_vue_type_script_setup_true_lang._sfc_main;
1009
1035
  exports.PTextarea = pTextarea_vue_vue_type_script_setup_true_lang._sfc_main;
1010
1036
  exports.PToggle = pToggle;
@@ -82,5 +82,5 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
82
82
  };
83
83
  }
84
84
  });
85
- const pTableTd = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["__scopeId", "data-v-c9978e26"]]);
86
- module.exports = pTableTd;
85
+ const PTableTd = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["__scopeId", "data-v-c9978e26"]]);
86
+ module.exports = PTableTd;
package/dist/es/index.js CHANGED
@@ -11,7 +11,7 @@ import { default as default5 } from "./p-drawer.js";
11
11
  import { default as default6 } from "./p-dropdown.js";
12
12
  import { _ as _imports_0$1 } from "./chunks/p-dropdown-select.js";
13
13
  import { a } from "./chunks/p-dropdown-select.js";
14
- import { defineComponent, shallowRef, ref, computed, onMounted, createElementBlock, openBlock, normalizeClass, createCommentVNode, createElementVNode, withDirectives, unref, toDisplayString, withModifiers, createVNode, createTextVNode, Fragment, renderList, vShow, useAttrs, resolveDirective, normalizeStyle, isRef, renderSlot, provide, onBeforeUnmount, watch, mergeProps, toHandlers } from "vue";
14
+ import { defineComponent, shallowRef, ref, computed, onMounted, createElementBlock, openBlock, normalizeClass, createCommentVNode, createElementVNode, withDirectives, unref, toDisplayString, withModifiers, createVNode, createTextVNode, Fragment, renderList, vShow, useAttrs, resolveDirective, normalizeStyle, isRef, renderSlot, provide, onBeforeUnmount, watch, mergeProps, toHandlers, createBlock, withCtx } from "vue";
15
15
  import { formatBytes, getFileExtension } from "./p-file-upload.js";
16
16
  import { _ as _sfc_main$4 } from "./chunks/p-icon.js";
17
17
  import { useInputClasses } from "./useInputClasses.js";
@@ -45,15 +45,15 @@ import { colsInjectionKey, isFirstColFixedInjectionKey, isLastColFixedInjectionK
45
45
  import { MIN_WIDTH_COL_RESIZE } from "./p-table.js";
46
46
  import { usePTableColResize } from "./usePTableColResize.js";
47
47
  import PTableHeaderCell from "./p-table-header-cell.js";
48
+ import PTableTd from "./p-table-td.js";
48
49
  import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
49
50
  import { usePTableRowVirtualizer } from "./usePTableRowVirtualizer.js";
50
51
  import { default as default11 } from "./p-table-filter-icon.js";
51
52
  import { _ as _19 } from "./chunks/p-table-loader.js";
52
53
  import { SORTING_TYPES } from "./p-table-sort.js";
53
- import { default as default12 } from "./p-table-td.js";
54
54
  import { _ as _20 } from "./chunks/p-tabs.js";
55
55
  import { _ as _21 } from "./chunks/p-textarea.js";
56
- import { default as default13 } from "./p-toggle.js";
56
+ import { default as default12 } from "./p-toggle.js";
57
57
  import { squirrelTailwindConfig } from "./config.js";
58
58
  import { S } from "./chunks/p-btn.types.js";
59
59
  import { CURRENCY_INPUT_DEFAULTS } from "./currency.js";
@@ -79,7 +79,7 @@ const _hoisted_6$3 = {
79
79
  key: 1,
80
80
  class: "flex flex-col items-center"
81
81
  };
82
- const _hoisted_7 = { class: "mt-2 text-p-purple-60" };
82
+ const _hoisted_7$1 = { class: "mt-2 text-p-purple-60" };
83
83
  const _hoisted_8 = ["accept", "multiple", "disabled"];
84
84
  const _hoisted_9 = { class: "max-h-48 overflow-y-auto overflow-x-hidden" };
85
85
  const _hoisted_10 = ["title"];
@@ -270,7 +270,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
270
270
  width: "32",
271
271
  class: "text-primary"
272
272
  }),
273
- createElementVNode("div", _hoisted_7, "Drop " + toDisplayString(fileWord.value), 1)
273
+ createElementVNode("div", _hoisted_7$1, "Drop " + toDisplayString(fileWord.value), 1)
274
274
  ])),
275
275
  createElementVNode("input", {
276
276
  ref_key: "fileInputRef",
@@ -668,7 +668,8 @@ const _hoisted_4$1 = {
668
668
  class: "min-w-[80px] bg-gradient-to-r from-white via-p-gray-10 to-p-gray-10"
669
669
  };
670
670
  const _hoisted_5$1 = { key: 0 };
671
- const _hoisted_6$1 = { key: 1 };
671
+ const _hoisted_6$1 = { class: "py-2" };
672
+ const _hoisted_7 = { key: 1 };
672
673
  const _sfc_main$1 = /* @__PURE__ */ defineComponent({
673
674
  ...{ name: "PTable" },
674
675
  __name: "p-table",
@@ -682,7 +683,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
682
683
  virtualizer: { default: () => ({
683
684
  paddingTop: 0,
684
685
  paddingBottom: 0
685
- }) }
686
+ }) },
687
+ data: { default: void 0 }
686
688
  },
687
689
  emits: ["scroll", "click-filter-icon", "col-resize"],
688
690
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -865,8 +867,32 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
865
867
  style: normalizeStyle({ height: `${_ctx.virtualizer.paddingTop}px` })
866
868
  }, null, 4)
867
869
  ])) : createCommentVNode("", true),
868
- renderSlot(_ctx.$slots, "default", {}, void 0, true),
869
- _ctx.virtualizer.paddingBottom > 0 ? (openBlock(), createElementBlock("tr", _hoisted_6$1, [
870
+ renderSlot(_ctx.$slots, "default", {}, () => [
871
+ (openBlock(true), createElementBlock(Fragment, null, renderList(props.data, (rowData, rowIndex) => {
872
+ return openBlock(), createElementBlock("tr", {
873
+ key: `row-${rowIndex}`
874
+ }, [
875
+ renderSlot(_ctx.$slots, "row", mergeProps({ ref_for: true }, { rowData, rowIndex }), () => [
876
+ (openBlock(true), createElementBlock(Fragment, null, renderList(props.cols, (col, colIndex) => {
877
+ return openBlock(), createBlock(PTableTd, {
878
+ key: `cell-${rowIndex}-${colIndex}`,
879
+ "col-index": colIndex
880
+ }, {
881
+ default: withCtx(() => [
882
+ renderSlot(_ctx.$slots, "cell", mergeProps({ ref_for: true }, { col, colIndex, rowData, rowIndex, cellData: rowData[col.name] }), () => [
883
+ renderSlot(_ctx.$slots, `cell-${unref(kebabCase)(col.name)}`, mergeProps({ ref_for: true }, { col, rowData, rowIndex, cellData: rowData[col.name] }), () => [
884
+ createElementVNode("div", _hoisted_6$1, toDisplayString(rowData[col.name]), 1)
885
+ ], true)
886
+ ], true)
887
+ ]),
888
+ _: 2
889
+ }, 1032, ["col-index"]);
890
+ }), 128))
891
+ ], true)
892
+ ]);
893
+ }), 128))
894
+ ], true),
895
+ _ctx.virtualizer.paddingBottom > 0 ? (openBlock(), createElementBlock("tr", _hoisted_7, [
870
896
  createElementVNode("td", {
871
897
  style: normalizeStyle({ height: `${_ctx.virtualizer.paddingBottom}px` })
872
898
  }, null, 4)
@@ -877,7 +903,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
877
903
  };
878
904
  }
879
905
  });
880
- const pTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-8560a8de"]]);
906
+ const pTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-80616550"]]);
881
907
  const _imports_0 = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_1019_75838)'%3e%3cpath%20d='M11.6533%203.37331L8.47329%200.18664C8.41131%200.124154%208.33758%200.074558%208.25634%200.0407122C8.1751%200.00686641%208.08796%20-0.0105591%207.99995%20-0.0105591C7.91194%20-0.0105591%207.82481%200.00686641%207.74357%200.0407122C7.66233%200.074558%207.58859%200.124154%207.52662%200.18664L4.34662%203.37331C4.253%203.46615%204.18902%203.58468%204.16277%203.71388C4.13651%203.84309%204.14916%203.97719%204.19911%204.09921C4.24906%204.22123%204.33407%204.3257%204.44339%204.39941C4.55271%204.47312%204.68144%204.51275%204.81329%204.51331H6.81329C6.83571%204.51054%206.85846%204.51235%206.88016%204.51865C6.90186%204.52494%206.92205%204.53559%206.93951%204.54993C6.95697%204.56427%206.97133%204.58201%206.98172%204.60207C6.99211%204.62214%206.99832%204.6441%206.99995%204.66664V14.9933C6.99995%2015.2585%207.10531%2015.5129%207.29285%2015.7004C7.48038%2015.888%207.73474%2015.9933%207.99995%2015.9933C8.26517%2015.9933%208.51952%2015.888%208.70706%2015.7004C8.8946%2015.5129%208.99995%2015.2585%208.99995%2014.9933V4.66664C8.99995%204.62244%209.01751%204.58004%209.04877%204.54879C9.08002%204.51753%209.12242%204.49997%209.16662%204.49997H11.1666C11.2985%204.49942%2011.4272%204.45978%2011.5365%204.38608C11.6458%204.31237%2011.7308%204.2079%2011.7808%204.08587C11.8307%203.96385%2011.8434%203.82976%2011.8171%203.70055C11.7909%203.57134%2011.7269%203.45282%2011.6333%203.35997L11.6533%203.37331Z'%20fill='%23424E6E'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_1019_75838'%3e%3crect%20width='16'%20height='16'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e";
882
908
  const _imports_1 = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_1019_80096)'%3e%3cpath%20d='M11.6533%203.37331L8.47329%200.18664C8.41131%200.124154%208.33758%200.074558%208.25634%200.0407122C8.1751%200.00686641%208.08796%20-0.0105591%207.99995%20-0.0105591C7.91194%20-0.0105591%207.82481%200.00686641%207.74357%200.0407122C7.66233%200.074558%207.58859%200.124154%207.52662%200.18664L4.34662%203.37331C4.253%203.46615%204.18902%203.58468%204.16277%203.71388C4.13651%203.84309%204.14916%203.97719%204.19911%204.09921C4.24906%204.22123%204.33407%204.3257%204.44339%204.39941C4.55271%204.47312%204.68144%204.51275%204.81329%204.51331H6.81329C6.83571%204.51054%206.85846%204.51235%206.88016%204.51865C6.90186%204.52494%206.92205%204.53559%206.93951%204.54993C6.95697%204.56427%206.97133%204.58201%206.98172%204.60207C6.99211%204.62214%206.99832%204.6441%206.99995%204.66664V14.9933C6.99995%2015.2585%207.10531%2015.5129%207.29285%2015.7004C7.48038%2015.888%207.73474%2015.9933%207.99995%2015.9933C8.26517%2015.9933%208.51952%2015.888%208.70706%2015.7004C8.8946%2015.5129%208.99995%2015.2585%208.99995%2014.9933V4.66664C8.99995%204.62244%209.01751%204.58004%209.04877%204.54879C9.08002%204.51753%209.12242%204.49997%209.16662%204.49997H11.1666C11.2985%204.49942%2011.4272%204.45978%2011.5365%204.38608C11.6458%204.31237%2011.7308%204.2079%2011.7808%204.08587C11.8307%203.96385%2011.8434%203.82976%2011.8171%203.70055C11.7909%203.57134%2011.7269%203.45282%2011.6333%203.35997L11.6533%203.37331Z'%20fill='%23323CEB'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_1019_80096'%3e%3crect%20width='16'%20height='16'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e";
883
909
  const _imports_2 = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_1019_75842)'%3e%3cpath%20d='M11.8%2011.8933C11.75%2011.7716%2011.665%2011.6674%2011.5559%2011.5938C11.4467%2011.5203%2011.3183%2011.4807%2011.1866%2011.48H9.18664C9.16473%2011.4828%209.14248%2011.4812%209.12119%2011.4753C9.0999%2011.4694%209.07999%2011.4594%209.06262%2011.4457C9.04525%2011.4321%209.03077%2011.4151%209.02001%2011.3958C9.00926%2011.3765%209.00245%2011.3553%208.99997%2011.3333V1C8.99997%200.734784%208.89462%200.48043%208.70708%200.292893C8.51954%200.105357%208.26519%200%207.99997%200C7.73476%200%207.4804%200.105357%207.29287%200.292893C7.10533%200.48043%206.99997%200.734784%206.99997%201V11.3333C6.99997%2011.3775%206.98241%2011.4199%206.95116%2011.4512C6.9199%2011.4824%206.87751%2011.5%206.83331%2011.5H4.83331C4.70146%2011.5006%204.57273%2011.5402%204.46341%2011.6139C4.35409%2011.6876%204.26908%2011.7921%204.21913%2011.9141C4.16918%2012.0361%204.15653%2012.1702%204.18279%2012.2994C4.20904%2012.4286%204.27302%2012.5472%204.36664%2012.64L7.54664%2015.8267C7.60861%2015.8892%207.68235%2015.9387%207.76359%2015.9726C7.84483%2016.0064%207.93196%2016.0239%208.01997%2016.0239C8.10798%2016.0239%208.19512%2016.0064%208.27636%2015.9726C8.3576%2015.9387%208.43133%2015.8892%208.49331%2015.8267L11.6733%2012.64C11.7677%2012.5431%2011.8303%2012.4198%2011.853%2012.2864C11.8756%2012.153%2011.8571%2012.0159%2011.8%2011.8933Z'%20fill='%23424E6E'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_1019_75842'%3e%3crect%20width='16'%20height='16'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e";
@@ -996,10 +1022,10 @@ export {
996
1022
  PTableHeaderCell,
997
1023
  _19 as PTableLoader,
998
1024
  _sfc_main as PTableSort,
999
- default12 as PTableTd,
1025
+ PTableTd,
1000
1026
  _20 as PTabs,
1001
1027
  _21 as PTextarea,
1002
- default13 as PToggle,
1028
+ default12 as PToggle,
1003
1029
  P_ICON_ALIASES,
1004
1030
  S as SIZES,
1005
1031
  SORTING_TYPES,
@@ -81,7 +81,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
81
81
  };
82
82
  }
83
83
  });
84
- const pTableTd = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c9978e26"]]);
84
+ const PTableTd = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c9978e26"]]);
85
85
  export {
86
- pTableTd as default
86
+ PTableTd as default
87
87
  };
@@ -1,5 +1,6 @@
1
1
  import { type TableCol } from './p-table.types';
2
2
  import PTableHeaderCell from '../p-table-header-cell/p-table-header-cell.vue';
3
+ import PTableTd from '../p-table-td/p-table-td.vue';
3
4
  import { kebabCase } from 'lodash-es';
4
5
  type Props = {
5
6
  cols: TableCol[];
@@ -12,6 +13,7 @@ type Props = {
12
13
  paddingTop: number;
13
14
  paddingBottom: number;
14
15
  };
16
+ data?: Record<string, unknown>[];
15
17
  };
16
18
  declare const scrollWrapper: import("vue").Ref<HTMLElement | null, HTMLElement | null>;
17
19
  declare const isColResizing: import("vue").Ref<boolean, boolean>, colResizeHandleLeft: import("vue").Ref<string, string>, colResize: (e: MouseEvent) => void, colResizeStart: (e: MouseEvent, i: number) => void, colResizeFitToData: (colIndex: number) => void;
@@ -28,16 +30,37 @@ declare const headerCellTextColor: (col: TableCol) => string;
28
30
  declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
29
31
  declare var __VLS_2: `prepend-header-cell-${string}`, __VLS_3: {
30
32
  col: TableCol;
31
- }, __VLS_13: `subheader-cell-${string}`, __VLS_14: {}, __VLS_16: {};
33
+ }, __VLS_13: `subheader-cell-${string}`, __VLS_14: {}, __VLS_16: {}, __VLS_18: {
34
+ rowData: Record<string, unknown>;
35
+ rowIndex: number;
36
+ }, __VLS_23: {
37
+ col: TableCol;
38
+ colIndex: number;
39
+ rowData: Record<string, unknown>;
40
+ rowIndex: number;
41
+ cellData: unknown;
42
+ }, __VLS_26: `cell-${string}`, __VLS_27: {
43
+ col: TableCol;
44
+ rowData: Record<string, unknown>;
45
+ rowIndex: number;
46
+ cellData: unknown;
47
+ };
32
48
  type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
33
49
  [K in NonNullable<typeof __VLS_2>]?: (props: typeof __VLS_3) => any;
34
50
  } & {
35
51
  [K in NonNullable<typeof __VLS_13>]?: (props: typeof __VLS_14) => any;
52
+ } & {
53
+ [K in NonNullable<typeof __VLS_26>]?: (props: typeof __VLS_27) => any;
36
54
  } & {
37
55
  default?: (props: typeof __VLS_16) => any;
56
+ } & {
57
+ row?: (props: typeof __VLS_18) => any;
58
+ } & {
59
+ cell?: (props: typeof __VLS_23) => any;
38
60
  }>;
39
61
  declare const __VLS_self: import("vue").DefineComponent<Props, {
40
62
  PTableHeaderCell: typeof PTableHeaderCell;
63
+ PTableTd: typeof PTableTd;
41
64
  kebabCase: typeof kebabCase;
42
65
  scrollWrapper: typeof scrollWrapper;
43
66
  isColResizing: typeof isColResizing;
@@ -60,6 +83,7 @@ declare const __VLS_self: import("vue").DefineComponent<Props, {
60
83
  "onCol-resize"?: ((colIndex: number, width: number) => any) | undefined;
61
84
  "onClick-filter-icon"?: ((val: Event, col: any) => any) | undefined;
62
85
  }>, {
86
+ data: Record<string, unknown>[];
63
87
  isFirstColFixed: boolean;
64
88
  isLastColFixed: boolean;
65
89
  colsResizable: boolean;
@@ -81,6 +105,7 @@ declare const __VLS_component: import("vue").DefineComponent<Props, {
81
105
  "onCol-resize"?: ((colIndex: number, width: number) => any) | undefined;
82
106
  "onClick-filter-icon"?: ((val: Event, col: any) => any) | undefined;
83
107
  }>, {
108
+ data: Record<string, unknown>[];
84
109
  isFirstColFixed: boolean;
85
110
  isLastColFixed: boolean;
86
111
  colsResizable: boolean;
package/dist/squirrel.css CHANGED
@@ -1128,29 +1128,29 @@ to {
1128
1128
  background-image: url("data:image/svg+xml,%3csvg%20width='33'%20height='30'%20viewBox='0%200%2033%2030'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M31.0143%2029.9524C31.1862%2029.9516%2031.3551%2029.9066%2031.5045%2029.8215C31.6539%2029.7365%2031.7789%2029.6144%2031.8674%2029.4669C31.9558%2029.3195%2032.0048%2029.1517%2032.0095%2028.9799C32.0142%2028.808%2031.9745%2028.6378%2031.8943%2028.4857L16.8943%200.485744C16.8006%200.337008%2016.6708%200.214443%2016.5169%200.129498C16.363%200.0445534%2016.1901%200%2016.0143%200C15.8385%200%2015.6656%200.0445534%2015.5117%200.129498C15.3578%200.214443%2015.228%200.337008%2015.1343%200.485744L0.134286%2028.4857C0.0463617%2028.6353%200%2028.8056%200%2028.9791C0%2029.1526%200.0463617%2029.3229%200.134286%2029.4724C0.221436%2029.6207%200.346313%2029.7432%200.496207%2029.8275C0.6461%2029.9118%200.815658%2029.9549%200.98762%2029.9524H31.0143ZM16.0143%2026.2857C15.6176%2026.2857%2015.2299%2026.1677%2014.9004%2025.9467C14.571%2025.7258%2014.3147%2025.4118%2014.1641%2025.0448C14.0136%2024.6778%2013.9755%2024.2743%2014.0549%2023.8857C14.1342%2023.497%2014.3274%2023.1407%2014.6098%2022.8621C14.8922%2022.5835%2015.251%2022.3951%2015.6407%2022.321C16.0304%2022.2468%2016.4334%2022.2903%2016.7983%2022.4458C17.1633%2022.6012%2017.4737%2022.8617%2017.6903%2023.1941C17.9068%2023.5265%2018.0196%2023.9158%2018.0143%2024.3124C18.0073%2024.8382%2017.7935%2025.3401%2017.4192%2025.7094C17.0448%2026.0787%2016.5401%2026.2858%2016.0143%2026.2857ZM16.0143%209.95241C16.3679%209.95241%2016.707%2010.0929%2016.9571%2010.3429C17.2071%2010.593%2017.3476%2010.9321%2017.3476%2011.2857V18.5791C17.3476%2018.9327%2017.2071%2019.2718%2016.9571%2019.5219C16.707%2019.7719%2016.3679%2019.9124%2016.0143%2019.9124C15.6607%2019.9124%2015.3215%2019.7719%2015.0715%2019.5219C14.8214%2019.2718%2014.681%2018.9327%2014.681%2018.5791V11.2857C14.681%2010.9321%2014.8214%2010.593%2015.0715%2010.3429C15.3215%2010.0929%2015.6607%209.95241%2016.0143%209.95241Z'%20fill='%23F2C94C'%20/%3e%3c/svg%3e");
1129
1129
  }
1130
1130
 
1131
- /*# sourceMappingURL=squirrel.css.map */.p-table[data-v-8560a8de] {
1131
+ /*# sourceMappingURL=squirrel.css.map */.p-table[data-v-80616550] {
1132
1132
  color: rgb(var(--color-night));
1133
1133
  height: 1px;
1134
1134
  }
1135
- .p-table th[data-v-8560a8de] {
1135
+ .p-table th[data-v-80616550] {
1136
1136
  position: sticky;
1137
1137
  top: 0px;
1138
1138
  z-index: 20;
1139
1139
  padding: 0px;
1140
1140
  }
1141
- .p-table.first-col-fixed th[data-v-8560a8de]:first-child {
1141
+ .p-table.first-col-fixed th[data-v-80616550]:first-child {
1142
1142
  left: 0px;
1143
1143
  z-index: 30;
1144
1144
  }
1145
- .p-table.first-col-fixed th:first-child .th-shadow[data-v-8560a8de] {
1145
+ .p-table.first-col-fixed th:first-child .th-shadow[data-v-80616550] {
1146
1146
  box-shadow: -1px 1px 5px 4px rgba(0, 0, 0, 0.15);
1147
1147
  clip-path: inset(0px -12px 0px 0px);
1148
1148
  }
1149
- .p-table.last-col-fixed th[data-v-8560a8de]:last-child {
1149
+ .p-table.last-col-fixed th[data-v-80616550]:last-child {
1150
1150
  right: 0px;
1151
1151
  z-index: 30;
1152
1152
  }
1153
- .p-table.last-col-fixed th:last-child .th-shadow[data-v-8560a8de] {
1153
+ .p-table.last-col-fixed th:last-child .th-shadow[data-v-80616550] {
1154
1154
  box-shadow: -2px 1px 8px rgba(0, 0, 0, 0.15);
1155
1155
  clip-path: inset(0px 0px 0px -12px);
1156
1156
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pequity/squirrel",
3
3
  "description": "Squirrel component library",
4
- "version": "7.1.5",
4
+ "version": "7.2.1",
5
5
  "packageManager": "pnpm@9.15.9",
6
6
  "type": "module",
7
7
  "scripts": {
@@ -47,7 +47,181 @@ const columns = [
47
47
  },
48
48
  ];
49
49
 
50
+ const data = [
51
+ {
52
+ 'First column': 'First column row 1 data',
53
+ 'Second column': 'Second column row 1 data',
54
+ 'Third column': 'Third column row 1 data',
55
+ },
56
+ {
57
+ 'First column': 'First column row 2 data',
58
+ 'Second column': 'Second column row 2 data',
59
+ 'Third column': 'Third column row 2 data',
60
+ },
61
+ ];
62
+
50
63
  describe('PTable.vue', () => {
64
+ it('renders correctly when data and columns are provided', async () => {
65
+ const cols = cloneDeep(columns);
66
+
67
+ const wrapper = createWrapperFor(PTable, {
68
+ props: { cols, data },
69
+
70
+ global: {
71
+ stubs: {
72
+ PTableHeaderCell: { template: `<div class="header-cell-stub">{{ text }}</div>`, props: { text: '' } },
73
+ PTableTd: { template: `<td><slot /></td>` },
74
+ },
75
+ },
76
+ });
77
+
78
+ expect(wrapper.find('table.p-table').exists()).toBe(true);
79
+
80
+ cols.forEach((col) => {
81
+ const th = wrapper.find(`th[data-col-id="${col.id}"]`);
82
+ const containerDiv = th.find('div.relative');
83
+ const headerCell = th.find('div.header-cell-stub');
84
+ const showFilterIcon = col.filterable || col.sortable;
85
+
86
+ expect(th.classes()).toContain('th-class');
87
+ expect(th.element.style.width).toBe(col.style.width);
88
+
89
+ expect(headerCell.text()).toBe(col.title);
90
+ expect(headerCell.classes()).toContain('header-cell-class');
91
+ expect(headerCell.attributes()['filter-active']).toBe(col.filterActive.toString());
92
+ expect(headerCell.attributes()['show-filter-icon']).toBe(showFilterIcon.toString());
93
+
94
+ if (!col.borderColor) {
95
+ ['border-b', 'border-p-gray-30'].forEach((className) => {
96
+ expect(containerDiv.classes()).toContain(className);
97
+ });
98
+ }
99
+ });
100
+
101
+ data.forEach((row, i) => {
102
+ const tr = wrapper.find(`tbody tr:nth-child(${i + 1})`);
103
+ const tds = tr.findAll('td');
104
+
105
+ expect(tds.length).toBe(cols.length);
106
+
107
+ cols.forEach((col, j) => {
108
+ const innerDiv = tds[j].find('div');
109
+ expect(innerDiv.text()).toBe(row[col.name]);
110
+ expect(innerDiv.classes()).toContain('py-2');
111
+ });
112
+ });
113
+ });
114
+
115
+ it('renders correctly when data and columns are provided with cell slot specified', async () => {
116
+ const cols = cloneDeep(columns);
117
+
118
+ const wrapper = createWrapperFor(PTable, {
119
+ props: { cols, data },
120
+ slots: {
121
+ cell: `<template #cell="{ cellData, col }"><div class="py-5">({{ cellData }})</div></template>`,
122
+ },
123
+ global: {
124
+ stubs: {
125
+ PTableHeaderCell: { template: `<div class="header-cell-stub">{{ text }}</div>`, props: { text: '' } },
126
+ PTableTd: { template: `<td><slot /></td>` },
127
+ },
128
+ },
129
+ });
130
+
131
+ expect(wrapper.find('table.p-table').exists()).toBe(true);
132
+
133
+ cols.forEach((col) => {
134
+ const th = wrapper.find(`th[data-col-id="${col.id}"]`);
135
+ const containerDiv = th.find('div.relative');
136
+ const headerCell = th.find('div.header-cell-stub');
137
+ const showFilterIcon = col.filterable || col.sortable;
138
+
139
+ expect(th.classes()).toContain('th-class');
140
+ expect(th.element.style.width).toBe(col.style.width);
141
+
142
+ expect(headerCell.text()).toBe(col.title);
143
+ expect(headerCell.classes()).toContain('header-cell-class');
144
+ expect(headerCell.attributes()['filter-active']).toBe(col.filterActive.toString());
145
+ expect(headerCell.attributes()['show-filter-icon']).toBe(showFilterIcon.toString());
146
+
147
+ if (!col.borderColor) {
148
+ ['border-b', 'border-p-gray-30'].forEach((className) => {
149
+ expect(containerDiv.classes()).toContain(className);
150
+ });
151
+ }
152
+ });
153
+
154
+ data.forEach((row, i) => {
155
+ const tr = wrapper.find(`tbody tr:nth-child(${i + 1})`);
156
+ const tds = tr.findAll('td');
157
+
158
+ expect(tds.length).toBe(cols.length);
159
+
160
+ cols.forEach((col, j) => {
161
+ const innerDiv = tds[j].find('div');
162
+ expect(innerDiv.text()).toBe('(' + row[col.name] + ')');
163
+ expect(innerDiv.classes()).toContain('py-5');
164
+ });
165
+ });
166
+ });
167
+
168
+ it('renders correctly when data and columns are provided with certain cell slot specified', async () => {
169
+ const cols = cloneDeep(columns);
170
+
171
+ const wrapper = createWrapperFor(PTable, {
172
+ props: { cols, data },
173
+ slots: {
174
+ 'cell-third-column': `<div>Constant Cell Content</div>`,
175
+ },
176
+ global: {
177
+ stubs: {
178
+ PTableHeaderCell: { template: `<div class="header-cell-stub">{{ text }}</div>`, props: { text: '' } },
179
+ PTableTd: { template: `<td><slot /></td>` },
180
+ },
181
+ },
182
+ });
183
+
184
+ expect(wrapper.find('table.p-table').exists()).toBe(true);
185
+
186
+ cols.forEach((col) => {
187
+ const th = wrapper.find(`th[data-col-id="${col.id}"]`);
188
+ const containerDiv = th.find('div.relative');
189
+ const headerCell = th.find('div.header-cell-stub');
190
+ const showFilterIcon = col.filterable || col.sortable;
191
+
192
+ expect(th.classes()).toContain('th-class');
193
+ expect(th.element.style.width).toBe(col.style.width);
194
+
195
+ expect(headerCell.text()).toBe(col.title);
196
+ expect(headerCell.classes()).toContain('header-cell-class');
197
+ expect(headerCell.attributes()['filter-active']).toBe(col.filterActive.toString());
198
+ expect(headerCell.attributes()['show-filter-icon']).toBe(showFilterIcon.toString());
199
+
200
+ if (!col.borderColor) {
201
+ ['border-b', 'border-p-gray-30'].forEach((className) => {
202
+ expect(containerDiv.classes()).toContain(className);
203
+ });
204
+ }
205
+ });
206
+
207
+ data.forEach((row, i) => {
208
+ const tr = wrapper.find(`tbody tr:nth-child(${i + 1})`);
209
+ const tds = tr.findAll('td');
210
+
211
+ expect(tds.length).toBe(cols.length);
212
+
213
+ cols.forEach((col, j) => {
214
+ const innerDiv = tds[j].find('div');
215
+ if (col.name === 'Third column') {
216
+ expect(innerDiv.text()).toBe('Constant Cell Content');
217
+ } else {
218
+ expect(innerDiv.text()).toBe(row[col.name]);
219
+ expect(innerDiv.classes()).toContain('py-2');
220
+ }
221
+ });
222
+ });
223
+ });
224
+
51
225
  it('renders correctly based on column attributes', async () => {
52
226
  const cols = cloneDeep(columns);
53
227
  const wrapper = createWrapperFor(PTable, {
@@ -96,6 +96,144 @@ export default {
96
96
  };
97
97
 
98
98
  export const Default = {
99
+ render: (args) => ({
100
+ components: { PTable },
101
+ setup() {
102
+ return { args };
103
+ },
104
+ template: `
105
+ <PTable v-bind="args"/>
106
+ `,
107
+ }),
108
+ args: {
109
+ cols: cloneDeep(columns),
110
+ data: rows(),
111
+ },
112
+ parameters: {
113
+ docs: {
114
+ source: {
115
+ code: `
116
+ <PTable :cols="cols" :data="data" />
117
+ `,
118
+ },
119
+ },
120
+ },
121
+ };
122
+
123
+ export const OverridingCellSlot = {
124
+ render: (args) => ({
125
+ components: { PTable },
126
+ setup() {
127
+ return { args };
128
+ },
129
+ template: `
130
+ <PTable v-bind="args">
131
+ <template #cell="{ cellData, colIndex }">
132
+ <div v-if="colIndex%2===0" style="color: green;">{{ cellData }}</div>
133
+ <div v-else>{{ cellData }}</div>
134
+ </template>
135
+ </PTable>
136
+ `,
137
+ }),
138
+ args: {
139
+ cols: cloneDeep(columns),
140
+ data: rows(),
141
+ },
142
+ parameters: {
143
+ docs: {
144
+ source: {
145
+ code: `
146
+ <PTable :cols="cols" :data="data">
147
+ <template #cell="{ cellData, colIndex }">
148
+ <div v-if="colIndex % 2 === 0" style="color: green;">{{ cellData }}</div>
149
+ <div v-else>{{ cellData }}</div>
150
+ </template>
151
+ </PTable>
152
+ `,
153
+ },
154
+ },
155
+ },
156
+ };
157
+
158
+ export const OverridingCertainCellSlot = {
159
+ render: (args) => ({
160
+ components: { PTable },
161
+ setup() {
162
+ return { args };
163
+ },
164
+ template: `
165
+ <PTable v-bind="args">
166
+ <template #cell-fifth-column="{ cellData }">
167
+ <div style="color: red;">{{ cellData }}</div>
168
+ </template>
169
+ </PTable>
170
+ `,
171
+ }),
172
+ args: {
173
+ cols: cloneDeep(columns),
174
+ data: rows(),
175
+ },
176
+ parameters: {
177
+ docs: {
178
+ source: {
179
+ code: `
180
+ <PTable :cols="cols" :data="data">
181
+ <template #cell-fifth-column="{ cellData }">
182
+ <div style="color: red;">{{ cellData }}</div>
183
+ </template>
184
+ </PTable>
185
+ `,
186
+ },
187
+ },
188
+ },
189
+ };
190
+
191
+ export const OverridingRowSlot = {
192
+ render: (args) => ({
193
+ components: { PTable, PTableTd },
194
+ setup() {
195
+ return { args };
196
+ },
197
+ template: `
198
+ <PTable v-bind="args">
199
+ <template #row="{ rowData }">
200
+ <PTableTd
201
+ v-for="(col, i) in args.cols"
202
+ :key="col.id"
203
+ :col-index="i"
204
+ >
205
+ {{ rowData[col.name] }}
206
+ </PTableTd>
207
+ </template>
208
+ </PTable>
209
+ `,
210
+ }),
211
+ args: {
212
+ cols: cloneDeep(columns),
213
+ data: rows(),
214
+ },
215
+ parameters: {
216
+ docs: {
217
+ source: {
218
+ code: `
219
+ <PTable :cols="cols" :data="data">
220
+ <template #row="{ rowData }">
221
+ <PTableTd
222
+ v-for="(col, i) in args.cols"
223
+ :key="col.id"
224
+ :col-index="i"
225
+ >
226
+ {{ rowData[col.name] }}
227
+ </PTableTd>
228
+ </template>
229
+ </PTable>
230
+ `,
231
+ },
232
+ },
233
+ },
234
+ };
235
+
236
+ export const OverridingDefaultSlot = {
99
237
  render: (args) => ({
100
238
  components: { PTable, PTableTd },
101
239
  setup() {
@@ -104,7 +242,7 @@ export const Default = {
104
242
  template: `
105
243
  <PTable v-bind="args">
106
244
  <tr v-for="row in args.rows" class="group/row">
107
- <PTableTd
245
+ <PTableTd
108
246
  v-for="(col, i) in args.cols"
109
247
  :key="col.id"
110
248
  :col-index="i"
@@ -123,4 +261,26 @@ export const Default = {
123
261
  rows: rows(),
124
262
  selectedRows: [2],
125
263
  },
264
+ parameters: {
265
+ docs: {
266
+ source: {
267
+ code: `
268
+ <PTable :cols="cols" :data="data">
269
+ <tr v-for="row in args.rows" class="group/row">
270
+ <PTableTd
271
+ v-for="(col, i) in args.cols"
272
+ :key="col.id"
273
+ :col-index="i"
274
+ :is-editable="col.editable"
275
+ :is-selected="args.selectedRows.includes(row.id)"
276
+ :class="{ 'td-editable': col.editable }"
277
+ >
278
+ {{ row[col.name] }}
279
+ </PTableTd>
280
+ </tr>
281
+ </PTable>
282
+ `,
283
+ },
284
+ },
285
+ },
126
286
  };
@@ -69,7 +69,28 @@
69
69
  <tr v-if="virtualizer.paddingTop > 0">
70
70
  <td :style="{ height: `${virtualizer.paddingTop}px` }"></td>
71
71
  </tr>
72
- <slot />
72
+ <slot>
73
+ <tr v-for="(rowData, rowIndex) in props.data" :key="`row-${rowIndex}`">
74
+ <slot name="row" v-bind="{ rowData, rowIndex }">
75
+ <PTableTd
76
+ v-for="(col, colIndex) in props.cols"
77
+ :key="`cell-${rowIndex}-${colIndex}`"
78
+ :col-index="colIndex"
79
+ >
80
+ <slot name="cell" v-bind="{ col, colIndex, rowData, rowIndex, cellData: rowData[col.name] }">
81
+ <slot
82
+ :name="`cell-${kebabCase(col.name)}`"
83
+ v-bind="{ col, rowData, rowIndex, cellData: rowData[col.name] }"
84
+ >
85
+ <div class="py-2">
86
+ {{ rowData[col.name] }}
87
+ </div>
88
+ </slot>
89
+ </slot>
90
+ </PTableTd>
91
+ </slot>
92
+ </tr>
93
+ </slot>
73
94
  <tr v-if="virtualizer.paddingBottom > 0">
74
95
  <td :style="{ height: `${virtualizer.paddingBottom}px` }"></td>
75
96
  </tr>
@@ -88,6 +109,7 @@ import {
88
109
  } from '@squirrel/components/p-table/p-table.types';
89
110
  import { usePTableColResize } from '@squirrel/components/p-table/usePTableColResize';
90
111
  import PTableHeaderCell from '@squirrel/components/p-table-header-cell/p-table-header-cell.vue';
112
+ import PTableTd from '@squirrel/components/p-table-td/p-table-td.vue';
91
113
  import { kebabCase } from 'lodash-es';
92
114
  import { computed, onBeforeUnmount, onMounted, provide, ref, watch } from 'vue';
93
115
 
@@ -102,6 +124,7 @@ type Props = {
102
124
  paddingTop: number;
103
125
  paddingBottom: number;
104
126
  };
127
+ data?: Record<string, unknown>[];
105
128
  };
106
129
 
107
130
  defineOptions({ name: 'PTable' });
@@ -124,6 +147,7 @@ const props = withDefaults(defineProps<Props>(), {
124
147
  paddingTop: 0,
125
148
  paddingBottom: 0,
126
149
  }),
150
+ data: undefined,
127
151
  });
128
152
 
129
153
  // Provides