@lushly-dev/violet-elements 0.2.0-preview.3 → 0.2.0-preview.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/custom-elements.json +54 -3
- package/dist/alert/violet-alert.js +2 -1
- package/dist/alert/violet-alert.js.map +1 -1
- package/dist/badge/violet-badge.js +3 -1
- package/dist/badge/violet-badge.js.map +1 -1
- package/dist/color-picker/violet-color-picker.js +11 -6
- package/dist/color-picker/violet-color-picker.js.map +1 -1
- package/dist/combobox/violet-combobox.js +9 -5
- package/dist/combobox/violet-combobox.js.map +1 -1
- package/dist/conversation/violet-approval-card.js +4 -4
- package/dist/conversation/violet-approval-card.js.map +1 -1
- package/dist/conversation/violet-chat-composer.js +2 -2
- package/dist/conversation/violet-chat-composer.js.map +1 -1
- package/dist/conversation/violet-chat-suggestions.js +5 -5
- package/dist/conversation/violet-chat-suggestions.js.map +1 -1
- package/dist/conversation/violet-conversation-thread.js +1 -1
- package/dist/conversation/violet-conversation-thread.js.map +1 -1
- package/dist/conversation/violet-message-media.js +4 -4
- package/dist/conversation/violet-message-media.js.map +1 -1
- package/dist/conversation/violet-message-status.js +6 -6
- package/dist/conversation/violet-message-status.js.map +1 -1
- package/dist/conversation/violet-message.js +5 -5
- package/dist/conversation/violet-message.js.map +1 -1
- package/dist/conversation/violet-reasoning-block.js +4 -4
- package/dist/conversation/violet-reasoning-block.js.map +1 -1
- package/dist/conversation/violet-source-citation.js +7 -7
- package/dist/conversation/violet-source-citation.js.map +1 -1
- package/dist/conversation/violet-tool-call-card.js +14 -14
- package/dist/conversation/violet-tool-call-card.js.map +1 -1
- package/dist/conversation/violet-tool-result-card.js +6 -6
- package/dist/conversation/violet-tool-result-card.js.map +1 -1
- package/dist/data-grid/violet-data-grid-multi-picker.js +9 -5
- package/dist/data-grid/violet-data-grid-multi-picker.js.map +1 -1
- package/dist/data-grid/violet-data-grid-persona-picker.js +9 -5
- package/dist/data-grid/violet-data-grid-persona-picker.js.map +1 -1
- package/dist/data-grid/violet-data-grid-pill-select.js +9 -5
- package/dist/data-grid/violet-data-grid-pill-select.js.map +1 -1
- package/dist/data-grid/violet-data-grid-reference-picker.js +9 -5
- package/dist/data-grid/violet-data-grid-reference-picker.js.map +1 -1
- package/dist/data-grid/violet-data-grid.styles.js +4 -1
- package/dist/data-grid/violet-data-grid.styles.js.map +1 -1
- package/dist/file-upload/violet-file-upload.d.ts +1 -0
- package/dist/file-upload/violet-file-upload.js +13 -10
- package/dist/file-upload/violet-file-upload.js.map +1 -1
- package/dist/icon/icon-registry.js +19 -0
- package/dist/icon/icon-registry.js.map +1 -1
- package/dist/listbox/violet-listbox.js +2 -5
- package/dist/listbox/violet-listbox.js.map +1 -1
- package/dist/option/violet-option.d.ts +3 -1
- package/dist/option/violet-option.js +22 -7
- package/dist/option/violet-option.js.map +1 -1
- package/dist/progress/violet-progress.js +15 -1
- package/dist/progress/violet-progress.js.map +1 -1
- package/dist/select/violet-select.js +10 -5
- package/dist/select/violet-select.js.map +1 -1
- package/dist/skeleton/violet-skeleton.js +3 -1
- package/dist/skeleton/violet-skeleton.js.map +1 -1
- package/dist/tab/violet-tab.js +3 -3
- package/dist/tab/violet-tab.js.map +1 -1
- package/dist/tab-panel/violet-tab-panel.js +14 -2
- package/dist/tab-panel/violet-tab-panel.js.map +1 -1
- package/dist/tabs/violet-tabs.d.ts +5 -0
- package/dist/tabs/violet-tabs.js +13 -5
- package/dist/tabs/violet-tabs.js.map +1 -1
- package/dist/teaching-tip/violet-teaching-tip.js +1 -1
- package/dist/teaching-tip/violet-teaching-tip.js.map +1 -1
- package/dist/text-area/violet-text-area.js +5 -0
- package/dist/text-area/violet-text-area.js.map +1 -1
- package/dist/text-field/violet-text-field.js +5 -0
- package/dist/text-field/violet-text-field.js.map +1 -1
- package/dist/theme/generated/violet-theme.generated.d.ts +15 -15
- package/dist/theme/generated/violet-theme.generated.js +15 -15
- package/dist/theme/generated/violet-theme.generated.js.map +1 -1
- package/dist/theme/violet-theme-runtime.js +28 -5
- package/dist/theme/violet-theme-runtime.js.map +1 -1
- package/package.json +6 -6
- package/tokens/raw-palette.proposal.jsonc +84 -81
- package/tokens/violet-theme.export.json +15 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"violet-listbox.js","sourceRoot":"","sources":["../../src/listbox/violet-listbox.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEpF,OAAO,qCAAqC,CAAC;AAC7C,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EACH,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,mBAAmB,GACtB,MAAM,4BAA4B,CAAC;AAEpC,IAAI,eAAe,GAAG,CAAC,CAAC;AAExB,MAAM,MAAM,GAAG,GAAG,CAAA;MACZ,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyD/B,CAAC;AAEF,MAAM,QAAQ,GAAG,IAAI,CAAe;;cAEtB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;;;;oBAIV,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;yBACzB,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;gCAChB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;sBAC3C,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,YAAY,CAAC,YAAY,CAA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CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC;QAC/E,CAAC;IACL,CAAC;CACJ;AAzQkB;IADd,UAAU;kDACwB;AASpB;IADd,UAAU;qDAC6B;AAkQ5C,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACvC,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACvC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,aAAa,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAC/D,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,aAAa,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAC/D,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,yBAAyB,EAAE,CAAC,CAAC,aAAa,CAAC,SAAS,EAAE,uBAAuB,CAAC,CAAC;AAElH,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,CAAC;IACxC,MAAM,WAAW,CAAC,MAAM,CAAC,aAAa,EAAE;QACpC,IAAI,EAAE,gBAAgB;QACtB,QAAQ;QACR,MAAM;QACN,aAAa,EAAE;YACX,cAAc,EAAE,IAAI;SACvB;KACJ,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { FASTElement, attr, css, html, observable } from \"@lushly-dev/fast-element\";\n\nimport \"../option-group/violet-option-group\";\nimport \"../option/violet-option\";\nimport type { VioletOption } from \"../option/violet-option\";\nimport { violetSurfaceTokenDefaults } from \"../theme/violet-token-defaults\";\nimport {\n findTypeaheadMatch,\n getEnabledOptions,\n getNextEnabledIndex,\n getOwnedOptions,\n getSelectedOption,\n syncOptionSelection,\n} from \"./violet-selection-helpers\";\n\nlet violetListboxId = 0;\n\nconst styles = css`\n ${violetSurfaceTokenDefaults}\n\n :host {\n display: grid;\n --_panel-min-inline: var(--violet-listbox-min-inline-size, 14rem);\n --_panel-max-block: var(--violet-listbox-max-block-size, 18rem);\n /* The surface block has no inline spacing; the panel's padding is the menu's and the select popup's. */\n --_space-inline-sm: var(--space-inline-sm, 4px);\n --_panel-padding: var(--violet-listbox-padding, var(--_space-inline-sm));\n }\n\n .control {\n box-sizing: border-box;\n display: grid;\n gap: 2px;\n min-inline-size: var(--_panel-min-inline);\n max-block-size: min(var(--_panel-max-block), 70vh);\n overflow: auto;\n padding: var(--_panel-padding);\n /* The shadow is the edge. The border is kept, clear, for forced colours. */\n border: 1px solid transparent;\n border-radius: var(--_radius-lg);\n background: var(--_surface-card);\n box-shadow: var(--_shadow-card);\n outline: none;\n }\n\n .control:focus-visible {\n box-shadow:\n var(--_shadow-card),\n 0 0 0 2px var(--_focus-ring);\n }\n\n /* The keys are in this list while it has focus, so its active row draws its ring. */\n .control:focus-visible ::slotted(violet-option) {\n --violet-option-active-ring: color-mix(in srgb, var(--_focus-ring) 55%, transparent);\n }\n\n :host([disabled]) .control {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n @media (forced-colors: active) {\n .control {\n forced-color-adjust: none;\n border-color: ButtonText;\n background: Canvas;\n color: ButtonText;\n box-shadow: none;\n }\n\n .control:focus-visible {\n border-color: Highlight;\n box-shadow: 0 0 0 2px Highlight;\n }\n }\n`;\n\nconst template = html<VioletListbox>`\n <div\n id=\"${x => x.listboxId}\"\n class=\"control\"\n part=\"control\"\n role=\"listbox\"\n tabindex=\"${x => (x.disabled ? \"-1\" : \"0\")}\"\n aria-disabled=\"${x => String(x.disabled)}\"\n aria-multiselectable=\"${x => (x.multiple ? \"true\" : null)}\"\n aria-label=\"${x => x.label || x.getAttribute(\"aria-label\") || \"Options\"}\"\n @focus=\"${x => x.handleFocus()}\"\n @keydown=\"${(x, c) => x.handleKeydown(c.event as KeyboardEvent)}\"\n >\n <slot @slotchange=\"${x => x.handleSlotChange()}\"></slot>\n </div>\n`;\n\n/**\n * Violet reusable listbox primitive.\n *\n * @summary Always-visible list of options for choosing one, or several with multiple.\n * @slot - The options: violet-option and violet-option-group elements.\n * @fires input - Emitted when the selection changes.\n * @fires change - Emitted when the selection changes.\n * @csspart control - The focusable list element.\n */\nexport class VioletListbox extends FASTElement {\n @observable\n declare public activeValue: string;\n\n declare public label: string;\n declare public value: string;\n declare public disabled: boolean;\n declare public multiple: boolean;\n declare public selectionFollowsFocus: boolean;\n\n @observable\n declare public selectedValues: string[];\n\n public readonly listboxId: string;\n\n #typeaheadBuffer = \"\";\n #typeaheadTimer = 0;\n\n public constructor() {\n super();\n violetListboxId += 1;\n this.listboxId = `violet-listbox-${violetListboxId}`;\n this.label = \"\";\n this.value = \"\";\n this.activeValue = \"\";\n this.selectedValues = [];\n this.disabled = false;\n this.multiple = false;\n this.selectionFollowsFocus = false;\n }\n\n public connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener(\"request-select\", this.handleRequestSelect as EventListener);\n this.handleSlotChange();\n }\n\n public disconnectedCallback(): void {\n this.removeEventListener(\"request-select\", this.handleRequestSelect as EventListener);\n super.disconnectedCallback();\n }\n\n public get options(): VioletOption[] {\n return getOwnedOptions(this);\n }\n\n public get activeOptionId(): string {\n return this.options.find(option => option.value === this.activeValue)?.optionId ?? \"\";\n }\n\n public handleSlotChange(): void {\n const enabled = getEnabledOptions(this.options);\n if (this.multiple) {\n const derivedSelected =\n this.selectedValues.length > 0\n ? this.selectedValues.filter(value => enabled.some(option => option.value === value))\n : this.options.filter(option => option.selected && enabled.some(candidate => candidate === option)).map(option => option.value);\n\n this.selectedValues = derivedSelected;\n this.value = this.selectedValues[0] ?? \"\";\n\n if (!this.activeValue || !enabled.some(option => option.value === this.activeValue)) {\n this.activeValue = this.selectedValues[0] ?? enabled[0]?.value ?? \"\";\n }\n } else {\n const selected = getSelectedOption(this.options, this.value);\n const fallbackActive = selected?.value ?? enabled[0]?.value ?? \"\";\n\n if (!this.value && selected) {\n this.value = selected.value;\n }\n\n this.selectedValues = this.value ? [this.value] : [];\n\n if (!this.activeValue || !enabled.some(option => option.value === this.activeValue)) {\n this.activeValue = fallbackActive;\n }\n }\n\n this.#syncOptions();\n }\n\n public handleFocus(): void {\n if (this.disabled) {\n return;\n }\n\n if (!this.activeValue) {\n const selected = this.multiple\n ? this.selectedValues[0]\n : getSelectedOption(this.options, this.value)?.value;\n this.activeValue = selected ?? getEnabledOptions(this.options)[0]?.value ?? \"\";\n }\n\n this.#syncOptions();\n this.#scrollActiveIntoView();\n }\n\n public handleKeydown(event: KeyboardEvent): boolean {\n if (this.disabled) {\n return true;\n }\n\n switch (event.key) {\n case \"ArrowDown\":\n event.preventDefault();\n this.#moveActive(1);\n return false;\n case \"ArrowUp\":\n event.preventDefault();\n this.#moveActive(-1);\n return false;\n case \"Home\":\n event.preventDefault();\n this.#setActive(getEnabledOptions(this.options)[0]?.value ?? \"\");\n return false;\n case \"End\": {\n event.preventDefault();\n const enabled = getEnabledOptions(this.options);\n this.#setActive(enabled.at(-1)?.value ?? \"\");\n return false;\n }\n case \"Enter\":\n case \" \":\n event.preventDefault();\n if (this.activeValue) {\n this.multiple ? this.toggleValue(this.activeValue) : this.selectValue(this.activeValue);\n }\n return false;\n case \"a\":\n case \"A\":\n if (this.multiple && (event.ctrlKey || event.metaKey)) {\n event.preventDefault();\n this.toggleAll();\n return false;\n }\n return true;\n default:\n if (event.key.length === 1 && !event.altKey && !event.ctrlKey && !event.metaKey) {\n this.#queueTypeahead(event.key);\n }\n return true;\n }\n }\n\n public handleRequestSelect(event: CustomEvent<{ value?: string }>): void {\n event.stopPropagation();\n\n const nextValue = event.detail?.value ?? \"\";\n this.multiple ? this.toggleValue(nextValue) : this.selectValue(nextValue);\n }\n\n public valueChanged(): void {\n if (!this.multiple) {\n this.selectedValues = this.value ? [this.value] : [];\n }\n this.#syncOptions();\n }\n\n public activeValueChanged(): void {\n this.#syncOptions();\n }\n\n public selectedValuesChanged(): void {\n if (this.multiple) {\n this.value = this.selectedValues[0] ?? \"\";\n }\n\n this.#syncOptions();\n }\n\n public selectValue(nextValue: string, emit = true): void {\n const option = getEnabledOptions(this.options).find(candidate => candidate.value === nextValue) ?? null;\n if (!option) {\n return;\n }\n\n this.value = option.value;\n this.activeValue = option.value;\n this.#syncOptions();\n\n if (emit) {\n this.$emit(\"input\", { value: this.value });\n this.$emit(\"change\", { value: this.value });\n }\n }\n\n public toggleValue(nextValue: string, emit = true): void {\n const option = getEnabledOptions(this.options).find(candidate => candidate.value === nextValue) ?? null;\n if (!option) {\n return;\n }\n\n const selected = new Set(this.selectedValues);\n if (selected.has(option.value)) {\n selected.delete(option.value);\n } else {\n selected.add(option.value);\n }\n\n this.selectedValues = this.options.filter(candidate => selected.has(candidate.value)).map(candidate => candidate.value);\n this.activeValue = option.value;\n this.#syncOptions();\n\n if (emit) {\n this.$emit(\"input\", { value: this.value, selectedValues: [...this.selectedValues] });\n this.$emit(\"change\", { value: this.value, selectedValues: [...this.selectedValues] });\n }\n }\n\n public toggleAll(): void {\n const enabled = getEnabledOptions(this.options);\n const allSelected = enabled.every(option => this.selectedValues.includes(option.value));\n\n this.selectedValues = allSelected ? [] : enabled.map(option => option.value);\n this.activeValue = enabled[0]?.value ?? \"\";\n this.#syncOptions();\n this.$emit(\"input\", { value: this.value, selectedValues: [...this.selectedValues] });\n this.$emit(\"change\", { value: this.value, selectedValues: [...this.selectedValues] });\n }\n\n #moveActive(step: 1 | -1): void {\n const options = this.options;\n const currentIndex = options.findIndex(option => option.value === this.activeValue);\n const nextIndex = getNextEnabledIndex(options, currentIndex < 0 ? (step === 1 ? -1 : 0) : currentIndex, step);\n const nextValue = options[nextIndex]?.value ?? \"\";\n\n this.#setActive(nextValue);\n }\n\n #setActive(nextValue: string): void {\n this.activeValue = nextValue;\n this.#syncOptions();\n this.#scrollActiveIntoView();\n\n if (!this.multiple && this.selectionFollowsFocus && nextValue) {\n this.selectValue(nextValue);\n }\n }\n\n #queueTypeahead(key: string): void {\n window.clearTimeout(this.#typeaheadTimer);\n this.#typeaheadBuffer = `${this.#typeaheadBuffer}${key.toLowerCase()}`;\n\n const match = findTypeaheadMatch(this.options, this.#typeaheadBuffer, this.activeValue);\n if (match) {\n this.#setActive(match.value);\n }\n\n this.#typeaheadTimer = window.setTimeout(() => {\n this.#typeaheadBuffer = \"\";\n }, 500);\n }\n\n #scrollActiveIntoView(): void {\n const active = this.options.find(option => option.value === this.activeValue);\n active?.shadowRoot?.querySelector('[part=\"control\"]')?.scrollIntoView({ block: \"nearest\" });\n }\n\n #syncOptions(): void {\n syncOptionSelection(this.options, this.multiple ? this.selectedValues : this.value, this.activeValue);\n const control = this.shadowRoot?.querySelector('[role=\"listbox\"]');\n if (control) {\n control.ariaActiveDescendantElement =\n this.options.find(option => option.value === this.activeValue) ?? null;\n }\n }\n}\n\nattr(VioletListbox.prototype, \"label\");\nattr(VioletListbox.prototype, \"value\");\nattr({ mode: \"boolean\" })(VioletListbox.prototype, \"disabled\");\nattr({ mode: \"boolean\" })(VioletListbox.prototype, \"multiple\");\nattr({ mode: \"boolean\", attribute: \"selection-follows-focus\" })(VioletListbox.prototype, \"selectionFollowsFocus\");\n\nif (!customElements.get(\"violet-listbox\")) {\n await FASTElement.define(VioletListbox, {\n name: \"violet-listbox\",\n template,\n styles,\n shadowOptions: {\n delegatesFocus: true,\n },\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"violet-listbox.js","sourceRoot":"","sources":["../../src/listbox/violet-listbox.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEpF,OAAO,qCAAqC,CAAC;AAC7C,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EACH,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,mBAAmB,GACtB,MAAM,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AE,CAAC,CAAC,aAAa,CAAC,SAAS,EAAE,uBAAuB,CAAC,CAAC;AAElH,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,CAAC;IACxC,MAAM,WAAW,CAAC,MAAM,CAAC,aAAa,EAAE;QACpC,IAAI,EAAE,gBAAgB;QACtB,QAAQ;QACR,MAAM;QACN,aAAa,EAAE;YACX,cAAc,EAAE,IAAI;SACvB;KACJ,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { FASTElement, attr, css, html, observable } from \"@lushly-dev/fast-element\";\n\nimport \"../option-group/violet-option-group\";\nimport \"../option/violet-option\";\nimport type { VioletOption } from \"../option/violet-option\";\nimport { violetSurfaceTokenDefaults } from \"../theme/violet-token-defaults\";\nimport {\n findTypeaheadMatch,\n getEnabledOptions,\n getNextEnabledIndex,\n getOwnedOptions,\n getSelectedOption,\n syncOptionSelection,\n} from \"./violet-selection-helpers\";\n\nlet violetListboxId = 0;\n\nconst styles = css`\n ${violetSurfaceTokenDefaults}\n\n :host {\n display: grid;\n --_panel-min-inline: var(--violet-listbox-min-inline-size, 14rem);\n --_panel-max-block: var(--violet-listbox-max-block-size, 18rem);\n /* The surface block has no inline spacing; the panel's padding is the menu's and the select popup's. */\n --_space-inline-sm: var(--space-inline-sm, 4px);\n --_panel-padding: var(--violet-listbox-padding, var(--_space-inline-sm));\n }\n\n .control {\n box-sizing: border-box;\n display: grid;\n gap: 2px;\n min-inline-size: var(--_panel-min-inline);\n max-block-size: min(var(--_panel-max-block), 70vh);\n overflow: auto;\n padding: var(--_panel-padding);\n /* The shadow is the edge. The border is kept, clear, for forced colours. */\n border: 1px solid transparent;\n border-radius: var(--_radius-lg);\n background: var(--_surface-card);\n box-shadow: var(--_shadow-card);\n outline: none;\n }\n\n .control:focus-visible {\n /* The keys are in this list while it has focus, so its active row draws its ring at >= 3:1. */\n --_option-active-ring: var(--_focus-ring);\n box-shadow:\n var(--_shadow-card),\n 0 0 0 2px var(--_focus-ring);\n }\n\n :host([disabled]) .control {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n @media (forced-colors: active) {\n .control {\n forced-color-adjust: none;\n border-color: ButtonText;\n background: Canvas;\n color: ButtonText;\n box-shadow: none;\n }\n\n .control:focus-visible {\n border-color: Highlight;\n box-shadow: 0 0 0 2px Highlight;\n }\n }\n`;\n\nconst template = html<VioletListbox>`\n <div\n id=\"${x => x.listboxId}\"\n class=\"control\"\n part=\"control\"\n role=\"listbox\"\n tabindex=\"${x => (x.disabled ? \"-1\" : \"0\")}\"\n aria-disabled=\"${x => String(x.disabled)}\"\n aria-multiselectable=\"${x => (x.multiple ? \"true\" : null)}\"\n aria-label=\"${x => x.label || x.getAttribute(\"aria-label\") || \"Options\"}\"\n @focus=\"${x => x.handleFocus()}\"\n @keydown=\"${(x, c) => x.handleKeydown(c.event as KeyboardEvent)}\"\n >\n <slot @slotchange=\"${x => x.handleSlotChange()}\"></slot>\n </div>\n`;\n\n/**\n * Violet reusable listbox primitive.\n *\n * @summary Always-visible list of options for choosing one, or several with multiple.\n * @slot - The options: violet-option and violet-option-group elements.\n * @fires input - Emitted when the selection changes.\n * @fires change - Emitted when the selection changes.\n * @csspart control - The focusable list element.\n */\nexport class VioletListbox extends FASTElement {\n @observable\n declare public activeValue: string;\n\n declare public label: string;\n declare public value: string;\n declare public disabled: boolean;\n declare public multiple: boolean;\n declare public selectionFollowsFocus: boolean;\n\n @observable\n declare public selectedValues: string[];\n\n public readonly listboxId: string;\n\n #typeaheadBuffer = \"\";\n #typeaheadTimer = 0;\n\n public constructor() {\n super();\n violetListboxId += 1;\n this.listboxId = `violet-listbox-${violetListboxId}`;\n this.label = \"\";\n this.value = \"\";\n this.activeValue = \"\";\n this.selectedValues = [];\n this.disabled = false;\n this.multiple = false;\n this.selectionFollowsFocus = false;\n }\n\n public connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener(\"request-select\", this.handleRequestSelect as EventListener);\n this.handleSlotChange();\n }\n\n public disconnectedCallback(): void {\n this.removeEventListener(\"request-select\", this.handleRequestSelect as EventListener);\n super.disconnectedCallback();\n }\n\n public get options(): VioletOption[] {\n return getOwnedOptions(this);\n }\n\n public get activeOptionId(): string {\n return this.options.find(option => option.value === this.activeValue)?.optionId ?? \"\";\n }\n\n public handleSlotChange(): void {\n const enabled = getEnabledOptions(this.options);\n if (this.multiple) {\n const derivedSelected =\n this.selectedValues.length > 0\n ? this.selectedValues.filter(value => enabled.some(option => option.value === value))\n : this.options.filter(option => option.selected && enabled.some(candidate => candidate === option)).map(option => option.value);\n\n this.selectedValues = derivedSelected;\n this.value = this.selectedValues[0] ?? \"\";\n\n if (!this.activeValue || !enabled.some(option => option.value === this.activeValue)) {\n this.activeValue = this.selectedValues[0] ?? enabled[0]?.value ?? \"\";\n }\n } else {\n const selected = getSelectedOption(this.options, this.value);\n const fallbackActive = selected?.value ?? enabled[0]?.value ?? \"\";\n\n if (!this.value && selected) {\n this.value = selected.value;\n }\n\n this.selectedValues = this.value ? [this.value] : [];\n\n if (!this.activeValue || !enabled.some(option => option.value === this.activeValue)) {\n this.activeValue = fallbackActive;\n }\n }\n\n this.#syncOptions();\n }\n\n public handleFocus(): void {\n if (this.disabled) {\n return;\n }\n\n if (!this.activeValue) {\n const selected = this.multiple\n ? this.selectedValues[0]\n : getSelectedOption(this.options, this.value)?.value;\n this.activeValue = selected ?? getEnabledOptions(this.options)[0]?.value ?? \"\";\n }\n\n this.#syncOptions();\n this.#scrollActiveIntoView();\n }\n\n public handleKeydown(event: KeyboardEvent): boolean {\n if (this.disabled) {\n return true;\n }\n\n switch (event.key) {\n case \"ArrowDown\":\n event.preventDefault();\n this.#moveActive(1);\n return false;\n case \"ArrowUp\":\n event.preventDefault();\n this.#moveActive(-1);\n return false;\n case \"Home\":\n event.preventDefault();\n this.#setActive(getEnabledOptions(this.options)[0]?.value ?? \"\");\n return false;\n case \"End\": {\n event.preventDefault();\n const enabled = getEnabledOptions(this.options);\n this.#setActive(enabled.at(-1)?.value ?? \"\");\n return false;\n }\n case \"Enter\":\n case \" \":\n event.preventDefault();\n if (this.activeValue) {\n this.multiple ? this.toggleValue(this.activeValue) : this.selectValue(this.activeValue);\n }\n return false;\n case \"a\":\n case \"A\":\n if (this.multiple && (event.ctrlKey || event.metaKey)) {\n event.preventDefault();\n this.toggleAll();\n return false;\n }\n return true;\n default:\n if (event.key.length === 1 && !event.altKey && !event.ctrlKey && !event.metaKey) {\n this.#queueTypeahead(event.key);\n }\n return true;\n }\n }\n\n public handleRequestSelect(event: CustomEvent<{ value?: string }>): void {\n event.stopPropagation();\n\n const nextValue = event.detail?.value ?? \"\";\n this.multiple ? this.toggleValue(nextValue) : this.selectValue(nextValue);\n }\n\n public valueChanged(): void {\n if (!this.multiple) {\n this.selectedValues = this.value ? [this.value] : [];\n }\n this.#syncOptions();\n }\n\n public activeValueChanged(): void {\n this.#syncOptions();\n }\n\n public selectedValuesChanged(): void {\n if (this.multiple) {\n this.value = this.selectedValues[0] ?? \"\";\n }\n\n this.#syncOptions();\n }\n\n public selectValue(nextValue: string, emit = true): void {\n const option = getEnabledOptions(this.options).find(candidate => candidate.value === nextValue) ?? null;\n if (!option) {\n return;\n }\n\n this.value = option.value;\n this.activeValue = option.value;\n this.#syncOptions();\n\n if (emit) {\n this.$emit(\"input\", { value: this.value });\n this.$emit(\"change\", { value: this.value });\n }\n }\n\n public toggleValue(nextValue: string, emit = true): void {\n const option = getEnabledOptions(this.options).find(candidate => candidate.value === nextValue) ?? null;\n if (!option) {\n return;\n }\n\n const selected = new Set(this.selectedValues);\n if (selected.has(option.value)) {\n selected.delete(option.value);\n } else {\n selected.add(option.value);\n }\n\n this.selectedValues = this.options.filter(candidate => selected.has(candidate.value)).map(candidate => candidate.value);\n this.activeValue = option.value;\n this.#syncOptions();\n\n if (emit) {\n this.$emit(\"input\", { value: this.value, selectedValues: [...this.selectedValues] });\n this.$emit(\"change\", { value: this.value, selectedValues: [...this.selectedValues] });\n }\n }\n\n public toggleAll(): void {\n const enabled = getEnabledOptions(this.options);\n const allSelected = enabled.every(option => this.selectedValues.includes(option.value));\n\n this.selectedValues = allSelected ? [] : enabled.map(option => option.value);\n this.activeValue = enabled[0]?.value ?? \"\";\n this.#syncOptions();\n this.$emit(\"input\", { value: this.value, selectedValues: [...this.selectedValues] });\n this.$emit(\"change\", { value: this.value, selectedValues: [...this.selectedValues] });\n }\n\n #moveActive(step: 1 | -1): void {\n const options = this.options;\n const currentIndex = options.findIndex(option => option.value === this.activeValue);\n const nextIndex = getNextEnabledIndex(options, currentIndex < 0 ? (step === 1 ? -1 : 0) : currentIndex, step);\n const nextValue = options[nextIndex]?.value ?? \"\";\n\n this.#setActive(nextValue);\n }\n\n #setActive(nextValue: string): void {\n this.activeValue = nextValue;\n this.#syncOptions();\n this.#scrollActiveIntoView();\n\n if (!this.multiple && this.selectionFollowsFocus && nextValue) {\n this.selectValue(nextValue);\n }\n }\n\n #queueTypeahead(key: string): void {\n window.clearTimeout(this.#typeaheadTimer);\n this.#typeaheadBuffer = `${this.#typeaheadBuffer}${key.toLowerCase()}`;\n\n const match = findTypeaheadMatch(this.options, this.#typeaheadBuffer, this.activeValue);\n if (match) {\n this.#setActive(match.value);\n }\n\n this.#typeaheadTimer = window.setTimeout(() => {\n this.#typeaheadBuffer = \"\";\n }, 500);\n }\n\n #scrollActiveIntoView(): void {\n const active = this.options.find(option => option.value === this.activeValue);\n active?.shadowRoot?.querySelector('[part=\"control\"]')?.scrollIntoView({ block: \"nearest\" });\n }\n\n #syncOptions(): void {\n syncOptionSelection(this.options, this.multiple ? this.selectedValues : this.value, this.activeValue);\n const control = this.shadowRoot?.querySelector('[role=\"listbox\"]');\n if (control) {\n control.ariaActiveDescendantElement =\n this.options.find(option => option.value === this.activeValue) ?? null;\n }\n }\n}\n\nattr(VioletListbox.prototype, \"label\");\nattr(VioletListbox.prototype, \"value\");\nattr({ mode: \"boolean\" })(VioletListbox.prototype, \"disabled\");\nattr({ mode: \"boolean\" })(VioletListbox.prototype, \"multiple\");\nattr({ mode: \"boolean\", attribute: \"selection-follows-focus\" })(VioletListbox.prototype, \"selectionFollowsFocus\");\n\nif (!customElements.get(\"violet-listbox\")) {\n await FASTElement.define(VioletListbox, {\n name: \"violet-listbox\",\n template,\n styles,\n shadowOptions: {\n delegatesFocus: true,\n },\n });\n}\n"]}
|
|
@@ -14,15 +14,17 @@ import { FASTElement } from "@lushly-dev/fast-element";
|
|
|
14
14
|
* @csspart label - Label wrapper.
|
|
15
15
|
* @csspart description - Description wrapper.
|
|
16
16
|
* @csspart after - Trailing slot wrapper.
|
|
17
|
+
* @cssproperty --violet-option-active-background - Background color of the active option row.
|
|
18
|
+
* @cssproperty --violet-option-active-ring - Inset ring color of the active option row when keyboard navigation is active.
|
|
17
19
|
*/
|
|
18
20
|
export declare class VioletOption extends FASTElement {
|
|
19
21
|
#private;
|
|
20
|
-
active: boolean;
|
|
21
22
|
hasDescription: boolean;
|
|
22
23
|
groupDisabled: boolean;
|
|
23
24
|
value: string;
|
|
24
25
|
label: string;
|
|
25
26
|
selected: boolean;
|
|
27
|
+
active: boolean;
|
|
26
28
|
disabled: boolean;
|
|
27
29
|
readonly optionId: string;
|
|
28
30
|
constructor();
|
|
@@ -22,6 +22,7 @@ const styles = css `
|
|
|
22
22
|
--_surface-selected: var(--color-surface-selected, #dfeae3);
|
|
23
23
|
--_option-mark: var(--color-control-selected-foreground, #2c5e4b);
|
|
24
24
|
--_option-mark-size: 0.6875rem;
|
|
25
|
+
--_focus-ring-width: var(--size-focus-ring-width, 2px);
|
|
25
26
|
--_control-caption-size: var(--violet-control-caption-size, var(--type-caption-xs-size, 12px));
|
|
26
27
|
--_type-caption-line: var(--type-caption-xs-line, 16px);
|
|
27
28
|
--_option-padding-inline-start: var(--violet-option-padding-inline-start, calc(var(--_space-inline-md) * 1.5));
|
|
@@ -54,9 +55,10 @@ const styles = css `
|
|
|
54
55
|
|
|
55
56
|
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
|
|
59
|
+
:host([active]) .control {
|
|
60
|
+
background: var(--violet-option-active-background, var(--_surface-active));
|
|
61
|
+
box-shadow: inset 0 0 0 var(--_focus-ring-width) var(--violet-option-active-ring, var(--_option-active-ring, transparent));
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
:host([selected]) .control {
|
|
@@ -64,6 +66,12 @@ const styles = css `
|
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
|
|
69
|
+
|
|
70
|
+
:host([active][selected]) .control {
|
|
71
|
+
background: var(--violet-option-active-background, var(--_surface-selected));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
67
75
|
:host([selected]) .control::after {
|
|
68
76
|
content: "";
|
|
69
77
|
position: absolute;
|
|
@@ -79,6 +87,11 @@ const styles = css `
|
|
|
79
87
|
background: var(--_surface-hover);
|
|
80
88
|
}
|
|
81
89
|
|
|
90
|
+
|
|
91
|
+
:host([active]) .control:not(.disabled):hover {
|
|
92
|
+
background: var(--violet-option-active-background, var(--_surface-hover));
|
|
93
|
+
}
|
|
94
|
+
|
|
82
95
|
.control.disabled {
|
|
83
96
|
color: var(--_text-secondary);
|
|
84
97
|
cursor: not-allowed;
|
|
@@ -126,7 +139,9 @@ const styles = css `
|
|
|
126
139
|
color: ButtonText;
|
|
127
140
|
}
|
|
128
141
|
|
|
129
|
-
.control
|
|
142
|
+
:host([active]) .control,
|
|
143
|
+
:host([active][selected]) .control,
|
|
144
|
+
:host([active]) .control:not(.disabled):hover,
|
|
130
145
|
:host([selected]) .control {
|
|
131
146
|
border-color: Highlight;
|
|
132
147
|
background: Highlight;
|
|
@@ -174,6 +189,8 @@ const template = html `
|
|
|
174
189
|
* @csspart label - Label wrapper.
|
|
175
190
|
* @csspart description - Description wrapper.
|
|
176
191
|
* @csspart after - Trailing slot wrapper.
|
|
192
|
+
* @cssproperty --violet-option-active-background - Background color of the active option row.
|
|
193
|
+
* @cssproperty --violet-option-active-ring - Inset ring color of the active option row when keyboard navigation is active.
|
|
177
194
|
*/
|
|
178
195
|
export class VioletOption extends FASTElement {
|
|
179
196
|
constructor() {
|
|
@@ -255,9 +272,6 @@ export class VioletOption extends FASTElement {
|
|
|
255
272
|
}
|
|
256
273
|
}
|
|
257
274
|
}
|
|
258
|
-
__decorate([
|
|
259
|
-
observable
|
|
260
|
-
], VioletOption.prototype, "active", void 0);
|
|
261
275
|
__decorate([
|
|
262
276
|
observable
|
|
263
277
|
], VioletOption.prototype, "hasDescription", void 0);
|
|
@@ -267,6 +281,7 @@ __decorate([
|
|
|
267
281
|
attr(VioletOption.prototype, "value");
|
|
268
282
|
attr(VioletOption.prototype, "label");
|
|
269
283
|
attr({ mode: "boolean" })(VioletOption.prototype, "selected");
|
|
284
|
+
attr({ mode: "boolean" })(VioletOption.prototype, "active");
|
|
270
285
|
attr({ mode: "boolean" })(VioletOption.prototype, "disabled");
|
|
271
286
|
if (!customElements.get("violet-option")) {
|
|
272
287
|
await FASTElement.define(VioletOption, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"violet-option.js","sourceRoot":"","sources":["../../src/option/violet-option.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEpF,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,IAAI,cAAc,GAAG,CAAC,CAAC;AAEvB,MAAM,MAAM,GAAG,GAAG,CAAA;MACZ,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsI9B,CAAC;AAEF,MAAM,QAAQ,GAAG,IAAI,CAAc;;iBAElB,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAA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AAM,WAAW,CAAC,MAAM,CAAC,YAAY,EAAE;QACnC,IAAI,EAAE,eAAe;QACrB,QAAQ;QACR,MAAM;KACT,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { FASTElement, attr, css, html, observable } from \"@lushly-dev/fast-element\";\n\nimport { violetActionTokenDefaults } from \"../theme/violet-token-defaults\";\n\nlet violetOptionId = 0;\n\nconst styles = css`\n ${violetActionTokenDefaults}\n\n /* An author style beats the user agent's [hidden] rule, so a filtered-out option needs its own. */\n :host([hidden]) {\n display: none;\n }\n\n :host {\n display: block;\n --_surface-hover: var(--color-surface-subtle, #e9e5de);\n --_surface-active: var(--color-surface-subtle, #e9e5de);\n --_surface-selected: var(--color-surface-selected, #dfeae3);\n --_option-mark: var(--color-control-selected-foreground, #2c5e4b);\n --_option-mark-size: 0.6875rem;\n --_control-caption-size: var(--violet-control-caption-size, var(--type-caption-xs-size, 12px));\n --_type-caption-line: var(--type-caption-xs-line, 16px);\n --_option-padding-inline-start: var(--violet-option-padding-inline-start, calc(var(--_space-inline-md) * 1.5));\n --_option-padding-inline-end: var(--violet-option-padding-inline-end, calc(var(--_space-inline-md) * 1.5));\n }\n\n .control {\n box-sizing: border-box;\n display: grid;\n grid-template-columns: auto minmax(0, 1fr) auto;\n align-items: center;\n gap: var(--_space-inline-sm);\n position: relative;\n min-block-size: var(--_target-size);\n padding-inline-start: var(--_option-padding-inline-start);\n /* Room for the mark, so choosing a row does not move its text. */\n padding-inline-end: calc(var(--_option-padding-inline-end) + 1.25rem);\n padding-block: var(--_space-inline-sm);\n border: 1px solid transparent;\n border-radius: var(--_radius-md);\n background: transparent;\n color: inherit;\n cursor: pointer;\n transition:\n background-color var(--_duration-fast) var(--_easing-standard),\n box-shadow var(--_duration-fast) var(--_easing-standard);\n }\n\n /*\n * The row the keys are on is tinted. Its ring is drawn only when the list that holds it says\n * the keyboard is there (--violet-option-active-ring), not on a list at rest.\n */\n .control.active {\n background: var(--_surface-active);\n box-shadow: inset 0 0 0 1px var(--violet-option-active-ring, transparent);\n }\n\n :host([selected]) .control {\n background: var(--_surface-selected);\n }\n\n /* Chosen is marked, not only tinted. */\n :host([selected]) .control::after {\n content: \"\";\n position: absolute;\n inset-inline-end: calc(var(--_option-padding-inline-end) - 2px);\n inset-block-start: calc(var(--_space-inline-sm) + (var(--_type-body-line) - var(--_option-mark-size)) / 2);\n inline-size: var(--_option-mark-size);\n block-size: var(--_option-mark-size);\n background: var(--_option-mark);\n clip-path: polygon(14% 44%, 0 59%, 37% 100%, 100% 16%, 84% 0, 35% 62%);\n }\n\n .control:not(.disabled):hover {\n background: var(--_surface-hover);\n }\n\n .control.disabled {\n color: var(--_text-secondary);\n cursor: not-allowed;\n opacity: 0.5;\n }\n\n .before,\n .after {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-inline-size: 0;\n }\n\n .content {\n display: grid;\n min-inline-size: 0;\n }\n\n .label {\n min-inline-size: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: var(--_control-body-size);\n line-height: var(--_type-body-line);\n }\n\n .description {\n color: var(--_text-muted);\n font-size: var(--_control-caption-size);\n line-height: var(--_type-caption-line);\n }\n\n /* Muted text fails 4.5:1 on the tinted selected surface; use secondary text there. */\n :host([selected]) .description {\n color: var(--_text-secondary);\n }\n\n @media (forced-colors: active) {\n .control {\n forced-color-adjust: none;\n border-color: transparent;\n background: Canvas;\n color: ButtonText;\n }\n\n .control.active,\n :host([selected]) .control {\n border-color: Highlight;\n background: Highlight;\n box-shadow: none;\n color: HighlightText;\n }\n\n :host([selected]) .control::after {\n background: HighlightText;\n }\n\n .control.disabled {\n color: GrayText;\n }\n }\n`;\n\nconst template = html<VioletOption>`\n <div\n class=\"${x => `control${x.active ? \" active\" : \"\"}${x.selected ? \" selected\" : \"\"}${x.isDisabled ? \" disabled\" : \"\"}`}\"\n part=\"control\"\n @click=\"${(x, c) => x.handleClick(c.event)}\"\n >\n <span class=\"before\" part=\"before\"><slot name=\"before\"></slot></span>\n <span class=\"content\" part=\"content\">\n <span class=\"label\" part=\"label\"><slot></slot></span>\n <span class=\"description\" part=\"description\" ?hidden=\"${x => !x.hasDescription}\">\n <slot name=\"description\" @slotchange=\"${x => x.handleDescriptionSlotChange()}\"></slot>\n </span>\n </span>\n <span class=\"after\" part=\"after\"><slot name=\"after\"></slot></span>\n </div>\n`;\n\n/**\n * Violet reusable option primitive.\n *\n * @summary One choice inside a violet-select, violet-combobox or violet-listbox.\n * @slot - The option's label text.\n * @slot before - Leading content such as an icon.\n * @slot description - Secondary text under the label.\n * @slot after - Trailing content such as a shortcut or count.\n * @fires request-select - Emitted when the option is chosen, for the list that owns it.\n * @csspart control - The option row.\n * @csspart before - Leading slot wrapper.\n * @csspart content - Wrapper around the label and description.\n * @csspart label - Label wrapper.\n * @csspart description - Description wrapper.\n * @csspart after - Trailing slot wrapper.\n */\nexport class VioletOption extends FASTElement {\n @observable\n declare public active: boolean;\n\n @observable\n declare public hasDescription: boolean;\n\n @observable\n declare public groupDisabled: boolean;\n\n declare public value: string;\n declare public label: string;\n declare public selected: boolean;\n declare public disabled: boolean;\n\n public readonly optionId: string;\n\n public constructor() {\n super();\n violetOptionId += 1;\n this.optionId = `violet-option-${violetOptionId}`;\n this.value = \"\";\n this.label = \"\";\n this.selected = false;\n this.active = false;\n this.disabled = false;\n this.groupDisabled = false;\n this.hasDescription = false;\n }\n\n public connectedCallback(): void {\n super.connectedCallback();\n this.id ||= this.optionId;\n this.setAttribute(\"role\", \"option\");\n this.#syncAriaState();\n this.handleDescriptionSlotChange();\n this.#syncDerivedValue();\n }\n\n public selectedChanged(): void {\n this.#syncAriaState();\n }\n\n public disabledChanged(): void {\n this.#syncAriaState();\n }\n\n public groupDisabledChanged(): void {\n this.#syncAriaState();\n }\n\n public labelChanged(): void {\n this.#syncDerivedValue();\n }\n\n public handleDescriptionSlotChange(): void {\n const slot = this.shadowRoot?.querySelector('slot[name=\"description\"]') as HTMLSlotElement | null;\n const assigned = slot?.assignedNodes({ flatten: true }).some((node: Node) => node.textContent?.trim());\n\n this.hasDescription = Boolean(assigned);\n }\n\n public handleClick(event: Event): void {\n if (this.isDisabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n this.$emit(\"request-select\", { value: this.value });\n }\n\n public get labelText(): string {\n if (this.label) {\n return this.label;\n }\n\n const unlottedText = Array.from(this.childNodes)\n .filter(node => !(node instanceof HTMLElement && node.slot))\n .map(node => node.textContent ?? \"\")\n .join(\" \")\n .replace(/\\s+/g, \" \")\n .trim();\n\n return unlottedText;\n }\n\n public get isDisabled(): boolean {\n return this.disabled || this.groupDisabled;\n }\n\n #syncDerivedValue(): void {\n if (!this.value) {\n this.value = this.labelText;\n }\n }\n\n #syncAriaState(): void {\n if (!this.isConnected) {\n return;\n }\n\n this.setAttribute(\"aria-selected\", String(this.selected));\n // An enabled option states nothing, so a disabled listbox's state reaches it.\n if (this.isDisabled) {\n this.setAttribute(\"aria-disabled\", \"true\");\n } else {\n this.removeAttribute(\"aria-disabled\");\n }\n }\n}\n\nattr(VioletOption.prototype, \"value\");\nattr(VioletOption.prototype, \"label\");\nattr({ mode: \"boolean\" })(VioletOption.prototype, \"selected\");\nattr({ mode: \"boolean\" })(VioletOption.prototype, \"disabled\");\n\nif (!customElements.get(\"violet-option\")) {\n await FASTElement.define(VioletOption, {\n name: \"violet-option\",\n template,\n styles,\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"violet-option.js","sourceRoot":"","sources":["../../src/option/violet-option.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEpF,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,IAAI,cAAc,GAAG,CAAC,CAAC;AAEvB,MAAM,MAAM,GAAG,GAAG,CAAA;MACZ,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AC,CAAC,YAAY,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAC9D,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAC5D,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAE9D,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC;IACvC,MAAM,WAAW,CAAC,MAAM,CAAC,YAAY,EAAE;QACnC,IAAI,EAAE,eAAe;QACrB,QAAQ;QACR,MAAM;KACT,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { FASTElement, attr, css, html, observable } from \"@lushly-dev/fast-element\";\n\nimport { violetActionTokenDefaults } from \"../theme/violet-token-defaults\";\n\nlet violetOptionId = 0;\n\nconst styles = css`\n ${violetActionTokenDefaults}\n\n /* An author style beats the user agent's [hidden] rule, so a filtered-out option needs its own. */\n :host([hidden]) {\n display: none;\n }\n\n :host {\n display: block;\n --_surface-hover: var(--color-surface-subtle, #e9e5de);\n --_surface-active: var(--color-surface-subtle, #e9e5de);\n --_surface-selected: var(--color-surface-selected, #dfeae3);\n --_option-mark: var(--color-control-selected-foreground, #2c5e4b);\n --_option-mark-size: 0.6875rem;\n --_focus-ring-width: var(--size-focus-ring-width, 2px);\n --_control-caption-size: var(--violet-control-caption-size, var(--type-caption-xs-size, 12px));\n --_type-caption-line: var(--type-caption-xs-line, 16px);\n --_option-padding-inline-start: var(--violet-option-padding-inline-start, calc(var(--_space-inline-md) * 1.5));\n --_option-padding-inline-end: var(--violet-option-padding-inline-end, calc(var(--_space-inline-md) * 1.5));\n }\n\n .control {\n box-sizing: border-box;\n display: grid;\n grid-template-columns: auto minmax(0, 1fr) auto;\n align-items: center;\n gap: var(--_space-inline-sm);\n position: relative;\n min-block-size: var(--_target-size);\n padding-inline-start: var(--_option-padding-inline-start);\n /* Room for the mark, so choosing a row does not move its text. */\n padding-inline-end: calc(var(--_option-padding-inline-end) + 1.25rem);\n padding-block: var(--_space-inline-sm);\n border: 1px solid transparent;\n border-radius: var(--_radius-md);\n background: transparent;\n color: inherit;\n cursor: pointer;\n transition:\n background-color var(--_duration-fast) var(--_easing-standard),\n box-shadow var(--_duration-fast) var(--_easing-standard);\n }\n\n /*\n * The row the keys are on is tinted. Its ring is drawn when the list that holds it says\n * the keyboard is there (--_option-active-ring), or when an author overrides\n * --violet-option-active-ring on the option or any ancestor.\n */\n :host([active]) .control {\n background: var(--violet-option-active-background, var(--_surface-active));\n box-shadow: inset 0 0 0 var(--_focus-ring-width) var(--violet-option-active-ring, var(--_option-active-ring, transparent));\n }\n\n :host([selected]) .control {\n background: var(--_surface-selected);\n }\n\n /* When an option is both active and selected, an explicit active-background hook wins;\n otherwise keep the selected fill so the committed choice stays recognizable. */\n :host([active][selected]) .control {\n background: var(--violet-option-active-background, var(--_surface-selected));\n }\n\n /* Chosen is marked, not only tinted. */\n :host([selected]) .control::after {\n content: \"\";\n position: absolute;\n inset-inline-end: calc(var(--_option-padding-inline-end) - 2px);\n inset-block-start: calc(var(--_space-inline-sm) + (var(--_type-body-line) - var(--_option-mark-size)) / 2);\n inline-size: var(--_option-mark-size);\n block-size: var(--_option-mark-size);\n background: var(--_option-mark);\n clip-path: polygon(14% 44%, 0 59%, 37% 100%, 100% 16%, 84% 0, 35% 62%);\n }\n\n .control:not(.disabled):hover {\n background: var(--_surface-hover);\n }\n\n /* Hovering the active row keeps an explicit active-background hook instead of replacing it. */\n :host([active]) .control:not(.disabled):hover {\n background: var(--violet-option-active-background, var(--_surface-hover));\n }\n\n .control.disabled {\n color: var(--_text-secondary);\n cursor: not-allowed;\n opacity: 0.5;\n }\n\n .before,\n .after {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-inline-size: 0;\n }\n\n .content {\n display: grid;\n min-inline-size: 0;\n }\n\n .label {\n min-inline-size: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: var(--_control-body-size);\n line-height: var(--_type-body-line);\n }\n\n .description {\n color: var(--_text-muted);\n font-size: var(--_control-caption-size);\n line-height: var(--_type-caption-line);\n }\n\n /* Muted text fails 4.5:1 on the tinted selected surface; use secondary text there. */\n :host([selected]) .description {\n color: var(--_text-secondary);\n }\n\n @media (forced-colors: active) {\n .control {\n forced-color-adjust: none;\n border-color: transparent;\n background: Canvas;\n color: ButtonText;\n }\n\n :host([active]) .control,\n :host([active][selected]) .control,\n :host([active]) .control:not(.disabled):hover,\n :host([selected]) .control {\n border-color: Highlight;\n background: Highlight;\n box-shadow: none;\n color: HighlightText;\n }\n\n :host([selected]) .control::after {\n background: HighlightText;\n }\n\n .control.disabled {\n color: GrayText;\n }\n }\n`;\n\nconst template = html<VioletOption>`\n <div\n class=\"${x => `control${x.active ? \" active\" : \"\"}${x.selected ? \" selected\" : \"\"}${x.isDisabled ? \" disabled\" : \"\"}`}\"\n part=\"control\"\n @click=\"${(x, c) => x.handleClick(c.event)}\"\n >\n <span class=\"before\" part=\"before\"><slot name=\"before\"></slot></span>\n <span class=\"content\" part=\"content\">\n <span class=\"label\" part=\"label\"><slot></slot></span>\n <span class=\"description\" part=\"description\" ?hidden=\"${x => !x.hasDescription}\">\n <slot name=\"description\" @slotchange=\"${x => x.handleDescriptionSlotChange()}\"></slot>\n </span>\n </span>\n <span class=\"after\" part=\"after\"><slot name=\"after\"></slot></span>\n </div>\n`;\n\n/**\n * Violet reusable option primitive.\n *\n * @summary One choice inside a violet-select, violet-combobox or violet-listbox.\n * @slot - The option's label text.\n * @slot before - Leading content such as an icon.\n * @slot description - Secondary text under the label.\n * @slot after - Trailing content such as a shortcut or count.\n * @fires request-select - Emitted when the option is chosen, for the list that owns it.\n * @csspart control - The option row.\n * @csspart before - Leading slot wrapper.\n * @csspart content - Wrapper around the label and description.\n * @csspart label - Label wrapper.\n * @csspart description - Description wrapper.\n * @csspart after - Trailing slot wrapper.\n * @cssproperty --violet-option-active-background - Background color of the active option row.\n * @cssproperty --violet-option-active-ring - Inset ring color of the active option row when keyboard navigation is active.\n */\nexport class VioletOption extends FASTElement {\n @observable\n declare public hasDescription: boolean;\n\n @observable\n declare public groupDisabled: boolean;\n\n declare public value: string;\n declare public label: string;\n declare public selected: boolean;\n declare public active: boolean;\n declare public disabled: boolean;\n\n public readonly optionId: string;\n\n public constructor() {\n super();\n violetOptionId += 1;\n this.optionId = `violet-option-${violetOptionId}`;\n this.value = \"\";\n this.label = \"\";\n this.selected = false;\n this.active = false;\n this.disabled = false;\n this.groupDisabled = false;\n this.hasDescription = false;\n }\n\n public connectedCallback(): void {\n super.connectedCallback();\n this.id ||= this.optionId;\n this.setAttribute(\"role\", \"option\");\n this.#syncAriaState();\n this.handleDescriptionSlotChange();\n this.#syncDerivedValue();\n }\n\n public selectedChanged(): void {\n this.#syncAriaState();\n }\n\n public disabledChanged(): void {\n this.#syncAriaState();\n }\n\n public groupDisabledChanged(): void {\n this.#syncAriaState();\n }\n\n public labelChanged(): void {\n this.#syncDerivedValue();\n }\n\n public handleDescriptionSlotChange(): void {\n const slot = this.shadowRoot?.querySelector('slot[name=\"description\"]') as HTMLSlotElement | null;\n const assigned = slot?.assignedNodes({ flatten: true }).some((node: Node) => node.textContent?.trim());\n\n this.hasDescription = Boolean(assigned);\n }\n\n public handleClick(event: Event): void {\n if (this.isDisabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n this.$emit(\"request-select\", { value: this.value });\n }\n\n public get labelText(): string {\n if (this.label) {\n return this.label;\n }\n\n const unlottedText = Array.from(this.childNodes)\n .filter(node => !(node instanceof HTMLElement && node.slot))\n .map(node => node.textContent ?? \"\")\n .join(\" \")\n .replace(/\\s+/g, \" \")\n .trim();\n\n return unlottedText;\n }\n\n public get isDisabled(): boolean {\n return this.disabled || this.groupDisabled;\n }\n\n #syncDerivedValue(): void {\n if (!this.value) {\n this.value = this.labelText;\n }\n }\n\n #syncAriaState(): void {\n if (!this.isConnected) {\n return;\n }\n\n this.setAttribute(\"aria-selected\", String(this.selected));\n // An enabled option states nothing, so a disabled listbox's state reaches it.\n if (this.isDisabled) {\n this.setAttribute(\"aria-disabled\", \"true\");\n } else {\n this.removeAttribute(\"aria-disabled\");\n }\n }\n}\n\nattr(VioletOption.prototype, \"value\");\nattr(VioletOption.prototype, \"label\");\nattr({ mode: \"boolean\" })(VioletOption.prototype, \"selected\");\nattr({ mode: \"boolean\" })(VioletOption.prototype, \"active\");\nattr({ mode: \"boolean\" })(VioletOption.prototype, \"disabled\");\n\nif (!customElements.get(\"violet-option\")) {\n await FASTElement.define(VioletOption, {\n name: \"violet-option\",\n template,\n styles,\n });\n}\n"]}
|
|
@@ -90,9 +90,23 @@ const styles = css `
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
@keyframes indeterminate-pulse {
|
|
94
|
+
0% {
|
|
95
|
+
opacity: 1;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
100% {
|
|
100
|
+
opacity: 0.75;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
|
|
93
105
|
@media (prefers-reduced-motion: reduce) {
|
|
94
106
|
:host([value=""]) .progress::before {
|
|
95
|
-
|
|
107
|
+
inset-inline-start: 0;
|
|
108
|
+
inline-size: 100%;
|
|
109
|
+
animation: indeterminate-pulse 1.6s ease-in-out infinite alternate;
|
|
96
110
|
}
|
|
97
111
|
}
|
|
98
112
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"violet-progress.js","sourceRoot":"","sources":["../../src/progress/violet-progress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAE1F,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAE1E,MAAM,MAAM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CAAC,aAAa,CAAC,CAAC;QAClD,MAAM,OAAO,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,OAAO,GAAG,OAAO,GAAG,CAAC;IACzB,CAAC;CACJ;AAED,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACxC,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACxC,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AACtC,IAAI,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAC,cAAc,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAEzE,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE,CAAC;IACzC,MAAM,WAAW,CAAC,MAAM,CAAC,cAAc,EAAE;QACrC,IAAI,EAAE,iBAAiB;QACvB,QAAQ;QACR,MAAM;KACT,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { FASTElement, Observable, attr, css, html, when } from \"@lushly-dev/fast-element\";\n\nimport { violetFieldTokenDefaults } from \"../theme/violet-token-defaults\";\n\nconst styles = css`\n ${violetFieldTokenDefaults}\n\n :host {\n display: grid;\n gap: var(--_space-stack-xs);\n color: var(--_text-secondary);\n --_progress-track-size: 6px;\n --_progress-radius: var(--radius-round, 9999px);\n --_progress-fill: var(--color-control-selected-foreground, #2c5e4b);\n /* The track is a well, filled to the value. */\n --_progress-track: color-mix(in srgb, var(--color-text-primary, #181b1a) 10%, transparent);\n }\n\n .header {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: var(--_space-inline-md);\n }\n\n .label,\n .value-label {\n margin: 0;\n font-size: var(--_control-label-size);\n line-height: var(--_type-label-line);\n }\n\n .label {\n color: var(--_text-secondary);\n font-weight: var(--_type-label-weight);\n }\n\n .value-label {\n color: var(--_text-muted);\n font-size: var(--_control-caption-size);\n font-variant-numeric: tabular-nums;\n }\n\n .progress {\n inline-size: 100%;\n block-size: var(--_progress-track-size);\n overflow: hidden;\n border: none;\n border-radius: var(--_progress-radius);\n background: var(--_progress-track);\n appearance: none;\n -webkit-appearance: none;\n }\n\n .progress::-webkit-progress-bar {\n background: var(--_progress-track);\n border-radius: var(--_progress-radius);\n }\n\n .progress::-webkit-progress-value {\n border-radius: var(--_progress-radius);\n background: var(--_progress-fill);\n }\n\n .progress::-moz-progress-bar {\n border-radius: var(--_progress-radius);\n background: var(--_progress-fill);\n }\n\n :host([value=\"\"]) .progress {\n position: relative;\n background: var(--_progress-track);\n }\n\n :host([value=\"\"]) .progress::before {\n content: \"\";\n position: absolute;\n inset-block: 0;\n inline-size: 35%;\n border-radius: var(--_progress-radius);\n background: var(--_progress-fill);\n animation: indeterminate-slide 2.4s var(--_easing-standard) infinite;\n }\n\n @keyframes indeterminate-slide {\n 0% {\n inset-inline-start: -35%;\n }\n\n 100% {\n inset-inline-start: 100%;\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n :host([value=\"\"]) .progress::before {\n animation-duration: 3.2s;\n }\n }\n\n @media (forced-colors: active) {\n .progress {\n forced-color-adjust: none;\n background: Canvas;\n border: 1px solid ButtonText;\n }\n\n .progress::-webkit-progress-bar {\n background: Canvas;\n }\n\n .progress::-webkit-progress-value,\n .progress::-moz-progress-bar,\n :host([value=\"\"]) .progress::before {\n background: Highlight;\n }\n }\n`;\n\nconst template = html<VioletProgress>`\n ${when(\n x => Boolean(x.label) || x.showValueLabel,\n html<VioletProgress>`\n <div class=\"header\" part=\"header\">\n ${when(\n x => Boolean(x.label),\n html<VioletProgress>`\n <p class=\"label\" part=\"label\">${x => x.label}</p>\n `\n )}\n ${when(\n x => x.showValueLabel,\n html<VioletProgress>`\n <p class=\"value-label\" part=\"value-label\">${x => x.valueLabel}</p>\n `\n )}\n </div>\n `\n )}\n <progress\n class=\"progress\"\n part=\"progress\"\n max=\"${x => x.normalizedMax}\"\n value=\"${x => x.progressValueAttribute}\"\n aria-label=\"${x => x.accessibleLabel}\"\n aria-valuetext=\"${x => x.valueText || null}\"\n ></progress>\n`;\n\n/**\n * Native-first linear progress indicator.\n *\n * @summary Styled wrapper around the native HTML progress element for determinate and indeterminate loading.\n * @csspart header - Optional label and value row.\n * @csspart label - Optional visible progress label.\n * @csspart value-label - Optional visible percentage label.\n * @csspart progress - The styled native progress element.\n */\nexport class VioletProgress extends FASTElement {\n declare public label: string;\n declare public value: string;\n declare public max: string;\n declare public valueText: string;\n\n public constructor() {\n super();\n this.label = \"\";\n this.value = \"0\";\n this.max = \"100\";\n this.valueText = \"\";\n }\n\n public get normalizedMax(): string {\n Observable.trackVolatile();\n const max = Number.parseFloat(this.max);\n return Number.isFinite(max) && max > 0 ? String(max) : \"100\";\n }\n\n public get progressValueAttribute(): string | null {\n Observable.trackVolatile();\n if (this.value === \"\") {\n return null;\n }\n\n const value = Number.parseFloat(this.value);\n if (!Number.isFinite(value)) {\n return \"0\";\n }\n\n return String(Math.min(Math.max(value, 0), Number.parseFloat(this.normalizedMax)));\n }\n\n public get accessibleLabel(): string {\n Observable.trackVolatile();\n return this.label || \"Progress\";\n }\n\n public get showValueLabel(): boolean {\n Observable.trackVolatile();\n return this.value !== \"\";\n }\n\n public get valueLabel(): string {\n Observable.trackVolatile();\n if (!this.showValueLabel) {\n return \"\";\n }\n\n const value = Number.parseFloat(this.progressValueAttribute ?? \"0\");\n const max = Number.parseFloat(this.normalizedMax);\n const percent = max > 0 ? Math.round((value / max) * 100) : 0;\n return `${percent}%`;\n }\n}\n\nattr(VioletProgress.prototype, \"label\");\nattr(VioletProgress.prototype, \"value\");\nattr(VioletProgress.prototype, \"max\");\nattr({ attribute: \"value-text\" })(VioletProgress.prototype, \"valueText\");\n\nif (!customElements.get(\"violet-progress\")) {\n await FASTElement.define(VioletProgress, {\n name: \"violet-progress\",\n template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E,CAAC;IAC7B,CAAC;IAED,IAAW,UAAU;QACjB,UAAU,CAAC,aAAa,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YACvB,OAAO,EAAE,CAAC;QACd,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,sBAAsB,IAAI,GAAG,CAAC,CAAC;QACpE,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAClD,MAAM,OAAO,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,OAAO,GAAG,OAAO,GAAG,CAAC;IACzB,CAAC;CACJ;AAED,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACxC,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACxC,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AACtC,IAAI,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAC,cAAc,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAEzE,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE,CAAC;IACzC,MAAM,WAAW,CAAC,MAAM,CAAC,cAAc,EAAE;QACrC,IAAI,EAAE,iBAAiB;QACvB,QAAQ;QACR,MAAM;KACT,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { FASTElement, Observable, attr, css, html, when } from \"@lushly-dev/fast-element\";\n\nimport { violetFieldTokenDefaults } from \"../theme/violet-token-defaults\";\n\nconst styles = css`\n ${violetFieldTokenDefaults}\n\n :host {\n display: grid;\n gap: var(--_space-stack-xs);\n color: var(--_text-secondary);\n --_progress-track-size: 6px;\n --_progress-radius: var(--radius-round, 9999px);\n --_progress-fill: var(--color-control-selected-foreground, #2c5e4b);\n /* The track is a well, filled to the value. */\n --_progress-track: color-mix(in srgb, var(--color-text-primary, #181b1a) 10%, transparent);\n }\n\n .header {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: var(--_space-inline-md);\n }\n\n .label,\n .value-label {\n margin: 0;\n font-size: var(--_control-label-size);\n line-height: var(--_type-label-line);\n }\n\n .label {\n color: var(--_text-secondary);\n font-weight: var(--_type-label-weight);\n }\n\n .value-label {\n color: var(--_text-muted);\n font-size: var(--_control-caption-size);\n font-variant-numeric: tabular-nums;\n }\n\n .progress {\n inline-size: 100%;\n block-size: var(--_progress-track-size);\n overflow: hidden;\n border: none;\n border-radius: var(--_progress-radius);\n background: var(--_progress-track);\n appearance: none;\n -webkit-appearance: none;\n }\n\n .progress::-webkit-progress-bar {\n background: var(--_progress-track);\n border-radius: var(--_progress-radius);\n }\n\n .progress::-webkit-progress-value {\n border-radius: var(--_progress-radius);\n background: var(--_progress-fill);\n }\n\n .progress::-moz-progress-bar {\n border-radius: var(--_progress-radius);\n background: var(--_progress-fill);\n }\n\n :host([value=\"\"]) .progress {\n position: relative;\n background: var(--_progress-track);\n }\n\n :host([value=\"\"]) .progress::before {\n content: \"\";\n position: absolute;\n inset-block: 0;\n inline-size: 35%;\n border-radius: var(--_progress-radius);\n background: var(--_progress-fill);\n animation: indeterminate-slide 2.4s var(--_easing-standard) infinite;\n }\n\n @keyframes indeterminate-slide {\n 0% {\n inset-inline-start: -35%;\n }\n\n 100% {\n inset-inline-start: 100%;\n }\n }\n\n @keyframes indeterminate-pulse {\n 0% {\n opacity: 1;\n }\n\n /* Not lower: a Highlight fill on Canvas keeps its contrast under forced colours. */\n 100% {\n opacity: 0.75;\n }\n }\n\n /* Nothing slides under reduced motion: the whole track fills and its opacity eases. */\n @media (prefers-reduced-motion: reduce) {\n :host([value=\"\"]) .progress::before {\n inset-inline-start: 0;\n inline-size: 100%;\n animation: indeterminate-pulse 1.6s ease-in-out infinite alternate;\n }\n }\n\n @media (forced-colors: active) {\n .progress {\n forced-color-adjust: none;\n background: Canvas;\n border: 1px solid ButtonText;\n }\n\n .progress::-webkit-progress-bar {\n background: Canvas;\n }\n\n .progress::-webkit-progress-value,\n .progress::-moz-progress-bar,\n :host([value=\"\"]) .progress::before {\n background: Highlight;\n }\n }\n`;\n\nconst template = html<VioletProgress>`\n ${when(\n x => Boolean(x.label) || x.showValueLabel,\n html<VioletProgress>`\n <div class=\"header\" part=\"header\">\n ${when(\n x => Boolean(x.label),\n html<VioletProgress>`\n <p class=\"label\" part=\"label\">${x => x.label}</p>\n `\n )}\n ${when(\n x => x.showValueLabel,\n html<VioletProgress>`\n <p class=\"value-label\" part=\"value-label\">${x => x.valueLabel}</p>\n `\n )}\n </div>\n `\n )}\n <progress\n class=\"progress\"\n part=\"progress\"\n max=\"${x => x.normalizedMax}\"\n value=\"${x => x.progressValueAttribute}\"\n aria-label=\"${x => x.accessibleLabel}\"\n aria-valuetext=\"${x => x.valueText || null}\"\n ></progress>\n`;\n\n/**\n * Native-first linear progress indicator.\n *\n * @summary Styled wrapper around the native HTML progress element for determinate and indeterminate loading.\n * @csspart header - Optional label and value row.\n * @csspart label - Optional visible progress label.\n * @csspart value-label - Optional visible percentage label.\n * @csspart progress - The styled native progress element.\n */\nexport class VioletProgress extends FASTElement {\n declare public label: string;\n declare public value: string;\n declare public max: string;\n declare public valueText: string;\n\n public constructor() {\n super();\n this.label = \"\";\n this.value = \"0\";\n this.max = \"100\";\n this.valueText = \"\";\n }\n\n public get normalizedMax(): string {\n Observable.trackVolatile();\n const max = Number.parseFloat(this.max);\n return Number.isFinite(max) && max > 0 ? String(max) : \"100\";\n }\n\n public get progressValueAttribute(): string | null {\n Observable.trackVolatile();\n if (this.value === \"\") {\n return null;\n }\n\n const value = Number.parseFloat(this.value);\n if (!Number.isFinite(value)) {\n return \"0\";\n }\n\n return String(Math.min(Math.max(value, 0), Number.parseFloat(this.normalizedMax)));\n }\n\n public get accessibleLabel(): string {\n Observable.trackVolatile();\n return this.label || \"Progress\";\n }\n\n public get showValueLabel(): boolean {\n Observable.trackVolatile();\n return this.value !== \"\";\n }\n\n public get valueLabel(): string {\n Observable.trackVolatile();\n if (!this.showValueLabel) {\n return \"\";\n }\n\n const value = Number.parseFloat(this.progressValueAttribute ?? \"0\");\n const max = Number.parseFloat(this.normalizedMax);\n const percent = max > 0 ? Math.round((value / max) * 100) : 0;\n return `${percent}%`;\n }\n}\n\nattr(VioletProgress.prototype, \"label\");\nattr(VioletProgress.prototype, \"value\");\nattr(VioletProgress.prototype, \"max\");\nattr({ attribute: \"value-text\" })(VioletProgress.prototype, \"valueText\");\n\nif (!customElements.get(\"violet-progress\")) {\n await FASTElement.define(VioletProgress, {\n name: \"violet-progress\",\n template,\n styles,\n });\n}\n"]}
|
|
@@ -19,16 +19,22 @@ const styles = css `
|
|
|
19
19
|
:host {
|
|
20
20
|
position: relative;
|
|
21
21
|
display: grid;
|
|
22
|
+
grid-template-columns: minmax(0, 1fr);
|
|
23
|
+
min-inline-size: 0;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
.field {
|
|
25
27
|
display: grid;
|
|
28
|
+
grid-template-columns: minmax(0, 1fr);
|
|
29
|
+
min-inline-size: 0;
|
|
26
30
|
gap: 0;
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
.control-shell {
|
|
30
34
|
position: relative;
|
|
31
35
|
display: grid;
|
|
36
|
+
grid-template-columns: minmax(0, 1fr);
|
|
37
|
+
min-inline-size: 0;
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
.control-shell.open {
|
|
@@ -49,6 +55,7 @@ const styles = css `
|
|
|
49
55
|
align-items: center;
|
|
50
56
|
gap: var(--_space-inline-sm);
|
|
51
57
|
inline-size: 100%;
|
|
58
|
+
min-inline-size: 0;
|
|
52
59
|
min-block-size: var(--_target-size);
|
|
53
60
|
padding-inline: max(var(--_space-inline-md), calc(var(--_target-size) * 0.375));
|
|
54
61
|
border: 1px solid var(--_border-subtle);
|
|
@@ -133,6 +140,8 @@ const styles = css `
|
|
|
133
140
|
}
|
|
134
141
|
|
|
135
142
|
.listbox {
|
|
143
|
+
|
|
144
|
+
--_option-active-ring: var(--_focus-ring);
|
|
136
145
|
display: grid;
|
|
137
146
|
gap: 2px;
|
|
138
147
|
max-block-size: inherit;
|
|
@@ -144,11 +153,6 @@ const styles = css `
|
|
|
144
153
|
outline: none;
|
|
145
154
|
}
|
|
146
155
|
|
|
147
|
-
|
|
148
|
-
.listbox ::slotted(violet-option) {
|
|
149
|
-
--violet-option-active-ring: color-mix(in srgb, var(--_focus-ring) 55%, transparent);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
156
|
.supporting,
|
|
153
157
|
.error {
|
|
154
158
|
margin: 0;
|
|
@@ -558,6 +562,7 @@ export class VioletSelect extends FASTElement {
|
|
|
558
562
|
}
|
|
559
563
|
this.open = true;
|
|
560
564
|
this.activeValue = this.value || getEnabledOptions(this.options)[0]?.value || "";
|
|
565
|
+
this.#syncOptions();
|
|
561
566
|
}
|
|
562
567
|
hide() {
|
|
563
568
|
this.open = false;
|