@pitcher/canvas-ui 2026.1.7-105737-beta → 2026.1.7-123048-beta

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/canvas-ui.css CHANGED
@@ -903,7 +903,7 @@ button[data-v-da2357d4]:focus {
903
903
  cursor: pointer;
904
904
  color: var(--000c7396);
905
905
  }
906
- .c-assigned-canvas-management[data-v-f6151990] {
906
+ .c-assigned-canvas-management[data-v-df004301] {
907
907
  display: flex;
908
908
  flex-direction: column;
909
909
  }
package/canvas-ui.js CHANGED
@@ -111026,6 +111026,7 @@ function useCanvasStandardFilters(options = {}) {
111026
111026
  includeTagsFilter = true,
111027
111027
  includeDraftFilter = true,
111028
111028
  includeTemplateFilter = false,
111029
+ templateOptions,
111029
111030
  includeOwnerFilter = false,
111030
111031
  ownerLabel
111031
111032
  } = options;
@@ -111054,9 +111055,10 @@ function useCanvasStandardFilters(options = {}) {
111054
111055
  }
111055
111056
  if (includeTemplateFilter) {
111056
111057
  components.push({
111057
- type: MetadataTemplateFieldTypeEnum.TEXT,
111058
- name: "template__name__icontains",
111059
- label: t("canvasUI.composables.useCanvasStandardFilters.templateUsed")
111058
+ type: MetadataTemplateFieldTypeEnum.SELECT,
111059
+ name: "template__id",
111060
+ label: t("canvasUI.composables.useCanvasStandardFilters.templateUsed"),
111061
+ options: templateOptions?.value ?? []
111060
111062
  });
111061
111063
  }
111062
111064
  return components;
@@ -118276,6 +118278,7 @@ const _sfc_main$4q = /*@__PURE__*/defineComponent({
118276
118278
  const fetchedData = ref([]);
118277
118279
  const isLoading = ref(false);
118278
118280
  const accessibleTemplateIds = ref(new Set());
118281
+ const availableTemplates = ref([]);
118279
118282
  const isCheckingTemplateAccess = ref(false);
118280
118283
  const isBulkDeleting = ref(false);
118281
118284
  const isBulkUpdating = ref(false);
@@ -118351,11 +118354,32 @@ const _sfc_main$4q = /*@__PURE__*/defineComponent({
118351
118354
  return systemTags.includes(lowerTag);
118352
118355
  }) ?? false;
118353
118356
  }
118357
+ const templateOptions = computed(() => availableTemplates.value.map(t => ({
118358
+ label: t.name,
118359
+ value: t.id
118360
+ })).sort((a, b) => a.label.localeCompare(b.label)));
118361
+ async function fetchTemplates() {
118362
+ try {
118363
+ const {
118364
+ results
118365
+ } = await props.fetcher({
118366
+ is_template: true,
118367
+ is_section: false,
118368
+ page: 1,
118369
+ page_size: 1000,
118370
+ fields: 'id,name'
118371
+ });
118372
+ availableTemplates.value = results;
118373
+ } catch (e) {
118374
+ console.error('Failed to fetch templates for filter:', e);
118375
+ }
118376
+ }
118354
118377
  const {
118355
118378
  filterComponents: dataFilterComponents
118356
118379
  } = useCanvasStandardFilters({
118357
118380
  includeTemplateFilter: true,
118358
- includeOwnerFilter: props.isAnyTypeOfAdmin ?? false
118381
+ includeOwnerFilter: props.isAnyTypeOfAdmin ?? false,
118382
+ templateOptions
118359
118383
  });
118360
118384
  const {
118361
118385
  height: canvasManagementToolbarHeight
@@ -119111,6 +119135,7 @@ const _sfc_main$4q = /*@__PURE__*/defineComponent({
119111
119135
  onMounted(async () => {
119112
119136
  try {
119113
119137
  isLoading.value = true;
119138
+ fetchTemplates();
119114
119139
  await fetch(fetchingParams.value);
119115
119140
  } catch (e) {
119116
119141
  console.error(e);
@@ -119285,6 +119310,9 @@ const _sfc_main$4o = /*@__PURE__*/defineComponent({
119285
119310
  fetcher: {
119286
119311
  type: Function
119287
119312
  },
119313
+ templatesFetcher: {
119314
+ type: Function
119315
+ },
119288
119316
  byIdFetcher: {
119289
119317
  type: Function
119290
119318
  },
@@ -119330,21 +119358,43 @@ const _sfc_main$4o = /*@__PURE__*/defineComponent({
119330
119358
  const tableRef = ref(null);
119331
119359
  const toolbarWrapper = ref(null);
119332
119360
  const launchDarkly = inject('launchDarkly', computed(() => ({})));
119361
+ const isLoading = ref(false);
119362
+ const fetchedData = ref([]);
119363
+ const totalCount = ref(0);
119364
+ const availableTemplates = ref([]);
119365
+ const templateOptions = computed(() => availableTemplates.value.map(t => ({
119366
+ label: t.name,
119367
+ value: t.id
119368
+ })).sort((a, b) => a.label.localeCompare(b.label)));
119369
+ async function fetchTemplates() {
119370
+ if (!props.templatesFetcher) return;
119371
+ try {
119372
+ const {
119373
+ results
119374
+ } = await props.templatesFetcher({
119375
+ is_template: true,
119376
+ is_section: false,
119377
+ page: 1,
119378
+ page_size: 1000,
119379
+ fields: 'id,name'
119380
+ });
119381
+ availableTemplates.value = results;
119382
+ } catch (e) {
119383
+ console.error('Failed to fetch templates for filter:', e);
119384
+ }
119385
+ }
119333
119386
  const {
119334
119387
  filterComponents: dataFilterComponents
119335
119388
  } = useCanvasStandardFilters({
119336
119389
  includeTemplateFilter: true,
119337
119390
  includeOwnerFilter: true,
119338
- // Include owner filter for assigned canvases
119339
119391
  includeTagsFilter: true,
119340
- includeDraftFilter: true
119392
+ includeDraftFilter: true,
119393
+ templateOptions
119341
119394
  });
119342
119395
  const {
119343
119396
  height: canvasManagementToolbarHeight
119344
119397
  } = useElementSize(toolbarWrapper);
119345
- const isLoading = ref(false);
119346
- const fetchedData = ref([]);
119347
- const totalCount = ref(0);
119348
119398
  const {
119349
119399
  search,
119350
119400
  pageSize,
@@ -119591,6 +119641,7 @@ const _sfc_main$4o = /*@__PURE__*/defineComponent({
119591
119641
  onMounted(async () => {
119592
119642
  try {
119593
119643
  isLoading.value = true;
119644
+ fetchTemplates();
119594
119645
  await fetch(fetchingParams.value);
119595
119646
  } catch (e) {
119596
119647
  console.error(e);
@@ -119644,7 +119695,7 @@ const _sfc_main$4o = /*@__PURE__*/defineComponent({
119644
119695
  }
119645
119696
  });
119646
119697
 
119647
- const CAssignedCanvasesManagement = /* @__PURE__ */ _export_sfc(_sfc_main$4o, [["__scopeId", "data-v-f6151990"]]);
119698
+ const CAssignedCanvasesManagement = /* @__PURE__ */ _export_sfc(_sfc_main$4o, [["__scopeId", "data-v-df004301"]]);
119648
119699
 
119649
119700
  const _hoisted_1$3v = { class: "w-fit flex items-center justify-center text-truncate rd uppercase c-table-select" };
119650
119701
  const __default__ = {
@@ -131590,21 +131641,24 @@ const displayIntegerWithMunit = (number, decimals = 2) => {
131590
131641
  return `${b.toFixed(decimals)}B`;
131591
131642
  };
131592
131643
  const convertSecondsToMinutes = (number) => {
131644
+ if (number <= 0) return "0 sec";
131645
+ if (number < 1) return "<1 sec";
131593
131646
  const units = [
131594
- [1, "sec"],
131595
- [60, "min"],
131647
+ [60 * 60 * 24, "day"],
131596
131648
  [60 * 60, "h"],
131597
- [60 * 60 * 24, "day"]
131649
+ [60, "min"],
131650
+ [1, "sec"]
131598
131651
  ];
131599
- let bestUnit = units[0];
131600
- for (const unit of units) {
131601
- if (number >= unit[0]) {
131602
- bestUnit = unit;
131652
+ const parts = [];
131653
+ let remaining = number;
131654
+ for (const [divisor, label] of units) {
131655
+ if (remaining >= divisor) {
131656
+ const val = Math.floor(remaining / divisor);
131657
+ parts.push(`${val} ${label}`);
131658
+ remaining = remaining % divisor;
131603
131659
  }
131604
131660
  }
131605
- const [divisor, label] = bestUnit;
131606
- const val = Math.floor(number / Number(divisor));
131607
- return `${val} ${label}`;
131661
+ return parts.slice(0, 2).join(" ");
131608
131662
  };
131609
131663
  const getNumberWithRegex = (string) => {
131610
131664
  return string?.replace(/\D+/g, "");
@@ -142417,7 +142471,10 @@ const _hoisted_94 = { class: "flex flex-col gap-2" };
142417
142471
  const _hoisted_95 = { class: "flex items-center gap-2" };
142418
142472
  const _hoisted_96 = { class: "text-sm" };
142419
142473
  const _hoisted_97 = { class: "text-sm" };
142420
- const _hoisted_98 = { class: "flex items-center gap-2" };
142474
+ const _hoisted_98 = {
142475
+ key: 0,
142476
+ class: "flex items-center gap-2"
142477
+ };
142421
142478
  const _hoisted_99 = { class: "text-sm" };
142422
142479
  const _hoisted_100 = { class: "mb-4" };
142423
142480
  const _hoisted_101 = { class: "block mb-2" };
@@ -142443,7 +142500,9 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
142443
142500
  const props = __props;
142444
142501
  const { t } = useI18n();
142445
142502
  const themeVars = useThemeVars();
142446
- const { setComponentEditMode, updateNodeDataById } = useCanvas$1();
142503
+ const { mode, setComponentEditMode, updateNodeDataById } = useCanvas$1();
142504
+ const isAdminMode = computed(() => mode.value === CanvasBuilderMode.ADMIN);
142505
+ const confirmation = useConfirmation();
142447
142506
  const { crmShape } = useCrmShape();
142448
142507
  const { palette } = useCanvasTheme$1();
142449
142508
  let seriesIdCounter = 0;
@@ -142531,7 +142590,9 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
142531
142590
  });
142532
142591
  const chartType = computed(() => seriesList.value[0]?.chartType ?? "bar");
142533
142592
  const primaryChartType = computed(() => seriesList.value[0]?.chartType ?? "bar");
142534
- const backgroundColor = props.data?.data?.datasets?.[0]?.background_color;
142593
+ const savedColorScheme = props.data?.color_scheme;
142594
+ const datasets = props.data?.data?.datasets;
142595
+ const backgroundColor = savedColorScheme ?? (datasets && datasets.length > 1 ? datasets.map((ds) => ds.background_color).filter(Boolean) : datasets?.[0]?.background_color);
142535
142596
  const colorSchemeType = ref(props.data?.color_scheme_type ?? "theme");
142536
142597
  const chartColors = ref([]);
142537
142598
  const displayColors = computed(() => {
@@ -142566,7 +142627,7 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
142566
142627
  const percentDisplay = ref(props.data?.percent_display ?? false);
142567
142628
  const enableFullscreenBtn = ref(props.data?.view_controls?.enable_fullscreen_btn ?? false);
142568
142629
  const enableChartTypeSwitcher = ref(props.data?.view_controls?.enable_chart_type_switcher ?? false);
142569
- const enableDataEntry = ref(props.data?.view_controls?.enable_data_entry ?? false);
142630
+ const enableDataEntry = ref(props.data?.view_controls?.enable_data_entry !== false);
142570
142631
  const chartHeight = ref(props.data?.chart_height ?? 800);
142571
142632
  const chartWidth = ref(props.data?.chart_width ?? 100);
142572
142633
  const legendPositionOptions = [
@@ -143083,7 +143144,7 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143083
143144
  return chartColors.value;
143084
143145
  }
143085
143146
  function createChartConfig() {
143086
- const datasets = [];
143147
+ const datasets2 = [];
143087
143148
  let allLabels = [];
143088
143149
  const colorsForStorage = getSeriesColors(true);
143089
143150
  const isSingleSeries = seriesList.value.length === 1;
@@ -143128,7 +143189,7 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143128
143189
  if (processedData.labels.length > allLabels.length) {
143129
143190
  allLabels = processedData.labels;
143130
143191
  }
143131
- datasets.push(datasetOptions);
143192
+ datasets2.push(datasetOptions);
143132
143193
  });
143133
143194
  const primaryType = seriesList.value[0].chartType;
143134
143195
  let actualPrimaryType = primaryType;
@@ -143167,6 +143228,7 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143167
143228
  const config = {
143168
143229
  type: actualPrimaryType,
143169
143230
  color_scheme_type: colorSchemeType.value,
143231
+ color_scheme: colorsForStorage,
143170
143232
  percent_display: percentDisplay.value,
143171
143233
  chart_height: chartHeight.value,
143172
143234
  chart_width: chartWidth.value,
@@ -143177,7 +143239,7 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143177
143239
  },
143178
143240
  data: {
143179
143241
  labels: allLabels,
143180
- datasets
143242
+ datasets: datasets2
143181
143243
  },
143182
143244
  options: {
143183
143245
  responsive: true,
@@ -143225,6 +143287,22 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143225
143287
  return config;
143226
143288
  }
143227
143289
  function onCancel() {
143290
+ if (isDirty.value) {
143291
+ confirmation.warning({
143292
+ title: t("canvasUI.canvasBuilder.confirmationOnUnsavedChanges.title"),
143293
+ content: t("canvasUI.canvasBuilder.confirmationOnUnsavedChanges.content"),
143294
+ confirmText: t("canvasUI.canvasBuilder.confirmationOnUnsavedChanges.confirm"),
143295
+ exitText: t("canvasUI.canvasBuilder.confirmationOnUnsavedChanges.exit"),
143296
+ hasExit: true,
143297
+ onConfirm: () => {
143298
+ onSave();
143299
+ },
143300
+ onExit: () => {
143301
+ setComponentEditMode(false);
143302
+ }
143303
+ });
143304
+ return;
143305
+ }
143228
143306
  setComponentEditMode(false);
143229
143307
  }
143230
143308
  function onSave() {
@@ -143233,6 +143311,10 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143233
143311
  setComponentEditMode(false);
143234
143312
  }
143235
143313
  const previewData = ref({});
143314
+ const isDirty = ref(false);
143315
+ function markDirty() {
143316
+ isDirty.value = true;
143317
+ }
143236
143318
  function updatePreview() {
143237
143319
  const config = createChartConfig();
143238
143320
  previewData.value = {
@@ -143254,6 +143336,7 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143254
143336
  enableChartTypeSwitcher.value = false;
143255
143337
  }
143256
143338
  });
143339
+ let isInitialized = false;
143257
143340
  watch(
143258
143341
  [
143259
143342
  seriesList,
@@ -143275,17 +143358,23 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143275
143358
  ],
143276
143359
  () => {
143277
143360
  updatePreview();
143361
+ if (isInitialized) {
143362
+ markDirty();
143363
+ }
143278
143364
  },
143279
143365
  { deep: true }
143280
143366
  );
143281
143367
  onMounted(() => {
143282
143368
  updatePreview();
143369
+ nextTick(() => {
143370
+ isInitialized = true;
143371
+ });
143283
143372
  });
143284
143373
  return (_ctx, _cache) => {
143285
143374
  return openBlock(), createBlock(unref(NModal), {
143286
143375
  bordered: false,
143287
143376
  class: "cb-data-charts-settings",
143288
- onEsc: () => unref(setComponentEditMode)(false),
143377
+ onEsc: onCancel,
143289
143378
  preset: "card",
143290
143379
  show: true,
143291
143380
  size: "huge",
@@ -143297,7 +143386,7 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143297
143386
  "--n-padding-left": "16px"
143298
143387
  }]),
143299
143388
  title: unref(t)("canvasUI.canvasBuilder.dataCharts.editDataChartsComponent"),
143300
- onClose: _cache[16] || (_cache[16] = ($event) => unref(setComponentEditMode)(false))
143389
+ onClose: onCancel
143301
143390
  }, {
143302
143391
  footer: withCtx(() => [
143303
143392
  createElementVNode("div", _hoisted_110, [
@@ -143937,13 +144026,13 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143937
144026
  ]),
143938
144027
  _: 1
143939
144028
  }, 8, ["disabled"]),
143940
- createElementVNode("div", _hoisted_98, [
144029
+ isAdminMode.value ? (openBlock(), createElementBlock("div", _hoisted_98, [
143941
144030
  createVNode(unref(NSwitch), {
143942
144031
  value: enableDataEntry.value,
143943
144032
  "onUpdate:value": _cache[13] || (_cache[13] = ($event) => enableDataEntry.value = $event)
143944
144033
  }, null, 8, ["value"]),
143945
144034
  createElementVNode("span", _hoisted_99, toDisplayString(unref(t)("canvasUI.canvasBuilder.dataCharts.enableDataEntry")), 1)
143946
- ])
144035
+ ])) : createCommentVNode("", true)
143947
144036
  ])
143948
144037
  ]),
143949
144038
  createElementVNode("div", _hoisted_100, [
@@ -143959,7 +144048,7 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143959
144048
  min: 100,
143960
144049
  step: 10
143961
144050
  }, {
143962
- suffix: withCtx(() => _cache[17] || (_cache[17] = [
144051
+ suffix: withCtx(() => _cache[16] || (_cache[16] = [
143963
144052
  createTextVNode("px")
143964
144053
  ])),
143965
144054
  _: 1
@@ -143975,7 +144064,7 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143975
144064
  min: 10,
143976
144065
  step: 5
143977
144066
  }, {
143978
- suffix: withCtx(() => _cache[18] || (_cache[18] = [
144067
+ suffix: withCtx(() => _cache[17] || (_cache[17] = [
143979
144068
  createTextVNode("%")
143980
144069
  ])),
143981
144070
  _: 1
@@ -144010,7 +144099,7 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
144010
144099
  }, 8, ["style"])
144011
144100
  ]),
144012
144101
  _: 1
144013
- }, 8, ["onEsc", "title"]);
144102
+ }, 8, ["title"]);
144014
144103
  };
144015
144104
  }
144016
144105
  });
@@ -144058,7 +144147,7 @@ const _sfc_main$2D = /* @__PURE__ */ defineComponent({
144058
144147
  if (mode.value === CanvasBuilderMode.ADMIN) {
144059
144148
  return true;
144060
144149
  }
144061
- return props.data?.view_controls?.enable_data_entry ?? false;
144150
+ return props.data?.view_controls?.enable_data_entry !== false;
144062
144151
  });
144063
144152
  onMounted(() => {
144064
144153
  if (justAddedComponentId.value === props.id) {