@lumiastream/ui 0.2.8-alpha.9 → 0.3.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/README.md +6 -6
- package/dist/LSButton.d.ts +32 -0
- package/dist/LSButton.js +80 -0
- package/dist/LSCheckbox.d.ts +21 -0
- package/dist/LSCheckbox.js +113 -0
- package/dist/LSColorPicker.d.ts +19 -0
- package/dist/LSColorPicker.js +316 -0
- package/dist/LSDatePicker.d.ts +15 -0
- package/dist/LSDatePicker.js +198 -0
- package/dist/LSFontPicker.d.ts +17 -0
- package/dist/LSFontPicker.js +179 -0
- package/dist/LSInput.d.ts +32 -0
- package/dist/LSInput.js +159 -0
- package/dist/LSMultiSelect.d.ts +16 -0
- package/dist/LSMultiSelect.js +274 -0
- package/dist/LSRadio.d.ts +17 -0
- package/dist/LSRadio.js +52 -0
- package/dist/LSSelect.d.ts +12 -0
- package/dist/LSSelect.js +140 -0
- package/dist/LSSliderInput.d.ts +39 -0
- package/dist/LSSliderInput.js +342 -0
- package/dist/LSTextField.d.ts +9 -0
- package/dist/LSTextField.js +63 -0
- package/dist/LSVariableInputField.d.ts +96 -0
- package/dist/LSVariableInputField.js +1402 -0
- package/dist/components.d.ts +22 -0
- package/dist/components.js +2317 -0
- package/dist/index.d.ts +26 -863
- package/dist/index.js +3136 -1446
- package/dist/se-import.d.ts +444 -0
- package/dist/se-import.js +8162 -0
- package/dist/utils/chatMedia.d.ts +106 -0
- package/dist/utils/chatMedia.js +611 -0
- package/dist/utils.d.ts +111 -0
- package/dist/utils.js +830 -0
- package/package.json +76 -7
|
@@ -0,0 +1,1402 @@
|
|
|
1
|
+
// #style-inject:#style-inject
|
|
2
|
+
function styleInject(css, { insertAt } = {}) {
|
|
3
|
+
if (!css || typeof document === "undefined") return;
|
|
4
|
+
const head = document.head || document.getElementsByTagName("head")[0];
|
|
5
|
+
const style = document.createElement("style");
|
|
6
|
+
style.type = "text/css";
|
|
7
|
+
if (insertAt === "top") {
|
|
8
|
+
if (head.firstChild) {
|
|
9
|
+
head.insertBefore(style, head.firstChild);
|
|
10
|
+
} else {
|
|
11
|
+
head.appendChild(style);
|
|
12
|
+
}
|
|
13
|
+
} else {
|
|
14
|
+
head.appendChild(style);
|
|
15
|
+
}
|
|
16
|
+
if (style.styleSheet) {
|
|
17
|
+
style.styleSheet.cssText = css;
|
|
18
|
+
} else {
|
|
19
|
+
style.appendChild(document.createTextNode(css));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// src/lumia-ui.css
|
|
24
|
+
styleInject(".ls-color-picker,\n.ls-color-picker *,\n.mui-multi-select,\n.mui-multi-select *,\n.ls-multi-select-value,\n.ls-multi-select-value *,\n.ls-variable-picker,\n.ls-variable-picker *,\n.ls-variable-token,\n.ls-variable-token *,\n.ls-font-picker,\n.ls-font-picker *,\n.mui-ls-input,\n.mui-ls-input * {\n box-sizing: border-box;\n}\n.ls-color-picker button,\n.mui-multi-select button {\n font: inherit;\n letter-spacing: inherit;\n color: inherit;\n margin: 0;\n}\n.ls-color-picker__preview {\n appearance: none;\n -webkit-appearance: none;\n background-color: transparent;\n background-image: none;\n cursor: pointer;\n text-transform: uppercase;\n user-select: none;\n}\n.mui-ls-button.Mui-disabled {\n color: var(--neutralLight2, var(--white2, #cac9d5));\n opacity: 0.45;\n background-color: var(--separator, #0a0821);\n cursor: not-allowed;\n}\n.mui-ls-button {\n border-radius: var(--radius, 1rem);\n padding: 0.375rem 1.5rem;\n text-transform: uppercase;\n}\n.mui-ls-button.MuiButton-sizeSmall {\n padding: 0.25rem 1rem;\n}\n.mui-ls-button.MuiButton-sizeLarge {\n padding: 0.625rem 2rem;\n}\n.mui-ls-button--extended {\n padding-inline: 3rem;\n}\n.mui-ls-button.MuiButton-containedPrimary,\n.mui-ls-button.Mui-disabled.MuiButton-containedPrimary {\n background: var(--primary, #ff4076);\n color: var(--alwayswhite, #fff) !important;\n}\n.mui-ls-button.MuiButton-containedSecondary {\n background-color: var(--secondary, #535395);\n color: var(--alwayswhite, #fff) !important;\n}\n.mui-ls-button.Mui-disabled.MuiButton-containedSecondary {\n background-color: var(--secondary, #535395);\n color: var(--neutralLight2, var(--white2, #cac9d5));\n opacity: 0.4;\n}\n.mui-ls-button.MuiButton-outlinedPrimary {\n color: var(--primary, #ff4076);\n border-color: var(--primary, #ff4076);\n}\n.mui-ls-button.MuiButton-outlinedPrimary:hover {\n border-color: var(--primary, #ff4076);\n background-color: color-mix(in srgb, var(--primary, #ff4076) 12%, transparent);\n}\n.mui-ls-button.MuiButton-outlinedSecondary {\n color: var(--neutralLight1, var(--white, #fff));\n border-color: var(--secondary, #535395);\n}\n.mui-ls-button.MuiButton-outlinedSecondary.Mui-disabled {\n color: var(--neutralLight2, var(--white2, #cac9d5));\n border-color: var(--neutralDark4, var(--cardborder, #393853));\n background-color: var(--transwhite, rgba(255, 255, 255, 0.05));\n opacity: 0.5;\n}\n.mui-ls-button.MuiButton-outlinedSecondary:hover {\n border-color: var(--secondary, #535395);\n background-color: var(--transwhite, rgba(255, 255, 255, 0.05));\n}\n.mui-ls-button.MuiButton-containedError {\n color: var(--alwayswhite, #fff) !important;\n}\n.mui-ls-button.MuiButton-outlinedError {\n color: var(--error, #fd5454);\n border-color: var(--error, #fd5454);\n}\n.mui-ls-button.MuiButton-outlinedError:hover {\n border-color: var(--error, #fd5454);\n background-color: color-mix(in srgb, var(--error, #fd5454) 12%, transparent);\n}\n.mui-ls-button--neutral.mui-ls-button--contained {\n background-color: var(--neutralDark4, var(--cardborder, #393853));\n color: var(--neutralLight1, var(--white, #fff)) !important;\n}\n.mui-ls-button--neutral.mui-ls-button--contained:hover {\n background-color: color-mix(in srgb, var(--neutralDark4, var(--cardborder, #393853)) 82%, var(--neutralLight1, #fff));\n}\n.mui-ls-button--neutral.mui-ls-button--outlined {\n color: var(--neutralLight1, var(--white, #fff));\n border-color: var(--neutralDark4, var(--cardborder, #393853));\n background-color: transparent;\n}\n.mui-ls-button--neutral.mui-ls-button--outlined:hover {\n border-color: var(--neutralLight3, var(--grey, #9392a1));\n background-color: var(--transwhite, rgba(255, 255, 255, 0.05));\n}\n.mui-ls-button--neutral.mui-ls-button--text {\n color: var(--neutralLight1, var(--white, #fff));\n}\n.mui-ls-button--neutral.mui-ls-button--text:hover {\n background-color: var(--transwhite, rgba(255, 255, 255, 0.05));\n}\n.mui-ls-button svg {\n max-height: 24px;\n max-width: 24px;\n}\n.mui-ls-input,\n.ls-font-picker,\n.ls-color-picker__input {\n width: 100%;\n}\n.mui-ls-input,\n.mui-ls-select-form-control,\n.mui-multi-select,\n.ls-font-picker,\n.mui-ls-slider-input-root {\n --ls-control-height: 55px;\n}\n.mui-ls-input .MuiOutlinedInput-root,\n.mui-ls-input .MuiInputBase-root,\n.mui-ls-input .MuiOutlinedInput-notchedOutline,\n.mui-ls-select.MuiOutlinedInput-root,\n.mui-ls-select .MuiOutlinedInput-notchedOutline,\n.mui-multi-select .mui-ls-select.MuiOutlinedInput-root,\n.mui-multi-select .mui-ls-select .MuiOutlinedInput-notchedOutline,\n.ls-font-picker .MuiOutlinedInput-root,\n.ls-font-picker .MuiInputBase-root,\n.ls-font-picker .MuiOutlinedInput-notchedOutline,\n.ls-color-picker__input .MuiOutlinedInput-root,\n.ls-color-picker__input .MuiInputBase-root,\n.ls-color-picker__input .MuiOutlinedInput-notchedOutline {\n border-radius: var(--radius) !important;\n}\n.mui-ls-input .MuiInputBase-root,\n.mui-ls-select.MuiInputBase-root,\n.mui-multi-select .mui-ls-select.MuiInputBase-root,\n.ls-font-picker .MuiInputBase-root {\n min-height: var(--ls-control-height);\n}\n.mui-ls-input.small .MuiInputBase-root {\n min-height: 25px;\n}\n.mui-ls-input.medium .MuiInputBase-root {\n min-height: 35px;\n}\n.mui-ls-input.noMinHeight .MuiInputBase-root {\n min-height: unset;\n}\n.mui-ls-date-picker input[type=datetime-local]::-webkit-calendar-picker-indicator {\n cursor: pointer;\n opacity: 0.9;\n filter: invert(1);\n}\n.mui-ls-select .MuiSelect-select,\n.mui-multi-select .MuiSelect-select {\n display: flex;\n min-height: calc(var(--ls-control-height) - 2px);\n align-items: center;\n box-sizing: border-box;\n border-radius: var(--radius);\n}\n.mui-multi-select .MuiSelect-select {\n min-width: 0;\n}\n.MuiSvgIcon-root svg {\n color: var(--neutralLight1, var(--white, #fff)) !important;\n}\n.mui-ls-input .MuiSvgIcon-root svg path {\n fill: currentcolor;\n stroke: currentcolor;\n}\n.mui-ls-input input::placeholder,\n.mui-ls-input textarea::placeholder {\n color: var(--neutralLight3, var(--grey, #9392a1));\n opacity: 1;\n}\n.mui-ls-input .Mui-focused .MuiOutlinedInput-notchedOutline,\n.mui-ls-input .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline {\n border-color: var(--primary, #ff4076) !important;\n}\n.ls-variable-autocomplete-popper .MuiAutocomplete-paper,\n.ls-variable-autocomplete-paper {\n border: 1px solid var(--neutralDark4, var(--cardborder, #393853)) !important;\n border-radius: var(--radius, 1rem) !important;\n background: var(--neutralDark2, var(--cardbackground, #211f45)) !important;\n color: var(--neutralLight1, var(--white, #fff)) !important;\n box-shadow: 0 16px 32px rgba(0, 0, 0, 0.32) !important;\n overflow: hidden !important;\n}\n.ls-variable-autocomplete-popper .MuiAutocomplete-listbox,\n.ls-variable-autocomplete-listbox {\n padding: 0.25rem 0 !important;\n background: var(--neutralDark2, var(--cardbackground, #211f45)) !important;\n color: var(--neutralLight1, var(--white, #fff)) !important;\n}\n.ls-variable-autocomplete-popper .MuiAutocomplete-option,\n.ls-variable-autocomplete-listbox .MuiAutocomplete-option {\n display: flex !important;\n min-height: 44px !important;\n align-items: center !important;\n padding: 0.625rem 1rem !important;\n color: var(--neutralLight1, var(--white, #fff)) !important;\n font-size: 1rem !important;\n line-height: 1.35 !important;\n cursor: pointer !important;\n transition: background-color 120ms ease, color 120ms ease !important;\n}\n.ls-variable-autocomplete-popper .MuiAutocomplete-option > *,\n.ls-variable-autocomplete-listbox .MuiAutocomplete-option > * {\n min-width: 0;\n}\n.ls-variable-autocomplete-popper .MuiAutocomplete-option:hover,\n.ls-variable-autocomplete-popper .MuiAutocomplete-option.Mui-focused,\n.ls-variable-autocomplete-popper .MuiAutocomplete-option[data-focus=true],\n.ls-variable-autocomplete-popper .MuiAutocomplete-option[aria-selected=true],\n.ls-variable-autocomplete-listbox .MuiAutocomplete-option:hover,\n.ls-variable-autocomplete-listbox .MuiAutocomplete-option.Mui-focused,\n.ls-variable-autocomplete-listbox .MuiAutocomplete-option[data-focus=true],\n.ls-variable-autocomplete-listbox .MuiAutocomplete-option[aria-selected=true] {\n background: var( --cardHover, var(--transwhite, rgba(255, 255, 255, 0.05)) ) !important;\n color: var(--neutralLight1, var(--white, #fff)) !important;\n}\n.ls-variable-option {\n gap: 0.75rem;\n}\n.ls-variable-option__thumb {\n width: 40px;\n height: 40px;\n flex: 0 0 40px;\n border-radius: var(--radius, 1rem);\n object-fit: cover;\n}\n.ls-variable-option__thumb--placeholder {\n background: var(--neutralDark4, var(--cardborder, #393853));\n}\n.ls-variable-option__body {\n min-width: 0;\n}\n.ls-variable-option__label {\n color: var(--neutralLight1, var(--white, #fff));\n font-weight: 500;\n line-height: 1.25;\n}\n.ls-variable-option__helper {\n margin-top: 0.125rem;\n color: var(--neutralLight3, var(--grey, #9392a1));\n font-size: 0.875rem;\n line-height: 1.25;\n}\n.ls-variable-autocomplete-popup-indicator,\n.ls-variable-autocomplete-popup-indicator.MuiIconButton-root,\n.ls-variable-autocomplete-popup-indicator svg {\n color: var(--neutralLight1, var(--white, #fff)) !important;\n}\n.ls-variable-autocomplete-popup-indicator svg path {\n fill: currentcolor !important;\n stroke: currentcolor !important;\n}\n.ls-variable-input-adornment,\n.ls-variable-input-adornment.MuiInputAdornment-root {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n height: 24px;\n width: 24px;\n min-width: 24px;\n margin-left: 0.35rem;\n border-radius: var(--radius, 1rem);\n background: var(--primary, #ff4076) !important;\n color: var(--alwayswhite, var(--white, #fff)) !important;\n font-weight: 800;\n line-height: 1;\n letter-spacing: 0;\n cursor: pointer;\n user-select: none;\n}\n.ls-variable-input-adornment svg,\n.ls-variable-input-adornment path {\n color: currentcolor !important;\n fill: currentcolor !important;\n stroke: currentcolor !important;\n}\n.ls-variable-input-adornment:hover,\n.ls-variable-input-adornment.MuiInputAdornment-root:hover {\n filter: brightness(1.08);\n}\n.ls-variable-input-adornment:active,\n.ls-variable-input-adornment.MuiInputAdornment-root:active {\n filter: brightness(0.96);\n}\n.mui-ls-slider-input-root {\n width: 100%;\n}\n.mui-ls-slider-input-fieldset {\n position: relative;\n min-width: 0;\n width: 100%;\n min-height: var(--ls-control-height);\n margin: 0;\n border: 2px solid var(--neutralDark4, var(--cardborder, #393853));\n border-radius: var(--radius, 1rem);\n padding: 0 0.875rem 0.5rem 0.875rem;\n background: transparent;\n color: var(--neutralLight1, var(--white, #fff));\n}\n.mui-ls-slider-input-fieldset:hover {\n border-color: var(--primary, #ff4076);\n}\n.mui-ls-slider-input-legend {\n display: block;\n width: auto;\n max-width: calc(100% - 1rem);\n margin: 0;\n padding: 0 0.25rem;\n color: var(--neutralLight1, var(--white, #fff));\n font-size: 0.875rem;\n line-height: 1.1;\n white-space: nowrap;\n}\n.mui-ls-slider-input-row {\n display: flex;\n min-width: 0;\n min-height: calc(var(--ls-control-height) - 14px);\n align-items: center;\n gap: 1rem;\n}\n.mui-ls-slider-input-row--slider {\n flex-wrap: nowrap;\n}\n.mui-ls-slider-input-row--input {\n justify-content: stretch;\n}\n.mui-ls-slider-input-value.mui-ls-input {\n margin: 0;\n}\n.mui-ls-slider-input-value.mui-ls-input .MuiFormControl-root,\n.mui-ls-slider-input-value.mui-ls-input .MuiTextField-root {\n margin: 0;\n}\n.mui-ls-slider-input-value.mui-ls-input .MuiInputBase-root {\n min-height: 36px;\n}\n.mui-ls-slider-input-value.mui-ls-input .MuiOutlinedInput-notchedOutline {\n border-color: var(--neutralDark4, var(--cardborder, #393853));\n}\n.mui-ls-slider-input-helper {\n display: block;\n margin-top: 0.25rem;\n color: var(--neutralLight3, var(--grey, #9392a1));\n font-size: 0.75rem;\n line-height: 1.25;\n}\n.ls-multi-select-value {\n display: flex;\n width: 100%;\n min-width: 0;\n flex-wrap: nowrap;\n align-items: center;\n justify-content: space-between;\n gap: 0.5rem;\n overflow: hidden;\n white-space: nowrap;\n}\n.ls-multi-select-value__label {\n min-width: 0;\n flex: 1 1 0%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.ls-multi-select-value__count {\n flex-shrink: 0;\n white-space: nowrap;\n}\n.ls-color-picker__preview {\n position: relative;\n display: inline-block;\n width: 1.5rem;\n height: 1.5rem;\n flex-shrink: 0;\n padding: 0;\n border: 1px solid color-mix(in srgb, #fff 25%, transparent);\n border-radius: var(--radius, 1rem);\n background-size: cover;\n background-position: center;\n background-repeat: no-repeat;\n box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);\n color: transparent;\n line-height: 0;\n}\n.ls-color-picker__preview:disabled {\n cursor: not-allowed;\n opacity: 0.5;\n}\n.ls-color-picker__preview:focus {\n outline: none;\n}\n.ls-color-picker__preview:focus-visible {\n box-shadow:\n 0 0 0 2px var(--primary, #ff4076),\n 0 0 0 4px var(--neutralDark1, #1b1a28),\n 0 0 0 1px rgba(0, 0, 0, 0.25);\n}\n.ls-color-picker__gradient circle,\n.ls-color-picker__gradient polyline {\n stroke: #fff;\n}\n.ls-variable-picker {\n --variable-custom-color: var(--customVariables, #69ffd2);\n --variable-function-color: var( --functionVariables, var(--semanticPurple, #b489ff) );\n --variable-normal-color: var(--normalVariables, var(--semanticBlue, #65b8ff));\n display: flex;\n width: 92vw;\n max-width: 1100px;\n min-height: 50vh;\n max-height: 55vh;\n flex-direction: column;\n overflow: hidden;\n padding: 1rem;\n}\n.ls-variable-picker__field {\n margin: 0 0 0.75rem;\n border: 1px solid color-mix(in srgb, var(--primary, #ff4076) 42%, var(--neutralDark4, #393853));\n border-radius: var(--radius, 1rem);\n padding: 0.5rem;\n}\n.ls-variable-picker__legend {\n padding-inline: 0.375rem;\n color: var(--primary, #ff4076);\n font-size: 0.75rem;\n font-weight: 700;\n}\n.ls-variable-picker__intro {\n margin-bottom: 1rem;\n color: var(--neutralLight2, #cac9d5);\n}\n.ls-variable-picker__header,\n.ls-variable-picker__row {\n display: grid;\n grid-template-columns: minmax(300px, 1.5fr) 1fr 1fr;\n gap: 2rem;\n}\n.ls-variable-picker__header {\n margin-bottom: 0.25rem;\n padding-inline: 0.25rem;\n padding-right: 1.7rem;\n color: var(--neutralLight3, #9392a1);\n}\n.ls-variable-picker__list {\n height: 100%;\n overflow: auto;\n padding-right: 1rem;\n}\n.ls-variable-picker__row {\n cursor: pointer;\n align-items: start;\n border-bottom: 1px solid color-mix(in srgb, var(--neutralDark4, #393853) 70%, transparent);\n padding: 1rem 0.25rem;\n}\n.ls-variable-picker__row--no-border {\n border-bottom: 0;\n}\n.ls-variable-picker__token-cell {\n display: flex;\n min-width: 0;\n align-items: center;\n gap: 0.375rem;\n}\n.ls-variable-picker__expand-toggle,\n.ls-variable-picker__expand-spacer {\n width: 24px;\n height: 24px;\n flex: 0 0 24px;\n}\n.ls-variable-picker__expand-toggle {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n border: 1px solid color-mix(in srgb, var(--neutralDark4, #393853) 75%, transparent);\n border-radius: var(--radius, 1rem);\n padding: 0;\n background: var(--neutralDark3, var(--containerbackground, #1f1f3a));\n color: var(--neutralLight2, #cac9d5);\n transition:\n background-color 140ms ease,\n border-color 140ms ease,\n color 140ms ease,\n transform 140ms ease;\n}\n.ls-variable-picker__expand-toggle:hover {\n border-color: var(--primary, #ff4076);\n background: color-mix(in srgb, var(--primary, #ff4076) 16%, var(--neutralDark3, #1f1f3a));\n color: var(--neutralLight1, #fff);\n}\n.ls-variable-picker__expand-toggle svg {\n transform: rotate(-90deg);\n transition: transform 140ms ease;\n}\n.ls-variable-picker__expand-toggle--expanded svg {\n transform: rotate(0deg);\n}\n.ls-variable-picker__row:active {\n opacity: 0.8;\n}\n.ls-variable-picker__description {\n max-width: 600px;\n overflow-wrap: break-word;\n line-height: 1.25;\n word-break: break-all;\n}\n.ls-variable-picker__value {\n min-width: 0;\n}\n.ls-variable-picker__value-input {\n width: 100%;\n min-width: 0;\n cursor: text;\n overflow: hidden;\n border: 0;\n background: transparent;\n color: var(--neutralLight1, var(--white, #fff));\n caret-color: transparent;\n font: inherit;\n font-size: 1rem;\n line-height: 1.25;\n outline: 0;\n padding: 0;\n text-overflow: ellipsis;\n}\n.ls-variable-picker__value-input:focus {\n outline: 0;\n}\n.ls-variable-picker__value-input::selection {\n background: color-mix(in srgb, var(--primary, #ff4076) 45%, transparent);\n color: var(--alwayswhite, var(--white, #fff));\n}\n.ls-variable-token {\n display: flex;\n min-width: 0;\n align-items: center;\n}\n.ls-variable-token--custom {\n color: var(--customVariables, #69ffd2);\n}\n.ls-variable-token--function {\n color: var(--functionVariables, var(--semanticPurple, #b489ff));\n}\n.ls-variable-token--system {\n color: var(--normalVariables, var(--semanticBlue, #65b8ff));\n}\n.ls-variable-token__name {\n min-width: 0;\n word-break: break-all;\n}\n.ls-variable-token__badge {\n display: inline-flex;\n margin-left: 0.5rem;\n flex-shrink: 0;\n align-items: center;\n border: 1px solid currentcolor;\n border-radius: var(--radius, 1rem);\n padding-inline: 0.25rem;\n padding-block: 0;\n font-size: 10px;\n font-weight: 600;\n line-height: 1;\n text-transform: uppercase;\n}\n");
|
|
25
|
+
|
|
26
|
+
// src/components/LSVariableInputField/LSVariableInputField.tsx
|
|
27
|
+
import Autocomplete, {
|
|
28
|
+
createFilterOptions
|
|
29
|
+
} from "@mui/material/Autocomplete";
|
|
30
|
+
import InputAdornment2 from "@mui/material/InputAdornment";
|
|
31
|
+
import Popover from "@mui/material/Popover";
|
|
32
|
+
import Search from "@mui/icons-material/Search";
|
|
33
|
+
import KeyboardArrowDown from "@mui/icons-material/KeyboardArrowDown";
|
|
34
|
+
import Tooltip from "@mui/material/Tooltip";
|
|
35
|
+
import {
|
|
36
|
+
Fragment,
|
|
37
|
+
createContext,
|
|
38
|
+
forwardRef as forwardRef3,
|
|
39
|
+
useCallback,
|
|
40
|
+
useContext,
|
|
41
|
+
useEffect,
|
|
42
|
+
useMemo,
|
|
43
|
+
useRef,
|
|
44
|
+
useState
|
|
45
|
+
} from "react";
|
|
46
|
+
|
|
47
|
+
// src/components/LSInput/LSInput.tsx
|
|
48
|
+
import FormControl from "@mui/material/FormControl";
|
|
49
|
+
import InputAdornment from "@mui/material/InputAdornment";
|
|
50
|
+
import TextField from "@mui/material/TextField";
|
|
51
|
+
import classNames from "classnames";
|
|
52
|
+
import { forwardRef } from "react";
|
|
53
|
+
import { jsx } from "react/jsx-runtime";
|
|
54
|
+
var LSInput = forwardRef(
|
|
55
|
+
(props, ref) => {
|
|
56
|
+
const hasExplicitValue = Object.prototype.hasOwnProperty.call(props, "value");
|
|
57
|
+
const {
|
|
58
|
+
startAdornment,
|
|
59
|
+
endAdornment,
|
|
60
|
+
inputBeforeText,
|
|
61
|
+
inputAfterText,
|
|
62
|
+
maxWidth,
|
|
63
|
+
className = "",
|
|
64
|
+
InputProps: inputPropsProp,
|
|
65
|
+
InputLabelProps: inputLabelPropsProp,
|
|
66
|
+
inputProps: htmlInputPropsProp,
|
|
67
|
+
slotProps: slotPropsProp,
|
|
68
|
+
onChange,
|
|
69
|
+
onChangeStart,
|
|
70
|
+
onChangeEnd,
|
|
71
|
+
type,
|
|
72
|
+
value,
|
|
73
|
+
helperText,
|
|
74
|
+
error,
|
|
75
|
+
style,
|
|
76
|
+
centerText,
|
|
77
|
+
$noMinHeight,
|
|
78
|
+
bypasscolor,
|
|
79
|
+
textColor,
|
|
80
|
+
fullWidth = true,
|
|
81
|
+
...rest
|
|
82
|
+
} = props;
|
|
83
|
+
const isNumberInput = type === "number";
|
|
84
|
+
const labelIdFallback = typeof rest.label === "string" ? rest.label : void 0;
|
|
85
|
+
const normalizedValue = isNumberInput && (value === void 0 || value === null) ? "" : value;
|
|
86
|
+
const handleChange = (event) => {
|
|
87
|
+
const rawValue = event.target.value;
|
|
88
|
+
let sanitizedValue = rawValue;
|
|
89
|
+
if (isNumberInput) {
|
|
90
|
+
if (rawValue === "") {
|
|
91
|
+
sanitizedValue = void 0;
|
|
92
|
+
} else {
|
|
93
|
+
const numericValue = Number(rawValue);
|
|
94
|
+
sanitizedValue = Number.isNaN(numericValue) ? void 0 : numericValue;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
onChangeStart?.(event, sanitizedValue);
|
|
98
|
+
onChange?.(event, sanitizedValue);
|
|
99
|
+
onChangeEnd?.(event, sanitizedValue);
|
|
100
|
+
};
|
|
101
|
+
const resolvedStartAdornment = inputPropsProp?.startAdornment ?? (startAdornment ? /* @__PURE__ */ jsx(InputAdornment, { position: "start", children: startAdornment }) : inputBeforeText ? /* @__PURE__ */ jsx(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx("span", { className: "mui-ls-input-affix", children: inputBeforeText }) }) : void 0);
|
|
102
|
+
const resolvedEndAdornment = inputPropsProp?.endAdornment ?? (endAdornment ? /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: endAdornment }) : inputAfterText ? /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx("span", { className: "mui-ls-input-affix", children: inputAfterText }) }) : void 0);
|
|
103
|
+
const inputSlotProps = {
|
|
104
|
+
...inputPropsProp,
|
|
105
|
+
startAdornment: resolvedStartAdornment,
|
|
106
|
+
endAdornment: resolvedEndAdornment,
|
|
107
|
+
readOnly: rest.readOnly ?? inputPropsProp?.readOnly,
|
|
108
|
+
sx: {
|
|
109
|
+
...inputPropsProp?.sx ?? {},
|
|
110
|
+
"& input, & textarea": {
|
|
111
|
+
textAlign: centerText ? "center" : void 0,
|
|
112
|
+
color: textColor ?? void 0
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const inputLabelProps = {
|
|
117
|
+
shrink: true,
|
|
118
|
+
...inputLabelPropsProp
|
|
119
|
+
};
|
|
120
|
+
const helperContent = helperText ?? (typeof error === "string" ? error : "");
|
|
121
|
+
const hasError = typeof error === "string" ? true : Boolean(error);
|
|
122
|
+
const resolvedMaxWidth = maxWidth ?? style?.maxWidth;
|
|
123
|
+
const valueProps = hasExplicitValue ? { value: normalizedValue } : {};
|
|
124
|
+
const slotProps = {
|
|
125
|
+
...slotPropsProp ?? {},
|
|
126
|
+
input: {
|
|
127
|
+
...slotPropsProp?.input ?? {},
|
|
128
|
+
...inputSlotProps,
|
|
129
|
+
sx: {
|
|
130
|
+
...slotPropsProp?.input?.sx ?? {},
|
|
131
|
+
...inputSlotProps.sx
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
inputLabel: {
|
|
135
|
+
...slotPropsProp?.inputLabel ?? {},
|
|
136
|
+
...inputLabelProps
|
|
137
|
+
},
|
|
138
|
+
htmlInput: {
|
|
139
|
+
...slotPropsProp?.htmlInput ?? {},
|
|
140
|
+
...htmlInputPropsProp ?? {}
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
const TextFieldComponent = TextField;
|
|
144
|
+
return /* @__PURE__ */ jsx(
|
|
145
|
+
FormControl,
|
|
146
|
+
{
|
|
147
|
+
variant: "outlined",
|
|
148
|
+
className: classNames("mui-ls-input", className, {
|
|
149
|
+
noMinHeight: $noMinHeight,
|
|
150
|
+
bypassMuiColor: bypasscolor || bypasscolor === "default"
|
|
151
|
+
}),
|
|
152
|
+
style: { ...style, maxWidth: resolvedMaxWidth, width: fullWidth ? "100%" : style?.width },
|
|
153
|
+
children: /* @__PURE__ */ jsx(
|
|
154
|
+
TextFieldComponent,
|
|
155
|
+
{
|
|
156
|
+
...rest,
|
|
157
|
+
...valueProps,
|
|
158
|
+
type,
|
|
159
|
+
id: rest.id ?? rest.name ?? labelIdFallback,
|
|
160
|
+
label: rest.label,
|
|
161
|
+
size: rest.size,
|
|
162
|
+
margin: "dense",
|
|
163
|
+
variant: "outlined",
|
|
164
|
+
color: bypasscolor === "default" || bypasscolor === "inherit" ? "primary" : bypasscolor,
|
|
165
|
+
fullWidth,
|
|
166
|
+
onChange: handleChange,
|
|
167
|
+
slotProps,
|
|
168
|
+
inputRef: ref,
|
|
169
|
+
helperText: helperContent,
|
|
170
|
+
error: hasError
|
|
171
|
+
}
|
|
172
|
+
)
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
LSInput.displayName = "LSInput";
|
|
178
|
+
|
|
179
|
+
// src/components/LSTextField/LSTextField.tsx
|
|
180
|
+
import TextField2 from "@mui/material/TextField";
|
|
181
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
182
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
183
|
+
var LSTextField = forwardRef2(
|
|
184
|
+
(props, ref) => {
|
|
185
|
+
const { InputLabelProps, InputProps, slotProps, ...rest } = props;
|
|
186
|
+
return /* @__PURE__ */ jsx2(
|
|
187
|
+
TextField2,
|
|
188
|
+
{
|
|
189
|
+
...rest,
|
|
190
|
+
variant: "outlined",
|
|
191
|
+
className: "mui-ls-input",
|
|
192
|
+
slotProps: {
|
|
193
|
+
...slotProps ?? {},
|
|
194
|
+
input: {
|
|
195
|
+
...slotProps?.input ?? {},
|
|
196
|
+
...InputProps ?? {},
|
|
197
|
+
sx: {
|
|
198
|
+
...slotProps?.input?.sx ?? {},
|
|
199
|
+
...InputProps?.sx ?? {}
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
inputLabel: {
|
|
203
|
+
...slotProps?.inputLabel ?? {},
|
|
204
|
+
shrink: true,
|
|
205
|
+
...InputLabelProps ?? {}
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
ref
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
);
|
|
213
|
+
LSTextField.displayName = "LSTextField";
|
|
214
|
+
|
|
215
|
+
// src/components/LSVariableInputField/LSVariableInputField.tsx
|
|
216
|
+
import { Fragment as Fragment2, jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
217
|
+
import { createElement } from "react";
|
|
218
|
+
var LSVariableInputContext = createContext({});
|
|
219
|
+
var LSVariableInputProvider = ({
|
|
220
|
+
children,
|
|
221
|
+
value
|
|
222
|
+
}) => {
|
|
223
|
+
return /* @__PURE__ */ jsx3(LSVariableInputContext.Provider, { value, children });
|
|
224
|
+
};
|
|
225
|
+
var DEFAULT_FUNCTION_VARIABLES = [
|
|
226
|
+
"sum_variables",
|
|
227
|
+
"offset_count",
|
|
228
|
+
"read_file",
|
|
229
|
+
"read_url",
|
|
230
|
+
"selection",
|
|
231
|
+
"random",
|
|
232
|
+
"random_input",
|
|
233
|
+
"get_commands",
|
|
234
|
+
"get_all_commands",
|
|
235
|
+
"convert_color_to_hex",
|
|
236
|
+
"get_latest_file_from_folder",
|
|
237
|
+
"get_random_file_from_folder",
|
|
238
|
+
"screenshot",
|
|
239
|
+
"overlay_screenshot",
|
|
240
|
+
"obs_screenshot",
|
|
241
|
+
"obs_vertical_replay",
|
|
242
|
+
"obs_replay",
|
|
243
|
+
"get_queue_count",
|
|
244
|
+
"lumia_uptime",
|
|
245
|
+
"twitch_uptime",
|
|
246
|
+
"youtube_uptime",
|
|
247
|
+
"facebook_uptime",
|
|
248
|
+
"twitch_followage",
|
|
249
|
+
"twitch_next_ad",
|
|
250
|
+
"twitch_get_avatar",
|
|
251
|
+
"get_var_from_msg",
|
|
252
|
+
"get_user_loyalty_points",
|
|
253
|
+
"translate",
|
|
254
|
+
"ai_prompt",
|
|
255
|
+
"viewer_profile_summary"
|
|
256
|
+
];
|
|
257
|
+
var MAX_OBJECT_DEPTH = 5;
|
|
258
|
+
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
259
|
+
var isExpandableValue = (value) => {
|
|
260
|
+
if (isPlainObject(value)) return Object.keys(value).length > 0;
|
|
261
|
+
if (Array.isArray(value)) return value.length > 0;
|
|
262
|
+
return false;
|
|
263
|
+
};
|
|
264
|
+
var isPrimitiveValue = (value) => value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
265
|
+
var renderPrimitiveValue = (value) => {
|
|
266
|
+
if (value === null || value === void 0) return "";
|
|
267
|
+
if (typeof value === "boolean") return value.toString();
|
|
268
|
+
if (typeof value === "number") return value.toString();
|
|
269
|
+
if (typeof value === "string") return value;
|
|
270
|
+
return String(value);
|
|
271
|
+
};
|
|
272
|
+
var renderComplexPreview = (value) => {
|
|
273
|
+
if (Array.isArray(value)) {
|
|
274
|
+
return `Array(${value.length}) [${value.slice(0, 3).map(
|
|
275
|
+
(item) => typeof item === "string" ? `"${item}"` : typeof item === "object" ? "{...}" : String(item)
|
|
276
|
+
).join(", ")}${value.length > 3 ? "..." : ""}]`;
|
|
277
|
+
}
|
|
278
|
+
const keys = Object.keys(value);
|
|
279
|
+
return `Object {${keys.slice(0, 2).join(", ")}${keys.length > 2 ? "..." : ""}}`;
|
|
280
|
+
};
|
|
281
|
+
var getVariableValueDisplay = (value) => {
|
|
282
|
+
const isComplexValue = !isPrimitiveValue(value) && value !== null && typeof value === "object";
|
|
283
|
+
const displayValue = isComplexValue ? renderComplexPreview(value) : renderPrimitiveValue(value);
|
|
284
|
+
const fullValue = isComplexValue ? JSON.stringify(value, null, 2) : renderPrimitiveValue(value);
|
|
285
|
+
return { displayValue, fullValue, isComplexValue };
|
|
286
|
+
};
|
|
287
|
+
var buildValueChildren = (value, parentPath, depth) => {
|
|
288
|
+
if (depth >= MAX_OBJECT_DEPTH) return [];
|
|
289
|
+
if (isPlainObject(value)) {
|
|
290
|
+
return Object.keys(value).map((key) => {
|
|
291
|
+
const childValue = value[key];
|
|
292
|
+
const relativePath = parentPath ? `${parentPath}.${key}` : key;
|
|
293
|
+
const expandable = depth + 1 < MAX_OBJECT_DEPTH && isExpandableValue(childValue);
|
|
294
|
+
return {
|
|
295
|
+
relativePath,
|
|
296
|
+
key,
|
|
297
|
+
displayKey: key,
|
|
298
|
+
depth: depth + 1,
|
|
299
|
+
value: childValue,
|
|
300
|
+
isExpandable: expandable,
|
|
301
|
+
children: expandable ? buildValueChildren(childValue, relativePath, depth + 1) : []
|
|
302
|
+
};
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
if (Array.isArray(value)) {
|
|
306
|
+
return value.map((item, idx) => {
|
|
307
|
+
const relativePath = parentPath ? `${parentPath}.${idx}` : String(idx);
|
|
308
|
+
const expandable = depth + 1 < MAX_OBJECT_DEPTH && isExpandableValue(item);
|
|
309
|
+
return {
|
|
310
|
+
relativePath,
|
|
311
|
+
key: String(idx),
|
|
312
|
+
displayKey: `[${idx}]`,
|
|
313
|
+
depth: depth + 1,
|
|
314
|
+
value: item,
|
|
315
|
+
isExpandable: expandable,
|
|
316
|
+
children: expandable ? buildValueChildren(item, relativePath, depth + 1) : []
|
|
317
|
+
};
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
return [];
|
|
321
|
+
};
|
|
322
|
+
var isVariableRecord = (value) => {
|
|
323
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
324
|
+
const v = value;
|
|
325
|
+
return typeof v.name === "string" && ("system" in v || "origin" in v || "value" in v);
|
|
326
|
+
};
|
|
327
|
+
var synthesizeRecord = (name, value) => ({
|
|
328
|
+
name,
|
|
329
|
+
system: false,
|
|
330
|
+
origin: "",
|
|
331
|
+
description: "",
|
|
332
|
+
value: value ?? ""
|
|
333
|
+
});
|
|
334
|
+
var normalizeVariableRecords = (systemVariables) => {
|
|
335
|
+
const out = {};
|
|
336
|
+
if (!systemVariables) return out;
|
|
337
|
+
for (const [key, raw] of Object.entries(systemVariables)) {
|
|
338
|
+
if (raw === void 0 || raw === null) continue;
|
|
339
|
+
out[key] = isVariableRecord(raw) ? raw : synthesizeRecord(key, raw);
|
|
340
|
+
}
|
|
341
|
+
return out;
|
|
342
|
+
};
|
|
343
|
+
var defaultTranslate = (key, fallback, options) => {
|
|
344
|
+
if (fallback && fallback !== "-") return fallback;
|
|
345
|
+
if (key === "overlay-variables.variables-description")
|
|
346
|
+
return "Use variables that will automatically be replaced before sending out the text";
|
|
347
|
+
if (key === "overlay-variables.variable" || key === "commands.variable")
|
|
348
|
+
return "Variable";
|
|
349
|
+
if (key === "overlay-variables.description" || key === "commands.description")
|
|
350
|
+
return "Description";
|
|
351
|
+
if (key === "commands.suggested-variables") return "Suggested Variables";
|
|
352
|
+
if (key === "common.value") return "Value";
|
|
353
|
+
if (key === "common.search" || key === "assets.search") return "Search";
|
|
354
|
+
if (key === "variables.functionvariables") return "Function variables";
|
|
355
|
+
if (key === "chatbot.allowed-variables") return "Allowed Variables";
|
|
356
|
+
if (key.startsWith("variables.")) {
|
|
357
|
+
const variableName = key.replace("variables.", "");
|
|
358
|
+
const example = options?.example;
|
|
359
|
+
return example === void 0 || example === null ? variableName : String(example);
|
|
360
|
+
}
|
|
361
|
+
return fallback ?? key;
|
|
362
|
+
};
|
|
363
|
+
var normalizeAllowedDefinitions = (allowedVariables) => {
|
|
364
|
+
if (!Array.isArray(allowedVariables)) return [];
|
|
365
|
+
const unique = /* @__PURE__ */ new Set();
|
|
366
|
+
const definitions = [];
|
|
367
|
+
allowedVariables.forEach((variable) => {
|
|
368
|
+
let variableName = "";
|
|
369
|
+
let description;
|
|
370
|
+
let origin;
|
|
371
|
+
let example;
|
|
372
|
+
if (typeof variable === "string") {
|
|
373
|
+
variableName = variable.trim();
|
|
374
|
+
} else if (variable && typeof variable === "object") {
|
|
375
|
+
const typedVariable = variable;
|
|
376
|
+
const candidateName = [
|
|
377
|
+
typedVariable.name,
|
|
378
|
+
typedVariable.key,
|
|
379
|
+
typedVariable.variable
|
|
380
|
+
].find((value) => typeof value === "string");
|
|
381
|
+
variableName = typeof candidateName === "string" ? candidateName.trim() : "";
|
|
382
|
+
description = typeof typedVariable.description === "string" ? typedVariable.description.trim() : void 0;
|
|
383
|
+
origin = typeof typedVariable.origin === "string" ? typedVariable.origin.trim().toLowerCase() : void 0;
|
|
384
|
+
example = typedVariable.example;
|
|
385
|
+
}
|
|
386
|
+
if (!variableName || unique.has(variableName)) return;
|
|
387
|
+
unique.add(variableName);
|
|
388
|
+
definitions.push({ name: variableName, description, origin, example });
|
|
389
|
+
});
|
|
390
|
+
return definitions;
|
|
391
|
+
};
|
|
392
|
+
var filter = createFilterOptions({
|
|
393
|
+
stringify: (option) => {
|
|
394
|
+
if (typeof option === "string") return option;
|
|
395
|
+
if (typeof option === "number" || typeof option === "boolean" || typeof option === "bigint")
|
|
396
|
+
return String(option);
|
|
397
|
+
if (!option || typeof option !== "object") return "";
|
|
398
|
+
const typed = option;
|
|
399
|
+
return [typed.label, typed.value, typed.helperText, typed.searchText].filter(
|
|
400
|
+
(value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean"
|
|
401
|
+
).map((value) => String(value)).join(" ");
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
var visualTypeFromRecord = (variable) => {
|
|
405
|
+
if (variable?.isFunction) return "func";
|
|
406
|
+
if (variable?.system || variable?.locked) return "system";
|
|
407
|
+
return "custom";
|
|
408
|
+
};
|
|
409
|
+
var visualTypeRank = (variableType) => {
|
|
410
|
+
if (variableType === "custom") return 0;
|
|
411
|
+
if (variableType === "func") return 1;
|
|
412
|
+
return 2;
|
|
413
|
+
};
|
|
414
|
+
var orderItemsByVariableType = (items, getType) => {
|
|
415
|
+
const grouped = {
|
|
416
|
+
custom: [],
|
|
417
|
+
func: [],
|
|
418
|
+
system: []
|
|
419
|
+
};
|
|
420
|
+
items.forEach((item) => grouped[getType(item)].push(item));
|
|
421
|
+
return [...grouped.custom, ...grouped.func, ...grouped.system];
|
|
422
|
+
};
|
|
423
|
+
var sortItemsByVariableTypeThenName = (items, getType, getName) => {
|
|
424
|
+
return [...items].sort((a, b) => {
|
|
425
|
+
const typeDiff = visualTypeRank(getType(a)) - visualTypeRank(getType(b));
|
|
426
|
+
if (typeDiff !== 0) return typeDiff;
|
|
427
|
+
return getName(a).localeCompare(getName(b));
|
|
428
|
+
});
|
|
429
|
+
};
|
|
430
|
+
var humanizeVariableName = (rawName) => {
|
|
431
|
+
if (!rawName) return "";
|
|
432
|
+
return rawName.replace(/^_+|_+$/g, "").replace(/_/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (char) => char.toUpperCase());
|
|
433
|
+
};
|
|
434
|
+
var getVariableColorClass = (variableType, isSuggested) => {
|
|
435
|
+
if (isSuggested && variableType !== "func")
|
|
436
|
+
return "ls-variable-token--custom";
|
|
437
|
+
if (variableType === "func") return "ls-variable-token--function";
|
|
438
|
+
if (variableType === "system") return "ls-variable-token--system";
|
|
439
|
+
return "ls-variable-token--custom";
|
|
440
|
+
};
|
|
441
|
+
var CHILD_VARIABLE_COLOR_CLASS = "ls-variable-token--child";
|
|
442
|
+
var LSVariableInputField = forwardRef3((props, ref) => {
|
|
443
|
+
const context = useContext(LSVariableInputContext);
|
|
444
|
+
const {
|
|
445
|
+
name,
|
|
446
|
+
label,
|
|
447
|
+
type,
|
|
448
|
+
isAutoComplete,
|
|
449
|
+
autoCompleteOptions,
|
|
450
|
+
autoCompleteGroupBy,
|
|
451
|
+
renderOption,
|
|
452
|
+
hideVariables,
|
|
453
|
+
allowedVariables,
|
|
454
|
+
disabled,
|
|
455
|
+
autoFocus,
|
|
456
|
+
inputProps = {},
|
|
457
|
+
multiline,
|
|
458
|
+
rows,
|
|
459
|
+
maxRows,
|
|
460
|
+
value,
|
|
461
|
+
placeholder,
|
|
462
|
+
variant,
|
|
463
|
+
ListboxComponent,
|
|
464
|
+
onScrollListBox,
|
|
465
|
+
onHighlightChange,
|
|
466
|
+
onPopupClose,
|
|
467
|
+
onPopupOpen,
|
|
468
|
+
afterFilter,
|
|
469
|
+
onChange,
|
|
470
|
+
loading,
|
|
471
|
+
getOptionLabel,
|
|
472
|
+
isOptionEqualToValue,
|
|
473
|
+
$disableInputChange,
|
|
474
|
+
$getFullValueObject,
|
|
475
|
+
$multiple,
|
|
476
|
+
$disableCloseOnSelect,
|
|
477
|
+
$freeSolo,
|
|
478
|
+
$renderOption,
|
|
479
|
+
allowedVariableOrigin,
|
|
480
|
+
systemVariables: systemVariablesProp,
|
|
481
|
+
functionVariables: functionVariablesProp,
|
|
482
|
+
translate,
|
|
483
|
+
onVariableTranslationsNeeded,
|
|
484
|
+
isOriginConnected: isOriginConnectedProp,
|
|
485
|
+
translationKeyExists: translationKeyExistsProp
|
|
486
|
+
} = props;
|
|
487
|
+
const t = translate ?? context.translate ?? defaultTranslate;
|
|
488
|
+
const rawSystemVariables = systemVariablesProp ?? context.systemVariables ?? {};
|
|
489
|
+
const variableRecords = useMemo(
|
|
490
|
+
() => normalizeVariableRecords(rawSystemVariables),
|
|
491
|
+
[rawSystemVariables]
|
|
492
|
+
);
|
|
493
|
+
const functionVariables = useMemo(
|
|
494
|
+
() => functionVariablesProp ?? context.functionVariables ?? DEFAULT_FUNCTION_VARIABLES,
|
|
495
|
+
[context.functionVariables, functionVariablesProp]
|
|
496
|
+
);
|
|
497
|
+
const requestTranslations = onVariableTranslationsNeeded ?? context.onVariableTranslationsNeeded;
|
|
498
|
+
const isOriginConnected = isOriginConnectedProp ?? context.isOriginConnected;
|
|
499
|
+
const translationKeyExists = translationKeyExistsProp ?? context.translationKeyExists;
|
|
500
|
+
const containerRef = useRef(null);
|
|
501
|
+
const variableId = useRef(`variable-input-${name ?? "field"}`);
|
|
502
|
+
const [showVariables, setShowVariables] = useState(false);
|
|
503
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
504
|
+
const functionVariableSet = useMemo(
|
|
505
|
+
() => new Set(functionVariables),
|
|
506
|
+
[functionVariables]
|
|
507
|
+
);
|
|
508
|
+
const allowedVariableDefinitions = useMemo(
|
|
509
|
+
() => normalizeAllowedDefinitions(allowedVariables),
|
|
510
|
+
[allowedVariables]
|
|
511
|
+
);
|
|
512
|
+
const allowedVariableDefinitionLookup = useMemo(() => {
|
|
513
|
+
const lookup = /* @__PURE__ */ new Map();
|
|
514
|
+
allowedVariableDefinitions.forEach(
|
|
515
|
+
(definition) => lookup.set(definition.name, definition)
|
|
516
|
+
);
|
|
517
|
+
return lookup;
|
|
518
|
+
}, [allowedVariableDefinitions]);
|
|
519
|
+
const allowedVariableNames = useMemo(
|
|
520
|
+
() => allowedVariableDefinitions.map((definition) => definition.name),
|
|
521
|
+
[allowedVariableDefinitions]
|
|
522
|
+
);
|
|
523
|
+
const [filteredAllowedVariables, setFilteredAllowedVariables] = useState(allowedVariableDefinitions);
|
|
524
|
+
const [filteredSystemVariables, setFilteredSystemVariables] = useState([]);
|
|
525
|
+
const [expandedPaths, setExpandedPaths] = useState(
|
|
526
|
+
() => /* @__PURE__ */ new Set()
|
|
527
|
+
);
|
|
528
|
+
const [autoExpandPaths, setAutoExpandPaths] = useState(
|
|
529
|
+
() => /* @__PURE__ */ new Set()
|
|
530
|
+
);
|
|
531
|
+
const systemVariableValueTrees = useMemo(() => {
|
|
532
|
+
const map = /* @__PURE__ */ new Map();
|
|
533
|
+
Object.values(variableRecords).forEach((variable) => {
|
|
534
|
+
if (variable && isExpandableValue(variable.value)) {
|
|
535
|
+
map.set(variable.name, buildValueChildren(variable.value, "", 0));
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
return map;
|
|
539
|
+
}, [variableRecords]);
|
|
540
|
+
const allowedExampleTrees = useMemo(() => {
|
|
541
|
+
const map = /* @__PURE__ */ new Map();
|
|
542
|
+
allowedVariableDefinitions.forEach((definition) => {
|
|
543
|
+
if (isExpandableValue(definition.example)) {
|
|
544
|
+
map.set(definition.name, buildValueChildren(definition.example, "", 0));
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
return map;
|
|
548
|
+
}, [allowedVariableDefinitions]);
|
|
549
|
+
useEffect(() => {
|
|
550
|
+
requestTranslations?.();
|
|
551
|
+
}, [requestTranslations]);
|
|
552
|
+
const isPathExpanded = useCallback(
|
|
553
|
+
(path) => expandedPaths.has(path) || autoExpandPaths.has(path),
|
|
554
|
+
[autoExpandPaths, expandedPaths]
|
|
555
|
+
);
|
|
556
|
+
const toggleExpand = useCallback(
|
|
557
|
+
(path) => {
|
|
558
|
+
const expanded = expandedPaths.has(path) || autoExpandPaths.has(path);
|
|
559
|
+
if (expanded) {
|
|
560
|
+
if (expandedPaths.has(path)) {
|
|
561
|
+
setExpandedPaths((prev) => {
|
|
562
|
+
const next = new Set(prev);
|
|
563
|
+
next.delete(path);
|
|
564
|
+
return next;
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
if (autoExpandPaths.has(path)) {
|
|
568
|
+
setAutoExpandPaths((prev) => {
|
|
569
|
+
const next = new Set(prev);
|
|
570
|
+
next.delete(path);
|
|
571
|
+
return next;
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
} else {
|
|
575
|
+
setExpandedPaths((prev) => {
|
|
576
|
+
const next = new Set(prev);
|
|
577
|
+
next.add(path);
|
|
578
|
+
return next;
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
},
|
|
582
|
+
[autoExpandPaths, expandedPaths]
|
|
583
|
+
);
|
|
584
|
+
const namespaceHas = useCallback(
|
|
585
|
+
(key, namespace) => {
|
|
586
|
+
if (!translationKeyExists) return false;
|
|
587
|
+
try {
|
|
588
|
+
return translationKeyExists(key, namespace);
|
|
589
|
+
} catch {
|
|
590
|
+
return false;
|
|
591
|
+
}
|
|
592
|
+
},
|
|
593
|
+
[translationKeyExists]
|
|
594
|
+
);
|
|
595
|
+
const resolveTranslationFromNamespace = useCallback(
|
|
596
|
+
(variableName, namespace) => {
|
|
597
|
+
const normalizedNamespace = typeof namespace === "string" ? namespace.trim().toLowerCase() : "";
|
|
598
|
+
if (!normalizedNamespace) return null;
|
|
599
|
+
const normalizedName = variableName.trim().toLowerCase();
|
|
600
|
+
if (!normalizedName) return null;
|
|
601
|
+
const unprefixedName = normalizedName.startsWith(
|
|
602
|
+
`${normalizedNamespace}_`
|
|
603
|
+
) ? normalizedName.slice(normalizedNamespace.length + 1) : normalizedName;
|
|
604
|
+
const prefixedName = normalizedName.startsWith(`${normalizedNamespace}_`) ? normalizedName : `${normalizedNamespace}_${normalizedName}`;
|
|
605
|
+
const candidateKeys = [prefixedName, unprefixedName];
|
|
606
|
+
for (const key of candidateKeys) {
|
|
607
|
+
if (namespaceHas(key, normalizedNamespace))
|
|
608
|
+
return t(key, void 0, { ns: normalizedNamespace });
|
|
609
|
+
if (namespaceHas(`variables.${key}`, normalizedNamespace))
|
|
610
|
+
return t(`variables.${key}`, void 0, { ns: normalizedNamespace });
|
|
611
|
+
}
|
|
612
|
+
return null;
|
|
613
|
+
},
|
|
614
|
+
[namespaceHas, t]
|
|
615
|
+
);
|
|
616
|
+
const knownOrigins = useMemo(() => {
|
|
617
|
+
return Array.from(
|
|
618
|
+
new Set(
|
|
619
|
+
Object.values(variableRecords).map(
|
|
620
|
+
(variable) => typeof variable?.origin === "string" ? variable.origin.trim().toLowerCase() : ""
|
|
621
|
+
).filter((origin) => origin.length > 0)
|
|
622
|
+
)
|
|
623
|
+
);
|
|
624
|
+
}, [variableRecords]);
|
|
625
|
+
const resolveAllowedVariableOrigin = useCallback(
|
|
626
|
+
(variableName) => {
|
|
627
|
+
const originFromProp = typeof allowedVariableOrigin === "string" ? allowedVariableOrigin.trim().toLowerCase() : "";
|
|
628
|
+
if (originFromProp) return originFromProp;
|
|
629
|
+
const fromDefinition = allowedVariableDefinitionLookup.get(variableName)?.origin;
|
|
630
|
+
if (fromDefinition) return fromDefinition;
|
|
631
|
+
const normalizedName = variableName.trim().toLowerCase();
|
|
632
|
+
if (!normalizedName) return void 0;
|
|
633
|
+
const prefixCandidate = normalizedName.split("_")[0];
|
|
634
|
+
if (prefixCandidate) {
|
|
635
|
+
const hasScopedTranslation = namespaceHas(normalizedName, prefixCandidate) || namespaceHas(`variables.${normalizedName}`, prefixCandidate) || namespaceHas(
|
|
636
|
+
normalizedName.slice(prefixCandidate.length + 1),
|
|
637
|
+
prefixCandidate
|
|
638
|
+
) || namespaceHas(
|
|
639
|
+
`variables.${normalizedName.slice(prefixCandidate.length + 1)}`,
|
|
640
|
+
prefixCandidate
|
|
641
|
+
);
|
|
642
|
+
if (hasScopedTranslation) return prefixCandidate;
|
|
643
|
+
}
|
|
644
|
+
const prefixedMatch = knownOrigins.find(
|
|
645
|
+
(origin) => normalizedName.startsWith(`${origin}_`)
|
|
646
|
+
);
|
|
647
|
+
if (prefixedMatch) return prefixedMatch;
|
|
648
|
+
const matchingOrigins = knownOrigins.filter(
|
|
649
|
+
(origin) => namespaceHas(normalizedName, origin) || namespaceHas(`variables.${normalizedName}`, origin) || namespaceHas(`${origin}_${normalizedName}`, origin)
|
|
650
|
+
);
|
|
651
|
+
if (matchingOrigins.length === 1) return matchingOrigins[0];
|
|
652
|
+
const inferredOrigins = Array.from(
|
|
653
|
+
new Set(
|
|
654
|
+
Object.values(variableRecords).filter((variable) => {
|
|
655
|
+
const variableNameLower = typeof variable?.name === "string" ? variable.name.trim().toLowerCase() : "";
|
|
656
|
+
const variableOrigin = typeof variable?.origin === "string" ? variable.origin.trim().toLowerCase() : "";
|
|
657
|
+
if (!variableNameLower || !variableOrigin) return false;
|
|
658
|
+
return variableNameLower === normalizedName || variableNameLower === `${variableOrigin}_${normalizedName}`;
|
|
659
|
+
}).map((variable) => String(variable.origin).trim().toLowerCase()).filter((origin) => origin.length > 0)
|
|
660
|
+
)
|
|
661
|
+
);
|
|
662
|
+
return inferredOrigins.length === 1 ? inferredOrigins[0] : void 0;
|
|
663
|
+
},
|
|
664
|
+
[
|
|
665
|
+
allowedVariableDefinitionLookup,
|
|
666
|
+
allowedVariableOrigin,
|
|
667
|
+
knownOrigins,
|
|
668
|
+
namespaceHas,
|
|
669
|
+
variableRecords
|
|
670
|
+
]
|
|
671
|
+
);
|
|
672
|
+
const resolveVariableDescription = useCallback(
|
|
673
|
+
(variableName, fallbackDescription, origin) => {
|
|
674
|
+
const fromOrigin = resolveTranslationFromNamespace(variableName, origin);
|
|
675
|
+
if (fromOrigin && fromOrigin.trim().length > 0) return fromOrigin;
|
|
676
|
+
const defaultTranslationKey = `variables.${variableName}`;
|
|
677
|
+
const defaultTranslated = t(defaultTranslationKey);
|
|
678
|
+
if (typeof defaultTranslated === "string" && defaultTranslated !== defaultTranslationKey)
|
|
679
|
+
return defaultTranslated;
|
|
680
|
+
if (fallbackDescription && fallbackDescription.trim().length > 0)
|
|
681
|
+
return fallbackDescription;
|
|
682
|
+
return humanizeVariableName(variableName);
|
|
683
|
+
},
|
|
684
|
+
[resolveTranslationFromNamespace, t]
|
|
685
|
+
);
|
|
686
|
+
const getSystemVariableDescription = useCallback(
|
|
687
|
+
(variable) => {
|
|
688
|
+
if (variable?.system && !variable?.pluginId) {
|
|
689
|
+
return t(`variables.${variable.description}`, void 0, {
|
|
690
|
+
example: variable.example,
|
|
691
|
+
interpolation: { escapeValue: false, prefix: "{{{", suffix: "}}}" }
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
return resolveVariableDescription(
|
|
695
|
+
variable?.name ?? "",
|
|
696
|
+
variable?.description,
|
|
697
|
+
variable?.origin
|
|
698
|
+
);
|
|
699
|
+
},
|
|
700
|
+
[resolveVariableDescription, t]
|
|
701
|
+
);
|
|
702
|
+
const getAllowedVariableRecord = useCallback(
|
|
703
|
+
(variableName) => {
|
|
704
|
+
const direct = variableRecords[variableName];
|
|
705
|
+
if (direct) return direct;
|
|
706
|
+
const normalizedOrigin = resolveAllowedVariableOrigin(variableName);
|
|
707
|
+
if (!normalizedOrigin) return void 0;
|
|
708
|
+
const prefixedName = variableName.startsWith(`${normalizedOrigin}_`) ? variableName : `${normalizedOrigin}_${variableName}`;
|
|
709
|
+
return variableRecords[prefixedName];
|
|
710
|
+
},
|
|
711
|
+
[resolveAllowedVariableOrigin, variableRecords]
|
|
712
|
+
);
|
|
713
|
+
const getAllowedVariableDescription = useCallback(
|
|
714
|
+
(variableName) => {
|
|
715
|
+
const variable = variableRecords[variableName];
|
|
716
|
+
if (variable) return getSystemVariableDescription(variable);
|
|
717
|
+
const fromDefinition = allowedVariableDefinitionLookup.get(variableName);
|
|
718
|
+
const origin = resolveAllowedVariableOrigin(variableName);
|
|
719
|
+
return resolveVariableDescription(
|
|
720
|
+
variableName,
|
|
721
|
+
fromDefinition?.description,
|
|
722
|
+
origin
|
|
723
|
+
);
|
|
724
|
+
},
|
|
725
|
+
[
|
|
726
|
+
allowedVariableDefinitionLookup,
|
|
727
|
+
getSystemVariableDescription,
|
|
728
|
+
resolveAllowedVariableOrigin,
|
|
729
|
+
resolveVariableDescription,
|
|
730
|
+
variableRecords
|
|
731
|
+
]
|
|
732
|
+
);
|
|
733
|
+
const getAllowedVariableValue = useCallback(
|
|
734
|
+
(variableName) => {
|
|
735
|
+
if (!variableName) return void 0;
|
|
736
|
+
const direct = variableRecords[variableName]?.value;
|
|
737
|
+
if (direct !== void 0) return direct;
|
|
738
|
+
const normalizedOrigin = resolveAllowedVariableOrigin(variableName);
|
|
739
|
+
if (!normalizedOrigin) return void 0;
|
|
740
|
+
const prefixedName = variableName.startsWith(`${normalizedOrigin}_`) ? variableName : `${normalizedOrigin}_${variableName}`;
|
|
741
|
+
return variableRecords[prefixedName]?.value;
|
|
742
|
+
},
|
|
743
|
+
[resolveAllowedVariableOrigin, variableRecords]
|
|
744
|
+
);
|
|
745
|
+
const getAllowedVariableVisualType = useCallback(
|
|
746
|
+
(variableName) => {
|
|
747
|
+
const record = getAllowedVariableRecord(variableName);
|
|
748
|
+
if (record) return visualTypeFromRecord(record);
|
|
749
|
+
if (functionVariableSet.has(variableName)) return "func";
|
|
750
|
+
return "custom";
|
|
751
|
+
},
|
|
752
|
+
[functionVariableSet, getAllowedVariableRecord]
|
|
753
|
+
);
|
|
754
|
+
const getAllowedVariableTree = useCallback(
|
|
755
|
+
(definition) => {
|
|
756
|
+
const record = getAllowedVariableRecord(definition.name);
|
|
757
|
+
const liveTree = record ? systemVariableValueTrees.get(record.name) : void 0;
|
|
758
|
+
if (liveTree && liveTree.length > 0) return liveTree;
|
|
759
|
+
return allowedExampleTrees.get(definition.name);
|
|
760
|
+
},
|
|
761
|
+
[allowedExampleTrees, getAllowedVariableRecord, systemVariableValueTrees]
|
|
762
|
+
);
|
|
763
|
+
useEffect(() => {
|
|
764
|
+
const query = (searchQuery ?? "").toLowerCase().replace("{{", "").replace("}}", "").trim();
|
|
765
|
+
const nextAutoExpand = /* @__PURE__ */ new Set();
|
|
766
|
+
const collectNestedAutoExpand = (rootToken, tree) => {
|
|
767
|
+
if (!query || !tree || tree.length === 0) return false;
|
|
768
|
+
let hit = false;
|
|
769
|
+
const walk = (nodes) => {
|
|
770
|
+
nodes.forEach((node) => {
|
|
771
|
+
if (node.relativePath.toLowerCase().includes(query) || node.key.toLowerCase().includes(query)) {
|
|
772
|
+
hit = true;
|
|
773
|
+
const segments = node.relativePath.split(".");
|
|
774
|
+
for (let i = 0; i < segments.length; i++) {
|
|
775
|
+
const rel = segments.slice(0, i).join(".");
|
|
776
|
+
nextAutoExpand.add(rel ? `${rootToken}.${rel}` : rootToken);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
if (node.children.length) walk(node.children);
|
|
780
|
+
});
|
|
781
|
+
};
|
|
782
|
+
walk(tree);
|
|
783
|
+
return hit;
|
|
784
|
+
};
|
|
785
|
+
if (allowedVariableNames.length > 0) {
|
|
786
|
+
if (!query) {
|
|
787
|
+
setFilteredAllowedVariables(
|
|
788
|
+
orderItemsByVariableType(
|
|
789
|
+
allowedVariableDefinitions,
|
|
790
|
+
(definition) => getAllowedVariableVisualType(definition.name)
|
|
791
|
+
)
|
|
792
|
+
);
|
|
793
|
+
} else {
|
|
794
|
+
const nameMatches = [];
|
|
795
|
+
const descMatches = [];
|
|
796
|
+
const nestedMatches = [];
|
|
797
|
+
allowedVariableDefinitions.forEach((definition) => {
|
|
798
|
+
const nameLower = definition.name?.toLowerCase();
|
|
799
|
+
const descLower = getAllowedVariableDescription(
|
|
800
|
+
definition.name
|
|
801
|
+
)?.toLowerCase();
|
|
802
|
+
if (nameLower?.includes(query)) {
|
|
803
|
+
nameMatches.push(definition);
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
if (descLower?.includes(query)) {
|
|
807
|
+
descMatches.push(definition);
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
const tree = getAllowedVariableTree(definition);
|
|
811
|
+
if (tree && collectNestedAutoExpand(definition.name, tree)) {
|
|
812
|
+
nestedMatches.push(definition);
|
|
813
|
+
}
|
|
814
|
+
});
|
|
815
|
+
const sortByDef = (items) => sortItemsByVariableTypeThenName(
|
|
816
|
+
items,
|
|
817
|
+
(definition) => getAllowedVariableVisualType(definition.name),
|
|
818
|
+
(definition) => definition.name
|
|
819
|
+
);
|
|
820
|
+
setFilteredAllowedVariables([
|
|
821
|
+
...sortByDef(nameMatches),
|
|
822
|
+
...sortByDef(descMatches),
|
|
823
|
+
...sortByDef(nestedMatches)
|
|
824
|
+
]);
|
|
825
|
+
}
|
|
826
|
+
} else {
|
|
827
|
+
setFilteredAllowedVariables([]);
|
|
828
|
+
}
|
|
829
|
+
const allowedSet = new Set(allowedVariableNames);
|
|
830
|
+
const shouldKeep = (variable) => {
|
|
831
|
+
if (allowedSet.has(variable.name)) return false;
|
|
832
|
+
if (!variable.origin) return true;
|
|
833
|
+
if (!isOriginConnected) return true;
|
|
834
|
+
return isOriginConnected(variable.origin);
|
|
835
|
+
};
|
|
836
|
+
const allRecords = Object.values(variableRecords);
|
|
837
|
+
if (!query) {
|
|
838
|
+
const visible = allRecords.filter(shouldKeep);
|
|
839
|
+
setFilteredSystemVariables(
|
|
840
|
+
orderItemsByVariableType(
|
|
841
|
+
visible,
|
|
842
|
+
(variable) => visualTypeFromRecord(variable)
|
|
843
|
+
)
|
|
844
|
+
);
|
|
845
|
+
} else {
|
|
846
|
+
const nameMatches = [];
|
|
847
|
+
const descMatches = [];
|
|
848
|
+
const nestedMatches = [];
|
|
849
|
+
allRecords.forEach((variable) => {
|
|
850
|
+
if (!shouldKeep(variable)) return;
|
|
851
|
+
const description = getSystemVariableDescription(variable);
|
|
852
|
+
const nameLower = variable.name?.toLowerCase();
|
|
853
|
+
const descLower = description?.toLowerCase();
|
|
854
|
+
if (nameLower?.includes(query)) {
|
|
855
|
+
nameMatches.push(variable);
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
if (descLower?.includes(query)) {
|
|
859
|
+
descMatches.push(variable);
|
|
860
|
+
return;
|
|
861
|
+
}
|
|
862
|
+
const tree = systemVariableValueTrees.get(variable.name);
|
|
863
|
+
if (tree && collectNestedAutoExpand(variable.example ?? variable.name, tree)) {
|
|
864
|
+
nestedMatches.push(variable);
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
const sortSys = (items) => sortItemsByVariableTypeThenName(
|
|
868
|
+
items,
|
|
869
|
+
(variable) => visualTypeFromRecord(variable),
|
|
870
|
+
(variable) => variable?.name ?? ""
|
|
871
|
+
);
|
|
872
|
+
setFilteredSystemVariables([
|
|
873
|
+
...sortSys(nameMatches),
|
|
874
|
+
...sortSys(descMatches),
|
|
875
|
+
...sortSys(nestedMatches)
|
|
876
|
+
]);
|
|
877
|
+
}
|
|
878
|
+
setAutoExpandPaths(nextAutoExpand);
|
|
879
|
+
}, [
|
|
880
|
+
searchQuery,
|
|
881
|
+
allowedVariableDefinitions,
|
|
882
|
+
allowedVariableNames,
|
|
883
|
+
getAllowedVariableDescription,
|
|
884
|
+
getAllowedVariableTree,
|
|
885
|
+
getAllowedVariableVisualType,
|
|
886
|
+
getSystemVariableDescription,
|
|
887
|
+
isOriginConnected,
|
|
888
|
+
systemVariableValueTrees,
|
|
889
|
+
variableRecords
|
|
890
|
+
]);
|
|
891
|
+
const clickedVariableIcon = () => {
|
|
892
|
+
if (!hideVariables) setShowVariables((current) => !current);
|
|
893
|
+
};
|
|
894
|
+
const appendValue = (newValue) => {
|
|
895
|
+
const currentValue = Array.isArray(value) ? value.join("") : value;
|
|
896
|
+
onChange?.(currentValue ? `${currentValue}${newValue}` : newValue);
|
|
897
|
+
};
|
|
898
|
+
const insertVariable = (variable) => {
|
|
899
|
+
appendValue(`{{${variable}}}`);
|
|
900
|
+
setShowVariables(false);
|
|
901
|
+
};
|
|
902
|
+
const handleFilterOptions = (options, params) => {
|
|
903
|
+
const filtered = filter(options, params);
|
|
904
|
+
afterFilter?.(filtered);
|
|
905
|
+
return filtered;
|
|
906
|
+
};
|
|
907
|
+
const renderVariableToken = (variableName, variableType, isSuggested = false) => /* @__PURE__ */ jsxs(
|
|
908
|
+
"div",
|
|
909
|
+
{
|
|
910
|
+
className: `ls-variable-token ${getVariableColorClass(variableType, isSuggested)}`,
|
|
911
|
+
children: [
|
|
912
|
+
/* @__PURE__ */ jsx3("span", { className: "ls-variable-token__name", children: `{{${variableName}}}` }),
|
|
913
|
+
variableType === "func" && /* @__PURE__ */ jsx3(
|
|
914
|
+
"span",
|
|
915
|
+
{
|
|
916
|
+
className: "ls-variable-token__badge",
|
|
917
|
+
title: t("variables.functionvariables", "Function variables"),
|
|
918
|
+
children: "fx"
|
|
919
|
+
}
|
|
920
|
+
)
|
|
921
|
+
]
|
|
922
|
+
}
|
|
923
|
+
);
|
|
924
|
+
const renderExpandToggle = (path, expanded) => /* @__PURE__ */ jsx3(
|
|
925
|
+
"button",
|
|
926
|
+
{
|
|
927
|
+
type: "button",
|
|
928
|
+
onClick: (e) => {
|
|
929
|
+
e.stopPropagation();
|
|
930
|
+
toggleExpand(path);
|
|
931
|
+
},
|
|
932
|
+
className: `ls-variable-picker__expand-toggle${expanded ? " ls-variable-picker__expand-toggle--expanded" : ""}`,
|
|
933
|
+
"aria-label": expanded ? "Collapse" : "Expand",
|
|
934
|
+
"aria-expanded": expanded,
|
|
935
|
+
children: /* @__PURE__ */ jsx3(KeyboardArrowDown, { style: { width: 16, height: 16 } })
|
|
936
|
+
}
|
|
937
|
+
);
|
|
938
|
+
const renderExpandSpacer = () => /* @__PURE__ */ jsx3("span", { className: "ls-variable-picker__expand-spacer", "aria-hidden": true });
|
|
939
|
+
const getVariableValuePreview = (variableValue) => {
|
|
940
|
+
const { displayValue, fullValue } = getVariableValueDisplay(variableValue);
|
|
941
|
+
return { displayValue, fullValue };
|
|
942
|
+
};
|
|
943
|
+
const renderVariableValueInput = (displayValue, fullValue) => /* @__PURE__ */ jsx3(
|
|
944
|
+
"input",
|
|
945
|
+
{
|
|
946
|
+
className: "ls-variable-picker__value-input",
|
|
947
|
+
title: fullValue,
|
|
948
|
+
readOnly: true,
|
|
949
|
+
value: fullValue || displayValue,
|
|
950
|
+
onClick: (e) => e.stopPropagation(),
|
|
951
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
952
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
953
|
+
"aria-label": t("common.value", "Value")
|
|
954
|
+
}
|
|
955
|
+
);
|
|
956
|
+
const renderValueChildRows = (rootToken, nodes) => nodes.map((node) => {
|
|
957
|
+
const fullToken = `${rootToken}.${node.relativePath}`;
|
|
958
|
+
const expanded = node.isExpandable && isPathExpanded(fullToken);
|
|
959
|
+
const { displayValue, fullValue } = getVariableValuePreview(node.value);
|
|
960
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
961
|
+
/* @__PURE__ */ jsxs(
|
|
962
|
+
"div",
|
|
963
|
+
{
|
|
964
|
+
className: "ls-variable-picker__row ls-variable-picker__row--child",
|
|
965
|
+
onClick: () => {
|
|
966
|
+
if (node.isExpandable && !expanded) toggleExpand(fullToken);
|
|
967
|
+
else insertVariable(fullToken);
|
|
968
|
+
},
|
|
969
|
+
children: [
|
|
970
|
+
/* @__PURE__ */ jsxs(
|
|
971
|
+
"div",
|
|
972
|
+
{
|
|
973
|
+
className: "ls-variable-picker__token-cell",
|
|
974
|
+
style: { paddingLeft: `${node.depth * 1.25}rem` },
|
|
975
|
+
children: [
|
|
976
|
+
node.isExpandable ? renderExpandToggle(fullToken, expanded) : renderExpandSpacer(),
|
|
977
|
+
/* @__PURE__ */ jsx3(
|
|
978
|
+
"div",
|
|
979
|
+
{
|
|
980
|
+
className: `ls-variable-token ${CHILD_VARIABLE_COLOR_CLASS}`,
|
|
981
|
+
children: /* @__PURE__ */ jsx3("span", { className: "ls-variable-token__name", children: `{{${fullToken}}}` })
|
|
982
|
+
}
|
|
983
|
+
)
|
|
984
|
+
]
|
|
985
|
+
}
|
|
986
|
+
),
|
|
987
|
+
/* @__PURE__ */ jsx3("div", { className: "ls-variable-picker__description", children: node.displayKey }),
|
|
988
|
+
/* @__PURE__ */ jsx3("div", { className: "ls-variable-picker__value", title: fullValue, children: renderVariableValueInput(displayValue, fullValue) })
|
|
989
|
+
]
|
|
990
|
+
}
|
|
991
|
+
),
|
|
992
|
+
expanded && renderValueChildRows(rootToken, node.children)
|
|
993
|
+
] }, fullToken);
|
|
994
|
+
});
|
|
995
|
+
const toOptionLabelString = (input) => {
|
|
996
|
+
if (typeof input === "string") return input;
|
|
997
|
+
if (typeof input === "number" || typeof input === "boolean" || typeof input === "bigint")
|
|
998
|
+
return String(input);
|
|
999
|
+
if (input === null || input === void 0) return "";
|
|
1000
|
+
if (typeof input === "object") {
|
|
1001
|
+
const labelCandidate = input.label;
|
|
1002
|
+
if (typeof labelCandidate === "string") return labelCandidate;
|
|
1003
|
+
if (typeof labelCandidate === "number" || typeof labelCandidate === "boolean" || typeof labelCandidate === "bigint")
|
|
1004
|
+
return String(labelCandidate);
|
|
1005
|
+
const valueCandidate = input.value;
|
|
1006
|
+
if (typeof valueCandidate === "string") return valueCandidate;
|
|
1007
|
+
if (typeof valueCandidate === "number" || typeof valueCandidate === "boolean" || typeof valueCandidate === "bigint")
|
|
1008
|
+
return String(valueCandidate);
|
|
1009
|
+
try {
|
|
1010
|
+
return JSON.stringify(input);
|
|
1011
|
+
} catch {
|
|
1012
|
+
return "[object Object]";
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
return String(input);
|
|
1016
|
+
};
|
|
1017
|
+
const resolveOptionLabel = (option) => {
|
|
1018
|
+
if (typeof getOptionLabel === "function") {
|
|
1019
|
+
try {
|
|
1020
|
+
const customLabel = getOptionLabel(option);
|
|
1021
|
+
return toOptionLabelString(
|
|
1022
|
+
customLabel === void 0 ? option : customLabel
|
|
1023
|
+
);
|
|
1024
|
+
} catch {
|
|
1025
|
+
return toOptionLabelString(option);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
return toOptionLabelString(option);
|
|
1029
|
+
};
|
|
1030
|
+
const defaultRenderOption = (optionProps, option) => {
|
|
1031
|
+
const opt = option;
|
|
1032
|
+
const thumb = opt?.imageUrl ?? opt?.thumb ?? opt?.iconUrl ?? opt?.previewImageUrl;
|
|
1033
|
+
const helperText = typeof opt?.helperText === "string" ? opt.helperText : "";
|
|
1034
|
+
const isSelected = opt?.value === value;
|
|
1035
|
+
return /* @__PURE__ */ createElement(
|
|
1036
|
+
"li",
|
|
1037
|
+
{
|
|
1038
|
+
...optionProps,
|
|
1039
|
+
key: String(opt?.label ?? opt?.value ?? ""),
|
|
1040
|
+
className: [
|
|
1041
|
+
optionProps.className,
|
|
1042
|
+
"ls-variable-option",
|
|
1043
|
+
isSelected ? "ls-variable-option--selected" : ""
|
|
1044
|
+
].filter(Boolean).join(" ")
|
|
1045
|
+
},
|
|
1046
|
+
thumb ? /* @__PURE__ */ jsx3(
|
|
1047
|
+
"img",
|
|
1048
|
+
{
|
|
1049
|
+
src: thumb,
|
|
1050
|
+
className: "ls-variable-option__thumb",
|
|
1051
|
+
alt: ""
|
|
1052
|
+
}
|
|
1053
|
+
) : null,
|
|
1054
|
+
/* @__PURE__ */ jsxs("div", { className: "ls-variable-option__body", children: [
|
|
1055
|
+
/* @__PURE__ */ jsx3("div", { className: "ls-variable-option__label", children: resolveOptionLabel(opt) }),
|
|
1056
|
+
helperText ? /* @__PURE__ */ jsx3("div", { className: "ls-variable-option__helper", children: helperText }) : null
|
|
1057
|
+
] })
|
|
1058
|
+
);
|
|
1059
|
+
};
|
|
1060
|
+
const showSuggestedSection = allowedVariableNames.length > 0 && filteredAllowedVariables.length > 0;
|
|
1061
|
+
const pickerBody = /* @__PURE__ */ jsxs("div", { className: "ls-variable-picker ls-variable-picker--three-col", children: [
|
|
1062
|
+
/* @__PURE__ */ jsxs("div", { className: "ls-variable-picker__intro", children: [
|
|
1063
|
+
/* @__PURE__ */ jsx3("div", { className: "ls-variable-picker__intro-text", children: t(
|
|
1064
|
+
"overlay-variables.variables-description",
|
|
1065
|
+
"Use variables that will automatically be replaced before sending out the text"
|
|
1066
|
+
) }),
|
|
1067
|
+
/* @__PURE__ */ jsx3(
|
|
1068
|
+
LSInput,
|
|
1069
|
+
{
|
|
1070
|
+
autoFocus: true,
|
|
1071
|
+
startAdornment: /* @__PURE__ */ jsx3(Search, { style: { color: "#fff", width: 20, height: 20 } }),
|
|
1072
|
+
placeholder: t("common.search", "Search"),
|
|
1073
|
+
value: searchQuery,
|
|
1074
|
+
onChange: (e) => setSearchQuery(e.target.value),
|
|
1075
|
+
type: "text"
|
|
1076
|
+
}
|
|
1077
|
+
)
|
|
1078
|
+
] }),
|
|
1079
|
+
/* @__PURE__ */ jsxs("div", { className: "ls-variable-picker__header", children: [
|
|
1080
|
+
/* @__PURE__ */ jsx3("div", { style: { paddingLeft: "2.2rem" }, children: t("commands.variable", "Variable") }),
|
|
1081
|
+
/* @__PURE__ */ jsx3("div", { children: t("commands.description", "Description") }),
|
|
1082
|
+
/* @__PURE__ */ jsx3("div", { children: t("common.value", "Value") })
|
|
1083
|
+
] }),
|
|
1084
|
+
/* @__PURE__ */ jsxs("div", { className: "ls-variable-picker__list", children: [
|
|
1085
|
+
showSuggestedSection && /* @__PURE__ */ jsxs("fieldset", { className: "ls-variable-picker__field", children: [
|
|
1086
|
+
/* @__PURE__ */ jsx3("legend", { className: "ls-variable-picker__legend", children: t("commands.suggested-variables", "Suggested Variables") }),
|
|
1087
|
+
filteredAllowedVariables.map((definition, idx) => {
|
|
1088
|
+
const variableType = getAllowedVariableVisualType(
|
|
1089
|
+
definition.name
|
|
1090
|
+
);
|
|
1091
|
+
const tree = getAllowedVariableTree(definition);
|
|
1092
|
+
const { displayValue, fullValue } = getVariableValuePreview(
|
|
1093
|
+
getAllowedVariableValue(definition.name) ?? definition.example
|
|
1094
|
+
);
|
|
1095
|
+
const expandable = !!tree && tree.length > 0;
|
|
1096
|
+
const expanded = expandable && isPathExpanded(definition.name);
|
|
1097
|
+
const isLast = idx === filteredAllowedVariables.length - 1;
|
|
1098
|
+
const rowCls = `ls-variable-picker__row${isLast && !expanded ? " ls-variable-picker__row--no-border" : ""}`;
|
|
1099
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1100
|
+
/* @__PURE__ */ jsxs(
|
|
1101
|
+
"div",
|
|
1102
|
+
{
|
|
1103
|
+
className: rowCls,
|
|
1104
|
+
onClick: () => {
|
|
1105
|
+
if (expandable && !expanded)
|
|
1106
|
+
toggleExpand(definition.name);
|
|
1107
|
+
else insertVariable(definition.name);
|
|
1108
|
+
},
|
|
1109
|
+
children: [
|
|
1110
|
+
/* @__PURE__ */ jsxs("div", { className: "ls-variable-picker__token-cell", children: [
|
|
1111
|
+
expandable ? renderExpandToggle(definition.name, expanded) : renderExpandSpacer(),
|
|
1112
|
+
renderVariableToken(definition.name, variableType, true)
|
|
1113
|
+
] }),
|
|
1114
|
+
/* @__PURE__ */ jsx3("div", { className: "ls-variable-picker__description", children: getAllowedVariableDescription(definition.name) }),
|
|
1115
|
+
/* @__PURE__ */ jsx3(
|
|
1116
|
+
"div",
|
|
1117
|
+
{
|
|
1118
|
+
className: "ls-variable-picker__value",
|
|
1119
|
+
title: fullValue,
|
|
1120
|
+
children: renderVariableValueInput(displayValue, fullValue)
|
|
1121
|
+
}
|
|
1122
|
+
)
|
|
1123
|
+
]
|
|
1124
|
+
}
|
|
1125
|
+
),
|
|
1126
|
+
expanded && tree && renderValueChildRows(definition.name, tree)
|
|
1127
|
+
] }, definition.name);
|
|
1128
|
+
})
|
|
1129
|
+
] }),
|
|
1130
|
+
filteredSystemVariables?.map((variable) => {
|
|
1131
|
+
const variableType = visualTypeFromRecord(variable);
|
|
1132
|
+
const { displayValue, fullValue } = getVariableValuePreview(
|
|
1133
|
+
variable.value
|
|
1134
|
+
);
|
|
1135
|
+
const rootToken = variable.example ?? variable.name;
|
|
1136
|
+
const tree = systemVariableValueTrees.get(variable.name);
|
|
1137
|
+
const expandable = !!tree && tree.length > 0;
|
|
1138
|
+
const expanded = expandable && isPathExpanded(rootToken);
|
|
1139
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1140
|
+
/* @__PURE__ */ jsxs(
|
|
1141
|
+
"div",
|
|
1142
|
+
{
|
|
1143
|
+
className: "ls-variable-picker__row",
|
|
1144
|
+
onClick: () => {
|
|
1145
|
+
if (expandable && !expanded) toggleExpand(rootToken);
|
|
1146
|
+
else insertVariable(rootToken);
|
|
1147
|
+
},
|
|
1148
|
+
children: [
|
|
1149
|
+
/* @__PURE__ */ jsxs("div", { className: "ls-variable-picker__token-cell", children: [
|
|
1150
|
+
expandable ? renderExpandToggle(rootToken, expanded) : renderExpandSpacer(),
|
|
1151
|
+
renderVariableToken(variable.name, variableType)
|
|
1152
|
+
] }),
|
|
1153
|
+
/* @__PURE__ */ jsx3("div", { className: "ls-variable-picker__description", children: getSystemVariableDescription(variable) }),
|
|
1154
|
+
/* @__PURE__ */ jsx3("div", { className: "ls-variable-picker__value", title: fullValue, children: renderVariableValueInput(displayValue, fullValue) })
|
|
1155
|
+
]
|
|
1156
|
+
}
|
|
1157
|
+
),
|
|
1158
|
+
expanded && tree && renderValueChildRows(rootToken, tree)
|
|
1159
|
+
] }, variable.name);
|
|
1160
|
+
})
|
|
1161
|
+
] })
|
|
1162
|
+
] });
|
|
1163
|
+
const textField = (params = {}) => /* @__PURE__ */ jsx3(
|
|
1164
|
+
VariableInputTextField,
|
|
1165
|
+
{
|
|
1166
|
+
t,
|
|
1167
|
+
params,
|
|
1168
|
+
id: variableId.current,
|
|
1169
|
+
containerRef,
|
|
1170
|
+
name,
|
|
1171
|
+
label,
|
|
1172
|
+
type,
|
|
1173
|
+
variant,
|
|
1174
|
+
disabled,
|
|
1175
|
+
autoFocus,
|
|
1176
|
+
multiline,
|
|
1177
|
+
placeholder,
|
|
1178
|
+
rows,
|
|
1179
|
+
maxRows,
|
|
1180
|
+
value,
|
|
1181
|
+
onChange: $disableInputChange ? void 0 : onChange,
|
|
1182
|
+
clickedVariableIcon,
|
|
1183
|
+
inputProps,
|
|
1184
|
+
allowedVariables,
|
|
1185
|
+
showVariableIcon: !hideVariables && (!isAutoComplete || allowedVariableDefinitions.length > 0),
|
|
1186
|
+
ref
|
|
1187
|
+
}
|
|
1188
|
+
);
|
|
1189
|
+
return /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
1190
|
+
/* @__PURE__ */ jsx3(
|
|
1191
|
+
Popover,
|
|
1192
|
+
{
|
|
1193
|
+
anchorEl: containerRef.current,
|
|
1194
|
+
anchorOrigin: { vertical: "bottom", horizontal: "left" },
|
|
1195
|
+
transformOrigin: { vertical: "top", horizontal: "left" },
|
|
1196
|
+
open: !hideVariables && showVariables,
|
|
1197
|
+
onClose: clickedVariableIcon,
|
|
1198
|
+
slotProps: {
|
|
1199
|
+
paper: {
|
|
1200
|
+
sx: {
|
|
1201
|
+
color: "var(--neutralLight2, #cac9d5)",
|
|
1202
|
+
backgroundColor: "var(--neutralDark1, #171628)",
|
|
1203
|
+
// Paper has no padding of its own — the picker body's `p-2` is the
|
|
1204
|
+
// single source of internal spacing. Adding paper padding on top of
|
|
1205
|
+
// that compounds the inset and forces premature horizontal scroll.
|
|
1206
|
+
padding: 0,
|
|
1207
|
+
border: "1px solid var(--neutralDark4, #393853)",
|
|
1208
|
+
borderRadius: "var(--radius, 1rem)",
|
|
1209
|
+
overflow: "hidden"
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
},
|
|
1213
|
+
children: pickerBody
|
|
1214
|
+
}
|
|
1215
|
+
),
|
|
1216
|
+
isAutoComplete ? /* @__PURE__ */ jsx3(
|
|
1217
|
+
Autocomplete,
|
|
1218
|
+
{
|
|
1219
|
+
disableClearable: true,
|
|
1220
|
+
openOnFocus: true,
|
|
1221
|
+
includeInputInList: true,
|
|
1222
|
+
multiple: $multiple,
|
|
1223
|
+
freeSolo: $freeSolo,
|
|
1224
|
+
disableCloseOnSelect: $disableCloseOnSelect,
|
|
1225
|
+
groupBy: autoCompleteGroupBy,
|
|
1226
|
+
options: autoCompleteOptions ?? [],
|
|
1227
|
+
isOptionEqualToValue,
|
|
1228
|
+
value,
|
|
1229
|
+
disabled,
|
|
1230
|
+
loading,
|
|
1231
|
+
getOptionLabel: resolveOptionLabel,
|
|
1232
|
+
onChange: (_e, nextValue) => {
|
|
1233
|
+
if ($getFullValueObject) {
|
|
1234
|
+
onChange?.(nextValue);
|
|
1235
|
+
return;
|
|
1236
|
+
}
|
|
1237
|
+
if ($multiple) {
|
|
1238
|
+
const list = Array.isArray(nextValue) ? nextValue : nextValue ? [nextValue] : [];
|
|
1239
|
+
const mapped = list.map((entry) => {
|
|
1240
|
+
if (entry && typeof entry === "object" && "value" in entry) {
|
|
1241
|
+
return entry.value;
|
|
1242
|
+
}
|
|
1243
|
+
return entry;
|
|
1244
|
+
});
|
|
1245
|
+
onChange?.(mapped);
|
|
1246
|
+
return;
|
|
1247
|
+
}
|
|
1248
|
+
if (nextValue && typeof nextValue === "object" && "value" in nextValue) {
|
|
1249
|
+
onChange?.(nextValue.value);
|
|
1250
|
+
return;
|
|
1251
|
+
}
|
|
1252
|
+
onChange?.(nextValue);
|
|
1253
|
+
},
|
|
1254
|
+
onInputChange: $disableInputChange ? void 0 : (_e, nextValue) => onChange?.(nextValue),
|
|
1255
|
+
filterOptions: handleFilterOptions,
|
|
1256
|
+
renderOption: $renderOption ?? renderOption ?? defaultRenderOption,
|
|
1257
|
+
slots: ListboxComponent ? { listbox: ListboxComponent } : void 0,
|
|
1258
|
+
slotProps: {
|
|
1259
|
+
popper: {
|
|
1260
|
+
className: "ls-variable-autocomplete-popper"
|
|
1261
|
+
},
|
|
1262
|
+
paper: {
|
|
1263
|
+
className: "ls-variable-autocomplete-paper",
|
|
1264
|
+
sx: {
|
|
1265
|
+
border: "1px solid var(--neutralDark4, var(--cardborder, #393853))",
|
|
1266
|
+
borderRadius: "var(--radius, 1rem)",
|
|
1267
|
+
backgroundColor: "var(--neutralDark2, var(--cardbackground, #211f45))",
|
|
1268
|
+
color: "var(--neutralLight1, var(--white, #fff))",
|
|
1269
|
+
boxShadow: "0 16px 32px rgba(0, 0, 0, 0.32)",
|
|
1270
|
+
overflow: "hidden"
|
|
1271
|
+
}
|
|
1272
|
+
},
|
|
1273
|
+
listbox: {
|
|
1274
|
+
className: "ls-variable-autocomplete-listbox",
|
|
1275
|
+
onScroll: onScrollListBox,
|
|
1276
|
+
sx: {
|
|
1277
|
+
padding: "0.25rem 0",
|
|
1278
|
+
backgroundColor: "var(--neutralDark2, var(--cardbackground, #211f45))",
|
|
1279
|
+
color: "var(--neutralLight1, var(--white, #fff))",
|
|
1280
|
+
"& .MuiAutocomplete-option": {
|
|
1281
|
+
display: "flex",
|
|
1282
|
+
minHeight: 44,
|
|
1283
|
+
alignItems: "center",
|
|
1284
|
+
padding: "0.625rem 1rem",
|
|
1285
|
+
color: "var(--neutralLight1, var(--white, #fff))",
|
|
1286
|
+
fontSize: "1rem",
|
|
1287
|
+
lineHeight: 1.35,
|
|
1288
|
+
transition: "background-color 120ms ease, color 120ms ease"
|
|
1289
|
+
},
|
|
1290
|
+
"& .MuiAutocomplete-option:hover, & .MuiAutocomplete-option.Mui-focused, & .MuiAutocomplete-option[data-focus='true'], & .MuiAutocomplete-option[aria-selected='true']": {
|
|
1291
|
+
backgroundColor: "var(--cardHover, var(--transwhite, rgba(255, 255, 255, 0.05)))",
|
|
1292
|
+
color: "var(--neutralLight1, var(--white, #fff))"
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
},
|
|
1296
|
+
popupIndicator: {
|
|
1297
|
+
className: "ls-variable-autocomplete-popup-indicator",
|
|
1298
|
+
sx: {
|
|
1299
|
+
color: "var(--neutralLight1, var(--white, #fff))",
|
|
1300
|
+
"& svg": {
|
|
1301
|
+
color: "var(--neutralLight1, var(--white, #fff))",
|
|
1302
|
+
fill: "currentColor"
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
},
|
|
1307
|
+
onHighlightChange,
|
|
1308
|
+
onOpen: onPopupOpen,
|
|
1309
|
+
onClose: onPopupClose,
|
|
1310
|
+
renderInput: (params) => textField(params)
|
|
1311
|
+
}
|
|
1312
|
+
) : textField()
|
|
1313
|
+
] });
|
|
1314
|
+
});
|
|
1315
|
+
LSVariableInputField.displayName = "LSVariableInputField";
|
|
1316
|
+
var VariableInputTextField = forwardRef3(
|
|
1317
|
+
({
|
|
1318
|
+
t,
|
|
1319
|
+
id,
|
|
1320
|
+
name,
|
|
1321
|
+
label,
|
|
1322
|
+
type,
|
|
1323
|
+
variant,
|
|
1324
|
+
disabled,
|
|
1325
|
+
autoFocus,
|
|
1326
|
+
multiline,
|
|
1327
|
+
placeholder,
|
|
1328
|
+
rows,
|
|
1329
|
+
maxRows,
|
|
1330
|
+
value,
|
|
1331
|
+
onChange,
|
|
1332
|
+
inputProps,
|
|
1333
|
+
clickedVariableIcon,
|
|
1334
|
+
params = {},
|
|
1335
|
+
containerRef,
|
|
1336
|
+
showVariableIcon
|
|
1337
|
+
}, ref) => {
|
|
1338
|
+
const inputPropsInputProps = inputProps?.InputProps ?? {};
|
|
1339
|
+
const paramsInputProps = params?.InputProps ?? {};
|
|
1340
|
+
const inputPropsSlotInputProps = inputProps?.slotProps?.input ?? {};
|
|
1341
|
+
const paramsSlotInputProps = params?.slotProps?.input ?? {};
|
|
1342
|
+
const explicitStartAdornment = inputProps?.startAdornment;
|
|
1343
|
+
const resolvedExplicitStartAdornment = explicitStartAdornment ? /* @__PURE__ */ jsx3(InputAdornment2, { position: "start", children: explicitStartAdornment }) : void 0;
|
|
1344
|
+
const startAdornment = paramsInputProps.startAdornment ?? paramsSlotInputProps.startAdornment ?? inputPropsInputProps.startAdornment ?? inputPropsSlotInputProps.startAdornment ?? resolvedExplicitStartAdornment;
|
|
1345
|
+
const endAdornment = paramsInputProps.endAdornment ?? paramsSlotInputProps.endAdornment ?? inputPropsInputProps.endAdornment ?? inputPropsSlotInputProps.endAdornment;
|
|
1346
|
+
return /* @__PURE__ */ jsx3(
|
|
1347
|
+
LSTextField,
|
|
1348
|
+
{
|
|
1349
|
+
id,
|
|
1350
|
+
name,
|
|
1351
|
+
label,
|
|
1352
|
+
type,
|
|
1353
|
+
color: "primary",
|
|
1354
|
+
variant,
|
|
1355
|
+
disabled,
|
|
1356
|
+
autoFocus,
|
|
1357
|
+
multiline,
|
|
1358
|
+
placeholder,
|
|
1359
|
+
rows,
|
|
1360
|
+
maxRows,
|
|
1361
|
+
value,
|
|
1362
|
+
fullWidth: true,
|
|
1363
|
+
className: `mui-ls-input ${params?.className ?? ""} ${inputProps?.className ?? ""}`.trim(),
|
|
1364
|
+
onChange: onChange ? (e) => onChange(e.target.value) : void 0,
|
|
1365
|
+
...inputProps,
|
|
1366
|
+
...params,
|
|
1367
|
+
InputProps: {
|
|
1368
|
+
...inputPropsSlotInputProps,
|
|
1369
|
+
...inputPropsInputProps,
|
|
1370
|
+
...paramsSlotInputProps,
|
|
1371
|
+
...paramsInputProps,
|
|
1372
|
+
startAdornment,
|
|
1373
|
+
endAdornment: /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
1374
|
+
endAdornment ?? null,
|
|
1375
|
+
showVariableIcon ? /* @__PURE__ */ jsx3(
|
|
1376
|
+
Tooltip,
|
|
1377
|
+
{
|
|
1378
|
+
title: t("chatbot.allowed-variables", "Allowed Variables"),
|
|
1379
|
+
children: /* @__PURE__ */ jsx3(
|
|
1380
|
+
InputAdornment2,
|
|
1381
|
+
{
|
|
1382
|
+
position: "end",
|
|
1383
|
+
onClick: clickedVariableIcon,
|
|
1384
|
+
ref: containerRef,
|
|
1385
|
+
className: "ls-variable-input-adornment",
|
|
1386
|
+
children: "{}"
|
|
1387
|
+
}
|
|
1388
|
+
)
|
|
1389
|
+
}
|
|
1390
|
+
) : null
|
|
1391
|
+
] })
|
|
1392
|
+
},
|
|
1393
|
+
inputRef: ref
|
|
1394
|
+
}
|
|
1395
|
+
);
|
|
1396
|
+
}
|
|
1397
|
+
);
|
|
1398
|
+
VariableInputTextField.displayName = "VariableInputTextField";
|
|
1399
|
+
export {
|
|
1400
|
+
LSVariableInputField,
|
|
1401
|
+
LSVariableInputProvider
|
|
1402
|
+
};
|