@spectrum-web-components/slider 0.14.0-devmode.0 → 0.14.0

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,210 +1,82 @@
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";
8
- export default {
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
- }
25
- },
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
- }
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
- }
54
- };
55
- const handleEvent = ({ onInput, onChange }) => (event) => {
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
- }
62
- };
63
- const handleHandleEvent = ({ onInput, onChange }) => (event) => {
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
- }
80
- }
81
- }
82
- };
83
- export const Default = (args = {}) => {
84
- return html`
1
+ import{html as i}from"@spectrum-web-components/base";import"@spectrum-web-components/slider/sp-slider.js";import"@spectrum-web-components/slider/sp-slider-handle.js";import{variants as y}from"@spectrum-web-components/slider";import{spreadProps as t}from"../../../test/lit-helpers.js";export default{component:"sp-slider",title:"Slider",argTypes:{onInput:{action:"input"},onChange:{action:"change"},variant:{name:"Variant",description:"Determines the style of slider.",table:{type:{summary:"string"},defaultValue:{summary:void 0}},control:{type:"inline-radio",options:[void 0,...y]}},tickStep:{name:"Tick Step",description:"Tick spacing on slider.",table:{type:{summary:"number"},defaultValue:{summary:.1}},control:{type:"number"}},labelVisibility:{name:"Label Visibility",description:"The labels visibily available in the UI",table:{type:{summary:'"text" | "value" | "none" | undefined'},defaultValue:{summary:void 0}},control:{type:"text"}}},args:{variant:void 0,tickStep:.1,labelVisibility:void 0}};const s=({onInput:e,onChange:l})=>r=>{const{value:d}=r.target;e&&r.type==="input"?e(d.toString()):l&&r.type==="change"&&l(d.toString())},o=({onInput:e,onChange:l})=>r=>{const d=r.target;if(d.value!=null)if(typeof d.value=="object"){const u=JSON.stringify(d.value,null,2);e&&r.type==="input"?e(u):l&&r.type==="change"&&l(u)}else{const u=`${d.name}: ${d.value}`;e&&r.type==="input"?e(u):l&&r.type==="change"&&l(u)}};export const Default=(e={})=>i`
85
2
  <div style="width: 500px; margin: 12px 20px;">
86
3
  <sp-slider
87
4
  max="1"
88
5
  min="0"
89
6
  value=".5"
90
7
  step="0.01"
91
- @input=${handleEvent(args)}
92
- @change=${handleEvent(args)}
93
- .formatOptions=${{ style: "percent" }}
94
- ...=${spreadProps(args)}
8
+ @input=${s(e)}
9
+ @change=${s(e)}
10
+ .formatOptions=${{style:"percent"}}
11
+ ...=${t(e)}
95
12
  >
96
13
  Opacity
97
14
  </sp-slider>
98
15
  </div>
99
- `;
100
- };
101
- export const noVisibleTextLabel = (args = {}) => {
102
- return html`
16
+ `,noVisibleTextLabel=(e={})=>i`
103
17
  <div style="width: 500px; margin: 12px 20px;">
104
18
  <sp-slider
105
19
  max="1"
106
20
  min="0"
107
21
  value=".5"
108
22
  step="0.01"
109
- @input=${handleEvent(args)}
110
- @change=${handleEvent(args)}
111
- .formatOptions=${{ style: "percent" }}
112
- ...=${spreadProps(args)}
23
+ @input=${s(e)}
24
+ @change=${s(e)}
25
+ .formatOptions=${{style:"percent"}}
26
+ ...=${t(e)}
113
27
  >
114
28
  Opacity
115
29
  </sp-slider>
116
30
  </div>
117
- `;
118
- };
119
- noVisibleTextLabel.args = {
120
- labelVisibility: "value"
121
- };
122
- export const noVisibleValueLabel = (args = {}) => {
123
- return html`
31
+ `;noVisibleTextLabel.args={labelVisibility:"value"};export const noVisibleValueLabel=(e={})=>i`
124
32
  <div style="width: 500px; margin: 12px 20px;">
125
33
  <sp-slider
126
34
  max="1"
127
35
  min="0"
128
36
  value=".5"
129
37
  step="0.01"
130
- @input=${handleEvent(args)}
131
- @change=${handleEvent(args)}
132
- .formatOptions=${{ style: "percent" }}
133
- ...=${spreadProps(args)}
38
+ @input=${s(e)}
39
+ @change=${s(e)}
40
+ .formatOptions=${{style:"percent"}}
41
+ ...=${t(e)}
134
42
  >
135
43
  Opacity
136
44
  </sp-slider>
137
45
  </div>
138
- `;
139
- };
140
- noVisibleValueLabel.args = {
141
- labelVisibility: "text"
142
- };
143
- export const noVisibleLabels = (args = {}) => {
144
- return html`
46
+ `;noVisibleValueLabel.args={labelVisibility:"text"};export const noVisibleLabels=(e={})=>i`
145
47
  <div style="width: 500px; margin: 12px 20px;">
146
48
  <sp-slider
147
49
  max="1"
148
50
  min="0"
149
51
  value=".5"
150
52
  step="0.01"
151
- @input=${handleEvent(args)}
152
- @change=${handleEvent(args)}
153
- .formatOptions=${{ style: "percent" }}
154
- ...=${spreadProps(args)}
53
+ @input=${s(e)}
54
+ @change=${s(e)}
55
+ .formatOptions=${{style:"percent"}}
56
+ ...=${t(e)}
155
57
  >
156
58
  Opacity
157
59
  </sp-slider>
158
60
  </div>
159
- `;
160
- };
161
- noVisibleLabels.args = {
162
- labelVisibility: "none"
163
- };
164
- export const px = (args = {}) => {
165
- return html`
61
+ `;noVisibleLabels.args={labelVisibility:"none"};export const px=(e={})=>i`
166
62
  <div style="width: 500px; margin: 12px 20px;">
167
63
  <sp-slider
168
64
  max="360"
169
65
  min="0"
170
66
  value="90"
171
67
  step="1"
172
- @input=${handleEvent(args)}
173
- @change=${handleEvent(args)}
174
- .formatOptions=${{
175
- style: "unit",
176
- unit: "px"
177
- }}
178
- ...=${spreadProps(args)}
68
+ @input=${s(e)}
69
+ @change=${s(e)}
70
+ .formatOptions=${{style:"unit",unit:"px"}}
71
+ ...=${t(e)}
179
72
  >
180
73
  Angle
181
74
  </sp-slider>
182
75
  </div>
183
- `;
184
- };
185
- class NumberFieldDefined extends HTMLElement {
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
- }
198
- }
199
- customElements.define("number-field-defined", NumberFieldDefined);
200
- const editableDecorator = (story) => {
201
- return html`
202
- ${story()}
76
+ `;class $ extends HTMLElement{constructor(){super();this.numberFieldLoaderPromise=Promise.resolve(!1);this.numberFieldLoaderPromise=new Promise(l=>{customElements.whenDefined("sp-number-field").then(()=>{l(!0)})})}get updateComplete(){return this.numberFieldLoaderPromise}}customElements.define("number-field-defined",$);const x=e=>i`
77
+ ${e()}
203
78
  <number-field-defined></number-field-defined>
204
- `;
205
- };
206
- export const editable = (args = {}) => {
207
- return html`
79
+ `;export const editable=(e={})=>i`
208
80
  <div style="width: 500px; margin: 12px 20px;">
209
81
  <sp-slider
210
82
  editable
@@ -212,23 +84,15 @@ export const editable = (args = {}) => {
212
84
  min="0"
213
85
  value="90"
214
86
  step="1"
215
- @input=${handleEvent(args)}
216
- @change=${handleEvent(args)}
217
- .formatOptions=${{
218
- style: "unit",
219
- unit: "degree",
220
- unitDisplay: "narrow"
221
- }}
222
- ...=${spreadProps(args)}
87
+ @input=${s(e)}
88
+ @change=${s(e)}
89
+ .formatOptions=${{style:"unit",unit:"degree",unitDisplay:"narrow"}}
90
+ ...=${t(e)}
223
91
  >
224
92
  Angle
225
93
  </sp-slider>
226
94
  </div>
227
- `;
228
- };
229
- editable.decorators = [editableDecorator];
230
- export const editableDisabled = (args = {}) => {
231
- return html`
95
+ `;editable.decorators=[x];export const editableDisabled=(e={})=>i`
232
96
  <div style="width: 500px; margin: 12px 20px;">
233
97
  <sp-slider
234
98
  editable
@@ -237,23 +101,15 @@ export const editableDisabled = (args = {}) => {
237
101
  min="0"
238
102
  value="90"
239
103
  step="1"
240
- @input=${handleEvent(args)}
241
- @change=${handleEvent(args)}
242
- .formatOptions=${{
243
- style: "unit",
244
- unit: "degree",
245
- unitDisplay: "narrow"
246
- }}
247
- ...=${spreadProps(args)}
104
+ @input=${s(e)}
105
+ @change=${s(e)}
106
+ .formatOptions=${{style:"unit",unit:"degree",unitDisplay:"narrow"}}
107
+ ...=${t(e)}
248
108
  >
249
109
  Angle
250
110
  </sp-slider>
251
111
  </div>
252
- `;
253
- };
254
- editable.decorators = [editableDecorator];
255
- export const editableCustom = (args = {}) => {
256
- return html`
112
+ `;editable.decorators=[x];export const editableCustom=(e={})=>i`
257
113
  <div
258
114
  style="width: 500px; margin: 12px 20px; --spectrum-slider-editable-number-field-width: 150px;"
259
115
  >
@@ -263,19 +119,15 @@ export const editableCustom = (args = {}) => {
263
119
  min="0"
264
120
  value="12.75"
265
121
  step="0.25"
266
- @input=${handleEvent(args)}
267
- @change=${handleEvent(args)}
268
- .formatOptions=${{ style: "unit", unit: "hour" }}
269
- ...=${spreadProps(args)}
122
+ @input=${s(e)}
123
+ @change=${s(e)}
124
+ .formatOptions=${{style:"unit",unit:"hour"}}
125
+ ...=${t(e)}
270
126
  >
271
127
  Hours
272
128
  </sp-slider>
273
129
  </div>
274
- `;
275
- };
276
- editableCustom.decorators = [editableDecorator];
277
- export const hideStepper = (args = {}) => {
278
- return html`
130
+ `;editableCustom.decorators=[x];export const hideStepper=(e={})=>i`
279
131
  <div style="width: 500px; margin: 12px 20px;">
280
132
  <sp-slider
281
133
  editable
@@ -284,19 +136,15 @@ export const hideStepper = (args = {}) => {
284
136
  min="0"
285
137
  value=".5"
286
138
  step="0.01"
287
- @input=${handleEvent(args)}
288
- @change=${handleEvent(args)}
289
- .formatOptions=${{ style: "percent" }}
290
- ...=${spreadProps(args)}
139
+ @input=${s(e)}
140
+ @change=${s(e)}
141
+ .formatOptions=${{style:"percent"}}
142
+ ...=${t(e)}
291
143
  >
292
144
  Opacity
293
145
  </sp-slider>
294
146
  </div>
295
- `;
296
- };
297
- hideStepper.decorators = [editableDecorator];
298
- export const Gradient = (args = {}) => {
299
- return html`
147
+ `;hideStepper.decorators=[x];export const Gradient=(e={})=>i`
300
148
  <div
301
149
  style="
302
150
  width: 500px;
@@ -311,49 +159,29 @@ export const Gradient = (args = {}) => {
311
159
  min="0"
312
160
  value="50"
313
161
  id="opacity-slider"
314
- @input=${handleEvent(args)}
315
- @change=${handleEvent(args)}
316
- ...=${spreadProps(args)}
162
+ @input=${s(e)}
163
+ @change=${s(e)}
164
+ ...=${t(e)}
317
165
  ></sp-slider>
318
166
  </div>
319
- `;
320
- };
321
- Gradient.args = {
322
- variant: void 0
323
- };
324
- export const tick = (args = {}) => {
325
- return html`
167
+ `;Gradient.args={variant:void 0};export const tick=(e={})=>i`
326
168
  <sp-slider
327
169
  label="Slider Label"
328
170
  variant="tick"
329
171
  min="0"
330
172
  max="92"
331
- ...=${spreadProps(args)}
173
+ ...=${t(e)}
332
174
  ></sp-slider>
333
- `;
334
- };
335
- tick.args = {
336
- variant: "tick",
337
- tickStep: 5
338
- };
339
- export const tickLabels = (args = {}) => {
340
- return html`
175
+ `;tick.args={variant:"tick",tickStep:5};export const tickLabels=(e={})=>i`
341
176
  <sp-slider
342
177
  label="Slider Label"
343
178
  tick-labels
344
179
  variant="tick"
345
180
  min="50"
346
181
  max="75"
347
- ...=${spreadProps(args)}
182
+ ...=${t(e)}
348
183
  ></sp-slider>
349
- `;
350
- };
351
- tickLabels.args = {
352
- variant: "tick",
353
- tickStep: 5
354
- };
355
- export const Disabled = (args = {}) => {
356
- return html`
184
+ `;tickLabels.args={variant:"tick",tickStep:5};export const Disabled=(e={})=>i`
357
185
  <div style="width: 500px; margin: 12px 20px;">
358
186
  <sp-slider
359
187
  disabled
@@ -362,13 +190,10 @@ export const Disabled = (args = {}) => {
362
190
  min="0"
363
191
  max="20"
364
192
  label="Intensity"
365
- ...=${spreadProps(args)}
193
+ ...=${t(e)}
366
194
  ></sp-slider>
367
195
  </div>
368
- `;
369
- };
370
- export const Quiet = (args = {}) => {
371
- return html`
196
+ `,Quiet=(e={})=>i`
372
197
  <div style="width: 500px; margin: 12px 20px;">
373
198
  <sp-slider
374
199
  editable
@@ -379,13 +204,10 @@ export const Quiet = (args = {}) => {
379
204
  min="0"
380
205
  max="20"
381
206
  label="Intensity"
382
- ...=${spreadProps(args)}
207
+ ...=${t(e)}
383
208
  ></sp-slider>
384
209
  </div>
385
- `;
386
- };
387
- export const Indeterminate = (args = {}) => {
388
- return html`
210
+ `,Indeterminate=(e={})=>i`
389
211
  <div style="width: 500px; margin: 12px 20px;">
390
212
  <sp-slider
391
213
  editable
@@ -395,41 +217,35 @@ export const Indeterminate = (args = {}) => {
395
217
  min="0"
396
218
  max="20"
397
219
  label="Intensity"
398
- @input=${handleEvent(args)}
399
- @change=${handleEvent(args)}
400
- ...=${spreadProps(args)}
220
+ @input=${s(e)}
221
+ @change=${s(e)}
222
+ ...=${t(e)}
401
223
  ></sp-slider>
402
224
  </div>
403
- `;
404
- };
405
- export const ExplicitHandle = (args = {}) => {
406
- return html`
225
+ `,ExplicitHandle=(e={})=>i`
407
226
  <div style="width: 500px; margin: 12px 20px;">
408
227
  <sp-slider
409
228
  step="0.5"
410
229
  min="0"
411
230
  max="20"
412
- @input=${handleHandleEvent(args)}
413
- @change=${handleHandleEvent(args)}
414
- ...=${spreadProps(args)}
231
+ @input=${o(e)}
232
+ @change=${o(e)}
233
+ ...=${t(e)}
415
234
  >
416
235
  Intensity
417
236
  <sp-slider-handle slot="handle" value="5"></sp-slider-handle>
418
237
  </sp-slider>
419
238
  </div>
420
- `;
421
- };
422
- export const TwoHandles = (args = {}) => {
423
- return html`
239
+ `,TwoHandles=(e={})=>i`
424
240
  <div style="width: 500px; margin: 12px 20px;">
425
241
  <sp-slider
426
242
  value="5"
427
243
  step="1"
428
244
  min="0"
429
245
  max="255"
430
- @input=${handleHandleEvent(args)}
431
- @change=${handleHandleEvent(args)}
432
- ...=${spreadProps(args)}
246
+ @input=${o(e)}
247
+ @change=${o(e)}
248
+ ...=${t(e)}
433
249
  >
434
250
  Output Levels
435
251
  <sp-slider-handle
@@ -444,27 +260,17 @@ export const TwoHandles = (args = {}) => {
444
260
  ></sp-slider-handle>
445
261
  </sp-slider>
446
262
  </div>
447
- `;
448
- };
449
- TwoHandles.args = {
450
- variant: "range",
451
- tickStep: 10
452
- };
453
- export const TwoHandlesPt = (args = {}) => {
454
- return html`
263
+ `;TwoHandles.args={variant:"range",tickStep:10};export const TwoHandlesPt=(e={})=>i`
455
264
  <div style="width: 500px; margin: 12px 20px;">
456
265
  <sp-slider
457
266
  value="5"
458
267
  step="1"
459
268
  min="0"
460
269
  max="255"
461
- @input=${handleHandleEvent(args)}
462
- @change=${handleHandleEvent(args)}
463
- .formatOptions=${{
464
- style: "unit",
465
- unit: "pt"
466
- }}
467
- ...=${spreadProps(args)}
270
+ @input=${o(e)}
271
+ @change=${o(e)}
272
+ .formatOptions=${{style:"unit",unit:"pt"}}
273
+ ...=${t(e)}
468
274
  >
469
275
  Output Levels
470
276
  <sp-slider-handle
@@ -479,27 +285,17 @@ export const TwoHandlesPt = (args = {}) => {
479
285
  ></sp-slider-handle>
480
286
  </sp-slider>
481
287
  </div>
482
- `;
483
- };
484
- TwoHandlesPt.args = {
485
- variant: "range",
486
- tickStep: 10
487
- };
488
- export const ThreeHandlesPc = (args = {}) => {
489
- return html`
288
+ `;TwoHandlesPt.args={variant:"range",tickStep:10};export const ThreeHandlesPc=(e={})=>i`
490
289
  <div style="width: 500px; margin: 12px 20px;">
491
290
  <sp-slider
492
291
  value="5"
493
292
  step="1"
494
293
  min="0"
495
294
  max="255"
496
- @input=${handleHandleEvent(args)}
497
- @change=${handleHandleEvent(args)}
498
- .formatOptions=${{
499
- style: "unit",
500
- unit: "pc"
501
- }}
502
- ...=${spreadProps(args)}
295
+ @input=${o(e)}
296
+ @change=${o(e)}
297
+ .formatOptions=${{style:"unit",unit:"pc"}}
298
+ ...=${t(e)}
503
299
  >
504
300
  Output Levels
505
301
  <sp-slider-handle slot="handle" value="5"></sp-slider-handle>
@@ -507,18 +303,15 @@ export const ThreeHandlesPc = (args = {}) => {
507
303
  <sp-slider-handle slot="handle" value="250"></sp-slider-handle>
508
304
  </sp-slider>
509
305
  </div>
510
- `;
511
- };
512
- export const ThreeHandlesOrdered = (args = {}) => {
513
- return html`
306
+ `,ThreeHandlesOrdered=(e={})=>i`
514
307
  <div style="width: 500px; margin: 12px 20px;">
515
308
  <sp-slider
516
309
  step="1"
517
310
  min="0"
518
311
  max="255"
519
- @input=${handleHandleEvent(args)}
520
- @change=${handleHandleEvent(args)}
521
- ...=${spreadProps(args)}
312
+ @input=${o(e)}
313
+ @change=${o(e)}
314
+ ...=${t(e)}
522
315
  >
523
316
  Output Levels
524
317
  <sp-slider-handle
@@ -542,101 +335,22 @@ export const ThreeHandlesOrdered = (args = {}) => {
542
335
  ></sp-slider-handle>
543
336
  </sp-slider>
544
337
  </div>
545
- `;
546
- };
547
- ThreeHandlesOrdered.args = {
548
- tickStep: 10
549
- };
550
- export const ThreeHandlesComplex = (args = {}) => {
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);
565
- }
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);
572
- }
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
621
- };
622
- return new Intl.NumberFormat(navigator.language, formatOptions).format(result);
623
- };
624
- return html`
338
+ `;ThreeHandlesOrdered.args={tickStep:10};export const ThreeHandlesComplex=(e={})=>{const l={black:50,gray:4.98,white:225},r=({onInput:a,onChange:n})=>p=>{const m=p.target;if(m.value!=null){if(typeof m.value=="object"){const c=JSON.stringify(m.value,null,2);a&&p.type==="input"?a(c):n&&p.type==="change"&&n(c)}else{const c=`${m.name}: ${m.value}`;a&&p.type==="input"?a(c):n&&p.type==="change"&&n(c)}l[m.name]=m.value}},d={toNormalized(a){const n=l.black/255,p=l.white/255;return Math.max(Math.min(a,1),0)*(p-n)+n},fromNormalized(a){const n=l.black/255,p=l.white/255;return(Math.max(Math.min(a,p),n)-n)/(p-n)}},u={toNormalized(a){return Math.min(a,l.white)/255},fromNormalized(a){const n=a*255;return Math.min(n,l.white)}},h={toNormalized(a){return Math.max(a,l.black)/255},fromNormalized(a){const n=a*255;return Math.max(n,l.black)}},v=a=>{let n=1;a>.5?n=Math.max(2*(1-a),.01):a<.5&&(n=((1-2*a)*(Math.sqrt(9.99)-1)+1)**2);const p={maximumFractionDigits:2,minimumFractionDigits:2};return new Intl.NumberFormat(navigator.language,p).format(n)};return i`
625
339
  <div style="width: 500px; margin: 12px 20px;">
626
340
  <sp-slider
627
341
  step="1"
628
342
  min="0"
629
343
  max="255"
630
- @input=${handleEvent2}
631
- @change=${handleEvent2}
632
- ...=${spreadProps(args)}
344
+ @input=${r}
345
+ @change=${r}
346
+ ...=${t(e)}
633
347
  >
634
348
  Output Levels
635
349
  <sp-slider-handle
636
350
  slot="handle"
637
351
  name="black"
638
- value=${values.black}
639
- .normalization=${blackNormalization}
352
+ value=${l.black}
353
+ .normalization=${u}
640
354
  ></sp-slider-handle>
641
355
  <sp-slider-handle
642
356
  slot="handle"
@@ -645,61 +359,50 @@ export const ThreeHandlesComplex = (args = {}) => {
645
359
  min="0"
646
360
  max="1"
647
361
  step="0.005"
648
- .normalization=${grayNormalization}
649
- .getAriaHandleText=${computeGray}
362
+ .normalization=${d}
363
+ .getAriaHandleText=${v}
650
364
  ></sp-slider-handle>
651
365
  <sp-slider-handle
652
366
  slot="handle"
653
367
  name="white"
654
- value=${values.white}
655
- .normalization=${whiteNormalization}
368
+ value=${l.white}
369
+ .normalization=${h}
656
370
  ></sp-slider-handle>
657
371
  </sp-slider>
658
372
  </div>
659
- `;
660
- };
661
- ThreeHandlesOrdered.args = {
662
- tickStep: 10
663
- };
664
- export const focusTabDemo = (args = {}) => {
665
- const value = 50;
666
- const min = 0;
667
- const max = 100;
668
- const step = 1;
669
- return html`
373
+ `};ThreeHandlesOrdered.args={tickStep:10};export const focusTabDemo=(e={})=>i`
670
374
  <div style="width: 500px; margin: 12px 20px 20px;">
671
375
  <sp-slider
672
- value="${value}"
673
- step="${step}"
674
- min="${min}"
675
- max="${max}"
376
+ value="${50}"
377
+ step="${1}"
378
+ min="${0}"
379
+ max="${100}"
676
380
  label="Opacity"
677
381
  id="opacity-slider-opacity"
678
- ...=${spreadProps(args)}
382
+ ...=${t(e)}
679
383
  ></sp-slider>
680
384
  </div>
681
385
  <div style="width: 500px; margin: 20px;">
682
386
  <sp-slider
683
- value="${value}"
684
- step="${step}"
685
- min="${min}"
686
- max="${max}"
387
+ value="${50}"
388
+ step="${1}"
389
+ min="${0}"
390
+ max="${100}"
687
391
  label="Lightness"
688
392
  id="opacity-slider-lightness"
689
- ...=${spreadProps(args)}
393
+ ...=${t(e)}
690
394
  ></sp-slider>
691
395
  </div>
692
396
  <div style="width: 500px; margin: 20px 20px 12px;">
693
397
  <sp-slider
694
- value="${value}"
695
- step="${step}"
696
- min="${min}"
697
- max="${max}"
398
+ value="${50}"
399
+ step="${1}"
400
+ min="${0}"
401
+ max="${100}"
698
402
  label="Saturation"
699
403
  id="opacity-slider-saturation"
700
- ...=${spreadProps(args)}
404
+ ...=${t(e)}
701
405
  ></sp-slider>
702
406
  </div>
703
407
  `;
704
- };
705
408
  //# sourceMappingURL=slider.stories.js.map