@ucd-lib/theme-elements 3.3.1 → 3.3.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ucd-lib/theme-elements",
3
- "version": "3.3.1",
3
+ "version": "3.3.2",
4
4
  "description": "Custom elements for the UCD brand theme",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -38,7 +38,9 @@ export default class UcdlibRangeSlider extends LitElement {
38
38
  // colors for histogram
39
39
  lightColor: { type: String, attribute: 'light-color' },
40
40
  mediumColor: { type: String, attribute: 'medium-color' },
41
- darkColor: { type: String, attribute: 'dark-color' }
41
+ darkColor: { type: String, attribute: 'dark-color' },
42
+ initialMin: { type: Number },
43
+ initialMax: { type: Number }
42
44
  };
43
45
  }
44
46
 
@@ -71,6 +73,8 @@ export default class UcdlibRangeSlider extends LitElement {
71
73
  this.lightColor = '#CCE0F3';
72
74
  this.mediumColor = '#73ABDD';
73
75
  this.darkColor = '#13639E';
76
+ this.initialMin = null;
77
+ this.initialMax = null;
74
78
 
75
79
  // consts to build histogram
76
80
  this.gapPx = 2;
@@ -163,6 +167,12 @@ export default class UcdlibRangeSlider extends LitElement {
163
167
  if( !this.merged ) {
164
168
  this.min = this.absMin;
165
169
  this.max = this.absMax;
170
+ if( Number.isFinite(this.initialMin) ) {
171
+ this.min = Math.max(this.absMin, Math.min(this.initialMin, this.absMax));
172
+ }
173
+ if( Number.isFinite(this.initialMax) ) {
174
+ this.max = Math.max(this.min, Math.min(this.initialMax, this.absMax));
175
+ }
166
176
  }
167
177
 
168
178
  if( this.data?.length < 5 ) return this.hideHistogram = true;
@@ -236,6 +246,9 @@ export default class UcdlibRangeSlider extends LitElement {
236
246
  this.numBins = (this.mergedData.length || this.data.length);
237
247
 
238
248
  this._updateHistogramColors();
249
+
250
+ this.initialMin = null;
251
+ this.initialMax = null;
239
252
  }
240
253
 
241
254
  /**
@@ -461,6 +474,22 @@ export default class UcdlibRangeSlider extends LitElement {
461
474
  );
462
475
  }
463
476
 
477
+ /**
478
+ * @method refresh
479
+ * @description public method to refresh histogram bins and layout after data/size changes
480
+ * @param {Boolean} forceRecalc force recalculation of merged bins
481
+ */
482
+ refresh(forceRecalc = false) {
483
+ // Reset render guard to allow full recalculation
484
+ this.hasRendered = false;
485
+
486
+ // Trigger resize logic to recalculate dimensions and bins
487
+ this._onResize(null, forceRecalc);
488
+
489
+ // Request update and wait for render
490
+ this.requestUpdate();
491
+ }
492
+
464
493
  /**
465
494
  * @method reset
466
495
  * @description reset range filter