@lushly-dev/violet-elements 0.2.0-preview.4 → 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.
@@ -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,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE;;kBAE3G,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC;;;;;oEAKkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,cAAc;wDAClC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,2BAA2B,EAAE;;;;;CAK3F,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,YAAa,SAAQ,WAAW;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AI,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC1D,8EAA8E;QAC9E,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;QAC/C,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC;CACJ;AA5GkB;IADd,UAAU;4CACoB;AAGhB;IADd,UAAU;oDAC4B;AAGxB;IADd,UAAU;mDAC2B;AAwG1C,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACtC,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACtC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAC9D,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 --_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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqJ9B,CAAC;AAEF,MAAM,QAAQ,GAAG,IAAI,CAAc;;iBAElB,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE;;kBAE3G,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAA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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"]}
@@ -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;
@@ -1 +1 @@
1
- {"version":3,"file":"violet-select.js","sourceRoot":"","sources":["../../src/select/violet-select.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAEtG,OAAO,yBAAyB,CAAC;A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,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC;IACvC,MAAM,WAAW,CAAC,MAAM,CAAC,YAAY,EAAE;QACnC,IAAI,EAAE,eAAe;QACrB,QAAQ;QACR,MAAM;QACN,aAAa,EAAE;YACX,cAAc,EAAE,IAAI;SACvB;KACJ,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { attr, css, FASTElement, html, Observable, observable, when } from \"@lushly-dev/fast-element\";\n\nimport \"../option/violet-option\";\nimport {\n getEnabledOptions,\n getNextEnabledIndex,\n getOwnedOptions,\n getSelectedOption,\n normalizeMatchText,\n syncOptionSelection,\n} from \"../listbox/violet-selection-helpers\";\nimport type { VioletOption } from \"../option/violet-option\";\nimport { violetFieldTokenDefaults } from \"../theme/violet-token-defaults\";\nimport { installFormDisabled } from \"../foundations/violet-form-disabled\";\n\nlet violetSelectCount = 0;\n\nfunction isComposingKeyboardEvent(event: KeyboardEvent): boolean {\n return event.isComposing || event.keyCode === 229;\n}\n\nconst styles = css`\n ${violetFieldTokenDefaults}\n\n :host {\n position: relative;\n display: grid;\n }\n\n .field {\n display: grid;\n gap: 0;\n }\n\n .control-shell {\n position: relative;\n display: grid;\n }\n\n .control-shell.open {\n z-index: var(--_layer-raised);\n }\n\n .label {\n color: var(--_text-secondary);\n font-size: var(--_control-label-size);\n font-weight: var(--_type-label-weight);\n line-height: var(--_type-label-line);\n margin-block-end: var(--_space-field-gap);\n }\n\n .trigger {\n box-sizing: border-box;\n display: flex;\n align-items: center;\n gap: var(--_space-inline-sm);\n inline-size: 100%;\n min-block-size: var(--_target-size);\n padding-inline: max(var(--_space-inline-md), calc(var(--_target-size) * 0.375));\n border: 1px solid var(--_border-subtle);\n border-radius: var(--_radius-md);\n background: var(--_field-background);\n color: var(--_field-text);\n box-shadow: var(--_field-shadow);\n cursor: pointer;\n font-family: inherit;\n font-size: var(--_control-body-size);\n line-height: var(--_type-body-line);\n text-align: start;\n transition:\n border-color var(--_duration-fast) var(--_easing-standard),\n box-shadow var(--_duration-base) var(--_easing-standard);\n }\n\n .trigger:hover {\n box-shadow: var(--_field-shadow-hover);\n }\n\n .trigger:focus-visible,\n .control-shell.open .trigger {\n outline: none;\n border-color: var(--_field-border-focus);\n box-shadow: var(--_field-shadow-focus);\n }\n\n :host([disabled]) .trigger,\n :host(:disabled) .trigger {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n :host([invalid]) .trigger {\n border-color: var(--_danger-border);\n }\n\n .value {\n flex: 1 1 auto;\n min-inline-size: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .value[data-placeholder=\"true\"] {\n color: var(--_field-placeholder);\n }\n\n .caret {\n inline-size: 0.4375rem;\n block-size: 0.4375rem;\n flex: 0 0 auto;\n margin-inline-end: 2px;\n border-inline-end: 1.5px solid currentColor;\n border-block-end: 1.5px solid currentColor;\n color: var(--_text-muted);\n transform: translateY(-1px) rotate(45deg);\n }\n\n .panel {\n box-sizing: border-box;\n position: fixed;\n inset: unset;\n z-index: var(--_layer-popover);\n inline-size: var(--_panel-inline-size, auto);\n max-inline-size: calc(100vw - 8px);\n max-block-size: min(18rem, 60vh);\n padding: var(--_space-inline-sm);\n /* The list floats on its surface and shadow. The edge is kept, clear, for forced colours. */\n border: thin solid transparent;\n border-radius: var(--_radius-lg);\n overflow: hidden;\n background: var(--_surface-floating);\n box-shadow: var(--_shadow-floating);\n color: inherit;\n }\n\n .panel[hidden] {\n display: none;\n }\n\n .listbox {\n display: grid;\n gap: 2px;\n max-block-size: inherit;\n overflow: auto;\n outline: none;\n }\n\n .listbox:focus-visible {\n outline: none;\n }\n\n /* The keys are in this list while it is open, so its active row draws its ring. */\n .listbox ::slotted(violet-option) {\n --violet-option-active-ring: color-mix(in srgb, var(--_focus-ring) 55%, transparent);\n }\n\n .supporting,\n .error {\n margin: 0;\n font-size: var(--_control-caption-size);\n line-height: var(--_type-caption-line);\n }\n\n .supporting {\n color: var(--_text-muted);\n margin-block-start: var(--_space-field-gap);\n }\n\n .error {\n color: var(--color-state-danger-foreground, #c42a1a);\n margin-block-start: var(--_space-field-gap);\n }\n\n .control-shell.open ~ .supporting,\n .control-shell.open ~ .error {\n visibility: hidden;\n }\n\n @media (forced-colors: active) {\n .trigger,\n .trigger:hover,\n .panel {\n forced-color-adjust: none;\n border-color: ButtonText;\n background: Canvas;\n color: ButtonText;\n box-shadow: none;\n }\n\n .trigger:focus-visible,\n .control-shell.open .trigger {\n box-shadow: 0 0 0 2px Highlight;\n border-color: Highlight;\n }\n }\n`;\n\nconst template = html<VioletSelect>`\n <div class=\"field\" part=\"field\">\n ${when(\n x => Boolean(x.label),\n html<VioletSelect>`\n <div class=\"label\" part=\"label\" id=\"${x => x.labelId}\">${x => x.label}</div>\n `\n )}\n <div\n class=\"control-shell\"\n part=\"control-shell\"\n @focusout=\"${(x, c) => x.handleControlFocusOut(c.event as FocusEvent)}\"\n >\n <button\n id=\"${x => x.triggerId}\"\n class=\"trigger\"\n part=\"trigger\"\n type=\"button\"\n ?disabled=\"${x => x.effectiveDisabled}\"\n aria-haspopup=\"listbox\"\n aria-expanded=\"false\"\n aria-controls=\"${x => x.listboxId}\"\n aria-labelledby=\"${x => x.label ? `${x.labelId} ${x.valueId}` : x.valueId}\"\n aria-describedby=\"${x => x.describedBy || null}\"\n aria-invalid=\"${x => x.invalid ? \"true\" : \"false\"}\"\n @click=\"${x => x.handleTriggerClick()}\"\n @keydown=\"${(x, c) => x.handleTriggerKeydown(c.event as KeyboardEvent)}\"\n >\n <span id=\"${x => x.valueId}\" class=\"value\" data-placeholder=\"${x => String(!x.selectedLabel && !x.value)}\">\n ${x => x.selectedLabel || x.value || x.placeholder || \"Select an option\"}\n </span>\n <span class=\"caret\" part=\"caret\" aria-hidden=\"true\"></span>\n </button>\n\n <div class=\"panel\" part=\"panel\" hidden>\n <div\n id=\"${x => x.listboxId}\"\n class=\"listbox\"\n part=\"listbox\"\n role=\"listbox\"\n tabindex=\"-1\"\n aria-labelledby=\"${x => x.label ? `${x.labelId} ${x.valueId}` : x.valueId}\"\n @keydown=\"${(x, c) => x.handleListboxKeydown(c.event as KeyboardEvent)}\"\n >\n <slot @slotchange=\"${x => x.handleSlotChange()}\"></slot>\n </div>\n </div>\n </div>\n\n ${when(\n x => Boolean(x.supportingText),\n html<VioletSelect>`\n <p class=\"supporting\" part=\"supporting-text\" id=\"${x => x.supportingId}\">${x => x.supportingText}</p>\n `\n )}\n ${when(\n x => Boolean(x.displayErrorText),\n html<VioletSelect>`\n <p class=\"error\" part=\"error-message\" id=\"${x => x.errorId}\">${x => x.displayErrorText}</p>\n `\n )}\n </div>\n`;\n\n/**\n * Violet reusable select primitive.\n *\n * @summary Button-triggered popup list for choosing one option; the form receives the chosen option's value.\n * @slot - The options: violet-option and violet-option-group elements.\n * @fires input - Emitted when the chosen option changes.\n * @fires change - Emitted when the chosen option changes.\n * @csspart field - Field wrapper.\n * @csspart label - Label text element.\n * @csspart control-shell - Wrapper around the trigger and the popup panel.\n * @csspart trigger - The button that opens the list and shows the chosen option.\n * @csspart caret - Decorative open indicator.\n * @csspart panel - Popup panel.\n * @csspart listbox - The popup list that holds the slotted options.\n * @csspart supporting-text - Supporting text element.\n * @csspart error-message - Error text element.\n */\nexport class VioletSelect extends FASTElement {\n public static readonly formAssociated = true;\n\n readonly #internals: ElementInternals;\n #defaultValue: string;\n #typeaheadBuffer = \"\";\n #typeaheadTimer = 0;\n\n readonly #handleViewportChange = () => {\n if (this.open) {\n this.#positionPanel();\n }\n };\n\n readonly #handleDocumentPointerDown = (event: PointerEvent) => {\n if (!this.open) {\n return;\n }\n\n if (event.composedPath().includes(this)) {\n return;\n }\n\n this.hide();\n };\n\n readonly #handleFocusOut = (event: FocusEvent) => {\n this.handleControlFocusOut(event);\n };\n\n // The slot's slotchange misses options nested in groups and edits to an\n // option's label, so watch the light DOM for both (#499).\n // The host's own attributes are left to their change callbacks.\n readonly #optionsObserver = new MutationObserver(records => {\n if (records.some(record => record.target !== this)) {\n this.handleSlotChange();\n }\n });\n\n @observable\n declare public open: boolean;\n\n @observable\n declare public validationMessageText: string;\n\n @observable\n declare public activeValue: string;\n\n declare public label: string;\n declare public placeholder: string;\n declare public supportingText: string;\n declare public errorText: string;\n declare public value: string;\n declare public name: string;\n declare public required: boolean;\n declare public disabled: boolean;\n\n /**\n * True while an ancestor `<fieldset disabled>` disables the control.\n */\n declare public fieldsetDisabled: boolean;\n\n /**\n * Author `disabled` or fieldset-disabled.\n */\n declare public readonly effectiveDisabled: boolean;\n declare public invalid: boolean;\n\n public readonly triggerId: string;\n public readonly labelId: string;\n public readonly valueId: string;\n public readonly listboxId: string;\n public readonly supportingId: string;\n public readonly errorId: string;\n\n public constructor() {\n super();\n this.#internals = this.attachInternals();\n this.#defaultValue = \"\";\n this.open = false;\n this.validationMessageText = \"\";\n this.label = \"\";\n this.placeholder = \"\";\n this.supportingText = \"\";\n this.errorText = \"\";\n this.value = \"\";\n this.activeValue = \"\";\n this.name = \"\";\n this.required = false;\n this.disabled = false;\n this.invalid = false;\n\n violetSelectCount += 1;\n this.triggerId = `violet-select-trigger-${violetSelectCount}`;\n this.labelId = `violet-select-label-${violetSelectCount}`;\n this.valueId = `violet-select-value-${violetSelectCount}`;\n this.listboxId = `violet-select-listbox-${violetSelectCount}`;\n this.supportingId = `violet-select-supporting-${violetSelectCount}`;\n this.errorId = `violet-select-error-${violetSelectCount}`;\n }\n\n public connectedCallback(): void {\n super.connectedCallback();\n if (this.name && this.getAttribute(\"name\") !== this.name) {\n this.setAttribute(\"name\", this.name);\n }\n this.addEventListener(\"request-select\", this.handleRequestSelect as EventListener);\n this.addEventListener(\"focusout\", this.#handleFocusOut);\n this.ownerDocument.addEventListener(\"pointerdown\", this.#handleDocumentPointerDown, true);\n window.addEventListener(\"resize\", this.#handleViewportChange);\n window.addEventListener(\"scroll\", this.#handleViewportChange, true);\n this.#optionsObserver.observe(this, {\n childList: true,\n subtree: true,\n characterData: true,\n attributes: true,\n attributeFilter: [\"value\", \"label\", \"disabled\"],\n });\n this.handleSlotChange();\n this.#defaultValue = this.value;\n this.#syncFormState();\n this.openChanged();\n }\n\n public disconnectedCallback(): void {\n this.#optionsObserver.disconnect();\n this.removeEventListener(\"request-select\", this.handleRequestSelect as EventListener);\n this.removeEventListener(\"focusout\", this.#handleFocusOut);\n this.ownerDocument.removeEventListener(\"pointerdown\", this.#handleDocumentPointerDown, true);\n window.removeEventListener(\"resize\", this.#handleViewportChange);\n window.removeEventListener(\"scroll\", this.#handleViewportChange, true);\n super.disconnectedCallback();\n }\n\n public get options(): VioletOption[] {\n return getOwnedOptions(this);\n }\n\n public get form(): HTMLFormElement | null {\n return this.#internals.form;\n }\n\n public get validity(): ValidityState {\n return this.#internals.validity;\n }\n\n public get validationMessage(): string {\n return this.#internals.validationMessage;\n }\n\n public get willValidate(): boolean {\n return this.#internals.willValidate;\n }\n\n public checkValidity(): boolean {\n return this.#internals.checkValidity();\n }\n\n public reportValidity(): boolean {\n return this.#internals.reportValidity();\n }\n\n /**\n * The chosen option's label. It is read from the slotted options, which\n * are not observable, so bindings re-read it when the options change.\n */\n public get selectedLabel(): string {\n Observable.track(this, \"selectedLabel\");\n return this.options.find(option => option.value === this.value)?.labelText ?? \"\";\n }\n\n public get activeOptionId(): string {\n return this.options.find(option => option.value === this.activeValue)?.optionId ?? \"\";\n }\n\n public get describedBy(): string {\n return [this.supportingText ? this.supportingId : \"\", this.displayErrorText ? this.errorId : \"\"]\n .filter(Boolean)\n .join(\" \");\n }\n\n public get displayErrorText(): string {\n return !this.effectiveDisabled && (this.invalid || (this.required && !this.value))\n ? this.errorText || \"Please select an option.\"\n : \"\";\n }\n\n public formStateRestoreCallback(state: File | string | FormData | null): void {\n if (typeof state === \"string\") {\n this.value = state;\n }\n }\n\n public formResetCallback(): void {\n this.value = this.#defaultValue;\n this.handleSlotChange();\n }\n\n public handleSlotChange(): void {\n const selected = getSelectedOption(this.options, this.value);\n const enabled = getEnabledOptions(this.options);\n\n if (!this.value) {\n this.value = selected?.value ?? \"\";\n }\n\n if (!this.activeValue || !enabled.some(option => option.value === this.activeValue)) {\n this.activeValue = selected?.value ?? enabled[0]?.value ?? \"\";\n }\n\n this.#syncOptions();\n this.#syncFormState();\n Observable.notify(this, \"selectedLabel\");\n }\n\n public handleTriggerClick(): void {\n if (this.effectiveDisabled) {\n return;\n }\n\n this.open ? this.hide() : this.show();\n }\n\n public handleTriggerKeydown(event: KeyboardEvent): boolean {\n if (isComposingKeyboardEvent(event)) {\n return true;\n }\n\n if (this.effectiveDisabled) {\n return true;\n }\n\n switch (event.key) {\n case \"ArrowDown\":\n event.preventDefault();\n this.show();\n this.#moveActive(1);\n return false;\n case \"ArrowUp\":\n event.preventDefault();\n this.show();\n this.#moveActive(-1);\n return false;\n case \"Enter\":\n case \" \": {\n event.preventDefault();\n this.show();\n return false;\n }\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 handleListboxKeydown(event: KeyboardEvent): boolean {\n if (isComposingKeyboardEvent(event) || !this.open) {\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 const active = getEnabledOptions(this.options).find(option => option.value === this.activeValue);\n if (!active) {\n return true;\n }\n\n event.preventDefault();\n this.selectValue(active.value);\n return false;\n }\n case \"Escape\":\n event.preventDefault();\n this.hide();\n this.#focusTrigger();\n return false;\n case \"Tab\":\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 handleControlFocusOut(event: FocusEvent): boolean {\n const relatedTarget = event.relatedTarget as Node | null;\n if (\n relatedTarget &&\n (relatedTarget === this || this.shadowRoot?.contains(relatedTarget) || this.contains(relatedTarget))\n ) {\n return true;\n }\n\n this.hide();\n return true;\n }\n\n public handleRequestSelect(event: CustomEvent<{ value?: string }>): void {\n event.stopPropagation();\n const nextValue = event.detail?.value ?? \"\";\n this.selectValue(nextValue);\n }\n\n public valueChanged(): void {\n this.#syncOptions();\n this.#syncFormState();\n }\n\n public nameChanged(): void {\n if (this.$fastController.isConnected && this.name && this.getAttribute(\"name\") !== this.name) {\n this.setAttribute(\"name\", this.name);\n }\n }\n\n public openChanged(): void {\n const shell = this.#controlShell;\n const panel = this.#panel;\n const trigger = this.#trigger;\n const listbox = this.#listbox;\n\n shell?.classList.toggle(\"open\", this.open);\n panel?.toggleAttribute(\"hidden\", !this.open);\n trigger?.setAttribute(\"aria-expanded\", String(this.open));\n if (trigger) {\n trigger.tabIndex = this.open ? -1 : 0;\n }\n\n if (!listbox) {\n return;\n }\n\n listbox.tabIndex = this.open ? 0 : -1;\n\n if (this.open) {\n requestAnimationFrame(() => {\n this.#positionPanel();\n this.#listbox?.focus();\n this.#scrollActiveIntoView();\n });\n }\n }\n\n public requiredChanged(): void {\n this.#syncFormState();\n }\n\n public disabledChanged(): void {\n this.#syncFormState();\n }\n\n public invalidChanged(): void {\n this.#syncFormState();\n }\n\n public errorTextChanged(): void {\n this.#syncFormState();\n }\n\n public show(): void {\n if (this.effectiveDisabled || this.open) {\n return;\n }\n\n this.open = true;\n this.activeValue = this.value || getEnabledOptions(this.options)[0]?.value || \"\";\n }\n\n public hide(): void {\n this.open = false;\n }\n\n public selectValue(nextValue: string): 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.hide();\n this.#syncOptions();\n this.#syncFormState();\n this.$emit(\"input\", { value: this.value });\n this.$emit(\"change\", { value: this.value });\n this.#focusTrigger();\n }\n\n #focusTrigger(): void {\n this.#trigger?.focus();\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 this.#setActive(options[nextIndex]?.value ?? \"\");\n }\n\n #setActive(nextValue: string): void {\n this.activeValue = nextValue;\n this.#syncOptions();\n this.#scrollActiveIntoView();\n }\n\n #queueTypeahead(key: string): void {\n window.clearTimeout(this.#typeaheadTimer);\n this.#typeaheadBuffer = `${this.#typeaheadBuffer}${key.toLowerCase()}`;\n const options = getEnabledOptions(this.options);\n const currentIndex = options.findIndex(option => option.value === this.activeValue);\n const ordered = currentIndex >= 0 ? [...options.slice(currentIndex + 1), ...options.slice(0, currentIndex + 1)] : options;\n const match = ordered.find(option => normalizeMatchText(option.labelText).startsWith(normalizeMatchText(this.#typeaheadBuffer)));\n\n if (match) {\n if (this.open) {\n this.#setActive(match.value);\n } else {\n this.selectValue(match.value);\n }\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 #positionPanel(): void {\n const panel = this.#panel;\n const trigger = this.#trigger;\n if (!panel || !trigger) {\n return;\n }\n\n const rect = trigger.getBoundingClientRect();\n const viewportPadding = 4;\n const gap = -1;\n\n let left = rect.left;\n let top = rect.bottom + gap;\n const width = Math.min(rect.width, window.innerWidth - viewportPadding * 2);\n\n panel.style.width = `${width}px`;\n panel.style.left = `${Math.max(viewportPadding, left)}px`;\n panel.style.top = `${Math.max(viewportPadding, top)}px`;\n\n requestAnimationFrame(() => {\n const panelRect = panel.getBoundingClientRect();\n\n if (panelRect.right > window.innerWidth - viewportPadding) {\n left = Math.max(viewportPadding, window.innerWidth - panelRect.width - viewportPadding);\n }\n\n if (panelRect.bottom > window.innerHeight - viewportPadding) {\n top = Math.max(viewportPadding, rect.top - panelRect.height + 1);\n }\n\n panel.style.left = `${left}px`;\n panel.style.top = `${top}px`;\n });\n }\n\n get #controlShell(): HTMLElement | null {\n return this.shadowRoot?.querySelector(\".control-shell\") ?? null;\n }\n\n get #panel(): HTMLElement | null {\n return this.shadowRoot?.querySelector(\".panel\") ?? null;\n }\n\n get #listbox(): HTMLElement | null {\n return this.shadowRoot?.querySelector('[role=\"listbox\"]') ?? null;\n }\n\n get #trigger(): HTMLButtonElement | null {\n return this.shadowRoot?.querySelector(\".trigger\") ?? null;\n }\n\n #syncOptions(): void {\n syncOptionSelection(this.options, this.value, this.activeValue);\n const listbox = this.#listbox;\n if (listbox) {\n listbox.ariaActiveDescendantElement =\n this.options.find(option => option.value === this.activeValue) ?? null;\n }\n }\n\n #syncFormState(): void {\n if (!this.$fastController.isConnected) {\n return;\n }\n\n const control = this.shadowRoot?.querySelector(\".trigger\") as HTMLButtonElement | null;\n const message = this.displayErrorText || this.errorText || \"Please select an option.\";\n const invalid = !this.effectiveDisabled && Boolean(this.displayErrorText);\n\n this.validationMessageText = this.displayErrorText;\n this.#internals.ariaInvalid = invalid ? \"true\" : \"false\";\n this.#internals.setFormValue(this.effectiveDisabled ? null : this.value || null, this.effectiveDisabled ? null : this.value || null);\n\n if (this.effectiveDisabled) {\n this.#internals.setValidity({});\n return;\n }\n\n if (this.invalid) {\n this.#internals.setValidity({ customError: true }, message, control ?? undefined);\n return;\n }\n\n if (this.required && !this.value) {\n this.#internals.setValidity({ valueMissing: true }, message, control ?? undefined);\n return;\n }\n\n this.#internals.setValidity({});\n }\n}\n\nattr(VioletSelect.prototype, \"label\");\nattr(VioletSelect.prototype, \"placeholder\");\nattr({ attribute: \"supporting-text\" })(VioletSelect.prototype, \"supportingText\");\nattr({ attribute: \"error-text\" })(VioletSelect.prototype, \"errorText\");\nattr(VioletSelect.prototype, \"value\");\nattr(VioletSelect.prototype, \"name\");\nattr({ mode: \"boolean\" })(VioletSelect.prototype, \"required\");\nattr({ mode: \"boolean\" })(VioletSelect.prototype, \"disabled\");\ninstallFormDisabled(VioletSelect.prototype);\nattr({ mode: \"boolean\" })(VioletSelect.prototype, \"invalid\");\nattr({ mode: \"boolean\" })(VioletSelect.prototype, \"open\");\n\nif (!customElements.get(\"violet-select\")) {\n await FASTElement.define(VioletSelect, {\n name: \"violet-select\",\n template,\n styles,\n shadowOptions: {\n delegatesFocus: true,\n },\n });\n}\n"]}
1
+ {"version":3,"file":"violet-select.js","sourceRoot":"","sources":["../../src/select/violet-select.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAEtG,OAAO,yBAAyB,CAAC;AACjC,OAAO,EACH,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,GACtB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAE1E,IAAI,iBAAiB,GAAG,CAAC,CAAC;AAE1B,SAAS,wBAAwB,CAAC,KAAoB;IAClD,OAAO,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,OAAO,KAAK,GAAG,CAAC;AACtD,CAAC;AAED,MAAM,MAAM,GAAG,GAAG,CAAA;MACZ,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC,CAAC;AACvE,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACtC,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AACrC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAC9D,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAC9D,mBAAmB,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;AAC5C,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AAC7D,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AAE1D,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;QACN,aAAa,EAAE;YACX,cAAc,EAAE,IAAI;SACvB;KACJ,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { attr, css, FASTElement, html, Observable, observable, when } from \"@lushly-dev/fast-element\";\n\nimport \"../option/violet-option\";\nimport {\n getEnabledOptions,\n getNextEnabledIndex,\n getOwnedOptions,\n getSelectedOption,\n normalizeMatchText,\n syncOptionSelection,\n} from \"../listbox/violet-selection-helpers\";\nimport type { VioletOption } from \"../option/violet-option\";\nimport { violetFieldTokenDefaults } from \"../theme/violet-token-defaults\";\nimport { installFormDisabled } from \"../foundations/violet-form-disabled\";\n\nlet violetSelectCount = 0;\n\nfunction isComposingKeyboardEvent(event: KeyboardEvent): boolean {\n return event.isComposing || event.keyCode === 229;\n}\n\nconst styles = css`\n ${violetFieldTokenDefaults}\n\n :host {\n position: relative;\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n min-inline-size: 0;\n }\n\n .field {\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n min-inline-size: 0;\n gap: 0;\n }\n\n .control-shell {\n position: relative;\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n min-inline-size: 0;\n }\n\n .control-shell.open {\n z-index: var(--_layer-raised);\n }\n\n .label {\n color: var(--_text-secondary);\n font-size: var(--_control-label-size);\n font-weight: var(--_type-label-weight);\n line-height: var(--_type-label-line);\n margin-block-end: var(--_space-field-gap);\n }\n\n .trigger {\n box-sizing: border-box;\n display: flex;\n align-items: center;\n gap: var(--_space-inline-sm);\n inline-size: 100%;\n min-inline-size: 0;\n min-block-size: var(--_target-size);\n padding-inline: max(var(--_space-inline-md), calc(var(--_target-size) * 0.375));\n border: 1px solid var(--_border-subtle);\n border-radius: var(--_radius-md);\n background: var(--_field-background);\n color: var(--_field-text);\n box-shadow: var(--_field-shadow);\n cursor: pointer;\n font-family: inherit;\n font-size: var(--_control-body-size);\n line-height: var(--_type-body-line);\n text-align: start;\n transition:\n border-color var(--_duration-fast) var(--_easing-standard),\n box-shadow var(--_duration-base) var(--_easing-standard);\n }\n\n .trigger:hover {\n box-shadow: var(--_field-shadow-hover);\n }\n\n .trigger:focus-visible,\n .control-shell.open .trigger {\n outline: none;\n border-color: var(--_field-border-focus);\n box-shadow: var(--_field-shadow-focus);\n }\n\n :host([disabled]) .trigger,\n :host(:disabled) .trigger {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n :host([invalid]) .trigger {\n border-color: var(--_danger-border);\n }\n\n .value {\n flex: 1 1 auto;\n min-inline-size: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .value[data-placeholder=\"true\"] {\n color: var(--_field-placeholder);\n }\n\n .caret {\n inline-size: 0.4375rem;\n block-size: 0.4375rem;\n flex: 0 0 auto;\n margin-inline-end: 2px;\n border-inline-end: 1.5px solid currentColor;\n border-block-end: 1.5px solid currentColor;\n color: var(--_text-muted);\n transform: translateY(-1px) rotate(45deg);\n }\n\n .panel {\n box-sizing: border-box;\n position: fixed;\n inset: unset;\n z-index: var(--_layer-popover);\n inline-size: var(--_panel-inline-size, auto);\n max-inline-size: calc(100vw - 8px);\n max-block-size: min(18rem, 60vh);\n padding: var(--_space-inline-sm);\n /* The list floats on its surface and shadow. The edge is kept, clear, for forced colours. */\n border: thin solid transparent;\n border-radius: var(--_radius-lg);\n overflow: hidden;\n background: var(--_surface-floating);\n box-shadow: var(--_shadow-floating);\n color: inherit;\n }\n\n .panel[hidden] {\n display: none;\n }\n\n .listbox {\n /* The keys are in this list while it is open, so its active row draws its ring at >= 3:1. */\n --_option-active-ring: var(--_focus-ring);\n display: grid;\n gap: 2px;\n max-block-size: inherit;\n overflow: auto;\n outline: none;\n }\n\n .listbox:focus-visible {\n outline: none;\n }\n\n .supporting,\n .error {\n margin: 0;\n font-size: var(--_control-caption-size);\n line-height: var(--_type-caption-line);\n }\n\n .supporting {\n color: var(--_text-muted);\n margin-block-start: var(--_space-field-gap);\n }\n\n .error {\n color: var(--color-state-danger-foreground, #c42a1a);\n margin-block-start: var(--_space-field-gap);\n }\n\n .control-shell.open ~ .supporting,\n .control-shell.open ~ .error {\n visibility: hidden;\n }\n\n @media (forced-colors: active) {\n .trigger,\n .trigger:hover,\n .panel {\n forced-color-adjust: none;\n border-color: ButtonText;\n background: Canvas;\n color: ButtonText;\n box-shadow: none;\n }\n\n .trigger:focus-visible,\n .control-shell.open .trigger {\n box-shadow: 0 0 0 2px Highlight;\n border-color: Highlight;\n }\n }\n`;\n\nconst template = html<VioletSelect>`\n <div class=\"field\" part=\"field\">\n ${when(\n x => Boolean(x.label),\n html<VioletSelect>`\n <div class=\"label\" part=\"label\" id=\"${x => x.labelId}\">${x => x.label}</div>\n `\n )}\n <div\n class=\"control-shell\"\n part=\"control-shell\"\n @focusout=\"${(x, c) => x.handleControlFocusOut(c.event as FocusEvent)}\"\n >\n <button\n id=\"${x => x.triggerId}\"\n class=\"trigger\"\n part=\"trigger\"\n type=\"button\"\n ?disabled=\"${x => x.effectiveDisabled}\"\n aria-haspopup=\"listbox\"\n aria-expanded=\"false\"\n aria-controls=\"${x => x.listboxId}\"\n aria-labelledby=\"${x => x.label ? `${x.labelId} ${x.valueId}` : x.valueId}\"\n aria-describedby=\"${x => x.describedBy || null}\"\n aria-invalid=\"${x => x.invalid ? \"true\" : \"false\"}\"\n @click=\"${x => x.handleTriggerClick()}\"\n @keydown=\"${(x, c) => x.handleTriggerKeydown(c.event as KeyboardEvent)}\"\n >\n <span id=\"${x => x.valueId}\" class=\"value\" data-placeholder=\"${x => String(!x.selectedLabel && !x.value)}\">\n ${x => x.selectedLabel || x.value || x.placeholder || \"Select an option\"}\n </span>\n <span class=\"caret\" part=\"caret\" aria-hidden=\"true\"></span>\n </button>\n\n <div class=\"panel\" part=\"panel\" hidden>\n <div\n id=\"${x => x.listboxId}\"\n class=\"listbox\"\n part=\"listbox\"\n role=\"listbox\"\n tabindex=\"-1\"\n aria-labelledby=\"${x => x.label ? `${x.labelId} ${x.valueId}` : x.valueId}\"\n @keydown=\"${(x, c) => x.handleListboxKeydown(c.event as KeyboardEvent)}\"\n >\n <slot @slotchange=\"${x => x.handleSlotChange()}\"></slot>\n </div>\n </div>\n </div>\n\n ${when(\n x => Boolean(x.supportingText),\n html<VioletSelect>`\n <p class=\"supporting\" part=\"supporting-text\" id=\"${x => x.supportingId}\">${x => x.supportingText}</p>\n `\n )}\n ${when(\n x => Boolean(x.displayErrorText),\n html<VioletSelect>`\n <p class=\"error\" part=\"error-message\" id=\"${x => x.errorId}\">${x => x.displayErrorText}</p>\n `\n )}\n </div>\n`;\n\n/**\n * Violet reusable select primitive.\n *\n * @summary Button-triggered popup list for choosing one option; the form receives the chosen option's value.\n * @slot - The options: violet-option and violet-option-group elements.\n * @fires input - Emitted when the chosen option changes.\n * @fires change - Emitted when the chosen option changes.\n * @csspart field - Field wrapper.\n * @csspart label - Label text element.\n * @csspart control-shell - Wrapper around the trigger and the popup panel.\n * @csspart trigger - The button that opens the list and shows the chosen option.\n * @csspart caret - Decorative open indicator.\n * @csspart panel - Popup panel.\n * @csspart listbox - The popup list that holds the slotted options.\n * @csspart supporting-text - Supporting text element.\n * @csspart error-message - Error text element.\n */\nexport class VioletSelect extends FASTElement {\n public static readonly formAssociated = true;\n\n readonly #internals: ElementInternals;\n #defaultValue: string;\n #typeaheadBuffer = \"\";\n #typeaheadTimer = 0;\n\n readonly #handleViewportChange = () => {\n if (this.open) {\n this.#positionPanel();\n }\n };\n\n readonly #handleDocumentPointerDown = (event: PointerEvent) => {\n if (!this.open) {\n return;\n }\n\n if (event.composedPath().includes(this)) {\n return;\n }\n\n this.hide();\n };\n\n readonly #handleFocusOut = (event: FocusEvent) => {\n this.handleControlFocusOut(event);\n };\n\n // The slot's slotchange misses options nested in groups and edits to an\n // option's label, so watch the light DOM for both (#499).\n // The host's own attributes are left to their change callbacks.\n readonly #optionsObserver = new MutationObserver(records => {\n if (records.some(record => record.target !== this)) {\n this.handleSlotChange();\n }\n });\n\n @observable\n declare public open: boolean;\n\n @observable\n declare public validationMessageText: string;\n\n @observable\n declare public activeValue: string;\n\n declare public label: string;\n declare public placeholder: string;\n declare public supportingText: string;\n declare public errorText: string;\n declare public value: string;\n declare public name: string;\n declare public required: boolean;\n declare public disabled: boolean;\n\n /**\n * True while an ancestor `<fieldset disabled>` disables the control.\n */\n declare public fieldsetDisabled: boolean;\n\n /**\n * Author `disabled` or fieldset-disabled.\n */\n declare public readonly effectiveDisabled: boolean;\n declare public invalid: boolean;\n\n public readonly triggerId: string;\n public readonly labelId: string;\n public readonly valueId: string;\n public readonly listboxId: string;\n public readonly supportingId: string;\n public readonly errorId: string;\n\n public constructor() {\n super();\n this.#internals = this.attachInternals();\n this.#defaultValue = \"\";\n this.open = false;\n this.validationMessageText = \"\";\n this.label = \"\";\n this.placeholder = \"\";\n this.supportingText = \"\";\n this.errorText = \"\";\n this.value = \"\";\n this.activeValue = \"\";\n this.name = \"\";\n this.required = false;\n this.disabled = false;\n this.invalid = false;\n\n violetSelectCount += 1;\n this.triggerId = `violet-select-trigger-${violetSelectCount}`;\n this.labelId = `violet-select-label-${violetSelectCount}`;\n this.valueId = `violet-select-value-${violetSelectCount}`;\n this.listboxId = `violet-select-listbox-${violetSelectCount}`;\n this.supportingId = `violet-select-supporting-${violetSelectCount}`;\n this.errorId = `violet-select-error-${violetSelectCount}`;\n }\n\n public connectedCallback(): void {\n super.connectedCallback();\n if (this.name && this.getAttribute(\"name\") !== this.name) {\n this.setAttribute(\"name\", this.name);\n }\n this.addEventListener(\"request-select\", this.handleRequestSelect as EventListener);\n this.addEventListener(\"focusout\", this.#handleFocusOut);\n this.ownerDocument.addEventListener(\"pointerdown\", this.#handleDocumentPointerDown, true);\n window.addEventListener(\"resize\", this.#handleViewportChange);\n window.addEventListener(\"scroll\", this.#handleViewportChange, true);\n this.#optionsObserver.observe(this, {\n childList: true,\n subtree: true,\n characterData: true,\n attributes: true,\n attributeFilter: [\"value\", \"label\", \"disabled\"],\n });\n this.handleSlotChange();\n this.#defaultValue = this.value;\n this.#syncFormState();\n this.openChanged();\n }\n\n public disconnectedCallback(): void {\n this.#optionsObserver.disconnect();\n this.removeEventListener(\"request-select\", this.handleRequestSelect as EventListener);\n this.removeEventListener(\"focusout\", this.#handleFocusOut);\n this.ownerDocument.removeEventListener(\"pointerdown\", this.#handleDocumentPointerDown, true);\n window.removeEventListener(\"resize\", this.#handleViewportChange);\n window.removeEventListener(\"scroll\", this.#handleViewportChange, true);\n super.disconnectedCallback();\n }\n\n public get options(): VioletOption[] {\n return getOwnedOptions(this);\n }\n\n public get form(): HTMLFormElement | null {\n return this.#internals.form;\n }\n\n public get validity(): ValidityState {\n return this.#internals.validity;\n }\n\n public get validationMessage(): string {\n return this.#internals.validationMessage;\n }\n\n public get willValidate(): boolean {\n return this.#internals.willValidate;\n }\n\n public checkValidity(): boolean {\n return this.#internals.checkValidity();\n }\n\n public reportValidity(): boolean {\n return this.#internals.reportValidity();\n }\n\n /**\n * The chosen option's label. It is read from the slotted options, which\n * are not observable, so bindings re-read it when the options change.\n */\n public get selectedLabel(): string {\n Observable.track(this, \"selectedLabel\");\n return this.options.find(option => option.value === this.value)?.labelText ?? \"\";\n }\n\n public get activeOptionId(): string {\n return this.options.find(option => option.value === this.activeValue)?.optionId ?? \"\";\n }\n\n public get describedBy(): string {\n return [this.supportingText ? this.supportingId : \"\", this.displayErrorText ? this.errorId : \"\"]\n .filter(Boolean)\n .join(\" \");\n }\n\n public get displayErrorText(): string {\n return !this.effectiveDisabled && (this.invalid || (this.required && !this.value))\n ? this.errorText || \"Please select an option.\"\n : \"\";\n }\n\n public formStateRestoreCallback(state: File | string | FormData | null): void {\n if (typeof state === \"string\") {\n this.value = state;\n }\n }\n\n public formResetCallback(): void {\n this.value = this.#defaultValue;\n this.handleSlotChange();\n }\n\n public handleSlotChange(): void {\n const selected = getSelectedOption(this.options, this.value);\n const enabled = getEnabledOptions(this.options);\n\n if (!this.value) {\n this.value = selected?.value ?? \"\";\n }\n\n if (!this.activeValue || !enabled.some(option => option.value === this.activeValue)) {\n this.activeValue = selected?.value ?? enabled[0]?.value ?? \"\";\n }\n\n this.#syncOptions();\n this.#syncFormState();\n Observable.notify(this, \"selectedLabel\");\n }\n\n public handleTriggerClick(): void {\n if (this.effectiveDisabled) {\n return;\n }\n\n this.open ? this.hide() : this.show();\n }\n\n public handleTriggerKeydown(event: KeyboardEvent): boolean {\n if (isComposingKeyboardEvent(event)) {\n return true;\n }\n\n if (this.effectiveDisabled) {\n return true;\n }\n\n switch (event.key) {\n case \"ArrowDown\":\n event.preventDefault();\n this.show();\n this.#moveActive(1);\n return false;\n case \"ArrowUp\":\n event.preventDefault();\n this.show();\n this.#moveActive(-1);\n return false;\n case \"Enter\":\n case \" \": {\n event.preventDefault();\n this.show();\n return false;\n }\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 handleListboxKeydown(event: KeyboardEvent): boolean {\n if (isComposingKeyboardEvent(event) || !this.open) {\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 const active = getEnabledOptions(this.options).find(option => option.value === this.activeValue);\n if (!active) {\n return true;\n }\n\n event.preventDefault();\n this.selectValue(active.value);\n return false;\n }\n case \"Escape\":\n event.preventDefault();\n this.hide();\n this.#focusTrigger();\n return false;\n case \"Tab\":\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 handleControlFocusOut(event: FocusEvent): boolean {\n const relatedTarget = event.relatedTarget as Node | null;\n if (\n relatedTarget &&\n (relatedTarget === this || this.shadowRoot?.contains(relatedTarget) || this.contains(relatedTarget))\n ) {\n return true;\n }\n\n this.hide();\n return true;\n }\n\n public handleRequestSelect(event: CustomEvent<{ value?: string }>): void {\n event.stopPropagation();\n const nextValue = event.detail?.value ?? \"\";\n this.selectValue(nextValue);\n }\n\n public valueChanged(): void {\n this.#syncOptions();\n this.#syncFormState();\n }\n\n public nameChanged(): void {\n if (this.$fastController.isConnected && this.name && this.getAttribute(\"name\") !== this.name) {\n this.setAttribute(\"name\", this.name);\n }\n }\n\n public openChanged(): void {\n const shell = this.#controlShell;\n const panel = this.#panel;\n const trigger = this.#trigger;\n const listbox = this.#listbox;\n\n shell?.classList.toggle(\"open\", this.open);\n panel?.toggleAttribute(\"hidden\", !this.open);\n trigger?.setAttribute(\"aria-expanded\", String(this.open));\n if (trigger) {\n trigger.tabIndex = this.open ? -1 : 0;\n }\n\n if (!listbox) {\n return;\n }\n\n listbox.tabIndex = this.open ? 0 : -1;\n\n if (this.open) {\n requestAnimationFrame(() => {\n this.#positionPanel();\n this.#listbox?.focus();\n this.#scrollActiveIntoView();\n });\n }\n }\n\n public requiredChanged(): void {\n this.#syncFormState();\n }\n\n public disabledChanged(): void {\n this.#syncFormState();\n }\n\n public invalidChanged(): void {\n this.#syncFormState();\n }\n\n public errorTextChanged(): void {\n this.#syncFormState();\n }\n\n public show(): void {\n if (this.effectiveDisabled || this.open) {\n return;\n }\n\n this.open = true;\n this.activeValue = this.value || getEnabledOptions(this.options)[0]?.value || \"\";\n this.#syncOptions();\n }\n\n public hide(): void {\n this.open = false;\n }\n\n public selectValue(nextValue: string): 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.hide();\n this.#syncOptions();\n this.#syncFormState();\n this.$emit(\"input\", { value: this.value });\n this.$emit(\"change\", { value: this.value });\n this.#focusTrigger();\n }\n\n #focusTrigger(): void {\n this.#trigger?.focus();\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 this.#setActive(options[nextIndex]?.value ?? \"\");\n }\n\n #setActive(nextValue: string): void {\n this.activeValue = nextValue;\n this.#syncOptions();\n this.#scrollActiveIntoView();\n }\n\n #queueTypeahead(key: string): void {\n window.clearTimeout(this.#typeaheadTimer);\n this.#typeaheadBuffer = `${this.#typeaheadBuffer}${key.toLowerCase()}`;\n const options = getEnabledOptions(this.options);\n const currentIndex = options.findIndex(option => option.value === this.activeValue);\n const ordered = currentIndex >= 0 ? [...options.slice(currentIndex + 1), ...options.slice(0, currentIndex + 1)] : options;\n const match = ordered.find(option => normalizeMatchText(option.labelText).startsWith(normalizeMatchText(this.#typeaheadBuffer)));\n\n if (match) {\n if (this.open) {\n this.#setActive(match.value);\n } else {\n this.selectValue(match.value);\n }\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 #positionPanel(): void {\n const panel = this.#panel;\n const trigger = this.#trigger;\n if (!panel || !trigger) {\n return;\n }\n\n const rect = trigger.getBoundingClientRect();\n const viewportPadding = 4;\n const gap = -1;\n\n let left = rect.left;\n let top = rect.bottom + gap;\n const width = Math.min(rect.width, window.innerWidth - viewportPadding * 2);\n\n panel.style.width = `${width}px`;\n panel.style.left = `${Math.max(viewportPadding, left)}px`;\n panel.style.top = `${Math.max(viewportPadding, top)}px`;\n\n requestAnimationFrame(() => {\n const panelRect = panel.getBoundingClientRect();\n\n if (panelRect.right > window.innerWidth - viewportPadding) {\n left = Math.max(viewportPadding, window.innerWidth - panelRect.width - viewportPadding);\n }\n\n if (panelRect.bottom > window.innerHeight - viewportPadding) {\n top = Math.max(viewportPadding, rect.top - panelRect.height + 1);\n }\n\n panel.style.left = `${left}px`;\n panel.style.top = `${top}px`;\n });\n }\n\n get #controlShell(): HTMLElement | null {\n return this.shadowRoot?.querySelector(\".control-shell\") ?? null;\n }\n\n get #panel(): HTMLElement | null {\n return this.shadowRoot?.querySelector(\".panel\") ?? null;\n }\n\n get #listbox(): HTMLElement | null {\n return this.shadowRoot?.querySelector('[role=\"listbox\"]') ?? null;\n }\n\n get #trigger(): HTMLButtonElement | null {\n return this.shadowRoot?.querySelector(\".trigger\") ?? null;\n }\n\n #syncOptions(): void {\n syncOptionSelection(this.options, this.value, this.activeValue);\n const listbox = this.#listbox;\n if (listbox) {\n listbox.ariaActiveDescendantElement =\n this.options.find(option => option.value === this.activeValue) ?? null;\n }\n }\n\n #syncFormState(): void {\n if (!this.$fastController.isConnected) {\n return;\n }\n\n const control = this.shadowRoot?.querySelector(\".trigger\") as HTMLButtonElement | null;\n const message = this.displayErrorText || this.errorText || \"Please select an option.\";\n const invalid = !this.effectiveDisabled && Boolean(this.displayErrorText);\n\n this.validationMessageText = this.displayErrorText;\n this.#internals.ariaInvalid = invalid ? \"true\" : \"false\";\n this.#internals.setFormValue(this.effectiveDisabled ? null : this.value || null, this.effectiveDisabled ? null : this.value || null);\n\n if (this.effectiveDisabled) {\n this.#internals.setValidity({});\n return;\n }\n\n if (this.invalid) {\n this.#internals.setValidity({ customError: true }, message, control ?? undefined);\n return;\n }\n\n if (this.required && !this.value) {\n this.#internals.setValidity({ valueMissing: true }, message, control ?? undefined);\n return;\n }\n\n this.#internals.setValidity({});\n }\n}\n\nattr(VioletSelect.prototype, \"label\");\nattr(VioletSelect.prototype, \"placeholder\");\nattr({ attribute: \"supporting-text\" })(VioletSelect.prototype, \"supportingText\");\nattr({ attribute: \"error-text\" })(VioletSelect.prototype, \"errorText\");\nattr(VioletSelect.prototype, \"value\");\nattr(VioletSelect.prototype, \"name\");\nattr({ mode: \"boolean\" })(VioletSelect.prototype, \"required\");\nattr({ mode: \"boolean\" })(VioletSelect.prototype, \"disabled\");\ninstallFormDisabled(VioletSelect.prototype);\nattr({ mode: \"boolean\" })(VioletSelect.prototype, \"invalid\");\nattr({ mode: \"boolean\" })(VioletSelect.prototype, \"open\");\n\nif (!customElements.get(\"violet-select\")) {\n await FASTElement.define(VioletSelect, {\n name: \"violet-select\",\n template,\n styles,\n shadowOptions: {\n delegatesFocus: true,\n },\n });\n}\n"]}
@@ -52,16 +52,39 @@ function activeCssText() {
52
52
  * next call, or the next install, tries again.
53
53
  */
54
54
  export function loadVioletBuiltInTheme() {
55
- builtInLoad ??= importBuiltIn()
56
- .then(module => {
57
- const cssText = module.violetThemeCssText;
55
+ // Defer the dynamic import by a microtask so single-file bundles finish initializing
56
+ // `violet-theme-builtin` when a pre-existing `<violet-theme>` upgrades synchronously during
57
+ // `FASTElement.define`. When a single-file bundle also awaits further element registrations
58
+ // before the inlined built-in module runs, its hoisted `var` namespace is still `undefined`
59
+ // (or its `const` bindings are still in TDZ) after one microtask; yield one macrotask so all
60
+ // registration microtasks drain, then retry once (#2072).
61
+ const load = async () => {
62
+ await Promise.resolve();
63
+ let cssText;
64
+ try {
65
+ const module = await importBuiltIn();
66
+ cssText = module?.violetThemeCssText;
67
+ }
68
+ catch (error) {
69
+ if (!(error instanceof ReferenceError)) {
70
+ throw error;
71
+ }
72
+ }
73
+ if (cssText === undefined) {
74
+ await new Promise(resolve => setTimeout(resolve, 0));
75
+ const module = await importBuiltIn();
76
+ if (module?.violetThemeCssText === undefined) {
77
+ throw new TypeError("violet-theme: built-in theme module did not export violetThemeCssText");
78
+ }
79
+ cssText = module.violetThemeCssText;
80
+ }
58
81
  builtInCssText = cssText;
59
82
  if (product === null) {
60
83
  refreshInstalledStyles();
61
84
  }
62
85
  return cssText;
63
- })
64
- .catch((error) => {
86
+ };
87
+ builtInLoad ??= load().catch((error) => {
65
88
  builtInLoad = undefined;
66
89
  throw error;
67
90
  });
@@ -1 +1 @@
1
- {"version":3,"file":"violet-theme-runtime.js","sourceRoot":"","sources":["../../src/theme/violet-theme-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAC7G,OAAO,EACH,oBAAoB,EACpB,6BAA6B,EAC7B,2BAA2B,GAG9B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACH,2BAA2B,EAE3B,kBAAkB,GACrB,MAAM,4CAA4C,CAAC;AAQpD,sEAAsE;AACtE,IAAI,OAAO,GAA2B,IAAI,CAAC;AAC3C,2DAA2D;AAC3D,IAAI,cAAkC,CAAC;AACvC,I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BAAoB,CAAC,MAAM,GAA2B,QAAQ;IAC1E,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,6BAA6B,CAAC,IAAI,mBAAmB,EAAE,CAAC;AAC5G,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,oBAAoB,CAAwB,OAAU,EAAE,MAA0B;IAC9F,MAAM,QAAQ,GAAG,0BAA0B,CAAC,MAAM,CAAC,CAAC;IACpD,OAAO,CAAC,YAAY,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAC;IACtD,OAAO,CAAC,YAAY,CAAC,6BAA6B,EAAE,QAAQ,CAAC,CAAC;IAC9D,OAAO,OAAO,CAAC;AACnB,CAAC","sourcesContent":["/**\n * Installs a Violet theme set and selects its presets on the document or a scoped\n * `[data-violet-theme-root]`.\n *\n * With nothing installed, the active set is the built-in default, so `installVioletTheme()` stays\n * the zero-config route. A product that brings its own tree calls `installVioletThemeSet()`\n * instead: its set replaces the built-in one wherever this module has installed a theme.\n *\n * The built-in set's values live in `violet-theme-builtin`, which this module never imports\n * statically: `installVioletTheme()` loads it on first use, with a dynamic import, and writes its\n * stylesheet once it arrives (the components' literal fallbacks are its light values meanwhile). A\n * product that installs its own set first never loads it, and a bundler keeps it in a chunk of its\n * own.\n */\nimport { VIOLET_THEME_DEFAULT_PRESET, violetThemePresets } from \"./generated/violet-theme-presets.generated\";\nimport {\n createVioletThemeCss,\n VIOLET_THEME_PRESET_ATTRIBUTE,\n VIOLET_THEME_ROOT_ATTRIBUTE,\n type VioletThemePreset,\n type VioletThemeSet,\n} from \"./violet-theme-css\";\n\nexport {\n VIOLET_THEME_DEFAULT_PRESET,\n type VioletBuiltInThemePreset,\n violetThemePresets,\n} from \"./generated/violet-theme-presets.generated\";\n\ninterface ProductThemeSet {\n readonly cssText: string;\n readonly presets: readonly VioletThemePreset[];\n readonly defaultPreset: VioletThemePreset;\n}\n\n/** The product's set; `null` while the built-in default is active. */\nlet product: ProductThemeSet | null = null;\n/** The built-in stylesheet, once its module has loaded. */\nlet builtInCssText: string | undefined;\nlet builtInLoad: Promise<string> | undefined;\n\n/**\n * Every runtime style element this module wrote, held weakly so a removed shadow root's style can\n * be collected, and written on every change, connected or not, so one reattached later is current.\n */\nconst installedStyles = new Set<WeakRef<HTMLStyleElement>>();\nconst trackedStyles = new WeakSet<HTMLStyleElement>();\n\nfunction activePresets(): readonly VioletThemePreset[] {\n return product?.presets ?? violetThemePresets;\n}\n\nfunction activeDefaultPreset(): VioletThemePreset {\n return product?.defaultPreset ?? VIOLET_THEME_DEFAULT_PRESET;\n}\n\n/** The active stylesheet; empty while the built-in one is still loading. */\nfunction activeCssText(): string {\n if (product !== null) {\n return product.cssText;\n }\n if (builtInCssText === undefined) {\n loadVioletBuiltInTheme().catch((error: unknown) => {\n console.error(\"violet-theme: the built-in theme failed to load; the next install retries\", error);\n });\n return \"\";\n }\n return builtInCssText;\n}\n\n/**\n * Loads the built-in default set's stylesheet, writing it into every installed runtime style if no\n * product set is active by then. `installVioletTheme()` calls it; await it to know the built-in\n * theme is applied. A failed load (a chunk that did not arrive) rejects and is not cached, so the\n * next call, or the next install, tries again.\n */\nexport function loadVioletBuiltInTheme(): Promise<string> {\n builtInLoad ??= importBuiltIn()\n .then(module => {\n const cssText = module.violetThemeCssText;\n builtInCssText = cssText;\n if (product === null) {\n refreshInstalledStyles();\n }\n return cssText;\n })\n .catch((error: unknown) => {\n builtInLoad = undefined;\n throw error;\n });\n return builtInLoad;\n}\n\ntype BuiltInImporter = () => Promise<{ violetThemeCssText: string }>;\n\nlet importBuiltIn: BuiltInImporter = () => import(\"./violet-theme-builtin\");\n\n/**\n * Replaces how the built-in set's module is imported, for this package's specs: a browser caches a\n * module that failed, so a spec cannot make the real chunk fail once and then load. Not exported\n * from the package root.\n *\n * @internal\n */\nexport function setVioletBuiltInThemeImporterForTesting(importer: BuiltInImporter): void {\n importBuiltIn = importer;\n builtInLoad = undefined;\n builtInCssText = undefined;\n}\n\nfunction isShadowRoot(target: unknown): target is ShadowRoot {\n return typeof ShadowRoot !== \"undefined\" && target instanceof ShadowRoot;\n}\n\nfunction isDocument(target: unknown): target is Document {\n return typeof Document !== \"undefined\" && target instanceof Document;\n}\n\nfunction resolveStyleContainer(target: Document | ShadowRoot = document): ShadowRoot | HTMLElement {\n if (isShadowRoot(target)) {\n return target;\n }\n\n if (isDocument(target)) {\n return target.head ?? target.documentElement;\n }\n\n return document.head ?? document.documentElement;\n}\n\nfunction resolvePresetTarget(target: Document | HTMLElement = document): HTMLElement {\n if (isDocument(target)) {\n return target.documentElement;\n }\n\n return target;\n}\n\nfunction writeStyle(target: Document | ShadowRoot): HTMLStyleElement {\n const styleContainer = resolveStyleContainer(target);\n const existing = styleContainer.querySelector('style[data-violet-theme=\"runtime\"]');\n const ownerDocument = isShadowRoot(target) ? target.ownerDocument : isDocument(target) ? target : document;\n const style = existing instanceof HTMLStyleElement ? existing : ownerDocument.createElement(\"style\");\n\n style.dataset.violetTheme = \"runtime\";\n style.textContent = activeCssText();\n if (!style.isConnected) {\n styleContainer.append(style);\n }\n if (!trackedStyles.has(style)) {\n trackedStyles.add(style);\n installedStyles.add(new WeakRef(style));\n }\n return style;\n}\n\nfunction refreshInstalledStyles(): void {\n const cssText = activeCssText();\n for (const ref of installedStyles) {\n const style = ref.deref();\n if (style === undefined) {\n installedStyles.delete(ref);\n } else {\n style.textContent = cssText;\n }\n }\n}\n\n/**\n * Writes the active theme set's stylesheet into `target` (the document's head by default, or a\n * shadow root), reusing the runtime style element already there. The active set is the built-in\n * default unless `installVioletThemeSet()` installed another; the built-in stylesheet is written\n * when its module has loaded (`loadVioletBuiltInTheme()`).\n */\nexport function installVioletTheme(target: Document | ShadowRoot = document): HTMLStyleElement {\n return writeStyle(target);\n}\n\n/**\n * Makes `themeSet` the active theme set, replacing the built-in default, and writes it into\n * `target` and every runtime style element installed before, so scoped `violet-theme` hosts in\n * shadow roots switch too. Preset names are the set's own. Throws a `TypeError` when the set is not\n * sound (see `validateVioletThemeSet`); completeness against `tokens/interface.json` is a build-time\n * check (`findVioletThemeSetGaps`).\n *\n * @example\n * ```ts\n * import { applyVioletThemePreset, installVioletThemeSet } from \"@lushly-dev/violet-elements\";\n *\n * installVioletThemeSet({\n * defaultPreset: \"light\",\n * presets: { light: lightTokens, dark: darkTokens, sepia: sepiaTokens },\n * });\n * applyVioletThemePreset(document, \"sepia\");\n * ```\n */\nexport function installVioletThemeSet(\n themeSet: VioletThemeSet,\n target: Document | ShadowRoot = document,\n): HTMLStyleElement {\n product = {\n cssText: createVioletThemeCss(themeSet),\n presets: Object.keys(themeSet.presets),\n defaultPreset: themeSet.defaultPreset,\n };\n refreshInstalledStyles();\n return writeStyle(target);\n}\n\n/** Makes the built-in default the active set again and rewrites every installed runtime style. */\nexport function resetVioletThemeSet(): void {\n product = null;\n refreshInstalledStyles();\n}\n\n/** The active set's preset names. */\nexport function getVioletThemePresets(): readonly VioletThemePreset[] {\n return activePresets();\n}\n\n/** The active set's default preset. */\nexport function getVioletThemeDefaultPreset(): VioletThemePreset {\n return activeDefaultPreset();\n}\n\n/** Whether `value` names a preset of the active set. */\nexport function isVioletThemePreset(value: string | null | undefined): value is VioletThemePreset {\n return typeof value === \"string\" && activePresets().includes(value);\n}\n\n/**\n * The active set's preset `value` names: the default preset for `null`, `undefined` or an empty\n * string, `value` itself when the active set has it. Throws a `RangeError` for any other name; it\n * is never mapped to the default.\n */\nexport function normalizeVioletThemePreset(value: string | null | undefined): VioletThemePreset {\n if (value === null || value === undefined || value === \"\") {\n return activeDefaultPreset();\n }\n if (isVioletThemePreset(value)) {\n return value;\n }\n throw new RangeError(`Unknown Violet theme preset '${value}'; the installed presets are ${activePresets().join(\", \")}`);\n}\n\n/**\n * Selects a preset of the active set on the document root or an element. Throws a `RangeError` for\n * a name the active set does not have, so install a product's set before selecting its presets.\n */\nexport function applyVioletThemePreset<T extends Document | HTMLElement>(target: T, preset?: VioletThemePreset): T {\n resolvePresetTarget(target).setAttribute(VIOLET_THEME_PRESET_ATTRIBUTE, normalizeVioletThemePreset(preset));\n return target;\n}\n\n/**\n * The preset selected on the document root or an element: its `data-violet-theme` attribute as\n * written, or the active set's default when it has none.\n */\nexport function getVioletThemePreset(target: Document | HTMLElement = document): VioletThemePreset {\n return resolvePresetTarget(target).getAttribute(VIOLET_THEME_PRESET_ATTRIBUTE) || activeDefaultPreset();\n}\n\n/** Marks an element as a scoped theme root and selects a preset of the active set on it. */\nexport function applyVioletThemeRoot<T extends HTMLElement>(element: T, preset?: VioletThemePreset): T {\n const resolved = normalizeVioletThemePreset(preset);\n element.setAttribute(VIOLET_THEME_ROOT_ATTRIBUTE, \"\");\n element.setAttribute(VIOLET_THEME_PRESET_ATTRIBUTE, resolved);\n return element;\n}\n"]}
1
+ {"version":3,"file":"violet-theme-runtime.js","sourceRoot":"","sources":["../../src/theme/violet-theme-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAC7G,OAAO,EACH,oBAAoB,EACpB,6BAA6B,EAC7B,2BAA2B,GAG9B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACH,2BAA2B,EAE3B,kBAAkB,GACrB,MAAM,4CAA4C,CAAC;AAQpD,sEAAsE;AACtE,IAAI,OAAO,GAA2B,IAAI,CAAC;AAC3C,2DAA2D;AAC3D,IAAI,cAAkC,CAAC;AACvC,IAAI,WAAwC,CAAC;AAE7C;;;GAGG;AACH,MAAM,eAAe,GAAG,IAAI,GAAG,EAA6B,CAAC;AAC7D,MAAM,aAAa,GAAG,IAAI,OAAO,EAAoB,CAAC;AAEtD,SAAS,aAAa;IAClB,OAAO,OAAO,EAAE,OAAO,IAAI,kBAAkB,CAAC;AAClD,CAAC;AAED,SAAS,mBAAmB;IACxB,OAAO,OAAO,EAAE,aAAa,IAAI,2BAA2B,CAAC;AACjE,CAAC;AAED,4EAA4E;AAC5E,SAAS,aAAa;IAClB,I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,CAAC;QAC7B,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,MAAM,IAAI,UAAU,CAAC,gCAAgC,KAAK,gCAAgC,aAAa,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC5H,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAmC,MAAS,EAAE,MAA0B;IAC1G,mBAAmB,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,6BAA6B,EAAE,0BAA0B,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5G,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAM,GAA2B,QAAQ;IAC1E,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,6BAA6B,CAAC,IAAI,mBAAmB,EAAE,CAAC;AAC5G,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,oBAAoB,CAAwB,OAAU,EAAE,MAA0B;IAC9F,MAAM,QAAQ,GAAG,0BAA0B,CAAC,MAAM,CAAC,CAAC;IACpD,OAAO,CAAC,YAAY,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAC;IACtD,OAAO,CAAC,YAAY,CAAC,6BAA6B,EAAE,QAAQ,CAAC,CAAC;IAC9D,OAAO,OAAO,CAAC;AACnB,CAAC","sourcesContent":["/**\n * Installs a Violet theme set and selects its presets on the document or a scoped\n * `[data-violet-theme-root]`.\n *\n * With nothing installed, the active set is the built-in default, so `installVioletTheme()` stays\n * the zero-config route. A product that brings its own tree calls `installVioletThemeSet()`\n * instead: its set replaces the built-in one wherever this module has installed a theme.\n *\n * The built-in set's values live in `violet-theme-builtin`, which this module never imports\n * statically: `installVioletTheme()` loads it on first use, with a dynamic import, and writes its\n * stylesheet once it arrives (the components' literal fallbacks are its light values meanwhile). A\n * product that installs its own set first never loads it, and a bundler keeps it in a chunk of its\n * own.\n */\nimport { VIOLET_THEME_DEFAULT_PRESET, violetThemePresets } from \"./generated/violet-theme-presets.generated\";\nimport {\n createVioletThemeCss,\n VIOLET_THEME_PRESET_ATTRIBUTE,\n VIOLET_THEME_ROOT_ATTRIBUTE,\n type VioletThemePreset,\n type VioletThemeSet,\n} from \"./violet-theme-css\";\n\nexport {\n VIOLET_THEME_DEFAULT_PRESET,\n type VioletBuiltInThemePreset,\n violetThemePresets,\n} from \"./generated/violet-theme-presets.generated\";\n\ninterface ProductThemeSet {\n readonly cssText: string;\n readonly presets: readonly VioletThemePreset[];\n readonly defaultPreset: VioletThemePreset;\n}\n\n/** The product's set; `null` while the built-in default is active. */\nlet product: ProductThemeSet | null = null;\n/** The built-in stylesheet, once its module has loaded. */\nlet builtInCssText: string | undefined;\nlet builtInLoad: Promise<string> | undefined;\n\n/**\n * Every runtime style element this module wrote, held weakly so a removed shadow root's style can\n * be collected, and written on every change, connected or not, so one reattached later is current.\n */\nconst installedStyles = new Set<WeakRef<HTMLStyleElement>>();\nconst trackedStyles = new WeakSet<HTMLStyleElement>();\n\nfunction activePresets(): readonly VioletThemePreset[] {\n return product?.presets ?? violetThemePresets;\n}\n\nfunction activeDefaultPreset(): VioletThemePreset {\n return product?.defaultPreset ?? VIOLET_THEME_DEFAULT_PRESET;\n}\n\n/** The active stylesheet; empty while the built-in one is still loading. */\nfunction activeCssText(): string {\n if (product !== null) {\n return product.cssText;\n }\n if (builtInCssText === undefined) {\n loadVioletBuiltInTheme().catch((error: unknown) => {\n console.error(\"violet-theme: the built-in theme failed to load; the next install retries\", error);\n });\n return \"\";\n }\n return builtInCssText;\n}\n\n/**\n * Loads the built-in default set's stylesheet, writing it into every installed runtime style if no\n * product set is active by then. `installVioletTheme()` calls it; await it to know the built-in\n * theme is applied. A failed load (a chunk that did not arrive) rejects and is not cached, so the\n * next call, or the next install, tries again.\n */\nexport function loadVioletBuiltInTheme(): Promise<string> {\n // Defer the dynamic import by a microtask so single-file bundles finish initializing\n // `violet-theme-builtin` when a pre-existing `<violet-theme>` upgrades synchronously during\n // `FASTElement.define`. When a single-file bundle also awaits further element registrations\n // before the inlined built-in module runs, its hoisted `var` namespace is still `undefined`\n // (or its `const` bindings are still in TDZ) after one microtask; yield one macrotask so all\n // registration microtasks drain, then retry once (#2072).\n const load = async (): Promise<string> => {\n await Promise.resolve();\n let cssText: string | undefined;\n try {\n const module = await importBuiltIn();\n cssText = module?.violetThemeCssText;\n } catch (error) {\n if (!(error instanceof ReferenceError)) {\n throw error;\n }\n }\n if (cssText === undefined) {\n await new Promise<void>(resolve => setTimeout(resolve, 0));\n const module = await importBuiltIn();\n if (module?.violetThemeCssText === undefined) {\n throw new TypeError(\"violet-theme: built-in theme module did not export violetThemeCssText\");\n }\n cssText = module.violetThemeCssText;\n }\n builtInCssText = cssText;\n if (product === null) {\n refreshInstalledStyles();\n }\n return cssText;\n };\n builtInLoad ??= load().catch((error: unknown) => {\n builtInLoad = undefined;\n throw error;\n });\n return builtInLoad;\n}\n\ntype BuiltInImporter = () => Promise<{ violetThemeCssText: string }>;\n\nlet importBuiltIn: BuiltInImporter = () => import(\"./violet-theme-builtin\");\n\n/**\n * Replaces how the built-in set's module is imported, for this package's specs: a browser caches a\n * module that failed, so a spec cannot make the real chunk fail once and then load. Not exported\n * from the package root.\n *\n * @internal\n */\nexport function setVioletBuiltInThemeImporterForTesting(importer: BuiltInImporter): void {\n importBuiltIn = importer;\n builtInLoad = undefined;\n builtInCssText = undefined;\n}\n\nfunction isShadowRoot(target: unknown): target is ShadowRoot {\n return typeof ShadowRoot !== \"undefined\" && target instanceof ShadowRoot;\n}\n\nfunction isDocument(target: unknown): target is Document {\n return typeof Document !== \"undefined\" && target instanceof Document;\n}\n\nfunction resolveStyleContainer(target: Document | ShadowRoot = document): ShadowRoot | HTMLElement {\n if (isShadowRoot(target)) {\n return target;\n }\n\n if (isDocument(target)) {\n return target.head ?? target.documentElement;\n }\n\n return document.head ?? document.documentElement;\n}\n\nfunction resolvePresetTarget(target: Document | HTMLElement = document): HTMLElement {\n if (isDocument(target)) {\n return target.documentElement;\n }\n\n return target;\n}\n\nfunction writeStyle(target: Document | ShadowRoot): HTMLStyleElement {\n const styleContainer = resolveStyleContainer(target);\n const existing = styleContainer.querySelector('style[data-violet-theme=\"runtime\"]');\n const ownerDocument = isShadowRoot(target) ? target.ownerDocument : isDocument(target) ? target : document;\n const style = existing instanceof HTMLStyleElement ? existing : ownerDocument.createElement(\"style\");\n\n style.dataset.violetTheme = \"runtime\";\n style.textContent = activeCssText();\n if (!style.isConnected) {\n styleContainer.append(style);\n }\n if (!trackedStyles.has(style)) {\n trackedStyles.add(style);\n installedStyles.add(new WeakRef(style));\n }\n return style;\n}\n\nfunction refreshInstalledStyles(): void {\n const cssText = activeCssText();\n for (const ref of installedStyles) {\n const style = ref.deref();\n if (style === undefined) {\n installedStyles.delete(ref);\n } else {\n style.textContent = cssText;\n }\n }\n}\n\n/**\n * Writes the active theme set's stylesheet into `target` (the document's head by default, or a\n * shadow root), reusing the runtime style element already there. The active set is the built-in\n * default unless `installVioletThemeSet()` installed another; the built-in stylesheet is written\n * when its module has loaded (`loadVioletBuiltInTheme()`).\n */\nexport function installVioletTheme(target: Document | ShadowRoot = document): HTMLStyleElement {\n return writeStyle(target);\n}\n\n/**\n * Makes `themeSet` the active theme set, replacing the built-in default, and writes it into\n * `target` and every runtime style element installed before, so scoped `violet-theme` hosts in\n * shadow roots switch too. Preset names are the set's own. Throws a `TypeError` when the set is not\n * sound (see `validateVioletThemeSet`); completeness against `tokens/interface.json` is a build-time\n * check (`findVioletThemeSetGaps`).\n *\n * @example\n * ```ts\n * import { applyVioletThemePreset, installVioletThemeSet } from \"@lushly-dev/violet-elements\";\n *\n * installVioletThemeSet({\n * defaultPreset: \"light\",\n * presets: { light: lightTokens, dark: darkTokens, sepia: sepiaTokens },\n * });\n * applyVioletThemePreset(document, \"sepia\");\n * ```\n */\nexport function installVioletThemeSet(\n themeSet: VioletThemeSet,\n target: Document | ShadowRoot = document,\n): HTMLStyleElement {\n product = {\n cssText: createVioletThemeCss(themeSet),\n presets: Object.keys(themeSet.presets),\n defaultPreset: themeSet.defaultPreset,\n };\n refreshInstalledStyles();\n return writeStyle(target);\n}\n\n/** Makes the built-in default the active set again and rewrites every installed runtime style. */\nexport function resetVioletThemeSet(): void {\n product = null;\n refreshInstalledStyles();\n}\n\n/** The active set's preset names. */\nexport function getVioletThemePresets(): readonly VioletThemePreset[] {\n return activePresets();\n}\n\n/** The active set's default preset. */\nexport function getVioletThemeDefaultPreset(): VioletThemePreset {\n return activeDefaultPreset();\n}\n\n/** Whether `value` names a preset of the active set. */\nexport function isVioletThemePreset(value: string | null | undefined): value is VioletThemePreset {\n return typeof value === \"string\" && activePresets().includes(value);\n}\n\n/**\n * The active set's preset `value` names: the default preset for `null`, `undefined` or an empty\n * string, `value` itself when the active set has it. Throws a `RangeError` for any other name; it\n * is never mapped to the default.\n */\nexport function normalizeVioletThemePreset(value: string | null | undefined): VioletThemePreset {\n if (value === null || value === undefined || value === \"\") {\n return activeDefaultPreset();\n }\n if (isVioletThemePreset(value)) {\n return value;\n }\n throw new RangeError(`Unknown Violet theme preset '${value}'; the installed presets are ${activePresets().join(\", \")}`);\n}\n\n/**\n * Selects a preset of the active set on the document root or an element. Throws a `RangeError` for\n * a name the active set does not have, so install a product's set before selecting its presets.\n */\nexport function applyVioletThemePreset<T extends Document | HTMLElement>(target: T, preset?: VioletThemePreset): T {\n resolvePresetTarget(target).setAttribute(VIOLET_THEME_PRESET_ATTRIBUTE, normalizeVioletThemePreset(preset));\n return target;\n}\n\n/**\n * The preset selected on the document root or an element: its `data-violet-theme` attribute as\n * written, or the active set's default when it has none.\n */\nexport function getVioletThemePreset(target: Document | HTMLElement = document): VioletThemePreset {\n return resolvePresetTarget(target).getAttribute(VIOLET_THEME_PRESET_ATTRIBUTE) || activeDefaultPreset();\n}\n\n/** Marks an element as a scoped theme root and selects a preset of the active set on it. */\nexport function applyVioletThemeRoot<T extends HTMLElement>(element: T, preset?: VioletThemePreset): T {\n const resolved = normalizeVioletThemePreset(preset);\n element.setAttribute(VIOLET_THEME_ROOT_ATTRIBUTE, \"\");\n element.setAttribute(VIOLET_THEME_PRESET_ATTRIBUTE, resolved);\n return element;\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lushly-dev/violet-elements",
3
3
  "description": "Reusable Violet web components for FAST-AF",
4
- "version": "0.2.0-preview.4",
4
+ "version": "0.2.0-preview.5",
5
5
  "author": "Lushly Dev",
6
6
  "homepage": "https://github.com/lushly-dev/afd/tree/main/foundations/fast-af/packages/violet-elements#readme",
7
7
  "license": "MIT",
@@ -62,7 +62,7 @@
62
62
  "vite": "8.3.5",
63
63
  "vitest": "^5.1.1",
64
64
  "@lushly-dev/fast-element": "3.0.1-preview.2",
65
- "@lushly-dev/specimen": "2.2.0-preview.8",
65
+ "@lushly-dev/specimen": "2.2.0-preview.9",
66
66
  "@lushly-dev/specimen-fast-af": "0.1.0-preview.4"
67
67
  },
68
68
  "scripts": {