@kumori/aurora-wui-components 0.0.248 → 0.0.249

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.
@@ -1,18 +1,24 @@
1
1
  import { LitElement } from 'lit';
2
- export type SelectorSliderPosition = 'min' | 'middle' | 'max';
2
+ export type SelectorSliderPosition = number | 'min' | 'middle' | 'max';
3
3
  export declare class AxebowSelectorSlider extends LitElement {
4
4
  static styles: import('lit').CSSResult[];
5
5
  quantity: SelectorSliderPosition;
6
6
  minTag: string | number;
7
7
  mediumTag: string | number;
8
8
  maxTag: string | number;
9
+ min?: number;
10
+ max?: number;
11
+ step: number;
9
12
  disabled: boolean;
10
13
  get value(): SelectorSliderPosition;
11
14
  set value(val: SelectorSliderPosition);
12
15
  private _trackContainer;
13
16
  private _isDragging;
14
- private get _stepIndex();
15
- private _setStepIndex;
17
+ private get _minVal();
18
+ private get _maxVal();
19
+ private get _numericQuantity();
20
+ private get _percentage();
21
+ private _setValue;
16
22
  private _handlePointerDown;
17
23
  private _updateFromPointer;
18
24
  private _handleKeyDown;
@@ -1 +1 @@
1
- {"version":3,"file":"axebow-selector-slider.d.ts","sourceRoot":"","sources":["../../../src/components/axebow-selector-slider/axebow-selector-slider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,UAAU,EAAa,MAAM,KAAK,CAAC;AAGvD,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE9D,qBACa,oBAAqB,SAAQ,UAAU;IAClD,MAAM,CAAC,MAAM,4BASX;IAE0B,QAAQ,EAAE,sBAAsB,CAAS;IACzD,MAAM,EAAE,MAAM,GAAG,MAAM,CAAK;IAC5B,SAAS,EAAE,MAAM,GAAG,MAAM,CAAO;IACjC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAO;IACb,QAAQ,UAAS;IAE9C,IACI,KAAK,IAAI,sBAAsB,CAElC;IACD,IAAI,KAAK,CAAC,GAAG,EAAE,sBAAsB,EAEpC;IAEiC,OAAO,CAAC,eAAe,CAAe;IAExE,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO,KAAK,UAAU,GAUrB;IAED,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,kBAAkB;IAqB1B,OAAO,CAAC,kBAAkB;IAmB1B,OAAO,CAAC,cAAc;IAkBtB,MAAM;CAiDP"}
1
+ {"version":3,"file":"axebow-selector-slider.d.ts","sourceRoot":"","sources":["../../../src/components/axebow-selector-slider/axebow-selector-slider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,UAAU,EAAa,MAAM,KAAK,CAAC;AAGvD,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEvE,qBACa,oBAAqB,SAAQ,UAAU;IAClD,MAAM,CAAC,MAAM,4BASX;IAEyC,QAAQ,EAAE,sBAAsB,CAAK;IACpE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAK;IAC5B,SAAS,EAAE,MAAM,GAAG,MAAM,CAAO;IACjC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAO;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,SAAK;IACR,QAAQ,UAAS;IAE9C,IACI,KAAK,IAAI,sBAAsB,CAElC;IACD,IAAI,KAAK,CAAC,GAAG,EAAE,sBAAsB,EAEpC;IAEiC,OAAO,CAAC,eAAe,CAAe;IAExE,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO,KAAK,OAAO,GAIlB;IAED,OAAO,KAAK,OAAO,GAIlB;IAED,OAAO,KAAK,gBAAgB,GAU3B;IAED,OAAO,KAAK,WAAW,GAMtB;IAED,OAAO,CAAC,SAAS;IAgBjB,OAAO,CAAC,kBAAkB;IAqB1B,OAAO,CAAC,kBAAkB;IAiB1B,OAAO,CAAC,cAAc;IAsBtB,MAAM;CAoDP"}
package/dist/index.js CHANGED
@@ -7454,10 +7454,11 @@ AxebowTabSelector = __decorate([customElement("axebow-tab-selector")], AxebowTab
7454
7454
  var AxebowSelectorSlider = class AxebowSelectorSlider extends LitElement {
7455
7455
  constructor(..._args) {
7456
7456
  super(..._args);
7457
- this.quantity = "min";
7457
+ this.quantity = 0;
7458
7458
  this.minTag = 0;
7459
7459
  this.mediumTag = "Y";
7460
7460
  this.maxTag = "X";
7461
+ this.step = 1;
7461
7462
  this.disabled = false;
7462
7463
  this._isDragging = false;
7463
7464
  }
@@ -7479,28 +7480,43 @@ var AxebowSelectorSlider = class AxebowSelectorSlider extends LitElement {
7479
7480
  set value(val) {
7480
7481
  this.quantity = val;
7481
7482
  }
7482
- get _stepIndex() {
7483
- switch (this.quantity) {
7484
- case "middle": return 1;
7485
- case "max": return 2;
7486
- default: return 0;
7483
+ get _minVal() {
7484
+ if (typeof this.min === "number") return this.min;
7485
+ const n = Number(this.minTag);
7486
+ return isNaN(n) ? 0 : n;
7487
+ }
7488
+ get _maxVal() {
7489
+ if (typeof this.max === "number") return this.max;
7490
+ const n = Number(this.maxTag);
7491
+ return isNaN(n) ? 100 : n;
7492
+ }
7493
+ get _numericQuantity() {
7494
+ if (typeof this.quantity === "string") {
7495
+ const str = this.quantity.toLowerCase();
7496
+ if (str === "min") return this._minVal;
7497
+ if (str === "max") return this._maxVal;
7498
+ if (str === "middle") return Math.round((this._minVal + this._maxVal) / 2);
7499
+ const parsed = Number(this.quantity);
7500
+ if (!isNaN(parsed)) return parsed;
7487
7501
  }
7488
- }
7489
- _setStepIndex(index) {
7490
- const steps = [
7491
- "min",
7492
- "middle",
7493
- "max"
7494
- ];
7495
- const clamped = Math.max(0, Math.min(2, Math.round(index)));
7496
- const newValue = steps[clamped];
7497
- if (this.quantity !== newValue) {
7498
- this.quantity = newValue;
7502
+ return typeof this.quantity === "number" ? this.quantity : this._minVal;
7503
+ }
7504
+ get _percentage() {
7505
+ const min = this._minVal;
7506
+ const max = this._maxVal;
7507
+ if (max <= min) return 0;
7508
+ return (Math.max(min, Math.min(max, this._numericQuantity)) - min) / (max - min) * 100;
7509
+ }
7510
+ _setValue(newValue) {
7511
+ const min = this._minVal;
7512
+ const max = this._maxVal;
7513
+ const clamped = Math.max(min, Math.min(max, newValue));
7514
+ if (this._numericQuantity !== clamped) {
7515
+ this.quantity = clamped;
7499
7516
  this.dispatchEvent(new CustomEvent("change", {
7500
7517
  detail: {
7501
- value: newValue,
7502
- quantity: newValue,
7503
- index: clamped
7518
+ value: clamped,
7519
+ quantity: clamped
7504
7520
  },
7505
7521
  bubbles: true,
7506
7522
  composed: true
@@ -7529,32 +7545,38 @@ var AxebowSelectorSlider = class AxebowSelectorSlider extends LitElement {
7529
7545
  const width = rect.width;
7530
7546
  if (width <= 0) return;
7531
7547
  const ratio = Math.max(0, Math.min(1, x / width));
7532
- let step = 0;
7533
- if (ratio < .25) step = 0;
7534
- else if (ratio > .75) step = 2;
7535
- else step = 1;
7536
- this._setStepIndex(step);
7548
+ const min = this._minVal;
7549
+ const rawVal = min + ratio * (this._maxVal - min);
7550
+ const step = this.step || 1;
7551
+ const stepped = Math.round((rawVal - min) / step) * step + min;
7552
+ this._setValue(stepped);
7537
7553
  }
7538
7554
  _handleKeyDown(e) {
7539
7555
  if (this.disabled) return;
7540
- const current = this._stepIndex;
7556
+ const min = this._minVal;
7557
+ const max = this._maxVal;
7558
+ const step = this.step || 1;
7559
+ const current = this._numericQuantity;
7541
7560
  if (e.key === "ArrowRight" || e.key === "ArrowUp") {
7542
7561
  e.preventDefault();
7543
- this._setStepIndex(current + 1);
7562
+ this._setValue(Math.min(max, current + step));
7544
7563
  } else if (e.key === "ArrowLeft" || e.key === "ArrowDown") {
7545
7564
  e.preventDefault();
7546
- this._setStepIndex(current - 1);
7565
+ this._setValue(Math.max(min, current - step));
7547
7566
  } else if (e.key === "Home") {
7548
7567
  e.preventDefault();
7549
- this._setStepIndex(0);
7568
+ this._setValue(min);
7550
7569
  } else if (e.key === "End") {
7551
7570
  e.preventDefault();
7552
- this._setStepIndex(2);
7571
+ this._setValue(max);
7553
7572
  }
7554
7573
  }
7555
7574
  render() {
7556
- const step = this._stepIndex;
7557
- const percent = step === 0 ? 0 : step === 1 ? 50 : 100;
7575
+ const percent = this._percentage;
7576
+ const currentVal = this._numericQuantity;
7577
+ const min = this._minVal;
7578
+ const max = this._maxVal;
7579
+ const mid = Math.round((min + max) / 2);
7558
7580
  return html`
7559
7581
  <div class="w-full flex flex-col gap-2 select-none ${this.disabled ? "opacity-50 pointer-events-none" : ""}">
7560
7582
  <!-- Slider Track Container -->
@@ -7562,10 +7584,10 @@ var AxebowSelectorSlider = class AxebowSelectorSlider extends LitElement {
7562
7584
  class="relative w-full h-8 flex items-center cursor-pointer touch-none focus:outline-none focus-visible:ring-2 focus-visible:ring-[#006BFF] rounded-full"
7563
7585
  tabindex=${this.disabled ? -1 : 0}
7564
7586
  role="slider"
7565
- aria-valuemin="0"
7566
- aria-valuemax="2"
7567
- aria-valuenow=${step}
7568
- aria-valuetext=${this.quantity}
7587
+ aria-valuemin=${min}
7588
+ aria-valuemax=${max}
7589
+ aria-valuenow=${currentVal}
7590
+ aria-valuetext=${String(currentVal)}
7569
7591
  @pointerdown=${this._handlePointerDown}
7570
7592
  @keydown=${this._handleKeyDown}
7571
7593
  >
@@ -7587,13 +7609,13 @@ var AxebowSelectorSlider = class AxebowSelectorSlider extends LitElement {
7587
7609
 
7588
7610
  <!-- Labels below -->
7589
7611
  <div class="flex justify-between items-center text-sm font-semibold text-[#78787A] px-1">
7590
- <span class="w-1/3 text-left cursor-pointer" @click=${() => !this.disabled && this._setStepIndex(0)}>
7612
+ <span class="w-1/3 text-left cursor-pointer" @click=${() => !this.disabled && this._setValue(min)}>
7591
7613
  ${this.minTag}
7592
7614
  </span>
7593
- <span class="w-1/3 text-center cursor-pointer" @click=${() => !this.disabled && this._setStepIndex(1)}>
7615
+ <span class="w-1/3 text-center cursor-pointer" @click=${() => !this.disabled && this._setValue(mid)}>
7594
7616
  ${this.mediumTag}
7595
7617
  </span>
7596
- <span class="w-1/3 text-right cursor-pointer" @click=${() => !this.disabled && this._setStepIndex(2)}>
7618
+ <span class="w-1/3 text-right cursor-pointer" @click=${() => !this.disabled && this._setValue(max)}>
7597
7619
  ${this.maxTag}
7598
7620
  </span>
7599
7621
  </div>
@@ -7601,12 +7623,18 @@ var AxebowSelectorSlider = class AxebowSelectorSlider extends LitElement {
7601
7623
  `;
7602
7624
  }
7603
7625
  };
7604
- __decorate([property({ type: String })], AxebowSelectorSlider.prototype, "quantity", void 0);
7626
+ __decorate([property({
7627
+ type: Number,
7628
+ reflect: true
7629
+ })], AxebowSelectorSlider.prototype, "quantity", void 0);
7605
7630
  __decorate([property()], AxebowSelectorSlider.prototype, "minTag", void 0);
7606
7631
  __decorate([property()], AxebowSelectorSlider.prototype, "mediumTag", void 0);
7607
7632
  __decorate([property()], AxebowSelectorSlider.prototype, "maxTag", void 0);
7633
+ __decorate([property({ type: Number })], AxebowSelectorSlider.prototype, "min", void 0);
7634
+ __decorate([property({ type: Number })], AxebowSelectorSlider.prototype, "max", void 0);
7635
+ __decorate([property({ type: Number })], AxebowSelectorSlider.prototype, "step", void 0);
7608
7636
  __decorate([property({ type: Boolean })], AxebowSelectorSlider.prototype, "disabled", void 0);
7609
- __decorate([property({ type: String })], AxebowSelectorSlider.prototype, "value", null);
7637
+ __decorate([property()], AxebowSelectorSlider.prototype, "value", null);
7610
7638
  __decorate([query(".slider-track-container")], AxebowSelectorSlider.prototype, "_trackContainer", void 0);
7611
7639
  AxebowSelectorSlider = __decorate([customElement("axebow-selector-slider")], AxebowSelectorSlider);
7612
7640
  //#endregion