@spectrum-web-components/slider 0.12.13 → 0.12.15-devmode.7

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.
Files changed (54) hide show
  1. package/README.md +16 -0
  2. package/custom-elements.json +40 -0
  3. package/package.json +41 -16
  4. package/sp-slider-handle.dev.js +3 -0
  5. package/sp-slider-handle.dev.js.map +7 -0
  6. package/sp-slider-handle.js +3 -14
  7. package/sp-slider-handle.js.map +7 -1
  8. package/sp-slider.dev.js +4 -0
  9. package/sp-slider.dev.js.map +7 -0
  10. package/sp-slider.js +4 -15
  11. package/sp-slider.js.map +7 -1
  12. package/src/HandleController.dev.js +434 -0
  13. package/src/HandleController.dev.js.map +7 -0
  14. package/src/HandleController.js +402 -451
  15. package/src/HandleController.js.map +7 -1
  16. package/src/Slider.d.ts +8 -0
  17. package/src/Slider.dev.js +367 -0
  18. package/src/Slider.dev.js.map +7 -0
  19. package/src/Slider.js +282 -289
  20. package/src/Slider.js.map +7 -1
  21. package/src/SliderHandle.dev.js +184 -0
  22. package/src/SliderHandle.dev.js.map +7 -0
  23. package/src/SliderHandle.js +171 -179
  24. package/src/SliderHandle.js.map +7 -1
  25. package/src/index.dev.js +4 -0
  26. package/src/index.dev.js.map +7 -0
  27. package/src/index.js +4 -15
  28. package/src/index.js.map +7 -1
  29. package/src/slider.css.dev.js +234 -0
  30. package/src/slider.css.dev.js.map +7 -0
  31. package/src/slider.css.js +3 -14
  32. package/src/slider.css.js.map +7 -1
  33. package/src/spectrum-slider.css.dev.js +216 -0
  34. package/src/spectrum-slider.css.dev.js.map +7 -0
  35. package/src/spectrum-slider.css.js +3 -14
  36. package/src/spectrum-slider.css.js.map +7 -1
  37. package/stories/slider.stories.js +257 -267
  38. package/stories/slider.stories.js.map +7 -1
  39. package/sync/sp-slider.dev.js +3 -0
  40. package/sync/sp-slider.dev.js.map +7 -0
  41. package/sync/sp-slider.js +3 -14
  42. package/sync/sp-slider.js.map +7 -1
  43. package/test/benchmark/test-basic.js +5 -16
  44. package/test/benchmark/test-basic.js.map +7 -1
  45. package/test/slider-editable-sync.test.js +132 -144
  46. package/test/slider-editable-sync.test.js.map +7 -1
  47. package/test/slider-editable.test.js +151 -144
  48. package/test/slider-editable.test.js.map +7 -1
  49. package/test/slider-handle-upgrade.test.js +10 -21
  50. package/test/slider-handle-upgrade.test.js.map +7 -1
  51. package/test/slider.test-vrt.js +4 -15
  52. package/test/slider.test-vrt.js.map +7 -1
  53. package/test/slider.test.js +686 -700
  54. package/test/slider.test.js.map +7 -1
@@ -1,100 +1,87 @@
1
- /*
2
- Copyright 2020 Adobe. All rights reserved.
3
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License. You may obtain a copy
5
- of the License at http://www.apache.org/licenses/LICENSE-2.0
6
-
7
- Unless required by applicable law or agreed to in writing, software distributed under
8
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- OF ANY KIND, either express or implied. See the License for the specific language
10
- governing permissions and limitations under the License.
11
- */
12
- import { html } from '@spectrum-web-components/base';
13
- import '../sp-slider.js';
14
- import '../sp-slider-handle.js';
15
- import { variants } from '../';
16
- import { spreadProps } from '../../../test/lit-helpers.js';
1
+ import { html } from "@spectrum-web-components/base";
2
+ import "@spectrum-web-components/slider/sp-slider.js";
3
+ import "@spectrum-web-components/slider/sp-slider-handle.js";
4
+ import {
5
+ variants
6
+ } from "@spectrum-web-components/slider";
7
+ import { spreadProps } from "../../../test/lit-helpers.js";
17
8
  export default {
18
- component: 'sp-slider',
19
- title: 'Slider',
20
- argTypes: {
21
- onInput: { action: 'input' },
22
- onChange: { action: 'change' },
23
- variant: {
24
- name: 'Variant',
25
- description: 'Determines the style of slider.',
26
- table: {
27
- type: { summary: 'string' },
28
- defaultValue: { summary: undefined },
29
- },
30
- control: {
31
- type: 'inline-radio',
32
- options: [undefined, ...variants],
33
- },
34
- },
35
- tickStep: {
36
- name: 'Tick Step',
37
- description: 'Tick spacing on slider.',
38
- table: {
39
- type: { summary: 'number' },
40
- defaultValue: { summary: 0.1 },
41
- },
42
- control: {
43
- type: 'number',
44
- },
45
- },
46
- labelVisibility: {
47
- name: 'Label Visibility',
48
- description: 'The labels visibily available in the UI',
49
- table: {
50
- type: { summary: '"text" | "value" | "none" | undefined' },
51
- defaultValue: { summary: undefined },
52
- },
53
- control: {
54
- type: 'text',
55
- },
56
- },
9
+ component: "sp-slider",
10
+ title: "Slider",
11
+ argTypes: {
12
+ onInput: { action: "input" },
13
+ onChange: { action: "change" },
14
+ variant: {
15
+ name: "Variant",
16
+ description: "Determines the style of slider.",
17
+ table: {
18
+ type: { summary: "string" },
19
+ defaultValue: { summary: void 0 }
20
+ },
21
+ control: {
22
+ type: "inline-radio",
23
+ options: [void 0, ...variants]
24
+ }
57
25
  },
58
- args: {
59
- variant: undefined,
60
- tickStep: 0.1,
61
- labelVisibility: undefined,
26
+ tickStep: {
27
+ name: "Tick Step",
28
+ description: "Tick spacing on slider.",
29
+ table: {
30
+ type: { summary: "number" },
31
+ defaultValue: { summary: 0.1 }
32
+ },
33
+ control: {
34
+ type: "number"
35
+ }
62
36
  },
37
+ labelVisibility: {
38
+ name: "Label Visibility",
39
+ description: "The labels visibily available in the UI",
40
+ table: {
41
+ type: { summary: '"text" | "value" | "none" | undefined' },
42
+ defaultValue: { summary: void 0 }
43
+ },
44
+ control: {
45
+ type: "text"
46
+ }
47
+ }
48
+ },
49
+ args: {
50
+ variant: void 0,
51
+ tickStep: 0.1,
52
+ labelVisibility: void 0
53
+ }
63
54
  };
64
55
  const handleEvent = ({ onInput, onChange }) => (event) => {
65
- const { value } = event.target;
66
- if (onInput && event.type === 'input') {
67
- onInput(value.toString());
68
- }
69
- else if (onChange && event.type === 'change') {
70
- onChange(value.toString());
71
- }
56
+ const { value } = event.target;
57
+ if (onInput && event.type === "input") {
58
+ onInput(value.toString());
59
+ } else if (onChange && event.type === "change") {
60
+ onChange(value.toString());
61
+ }
72
62
  };
73
63
  const handleHandleEvent = ({ onInput, onChange }) => (event) => {
74
- const target = event.target;
75
- if (target.value != null) {
76
- if (typeof target.value === 'object') {
77
- const value = JSON.stringify(target.value, null, 2);
78
- if (onInput && event.type === 'input') {
79
- onInput(value);
80
- }
81
- else if (onChange && event.type === 'change') {
82
- onChange(value);
83
- }
84
- }
85
- else {
86
- const value = `${target.name}: ${target.value}`;
87
- if (onInput && event.type === 'input') {
88
- onInput(value);
89
- }
90
- else if (onChange && event.type === 'change') {
91
- onChange(value);
92
- }
93
- }
64
+ const target = event.target;
65
+ if (target.value != null) {
66
+ if (typeof target.value === "object") {
67
+ const value = JSON.stringify(target.value, null, 2);
68
+ if (onInput && event.type === "input") {
69
+ onInput(value);
70
+ } else if (onChange && event.type === "change") {
71
+ onChange(value);
72
+ }
73
+ } else {
74
+ const value = `${target.name}: ${target.value}`;
75
+ if (onInput && event.type === "input") {
76
+ onInput(value);
77
+ } else if (onChange && event.type === "change") {
78
+ onChange(value);
79
+ }
94
80
  }
81
+ }
95
82
  };
96
83
  export const Default = (args = {}) => {
97
- return html `
84
+ return html`
98
85
  <div style="width: 500px; margin: 12px 20px;">
99
86
  <sp-slider
100
87
  max="1"
@@ -103,7 +90,7 @@ export const Default = (args = {}) => {
103
90
  step="0.01"
104
91
  @input=${handleEvent(args)}
105
92
  @change=${handleEvent(args)}
106
- .formatOptions=${{ style: 'percent' }}
93
+ .formatOptions=${{ style: "percent" }}
107
94
  ...=${spreadProps(args)}
108
95
  >
109
96
  Opacity
@@ -112,7 +99,7 @@ export const Default = (args = {}) => {
112
99
  `;
113
100
  };
114
101
  export const noVisibleTextLabel = (args = {}) => {
115
- return html `
102
+ return html`
116
103
  <div style="width: 500px; margin: 12px 20px;">
117
104
  <sp-slider
118
105
  max="1"
@@ -121,7 +108,7 @@ export const noVisibleTextLabel = (args = {}) => {
121
108
  step="0.01"
122
109
  @input=${handleEvent(args)}
123
110
  @change=${handleEvent(args)}
124
- .formatOptions=${{ style: 'percent' }}
111
+ .formatOptions=${{ style: "percent" }}
125
112
  ...=${spreadProps(args)}
126
113
  >
127
114
  Opacity
@@ -130,10 +117,10 @@ export const noVisibleTextLabel = (args = {}) => {
130
117
  `;
131
118
  };
132
119
  noVisibleTextLabel.args = {
133
- labelVisibility: 'value',
120
+ labelVisibility: "value"
134
121
  };
135
122
  export const noVisibleValueLabel = (args = {}) => {
136
- return html `
123
+ return html`
137
124
  <div style="width: 500px; margin: 12px 20px;">
138
125
  <sp-slider
139
126
  max="1"
@@ -142,7 +129,7 @@ export const noVisibleValueLabel = (args = {}) => {
142
129
  step="0.01"
143
130
  @input=${handleEvent(args)}
144
131
  @change=${handleEvent(args)}
145
- .formatOptions=${{ style: 'percent' }}
132
+ .formatOptions=${{ style: "percent" }}
146
133
  ...=${spreadProps(args)}
147
134
  >
148
135
  Opacity
@@ -151,10 +138,10 @@ export const noVisibleValueLabel = (args = {}) => {
151
138
  `;
152
139
  };
153
140
  noVisibleValueLabel.args = {
154
- labelVisibility: 'text',
141
+ labelVisibility: "text"
155
142
  };
156
143
  export const noVisibleLabels = (args = {}) => {
157
- return html `
144
+ return html`
158
145
  <div style="width: 500px; margin: 12px 20px;">
159
146
  <sp-slider
160
147
  max="1"
@@ -163,7 +150,7 @@ export const noVisibleLabels = (args = {}) => {
163
150
  step="0.01"
164
151
  @input=${handleEvent(args)}
165
152
  @change=${handleEvent(args)}
166
- .formatOptions=${{ style: 'percent' }}
153
+ .formatOptions=${{ style: "percent" }}
167
154
  ...=${spreadProps(args)}
168
155
  >
169
156
  Opacity
@@ -172,10 +159,10 @@ export const noVisibleLabels = (args = {}) => {
172
159
  `;
173
160
  };
174
161
  noVisibleLabels.args = {
175
- labelVisibility: 'none',
162
+ labelVisibility: "none"
176
163
  };
177
164
  export const px = (args = {}) => {
178
- return html `
165
+ return html`
179
166
  <div style="width: 500px; margin: 12px 20px;">
180
167
  <sp-slider
181
168
  max="360"
@@ -185,9 +172,9 @@ export const px = (args = {}) => {
185
172
  @input=${handleEvent(args)}
186
173
  @change=${handleEvent(args)}
187
174
  .formatOptions=${{
188
- style: 'unit',
189
- unit: 'px',
190
- }}
175
+ style: "unit",
176
+ unit: "px"
177
+ }}
191
178
  ...=${spreadProps(args)}
192
179
  >
193
180
  Angle
@@ -196,28 +183,28 @@ export const px = (args = {}) => {
196
183
  `;
197
184
  };
198
185
  class NumberFieldDefined extends HTMLElement {
199
- constructor() {
200
- super();
201
- this.numberFieldLoaderPromise = Promise.resolve(false);
202
- this.numberFieldLoaderPromise = new Promise((res) => {
203
- customElements.whenDefined('sp-number-field').then(() => {
204
- res(true);
205
- });
206
- });
207
- }
208
- get updateComplete() {
209
- return this.numberFieldLoaderPromise;
210
- }
186
+ constructor() {
187
+ super();
188
+ this.numberFieldLoaderPromise = Promise.resolve(false);
189
+ this.numberFieldLoaderPromise = new Promise((res) => {
190
+ customElements.whenDefined("sp-number-field").then(() => {
191
+ res(true);
192
+ });
193
+ });
194
+ }
195
+ get updateComplete() {
196
+ return this.numberFieldLoaderPromise;
197
+ }
211
198
  }
212
- customElements.define('number-field-defined', NumberFieldDefined);
199
+ customElements.define("number-field-defined", NumberFieldDefined);
213
200
  const editableDecorator = (story) => {
214
- return html `
201
+ return html`
215
202
  ${story()}
216
203
  <number-field-defined></number-field-defined>
217
204
  `;
218
205
  };
219
206
  export const editable = (args = {}) => {
220
- return html `
207
+ return html`
221
208
  <div style="width: 500px; margin: 12px 20px;">
222
209
  <sp-slider
223
210
  editable
@@ -228,10 +215,10 @@ export const editable = (args = {}) => {
228
215
  @input=${handleEvent(args)}
229
216
  @change=${handleEvent(args)}
230
217
  .formatOptions=${{
231
- style: 'unit',
232
- unit: 'degree',
233
- unitDisplay: 'narrow',
234
- }}
218
+ style: "unit",
219
+ unit: "degree",
220
+ unitDisplay: "narrow"
221
+ }}
235
222
  ...=${spreadProps(args)}
236
223
  >
237
224
  Angle
@@ -241,7 +228,7 @@ export const editable = (args = {}) => {
241
228
  };
242
229
  editable.decorators = [editableDecorator];
243
230
  export const editableDisabled = (args = {}) => {
244
- return html `
231
+ return html`
245
232
  <div style="width: 500px; margin: 12px 20px;">
246
233
  <sp-slider
247
234
  editable
@@ -253,10 +240,10 @@ export const editableDisabled = (args = {}) => {
253
240
  @input=${handleEvent(args)}
254
241
  @change=${handleEvent(args)}
255
242
  .formatOptions=${{
256
- style: 'unit',
257
- unit: 'degree',
258
- unitDisplay: 'narrow',
259
- }}
243
+ style: "unit",
244
+ unit: "degree",
245
+ unitDisplay: "narrow"
246
+ }}
260
247
  ...=${spreadProps(args)}
261
248
  >
262
249
  Angle
@@ -266,7 +253,7 @@ export const editableDisabled = (args = {}) => {
266
253
  };
267
254
  editable.decorators = [editableDecorator];
268
255
  export const editableCustom = (args = {}) => {
269
- return html `
256
+ return html`
270
257
  <div
271
258
  style="width: 500px; margin: 12px 20px; --spectrum-slider-editable-number-field-width: 150px;"
272
259
  >
@@ -278,7 +265,7 @@ export const editableCustom = (args = {}) => {
278
265
  step="0.25"
279
266
  @input=${handleEvent(args)}
280
267
  @change=${handleEvent(args)}
281
- .formatOptions=${{ style: 'unit', unit: 'hour' }}
268
+ .formatOptions=${{ style: "unit", unit: "hour" }}
282
269
  ...=${spreadProps(args)}
283
270
  >
284
271
  Hours
@@ -288,7 +275,7 @@ export const editableCustom = (args = {}) => {
288
275
  };
289
276
  editableCustom.decorators = [editableDecorator];
290
277
  export const hideStepper = (args = {}) => {
291
- return html `
278
+ return html`
292
279
  <div style="width: 500px; margin: 12px 20px;">
293
280
  <sp-slider
294
281
  editable
@@ -299,7 +286,7 @@ export const hideStepper = (args = {}) => {
299
286
  step="0.01"
300
287
  @input=${handleEvent(args)}
301
288
  @change=${handleEvent(args)}
302
- .formatOptions=${{ style: 'percent' }}
289
+ .formatOptions=${{ style: "percent" }}
303
290
  ...=${spreadProps(args)}
304
291
  >
305
292
  Opacity
@@ -309,7 +296,7 @@ export const hideStepper = (args = {}) => {
309
296
  };
310
297
  hideStepper.decorators = [editableDecorator];
311
298
  export const Gradient = (args = {}) => {
312
- return html `
299
+ return html`
313
300
  <div
314
301
  style="
315
302
  width: 500px;
@@ -332,10 +319,10 @@ export const Gradient = (args = {}) => {
332
319
  `;
333
320
  };
334
321
  Gradient.args = {
335
- variant: undefined,
322
+ variant: void 0
336
323
  };
337
324
  export const tick = (args = {}) => {
338
- return html `
325
+ return html`
339
326
  <sp-slider
340
327
  label="Slider Label"
341
328
  variant="tick"
@@ -346,11 +333,11 @@ export const tick = (args = {}) => {
346
333
  `;
347
334
  };
348
335
  tick.args = {
349
- variant: 'tick',
350
- tickStep: 5,
336
+ variant: "tick",
337
+ tickStep: 5
351
338
  };
352
339
  export const tickLabels = (args = {}) => {
353
- return html `
340
+ return html`
354
341
  <sp-slider
355
342
  label="Slider Label"
356
343
  tick-labels
@@ -362,11 +349,11 @@ export const tickLabels = (args = {}) => {
362
349
  `;
363
350
  };
364
351
  tickLabels.args = {
365
- variant: 'tick',
366
- tickStep: 5,
352
+ variant: "tick",
353
+ tickStep: 5
367
354
  };
368
355
  export const Disabled = (args = {}) => {
369
- return html `
356
+ return html`
370
357
  <div style="width: 500px; margin: 12px 20px;">
371
358
  <sp-slider
372
359
  disabled
@@ -380,8 +367,43 @@ export const Disabled = (args = {}) => {
380
367
  </div>
381
368
  `;
382
369
  };
370
+ export const Quiet = (args = {}) => {
371
+ return html`
372
+ <div style="width: 500px; margin: 12px 20px;">
373
+ <sp-slider
374
+ editable
375
+ hide-stepper
376
+ quiet
377
+ value="5"
378
+ step="0.5"
379
+ min="0"
380
+ max="20"
381
+ label="Intensity"
382
+ ...=${spreadProps(args)}
383
+ ></sp-slider>
384
+ </div>
385
+ `;
386
+ };
387
+ export const Indeterminate = (args = {}) => {
388
+ return html`
389
+ <div style="width: 500px; margin: 12px 20px;">
390
+ <sp-slider
391
+ editable
392
+ indeterminate
393
+ value="5"
394
+ step="0.5"
395
+ min="0"
396
+ max="20"
397
+ label="Intensity"
398
+ @input=${handleEvent(args)}
399
+ @change=${handleEvent(args)}
400
+ ...=${spreadProps(args)}
401
+ ></sp-slider>
402
+ </div>
403
+ `;
404
+ };
383
405
  export const ExplicitHandle = (args = {}) => {
384
- return html `
406
+ return html`
385
407
  <div style="width: 500px; margin: 12px 20px;">
386
408
  <sp-slider
387
409
  step="0.5"
@@ -398,7 +420,7 @@ export const ExplicitHandle = (args = {}) => {
398
420
  `;
399
421
  };
400
422
  export const TwoHandles = (args = {}) => {
401
- return html `
423
+ return html`
402
424
  <div style="width: 500px; margin: 12px 20px;">
403
425
  <sp-slider
404
426
  value="5"
@@ -425,11 +447,11 @@ export const TwoHandles = (args = {}) => {
425
447
  `;
426
448
  };
427
449
  TwoHandles.args = {
428
- variant: 'range',
429
- tickStep: 10,
450
+ variant: "range",
451
+ tickStep: 10
430
452
  };
431
453
  export const TwoHandlesPt = (args = {}) => {
432
- return html `
454
+ return html`
433
455
  <div style="width: 500px; margin: 12px 20px;">
434
456
  <sp-slider
435
457
  value="5"
@@ -439,9 +461,9 @@ export const TwoHandlesPt = (args = {}) => {
439
461
  @input=${handleHandleEvent(args)}
440
462
  @change=${handleHandleEvent(args)}
441
463
  .formatOptions=${{
442
- style: 'unit',
443
- unit: 'pt',
444
- }}
464
+ style: "unit",
465
+ unit: "pt"
466
+ }}
445
467
  ...=${spreadProps(args)}
446
468
  >
447
469
  Output Levels
@@ -460,11 +482,11 @@ export const TwoHandlesPt = (args = {}) => {
460
482
  `;
461
483
  };
462
484
  TwoHandlesPt.args = {
463
- variant: 'range',
464
- tickStep: 10,
485
+ variant: "range",
486
+ tickStep: 10
465
487
  };
466
488
  export const ThreeHandlesPc = (args = {}) => {
467
- return html `
489
+ return html`
468
490
  <div style="width: 500px; margin: 12px 20px;">
469
491
  <sp-slider
470
492
  value="5"
@@ -474,9 +496,9 @@ export const ThreeHandlesPc = (args = {}) => {
474
496
  @input=${handleHandleEvent(args)}
475
497
  @change=${handleHandleEvent(args)}
476
498
  .formatOptions=${{
477
- style: 'unit',
478
- unit: 'pc',
479
- }}
499
+ style: "unit",
500
+ unit: "pc"
501
+ }}
480
502
  ...=${spreadProps(args)}
481
503
  >
482
504
  Output Levels
@@ -488,7 +510,7 @@ export const ThreeHandlesPc = (args = {}) => {
488
510
  `;
489
511
  };
490
512
  export const ThreeHandlesOrdered = (args = {}) => {
491
- return html `
513
+ return html`
492
514
  <div style="width: 500px; margin: 12px 20px;">
493
515
  <sp-slider
494
516
  step="1"
@@ -523,122 +545,90 @@ export const ThreeHandlesOrdered = (args = {}) => {
523
545
  `;
524
546
  };
525
547
  ThreeHandlesOrdered.args = {
526
- tickStep: 10,
527
- };
528
- // This is a very complex example from an actual application.
529
- //
530
- // The first and last handles go from 0 to 255 in a linear fashion.
531
- // The last and first handles are ordered so that the last handle
532
- // must be greater than or equal to the first handle.
533
- //
534
- // The middle handle's range goes from 9.99 to 0.01, counting down.
535
- // the middle handle's limits are set by the outer handles such that
536
- // the position of the left handle is the staring value (9.99) for the
537
- // middle handle. And the position of the right handle is the end
538
- // value (0.01). That means that the middle handle will move
539
- // proportionally as you move the outer handles.
540
- //
541
- // The two other interesting features of the middle handle are that
542
- // it counts down, and that it does so exponentially for the first
543
- // half of its range.
544
- //
545
- // Because the specification for the <input> tag in HTML says that the
546
- // min should be less than the max, we do a double normalization to make
547
- // this work. The middle handle is considered to go between 0 and 1,
548
- // where 0 is the left handle's position and 1 is the right handle's
549
- // position. We then do the appropriate calculation to convert that
550
- // value into one between 9.99 and 0.01 for display to the user.
551
- //
552
- // One iteresting thing to note is that the normalization function
553
- // can also be used to enforce clamping.
554
- //
548
+ tickStep: 10
549
+ };
555
550
  export const ThreeHandlesComplex = (args = {}) => {
556
- const values = {
557
- black: 50,
558
- gray: 4.98,
559
- white: 225,
560
- };
561
- const handleEvent = ({ onInput, onChange }) => (event) => {
562
- const target = event.target;
563
- if (target.value != null) {
564
- if (typeof target.value === 'object') {
565
- const value = JSON.stringify(target.value, null, 2);
566
- if (onInput && event.type === 'input') {
567
- onInput(value);
568
- }
569
- else if (onChange && event.type === 'change') {
570
- onChange(value);
571
- }
572
- }
573
- else {
574
- const value = `${target.name}: ${target.value}`;
575
- if (onInput && event.type === 'input') {
576
- onInput(value);
577
- }
578
- else if (onChange && event.type === 'change') {
579
- onChange(value);
580
- }
581
- }
582
- values[target.name] = target.value;
583
- }
584
- };
585
- const grayNormalization = {
586
- toNormalized(value) {
587
- const normalizedBlack = values.black / 255;
588
- const normalizedWhite = values.white / 255;
589
- const clamped = Math.max(Math.min(value, 1), 0);
590
- return (clamped * (normalizedWhite - normalizedBlack) + normalizedBlack);
591
- },
592
- fromNormalized(value) {
593
- const normalizedBlack = values.black / 255;
594
- const normalizedWhite = values.white / 255;
595
- const clamped = Math.max(Math.min(value, normalizedWhite), normalizedBlack);
596
- return ((clamped - normalizedBlack) /
597
- (normalizedWhite - normalizedBlack));
598
- },
599
- };
600
- const blackNormalization = {
601
- toNormalized(value) {
602
- const clamped = Math.min(value, values.white);
603
- return clamped / 255;
604
- },
605
- fromNormalized(value) {
606
- const denormalized = value * 255;
607
- return Math.min(denormalized, values.white);
608
- },
609
- };
610
- const whiteNormalization = {
611
- toNormalized(value) {
612
- const clamped = Math.max(value, values.black);
613
- return clamped / 255;
614
- },
615
- fromNormalized(value) {
616
- const denormalized = value * 255;
617
- return Math.max(denormalized, values.black);
618
- },
619
- };
620
- const computeGray = (value) => {
621
- let result = 1.0;
622
- if (value > 0.5) {
623
- result = Math.max(2 * (1 - value), 0.01);
551
+ const values = {
552
+ black: 50,
553
+ gray: 4.98,
554
+ white: 225
555
+ };
556
+ const handleEvent2 = ({ onInput, onChange }) => (event) => {
557
+ const target = event.target;
558
+ if (target.value != null) {
559
+ if (typeof target.value === "object") {
560
+ const value = JSON.stringify(target.value, null, 2);
561
+ if (onInput && event.type === "input") {
562
+ onInput(value);
563
+ } else if (onChange && event.type === "change") {
564
+ onChange(value);
624
565
  }
625
- else if (value < 0.5) {
626
- result = ((1 - 2 * value) * (Math.sqrt(9.99) - 1) + 1) ** 2;
566
+ } else {
567
+ const value = `${target.name}: ${target.value}`;
568
+ if (onInput && event.type === "input") {
569
+ onInput(value);
570
+ } else if (onChange && event.type === "change") {
571
+ onChange(value);
627
572
  }
628
- const formatOptions = {
629
- maximumFractionDigits: 2,
630
- minimumFractionDigits: 2,
631
- };
632
- return new Intl.NumberFormat(navigator.language, formatOptions).format(result);
573
+ }
574
+ values[target.name] = target.value;
575
+ }
576
+ };
577
+ const grayNormalization = {
578
+ toNormalized(value) {
579
+ const normalizedBlack = values.black / 255;
580
+ const normalizedWhite = values.white / 255;
581
+ const clamped = Math.max(Math.min(value, 1), 0);
582
+ return clamped * (normalizedWhite - normalizedBlack) + normalizedBlack;
583
+ },
584
+ fromNormalized(value) {
585
+ const normalizedBlack = values.black / 255;
586
+ const normalizedWhite = values.white / 255;
587
+ const clamped = Math.max(Math.min(value, normalizedWhite), normalizedBlack);
588
+ return (clamped - normalizedBlack) / (normalizedWhite - normalizedBlack);
589
+ }
590
+ };
591
+ const blackNormalization = {
592
+ toNormalized(value) {
593
+ const clamped = Math.min(value, values.white);
594
+ return clamped / 255;
595
+ },
596
+ fromNormalized(value) {
597
+ const denormalized = value * 255;
598
+ return Math.min(denormalized, values.white);
599
+ }
600
+ };
601
+ const whiteNormalization = {
602
+ toNormalized(value) {
603
+ const clamped = Math.max(value, values.black);
604
+ return clamped / 255;
605
+ },
606
+ fromNormalized(value) {
607
+ const denormalized = value * 255;
608
+ return Math.max(denormalized, values.black);
609
+ }
610
+ };
611
+ const computeGray = (value) => {
612
+ let result = 1;
613
+ if (value > 0.5) {
614
+ result = Math.max(2 * (1 - value), 0.01);
615
+ } else if (value < 0.5) {
616
+ result = ((1 - 2 * value) * (Math.sqrt(9.99) - 1) + 1) ** 2;
617
+ }
618
+ const formatOptions = {
619
+ maximumFractionDigits: 2,
620
+ minimumFractionDigits: 2
633
621
  };
634
- return html `
622
+ return new Intl.NumberFormat(navigator.language, formatOptions).format(result);
623
+ };
624
+ return html`
635
625
  <div style="width: 500px; margin: 12px 20px;">
636
626
  <sp-slider
637
627
  step="1"
638
628
  min="0"
639
629
  max="255"
640
- @input=${handleEvent}
641
- @change=${handleEvent}
630
+ @input=${handleEvent2}
631
+ @change=${handleEvent2}
642
632
  ...=${spreadProps(args)}
643
633
  >
644
634
  Output Levels
@@ -669,14 +659,14 @@ export const ThreeHandlesComplex = (args = {}) => {
669
659
  `;
670
660
  };
671
661
  ThreeHandlesOrdered.args = {
672
- tickStep: 10,
662
+ tickStep: 10
673
663
  };
674
664
  export const focusTabDemo = (args = {}) => {
675
- const value = 50;
676
- const min = 0;
677
- const max = 100;
678
- const step = 1;
679
- return html `
665
+ const value = 50;
666
+ const min = 0;
667
+ const max = 100;
668
+ const step = 1;
669
+ return html`
680
670
  <div style="width: 500px; margin: 12px 20px 20px;">
681
671
  <sp-slider
682
672
  value="${value}"
@@ -712,4 +702,4 @@ export const focusTabDemo = (args = {}) => {
712
702
  </div>
713
703
  `;
714
704
  };
715
- //# sourceMappingURL=slider.stories.js.map
705
+ //# sourceMappingURL=slider.stories.js.map