@spectrum-web-components/slider 0.12.13 → 0.12.15-devmode.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/custom-elements.json +40 -0
- package/package.json +41 -16
- package/sp-slider-handle.dev.js +3 -0
- package/sp-slider-handle.dev.js.map +7 -0
- package/sp-slider-handle.js +3 -14
- package/sp-slider-handle.js.map +7 -1
- package/sp-slider.dev.js +4 -0
- package/sp-slider.dev.js.map +7 -0
- package/sp-slider.js +4 -15
- package/sp-slider.js.map +7 -1
- package/src/HandleController.dev.js +434 -0
- package/src/HandleController.dev.js.map +7 -0
- package/src/HandleController.js +402 -451
- package/src/HandleController.js.map +7 -1
- package/src/Slider.d.ts +8 -0
- package/src/Slider.dev.js +367 -0
- package/src/Slider.dev.js.map +7 -0
- package/src/Slider.js +282 -289
- package/src/Slider.js.map +7 -1
- package/src/SliderHandle.dev.js +184 -0
- package/src/SliderHandle.dev.js.map +7 -0
- package/src/SliderHandle.js +171 -179
- package/src/SliderHandle.js.map +7 -1
- package/src/index.dev.js +4 -0
- package/src/index.dev.js.map +7 -0
- package/src/index.js +4 -15
- package/src/index.js.map +7 -1
- package/src/slider.css.dev.js +234 -0
- package/src/slider.css.dev.js.map +7 -0
- package/src/slider.css.js +3 -14
- package/src/slider.css.js.map +7 -1
- package/src/spectrum-slider.css.dev.js +216 -0
- package/src/spectrum-slider.css.dev.js.map +7 -0
- package/src/spectrum-slider.css.js +3 -14
- package/src/spectrum-slider.css.js.map +7 -1
- package/stories/slider.stories.js +257 -267
- package/stories/slider.stories.js.map +7 -1
- package/sync/sp-slider.dev.js +3 -0
- package/sync/sp-slider.dev.js.map +7 -0
- package/sync/sp-slider.js +3 -14
- package/sync/sp-slider.js.map +7 -1
- package/test/benchmark/test-basic.js +5 -16
- package/test/benchmark/test-basic.js.map +7 -1
- package/test/slider-editable-sync.test.js +132 -144
- package/test/slider-editable-sync.test.js.map +7 -1
- package/test/slider-editable.test.js +151 -144
- package/test/slider-editable.test.js.map +7 -1
- package/test/slider-handle-upgrade.test.js +10 -21
- package/test/slider-handle-upgrade.test.js.map +7 -1
- package/test/slider.test-vrt.js +4 -15
- package/test/slider.test-vrt.js.map +7 -1
- package/test/slider.test.js +686 -700
- package/test/slider.test.js.map +7 -1
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"version":3,"file":"HandleController.js","sourceRoot":"","sources":["HandleController.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,IAAI,EAAkB,MAAM,+BAA+B,CAAC;AACrE,OAAO,EACH,QAAQ,EACR,SAAS,EACT,QAAQ,GACX,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAEhF,OAAO,EAEH,YAAY,GAEf,MAAM,mBAAmB,CAAC;AAwC3B,MAAM,OAAO,gBAAgB;IAQzB,YAAY,IAAY;QANhB,YAAO,GAA8B,IAAI,GAAG,EAAE,CAAC;QAC/C,UAAK,GAAiB,EAAE,CAAC;QACzB,gBAAW,GAAa,EAAE,CAAC;QAqGzB,sBAAiB,GAAG,GAAS,EAAE;YACrC,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC9B,CAAC,CAAC;QAgDM,6BAAwB,GAAG,GAAS,EAAE;YAC1C,IAAI,OAAO,GAAG;gBACV,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC;aACjC,CAAC;YACpB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;gBACtB,OAAO,GAAG,CAAC,IAAI,CAAC,IAAoB,CAAC,CAAC;aACzC;YACD,mFAAmF;YACnF,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE;gBAC7C,OAAO;aACV;YACD,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,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ACnB,eAAe,EACf,SAAS,EAAE,MAAM,CAAC,SAAS,EAC3B,IAAI,EAAE,MAAA,MAAM,CAAC,IAAI,mCAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EACnC,aAAa,EAAE,MAAM,CAAC,aAAa,EACnC,MAAM,EACN,SAAS,EACL,MAAM,KAAK,IAAI,CAAC,IAAI,IAAI,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,MAAM,IAAG,CAAC;oBAC5C,CAAC,CAAC,MAAM,CAAC,KAAK;oBACd,CAAC,CAAC,SAAS,IAChB,aAAa,CACnB,CAAC;YACF,OAAO,KAAK,CAAC;QACjB,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC;IAC7B,CAAC;IAEM,KAAK,CAAC,qBAAqB;QAC9B,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;aACrC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC,IAAI,CAAC;aACxC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QAC5C,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;CACJ","sourcesContent":["/*\nCopyright 2021 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { html, TemplateResult } from '@spectrum-web-components/base';\nimport {\n classMap,\n ifDefined,\n styleMap,\n} from '@spectrum-web-components/base/src/directives.js';\nimport { 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 this.host.requestUpdate();\n }\n\n /**\n * It is possible for value attributes to be set programmatically. The <input>\n * for a particular slider needs to have an opportunity to validate any such\n * values\n *\n * @param handle Handle who's value needs validation\n */\n public setValueFromHandle(handle: SliderHandle): void {\n const elements = this.getHandleElements(handle);\n /* c8 ignore next */\n if (!elements) return;\n\n const { input } = elements;\n if (input.valueAsNumber === handle.value) {\n if (handle.dragging) {\n handle.dispatchInputEvent();\n }\n } else {\n input.valueAsNumber = handle.value;\n handle.value = input.valueAsNumber;\n this.requestUpdate();\n }\n handle.value = input.valueAsNumber;\n }\n\n public handleHasChanged(handle: SliderHandle): void {\n if (handle !== this.host) {\n this.requestUpdate();\n }\n }\n\n public formattedValueForHandle(model: ModelValue): string {\n const { handle } = model;\n const numberFormat = handle.numberFormat ?? this.host.numberFormat;\n return handle.getAriaHandleText(model.value, numberFormat);\n }\n\n public get formattedValues(): Map<string, string> {\n const result = new Map<string, string>();\n for (const model of this.model) {\n result.set(model.name, this.formattedValueForHandle(model));\n }\n return result;\n }\n\n public get focusElement(): HTMLElement {\n const { input } = this.getActiveHandleElements();\n if (\n this.host.editable &&\n !(input as InputWithModel).model.handle.dragging\n ) {\n return this.host.numberField;\n }\n return input;\n }\n\n protected handleOrientation = (): void => {\n this.updateBoundingRect();\n };\n\n public hostConnected(): void {\n if ('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.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 /* c8 ignore next 5 */\n } else {\n console.warn(\n 'First slider handle cannot have attribute min=\"previous\"'\n );\n }\n }\n if (handle.max === 'next') {\n if (next) {\n for (let j = index + 1; j < handles.length; j++) {\n const item = handles[j];\n if (typeof item.max === 'number') {\n result.range.max = item.max;\n break;\n }\n }\n result.clamp.max = Math.min(next.value, result.range.max);\n /* c8 ignore next 5 */\n } else {\n console.warn(\n 'Last slider handle cannot have attribute max=\"next\"'\n );\n }\n }\n return result;\n };\n\n const modelValues = handles.map((handle, index) => {\n const rangeAndClamp = getRangeAndClamp(index);\n const { toNormalized } = handle.normalization;\n const clampedValue = Math.max(\n Math.min(handle.value, rangeAndClamp.clamp.max),\n rangeAndClamp.clamp.min\n );\n const normalizedValue = toNormalized(\n clampedValue,\n rangeAndClamp.range.min,\n rangeAndClamp.range.max\n );\n const model = {\n name: handle.handleName,\n value: clampedValue,\n normalizedValue,\n highlight: handle.highlight,\n step: handle.step ?? this.host.step,\n normalization: handle.normalization,\n handle,\n ariaLabel:\n handle !== this.host && handle?.label.length > 0\n ? handle.label\n : undefined,\n ...rangeAndClamp,\n };\n return model;\n });\n\n this.model = modelValues;\n }\n\n public async handleUpdatesComplete(): Promise<void> {\n const updates = [...this.handles.values()]\n .filter((handle) => handle !== this.host)\n .map((handle) => handle.updateComplete);\n await Promise.all(updates);\n }\n}\n"]}
|
|
1
|
+
{
|
|
2
|
+
"version": 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.issueWarning(\n 'slider:api:default',\n 'First slider handle 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.issueWarning(\n 'slider:api:default',\n 'Last slider handle cannot have attribute max=\"next\"',\n 'This needs a URL!'\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;AACA;AAAA;AAAA;AAAA;AAAA;AAKA;AAEA;AAAA;AAAA;AA4CO,aAAM,iBAAuC;AAAA,EAQhD,YAAY,MAAc;AANlB,mBAAqC,oBAAI,IAAI;AAC7C,iBAAsB,CAAC;AACvB,uBAAwB,CAAC;AAsGvB,6BAAoB,MAAY;AACtC,WAAK,mBAAmB;AAAA,IAC5B;AAgDQ,oCAA2B,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,CAAC,cAAO,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,WAAK,cAAc;AAAA,IACvB;AA4JQ,yBAAgB,CAAC,UAAuB;AAC5C,YAAM,QAAQ,MAAM;AACpB,YAAM,MAAM,OAAO,QAAQ,MAAM;AAEjC,WAAK,cAAc;AACnB,WAAK,oBAAoB,OAAO,MAAM,MAAM,MAAM;AAAA,IACtD;AA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@@ -43,6 +43,14 @@ export declare class Slider extends Slider_base {
|
|
|
43
43
|
tickStep: number;
|
|
44
44
|
tickLabels: boolean;
|
|
45
45
|
disabled: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Applies `quiet` to the underlying `sp-number-field` when `editable === true`.
|
|
48
|
+
*/
|
|
49
|
+
quiet: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Applies `indeterminate` to the underlying `sp-number-field` when `editable === true`. Is removed on the next `change` event.
|
|
52
|
+
*/
|
|
53
|
+
indeterminate: boolean;
|
|
46
54
|
labelEl: HTMLLabelElement;
|
|
47
55
|
numberField: NumberField;
|
|
48
56
|
track: HTMLDivElement;
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result)
|
|
9
|
+
__defProp(target, key, result);
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
import {
|
|
13
|
+
html
|
|
14
|
+
} from "@spectrum-web-components/base";
|
|
15
|
+
import {
|
|
16
|
+
property,
|
|
17
|
+
query
|
|
18
|
+
} from "@spectrum-web-components/base/src/decorators.js";
|
|
19
|
+
import {
|
|
20
|
+
classMap,
|
|
21
|
+
ifDefined,
|
|
22
|
+
repeat,
|
|
23
|
+
styleMap
|
|
24
|
+
} from "@spectrum-web-components/base/src/directives.js";
|
|
25
|
+
import sliderStyles from "./slider.css.js";
|
|
26
|
+
import { ObserveSlotText } from "@spectrum-web-components/shared/src/observe-slot-text.js";
|
|
27
|
+
import "@spectrum-web-components/field-label/sp-field-label.js";
|
|
28
|
+
import { HandleController } from "./HandleController.dev.js";
|
|
29
|
+
import { SliderHandle } from "./SliderHandle.dev.js";
|
|
30
|
+
import { streamingListener } from "@spectrum-web-components/base/src/streaming-listener.js";
|
|
31
|
+
export const variants = ["filled", "ramp", "range", "tick"];
|
|
32
|
+
export class Slider extends ObserveSlotText(SliderHandle, "") {
|
|
33
|
+
constructor() {
|
|
34
|
+
super(...arguments);
|
|
35
|
+
this.handleController = new HandleController(this);
|
|
36
|
+
this._editable = false;
|
|
37
|
+
this.hideStepper = false;
|
|
38
|
+
this.type = "";
|
|
39
|
+
this._variant = "";
|
|
40
|
+
this.getAriaValueText = (values) => {
|
|
41
|
+
const valueArray = [...values.values()];
|
|
42
|
+
if (valueArray.length === 2)
|
|
43
|
+
return `${valueArray[0]}${this._forcedUnit} - ${valueArray[1]}${this._forcedUnit}`;
|
|
44
|
+
return valueArray.join(`${this._forcedUnit}, `) + this._forcedUnit;
|
|
45
|
+
};
|
|
46
|
+
this.min = 0;
|
|
47
|
+
this.max = 100;
|
|
48
|
+
this.step = 1;
|
|
49
|
+
this.tickStep = 0;
|
|
50
|
+
this.tickLabels = false;
|
|
51
|
+
this.disabled = false;
|
|
52
|
+
this.quiet = false;
|
|
53
|
+
this.indeterminate = false;
|
|
54
|
+
this._numberFieldInput = Promise.resolve();
|
|
55
|
+
}
|
|
56
|
+
static get styles() {
|
|
57
|
+
return [sliderStyles];
|
|
58
|
+
}
|
|
59
|
+
get editable() {
|
|
60
|
+
return this._editable;
|
|
61
|
+
}
|
|
62
|
+
set editable(editable) {
|
|
63
|
+
if (editable === this.editable)
|
|
64
|
+
return;
|
|
65
|
+
const oldValue = this.editable;
|
|
66
|
+
this._editable = this.handleController.size < 2 ? editable : false;
|
|
67
|
+
if (this.editable) {
|
|
68
|
+
this._numberFieldInput = import("@spectrum-web-components/number-field/sp-number-field.js");
|
|
69
|
+
}
|
|
70
|
+
if (oldValue !== this.editable) {
|
|
71
|
+
this.requestUpdate("editable", oldValue);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
set variant(variant) {
|
|
75
|
+
const oldVariant = this.variant;
|
|
76
|
+
if (variant === this.variant) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (variants.includes(variant)) {
|
|
80
|
+
this.setAttribute("variant", variant);
|
|
81
|
+
this._variant = variant;
|
|
82
|
+
} else {
|
|
83
|
+
this.removeAttribute("variant");
|
|
84
|
+
this._variant = "";
|
|
85
|
+
}
|
|
86
|
+
this.requestUpdate("variant", oldVariant);
|
|
87
|
+
}
|
|
88
|
+
get variant() {
|
|
89
|
+
return this._variant;
|
|
90
|
+
}
|
|
91
|
+
get values() {
|
|
92
|
+
return this.handleController.values;
|
|
93
|
+
}
|
|
94
|
+
get handleName() {
|
|
95
|
+
return "value";
|
|
96
|
+
}
|
|
97
|
+
get ariaValueText() {
|
|
98
|
+
if (!this.getAriaValueText) {
|
|
99
|
+
return `${this.value}${this._forcedUnit}`;
|
|
100
|
+
}
|
|
101
|
+
return this.getAriaValueText(this.handleController.formattedValues);
|
|
102
|
+
}
|
|
103
|
+
get numberFormat() {
|
|
104
|
+
return this.getNumberFormat();
|
|
105
|
+
}
|
|
106
|
+
get focusElement() {
|
|
107
|
+
return this.handleController.focusElement;
|
|
108
|
+
}
|
|
109
|
+
handleLabelClick(event) {
|
|
110
|
+
if (this.editable) {
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
this.focus();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
render() {
|
|
116
|
+
return html`
|
|
117
|
+
${this.renderLabel()} ${this.renderTrack()}
|
|
118
|
+
${this.editable ? html`
|
|
119
|
+
<sp-number-field
|
|
120
|
+
.formatOptions=${this.formatOptions || {}}
|
|
121
|
+
id="number-field"
|
|
122
|
+
min=${this.min}
|
|
123
|
+
max=${this.max}
|
|
124
|
+
step=${this.step}
|
|
125
|
+
value=${this.value}
|
|
126
|
+
?hide-stepper=${this.hideStepper}
|
|
127
|
+
?disabled=${this.disabled}
|
|
128
|
+
?quiet=${this.quiet}
|
|
129
|
+
?indeterminate=${this.indeterminate}
|
|
130
|
+
@input=${this.handleNumberInput}
|
|
131
|
+
@change=${this.handleNumberChange}
|
|
132
|
+
></sp-number-field>
|
|
133
|
+
` : html``}
|
|
134
|
+
`;
|
|
135
|
+
}
|
|
136
|
+
connectedCallback() {
|
|
137
|
+
super.connectedCallback();
|
|
138
|
+
this.handleController.hostConnected();
|
|
139
|
+
}
|
|
140
|
+
disconnectedCallback() {
|
|
141
|
+
super.disconnectedCallback();
|
|
142
|
+
this.handleController.hostDisconnected();
|
|
143
|
+
}
|
|
144
|
+
update(changedProperties) {
|
|
145
|
+
this.handleController.hostUpdate();
|
|
146
|
+
if (changedProperties.has("disabled") && this.disabled) {
|
|
147
|
+
this.handleController.cancelDrag();
|
|
148
|
+
}
|
|
149
|
+
super.update(changedProperties);
|
|
150
|
+
}
|
|
151
|
+
renderLabel() {
|
|
152
|
+
const textLabelVisible = this.labelVisibility === "none" || this.labelVisibility === "value";
|
|
153
|
+
const valueLabelVisible = this.labelVisibility === "none" || this.labelVisibility === "text";
|
|
154
|
+
return html`
|
|
155
|
+
<div id="label-container">
|
|
156
|
+
<sp-field-label
|
|
157
|
+
class=${classMap({
|
|
158
|
+
"visually-hidden": textLabelVisible
|
|
159
|
+
})}
|
|
160
|
+
?disabled=${this.disabled}
|
|
161
|
+
id="label"
|
|
162
|
+
for=${this.editable ? "number-field" : this.handleController.activeHandleInputId}
|
|
163
|
+
@click=${this.handleLabelClick}
|
|
164
|
+
>
|
|
165
|
+
${this.slotHasContent ? html`` : this.label}
|
|
166
|
+
<slot>${this.label}</slot>
|
|
167
|
+
</sp-field-label>
|
|
168
|
+
<output
|
|
169
|
+
class=${classMap({
|
|
170
|
+
"visually-hidden": valueLabelVisible
|
|
171
|
+
})}
|
|
172
|
+
id="value"
|
|
173
|
+
aria-live="off"
|
|
174
|
+
for="input"
|
|
175
|
+
>
|
|
176
|
+
${this.ariaValueText}
|
|
177
|
+
</output>
|
|
178
|
+
</div>
|
|
179
|
+
`;
|
|
180
|
+
}
|
|
181
|
+
renderRamp() {
|
|
182
|
+
if (this.variant !== "ramp") {
|
|
183
|
+
return html``;
|
|
184
|
+
}
|
|
185
|
+
return html`
|
|
186
|
+
<div id="ramp">
|
|
187
|
+
<svg
|
|
188
|
+
viewBox="0 0 240 16"
|
|
189
|
+
preserveAspectRatio="none"
|
|
190
|
+
aria-hidden="true"
|
|
191
|
+
focusable="false"
|
|
192
|
+
>
|
|
193
|
+
<path
|
|
194
|
+
d="M240,4v8c0,2.3-1.9,4.1-4.2,4L1,9C0.4,9,0,8.5,0,8c0-0.5,0.4-1,1-1l234.8-7C238.1-0.1,240,1.7,240,4z"
|
|
195
|
+
></path>
|
|
196
|
+
</svg>
|
|
197
|
+
</div>
|
|
198
|
+
`;
|
|
199
|
+
}
|
|
200
|
+
renderTicks() {
|
|
201
|
+
if (this.variant !== "tick") {
|
|
202
|
+
return html``;
|
|
203
|
+
}
|
|
204
|
+
const tickStep = this.tickStep || this.step;
|
|
205
|
+
const tickCount = (this.max - this.min) / tickStep;
|
|
206
|
+
const partialFit = tickCount % 1 !== 0;
|
|
207
|
+
const ticks = new Array(Math.floor(tickCount + 1));
|
|
208
|
+
ticks.fill(0, 0, tickCount + 1);
|
|
209
|
+
return html`
|
|
210
|
+
<div
|
|
211
|
+
class="${partialFit ? "not-exact " : ""}ticks"
|
|
212
|
+
style=${ifDefined(partialFit ? `--sp-slider-tick-offset: calc(100% / ${this.max} * ${this.tickStep}` : void 0)}
|
|
213
|
+
>
|
|
214
|
+
${ticks.map((_tick, i) => html`
|
|
215
|
+
<div class="tick">
|
|
216
|
+
${this.tickLabels ? html`
|
|
217
|
+
<div class="tickLabel">
|
|
218
|
+
${i * tickStep + this.min}
|
|
219
|
+
</div>
|
|
220
|
+
` : html``}
|
|
221
|
+
</div>
|
|
222
|
+
`)}
|
|
223
|
+
</div>
|
|
224
|
+
`;
|
|
225
|
+
}
|
|
226
|
+
renderTrackSegment(start, end) {
|
|
227
|
+
if (this.variant === "ramp") {
|
|
228
|
+
return html``;
|
|
229
|
+
}
|
|
230
|
+
return html`
|
|
231
|
+
<div
|
|
232
|
+
class="track"
|
|
233
|
+
style=${styleMap(this.trackSegmentStyles(start, end))}
|
|
234
|
+
role="presentation"
|
|
235
|
+
></div>
|
|
236
|
+
`;
|
|
237
|
+
}
|
|
238
|
+
renderTrack() {
|
|
239
|
+
const segments = this.handleController.trackSegments();
|
|
240
|
+
const trackItems = [
|
|
241
|
+
{ id: "track0", html: this.renderTrackSegment(...segments[0]) },
|
|
242
|
+
{ id: "ramp", html: this.renderRamp() },
|
|
243
|
+
{ id: "ticks", html: this.renderTicks() },
|
|
244
|
+
{ id: "handles", html: this.handleController.render() },
|
|
245
|
+
...segments.slice(1).map(([start, end], index) => ({
|
|
246
|
+
id: `track${index + 1}`,
|
|
247
|
+
html: this.renderTrackSegment(start, end)
|
|
248
|
+
}))
|
|
249
|
+
];
|
|
250
|
+
return html`
|
|
251
|
+
<div
|
|
252
|
+
id="track"
|
|
253
|
+
${streamingListener({
|
|
254
|
+
start: ["pointerdown", this.handlePointerdown],
|
|
255
|
+
streamInside: ["pointermove", this.handlePointermove],
|
|
256
|
+
end: [["pointerup", "pointercancel"], this.handlePointerup]
|
|
257
|
+
})}
|
|
258
|
+
>
|
|
259
|
+
<div id="controls">
|
|
260
|
+
${repeat(trackItems, (item) => item.id, (item) => item.html)}
|
|
261
|
+
</div>
|
|
262
|
+
</div>
|
|
263
|
+
`;
|
|
264
|
+
}
|
|
265
|
+
handlePointerdown(event) {
|
|
266
|
+
this.handleController.handlePointerdown(event);
|
|
267
|
+
}
|
|
268
|
+
handlePointermove(event) {
|
|
269
|
+
this.handleController.handlePointermove(event);
|
|
270
|
+
}
|
|
271
|
+
handlePointerup(event) {
|
|
272
|
+
this.handleController.handlePointerup(event);
|
|
273
|
+
}
|
|
274
|
+
handleNumberInput(event) {
|
|
275
|
+
var _a;
|
|
276
|
+
const { value } = event.target;
|
|
277
|
+
if (((_a = event.target) == null ? void 0 : _a.stepperActive) && !isNaN(value)) {
|
|
278
|
+
this.value = value;
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
event.stopPropagation();
|
|
282
|
+
}
|
|
283
|
+
handleNumberChange(event) {
|
|
284
|
+
var _a;
|
|
285
|
+
const { value } = event.target;
|
|
286
|
+
if (isNaN(value)) {
|
|
287
|
+
event.target.value = this.value;
|
|
288
|
+
event.stopPropagation();
|
|
289
|
+
} else {
|
|
290
|
+
this.value = value;
|
|
291
|
+
if (!((_a = event.target) == null ? void 0 : _a.stepperActive)) {
|
|
292
|
+
this.dispatchInputEvent();
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
this.indeterminate = false;
|
|
296
|
+
}
|
|
297
|
+
trackSegmentStyles(start, end) {
|
|
298
|
+
const size = end - start;
|
|
299
|
+
const styles = {
|
|
300
|
+
width: `${size * 100}%`,
|
|
301
|
+
"--spectrum-slider-track-background-size": `${1 / size * 100}%`,
|
|
302
|
+
"--spectrum-slider-track-segment-position": `${start * 100}%`
|
|
303
|
+
};
|
|
304
|
+
return styles;
|
|
305
|
+
}
|
|
306
|
+
async getUpdateComplete() {
|
|
307
|
+
const complete = await super.getUpdateComplete();
|
|
308
|
+
if (this.editable) {
|
|
309
|
+
await this._numberFieldInput;
|
|
310
|
+
await this.numberField.updateComplete;
|
|
311
|
+
}
|
|
312
|
+
await this.handleController.handleUpdatesComplete();
|
|
313
|
+
return complete;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
__decorateClass([
|
|
317
|
+
property({ type: Boolean, reflect: true })
|
|
318
|
+
], Slider.prototype, "editable", 1);
|
|
319
|
+
__decorateClass([
|
|
320
|
+
property({ type: Boolean, reflect: true, attribute: "hide-stepper" })
|
|
321
|
+
], Slider.prototype, "hideStepper", 2);
|
|
322
|
+
__decorateClass([
|
|
323
|
+
property()
|
|
324
|
+
], Slider.prototype, "type", 2);
|
|
325
|
+
__decorateClass([
|
|
326
|
+
property({ type: String })
|
|
327
|
+
], Slider.prototype, "variant", 1);
|
|
328
|
+
__decorateClass([
|
|
329
|
+
property({ attribute: false })
|
|
330
|
+
], Slider.prototype, "getAriaValueText", 2);
|
|
331
|
+
__decorateClass([
|
|
332
|
+
property({ type: String, reflect: true, attribute: "label-visibility" })
|
|
333
|
+
], Slider.prototype, "labelVisibility", 2);
|
|
334
|
+
__decorateClass([
|
|
335
|
+
property({ type: Number, reflect: true })
|
|
336
|
+
], Slider.prototype, "min", 2);
|
|
337
|
+
__decorateClass([
|
|
338
|
+
property({ type: Number, reflect: true })
|
|
339
|
+
], Slider.prototype, "max", 2);
|
|
340
|
+
__decorateClass([
|
|
341
|
+
property({ type: Number })
|
|
342
|
+
], Slider.prototype, "step", 2);
|
|
343
|
+
__decorateClass([
|
|
344
|
+
property({ type: Number, attribute: "tick-step" })
|
|
345
|
+
], Slider.prototype, "tickStep", 2);
|
|
346
|
+
__decorateClass([
|
|
347
|
+
property({ type: Boolean, attribute: "tick-labels" })
|
|
348
|
+
], Slider.prototype, "tickLabels", 2);
|
|
349
|
+
__decorateClass([
|
|
350
|
+
property({ type: Boolean, reflect: true })
|
|
351
|
+
], Slider.prototype, "disabled", 2);
|
|
352
|
+
__decorateClass([
|
|
353
|
+
property({ type: Boolean })
|
|
354
|
+
], Slider.prototype, "quiet", 2);
|
|
355
|
+
__decorateClass([
|
|
356
|
+
property({ type: Boolean })
|
|
357
|
+
], Slider.prototype, "indeterminate", 2);
|
|
358
|
+
__decorateClass([
|
|
359
|
+
query("#label")
|
|
360
|
+
], Slider.prototype, "labelEl", 2);
|
|
361
|
+
__decorateClass([
|
|
362
|
+
query("#number-field")
|
|
363
|
+
], Slider.prototype, "numberField", 2);
|
|
364
|
+
__decorateClass([
|
|
365
|
+
query("#track")
|
|
366
|
+
], Slider.prototype, "track", 2);
|
|
367
|
+
//# sourceMappingURL=Slider.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["Slider.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport {\n classMap,\n ifDefined,\n repeat,\n styleMap,\n} from '@spectrum-web-components/base/src/directives.js';\n\nimport sliderStyles from './slider.css.js';\nimport { ObserveSlotText } from '@spectrum-web-components/shared/src/observe-slot-text.js';\nimport { StyleInfo } from 'lit-html/directives/style-map';\nimport '@spectrum-web-components/field-label/sp-field-label.js';\nimport type { NumberField } from '@spectrum-web-components/number-field';\nimport { HandleController, HandleValueDictionary } from './HandleController.dev.js'\nimport { SliderHandle } from './SliderHandle.dev.js'\nimport { streamingListener } from '@spectrum-web-components/base/src/streaming-listener.js';\nimport type { NumberFormatter } from '@internationalized/number';\n\nexport const variants = ['filled', 'ramp', 'range', 'tick'];\n\n/**\n * @element sp-slider\n *\n * @slot - text label for the Slider\n * @slot handle - optionally accepts two or more sp-slider-handle elements\n */\nexport class Slider extends ObserveSlotText(SliderHandle, '') {\n public static override get styles(): CSSResultArray {\n return [sliderStyles];\n }\n\n public override handleController: HandleController = new HandleController(\n this\n );\n\n /**\n * Whether to display a Number Field along side the slider UI\n */\n @property({ type: Boolean, reflect: true })\n public get editable(): boolean {\n return this._editable;\n }\n\n public set editable(editable: boolean) {\n if (editable === this.editable) return;\n const oldValue = this.editable;\n this._editable = this.handleController.size < 2 ? editable : false;\n if (this.editable) {\n this._numberFieldInput = import(\n '@spectrum-web-components/number-field/sp-number-field.js'\n );\n }\n if (oldValue !== this.editable) {\n this.requestUpdate('editable', oldValue);\n }\n }\n\n private _editable = false;\n\n /**\n * Whether the stepper UI of the Number Field is hidden or not\n */\n @property({ type: Boolean, reflect: true, attribute: 'hide-stepper' })\n public hideStepper = false;\n\n @property()\n public type = '';\n\n @property({ type: String })\n public set variant(variant: string) {\n const oldVariant = this.variant;\n if (variant === this.variant) {\n return;\n }\n if (variants.includes(variant)) {\n this.setAttribute('variant', variant);\n this._variant = variant;\n } else {\n this.removeAttribute('variant');\n this._variant = '';\n }\n this.requestUpdate('variant', oldVariant);\n }\n\n public get variant(): string {\n return this._variant;\n }\n\n public get values(): HandleValueDictionary {\n return this.handleController.values;\n }\n\n public override get handleName(): string {\n return 'value';\n }\n\n /* Ensure that a '' value for `variant` removes the attribute instead of a blank value */\n private _variant = '';\n\n @property({ attribute: false })\n public getAriaValueText: (values: Map<string, string>) => string = (\n values\n ) => {\n const valueArray = [...values.values()];\n if (valueArray.length === 2)\n return `${valueArray[0]}${this._forcedUnit} - ${valueArray[1]}${this._forcedUnit}`;\n return valueArray.join(`${this._forcedUnit}, `) + this._forcedUnit;\n };\n\n public override get ariaValueText(): string {\n if (!this.getAriaValueText) {\n return `${this.value}${this._forcedUnit}`;\n }\n return this.getAriaValueText(this.handleController.formattedValues);\n }\n\n @property({ type: String, reflect: true, attribute: 'label-visibility' })\n public labelVisibility?: 'text' | 'value' | 'none';\n\n @property({ type: Number, reflect: true })\n public override min = 0;\n\n @property({ type: Number, reflect: true })\n public override max = 100;\n\n @property({ type: Number })\n public override step = 1;\n\n @property({ type: Number, attribute: 'tick-step' })\n public tickStep = 0;\n\n @property({ type: Boolean, attribute: 'tick-labels' })\n public tickLabels = false;\n\n @property({ type: Boolean, reflect: true })\n public override disabled = false;\n\n /**\n * Applies `quiet` to the underlying `sp-number-field` when `editable === true`.\n */\n @property({ type: Boolean })\n public quiet = false;\n\n /**\n * Applies `indeterminate` to the underlying `sp-number-field` when `editable === true`. Is removed on the next `change` event.\n */\n @property({ type: Boolean })\n public indeterminate = false;\n\n @query('#label')\n public labelEl!: HTMLLabelElement;\n\n @query('#number-field')\n public numberField!: NumberField;\n\n @query('#track')\n public track!: HTMLDivElement;\n\n public override get numberFormat(): NumberFormatter {\n return this.getNumberFormat();\n }\n\n public override get focusElement(): HTMLElement {\n return this.handleController.focusElement;\n }\n\n protected handleLabelClick(event: Event): void {\n if (this.editable) {\n event.preventDefault();\n this.focus();\n }\n }\n\n protected override render(): TemplateResult {\n return html`\n ${this.renderLabel()} ${this.renderTrack()}\n ${this.editable\n ? html`\n <sp-number-field\n .formatOptions=${this.formatOptions || {}}\n id=\"number-field\"\n min=${this.min}\n max=${this.max}\n step=${this.step}\n value=${this.value}\n ?hide-stepper=${this.hideStepper}\n ?disabled=${this.disabled}\n ?quiet=${this.quiet}\n ?indeterminate=${this.indeterminate}\n @input=${this.handleNumberInput}\n @change=${this.handleNumberChange}\n ></sp-number-field>\n `\n : html``}\n `;\n }\n\n public override connectedCallback(): void {\n super.connectedCallback();\n this.handleController.hostConnected();\n }\n\n public override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.handleController.hostDisconnected();\n }\n\n public override update(changedProperties: Map<string, boolean>): void {\n this.handleController.hostUpdate();\n if (changedProperties.has('disabled') && this.disabled) {\n this.handleController.cancelDrag();\n }\n super.update(changedProperties);\n }\n\n private renderLabel(): TemplateResult {\n const textLabelVisible =\n this.labelVisibility === 'none' || this.labelVisibility === 'value';\n const valueLabelVisible =\n this.labelVisibility === 'none' || this.labelVisibility === 'text';\n return html`\n <div id=\"label-container\">\n <sp-field-label\n class=${classMap({\n 'visually-hidden': textLabelVisible,\n })}\n ?disabled=${this.disabled}\n id=\"label\"\n for=${this.editable\n ? 'number-field'\n : this.handleController.activeHandleInputId}\n @click=${this.handleLabelClick}\n >\n ${this.slotHasContent ? html`` : this.label}\n <slot>${this.label}</slot>\n </sp-field-label>\n <output\n class=${classMap({\n 'visually-hidden': valueLabelVisible,\n })}\n id=\"value\"\n aria-live=\"off\"\n for=\"input\"\n >\n ${this.ariaValueText}\n </output>\n </div>\n `;\n }\n\n private renderRamp(): TemplateResult {\n if (this.variant !== 'ramp') {\n return html``;\n }\n return html`\n <div id=\"ramp\">\n <svg\n viewBox=\"0 0 240 16\"\n preserveAspectRatio=\"none\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path\n d=\"M240,4v8c0,2.3-1.9,4.1-4.2,4L1,9C0.4,9,0,8.5,0,8c0-0.5,0.4-1,1-1l234.8-7C238.1-0.1,240,1.7,240,4z\"\n ></path>\n </svg>\n </div>\n `;\n }\n\n private renderTicks(): TemplateResult {\n if (this.variant !== 'tick') {\n return html``;\n }\n const tickStep = this.tickStep || this.step;\n const tickCount =\n ((this.max as number) - (this.min as number)) / tickStep;\n const partialFit = tickCount % 1 !== 0;\n const ticks = new Array(Math.floor(tickCount + 1));\n ticks.fill(0, 0, tickCount + 1);\n return html`\n <div\n class=\"${partialFit ? 'not-exact ' : ''}ticks\"\n style=${ifDefined(\n partialFit\n ? `--sp-slider-tick-offset: calc(100% / ${this.max} * ${this.tickStep}`\n : undefined\n )}\n >\n ${ticks.map(\n (_tick, i) => html`\n <div class=\"tick\">\n ${this.tickLabels\n ? html`\n <div class=\"tickLabel\">\n ${i * tickStep + this.min}\n </div>\n `\n : html``}\n </div>\n `\n )}\n </div>\n `;\n }\n\n private renderTrackSegment(start: number, end: number): TemplateResult {\n if (this.variant === 'ramp') {\n return html``;\n }\n return html`\n <div\n class=\"track\"\n style=${styleMap(this.trackSegmentStyles(start, end))}\n role=\"presentation\"\n ></div>\n `;\n }\n\n private renderTrack(): TemplateResult {\n const segments = this.handleController.trackSegments();\n\n const trackItems = [\n { id: 'track0', html: this.renderTrackSegment(...segments[0]) },\n { id: 'ramp', html: this.renderRamp() },\n { id: 'ticks', html: this.renderTicks() },\n { id: 'handles', html: this.handleController.render() },\n ...segments.slice(1).map(([start, end], index) => ({\n id: `track${index + 1}`,\n html: this.renderTrackSegment(start, end),\n })),\n ];\n\n return html`\n <div\n id=\"track\"\n ${streamingListener({\n start: ['pointerdown', this.handlePointerdown],\n streamInside: ['pointermove', this.handlePointermove],\n end: [['pointerup', 'pointercancel'], this.handlePointerup],\n })}\n >\n <div id=\"controls\">\n ${repeat(\n trackItems,\n (item) => item.id,\n (item) => item.html\n )}\n </div>\n </div>\n `;\n }\n\n protected handlePointerdown(event: PointerEvent): void {\n this.handleController.handlePointerdown(event);\n }\n\n protected handlePointermove(event: PointerEvent): void {\n this.handleController.handlePointermove(event);\n }\n\n protected handlePointerup(event: PointerEvent): void {\n this.handleController.handlePointerup(event);\n }\n\n private handleNumberInput(event: Event & { target: NumberField }): void {\n const { value } = event.target;\n if (event.target?.stepperActive && !isNaN(value)) {\n this.value = value;\n return;\n }\n // Do not apply uncommited values to the parent element unless interacting with the stepper UI.\n // Stop uncommited input from being annoucned to the parent application.\n event.stopPropagation();\n }\n\n private handleNumberChange(event: Event & { target: NumberField }): void {\n const { value } = event.target;\n if (isNaN(value)) {\n event.target.value = this.value;\n event.stopPropagation();\n } else {\n this.value = value;\n if (!event.target?.stepperActive) {\n // When stepper is not active, sythesize an `input` event so that the\n // `change` event isn't surprising.\n this.dispatchInputEvent();\n }\n }\n this.indeterminate = false;\n }\n\n private trackSegmentStyles(start: number, end: number): StyleInfo {\n const size = end - start;\n const styles: StyleInfo = {\n width: `${size * 100}%`,\n '--spectrum-slider-track-background-size': `${(1 / size) * 100}%`,\n '--spectrum-slider-track-segment-position': `${start * 100}%`,\n };\n return styles;\n }\n\n private _numberFieldInput: Promise<unknown> = Promise.resolve();\n\n protected override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n if (this.editable) {\n await this._numberFieldInput;\n await this.numberField.updateComplete;\n }\n await this.handleController.handleUpdatesComplete();\n return complete;\n }\n}\n"],
|
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