@spectrum-web-components/slider 0.14.2 → 0.14.3

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.
@@ -1190,15 +1190,6 @@
1190
1190
  "module": "src/SliderHandle.js"
1191
1191
  }
1192
1192
  },
1193
- {
1194
- "kind": "field",
1195
- "name": "resolvedLanguage",
1196
- "privacy": "private",
1197
- "inheritedFrom": {
1198
- "name": "SliderHandle",
1199
- "module": "src/SliderHandle.js"
1200
- }
1201
- },
1202
1193
  {
1203
1194
  "kind": "field",
1204
1195
  "name": "formatOptions",
@@ -1238,6 +1229,16 @@
1238
1229
  "module": "src/SliderHandle.js"
1239
1230
  }
1240
1231
  },
1232
+ {
1233
+ "kind": "field",
1234
+ "name": "languageResolver",
1235
+ "privacy": "private",
1236
+ "default": "new LanguageResolutionController(this)",
1237
+ "inheritedFrom": {
1238
+ "name": "SliderHandle",
1239
+ "module": "src/SliderHandle.js"
1240
+ }
1241
+ },
1241
1242
  {
1242
1243
  "kind": "field",
1243
1244
  "name": "normalization",
@@ -1290,20 +1291,6 @@
1290
1291
  "name": "SliderHandle",
1291
1292
  "module": "src/SliderHandle.js"
1292
1293
  }
1293
- },
1294
- {
1295
- "kind": "method",
1296
- "name": "resolveLanguage",
1297
- "privacy": "private",
1298
- "return": {
1299
- "type": {
1300
- "text": "void"
1301
- }
1302
- },
1303
- "inheritedFrom": {
1304
- "name": "SliderHandle",
1305
- "module": "src/SliderHandle.js"
1306
- }
1307
1294
  }
1308
1295
  ],
1309
1296
  "attributes": [
@@ -1666,11 +1653,6 @@
1666
1653
  "attribute": "max",
1667
1654
  "reflects": true
1668
1655
  },
1669
- {
1670
- "kind": "field",
1671
- "name": "resolvedLanguage",
1672
- "privacy": "private"
1673
- },
1674
1656
  {
1675
1657
  "kind": "field",
1676
1658
  "name": "step",
@@ -1708,6 +1690,12 @@
1708
1690
  },
1709
1691
  "privacy": "public"
1710
1692
  },
1693
+ {
1694
+ "kind": "field",
1695
+ "name": "languageResolver",
1696
+ "privacy": "private",
1697
+ "default": "new LanguageResolutionController(this)"
1698
+ },
1711
1699
  {
1712
1700
  "kind": "field",
1713
1701
  "name": "normalization",
@@ -1752,16 +1740,6 @@
1752
1740
  "text": "NumberFormatter | undefined"
1753
1741
  },
1754
1742
  "privacy": "public"
1755
- },
1756
- {
1757
- "kind": "method",
1758
- "name": "resolveLanguage",
1759
- "privacy": "private",
1760
- "return": {
1761
- "type": {
1762
- "text": "void"
1763
- }
1764
- }
1765
1743
  }
1766
1744
  ],
1767
1745
  "events": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/slider",
3
- "version": "0.14.2",
3
+ "version": "0.14.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -76,10 +76,10 @@
76
76
  "@internationalized/number": "^3.1.0",
77
77
  "@lit-labs/observers": "^1.0.1",
78
78
  "@spectrum-web-components/base": "^0.7.0",
79
- "@spectrum-web-components/field-label": "^0.8.0",
80
- "@spectrum-web-components/number-field": "^0.5.2",
79
+ "@spectrum-web-components/field-label": "^0.9.0",
80
+ "@spectrum-web-components/number-field": "^0.5.3",
81
81
  "@spectrum-web-components/shared": "^0.15.0",
82
- "@spectrum-web-components/theme": "^0.14.2",
82
+ "@spectrum-web-components/theme": "^0.14.3",
83
83
  "tslib": "^2.0.0"
84
84
  },
85
85
  "devDependencies": {
@@ -92,5 +92,5 @@
92
92
  "./**/*.dev.js",
93
93
  "./sync/sp-*.js"
94
94
  ],
95
- "gitHead": "60b2d3b7d9020d72f9ae930568670321a1918e6f"
95
+ "gitHead": "15588c72c774b17cfac605b20ac52a27d123bd03"
96
96
  }
@@ -262,7 +262,9 @@ export class HandleController {
262
262
  }
263
263
  this.host.track.setPointerCapture(event.pointerId);
264
264
  this.updateBoundingRect();
265
- this.host.labelEl.click();
265
+ if (event.pointerType === "mouse") {
266
+ this.host.labelEl.click();
267
+ }
266
268
  this.draggingHandle = model.handle;
267
269
  model.handle.dragging = true;
268
270
  this.activateHandle(model.name);
@@ -276,7 +278,9 @@ export class HandleController {
276
278
  delete this._activePointerEventData;
277
279
  if (!model)
278
280
  return;
279
- this.host.labelEl.click();
281
+ if (event.pointerType === "mouse") {
282
+ this.host.labelEl.click();
283
+ }
280
284
  this.cancelDrag(model);
281
285
  this.requestUpdate();
282
286
  this.host.track.releasePointerCapture(event.pointerId);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["HandleController.ts"],
4
- "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 { MutationController } from '@lit-labs/observers/mutation_controller.js';\nimport { Slider } from './Slider.dev.js'\nimport {\n Controller,\n SliderHandle,\n SliderNormalization,\n} from './SliderHandle.dev.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 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 new MutationController(this.host, {\n config: {\n subtree: true,\n childList: true,\n },\n callback: () => {\n this.extractModelFromLightDom();\n },\n });\n\n this.extractModelFromLightDom();\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 if (this.host.hasUpdated) {\n this.host.requestUpdate();\n }\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 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 ('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 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 this.cancelDrag(model);\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.host.indeterminate = false;\n this.requestUpdate();\n }\n\n public cancelDrag(model?: ModelValue): void {\n model =\n model || this.model.find((item) => item.name === this.activeHandle);\n if (!model) return;\n model.handle.highlight = false;\n delete this.draggingHandle;\n model.handle.dragging = false;\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 directionalOffset = this.host.isLTR\n ? offset - minOffset\n : size - (offset - minOffset);\n const normalized = directionalOffset / size;\n\n return model.normalization.fromNormalized(\n normalized,\n model.range.min,\n model.range.max\n );\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 }\n if (window.__swc.DEBUG) {\n if (!previous) {\n window.__swc.warn(\n this.host,\n '<sp-slider-handle> elements that are the first child of an <sp-slider> element cannot have attribute \"min=\\'previous\\'\"`',\n 'https://opensource.adobe.com/spectrum-web-components/components/slider-handle/#multi-handle-slider-with-ordered-handles'\n );\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 }\n if (window.__swc.DEBUG) {\n if (!next) {\n window.__swc.warn(\n this.host,\n '<sp-slider-handle> elements that are the last child of an <sp-slider> element cannot have attribute \"max=\\'next\\'\"',\n 'https://opensource.adobe.com/spectrum-web-components/components/slider-handle/#multi-handle-slider-with-ordered-handles'\n );\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"],
5
- "mappings": ";AAWA,SAAS,YAA4B;AACrC;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,SAAS,0BAA0B;AAEnC;AAAA,EAEI;AAAA,OAEG;AAwCA,aAAM,iBAAuC;AAAA,EAQhD,YAAY,MAAc;AAN1B,SAAQ,UAAqC,oBAAI,IAAI;AACrD,SAAQ,QAAsB,CAAC;AAC/B,SAAQ,cAAwB,CAAC;AAsGjC,SAAU,oBAAoB,MAAY;AACtC,WAAK,mBAAmB;AAAA,IAC5B;AAgDA,SAAQ,2BAA2B,MAAY;AAC3C,UAAI,UAAU;AAAA,QACV,GAAG,KAAK,KAAK,iBAAiB,iBAAiB;AAAA,MACnD;AACA,UAAI,QA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B;AACpB,cAAI,CAAC,MAAM;AACP,mBAAO,MAAM;AAAA,cACT,KAAK;AAAA,cACL;AAAA,cACA;AAAA,YACJ;AAAA,UACJ;AAAA,QACJ;AAAA,MACJ;AACA,aAAO;AAAA,IACX;AAEA,UAAM,cAAc,QAAQ,IAAI,CAAC,QAAQ,UAAU;AAlnB3D;AAmnBY,YAAM,gBAAgB,iBAAiB,KAAK;AAC5C,YAAM,EAAE,aAAa,IAAI,OAAO;AAChC,YAAM,eAAe,KAAK;AAAA,QACtB,KAAK,IAAI,OAAO,OAAO,cAAc,MAAM,GAAG;AAAA,QAC9C,cAAc,MAAM;AAAA,MACxB;AACA,YAAM,kBAAkB;AAAA,QACpB;AAAA,QACA,cAAc,MAAM;AAAA,QACpB,cAAc,MAAM;AAAA,MACxB;AACA,YAAM,QAAQ;AAAA,QACV,MAAM,OAAO;AAAA,QACb,OAAO;AAAA,QACP;AAAA,QACA,WAAW,OAAO;AAAA,QAClB,OAAM,YAAO,SAAP,YAAe,KAAK,KAAK;AAAA,QAC/B,eAAe,OAAO;AAAA,QACtB;AAAA,QACA,WACI,WAAW,KAAK,SAAQ,iCAAQ,MAAM,UAAS,IACzC,OAAO,QACP;AAAA,QACV,GAAG;AAAA,MACP;AACA,aAAO;AAAA,IACX,CAAC;AAED,SAAK,QAAQ;AAAA,EACjB;AAAA,EAEA,MAAa,wBAAuC;AAChD,UAAM,UAAU,CAAC,GAAG,KAAK,QAAQ,OAAO,CAAC,EACpC,OAAO,CAAC,WAAW,WAAW,KAAK,IAAI,EACvC,IAAI,CAAC,WAAW,OAAO,cAAc;AAC1C,UAAM,QAAQ,IAAI,OAAO;AAAA,EAC7B;AACJ;",
4
+ "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 { MutationController } from '@lit-labs/observers/mutation_controller.js';\nimport { Slider } from './Slider.dev.js'\nimport {\n Controller,\n SliderHandle,\n SliderNormalization,\n} from './SliderHandle.dev.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 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 new MutationController(this.host, {\n config: {\n subtree: true,\n childList: true,\n },\n callback: () => {\n this.extractModelFromLightDom();\n },\n });\n\n this.extractModelFromLightDom();\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 if (this.host.hasUpdated) {\n this.host.requestUpdate();\n }\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 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 ('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 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 if (event.pointerType === 'mouse') {\n this.host.labelEl.click();\n }\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 if (event.pointerType === 'mouse') {\n this.host.labelEl.click();\n }\n this.cancelDrag(model);\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.host.indeterminate = false;\n this.requestUpdate();\n }\n\n public cancelDrag(model?: ModelValue): void {\n model =\n model || this.model.find((item) => item.name === this.activeHandle);\n if (!model) return;\n model.handle.highlight = false;\n delete this.draggingHandle;\n model.handle.dragging = false;\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 directionalOffset = this.host.isLTR\n ? offset - minOffset\n : size - (offset - minOffset);\n const normalized = directionalOffset / size;\n\n return model.normalization.fromNormalized(\n normalized,\n model.range.min,\n model.range.max\n );\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 }\n if (window.__swc.DEBUG) {\n if (!previous) {\n window.__swc.warn(\n this.host,\n '<sp-slider-handle> elements that are the first child of an <sp-slider> element cannot have attribute \"min=\\'previous\\'\"`',\n 'https://opensource.adobe.com/spectrum-web-components/components/slider-handle/#multi-handle-slider-with-ordered-handles'\n );\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 }\n if (window.__swc.DEBUG) {\n if (!next) {\n window.__swc.warn(\n this.host,\n '<sp-slider-handle> elements that are the last child of an <sp-slider> element cannot have attribute \"max=\\'next\\'\"',\n 'https://opensource.adobe.com/spectrum-web-components/components/slider-handle/#multi-handle-slider-with-ordered-handles'\n );\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"],
5
+ "mappings": ";AAWA,SAAS,YAA4B;AACrC;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,SAAS,0BAA0B;AAEnC;AAAA,EAEI;AAAA,OAEG;AAwCA,aAAM,iBAAuC;AAAA,EAQhD,YAAY,MAAc;AAN1B,SAAQ,UAAqC,oBAAI,IAAI;AACrD,SAAQ,QAAsB,CAAC;AAC/B,SAAQ,cAAwB,CAAC;AAsGjC,SAAU,oBAAoB,MAAY;AACtC,WAAK,mBAAmB;AAAA,IAC5B;AAgDA,SAAQ,2BAA2B,MAAY;AAC3C,UAAI,UAAU;AAAA,QACV,GAAG,KAAK,KAAK,iBAAiB,iBAAiB;AAAA,MACnD;AACA,UAAI,QAAQ,WAAW,GAAG;AACtB,kBAAU,CAAC,KAAK,IAAoB;AAAA,MACxC;AAEA,UAAI,QAAQ,KAAK,CAAC,MAAM,KAAK,eAAe,CAAC,CAAC,GAAG;AAC7C;AAAA,MACJ;AACA,WAAK,UAAU,oBAAI,IAAI;AACvB,WAAK,cAAc,CAAC;AACpB,cAAQ,QAAQ,CAAC,QAAQ,UAAU;AAxO3C;AA0OY,YAAI,GAAC,YAAO,eAAP,mBAAmB,SAAQ;AAC5B,iBAAO,OAAO,SAAS,QAAQ;AAAA,QACnC;AACA,aAAK,QAAQ,IAAI,OAAO,YAAY,MAAM;AAC1C,aAAK,YAAY,KAAK,OAAO,UAAU;AACvC,eAAO,mBAAmB;AAAA,MAC9B,CAAC;AACD,W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AAc,MAAM;AAAA,MACxB;AACA,YAAM,kBAAkB;AAAA,QACpB;AAAA,QACA,cAAc,MAAM;AAAA,QACpB,cAAc,MAAM;AAAA,MACxB;AACA,YAAM,QAAQ;AAAA,QACV,MAAM,OAAO;AAAA,QACb,OAAO;AAAA,QACP;AAAA,QACA,WAAW,OAAO;AAAA,QAClB,OAAM,YAAO,SAAP,YAAe,KAAK,KAAK;AAAA,QAC/B,eAAe,OAAO;AAAA,QACtB;AAAA,QACA,WACI,WAAW,KAAK,SAAQ,iCAAQ,MAAM,UAAS,IACzC,OAAO,QACP;AAAA,QACV,GAAG;AAAA,MACP;AACA,aAAO;AAAA,IACX,CAAC;AAED,SAAK,QAAQ;AAAA,EACjB;AAAA,EAEA,MAAa,wBAAuC;AAChD,UAAM,UAAU,CAAC,GAAG,KAAK,QAAQ,OAAO,CAAC,EACpC,OAAO,CAAC,WAAW,WAAW,KAAK,IAAI,EACvC,IAAI,CAAC,WAAW,OAAO,cAAc;AAC1C,UAAM,QAAQ,IAAI,OAAO;AAAA,EAC7B;AACJ;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- "use strict";import{html as m}from"@spectrum-web-components/base";import{classMap as p,ifDefined as c,styleMap as g}from"@spectrum-web-components/base/src/directives.js";import{MutationController as v}from"@lit-labs/observers/mutation_controller.js";import{SliderHandle as f}from"./SliderHandle.js";export class HandleController{constructor(e){this.handles=new Map;this.model=[];this.handleOrder=[];this.handleOrientation=()=>{this.updateBoundingRect()};this.extractModelFromLightDom=()=>{let e=[...this.host.querySelectorAll('[slot="handle"]')];e.length===0&&(e=[this.host]),!e.some(t=>this.waitForUpgrade(t))&&(this.handles=new Map,this.handleOrder=[],e.forEach((t,n)=>{var a;(a=t.handleName)!=null&&a.length||(t.name=`handle${n+1}`),this.handles.set(t.handleName,t),this.handleOrder.push(t.handleName),t.handleController=this}),this.requestUpdate())};this.onInputChange=e=>{const t=e.target;t.model.handle.value=t.valueAsNumber,this.requestUpdate(),this.dispatchChangeEvent(t,t.model.handle)};this.onInputFocus=e=>{const t=e.target;let n;try{n=t.matches(":focus-visible")||this.host.matches(".focus-visible")}catch(a){n=this.host.matches(".focus-visible")}t.model.handle.highlight=n,this.requestUpdate()};this.onInputBlur=e=>{const t=e.target;t.model.handle.highlight=!1,this.requestUpdate()};this.onInputKeydown=e=>{const t=e.target;t.model.handle.highlight=!0,this.requestUpdate()};this.host=e,new v(this.host,{config:{subtree:!0,childList:!0},callback:()=>{this.extractModelFromLightDom()}}),this.extractModelFromLightDom()}get values(){const e={};for(const t of this.handles.values())e[t.handleName]=t.value;return e}get size(){return this.handles.size}inputForHandle(e){if(this.handles.has(e.handleName)){const{input:t}=this.getHandleElements(e);return t}throw new Error(`No input for handle "${e.name}"`)}requestUpdate(){this.host.hasUpdated&&this.host.requestUpdate()}setValueFromHandle(e){const t=this.getHandleElements(e);if(!t)return;const{input:n}=t;n.valueAsNumber===e.value?e.dragging&&e.dispatchInputEvent():(n.valueAsNumber=e.value,this.requestUpdate()),e.value=n.valueAsNumber}handleHasChanged(e){e!==this.host&&this.requestUpdate()}formattedValueForHandle(e){var a;const{handle:t}=e,n=(a=t.numberFormat)!=null?a:this.host.numberFormat;return t.getAriaHandleText(e.value,n)}get formattedValues(){const e=new Map;for(const t of this.model)e.set(t.name,this.formattedValueForHandle(t));return e}get focusElement(){const{input:e}=this.getActiveHandleElements();return this.host.editable&&!e.model.handle.dragging?this.host.numberField:e}hostConnected(){"orientation"in screen?screen.orientation.addEventListener("change",this.handleOrientation):window.addEventListener("orientationchange",this.handleOrientation)}hostDisconnected(){"orientation"in screen?screen.orientation.removeEventListener("change",this.handleOrientation):window.removeEventListener("orientationchange",this.handleOrientation)}hostUpdate(){this.updateModel()}waitForUpgrade(e){return e instanceof f?!1:(e.addEventListener("sp-slider-handle-ready",()=>this.extractModelFromLightDom(),{once:!0,passive:!0}),!0)}get activeHandle(){return this.handleOrder[this.handleOrder.length-1]}get activeHandleInputId(){const e=this.activeHandle;return`input-${this.model.findIndex(n=>n.name===e)}`}activateHandle(e){const t=this.handleOrder.findIndex(n=>n===e);t>=0&&this.handleOrder.splice(t,1),this.handleOrder.push(e)}getActiveHandleElements(){const e=this.activeHandle,t=this.handles.get(e),n=this.getHandleElements(t);return{model:t,...n}}getHandleElements(e){if(!this.handleRefMap){this.handleRefMap=new WeakMap;const n=this.host.shadowRoot.querySelectorAll(".handle > input");for(const a of n){const i=a,r=i.parentElement,l=this.handles.get(r.getAttribute("name"));l&&this.handleRefMap.set(l,{input:i,handle:r})}}return this.handleRefMap.get(e)}clearHandleComponentCache(){delete this.handleRefMap}get boundingClientRect(){return this._boundingClientRect||(this._boundingClientRect=this.host.track.getBoundingClientRect()),this._boundingClientRect}updateBoundingRect(){delete this._boundingClientRect}extractDataFromEvent(e){if(!this._activePointerEventData){let t=e.target.querySelector(":scope > .input");const n=!t,a=t?t.model:this.model.find(i=>i.name===this.activeHandle);!t&&!!a&&(t=a.handle.focusElement),this._activePointerEventData={input:t,model:a,resolvedInput:n}}return this._activePointerEventData}handlePointerdown(e){const{resolvedInput:t,model:n}=this.extractDataFromEvent(e);if(!n||this.host.disabled||e.button!==0){e.preventDefault();return}this.host.track.setPointerCapture(e.pointerId),this.updateBoundingRect(),this.host.labelEl.click(),this.draggingHandle=n.handle,n.handle.dragging=!0,this.activateHandle(n.name),t&&this.handlePointermove(e),this.requestUpdate()}handlePointerup(e){const{input:t,model:n}=this.extractDataFromEvent(e);delete this._activePointerEventData,n&&(this.host.labelEl.click(),this.cancelDrag(n),this.requestUpdate(),this.host.track.releasePointerCapture(e.pointerId),this.dispatchChangeEvent(t,n.handle))}handlePointermove(e){const{input:t,model:n}=this.extractDataFromEvent(e);!n||!this.draggingHandle||(e.stopPropagation(),t.value=this.calculateHandlePosition(e,n).toString(),n.handle.value=parseFloat(t.value),this.host.indeterminate=!1,this.requestUpdate())}cancelDrag(e){e=e||this.model.find(t=>t.name===this.activeHandle),e&&(e.handle.highlight=!1,delete this.draggingHandle,e.handle.dragging=!1)}dispatchChangeEvent(e,t){e.valueAsNumber=t.value;const n=new Event("change",{bubbles:!0,composed:!0});t.dispatchEvent(n)}calculateHandlePosition(e,t){const n=this.boundingClientRect,a=n.left,i=e.clientX,r=n.width,s=(this.host.isLTR?i-a:r-(i-a))/r;return t.normalization.fromNormalized(s,t.range.min,t.range.max)}renderHandle(e,t,n,a){var s;const i={handle:!0,dragging:((s=this.draggingHandle)==null?void 0:s.handleName)===e.name,"handle-highlight":e.highlight},r={[this.host.isLTR?"left":"right"]:`${e.normalizedValue*100}%`,"z-index":n.toString(),"background-color":`var(--spectrum-slider-handle-background-color-${t}, var(--spectrum-slider-handle-default-background-color))`,"border-color":`var(--spectrum-slider-handle-border-color-${t}, var(-spectrum-slider-handle-default-border-color))`},l=a?`label input-${t}`:"label";return m`
1
+ "use strict";import{html as m}from"@spectrum-web-components/base";import{classMap as p,ifDefined as c,styleMap as g}from"@spectrum-web-components/base/src/directives.js";import{MutationController as v}from"@lit-labs/observers/mutation_controller.js";import{SliderHandle as f}from"./SliderHandle.js";export class HandleController{constructor(e){this.handles=new Map;this.model=[];this.handleOrder=[];this.handleOrientation=()=>{this.updateBoundingRect()};this.extractModelFromLightDom=()=>{let e=[...this.host.querySelectorAll('[slot="handle"]')];e.length===0&&(e=[this.host]),!e.some(t=>this.waitForUpgrade(t))&&(this.handles=new Map,this.handleOrder=[],e.forEach((t,n)=>{var a;(a=t.handleName)!=null&&a.length||(t.name=`handle${n+1}`),this.handles.set(t.handleName,t),this.handleOrder.push(t.handleName),t.handleController=this}),this.requestUpdate())};this.onInputChange=e=>{const t=e.target;t.model.handle.value=t.valueAsNumber,this.requestUpdate(),this.dispatchChangeEvent(t,t.model.handle)};this.onInputFocus=e=>{const t=e.target;let n;try{n=t.matches(":focus-visible")||this.host.matches(".focus-visible")}catch(a){n=this.host.matches(".focus-visible")}t.model.handle.highlight=n,this.requestUpdate()};this.onInputBlur=e=>{const t=e.target;t.model.handle.highlight=!1,this.requestUpdate()};this.onInputKeydown=e=>{const t=e.target;t.model.handle.highlight=!0,this.requestUpdate()};this.host=e,new v(this.host,{config:{subtree:!0,childList:!0},callback:()=>{this.extractModelFromLightDom()}}),this.extractModelFromLightDom()}get values(){const e={};for(const t of this.handles.values())e[t.handleName]=t.value;return e}get size(){return this.handles.size}inputForHandle(e){if(this.handles.has(e.handleName)){const{input:t}=this.getHandleElements(e);return t}throw new Error(`No input for handle "${e.name}"`)}requestUpdate(){this.host.hasUpdated&&this.host.requestUpdate()}setValueFromHandle(e){const t=this.getHandleElements(e);if(!t)return;const{input:n}=t;n.valueAsNumber===e.value?e.dragging&&e.dispatchInputEvent():(n.valueAsNumber=e.value,this.requestUpdate()),e.value=n.valueAsNumber}handleHasChanged(e){e!==this.host&&this.requestUpdate()}formattedValueForHandle(e){var a;const{handle:t}=e,n=(a=t.numberFormat)!=null?a:this.host.numberFormat;return t.getAriaHandleText(e.value,n)}get formattedValues(){const e=new Map;for(const t of this.model)e.set(t.name,this.formattedValueForHandle(t));return e}get focusElement(){const{input:e}=this.getActiveHandleElements();return this.host.editable&&!e.model.handle.dragging?this.host.numberField:e}hostConnected(){"orientation"in screen?screen.orientation.addEventListener("change",this.handleOrientation):window.addEventListener("orientationchange",this.handleOrientation)}hostDisconnected(){"orientation"in screen?screen.orientation.removeEventListener("change",this.handleOrientation):window.removeEventListener("orientationchange",this.handleOrientation)}hostUpdate(){this.updateModel()}waitForUpgrade(e){return e instanceof f?!1:(e.addEventListener("sp-slider-handle-ready",()=>this.extractModelFromLightDom(),{once:!0,passive:!0}),!0)}get activeHandle(){return this.handleOrder[this.handleOrder.length-1]}get activeHandleInputId(){const e=this.activeHandle;return`input-${this.model.findIndex(n=>n.name===e)}`}activateHandle(e){const t=this.handleOrder.findIndex(n=>n===e);t>=0&&this.handleOrder.splice(t,1),this.handleOrder.push(e)}getActiveHandleElements(){const e=this.activeHandle,t=this.handles.get(e),n=this.getHandleElements(t);return{model:t,...n}}getHandleElements(e){if(!this.handleRefMap){this.handleRefMap=new WeakMap;const n=this.host.shadowRoot.querySelectorAll(".handle > input");for(const a of n){const i=a,r=i.parentElement,l=this.handles.get(r.getAttribute("name"));l&&this.handleRefMap.set(l,{input:i,handle:r})}}return this.handleRefMap.get(e)}clearHandleComponentCache(){delete this.handleRefMap}get boundingClientRect(){return this._boundingClientRect||(this._boundingClientRect=this.host.track.getBoundingClientRect()),this._boundingClientRect}updateBoundingRect(){delete this._boundingClientRect}extractDataFromEvent(e){if(!this._activePointerEventData){let t=e.target.querySelector(":scope > .input");const n=!t,a=t?t.model:this.model.find(i=>i.name===this.activeHandle);!t&&!!a&&(t=a.handle.focusElement),this._activePointerEventData={input:t,model:a,resolvedInput:n}}return this._activePointerEventData}handlePointerdown(e){const{resolvedInput:t,model:n}=this.extractDataFromEvent(e);if(!n||this.host.disabled||e.button!==0){e.preventDefault();return}this.host.track.setPointerCapture(e.pointerId),this.updateBoundingRect(),e.pointerType==="mouse"&&this.host.labelEl.click(),this.draggingHandle=n.handle,n.handle.dragging=!0,this.activateHandle(n.name),t&&this.handlePointermove(e),this.requestUpdate()}handlePointerup(e){const{input:t,model:n}=this.extractDataFromEvent(e);delete this._activePointerEventData,n&&(e.pointerType==="mouse"&&this.host.labelEl.click(),this.cancelDrag(n),this.requestUpdate(),this.host.track.releasePointerCapture(e.pointerId),this.dispatchChangeEvent(t,n.handle))}handlePointermove(e){const{input:t,model:n}=this.extractDataFromEvent(e);!n||!this.draggingHandle||(e.stopPropagation(),t.value=this.calculateHandlePosition(e,n).toString(),n.handle.value=parseFloat(t.value),this.host.indeterminate=!1,this.requestUpdate())}cancelDrag(e){e=e||this.model.find(t=>t.name===this.activeHandle),e&&(e.handle.highlight=!1,delete this.draggingHandle,e.handle.dragging=!1)}dispatchChangeEvent(e,t){e.valueAsNumber=t.value;const n=new Event("change",{bubbles:!0,composed:!0});t.dispatchEvent(n)}calculateHandlePosition(e,t){const n=this.boundingClientRect,a=n.left,i=e.clientX,r=n.width,s=(this.host.isLTR?i-a:r-(i-a))/r;return t.normalization.fromNormalized(s,t.range.min,t.range.max)}renderHandle(e,t,n,a){var s;const i={handle:!0,dragging:((s=this.draggingHandle)==null?void 0:s.handleName)===e.name,"handle-highlight":e.highlight},r={[this.host.isLTR?"left":"right"]:`${e.normalizedValue*100}%`,"z-index":n.toString(),"background-color":`var(--spectrum-slider-handle-background-color-${t}, var(--spectrum-slider-handle-default-background-color))`,"border-color":`var(--spectrum-slider-handle-border-color-${t}, var(-spectrum-slider-handle-default-border-color))`},l=a?`label input-${t}`:"label";return m`
2
2
  <div
3
3
  class=${p(i)}
4
4
  name=${e.name}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["HandleController.ts"],
4
- "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 { MutationController } from '@lit-labs/observers/mutation_controller.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 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 new MutationController(this.host, {\n config: {\n subtree: true,\n childList: true,\n },\n callback: () => {\n this.extractModelFromLightDom();\n },\n });\n\n this.extractModelFromLightDom();\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 if (this.host.hasUpdated) {\n this.host.requestUpdate();\n }\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 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 ('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 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 this.cancelDrag(model);\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.host.indeterminate = false;\n this.requestUpdate();\n }\n\n public cancelDrag(model?: ModelValue): void {\n model =\n model || this.model.find((item) => item.name === this.activeHandle);\n if (!model) return;\n model.handle.highlight = false;\n delete this.draggingHandle;\n model.handle.dragging = false;\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 directionalOffset = this.host.isLTR\n ? offset - minOffset\n : size - (offset - minOffset);\n const normalized = directionalOffset / size;\n\n return model.normalization.fromNormalized(\n normalized,\n model.range.min,\n model.range.max\n );\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 }\n if (window.__swc.DEBUG) {\n if (!previous) {\n window.__swc.warn(\n this.host,\n '<sp-slider-handle> elements that are the first child of an <sp-slider> element cannot have attribute \"min=\\'previous\\'\"`',\n 'https://opensource.adobe.com/spectrum-web-components/components/slider-handle/#multi-handle-slider-with-ordered-handles'\n );\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 }\n if (window.__swc.DEBUG) {\n if (!next) {\n window.__swc.warn(\n this.host,\n '<sp-slider-handle> elements that are the last child of an <sp-slider> element cannot have attribute \"max=\\'next\\'\"',\n 'https://opensource.adobe.com/spectrum-web-components/components/slider-handle/#multi-handle-slider-with-ordered-handles'\n );\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"],
5
- "mappings": "aAWA,OAAS,QAAAA,MAA4B,gCACrC,OACI,YAAAC,EACA,aAAAC,EACA,YAAAC,MACG,kDACP,OAAS,sBAAAC,MAA0B,6CAEnC,OAEI,gBAAAC,MAEG,oBAwCA,aAAM,gBAAuC,CAQhD,YAAYC,EAAc,CAN1B,KAAQ,QAAqC,IAAI,IACjD,KAAQ,MAAsB,CAAC,EAC/B,KAAQ,YAAwB,CAAC,EAsGjC,KAAU,kBAAoB,IAAY,CACtC,KAAK,mBAAmB,CAC5B,EAgDA,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CAC5D,CAWJ,OAAOA,CACX,EAEMkC,EAAc3C,EAAQ,IAAI,CAACE,EAAQC,IAAU,CAlnB3D,IAAAC,EAmnBY,MAAMwC,EAAgBP,EAAiBlC,CAAK,EACtC,CAAE,aAAA0C,CAAa,EAAI3C,EAAO,cAC1B4C,EAAe,KAAK,IACtB,KAAK,IAAI5C,EAAO,MAAO0C,EAAc,MAAM,GAAG,EAC9CA,EAAc,MAAM,GACxB,EACMG,EAAkBF,EACpBC,EACAF,EAAc,MAAM,IACpBA,EAAc,MAAM,GACxB,EAeA,MAdc,CACV,KAAM1C,EAAO,WACb,MAAO4C,EACP,gBAAAC,EACA,UAAW7C,EAAO,UAClB,MAAME,EAAAF,EAAO,OAAP,KAAAE,EAAe,KAAK,KAAK,KAC/B,cAAeF,EAAO,cACtB,OAAAA,EACA,UACIA,IAAW,KAAK,OAAQA,GAAA,YAAAA,EAAQ,MAAM,QAAS,EACzCA,EAAO,MACP,OACV,GAAG0C,CACP,CAEJ,CAAC,EAED,KAAK,MAAQD,CACjB,CAEA,MAAa,uBAAuC,CAChD,MAAMK,EAAU,CAAC,GAAG,KAAK,QAAQ,OAAO,CAAC,EACpC,OAAQ9C,GAAWA,IAAW,KAAK,IAAI,EACvC,IAAKA,GAAWA,EAAO,cAAc,EAC1C,MAAM,QAAQ,IAAI8C,CAAO,CAC7B,CACJ",
4
+ "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 { MutationController } from '@lit-labs/observers/mutation_controller.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 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 new MutationController(this.host, {\n config: {\n subtree: true,\n childList: true,\n },\n callback: () => {\n this.extractModelFromLightDom();\n },\n });\n\n this.extractModelFromLightDom();\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 if (this.host.hasUpdated) {\n this.host.requestUpdate();\n }\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 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 ('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 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 if (event.pointerType === 'mouse') {\n this.host.labelEl.click();\n }\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 if (event.pointerType === 'mouse') {\n this.host.labelEl.click();\n }\n this.cancelDrag(model);\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.host.indeterminate = false;\n this.requestUpdate();\n }\n\n public cancelDrag(model?: ModelValue): void {\n model =\n model || this.model.find((item) => item.name === this.activeHandle);\n if (!model) return;\n model.handle.highlight = false;\n delete this.draggingHandle;\n model.handle.dragging = false;\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 directionalOffset = this.host.isLTR\n ? offset - minOffset\n : size - (offset - minOffset);\n const normalized = directionalOffset / size;\n\n return model.normalization.fromNormalized(\n normalized,\n model.range.min,\n model.range.max\n );\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 }\n if (window.__swc.DEBUG) {\n if (!previous) {\n window.__swc.warn(\n this.host,\n '<sp-slider-handle> elements that are the first child of an <sp-slider> element cannot have attribute \"min=\\'previous\\'\"`',\n 'https://opensource.adobe.com/spectrum-web-components/components/slider-handle/#multi-handle-slider-with-ordered-handles'\n );\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 }\n if (window.__swc.DEBUG) {\n if (!next) {\n window.__swc.warn(\n this.host,\n '<sp-slider-handle> elements that are the last child of an <sp-slider> element cannot have attribute \"max=\\'next\\'\"',\n 'https://opensource.adobe.com/spectrum-web-components/components/slider-handle/#multi-handle-slider-with-ordered-handles'\n );\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"],
5
+ "mappings": "aAWA,OAAS,QAAAA,MAA4B,gCACrC,OACI,YAAAC,EACA,aAAAC,EACA,YAAAC,MACG,kDACP,OAAS,sBAAAC,MAA0B,6CAEnC,OAEI,gBAAAC,MAEG,oBAwCA,aAAM,gBAAuC,CAQhD,YAAYC,EAAc,CAN1B,KAAQ,QAAqC,IAAI,IACjD,KAAQ,MAAsB,CAAC,EAC/B,KAAQ,YAAwB,CAAC,EAsGjC,KAAU,kBAAoB,IAAY,CACtC,KAAK,mBAAmB,CAC5B,EAgDA,KAAQ,yBAA2B,IAAY,CAC3C,IAAIC,EAAU,CACV,GAAG,KAAK,KAAK,iBAAiB,iBAAiB,CACnD,EACIA,EAAQ,SAAW,IACnBA,EAAU,CAAC,KAAK,IAAoB,GAGpC,CAAAA,EAAQ,KAAMC,GAAM,KAAK,eAAeA,CAAC,CAAC,IAG9C,KAAK,QAAU,IAAI,IACnB,KAAK,YAAc,CAAC,EACpBD,EAAQ,QAAQ,CAACE,EAAQC,IAAU,CAxO3C,IAAAC,GA0OiBA,EAAAF,EAAO,aAAP,MAAAE,EAAmB,SACpBF,EAAO,KAAO,SAASC,EAAQ,KAEnC,KAAK,QAAQ,IAAID,EAAO,WAAYA,CAAM,EAC1C,KAAK,YAAY,KAAKA,EAAO,UAAU,EACvCA,EAAO,iBAAmB,IAC9B,CAAC,EACD,KAAK,cAAc,EACvB,EAgKA,KAAQ,cAAiBG,GAAuB,CAC5C,MAAMC,EAAQD,EAAM,OACpBC,EAAM,MAAM,OAAO,MAAQA,EAAM,cAEjC,KAAK,cAAc,EACnB,KAAK,oBAAoBA,EAAOA,EAAM,MAAM,MAAM,CACtD,EAEA,KAAQ,aAAgBD,GAAuB,CAC3C,MAAMC,EAAQD,EAAM,OACpB,IAAIE,EACJ,GAAI,CACAA,EACID,EAAM,Q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AK,IAAI,EACvC,IAAKA,GAAWA,EAAO,cAAc,EAC1C,MAAM,QAAQ,IAAI8C,CAAO,CAC7B,CACJ",
6
6
  "names": ["html", "classMap", "ifDefined", "styleMap", "MutationController", "SliderHandle", "host", "handles", "h", "handle", "index", "_a", "event", "input", "isFocusVisible", "error", "result", "model", "elements", "numberFormat", "active", "name", "item", "handleSlider", "sliderHandle", "inputNodes", "inputNode", "resolvedInput", "changeEvent", "rect", "minOffset", "offset", "size", "normalized", "zIndex", "isMultiHandle", "classes", "style", "ariaLabelledBy", "values", "a", "b", "value", "array", "getRangeAndClamp", "previous", "next", "min", "max", "j", "modelValues", "rangeAndClamp", "toNormalized", "clampedValue", "normalizedValue", "updates"]
7
7
  }
@@ -35,11 +35,11 @@ export declare class SliderHandle extends Focusable {
35
35
  name: string;
36
36
  min?: number | 'previous';
37
37
  max?: number | 'next';
38
- private resolvedLanguage;
39
38
  step?: number;
40
39
  formatOptions?: NumberFormatOptions;
41
40
  label: string;
42
41
  getAriaHandleText: (value: number, numberFormat: NumberFormatter) => string;
42
+ private languageResolver;
43
43
  protected update(changes: PropertyValues): void;
44
44
  protected firstUpdated(changedProperties: PropertyValues<this>): void;
45
45
  normalization: SliderNormalization;
@@ -50,7 +50,4 @@ export declare class SliderHandle extends Focusable {
50
50
  } | undefined;
51
51
  protected getNumberFormat(): NumberFormatter;
52
52
  get numberFormat(): NumberFormatter | undefined;
53
- connectedCallback(): void;
54
- disconnectedCallback(): void;
55
- private resolveLanguage;
56
53
  }
@@ -12,6 +12,7 @@ var __decorateClass = (decorators, target, key, kind) => {
12
12
  };
13
13
  import { property } from "@spectrum-web-components/base/src/decorators.js";
14
14
  import { Focusable } from "@spectrum-web-components/shared/src/focusable.js";
15
+ import { LanguageResolutionController } from "@spectrum-web-components/reactive-controllers/src/LanguageResolution.js";
15
16
  import {
16
17
  NumberFormatter
17
18
  } from "@internationalized/number";
@@ -51,11 +52,11 @@ export class SliderHandle extends Focusable {
51
52
  this.dragging = false;
52
53
  this.highlight = false;
53
54
  this.name = "";
54
- this.resolvedLanguage = document.documentElement.lang || navigator.language;
55
55
  this.label = "";
56
56
  this.getAriaHandleText = (value, numberFormat) => {
57
57
  return numberFormat.format(value);
58
58
  };
59
+ this.languageResolver = new LanguageResolutionController(this);
59
60
  this.normalization = defaultNormalization;
60
61
  }
61
62
  get handleName() {
@@ -95,11 +96,11 @@ export class SliderHandle extends Focusable {
95
96
  }
96
97
  getNumberFormat() {
97
98
  var _a;
98
- if (!this._numberFormatCache || this.resolvedLanguage !== this._numberFormatCache.language) {
99
+ if (!this._numberFormatCache || this.languageResolver.language !== this._numberFormatCache.language) {
99
100
  let numberFormatter;
100
101
  try {
101
102
  numberFormatter = new NumberFormatter(
102
- this.resolvedLanguage,
103
+ this.languageResolver.language,
103
104
  this.formatOptions
104
105
  );
105
106
  this._forcedUnit = "";
@@ -114,12 +115,12 @@ export class SliderHandle extends Focusable {
114
115
  this._forcedUnit = unit;
115
116
  }
116
117
  numberFormatter = new NumberFormatter(
117
- this.resolvedLanguage,
118
+ this.languageResolver.language,
118
119
  formatOptionsNoUnit
119
120
  );
120
121
  }
121
122
  this._numberFormatCache = {
122
- language: this.resolvedLanguage,
123
+ language: this.languageResolver.language,
123
124
  numberFormat: numberFormatter
124
125
  };
125
126
  }
@@ -130,30 +131,6 @@ export class SliderHandle extends Focusable {
130
131
  return;
131
132
  return this.getNumberFormat();
132
133
  }
133
- connectedCallback() {
134
- super.connectedCallback();
135
- this.resolveLanguage();
136
- }
137
- disconnectedCallback() {
138
- this.resolveLanguage();
139
- super.disconnectedCallback();
140
- }
141
- resolveLanguage() {
142
- const queryThemeEvent = new CustomEvent(
143
- "sp-language-context",
144
- {
145
- bubbles: true,
146
- composed: true,
147
- detail: {
148
- callback: (lang) => {
149
- this.resolvedLanguage = lang;
150
- }
151
- },
152
- cancelable: true
153
- }
154
- );
155
- this.dispatchEvent(queryThemeEvent);
156
- }
157
134
  }
158
135
  __decorateClass([
159
136
  property({ type: Number })
@@ -173,9 +150,6 @@ __decorateClass([
173
150
  __decorateClass([
174
151
  property({ reflect: true, converter: MaxConverter })
175
152
  ], SliderHandle.prototype, "max", 2);
176
- __decorateClass([
177
- property({ attribute: false })
178
- ], SliderHandle.prototype, "resolvedLanguage", 2);
179
153
  __decorateClass([
180
154
  property({ type: Number, reflect: true })
181
155
  ], SliderHandle.prototype, "step", 2);