django-unfold 0.66.0__py3-none-any.whl → 0.67.0__py3-none-any.whl

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.
@@ -416,6 +416,12 @@ const DEFAULT_CHART_OPTIONS = {
416
416
  pointBorderWidth: 0,
417
417
  pointStyle: false,
418
418
  },
419
+ pie: {
420
+ borderWidth: 0,
421
+ },
422
+ doughnut: {
423
+ borderWidth: 0,
424
+ },
419
425
  },
420
426
  plugins: {
421
427
  legend: {
@@ -436,6 +442,13 @@ const DEFAULT_CHART_OPTIONS = {
436
442
  },
437
443
  scales: {
438
444
  x: {
445
+ display: function (context) {
446
+ if (["pie", "doughnut", "radar"].includes(context.chart.config.type)) {
447
+ return false;
448
+ }
449
+
450
+ return true;
451
+ },
439
452
  border: {
440
453
  dash: [5, 5],
441
454
  dashOffset: 2,
@@ -456,6 +469,13 @@ const DEFAULT_CHART_OPTIONS = {
456
469
  },
457
470
  },
458
471
  y: {
472
+ display: function (context) {
473
+ if (["pie", "doughnut", "radar"].includes(context.chart.config.type)) {
474
+ return false;
475
+ }
476
+
477
+ return true;
478
+ },
459
479
  border: {
460
480
  dash: [5, 5],
461
481
  dashOffset: 5,
@@ -512,8 +532,17 @@ const renderCharts = () => {
512
532
  const borderColor = hasDarkClass ? baseColorDark : baseColorLight;
513
533
 
514
534
  for (const chart of charts) {
515
- chart.options.scales.x.grid.color = borderColor;
516
- chart.options.scales.y.grid.color = borderColor;
535
+ if (chart.options.scales.x) {
536
+ chart.options.scales.x.grid.color = borderColor;
537
+ }
538
+
539
+ if (chart.options.scales.y) {
540
+ chart.options.scales.y.grid.color = borderColor;
541
+ }
542
+
543
+ if (chart.options.scales.r) {
544
+ chart.options.scales.r.grid.color = borderColor;
545
+ }
517
546
  chart.update();
518
547
  }
519
548
  };
@@ -533,7 +562,17 @@ const renderCharts = () => {
533
562
  for (const key in parsedData.datasets) {
534
563
  const dataset = parsedData.datasets[key];
535
564
  const processColor = (colorProp) => {
536
- if (dataset?.[colorProp]?.startsWith("var(")) {
565
+ if (Array.isArray(dataset?.[colorProp])) {
566
+ for (const [index, prop] of dataset?.[colorProp].entries()) {
567
+ if (prop.startsWith("var(")) {
568
+ const cssVar = prop.match(/var\((.*?)\)/)[1];
569
+ const color = getComputedStyle(document.documentElement)
570
+ .getPropertyValue(cssVar)
571
+ .trim();
572
+ dataset[colorProp][index] = color;
573
+ }
574
+ }
575
+ } else if (dataset?.[colorProp]?.startsWith("var(")) {
537
576
  const cssVar = dataset[colorProp].match(/var\((.*?)\)/)[1];
538
577
  const color = getComputedStyle(document.documentElement)
539
578
  .getPropertyValue(cssVar)
@@ -546,11 +585,30 @@ const renderCharts = () => {
546
585
  processColor("backgroundColor");
547
586
  }
548
587
 
588
+ CHART_OPTIONS = { ...DEFAULT_CHART_OPTIONS };
589
+ if (type === "radar") {
590
+ CHART_OPTIONS.scales = {
591
+ r: {
592
+ ticks: {
593
+ backdropColor: "transparent",
594
+ },
595
+ pointLabels: {
596
+ color: "#9ca3af",
597
+ font: {
598
+ size: 12,
599
+ },
600
+ },
601
+ },
602
+ };
603
+ }
604
+ Chart.defaults.font.family = "Inter";
605
+ Chart.defaults.font.size = 12;
606
+
549
607
  charts.push(
550
608
  new Chart(ctx, {
551
609
  type: type || "bar",
552
610
  data: parsedData,
553
- options: options ? JSON.parse(options) : { ...DEFAULT_CHART_OPTIONS },
611
+ options: options ? JSON.parse(options) : { ...CHART_OPTIONS },
554
612
  })
555
613
  );
556
614
  }
@@ -18,7 +18,7 @@
18
18
  return this;
19
19
  };
20
20
 
21
- $.fn.djangoAdminSelect2 = function () {
21
+ $.fn.djangoFilterSelect2 = function () {
22
22
  $.each(this, function (i, element) {
23
23
  $(element).select2({
24
24
  ajax: {
@@ -40,13 +40,6 @@
40
40
  $(function () {
41
41
  $(".unfold-admin-autocomplete.admin-autocomplete").djangoCustomSelect2();
42
42
 
43
- $(".admin-autocomplete")
44
- .not(".unfold-admin-autocomplete")
45
- .not("[name*=__prefix__]")
46
- .djangoAdminSelect2();
47
- });
48
-
49
- document.addEventListener("formset:added", (event) => {
50
- $(event.target).find(".admin-autocomplete").djangoAdminSelect2();
43
+ $(".unfold-filter-autocomplete.admin-autocomplete").djangoFilterSelect2();
51
44
  });
52
45
  }
unfold/styles.css CHANGED
@@ -16,7 +16,7 @@
16
16
  @source inline("{md:,lg:,2xl:,}relative {md:,lg:,2xl:,}flex {md:,lg:,2xl:,}absolute {md:,lg:,2xl:,}sticky");
17
17
  @source inline("{-,}{lg:,}m{t,r,b,l,x,y,}-{0..24} {-,}{lg:,}p{t,r,b,l,x,y,}-{0..24}");
18
18
  @source inline("{md:,lg:,}border-{0,2} {md:,lg:,}border-{t,r,b,l}-{0,2}");
19
- @source inline("{hover:,dark:,}bg-primary-{50,{100..900..100},950}");
19
+ @source inline("{!,}{hover:,dark:,}bg-primary-{50,{100..900..100},950}");
20
20
  @source inline("{hover:,dark:,}border-base-{50,{100..900..100},950} {hover:,dark:,}border-transparent");
21
21
  @source inline("{hover:,dark:,}bg-base-{50,{100..900..100},950}");
22
22
  @source inline("{md:,lg:,}{min-h,h,min-w,w}-{1..8} {md:,lg:,}w-{1/2,1/3,2/3,1/4,2/4,3/4,1/5,2/5,3/5,4/5,1/6,2/6,3/6,4/6,5/6,1/7,2/7,3/7,4/7,5/7,6/7}");
@@ -637,10 +637,6 @@ fieldset details[open] > summary:after {
637
637
  @apply bg-primary-600 border-0 h-1;
638
638
  }
639
639
 
640
- #changelist-filter .admin-numeric-filter-slider-tooltips {
641
- @apply flex flex-row font-medium mb-5 space-x-4 text-base-500 text-sm;
642
- }
643
-
644
640
  /*******************************************************
645
641
  Trix
646
642
  *******************************************************/
@@ -1,8 +1,17 @@
1
1
  <{% if href %}a href="{{ href }}"{% else %}div{% endif %} class="bg-white block flex flex-col grow overflow-hidden p-6 relative rounded-default shadow-xs dark:bg-base-900 dark:border-base-800 {% if not disable_border %}border border-base-200 {% else %}shadow-base-500/20{% endif %} {% if href %}cursor-pointer transition-all hover:border-base-300 hover:shadow-md dark:hover:border-base-700 dark:hover:shadow-base-800/50 {% endif %}{% if class %} {{ class }}{% endif %}">
2
+
2
3
  {% if title %}
3
- <h2 class="border-b border-base-200 font-semibold mb-6 -mt-6 -mx-6 py-4 px-6 text-[15px] text-font-important-light dark:text-font-important-dark dark:border-base-800">
4
- {{ title }}
5
- </h2>
4
+ <div class="border-b border-base-200 flex flex-row items-center mb-6 -mt-6 -mx-6 py-4 px-6 dark:border-base-800">
5
+ <h2 class="font-semibold text-[15px] text-important">
6
+ {{ title }}
7
+ </h2>
8
+
9
+ {% if action %}
10
+ <div class="ml-auto">
11
+ {{ action }}
12
+ </div>
13
+ {% endif %}
14
+ </div>
6
15
  {% endif %}
7
16
 
8
17
  <div class="grow relative{% if icon %} pl-8{% endif %}">
@@ -15,9 +15,15 @@
15
15
  </div>
16
16
  {% endif %}
17
17
 
18
- {% if value %}
19
- <div class="bg-base-100 overflow-hidden rounded-default dark:bg-base-800">
20
- <div class="h-1.5 bg-primary-600 rounded-default z-10 dark:bg-primary-500 {{ progress_class }}" title="{{ value }}%" style="width: {{ value }}%"></div>
18
+ {% if items or value %}
19
+ <div class="bg-base-100 flex flex-row overflow-hidden rounded-default dark:bg-base-800">
20
+ {% if items %}
21
+ {% for item in items %}
22
+ <div class="h-1.5 bg-primary-600 z-10 dark:bg-primary-500 last:rounded-r-default {{ item.progress_class }}" title="{% if item.title %}{{ item.title }}: {% endif %}{{ item.value }}%" style="width: {{ item.value }}%"></div>
23
+ {% endfor %}
24
+ {% elif value %}
25
+ <div class="h-1.5 bg-primary-600 rounded-default z-10 last:rounded-r-default dark:bg-primary-500 {{ progress_class }}" title="{% if title %}{{ title }}: {% endif %}{{ value }}%" style="width: {{ value }}%"></div>
26
+ {% endif %}
21
27
  </div>
22
28
  {% endif %}
23
29
  </div>
@@ -1 +1 @@
1
- <div class="readonly break-words {% if field.is_json %}max-w-4xl{% else %}max-w-2xl{% endif %} py-2 text-sm *:rounded-default {% if not adminform.model_admin.compressed_fields and not field.is_image %}bg-base-50 border border-base-200 font-medium px-3 rounded-default shadow-xs dark:border-base-700 dark:bg-base-800{% endif %} {% if field.is_image %}inline-block [&_img]:rounded-default py-0!{% endif %}">{% if value %}{{ value }}{% elif field.contents %}{{ field.contents }}{% else %}-{% endif %}</div>
1
+ <div class="readonly break-words {% if field.is_json %}max-w-4xl{% else %}max-w-2xl{% endif %} py-2 text-sm *:rounded-default {% if not adminform.model_admin.compressed_fields and not field.is_image %}bg-base-50 border border-base-200 font-medium px-3 rounded-default shadow-xs dark:border-base-700 dark:bg-base-800{% endif %}">{% if value %}{{ value }}{% elif field.contents %}{% if field.is_file %}{% include "unfold/helpers/field_readonly_value_file.html" %}{% else %}{{ field.contents }}{% endif %}{% else %}-{% endif %}</div>
@@ -0,0 +1,18 @@
1
+ {% load i18n %}
2
+
3
+ {% with url=field.url %}
4
+ {% if not url %}
5
+ <span class="flex items-center">-<span>
6
+ {% elif field.is_image %}
7
+ <a href="{{ url }}" target="_blank" class="block max-w-48">
8
+ <img src="{{ url }}" alt="{% trans 'Image preview' %}" class="block rounded-default" />
9
+ </a>
10
+ {% else %}
11
+ <a href="{{ url }}" target="_blank">
12
+ <span class="flex items-center gap-2">
13
+ <span class="text-primary-600 dark:text-primary-500">{% trans "Click to download" %}</span>
14
+ <span class="material-symbols-outlined text-base-400 dark:text-base-500">download</span>
15
+ </span>
16
+ </a>
17
+ {% endif %}
18
+ {% endwith %}