@spectrum-web-components/slider 0.12.3-express.0 → 0.12.5
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/custom-elements.json
CHANGED
|
@@ -32,6 +32,12 @@
|
|
|
32
32
|
}
|
|
33
33
|
]
|
|
34
34
|
},
|
|
35
|
+
{
|
|
36
|
+
"kind": "javascript-module",
|
|
37
|
+
"path": "sync/sp-slider.ts",
|
|
38
|
+
"declarations": [],
|
|
39
|
+
"exports": []
|
|
40
|
+
},
|
|
35
41
|
{
|
|
36
42
|
"kind": "javascript-module",
|
|
37
43
|
"path": "src/HandleController.ts",
|
|
@@ -242,6 +248,24 @@
|
|
|
242
248
|
}
|
|
243
249
|
}
|
|
244
250
|
},
|
|
251
|
+
{
|
|
252
|
+
"kind": "method",
|
|
253
|
+
"name": "waitForUpgrade",
|
|
254
|
+
"privacy": "private",
|
|
255
|
+
"return": {
|
|
256
|
+
"type": {
|
|
257
|
+
"text": "boolean"
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
"parameters": [
|
|
261
|
+
{
|
|
262
|
+
"name": "handle",
|
|
263
|
+
"type": {
|
|
264
|
+
"text": "HTMLElement"
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
]
|
|
268
|
+
},
|
|
245
269
|
{
|
|
246
270
|
"kind": "field",
|
|
247
271
|
"name": "extractModelFromLightDom",
|
|
@@ -1430,6 +1454,16 @@
|
|
|
1430
1454
|
"tagName": "sp-slider",
|
|
1431
1455
|
"customElement": true,
|
|
1432
1456
|
"events": [
|
|
1457
|
+
{
|
|
1458
|
+
"name": "sp-slider-handle-ready",
|
|
1459
|
+
"type": {
|
|
1460
|
+
"text": "CustomEvent"
|
|
1461
|
+
},
|
|
1462
|
+
"inheritedFrom": {
|
|
1463
|
+
"name": "SliderHandle",
|
|
1464
|
+
"module": "src/SliderHandle.ts"
|
|
1465
|
+
}
|
|
1466
|
+
},
|
|
1433
1467
|
{
|
|
1434
1468
|
"description": "The value of the element has changed.",
|
|
1435
1469
|
"name": "input",
|
|
@@ -1676,6 +1710,12 @@
|
|
|
1676
1710
|
}
|
|
1677
1711
|
],
|
|
1678
1712
|
"events": [
|
|
1713
|
+
{
|
|
1714
|
+
"name": "sp-slider-handle-ready",
|
|
1715
|
+
"type": {
|
|
1716
|
+
"text": "CustomEvent"
|
|
1717
|
+
}
|
|
1718
|
+
},
|
|
1679
1719
|
{
|
|
1680
1720
|
"description": "The value of the element has changed.",
|
|
1681
1721
|
"name": "input"
|
|
@@ -1854,12 +1894,6 @@
|
|
|
1854
1894
|
}
|
|
1855
1895
|
}
|
|
1856
1896
|
]
|
|
1857
|
-
},
|
|
1858
|
-
{
|
|
1859
|
-
"kind": "javascript-module",
|
|
1860
|
-
"path": "sync/sp-slider.ts",
|
|
1861
|
-
"declarations": [],
|
|
1862
|
-
"exports": []
|
|
1863
1897
|
}
|
|
1864
1898
|
]
|
|
1865
1899
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/slider",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -48,16 +48,16 @@
|
|
|
48
48
|
"lit-html"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@internationalized/number": "^3.0.
|
|
52
|
-
"@spectrum-web-components/base": "^0.5.2
|
|
53
|
-
"@spectrum-web-components/field-label": "^0.7.
|
|
54
|
-
"@spectrum-web-components/number-field": "^0.3.
|
|
55
|
-
"@spectrum-web-components/shared": "^0.13.
|
|
56
|
-
"@spectrum-web-components/theme": "^0.9.
|
|
51
|
+
"@internationalized/number": "^3.0.2",
|
|
52
|
+
"@spectrum-web-components/base": "^0.5.2",
|
|
53
|
+
"@spectrum-web-components/field-label": "^0.7.4",
|
|
54
|
+
"@spectrum-web-components/number-field": "^0.3.5",
|
|
55
|
+
"@spectrum-web-components/shared": "^0.13.4",
|
|
56
|
+
"@spectrum-web-components/theme": "^0.9.4",
|
|
57
57
|
"tslib": "^2.0.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@spectrum-css/slider": "
|
|
60
|
+
"@spectrum-css/slider": "^3.0.11"
|
|
61
61
|
},
|
|
62
62
|
"types": "./src/index.d.ts",
|
|
63
63
|
"customElements": "custom-elements.json",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"./sp-*.js",
|
|
66
66
|
"./sync/sp-*.js"
|
|
67
67
|
],
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "bb5308b9be01cc7c5bbab289312042256bdcc740"
|
|
69
69
|
}
|
|
@@ -61,6 +61,7 @@ export declare class HandleController implements Controller {
|
|
|
61
61
|
hostConnected(): void;
|
|
62
62
|
hostDisconnected(): void;
|
|
63
63
|
hostUpdate(): void;
|
|
64
|
+
private waitForUpgrade;
|
|
64
65
|
private extractModelFromLightDom;
|
|
65
66
|
get activeHandle(): string;
|
|
66
67
|
get activeHandleInputId(): string;
|
package/src/HandleController.js
CHANGED
|
@@ -11,6 +11,7 @@ governing permissions and limitations under the License.
|
|
|
11
11
|
*/
|
|
12
12
|
import { html } from '@spectrum-web-components/base';
|
|
13
13
|
import { classMap, ifDefined, styleMap, } from '@spectrum-web-components/base/src/directives.js';
|
|
14
|
+
import { SliderHandle, } from './SliderHandle.js';
|
|
14
15
|
export class HandleController {
|
|
15
16
|
constructor(host) {
|
|
16
17
|
this.handles = new Map();
|
|
@@ -26,6 +27,10 @@ export class HandleController {
|
|
|
26
27
|
if (handles.length === 0) {
|
|
27
28
|
handles = [this.host];
|
|
28
29
|
}
|
|
30
|
+
// extractModelFromLightDom depends on slotted handles already having been upgraded
|
|
31
|
+
if (handles.some((h) => this.waitForUpgrade(h))) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
29
34
|
this.handles = new Map();
|
|
30
35
|
this.handleOrder = [];
|
|
31
36
|
handles.forEach((handle, index) => {
|
|
@@ -173,6 +178,15 @@ export class HandleController {
|
|
|
173
178
|
hostUpdate() {
|
|
174
179
|
this.updateModel();
|
|
175
180
|
}
|
|
181
|
+
// Since extractModelFromLightDom bails on the first un-upgraded handle,
|
|
182
|
+
// a maximum of one listener will be set up per extraction attempt.
|
|
183
|
+
waitForUpgrade(handle) {
|
|
184
|
+
if (handle instanceof SliderHandle) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
handle.addEventListener('sp-slider-handle-ready', () => this.extractModelFromLightDom(), { once: true, passive: true });
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
176
190
|
get activeHandle() {
|
|
177
191
|
return this.handleOrder[this.handleOrder.length - 1];
|
|
178
192
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HandleController.js","sourceRoot":"","sources":["HandleController.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,IAAI,EAAkB,MAAM,+BAA+B,CAAC;AACrE,OAAO,EACH,QAAQ,EACR,SAAS,EACT,QAAQ,GACX,MAAM,iDAAiD,CAAC;AA8CzD,MAAM,OAAO,gBAAgB;IASzB,YAAY,IAAY;QANhB,YAAO,GAA8B,IAAI,GAAG,EAAE,CAAC;QAC/C,UAAK,GAAiB,EAAE,CAAC;QACzB,gBAAW,GAAa,EAAE,CAAC;QAyFzB,sBAAiB,GAAG,GAAS,EAAE;YACrC,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC9B,CAAC,CAAC;QAwCM,6BAAwB,GAAG,GAAS,EAAE;YAC1C,IAAI,OAAO,GAAG;gBACV,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC;aACjC,CAAC;YACpB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;gBACtB,OAAO,GAAG,CAAC,IAAI,CAAC,IAAoB,CAAC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CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC;IAC7B,CAAC;IAEM,KAAK,CAAC,qBAAqB;QAC9B,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;aACrC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC,IAAI,CAAC;aACxC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QAC5C,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;CACJ","sourcesContent":["/*\nCopyright 2021 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { html, TemplateResult } from '@spectrum-web-components/base';\nimport {\n classMap,\n ifDefined,\n styleMap,\n} from '@spectrum-web-components/base/src/directives.js';\nimport { Slider } from './Slider.js';\nimport {\n Controller,\n SliderHandle,\n SliderNormalization,\n} from './SliderHandle.js';\n\ninterface HandleReference {\n handle: HTMLElement;\n input: HTMLInputElement;\n}\n\ninterface HandleComponents extends HandleReference {\n model: SliderHandle;\n}\n\ninterface RangeAndClamp {\n range: { min: number; max: number };\n clamp: { min: number; max: number };\n}\ninterface ModelValue extends RangeAndClamp {\n name: string;\n value: number;\n normalizedValue: number;\n step: number;\n highlight: boolean;\n ariaLabel?: string;\n normalization: SliderNormalization;\n handle: SliderHandle;\n}\n\ninterface InputWithModel extends HTMLInputElement {\n model: ModelValue;\n}\n\ninterface DataFromPointerEvent {\n resolvedInput: boolean;\n input: InputWithModel;\n model?: ModelValue;\n}\n\nexport interface HandleValueDictionary {\n [key: string]: number;\n}\n\nexport class HandleController implements Controller {\n private observer!: MutationObserver;\n private host!: Slider;\n private handles: Map<string, SliderHandle> = new Map();\n private model: ModelValue[] = [];\n private handleOrder: string[] = [];\n private draggingHandle?: SliderHandle;\n private handleRefMap?: WeakMap<SliderHandle, HandleReference>;\n\n constructor(host: Slider) {\n this.host = host;\n }\n\n public get values(): HandleValueDictionary {\n const result: HandleValueDictionary = {};\n for (const model of this.handles.values()) {\n result[model.handleName] = model.value;\n }\n return result;\n }\n\n public get size(): number {\n return this.handles.size;\n }\n\n public inputForHandle(handle: SliderHandle): HTMLInputElement | undefined {\n if (this.handles.has(handle.handleName)) {\n const { input } = this.getHandleElements(handle);\n return input;\n }\n /* c8 ignore next 2 */\n throw new Error(`No input for handle \"${handle.name}\"`);\n }\n\n public requestUpdate(): void {\n this.host.requestUpdate();\n }\n\n /**\n * It is possible for value attributes to be set programmatically. The <input>\n * for a particular slider needs to have an opportunity to validate any such\n * values\n *\n * @param handle Handle who's value needs validation\n */\n public setValueFromHandle(handle: SliderHandle): void {\n const elements = this.getHandleElements(handle);\n /* c8 ignore next */\n if (!elements) return;\n\n const { input } = elements;\n if (input.valueAsNumber === handle.value) {\n if (handle.dragging) {\n handle.dispatchInputEvent();\n }\n } else {\n input.valueAsNumber = handle.value;\n handle.value = input.valueAsNumber;\n this.requestUpdate();\n }\n handle.value = input.valueAsNumber;\n }\n\n public handleHasChanged(handle: SliderHandle): void {\n if (handle !== this.host) {\n this.requestUpdate();\n }\n }\n\n public formattedValueForHandle(model: ModelValue): string {\n const { handle } = model;\n const numberFormat = handle.numberFormat ?? this.host.numberFormat;\n return handle.getAriaHandleText(model.value, numberFormat);\n }\n\n public get formattedValues(): Map<string, string> {\n const result = new Map<string, string>();\n for (const model of this.model) {\n result.set(model.name, this.formattedValueForHandle(model));\n }\n return result;\n }\n\n public get focusElement(): HTMLElement {\n const { input } = this.getActiveHandleElements();\n if (\n this.host.editable &&\n !(input as InputWithModel).model.handle.dragging\n ) {\n return this.host.numberField;\n }\n return input;\n }\n\n protected handleOrientation = (): void => {\n this.updateBoundingRect();\n };\n\n public hostConnected(): void {\n if (!this.observer) {\n this.observer = new MutationObserver(this.extractModelFromLightDom);\n }\n this.observer.observe(this.host, { subtree: true, childList: true });\n this.extractModelFromLightDom();\n if ('orientation' in screen) {\n screen.orientation.addEventListener(\n 'change',\n this.handleOrientation\n );\n } else {\n window.addEventListener(\n 'orientationchange',\n this.handleOrientation\n );\n }\n }\n\n public hostDisconnected(): void {\n this.observer.disconnect();\n if ('orientation' in screen) {\n screen.orientation.removeEventListener(\n 'change',\n this.handleOrientation\n );\n } else {\n window.removeEventListener(\n 'orientationchange',\n this.handleOrientation\n );\n }\n }\n\n public hostUpdate(): void {\n this.updateModel();\n }\n\n private extractModelFromLightDom = (): void => {\n let handles = [\n ...this.host.querySelectorAll('[slot=\"handle\"]'),\n ] as SliderHandle[];\n if (handles.length === 0) {\n handles = [this.host as SliderHandle];\n }\n this.handles = new Map();\n this.handleOrder = [];\n handles.forEach((handle, index) => {\n /* c8 ignore next */\n if (!handle.handleName?.length) {\n handle.name = `handle${index + 1}`;\n }\n this.handles.set(handle.handleName, handle);\n this.handleOrder.push(handle.handleName);\n handle.handleController = this;\n });\n this.requestUpdate();\n };\n\n public get activeHandle(): string {\n return this.handleOrder[this.handleOrder.length - 1];\n }\n\n public get activeHandleInputId(): string {\n const active = this.activeHandle;\n const index = this.model.findIndex((model) => model.name === active);\n return `input-${index}`;\n }\n\n public activateHandle(name: string): void {\n const index = this.handleOrder.findIndex((item) => item === name);\n if (index >= 0) {\n this.handleOrder.splice(index, 1);\n }\n this.handleOrder.push(name);\n }\n\n private getActiveHandleElements(): HandleComponents {\n const name = this.activeHandle;\n const handleSlider = this.handles.get(name) as SliderHandle;\n const elements = this.getHandleElements(\n handleSlider\n ) as HandleReference;\n return { model: handleSlider, ...elements };\n }\n\n private getHandleElements(sliderHandle: SliderHandle): HandleReference {\n if (!this.handleRefMap) {\n this.handleRefMap = new WeakMap();\n\n const inputNodes =\n this.host.shadowRoot.querySelectorAll('.handle > input');\n for (const inputNode of inputNodes) {\n const input = inputNode as HTMLInputElement;\n const handle = input.parentElement as HTMLElement;\n const model = this.handles.get(\n handle.getAttribute('name') as string\n );\n if (model) {\n this.handleRefMap.set(model, { input, handle });\n }\n }\n }\n\n const components = this.handleRefMap.get(\n sliderHandle\n ) as HandleReference;\n return components;\n }\n\n private clearHandleComponentCache(): void {\n delete this.handleRefMap;\n }\n\n private _boundingClientRect?: DOMRect;\n\n private get boundingClientRect(): DOMRect {\n if (!this._boundingClientRect) {\n this._boundingClientRect = this.host.track.getBoundingClientRect();\n }\n return this._boundingClientRect;\n }\n\n private updateBoundingRect(): void {\n delete this._boundingClientRect;\n }\n\n /**\n * Return the `input` and `model` associated with the event and\n * whether the `input` is a `resolvedInput` meaning it was acquired\n * from the `model` rather than the event.\n */\n protected extractDataFromEvent(event: PointerEvent): DataFromPointerEvent {\n if (!this._activePointerEventData) {\n let input = (event.target as Element).querySelector(\n ':scope > .input'\n ) as InputWithModel;\n const resolvedInput = !input;\n const model = input\n ? input.model\n : this.model.find((item) => item.name === this.activeHandle);\n if (!input && !!model) {\n input = model.handle.focusElement as InputWithModel;\n }\n this._activePointerEventData = {\n input,\n model,\n resolvedInput,\n };\n }\n return this._activePointerEventData;\n }\n\n private _activePointerEventData!: DataFromPointerEvent | undefined;\n\n public handlePointerdown(event: PointerEvent): void {\n const { resolvedInput, model } = this.extractDataFromEvent(event);\n if (!model || this.host.disabled || event.button !== 0) {\n event.preventDefault();\n return;\n }\n this.host.track.setPointerCapture(event.pointerId);\n this.updateBoundingRect();\n this.host.labelEl.click();\n this.draggingHandle = model.handle;\n model.handle.dragging = true;\n this.activateHandle(model.name);\n if (resolvedInput) {\n // When the input is resolved forward the pointer event to\n // `handlePointermove` in order to update the value/UI becuase\n // the pointer event was on the track not a handle\n this.handlePointermove(event);\n }\n this.requestUpdate();\n }\n\n public handlePointerup(event: PointerEvent): void {\n const { input, model } = this.extractDataFromEvent(event);\n delete this._activePointerEventData;\n if (!model) return;\n this.host.labelEl.click();\n model.handle.highlight = false;\n delete this.draggingHandle;\n model.handle.dragging = false;\n this.requestUpdate();\n this.host.track.releasePointerCapture(event.pointerId);\n this.dispatchChangeEvent(input, model.handle);\n }\n\n public handlePointermove(event: PointerEvent): void {\n const { input, model } = this.extractDataFromEvent(event);\n if (!model) return;\n /* c8 ignore next 3 */\n if (!this.draggingHandle) {\n return;\n }\n event.stopPropagation();\n input.value = this.calculateHandlePosition(event, model).toString();\n model.handle.value = parseFloat(input.value);\n this.requestUpdate();\n }\n\n /**\n * Keep the slider value property in sync with the input element's value\n */\n private onInputChange = (event: Event): void => {\n const input = event.target as InputWithModel;\n input.model.handle.value = input.valueAsNumber;\n\n this.requestUpdate();\n this.dispatchChangeEvent(input, input.model.handle);\n };\n\n private onInputFocus = (event: Event): void => {\n const input = event.target as InputWithModel;\n let isFocusVisible;\n try {\n isFocusVisible =\n input.matches(':focus-visible') ||\n this.host.matches('.focus-visible');\n /* c8 ignore next 3 */\n } catch (error) {\n isFocusVisible = this.host.matches('.focus-visible');\n }\n input.model.handle.highlight = isFocusVisible;\n this.requestUpdate();\n };\n\n private onInputBlur = (event: Event): void => {\n const input = event.target as InputWithModel;\n input.model.handle.highlight = false;\n this.requestUpdate();\n };\n\n private onInputKeydown = (event: Event): void => {\n const input = event.target as InputWithModel;\n input.model.handle.highlight = true;\n this.requestUpdate();\n };\n\n private dispatchChangeEvent(\n input: HTMLInputElement,\n handle: SliderHandle\n ): void {\n input.valueAsNumber = handle.value;\n\n const changeEvent = new Event('change', {\n bubbles: true,\n composed: true,\n });\n\n handle.dispatchEvent(changeEvent);\n }\n\n /**\n * Returns the value under the cursor\n * @param: PointerEvent on slider\n * @return: Slider value that correlates to the position under the pointer\n */\n private calculateHandlePosition(\n event: PointerEvent | MouseEvent,\n model: ModelValue\n ): number {\n const rect = this.boundingClientRect;\n const minOffset = rect.left;\n const offset = event.clientX;\n const size = rect.width;\n\n const normalized = (offset - minOffset) / size;\n const value = model.normalization.fromNormalized(\n normalized,\n model.range.min,\n model.range.max\n );\n\n /* c8 ignore next */\n return this.host.isLTR ? value : model.range.max - value;\n }\n\n public renderHandle(\n model: ModelValue,\n index: number,\n zIndex: number,\n isMultiHandle: boolean\n ): TemplateResult {\n const classes = {\n handle: true,\n dragging: this.draggingHandle?.handleName === model.name,\n 'handle-highlight': model.highlight,\n };\n const style = {\n [this.host.isLTR ? 'left' : 'right']: `${\n model.normalizedValue * 100\n }%`,\n 'z-index': zIndex.toString(),\n // Allow setting background per-handle\n 'background-color': `var(--spectrum-slider-handle-background-color-${index}, var(--spectrum-slider-handle-default-background-color))`,\n 'border-color': `var(--spectrum-slider-handle-border-color-${index}, var(-spectrum-slider-handle-default-border-color))`,\n };\n const ariaLabelledBy = isMultiHandle ? `label input-${index}` : 'label';\n return html`\n <div\n class=${classMap(classes)}\n name=${model.name}\n style=${styleMap(style)}\n role=\"presentation\"\n >\n <input\n type=\"range\"\n class=\"input\"\n id=\"input-${index}\"\n min=${model.clamp.min}\n max=${model.clamp.max}\n step=${model.step}\n value=${model.value}\n aria-disabled=${ifDefined(\n this.host.disabled ? 'true' : undefined\n )}\n tabindex=${ifDefined(this.host.editable ? -1 : undefined)}\n aria-label=${ifDefined(model.ariaLabel)}\n aria-labelledby=${ariaLabelledBy}\n aria-valuetext=${this.formattedValueForHandle(model)}\n @change=${this.onInputChange}\n @focus=${this.onInputFocus}\n @blur=${this.onInputBlur}\n @keydown=${this.onInputKeydown}\n .model=${model}\n />\n </div>\n `;\n }\n\n public render(): TemplateResult[] {\n this.clearHandleComponentCache();\n return this.model.map((model, index) => {\n const zIndex = this.handleOrder.indexOf(model.name) + 1;\n return this.renderHandle(\n model,\n index,\n zIndex,\n this.model.length > 1\n );\n });\n }\n\n /**\n * Returns a list of track segment [start, end] tuples where the values are\n * normalized to be between 0 and 1.\n * @returns A list of track segment tuples [start, end]\n */\n public trackSegments(): [number, number][] {\n const values = this.model.map((model) => model.normalizedValue);\n values.sort((a, b) => a - b);\n\n // The first segment always starts at 0\n values.unshift(0);\n return values.map((value, index, array) => [\n value,\n array[index + 1] ?? 1,\n ]);\n }\n\n private updateModel(): void {\n const handles = [...this.handles.values()];\n\n const getRangeAndClamp = (index: number): RangeAndClamp => {\n const handle = handles[index];\n const previous = handles[index - 1];\n const next = handles[index + 1];\n\n const min =\n typeof handle.min === 'number'\n ? handle.min\n : (this.host.min as number);\n const max =\n typeof handle.max === 'number'\n ? handle.max\n : (this.host.max as number);\n\n const result: RangeAndClamp = {\n range: { min: min, max: max },\n clamp: { min: min, max: max },\n };\n\n if (handle.min === 'previous') {\n if (previous) {\n for (let j = index - 1; j >= 0; j--) {\n const item = handles[j];\n if (typeof item.min === 'number') {\n result.range.min = item.min;\n break;\n }\n }\n result.clamp.min = Math.max(\n previous.value,\n result.range.min\n );\n /* c8 ignore next 5 */\n } else {\n console.warn(\n 'First slider handle cannot have attribute min=\"previous\"'\n );\n }\n }\n if (handle.max === 'next') {\n if (next) {\n for (let j = index + 1; j < handles.length; j++) {\n const item = handles[j];\n if (typeof item.max === 'number') {\n result.range.max = item.max;\n break;\n }\n }\n result.clamp.max = Math.min(next.value, result.range.max);\n /* c8 ignore next 5 */\n } else {\n console.warn(\n 'Last slider handle cannot have attribute max=\"next\"'\n );\n }\n }\n return result;\n };\n\n const modelValues = handles.map((handle, index) => {\n const rangeAndClamp = getRangeAndClamp(index);\n const { toNormalized } = handle.normalization;\n const clampedValue = Math.max(\n Math.min(handle.value, rangeAndClamp.clamp.max),\n rangeAndClamp.clamp.min\n );\n const normalizedValue = toNormalized(\n clampedValue,\n rangeAndClamp.range.min,\n rangeAndClamp.range.max\n );\n const model = {\n name: handle.handleName,\n value: clampedValue,\n normalizedValue,\n highlight: handle.highlight,\n step: handle.step ?? this.host.step,\n normalization: handle.normalization,\n handle,\n ariaLabel:\n handle !== this.host && handle?.label.length > 0\n ? handle.label\n : undefined,\n ...rangeAndClamp,\n };\n return model;\n });\n\n this.model = modelValues;\n }\n\n public async handleUpdatesComplete(): Promise<void> {\n const updates = [...this.handles.values()]\n .filter((handle) => handle !== this.host)\n .map((handle) => handle.updateComplete);\n await Promise.all(updates);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"HandleController.js","sourceRoot":"","sources":["HandleController.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,IAAI,EAAkB,MAAM,+BAA+B,CAAC;AACrE,OAAO,EACH,QAAQ,EACR,SAAS,EACT,QAAQ,GACX,MAAM,iDAAiD,CAAC;AAEzD,OAAO,EAEH,YAAY,GAEf,MAAM,mBAAmB,CAAC;AAwC3B,MAAM,OAAO,gBAAgB;IASzB,YAAY,IAAY;QANhB,YAAO,GAA8B,IAAI,GAAG,EAAE,CAAC;QAC/C,UAAK,GAAiB,EAAE,CAAC;QACzB,gBAAW,GAAa,EAAE,CAAC;QAyFzB,sBAAiB,GAAG,GAAS,EAAE;YACrC,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC9B,CAAC,CAAC;QAsDM,6BAAwB,GAAG,GAAS,EAAE;YAC1C,IAAI,OAAO,GAAG;gBACV,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC;aACjC,CAAC;YACpB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;gBACtB,OAAO,GAAG,CAAC,IAAI,CAAC,IAAoB,CAAC,CAAC;aACzC;YACD,mFAAmF;YACnF,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE;gBAC7C,OAAO;aACV;YACD,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;YACzB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;YACtB,OAAO,CAAC,O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,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,MAAM,IAAG,CAAC;oBAC5C,CAAC,CAAC,MAAM,CAAC,KAAK;oBACd,CAAC,CAAC,SAAS,IAChB,aAAa,CACnB,CAAC;YACF,OAAO,KAAK,CAAC;QACjB,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC;IAC7B,CAAC;IAEM,KAAK,CAAC,qBAAqB;QAC9B,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;aACrC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC,IAAI,CAAC;aACxC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QAC5C,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;CACJ","sourcesContent":["/*\nCopyright 2021 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { html, TemplateResult } from '@spectrum-web-components/base';\nimport {\n classMap,\n ifDefined,\n styleMap,\n} from '@spectrum-web-components/base/src/directives.js';\nimport { Slider } from './Slider.js';\nimport {\n Controller,\n SliderHandle,\n SliderNormalization,\n} from './SliderHandle.js';\n\ninterface HandleReference {\n handle: HTMLElement;\n input: HTMLInputElement;\n}\n\ninterface HandleComponents extends HandleReference {\n model: SliderHandle;\n}\n\ninterface RangeAndClamp {\n range: { min: number; max: number };\n clamp: { min: number; max: number };\n}\ninterface ModelValue extends RangeAndClamp {\n name: string;\n value: number;\n normalizedValue: number;\n step: number;\n highlight: boolean;\n ariaLabel?: string;\n normalization: SliderNormalization;\n handle: SliderHandle;\n}\n\ninterface InputWithModel extends HTMLInputElement {\n model: ModelValue;\n}\n\ninterface DataFromPointerEvent {\n resolvedInput: boolean;\n input: InputWithModel;\n model?: ModelValue;\n}\n\nexport interface HandleValueDictionary {\n [key: string]: number;\n}\n\nexport class HandleController implements Controller {\n private observer!: MutationObserver;\n private host!: Slider;\n private handles: Map<string, SliderHandle> = new Map();\n private model: ModelValue[] = [];\n private handleOrder: string[] = [];\n private draggingHandle?: SliderHandle;\n private handleRefMap?: WeakMap<SliderHandle, HandleReference>;\n\n constructor(host: Slider) {\n this.host = host;\n }\n\n public get values(): HandleValueDictionary {\n const result: HandleValueDictionary = {};\n for (const model of this.handles.values()) {\n result[model.handleName] = model.value;\n }\n return result;\n }\n\n public get size(): number {\n return this.handles.size;\n }\n\n public inputForHandle(handle: SliderHandle): HTMLInputElement | undefined {\n if (this.handles.has(handle.handleName)) {\n const { input } = this.getHandleElements(handle);\n return input;\n }\n /* c8 ignore next 2 */\n throw new Error(`No input for handle \"${handle.name}\"`);\n }\n\n public requestUpdate(): void {\n this.host.requestUpdate();\n }\n\n /**\n * It is possible for value attributes to be set programmatically. The <input>\n * for a particular slider needs to have an opportunity to validate any such\n * values\n *\n * @param handle Handle who's value needs validation\n */\n public setValueFromHandle(handle: SliderHandle): void {\n const elements = this.getHandleElements(handle);\n /* c8 ignore next */\n if (!elements) return;\n\n const { input } = elements;\n if (input.valueAsNumber === handle.value) {\n if (handle.dragging) {\n handle.dispatchInputEvent();\n }\n } else {\n input.valueAsNumber = handle.value;\n handle.value = input.valueAsNumber;\n this.requestUpdate();\n }\n handle.value = input.valueAsNumber;\n }\n\n public handleHasChanged(handle: SliderHandle): void {\n if (handle !== this.host) {\n this.requestUpdate();\n }\n }\n\n public formattedValueForHandle(model: ModelValue): string {\n const { handle } = model;\n const numberFormat = handle.numberFormat ?? this.host.numberFormat;\n return handle.getAriaHandleText(model.value, numberFormat);\n }\n\n public get formattedValues(): Map<string, string> {\n const result = new Map<string, string>();\n for (const model of this.model) {\n result.set(model.name, this.formattedValueForHandle(model));\n }\n return result;\n }\n\n public get focusElement(): HTMLElement {\n const { input } = this.getActiveHandleElements();\n if (\n this.host.editable &&\n !(input as InputWithModel).model.handle.dragging\n ) {\n return this.host.numberField;\n }\n return input;\n }\n\n protected handleOrientation = (): void => {\n this.updateBoundingRect();\n };\n\n public hostConnected(): void {\n if (!this.observer) {\n this.observer = new MutationObserver(this.extractModelFromLightDom);\n }\n this.observer.observe(this.host, { subtree: true, childList: true });\n this.extractModelFromLightDom();\n if ('orientation' in screen) {\n screen.orientation.addEventListener(\n 'change',\n this.handleOrientation\n );\n } else {\n window.addEventListener(\n 'orientationchange',\n this.handleOrientation\n );\n }\n }\n\n public hostDisconnected(): void {\n this.observer.disconnect();\n if ('orientation' in screen) {\n screen.orientation.removeEventListener(\n 'change',\n this.handleOrientation\n );\n } else {\n window.removeEventListener(\n 'orientationchange',\n this.handleOrientation\n );\n }\n }\n\n public hostUpdate(): void {\n this.updateModel();\n }\n\n // Since extractModelFromLightDom bails on the first un-upgraded handle,\n // a maximum of one listener will be set up per extraction attempt.\n private waitForUpgrade(handle: HTMLElement): boolean {\n if (handle instanceof SliderHandle) {\n return false;\n }\n handle.addEventListener(\n 'sp-slider-handle-ready',\n () => this.extractModelFromLightDom(),\n { once: true, passive: true }\n );\n return true;\n }\n\n private extractModelFromLightDom = (): void => {\n let handles = [\n ...this.host.querySelectorAll('[slot=\"handle\"]'),\n ] as SliderHandle[];\n if (handles.length === 0) {\n handles = [this.host as SliderHandle];\n }\n // extractModelFromLightDom depends on slotted handles already having been upgraded\n if (handles.some((h) => this.waitForUpgrade(h))) {\n return;\n }\n this.handles = new Map();\n this.handleOrder = [];\n handles.forEach((handle, index) => {\n /* c8 ignore next */\n if (!handle.handleName?.length) {\n handle.name = `handle${index + 1}`;\n }\n this.handles.set(handle.handleName, handle);\n this.handleOrder.push(handle.handleName);\n handle.handleController = this;\n });\n this.requestUpdate();\n };\n\n public get activeHandle(): string {\n return this.handleOrder[this.handleOrder.length - 1];\n }\n\n public get activeHandleInputId(): string {\n const active = this.activeHandle;\n const index = this.model.findIndex((model) => model.name === active);\n return `input-${index}`;\n }\n\n public activateHandle(name: string): void {\n const index = this.handleOrder.findIndex((item) => item === name);\n if (index >= 0) {\n this.handleOrder.splice(index, 1);\n }\n this.handleOrder.push(name);\n }\n\n private getActiveHandleElements(): HandleComponents {\n const name = this.activeHandle;\n const handleSlider = this.handles.get(name) as SliderHandle;\n const elements = this.getHandleElements(\n handleSlider\n ) as HandleReference;\n return { model: handleSlider, ...elements };\n }\n\n private getHandleElements(sliderHandle: SliderHandle): HandleReference {\n if (!this.handleRefMap) {\n this.handleRefMap = new WeakMap();\n\n const inputNodes =\n this.host.shadowRoot.querySelectorAll('.handle > input');\n for (const inputNode of inputNodes) {\n const input = inputNode as HTMLInputElement;\n const handle = input.parentElement as HTMLElement;\n const model = this.handles.get(\n handle.getAttribute('name') as string\n );\n if (model) {\n this.handleRefMap.set(model, { input, handle });\n }\n }\n }\n\n const components = this.handleRefMap.get(\n sliderHandle\n ) as HandleReference;\n return components;\n }\n\n private clearHandleComponentCache(): void {\n delete this.handleRefMap;\n }\n\n private _boundingClientRect?: DOMRect;\n\n private get boundingClientRect(): DOMRect {\n if (!this._boundingClientRect) {\n this._boundingClientRect = this.host.track.getBoundingClientRect();\n }\n return this._boundingClientRect;\n }\n\n private updateBoundingRect(): void {\n delete this._boundingClientRect;\n }\n\n /**\n * Return the `input` and `model` associated with the event and\n * whether the `input` is a `resolvedInput` meaning it was acquired\n * from the `model` rather than the event.\n */\n protected extractDataFromEvent(event: PointerEvent): DataFromPointerEvent {\n if (!this._activePointerEventData) {\n let input = (event.target as Element).querySelector(\n ':scope > .input'\n ) as InputWithModel;\n const resolvedInput = !input;\n const model = input\n ? input.model\n : this.model.find((item) => item.name === this.activeHandle);\n if (!input && !!model) {\n input = model.handle.focusElement as InputWithModel;\n }\n this._activePointerEventData = {\n input,\n model,\n resolvedInput,\n };\n }\n return this._activePointerEventData;\n }\n\n private _activePointerEventData!: DataFromPointerEvent | undefined;\n\n public handlePointerdown(event: PointerEvent): void {\n const { resolvedInput, model } = this.extractDataFromEvent(event);\n if (!model || this.host.disabled || event.button !== 0) {\n event.preventDefault();\n return;\n }\n this.host.track.setPointerCapture(event.pointerId);\n this.updateBoundingRect();\n this.host.labelEl.click();\n this.draggingHandle = model.handle;\n model.handle.dragging = true;\n this.activateHandle(model.name);\n if (resolvedInput) {\n // When the input is resolved forward the pointer event to\n // `handlePointermove` in order to update the value/UI becuase\n // the pointer event was on the track not a handle\n this.handlePointermove(event);\n }\n this.requestUpdate();\n }\n\n public handlePointerup(event: PointerEvent): void {\n const { input, model } = this.extractDataFromEvent(event);\n delete this._activePointerEventData;\n if (!model) return;\n this.host.labelEl.click();\n model.handle.highlight = false;\n delete this.draggingHandle;\n model.handle.dragging = false;\n this.requestUpdate();\n this.host.track.releasePointerCapture(event.pointerId);\n this.dispatchChangeEvent(input, model.handle);\n }\n\n public handlePointermove(event: PointerEvent): void {\n const { input, model } = this.extractDataFromEvent(event);\n if (!model) return;\n /* c8 ignore next 3 */\n if (!this.draggingHandle) {\n return;\n }\n event.stopPropagation();\n input.value = this.calculateHandlePosition(event, model).toString();\n model.handle.value = parseFloat(input.value);\n this.requestUpdate();\n }\n\n /**\n * Keep the slider value property in sync with the input element's value\n */\n private onInputChange = (event: Event): void => {\n const input = event.target as InputWithModel;\n input.model.handle.value = input.valueAsNumber;\n\n this.requestUpdate();\n this.dispatchChangeEvent(input, input.model.handle);\n };\n\n private onInputFocus = (event: Event): void => {\n const input = event.target as InputWithModel;\n let isFocusVisible;\n try {\n isFocusVisible =\n input.matches(':focus-visible') ||\n this.host.matches('.focus-visible');\n /* c8 ignore next 3 */\n } catch (error) {\n isFocusVisible = this.host.matches('.focus-visible');\n }\n input.model.handle.highlight = isFocusVisible;\n this.requestUpdate();\n };\n\n private onInputBlur = (event: Event): void => {\n const input = event.target as InputWithModel;\n input.model.handle.highlight = false;\n this.requestUpdate();\n };\n\n private onInputKeydown = (event: Event): void => {\n const input = event.target as InputWithModel;\n input.model.handle.highlight = true;\n this.requestUpdate();\n };\n\n private dispatchChangeEvent(\n input: HTMLInputElement,\n handle: SliderHandle\n ): void {\n input.valueAsNumber = handle.value;\n\n const changeEvent = new Event('change', {\n bubbles: true,\n composed: true,\n });\n\n handle.dispatchEvent(changeEvent);\n }\n\n /**\n * Returns the value under the cursor\n * @param: PointerEvent on slider\n * @return: Slider value that correlates to the position under the pointer\n */\n private calculateHandlePosition(\n event: PointerEvent | MouseEvent,\n model: ModelValue\n ): number {\n const rect = this.boundingClientRect;\n const minOffset = rect.left;\n const offset = event.clientX;\n const size = rect.width;\n\n const normalized = (offset - minOffset) / size;\n const value = model.normalization.fromNormalized(\n normalized,\n model.range.min,\n model.range.max\n );\n\n /* c8 ignore next */\n return this.host.isLTR ? value : model.range.max - value;\n }\n\n public renderHandle(\n model: ModelValue,\n index: number,\n zIndex: number,\n isMultiHandle: boolean\n ): TemplateResult {\n const classes = {\n handle: true,\n dragging: this.draggingHandle?.handleName === model.name,\n 'handle-highlight': model.highlight,\n };\n const style = {\n [this.host.isLTR ? 'left' : 'right']: `${\n model.normalizedValue * 100\n }%`,\n 'z-index': zIndex.toString(),\n // Allow setting background per-handle\n 'background-color': `var(--spectrum-slider-handle-background-color-${index}, var(--spectrum-slider-handle-default-background-color))`,\n 'border-color': `var(--spectrum-slider-handle-border-color-${index}, var(-spectrum-slider-handle-default-border-color))`,\n };\n const ariaLabelledBy = isMultiHandle ? `label input-${index}` : 'label';\n return html`\n <div\n class=${classMap(classes)}\n name=${model.name}\n style=${styleMap(style)}\n role=\"presentation\"\n >\n <input\n type=\"range\"\n class=\"input\"\n id=\"input-${index}\"\n min=${model.clamp.min}\n max=${model.clamp.max}\n step=${model.step}\n value=${model.value}\n aria-disabled=${ifDefined(\n this.host.disabled ? 'true' : undefined\n )}\n tabindex=${ifDefined(this.host.editable ? -1 : undefined)}\n aria-label=${ifDefined(model.ariaLabel)}\n aria-labelledby=${ariaLabelledBy}\n aria-valuetext=${this.formattedValueForHandle(model)}\n @change=${this.onInputChange}\n @focus=${this.onInputFocus}\n @blur=${this.onInputBlur}\n @keydown=${this.onInputKeydown}\n .model=${model}\n />\n </div>\n `;\n }\n\n public render(): TemplateResult[] {\n this.clearHandleComponentCache();\n return this.model.map((model, index) => {\n const zIndex = this.handleOrder.indexOf(model.name) + 1;\n return this.renderHandle(\n model,\n index,\n zIndex,\n this.model.length > 1\n );\n });\n }\n\n /**\n * Returns a list of track segment [start, end] tuples where the values are\n * normalized to be between 0 and 1.\n * @returns A list of track segment tuples [start, end]\n */\n public trackSegments(): [number, number][] {\n const values = this.model.map((model) => model.normalizedValue);\n values.sort((a, b) => a - b);\n\n // The first segment always starts at 0\n values.unshift(0);\n return values.map((value, index, array) => [\n value,\n array[index + 1] ?? 1,\n ]);\n }\n\n private updateModel(): void {\n const handles = [...this.handles.values()];\n\n const getRangeAndClamp = (index: number): RangeAndClamp => {\n const handle = handles[index];\n const previous = handles[index - 1];\n const next = handles[index + 1];\n\n const min =\n typeof handle.min === 'number'\n ? handle.min\n : (this.host.min as number);\n const max =\n typeof handle.max === 'number'\n ? handle.max\n : (this.host.max as number);\n\n const result: RangeAndClamp = {\n range: { min: min, max: max },\n clamp: { min: min, max: max },\n };\n\n if (handle.min === 'previous') {\n if (previous) {\n for (let j = index - 1; j >= 0; j--) {\n const item = handles[j];\n if (typeof item.min === 'number') {\n result.range.min = item.min;\n break;\n }\n }\n result.clamp.min = Math.max(\n previous.value,\n result.range.min\n );\n /* c8 ignore next 5 */\n } else {\n console.warn(\n 'First slider handle cannot have attribute min=\"previous\"'\n );\n }\n }\n if (handle.max === 'next') {\n if (next) {\n for (let j = index + 1; j < handles.length; j++) {\n const item = handles[j];\n if (typeof item.max === 'number') {\n result.range.max = item.max;\n break;\n }\n }\n result.clamp.max = Math.min(next.value, result.range.max);\n /* c8 ignore next 5 */\n } else {\n console.warn(\n 'Last slider handle cannot have attribute max=\"next\"'\n );\n }\n }\n return result;\n };\n\n const modelValues = handles.map((handle, index) => {\n const rangeAndClamp = getRangeAndClamp(index);\n const { toNormalized } = handle.normalization;\n const clampedValue = Math.max(\n Math.min(handle.value, rangeAndClamp.clamp.max),\n rangeAndClamp.clamp.min\n );\n const normalizedValue = toNormalized(\n clampedValue,\n rangeAndClamp.range.min,\n rangeAndClamp.range.max\n );\n const model = {\n name: handle.handleName,\n value: clampedValue,\n normalizedValue,\n highlight: handle.highlight,\n step: handle.step ?? this.host.step,\n normalization: handle.normalization,\n handle,\n ariaLabel:\n handle !== this.host && handle?.label.length > 0\n ? handle.label\n : undefined,\n ...rangeAndClamp,\n };\n return model;\n });\n\n this.model = modelValues;\n }\n\n public async handleUpdatesComplete(): Promise<void> {\n const updates = [...this.handles.values()]\n .filter((handle) => handle !== this.host)\n .map((handle) => handle.updateComplete);\n await Promise.all(updates);\n }\n}\n"]}
|
package/src/SliderHandle.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export declare class SliderHandle extends Focusable {
|
|
|
42
42
|
getAriaHandleText: (value: number, numberFormat: NumberFormatter) => string;
|
|
43
43
|
protected update(changes: PropertyValues): void;
|
|
44
44
|
protected updated(changedProperties: PropertyValues<this>): void;
|
|
45
|
+
protected firstUpdated(changedProperties: PropertyValues<this>): void;
|
|
45
46
|
normalization: SliderNormalization;
|
|
46
47
|
dispatchInputEvent(): void;
|
|
47
48
|
protected _numberFormatCache: {
|
package/src/SliderHandle.js
CHANGED
|
@@ -87,6 +87,10 @@ export class SliderHandle extends Focusable {
|
|
|
87
87
|
(_b = this.handleController) === null || _b === void 0 ? void 0 : _b.handleHasChanged(this);
|
|
88
88
|
super.updated(changedProperties);
|
|
89
89
|
}
|
|
90
|
+
firstUpdated(changedProperties) {
|
|
91
|
+
super.firstUpdated(changedProperties);
|
|
92
|
+
this.dispatchEvent(new CustomEvent('sp-slider-handle-ready'));
|
|
93
|
+
}
|
|
90
94
|
dispatchInputEvent() {
|
|
91
95
|
const inputEvent = new Event('input', {
|
|
92
96
|
bubbles: true,
|
package/src/SliderHandle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliderHandle.js","sourceRoot":"","sources":["SliderHandle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAGF,OAAO,EAAE,QAAQ,EAAE,MAAM,iDAAiD,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,kDAAkD,CAAC;AAE7E,OAAO,EAEH,eAAe,GAClB,MAAM,2BAA2B,CAAC;AAsBnC,MAAM,CAAC,MAAM,oBAAoB,GAAwB;IACrD,YAAY,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW;QAChD,OAAO,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;IACvC,CAAC;IACD,cAAc,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW;QAClD,OAAO,KAAK,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;IACrC,CAAC;CACJ,CAAC;AAEF,MAAM,YAAY,GAAG;IACjB,aAAa,EAAE,CAAC,KAAa,EAAuB,EAAE;QAClD,IAAI,KAAK,KAAK,UAAU;YAAE,OAAO,KAAK,CAAC;QACvC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IACD,WAAW,EAAE,CAAC,KAA0B,EAAU,EAAE;QAChD,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC5B,CAAC;CACJ,CAAC;AAEF,MAAM,YAAY,GAAG;IACjB,aAAa,EAAE,CAAC,KAAa,EAAmB,EAAE;QAC9C,IAAI,KAAK,KAAK,MAAM;YAAE,OAAO,KAAK,CAAC;QACnC,OAAO,UAAU,CAAC,KAAK,CAAC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,SAAS,EAAE,YAAY,EAAE,CAAC;yCACxB;AAG7B;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;sDAEyB;AAGxD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CACrB;AAGrB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;mDACb;AAG3C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CACT;AAGlB;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;uDAM7B;AAsBF;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;mDACkC","sourcesContent":["/*\nCopyright 2021 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { PropertyValues } from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport { ProvideLang } from '@spectrum-web-components/theme';\nimport {\n NumberFormatOptions,\n NumberFormatter,\n} from '@internationalized/number';\n\nexport type HandleMin = number | 'previous';\nexport type HandleMax = number | 'next';\n\nexport type HandleValues = {\n name: string;\n value: number;\n}[];\n\nexport interface Controller {\n inputForHandle(handle: SliderHandle): HTMLInputElement | undefined;\n requestUpdate(): void;\n setValueFromHandle(handle: SliderHandle): void;\n handleHasChanged(handle: SliderHandle): void;\n}\n\nexport type SliderNormalization = {\n toNormalized: (value: number, min: number, max: number) => number;\n fromNormalized: (value: number, min: number, max: number) => number;\n};\n\nexport const defaultNormalization: SliderNormalization = {\n toNormalized(value: number, min: number, max: number) {\n return (value - min) / (max - min);\n },\n fromNormalized(value: number, min: number, max: number) {\n return value * (max - min) + min;\n },\n};\n\nconst MinConverter = {\n fromAttribute: (value: string): number | 'previous' => {\n if (value === 'previous') return value;\n return parseFloat(value);\n },\n toAttribute: (value: 'previous' | number): string => {\n return value.toString();\n },\n};\n\nconst MaxConverter = {\n fromAttribute: (value: string): number | 'next' => {\n if (value === 'next') return value;\n return parseFloat(value);\n },\n toAttribute: (value: 'next' | number): string => {\n return value.toString();\n },\n};\n\n/**\n * @element sp-slider-handle\n *\n * @fires input - The value of the element has changed.\n * @fires change - An alteration to the value of the element has been committed by the user.\n */\nexport class SliderHandle extends Focusable {\n public handleController?: Controller;\n\n public get handleName(): string {\n return this.name;\n }\n\n public get focusElement(): HTMLElement {\n /* c8 ignore next */\n return this.handleController?.inputForHandle(this) ?? this;\n }\n\n _forcedUnit = '';\n\n @property({ type: Number })\n value = 10;\n\n @property({ type: Boolean, reflect: true })\n public dragging = false;\n\n @property({ type: Boolean })\n public highlight = false;\n\n @property({ type: String })\n public name = '';\n\n @property({ reflect: true, converter: MinConverter })\n public min?: number | 'previous';\n\n @property({ reflect: true, converter: MaxConverter })\n public max?: number | 'next';\n\n @property({ attribute: false })\n private resolvedLanguage =\n document.documentElement.lang || navigator.language;\n\n @property({ type: Number, reflect: true })\n public step?: number;\n\n @property({ type: Object, attribute: 'format-options' })\n public formatOptions?: NumberFormatOptions;\n\n @property({ type: String })\n public label = '';\n\n @property({ attribute: false })\n public getAriaHandleText: (\n value: number,\n numberFormat: NumberFormatter\n ) => string = (value, numberFormat) => {\n return numberFormat.format(value);\n };\n\n protected update(changes: PropertyValues): void {\n if (changes.has('formatOptions') || changes.has('resolvedLanguage')) {\n delete this._numberFormatCache;\n }\n super.update(changes);\n }\n\n protected updated(changedProperties: PropertyValues<this>): void {\n if (changedProperties.has('value')) {\n const oldValue = changedProperties.get('value');\n if (oldValue != null) {\n this.handleController /* c8 ignore next */\n ?.setValueFromHandle(this);\n }\n }\n this.handleController?.handleHasChanged(this);\n super.updated(changedProperties);\n }\n\n @property({ attribute: false })\n public normalization: SliderNormalization = defaultNormalization;\n\n public dispatchInputEvent(): void {\n const inputEvent = new Event('input', {\n bubbles: true,\n composed: true,\n });\n\n this.dispatchEvent(inputEvent);\n }\n\n protected _numberFormatCache:\n | { numberFormat: NumberFormatter; language: string }\n | undefined;\n protected getNumberFormat(): Intl.NumberFormat {\n /* c8 ignore next */\n if (\n !this._numberFormatCache ||\n this.resolvedLanguage !== this._numberFormatCache.language\n ) {\n let numberFormatter: NumberFormatter;\n try {\n numberFormatter = new NumberFormatter(\n this.resolvedLanguage,\n this.formatOptions\n );\n this._forcedUnit = '';\n // numberFormatter.format(1);\n } catch (error) {\n const {\n style,\n unit,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n unitDisplay,\n ...formatOptionsNoUnit\n } = this.formatOptions || {};\n if (style === 'unit') {\n this._forcedUnit = unit as string;\n }\n numberFormatter = new NumberFormatter(\n this.resolvedLanguage,\n formatOptionsNoUnit\n );\n }\n this._numberFormatCache = {\n language: this.resolvedLanguage,\n numberFormat: numberFormatter,\n };\n }\n /* c8 ignore next */\n return this._numberFormatCache?.numberFormat;\n }\n\n public get numberFormat(): NumberFormatter | undefined {\n if (!this.formatOptions) return;\n return this.getNumberFormat();\n }\n\n public connectedCallback(): void {\n super.connectedCallback();\n this.resolveLanguage();\n }\n\n public disconnectedCallback(): void {\n this.resolveLanguage();\n super.disconnectedCallback();\n }\n\n private resolveLanguage(): void {\n const queryThemeEvent = new CustomEvent<ProvideLang>(\n 'sp-language-context',\n {\n bubbles: true,\n composed: true,\n detail: {\n callback: (lang: string) => {\n this.resolvedLanguage = lang;\n },\n },\n cancelable: true,\n }\n );\n this.dispatchEvent(queryThemeEvent);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SliderH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AE,SAAS,EAAE,KAAK,EAAE,CAAC;sDAEyB;AAGxD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CACrB;AAGrB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;mDACb;AAG3C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CACT;AAGlB;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;uDAM7B;AA2BF;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;mDACkC","sourcesContent":["/*\nCopyright 2021 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { PropertyValues } from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport { ProvideLang } from '@spectrum-web-components/theme';\nimport {\n NumberFormatOptions,\n NumberFormatter,\n} from '@internationalized/number';\n\nexport type HandleMin = number | 'previous';\nexport type HandleMax = number | 'next';\n\nexport type HandleValues = {\n name: string;\n value: number;\n}[];\n\nexport interface Controller {\n inputForHandle(handle: SliderHandle): HTMLInputElement | undefined;\n requestUpdate(): void;\n setValueFromHandle(handle: SliderHandle): void;\n handleHasChanged(handle: SliderHandle): void;\n}\n\nexport type SliderNormalization = {\n toNormalized: (value: number, min: number, max: number) => number;\n fromNormalized: (value: number, min: number, max: number) => number;\n};\n\nexport const defaultNormalization: SliderNormalization = {\n toNormalized(value: number, min: number, max: number) {\n return (value - min) / (max - min);\n },\n fromNormalized(value: number, min: number, max: number) {\n return value * (max - min) + min;\n },\n};\n\nconst MinConverter = {\n fromAttribute: (value: string): number | 'previous' => {\n if (value === 'previous') return value;\n return parseFloat(value);\n },\n toAttribute: (value: 'previous' | number): string => {\n return value.toString();\n },\n};\n\nconst MaxConverter = {\n fromAttribute: (value: string): number | 'next' => {\n if (value === 'next') return value;\n return parseFloat(value);\n },\n toAttribute: (value: 'next' | number): string => {\n return value.toString();\n },\n};\n\n/**\n * @element sp-slider-handle\n *\n * @fires input - The value of the element has changed.\n * @fires change - An alteration to the value of the element has been committed by the user.\n */\nexport class SliderHandle extends Focusable {\n public handleController?: Controller;\n\n public get handleName(): string {\n return this.name;\n }\n\n public get focusElement(): HTMLElement {\n /* c8 ignore next */\n return this.handleController?.inputForHandle(this) ?? this;\n }\n\n _forcedUnit = '';\n\n @property({ type: Number })\n value = 10;\n\n @property({ type: Boolean, reflect: true })\n public dragging = false;\n\n @property({ type: Boolean })\n public highlight = false;\n\n @property({ type: String })\n public name = '';\n\n @property({ reflect: true, converter: MinConverter })\n public min?: number | 'previous';\n\n @property({ reflect: true, converter: MaxConverter })\n public max?: number | 'next';\n\n @property({ attribute: false })\n private resolvedLanguage =\n document.documentElement.lang || navigator.language;\n\n @property({ type: Number, reflect: true })\n public step?: number;\n\n @property({ type: Object, attribute: 'format-options' })\n public formatOptions?: NumberFormatOptions;\n\n @property({ type: String })\n public label = '';\n\n @property({ attribute: false })\n public getAriaHandleText: (\n value: number,\n numberFormat: NumberFormatter\n ) => string = (value, numberFormat) => {\n return numberFormat.format(value);\n };\n\n protected update(changes: PropertyValues): void {\n if (changes.has('formatOptions') || changes.has('resolvedLanguage')) {\n delete this._numberFormatCache;\n }\n super.update(changes);\n }\n\n protected updated(changedProperties: PropertyValues<this>): void {\n if (changedProperties.has('value')) {\n const oldValue = changedProperties.get('value');\n if (oldValue != null) {\n this.handleController /* c8 ignore next */\n ?.setValueFromHandle(this);\n }\n }\n this.handleController?.handleHasChanged(this);\n super.updated(changedProperties);\n }\n\n protected firstUpdated(changedProperties: PropertyValues<this>): void {\n super.firstUpdated(changedProperties);\n this.dispatchEvent(new CustomEvent('sp-slider-handle-ready'));\n }\n\n @property({ attribute: false })\n public normalization: SliderNormalization = defaultNormalization;\n\n public dispatchInputEvent(): void {\n const inputEvent = new Event('input', {\n bubbles: true,\n composed: true,\n });\n\n this.dispatchEvent(inputEvent);\n }\n\n protected _numberFormatCache:\n | { numberFormat: NumberFormatter; language: string }\n | undefined;\n protected getNumberFormat(): Intl.NumberFormat {\n /* c8 ignore next */\n if (\n !this._numberFormatCache ||\n this.resolvedLanguage !== this._numberFormatCache.language\n ) {\n let numberFormatter: NumberFormatter;\n try {\n numberFormatter = new NumberFormatter(\n this.resolvedLanguage,\n this.formatOptions\n );\n this._forcedUnit = '';\n // numberFormatter.format(1);\n } catch (error) {\n const {\n style,\n unit,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n unitDisplay,\n ...formatOptionsNoUnit\n } = this.formatOptions || {};\n if (style === 'unit') {\n this._forcedUnit = unit as string;\n }\n numberFormatter = new NumberFormatter(\n this.resolvedLanguage,\n formatOptionsNoUnit\n );\n }\n this._numberFormatCache = {\n language: this.resolvedLanguage,\n numberFormat: numberFormatter,\n };\n }\n /* c8 ignore next */\n return this._numberFormatCache?.numberFormat;\n }\n\n public get numberFormat(): NumberFormatter | undefined {\n if (!this.formatOptions) return;\n return this.getNumberFormat();\n }\n\n public connectedCallback(): void {\n super.connectedCallback();\n this.resolveLanguage();\n }\n\n public disconnectedCallback(): void {\n this.resolveLanguage();\n super.disconnectedCallback();\n }\n\n private resolveLanguage(): void {\n const queryThemeEvent = new CustomEvent<ProvideLang>(\n 'sp-language-context',\n {\n bubbles: true,\n composed: true,\n detail: {\n callback: (lang: string) => {\n this.resolvedLanguage = lang;\n },\n },\n cancelable: true,\n }\n );\n this.dispatchEvent(queryThemeEvent);\n }\n}\n"]}
|