@emuanalytics/flow-rdf-ui 4.1.8 → 4.1.9

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.
@@ -7,6 +7,7 @@ import { boolean } from '../../internal/boolean.mjs';
7
7
  import { defaultValue } from '../../internal/default-value.mjs';
8
8
  import { FlowRdfFormControl } from '../../internal/flow-ui-rdf-element.mjs';
9
9
  import { FormControlController } from '../../internal/form.mjs';
10
+ import { clamp } from '../../internal/math.mjs';
10
11
  import { HasSlotController } from '../../internal/slot.mjs';
11
12
  import { isNumber } from '../../internal/type-checks.mjs';
12
13
  import { watch } from '../../internal/watch.mjs';
@@ -78,13 +79,15 @@ class FlowUiRange extends FlowRdfFormControl {
78
79
  super.disconnectedCallback();
79
80
  this.resizeObserver.unobserve(this.input);
80
81
  }
81
- handleChange() {
82
+ handleRangeChange(event) {
83
+ event.stopPropagation();
82
84
  this.emit("flow-ui-change");
83
85
  }
84
- handleInput() {
86
+ handleRangeInput(event) {
87
+ event.stopPropagation();
85
88
  this.value = parseFloat(this.input.value);
86
- this.emit("flow-ui-input");
87
89
  this.syncRange();
90
+ this.emit("flow-ui-input");
88
91
  }
89
92
  /*
90
93
  Handler for flow-ui-input & flow-ui-change events from number input.
@@ -97,11 +100,13 @@ class FlowUiRange extends FlowRdfFormControl {
97
100
  this.syncRange();
98
101
  }
99
102
  }
100
- handleBlur() {
103
+ handleBlur(event) {
104
+ event.stopPropagation();
101
105
  this.hasFocus = false;
102
106
  this.emit("flow-ui-blur");
103
107
  }
104
- handleFocus() {
108
+ handleFocus(event) {
109
+ event.stopPropagation();
105
110
  this.hasFocus = true;
106
111
  this.emit("flow-ui-focus");
107
112
  }
@@ -114,8 +119,7 @@ class FlowUiRange extends FlowRdfFormControl {
114
119
  }
115
120
  handleValueChange() {
116
121
  this.formControlController.updateValidity();
117
- this.input.value = this.value?.toString();
118
- this.value = parseFloat(this.input.value);
122
+ this.value = clamp(this.value, this.min, this.max);
119
123
  this.syncRange();
120
124
  }
121
125
  handleDisabledChange() {
@@ -126,7 +130,7 @@ class FlowUiRange extends FlowRdfFormControl {
126
130
  const percent = Math.max(0, (this.value - this.min) / (this.max - this.min));
127
131
  this.syncProgress(percent);
128
132
  }
129
- handleInvalid(event) {
133
+ handleRangeInvalid(event) {
130
134
  this.formControlController.setValidity(false);
131
135
  this.formControlController.emitInvalidEvent(event);
132
136
  }
@@ -240,30 +244,35 @@ class FlowUiRange extends FlowRdfFormControl {
240
244
  step=${ifDefined(this.step)}
241
245
  .value=${live(this.value.toString())}
242
246
  aria-describedby="help-text"
243
- @change=${this.handleChange}
247
+ @change=${this.handleRangeChange}
244
248
  @focus=${this.handleFocus}
245
- @input=${this.handleInput}
246
- @invalid=${this.handleInvalid}
249
+ @input=${this.handleRangeInput}
250
+ @invalid=${this.handleRangeInvalid}
247
251
  @blur=${this.handleBlur}
248
252
  />
249
253
  <slot name="suffix" part="suffix" class="range__suffix"></slot>
250
254
 
251
- ${this.noInput ? nothing : html`
252
- <flow-ui-input
253
- class="number-input"
254
- type="number"
255
- inline
256
- filled
257
- exportparts="form-control:number-input"
258
- no-step-buttons
259
- size=${this.size}
260
- format=${this.format}
261
- ?disabled=${this.disabled}
262
- .value=${this.value.toString()}
263
- @flow-ui-input=${this.handleNumberChange}
264
- @flow-ui-change=${this.handleNumberChange}
265
- ></flow-ui-input>
266
- `}
255
+ <flow-ui-input
256
+ class=${classMap({
257
+ "number-input": true,
258
+ "no-input": this.noInput
259
+ })}
260
+ type="number"
261
+ inline
262
+ filled
263
+ exportparts="form-control:number-input"
264
+ no-step-buttons
265
+ size=${this.size}
266
+ format=${this.format}
267
+ min=${ifDefined(this.min)}
268
+ max=${ifDefined(this.max)}
269
+ step=${ifDefined(this.step)}
270
+ ?disabled=${this.disabled}
271
+ .value=${this.value.toString()}
272
+ @flow-ui-change=${this.handleNumberChange}
273
+ @flow-ui-focus=${this.handleFocus}
274
+ @flow-ui-blur=${this.handleBlur}
275
+ ></flow-ui-input>
267
276
  </div>
268
277
  </div>
269
278
 
@@ -210,6 +210,10 @@ const styles = css`
210
210
  color: var(--flow-ui-control-icon-color);
211
211
  }
212
212
 
213
+ .number-input.no-input {
214
+ display: none;
215
+ }
216
+
213
217
  @media (forced-colors: active) {
214
218
  .range__control,
215
219
  .range__control::-webkit-slider-thumb {