ssml-builder-js 2.13.0 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.mjs CHANGED
@@ -42,13 +42,13 @@ import {
42
42
  resolveExpressAsStyles,
43
43
  updateEditableText,
44
44
  updateTagAttribute
45
- } from "./chunk-LCTE26LS.mjs";
45
+ } from "./chunk-UZSCXPC5.mjs";
46
46
  import {
47
47
  buildPartialSsml,
48
48
  buildSsml,
49
49
  validateAzureSsml,
50
50
  validateSsml
51
- } from "./chunk-CZ2F3TET.mjs";
51
+ } from "./chunk-QFIBPCO4.mjs";
52
52
  import "./chunk-6S5ODO6A.mjs";
53
53
 
54
54
  // packages/ssml-editor-react/src/SsmlEditor.tsx
@@ -1960,13 +1960,31 @@ function localizedElementLabel(element, locale) {
1960
1960
  function filteredVoices(voiceCatalog, locale, region, style) {
1961
1961
  return (voiceCatalog ?? []).filter((voice) => {
1962
1962
  if (locale && voice.locale.toLowerCase() !== locale.toLowerCase()) return false;
1963
- if (region && voice.region && voice.region.toLowerCase() !== region.toLowerCase()) return false;
1963
+ const regions = [voice.region, ...voice.regions ?? []].filter(
1964
+ (candidate) => Boolean(candidate)
1965
+ );
1966
+ if (region && regions.length > 0 && !regions.some((candidate) => candidate.toLowerCase() === region.toLowerCase()))
1967
+ return false;
1964
1968
  if (style && !voice.styles?.some((candidate) => candidate.toLowerCase() === style.toLowerCase())) return false;
1965
1969
  return true;
1966
1970
  });
1967
1971
  }
1968
- function DefaultVoiceSelector({ value, voices, readOnly, locale, onChange }) {
1969
- return /* @__PURE__ */ React.createElement(
1972
+ function VoiceCapabilityMatrix({
1973
+ voice,
1974
+ locale
1975
+ }) {
1976
+ const status = voice.status ?? (voice.preview ? "preview" : void 0);
1977
+ return /* @__PURE__ */ React.createElement("div", { className: "ssml-editor-voice-capabilities", "data-voice-capabilities": "" }, /* @__PURE__ */ React.createElement("div", null, locale === "ja" ? "\u30B9\u30C6\u30FC\u30BF\u30B9" : "Status", ": ", status?.toUpperCase() ?? (locale === "ja" ? "GA" : "GA"), status === "preview" || status === "deprecated" ? /* @__PURE__ */ React.createElement("span", { role: "status", "aria-label": status, className: "ssml-editor-voice-warning-badge" }, status === "preview" ? "\u26A0 Preview" : "\u26A0 Deprecated") : null), (voice.regions?.length || voice.region) && /* @__PURE__ */ React.createElement("div", null, locale === "ja" ? "\u30EA\u30FC\u30B8\u30E7\u30F3" : "Regions", ":", " ", [...voice.regions ?? [], ...voice.region ? [voice.region] : []].filter((region, index, all) => all.indexOf(region) === index).join(", ")), voice.supportedTags && voice.supportedTags.length > 0 && /* @__PURE__ */ React.createElement("div", null, locale === "ja" ? "\u5BFE\u5FDC\u30BF\u30B0" : "Supported tags", ": ", voice.supportedTags.join(", ")), voice.unsupportedTags && voice.unsupportedTags.length > 0 && /* @__PURE__ */ React.createElement("div", { className: "ssml-editor-voice-unsupported" }, locale === "ja" ? "\u975E\u5BFE\u5FDC\u30BF\u30B0" : "Unsupported tags", ": ", voice.unsupportedTags.join(", ")));
1978
+ }
1979
+ function DefaultVoiceSelector({
1980
+ value,
1981
+ voices,
1982
+ selectedVoice,
1983
+ readOnly,
1984
+ locale,
1985
+ onChange
1986
+ }) {
1987
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
1970
1988
  "select",
1971
1989
  {
1972
1990
  "aria-label": locale === "ja" ? "\u97F3\u58F0" : "Voice",
@@ -1976,7 +1994,7 @@ function DefaultVoiceSelector({ value, voices, readOnly, locale, onChange }) {
1976
1994
  },
1977
1995
  /* @__PURE__ */ React.createElement("option", { value: "" }, locale === "ja" ? "\u97F3\u58F0\u3092\u9078\u629E" : "Select a voice"),
1978
1996
  voices.map((voice) => /* @__PURE__ */ React.createElement("option", { key: voice.name, value: voice.name }, voice.name, voice.preview || voice.status === "preview" ? " (preview)" : ""))
1979
- );
1997
+ ), selectedVoice ? /* @__PURE__ */ React.createElement(VoiceCapabilityMatrix, { voice: selectedVoice, locale }) : null);
1980
1998
  }
1981
1999
  function VisualElementInspector({
1982
2000
  document: document2,
@@ -1997,6 +2015,9 @@ function VisualElementInspector({
1997
2015
  }
1998
2016
  const fields = getElementFields(element);
1999
2017
  const availableVoices = filteredVoices(voiceCatalog, voiceLocale, voiceRegion, voiceStyle);
2018
+ const selectedVoice = voiceCatalog?.find(
2019
+ (voice) => voice.name === (element.type === "voice" ? element.name : void 0)
2020
+ );
2000
2021
  const renderSelector = renderVoiceSelector ?? DefaultVoiceSelector;
2001
2022
  return /* @__PURE__ */ React.createElement("fieldset", null, /* @__PURE__ */ React.createElement("legend", null, `<${elementLabel(element)}>`), fields.length === 0 ? /* @__PURE__ */ React.createElement("p", null, "This element is preserved in the visual tree. Edit its attributes in Code mode.") : fields.map((field) => {
2002
2023
  const value = element[field.key];
@@ -2038,6 +2059,7 @@ function VisualElementInspector({
2038
2059
  }[field.key] ?? field.label : field.label, field.key === "name" && elementLabel(element) === "voice" && voiceCatalog ? renderSelector({
2039
2060
  value: inputValue,
2040
2061
  voices: availableVoices,
2062
+ selectedVoice,
2041
2063
  readOnly,
2042
2064
  locale,
2043
2065
  onChange: (value2) => commit(updateOptionalElementProperty(document2, path, field.key, value2))
@@ -2182,6 +2204,7 @@ function VisualSsmlEditor({
2182
2204
  )) : selectedElement && isElement(selectedElement) && selectedElement.type === "mstts:turn" ? /* @__PURE__ */ React.createElement("fieldset", null, /* @__PURE__ */ React.createElement("legend", null, localizedElementLabel(selectedElement, locale)), /* @__PURE__ */ React.createElement("label", { htmlFor: "ssml-visual-turn-voice" }, locale === "ja" ? "\u97F3\u58F0" : "Voice", voiceCatalog ? (renderVoiceSelector ?? DefaultVoiceSelector)({
2183
2205
  value: selectedElement.voice ?? "",
2184
2206
  voices: filteredVoices(voiceCatalog, voiceLocale, voiceRegion, voiceStyle),
2207
+ selectedVoice: voiceCatalog?.find((voice) => voice.name === selectedElement.voice),
2185
2208
  readOnly,
2186
2209
  locale,
2187
2210
  onChange: (value) => commit(updateOptionalElementProperty(document2, selectedPath ?? [], "voice", value))