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

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
@@ -551,13 +551,13 @@ swiper-container::part(pagination) {
551
551
  line-height: 20px;
552
552
  letter-spacing: 0.25px;
553
553
  color: var(--ad430d74);
554
- }[data-v-da2357d4] .ais-SearchBox {
554
+ }[data-v-052f4440] .ais-SearchBox {
555
555
  margin: 0;
556
556
  }
557
- [data-v-da2357d4] .ais-SearchBox-submit,[data-v-da2357d4] .ais-SearchBox-reset {
557
+ [data-v-052f4440] .ais-SearchBox-submit,[data-v-052f4440] .ais-SearchBox-reset {
558
558
  display: none;
559
559
  }
560
- .admin-search[data-v-da2357d4] .ais-SearchBox-reset {
560
+ .admin-search[data-v-052f4440] .ais-SearchBox-reset {
561
561
  display: block !important;
562
562
  position: absolute !important;
563
563
  right: 12px !important;
@@ -571,17 +571,17 @@ swiper-container::part(pagination) {
571
571
  font-size: 16px !important;
572
572
  z-index: 10 !important;
573
573
  }
574
- .admin-search[data-v-da2357d4] .ais-SearchBox-reset:hover {
574
+ .admin-search[data-v-052f4440] .ais-SearchBox-reset:hover {
575
575
  color: var(--p-text2) !important;
576
576
  }
577
- .admin-search[data-v-da2357d4] .ais-SearchBox-reset:focus {
577
+ .admin-search[data-v-052f4440] .ais-SearchBox-reset:focus {
578
578
  outline: none !important;
579
579
  color: var(--p-primary) !important;
580
580
  }
581
- .admin-search[data-v-da2357d4] .ais-SearchBox-input {
581
+ .admin-search[data-v-052f4440] .ais-SearchBox-input {
582
582
  padding-right: 40px !important;
583
583
  }
584
- [data-v-da2357d4] .ais-SearchBox-input {
584
+ [data-v-052f4440] .ais-SearchBox-input {
585
585
  width: 100%;
586
586
  padding: 12px 16px 12px 40px;
587
587
  border: 1px solid var(--p-primary4);
@@ -590,39 +590,39 @@ swiper-container::part(pagination) {
590
590
  background-color: var(--p-base);
591
591
  transition: border-color 0.2s ease;
592
592
  }
593
- [data-v-da2357d4] .ais-SearchBox-input:focus {
593
+ [data-v-052f4440] .ais-SearchBox-input:focus {
594
594
  outline: none;
595
595
  border-color: var(--p-primary);
596
596
  box-shadow: 0 0 0 3px var(--p-primary5);
597
597
  }
598
- [data-v-da2357d4] .ais-SearchBox-input::placeholder {
598
+ [data-v-052f4440] .ais-SearchBox-input::placeholder {
599
599
  color: var(--p-text3);
600
600
  font-size: 14px;
601
601
  }
602
- .overflow-y-auto[data-v-da2357d4] {
602
+ .overflow-y-auto[data-v-052f4440] {
603
603
  scrollbar-width: thin;
604
604
  scrollbar-color: var(--p-border2) var(--p-surface2);
605
605
  }
606
- .overflow-y-auto[data-v-da2357d4]::-webkit-scrollbar {
606
+ .overflow-y-auto[data-v-052f4440]::-webkit-scrollbar {
607
607
  width: 6px;
608
608
  }
609
- .overflow-y-auto[data-v-da2357d4]::-webkit-scrollbar-track {
609
+ .overflow-y-auto[data-v-052f4440]::-webkit-scrollbar-track {
610
610
  background: var(--p-surface2);
611
611
  }
612
- .overflow-y-auto[data-v-da2357d4]::-webkit-scrollbar-thumb {
612
+ .overflow-y-auto[data-v-052f4440]::-webkit-scrollbar-thumb {
613
613
  background-color: var(--p-border2);
614
614
  border-radius: 3px;
615
615
  }
616
- .overflow-y-auto[data-v-da2357d4]::-webkit-scrollbar-thumb:hover {
616
+ .overflow-y-auto[data-v-052f4440]::-webkit-scrollbar-thumb:hover {
617
617
  background-color: var(--p-text3);
618
618
  }
619
- button[data-v-da2357d4]:hover {
619
+ button[data-v-052f4440]:hover {
620
620
  transition: all 0.2s ease;
621
621
  }
622
- button[data-v-da2357d4]:focus {
622
+ button[data-v-052f4440]:focus {
623
623
  outline: none;
624
624
  }
625
- [data-v-da2357d4] mark,[data-v-da2357d4] em {
625
+ [data-v-052f4440] mark,[data-v-052f4440] em {
626
626
  font-weight: bold;
627
627
  font-style: normal;
628
628
  }
@@ -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
@@ -95891,8 +95891,8 @@ const _sfc_main$5K = /* @__PURE__ */ defineComponent({
95891
95891
  }
95892
95892
  const emIndex = highlightValue.indexOf("<em>");
95893
95893
  if (emIndex === -1) return "";
95894
- const startChar = Math.max(0, emIndex - 75);
95895
- const endChar = Math.min(highlightValue.length, emIndex + 125);
95894
+ const startChar = Math.max(0, emIndex - 100);
95895
+ const endChar = Math.min(highlightValue.length, emIndex + 100);
95896
95896
  let truncated = highlightValue.substring(startChar, endChar);
95897
95897
  if (startChar > 0) truncated = "..." + truncated;
95898
95898
  if (endChar < highlightValue.length) truncated = truncated + "...";
@@ -96093,7 +96093,7 @@ const _sfc_main$5K = /* @__PURE__ */ defineComponent({
96093
96093
  show: "",
96094
96094
  verticalAlignment: "top",
96095
96095
  "z-index": _ctx.zIndex,
96096
- "onUpdate:show": _cache[15] || (_cache[15] = ($event) => emit("toggleSearch", $event))
96096
+ "onUpdate:show": _cache[16] || (_cache[16] = ($event) => emit("toggleSearch", $event))
96097
96097
  }, {
96098
96098
  default: withCtx(() => [
96099
96099
  createElementVNode("div", {
@@ -96102,7 +96102,7 @@ const _sfc_main$5K = /* @__PURE__ */ defineComponent({
96102
96102
  }, [
96103
96103
  createElementVNode("div", _hoisted_1$4w, [
96104
96104
  createElementVNode("div", _hoisted_2$3j, [
96105
- _cache[16] || (_cache[16] = createElementVNode("div", { class: "absolute left-2.5 top-1/2 transform -translate-y-1/2 z-10" }, [
96105
+ _cache[17] || (_cache[17] = createElementVNode("div", { class: "absolute left-2.5 top-1/2 transform -translate-y-1/2 z-10" }, [
96106
96106
  createElementVNode("i", { class: "c-icon far fa-search text-gray-400 text-l" })
96107
96107
  ], -1)),
96108
96108
  withDirectives(createElementVNode("input", {
@@ -96208,7 +96208,7 @@ const _sfc_main$5K = /* @__PURE__ */ defineComponent({
96208
96208
  show: showFileTypeDropdown.value,
96209
96209
  "show-arrow": false,
96210
96210
  trigger: "manual",
96211
- onClickoutside: _cache[7] || (_cache[7] = ($event) => showFileTypeDropdown.value = false)
96211
+ onClickoutside: _cache[8] || (_cache[8] = ($event) => showFileTypeDropdown.value = false)
96212
96212
  }, {
96213
96213
  trigger: withCtx(() => [
96214
96214
  createVNode(unref(NTag), {
@@ -96221,12 +96221,20 @@ const _sfc_main$5K = /* @__PURE__ */ defineComponent({
96221
96221
  themeOverrides: {
96222
96222
  borderRadius: "4px"
96223
96223
  },
96224
- onClick: _cache[6] || (_cache[6] = ($event) => showFileTypeDropdown.value = !showFileTypeDropdown.value)
96224
+ onClick: _cache[7] || (_cache[7] = ($event) => showFileTypeDropdown.value = !showFileTypeDropdown.value)
96225
96225
  }, {
96226
96226
  default: withCtx(() => [
96227
96227
  createElementVNode("div", _hoisted_10$C, [
96228
96228
  createElementVNode("span", null, toDisplayString(unref(t)("canvasUI.CAlgoliaSearch.filters.type")), 1),
96229
- selectedFileTypes.value.length ? (openBlock(), createElementBlock("span", _hoisted_11$x, ": " + toDisplayString(selectedFileTypes.value.length), 1)) : createCommentVNode("", true)
96229
+ selectedFileTypes.value.length ? (openBlock(), createElementBlock("span", _hoisted_11$x, ": " + toDisplayString(selectedFileTypes.value.length), 1)) : createCommentVNode("", true),
96230
+ selectedFileTypes.value.length ? (openBlock(), createBlock(CIcon, {
96231
+ key: 1,
96232
+ class: "ml-1",
96233
+ color: "var(--p-primary2)",
96234
+ icon: "xmark",
96235
+ size: "12",
96236
+ onClick: _cache[6] || (_cache[6] = withModifiers(($event) => selectedFileTypes.value = [], ["stop"]))
96237
+ })) : createCommentVNode("", true)
96230
96238
  ])
96231
96239
  ]),
96232
96240
  _: 1
@@ -96275,7 +96283,7 @@ const _sfc_main$5K = /* @__PURE__ */ defineComponent({
96275
96283
  _: 1
96276
96284
  }, 8, ["show"]),
96277
96285
  hasActiveFilters.value ? (openBlock(), createElementBlock("div", _hoisted_14$h, [
96278
- _cache[17] || (_cache[17] = createElementVNode("div", { class: "h-6 w-px bg-gray-300 mx-2" }, null, -1)),
96286
+ _cache[18] || (_cache[18] = createElementVNode("div", { class: "h-6 w-px bg-gray-300 mx-2" }, null, -1)),
96279
96287
  createElementVNode("span", {
96280
96288
  class: "text-sm text-gray-600 hover:text-gray-800 font-normal cursor-pointer",
96281
96289
  onClick: clearAllFilters
@@ -96293,7 +96301,7 @@ const _sfc_main$5K = /* @__PURE__ */ defineComponent({
96293
96301
  themeOverrides: {
96294
96302
  borderRadius: "4px"
96295
96303
  },
96296
- onClick: _cache[8] || (_cache[8] = ($event) => toggleCanvasFilter("saved_canvas"))
96304
+ onClick: _cache[9] || (_cache[9] = ($event) => toggleCanvasFilter("saved_canvas"))
96297
96305
  }, {
96298
96306
  default: withCtx(() => [
96299
96307
  createElementVNode("span", null, toDisplayString(unref(t)("canvasUI.CAlgoliaSearch.canvasFilters.saved")), 1)
@@ -96310,7 +96318,7 @@ const _sfc_main$5K = /* @__PURE__ */ defineComponent({
96310
96318
  themeOverrides: {
96311
96319
  borderRadius: "4px"
96312
96320
  },
96313
- onClick: _cache[9] || (_cache[9] = ($event) => toggleCanvasFilter("template"))
96321
+ onClick: _cache[10] || (_cache[10] = ($event) => toggleCanvasFilter("template"))
96314
96322
  }, {
96315
96323
  default: withCtx(() => [
96316
96324
  createElementVNode("span", null, toDisplayString(unref(t)("canvasUI.CAlgoliaSearch.canvasFilters.templates")), 1)
@@ -96328,7 +96336,7 @@ const _sfc_main$5K = /* @__PURE__ */ defineComponent({
96328
96336
  themeOverrides: {
96329
96337
  borderRadius: "4px"
96330
96338
  },
96331
- onClick: _cache[10] || (_cache[10] = ($event) => toggleCanvasFilter("product_template"))
96339
+ onClick: _cache[11] || (_cache[11] = ($event) => toggleCanvasFilter("product_template"))
96332
96340
  }, {
96333
96341
  default: withCtx(() => [
96334
96342
  createElementVNode("span", null, toDisplayString(unref(t)("canvasUI.CAlgoliaSearch.canvasFilters.productTemplates")), 1)
@@ -96345,7 +96353,7 @@ const _sfc_main$5K = /* @__PURE__ */ defineComponent({
96345
96353
  themeOverrides: {
96346
96354
  borderRadius: "4px"
96347
96355
  },
96348
- onClick: _cache[11] || (_cache[11] = ($event) => toggleCanvasFilter("section"))
96356
+ onClick: _cache[12] || (_cache[12] = ($event) => toggleCanvasFilter("section"))
96349
96357
  }, {
96350
96358
  default: withCtx(() => [
96351
96359
  createElementVNode("span", null, toDisplayString(unref(t)("canvasUI.CAlgoliaSearch.canvasFilters.products")), 1)
@@ -96362,7 +96370,7 @@ const _sfc_main$5K = /* @__PURE__ */ defineComponent({
96362
96370
  themeOverrides: {
96363
96371
  borderRadius: "4px"
96364
96372
  },
96365
- onClick: _cache[12] || (_cache[12] = ($event) => toggleCanvasFilter("block"))
96373
+ onClick: _cache[13] || (_cache[13] = ($event) => toggleCanvasFilter("block"))
96366
96374
  }, {
96367
96375
  default: withCtx(() => [
96368
96376
  createElementVNode("span", null, toDisplayString(unref(t)("canvasUI.CAlgoliaSearch.canvasFilters.blocks")), 1)
@@ -96370,7 +96378,7 @@ const _sfc_main$5K = /* @__PURE__ */ defineComponent({
96370
96378
  _: 1
96371
96379
  }, 8, ["style"]),
96372
96380
  selectedCanvasFilters.value.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_15$f, [
96373
- _cache[18] || (_cache[18] = createElementVNode("div", { class: "h-6 w-px bg-gray-300 mx-2" }, null, -1)),
96381
+ _cache[19] || (_cache[19] = createElementVNode("div", { class: "h-6 w-px bg-gray-300 mx-2" }, null, -1)),
96374
96382
  createElementVNode("span", {
96375
96383
  class: "text-sm text-gray-600 hover:text-gray-800 font-normal cursor-pointer",
96376
96384
  onClick: clearCanvasFilters
@@ -96400,7 +96408,7 @@ const _sfc_main$5K = /* @__PURE__ */ defineComponent({
96400
96408
  }), 128))
96401
96409
  ]),
96402
96410
  recentlyOpenedDocs.value.length > 0 ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
96403
- _cache[19] || (_cache[19] = createElementVNode("hr", { class: "border-0 h-px bg-gray-200 mt-2 mb-3 w-full" }, null, -1)),
96411
+ _cache[20] || (_cache[20] = createElementVNode("hr", { class: "border-0 h-px bg-gray-200 mt-2 mb-3 w-full" }, null, -1)),
96404
96412
  createElementVNode("div", _hoisted_21$7, [
96405
96413
  createElementVNode("span", _hoisted_22$5, toDisplayString(unref(t)("canvasUI.components.fileViewer.recentlyOpened")), 1)
96406
96414
  ]),
@@ -96517,7 +96525,7 @@ const _sfc_main$5K = /* @__PURE__ */ defineComponent({
96517
96525
  filteredContentFiles.value.length > 5 ? (openBlock(), createElementBlock("div", _hoisted_44$4, [
96518
96526
  createElementVNode("span", {
96519
96527
  class: "text-sm text-gray-600 hover:text-gray-800 font-bold flex items-center cursor-pointer",
96520
- onClick: _cache[13] || (_cache[13] = ($event) => searchType.value = "content")
96528
+ onClick: _cache[14] || (_cache[14] = ($event) => searchType.value = "content")
96521
96529
  }, [
96522
96530
  createTextVNode(toDisplayString(unref(t)("canvasUI.CAlgoliaSearch.actions.viewAll")) + " ", 1),
96523
96531
  createVNode(CIcon, {
@@ -96569,7 +96577,7 @@ const _sfc_main$5K = /* @__PURE__ */ defineComponent({
96569
96577
  filteredCanvasFiles.value.length > 5 ? (openBlock(), createElementBlock("div", _hoisted_55$2, [
96570
96578
  createElementVNode("span", {
96571
96579
  class: "text-sm text-gray-600 hover:text-gray-800 font-bold flex items-center cursor-pointer",
96572
- onClick: _cache[14] || (_cache[14] = ($event) => searchType.value = "canvases")
96580
+ onClick: _cache[15] || (_cache[15] = ($event) => searchType.value = "canvases")
96573
96581
  }, [
96574
96582
  createTextVNode(toDisplayString(unref(t)("canvasUI.CAlgoliaSearch.actions.viewAll")) + " ", 1),
96575
96583
  createVNode(CIcon, {
@@ -96725,7 +96733,7 @@ const _sfc_main$5K = /* @__PURE__ */ defineComponent({
96725
96733
  }
96726
96734
  });
96727
96735
 
96728
- const CAlgoliaSearch = /* @__PURE__ */ _export_sfc(_sfc_main$5K, [["__scopeId", "data-v-da2357d4"]]);
96736
+ const CAlgoliaSearch = /* @__PURE__ */ _export_sfc(_sfc_main$5K, [["__scopeId", "data-v-052f4440"]]);
96729
96737
 
96730
96738
  const BulletListExtended = BulletList.extend({
96731
96739
  addOptions() {
@@ -111026,6 +111034,7 @@ function useCanvasStandardFilters(options = {}) {
111026
111034
  includeTagsFilter = true,
111027
111035
  includeDraftFilter = true,
111028
111036
  includeTemplateFilter = false,
111037
+ templateOptions,
111029
111038
  includeOwnerFilter = false,
111030
111039
  ownerLabel
111031
111040
  } = options;
@@ -111054,9 +111063,10 @@ function useCanvasStandardFilters(options = {}) {
111054
111063
  }
111055
111064
  if (includeTemplateFilter) {
111056
111065
  components.push({
111057
- type: MetadataTemplateFieldTypeEnum.TEXT,
111058
- name: "template__name__icontains",
111059
- label: t("canvasUI.composables.useCanvasStandardFilters.templateUsed")
111066
+ type: MetadataTemplateFieldTypeEnum.SELECT,
111067
+ name: "template__id",
111068
+ label: t("canvasUI.composables.useCanvasStandardFilters.templateUsed"),
111069
+ options: templateOptions?.value ?? []
111060
111070
  });
111061
111071
  }
111062
111072
  return components;
@@ -118276,6 +118286,7 @@ const _sfc_main$4q = /*@__PURE__*/defineComponent({
118276
118286
  const fetchedData = ref([]);
118277
118287
  const isLoading = ref(false);
118278
118288
  const accessibleTemplateIds = ref(new Set());
118289
+ const availableTemplates = ref([]);
118279
118290
  const isCheckingTemplateAccess = ref(false);
118280
118291
  const isBulkDeleting = ref(false);
118281
118292
  const isBulkUpdating = ref(false);
@@ -118351,11 +118362,32 @@ const _sfc_main$4q = /*@__PURE__*/defineComponent({
118351
118362
  return systemTags.includes(lowerTag);
118352
118363
  }) ?? false;
118353
118364
  }
118365
+ const templateOptions = computed(() => availableTemplates.value.map(t => ({
118366
+ label: t.name,
118367
+ value: t.id
118368
+ })).sort((a, b) => a.label.localeCompare(b.label)));
118369
+ async function fetchTemplates() {
118370
+ try {
118371
+ const {
118372
+ results
118373
+ } = await props.fetcher({
118374
+ is_template: true,
118375
+ is_section: false,
118376
+ page: 1,
118377
+ page_size: 1000,
118378
+ fields: 'id,name'
118379
+ });
118380
+ availableTemplates.value = results;
118381
+ } catch (e) {
118382
+ console.error('Failed to fetch templates for filter:', e);
118383
+ }
118384
+ }
118354
118385
  const {
118355
118386
  filterComponents: dataFilterComponents
118356
118387
  } = useCanvasStandardFilters({
118357
118388
  includeTemplateFilter: true,
118358
- includeOwnerFilter: props.isAnyTypeOfAdmin ?? false
118389
+ includeOwnerFilter: props.isAnyTypeOfAdmin ?? false,
118390
+ templateOptions
118359
118391
  });
118360
118392
  const {
118361
118393
  height: canvasManagementToolbarHeight
@@ -119111,6 +119143,7 @@ const _sfc_main$4q = /*@__PURE__*/defineComponent({
119111
119143
  onMounted(async () => {
119112
119144
  try {
119113
119145
  isLoading.value = true;
119146
+ fetchTemplates();
119114
119147
  await fetch(fetchingParams.value);
119115
119148
  } catch (e) {
119116
119149
  console.error(e);
@@ -119285,6 +119318,9 @@ const _sfc_main$4o = /*@__PURE__*/defineComponent({
119285
119318
  fetcher: {
119286
119319
  type: Function
119287
119320
  },
119321
+ templatesFetcher: {
119322
+ type: Function
119323
+ },
119288
119324
  byIdFetcher: {
119289
119325
  type: Function
119290
119326
  },
@@ -119330,21 +119366,43 @@ const _sfc_main$4o = /*@__PURE__*/defineComponent({
119330
119366
  const tableRef = ref(null);
119331
119367
  const toolbarWrapper = ref(null);
119332
119368
  const launchDarkly = inject('launchDarkly', computed(() => ({})));
119369
+ const isLoading = ref(false);
119370
+ const fetchedData = ref([]);
119371
+ const totalCount = ref(0);
119372
+ const availableTemplates = ref([]);
119373
+ const templateOptions = computed(() => availableTemplates.value.map(t => ({
119374
+ label: t.name,
119375
+ value: t.id
119376
+ })).sort((a, b) => a.label.localeCompare(b.label)));
119377
+ async function fetchTemplates() {
119378
+ if (!props.templatesFetcher) return;
119379
+ try {
119380
+ const {
119381
+ results
119382
+ } = await props.templatesFetcher({
119383
+ is_template: true,
119384
+ is_section: false,
119385
+ page: 1,
119386
+ page_size: 1000,
119387
+ fields: 'id,name'
119388
+ });
119389
+ availableTemplates.value = results;
119390
+ } catch (e) {
119391
+ console.error('Failed to fetch templates for filter:', e);
119392
+ }
119393
+ }
119333
119394
  const {
119334
119395
  filterComponents: dataFilterComponents
119335
119396
  } = useCanvasStandardFilters({
119336
119397
  includeTemplateFilter: true,
119337
119398
  includeOwnerFilter: true,
119338
- // Include owner filter for assigned canvases
119339
119399
  includeTagsFilter: true,
119340
- includeDraftFilter: true
119400
+ includeDraftFilter: true,
119401
+ templateOptions
119341
119402
  });
119342
119403
  const {
119343
119404
  height: canvasManagementToolbarHeight
119344
119405
  } = useElementSize(toolbarWrapper);
119345
- const isLoading = ref(false);
119346
- const fetchedData = ref([]);
119347
- const totalCount = ref(0);
119348
119406
  const {
119349
119407
  search,
119350
119408
  pageSize,
@@ -119591,6 +119649,7 @@ const _sfc_main$4o = /*@__PURE__*/defineComponent({
119591
119649
  onMounted(async () => {
119592
119650
  try {
119593
119651
  isLoading.value = true;
119652
+ fetchTemplates();
119594
119653
  await fetch(fetchingParams.value);
119595
119654
  } catch (e) {
119596
119655
  console.error(e);
@@ -119644,7 +119703,7 @@ const _sfc_main$4o = /*@__PURE__*/defineComponent({
119644
119703
  }
119645
119704
  });
119646
119705
 
119647
- const CAssignedCanvasesManagement = /* @__PURE__ */ _export_sfc(_sfc_main$4o, [["__scopeId", "data-v-f6151990"]]);
119706
+ const CAssignedCanvasesManagement = /* @__PURE__ */ _export_sfc(_sfc_main$4o, [["__scopeId", "data-v-df004301"]]);
119648
119707
 
119649
119708
  const _hoisted_1$3v = { class: "w-fit flex items-center justify-center text-truncate rd uppercase c-table-select" };
119650
119709
  const __default__ = {
@@ -131590,21 +131649,24 @@ const displayIntegerWithMunit = (number, decimals = 2) => {
131590
131649
  return `${b.toFixed(decimals)}B`;
131591
131650
  };
131592
131651
  const convertSecondsToMinutes = (number) => {
131652
+ if (number <= 0) return "0 sec";
131653
+ if (number < 1) return "<1 sec";
131593
131654
  const units = [
131594
- [1, "sec"],
131595
- [60, "min"],
131655
+ [60 * 60 * 24, "day"],
131596
131656
  [60 * 60, "h"],
131597
- [60 * 60 * 24, "day"]
131657
+ [60, "min"],
131658
+ [1, "sec"]
131598
131659
  ];
131599
- let bestUnit = units[0];
131600
- for (const unit of units) {
131601
- if (number >= unit[0]) {
131602
- bestUnit = unit;
131660
+ const parts = [];
131661
+ let remaining = number;
131662
+ for (const [divisor, label] of units) {
131663
+ if (remaining >= divisor) {
131664
+ const val = Math.floor(remaining / divisor);
131665
+ parts.push(`${val} ${label}`);
131666
+ remaining = remaining % divisor;
131603
131667
  }
131604
131668
  }
131605
- const [divisor, label] = bestUnit;
131606
- const val = Math.floor(number / Number(divisor));
131607
- return `${val} ${label}`;
131669
+ return parts.slice(0, 2).join(" ");
131608
131670
  };
131609
131671
  const getNumberWithRegex = (string) => {
131610
131672
  return string?.replace(/\D+/g, "");
@@ -142417,7 +142479,10 @@ const _hoisted_94 = { class: "flex flex-col gap-2" };
142417
142479
  const _hoisted_95 = { class: "flex items-center gap-2" };
142418
142480
  const _hoisted_96 = { class: "text-sm" };
142419
142481
  const _hoisted_97 = { class: "text-sm" };
142420
- const _hoisted_98 = { class: "flex items-center gap-2" };
142482
+ const _hoisted_98 = {
142483
+ key: 0,
142484
+ class: "flex items-center gap-2"
142485
+ };
142421
142486
  const _hoisted_99 = { class: "text-sm" };
142422
142487
  const _hoisted_100 = { class: "mb-4" };
142423
142488
  const _hoisted_101 = { class: "block mb-2" };
@@ -142443,7 +142508,9 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
142443
142508
  const props = __props;
142444
142509
  const { t } = useI18n();
142445
142510
  const themeVars = useThemeVars();
142446
- const { setComponentEditMode, updateNodeDataById } = useCanvas$1();
142511
+ const { mode, setComponentEditMode, updateNodeDataById } = useCanvas$1();
142512
+ const isAdminMode = computed(() => mode.value === CanvasBuilderMode.ADMIN);
142513
+ const confirmation = useConfirmation();
142447
142514
  const { crmShape } = useCrmShape();
142448
142515
  const { palette } = useCanvasTheme$1();
142449
142516
  let seriesIdCounter = 0;
@@ -142531,7 +142598,9 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
142531
142598
  });
142532
142599
  const chartType = computed(() => seriesList.value[0]?.chartType ?? "bar");
142533
142600
  const primaryChartType = computed(() => seriesList.value[0]?.chartType ?? "bar");
142534
- const backgroundColor = props.data?.data?.datasets?.[0]?.background_color;
142601
+ const savedColorScheme = props.data?.color_scheme;
142602
+ const datasets = props.data?.data?.datasets;
142603
+ const backgroundColor = savedColorScheme ?? (datasets && datasets.length > 1 ? datasets.map((ds) => ds.background_color).filter(Boolean) : datasets?.[0]?.background_color);
142535
142604
  const colorSchemeType = ref(props.data?.color_scheme_type ?? "theme");
142536
142605
  const chartColors = ref([]);
142537
142606
  const displayColors = computed(() => {
@@ -142566,7 +142635,7 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
142566
142635
  const percentDisplay = ref(props.data?.percent_display ?? false);
142567
142636
  const enableFullscreenBtn = ref(props.data?.view_controls?.enable_fullscreen_btn ?? false);
142568
142637
  const enableChartTypeSwitcher = ref(props.data?.view_controls?.enable_chart_type_switcher ?? false);
142569
- const enableDataEntry = ref(props.data?.view_controls?.enable_data_entry ?? false);
142638
+ const enableDataEntry = ref(props.data?.view_controls?.enable_data_entry !== false);
142570
142639
  const chartHeight = ref(props.data?.chart_height ?? 800);
142571
142640
  const chartWidth = ref(props.data?.chart_width ?? 100);
142572
142641
  const legendPositionOptions = [
@@ -143083,7 +143152,7 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143083
143152
  return chartColors.value;
143084
143153
  }
143085
143154
  function createChartConfig() {
143086
- const datasets = [];
143155
+ const datasets2 = [];
143087
143156
  let allLabels = [];
143088
143157
  const colorsForStorage = getSeriesColors(true);
143089
143158
  const isSingleSeries = seriesList.value.length === 1;
@@ -143128,7 +143197,7 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143128
143197
  if (processedData.labels.length > allLabels.length) {
143129
143198
  allLabels = processedData.labels;
143130
143199
  }
143131
- datasets.push(datasetOptions);
143200
+ datasets2.push(datasetOptions);
143132
143201
  });
143133
143202
  const primaryType = seriesList.value[0].chartType;
143134
143203
  let actualPrimaryType = primaryType;
@@ -143167,6 +143236,7 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143167
143236
  const config = {
143168
143237
  type: actualPrimaryType,
143169
143238
  color_scheme_type: colorSchemeType.value,
143239
+ color_scheme: colorsForStorage,
143170
143240
  percent_display: percentDisplay.value,
143171
143241
  chart_height: chartHeight.value,
143172
143242
  chart_width: chartWidth.value,
@@ -143177,7 +143247,7 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143177
143247
  },
143178
143248
  data: {
143179
143249
  labels: allLabels,
143180
- datasets
143250
+ datasets: datasets2
143181
143251
  },
143182
143252
  options: {
143183
143253
  responsive: true,
@@ -143225,6 +143295,22 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143225
143295
  return config;
143226
143296
  }
143227
143297
  function onCancel() {
143298
+ if (isDirty.value) {
143299
+ confirmation.warning({
143300
+ title: t("canvasUI.canvasBuilder.confirmationOnUnsavedChanges.title"),
143301
+ content: t("canvasUI.canvasBuilder.confirmationOnUnsavedChanges.content"),
143302
+ confirmText: t("canvasUI.canvasBuilder.confirmationOnUnsavedChanges.confirm"),
143303
+ exitText: t("canvasUI.canvasBuilder.confirmationOnUnsavedChanges.exit"),
143304
+ hasExit: true,
143305
+ onConfirm: () => {
143306
+ onSave();
143307
+ },
143308
+ onExit: () => {
143309
+ setComponentEditMode(false);
143310
+ }
143311
+ });
143312
+ return;
143313
+ }
143228
143314
  setComponentEditMode(false);
143229
143315
  }
143230
143316
  function onSave() {
@@ -143233,6 +143319,10 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143233
143319
  setComponentEditMode(false);
143234
143320
  }
143235
143321
  const previewData = ref({});
143322
+ const isDirty = ref(false);
143323
+ function markDirty() {
143324
+ isDirty.value = true;
143325
+ }
143236
143326
  function updatePreview() {
143237
143327
  const config = createChartConfig();
143238
143328
  previewData.value = {
@@ -143254,6 +143344,7 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143254
143344
  enableChartTypeSwitcher.value = false;
143255
143345
  }
143256
143346
  });
143347
+ let isInitialized = false;
143257
143348
  watch(
143258
143349
  [
143259
143350
  seriesList,
@@ -143275,17 +143366,23 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143275
143366
  ],
143276
143367
  () => {
143277
143368
  updatePreview();
143369
+ if (isInitialized) {
143370
+ markDirty();
143371
+ }
143278
143372
  },
143279
143373
  { deep: true }
143280
143374
  );
143281
143375
  onMounted(() => {
143282
143376
  updatePreview();
143377
+ nextTick(() => {
143378
+ isInitialized = true;
143379
+ });
143283
143380
  });
143284
143381
  return (_ctx, _cache) => {
143285
143382
  return openBlock(), createBlock(unref(NModal), {
143286
143383
  bordered: false,
143287
143384
  class: "cb-data-charts-settings",
143288
- onEsc: () => unref(setComponentEditMode)(false),
143385
+ onEsc: onCancel,
143289
143386
  preset: "card",
143290
143387
  show: true,
143291
143388
  size: "huge",
@@ -143297,7 +143394,7 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143297
143394
  "--n-padding-left": "16px"
143298
143395
  }]),
143299
143396
  title: unref(t)("canvasUI.canvasBuilder.dataCharts.editDataChartsComponent"),
143300
- onClose: _cache[16] || (_cache[16] = ($event) => unref(setComponentEditMode)(false))
143397
+ onClose: onCancel
143301
143398
  }, {
143302
143399
  footer: withCtx(() => [
143303
143400
  createElementVNode("div", _hoisted_110, [
@@ -143937,13 +144034,13 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143937
144034
  ]),
143938
144035
  _: 1
143939
144036
  }, 8, ["disabled"]),
143940
- createElementVNode("div", _hoisted_98, [
144037
+ isAdminMode.value ? (openBlock(), createElementBlock("div", _hoisted_98, [
143941
144038
  createVNode(unref(NSwitch), {
143942
144039
  value: enableDataEntry.value,
143943
144040
  "onUpdate:value": _cache[13] || (_cache[13] = ($event) => enableDataEntry.value = $event)
143944
144041
  }, null, 8, ["value"]),
143945
144042
  createElementVNode("span", _hoisted_99, toDisplayString(unref(t)("canvasUI.canvasBuilder.dataCharts.enableDataEntry")), 1)
143946
- ])
144043
+ ])) : createCommentVNode("", true)
143947
144044
  ])
143948
144045
  ]),
143949
144046
  createElementVNode("div", _hoisted_100, [
@@ -143959,7 +144056,7 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143959
144056
  min: 100,
143960
144057
  step: 10
143961
144058
  }, {
143962
- suffix: withCtx(() => _cache[17] || (_cache[17] = [
144059
+ suffix: withCtx(() => _cache[16] || (_cache[16] = [
143963
144060
  createTextVNode("px")
143964
144061
  ])),
143965
144062
  _: 1
@@ -143975,7 +144072,7 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
143975
144072
  min: 10,
143976
144073
  step: 5
143977
144074
  }, {
143978
- suffix: withCtx(() => _cache[18] || (_cache[18] = [
144075
+ suffix: withCtx(() => _cache[17] || (_cache[17] = [
143979
144076
  createTextVNode("%")
143980
144077
  ])),
143981
144078
  _: 1
@@ -144010,7 +144107,7 @@ const _sfc_main$2E = /* @__PURE__ */ defineComponent({
144010
144107
  }, 8, ["style"])
144011
144108
  ]),
144012
144109
  _: 1
144013
- }, 8, ["onEsc", "title"]);
144110
+ }, 8, ["title"]);
144014
144111
  };
144015
144112
  }
144016
144113
  });
@@ -144058,7 +144155,7 @@ const _sfc_main$2D = /* @__PURE__ */ defineComponent({
144058
144155
  if (mode.value === CanvasBuilderMode.ADMIN) {
144059
144156
  return true;
144060
144157
  }
144061
- return props.data?.view_controls?.enable_data_entry ?? false;
144158
+ return props.data?.view_controls?.enable_data_entry !== false;
144062
144159
  });
144063
144160
  onMounted(() => {
144064
144161
  if (justAddedComponentId.value === props.id) {