@lumiastream/ui 0.2.8-alpha.9 → 0.2.9
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 +3068 -1446
- package/dist/se-import.d.ts +444 -0
- package/dist/se-import.js +8094 -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 +73 -6
|
@@ -0,0 +1,2317 @@
|
|
|
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/LSButton/LSButton.tsx
|
|
27
|
+
import Button from "@mui/material/Button";
|
|
28
|
+
import classNames from "classnames";
|
|
29
|
+
import { jsx } from "react/jsx-runtime";
|
|
30
|
+
var LSButton = ({
|
|
31
|
+
label,
|
|
32
|
+
disabled = false,
|
|
33
|
+
loading = false,
|
|
34
|
+
variant = "contained",
|
|
35
|
+
extended = 0,
|
|
36
|
+
color,
|
|
37
|
+
primary = false,
|
|
38
|
+
backgroundColor,
|
|
39
|
+
className,
|
|
40
|
+
sx,
|
|
41
|
+
style,
|
|
42
|
+
...props
|
|
43
|
+
}) => {
|
|
44
|
+
const resolvedColor = color ?? (primary ? "primary" : "primary");
|
|
45
|
+
const muiColor = resolvedColor === "neutral" ? void 0 : resolvedColor;
|
|
46
|
+
const backgroundSx = backgroundColor ? { backgroundColor, "&:hover": { backgroundColor } } : null;
|
|
47
|
+
const secondaryOutlinedStyles = resolvedColor === "secondary" && variant === "outlined" ? {
|
|
48
|
+
color: "var(--white) !important",
|
|
49
|
+
"& .MuiButton-startIcon, & .MuiButton-endIcon": {
|
|
50
|
+
color: "inherit"
|
|
51
|
+
}
|
|
52
|
+
} : null;
|
|
53
|
+
return /* @__PURE__ */ jsx(
|
|
54
|
+
Button,
|
|
55
|
+
{
|
|
56
|
+
disabled: disabled || loading,
|
|
57
|
+
variant,
|
|
58
|
+
color: muiColor,
|
|
59
|
+
style,
|
|
60
|
+
sx: [
|
|
61
|
+
{ borderRadius: "1rem", transition: "opacity 300ms ease-in-out" },
|
|
62
|
+
...backgroundSx ? [backgroundSx] : [],
|
|
63
|
+
...Array.isArray(sx) ? sx : sx ? [sx] : [],
|
|
64
|
+
...secondaryOutlinedStyles ? [secondaryOutlinedStyles] : []
|
|
65
|
+
],
|
|
66
|
+
className: classNames(
|
|
67
|
+
"mui-ls-button cursor-pointer rounded-2xl pb-1.5 pt-1.5 hover:opacity-80 svg-current-color",
|
|
68
|
+
extended ? "pl-12 pr-12 mui-ls-button--extended" : "pl-6 pr-6",
|
|
69
|
+
`mui-ls-button--${resolvedColor}`,
|
|
70
|
+
`mui-ls-button--${variant}`,
|
|
71
|
+
className
|
|
72
|
+
),
|
|
73
|
+
...props,
|
|
74
|
+
children: loading ? "Loading..." : label
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// src/components/LSInput/LSInput.tsx
|
|
80
|
+
import FormControl from "@mui/material/FormControl";
|
|
81
|
+
import InputAdornment from "@mui/material/InputAdornment";
|
|
82
|
+
import TextField from "@mui/material/TextField";
|
|
83
|
+
import classNames2 from "classnames";
|
|
84
|
+
import { forwardRef } from "react";
|
|
85
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
86
|
+
var LSInput = forwardRef(
|
|
87
|
+
(props, ref) => {
|
|
88
|
+
const hasExplicitValue = Object.prototype.hasOwnProperty.call(props, "value");
|
|
89
|
+
const {
|
|
90
|
+
startAdornment,
|
|
91
|
+
endAdornment,
|
|
92
|
+
inputBeforeText,
|
|
93
|
+
inputAfterText,
|
|
94
|
+
maxWidth,
|
|
95
|
+
className = "",
|
|
96
|
+
InputProps: inputPropsProp,
|
|
97
|
+
InputLabelProps: inputLabelPropsProp,
|
|
98
|
+
inputProps: htmlInputPropsProp,
|
|
99
|
+
slotProps: slotPropsProp,
|
|
100
|
+
onChange,
|
|
101
|
+
onChangeStart,
|
|
102
|
+
onChangeEnd,
|
|
103
|
+
type,
|
|
104
|
+
value,
|
|
105
|
+
helperText,
|
|
106
|
+
error,
|
|
107
|
+
style,
|
|
108
|
+
centerText,
|
|
109
|
+
$noMinHeight,
|
|
110
|
+
bypasscolor,
|
|
111
|
+
textColor,
|
|
112
|
+
fullWidth = true,
|
|
113
|
+
...rest
|
|
114
|
+
} = props;
|
|
115
|
+
const isNumberInput = type === "number";
|
|
116
|
+
const labelIdFallback = typeof rest.label === "string" ? rest.label : void 0;
|
|
117
|
+
const normalizedValue = isNumberInput && (value === void 0 || value === null) ? "" : value;
|
|
118
|
+
const handleChange = (event) => {
|
|
119
|
+
const rawValue = event.target.value;
|
|
120
|
+
let sanitizedValue = rawValue;
|
|
121
|
+
if (isNumberInput) {
|
|
122
|
+
if (rawValue === "") {
|
|
123
|
+
sanitizedValue = void 0;
|
|
124
|
+
} else {
|
|
125
|
+
const numericValue = Number(rawValue);
|
|
126
|
+
sanitizedValue = Number.isNaN(numericValue) ? void 0 : numericValue;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
onChangeStart?.(event, sanitizedValue);
|
|
130
|
+
onChange?.(event, sanitizedValue);
|
|
131
|
+
onChangeEnd?.(event, sanitizedValue);
|
|
132
|
+
};
|
|
133
|
+
const resolvedStartAdornment = inputPropsProp?.startAdornment ?? (startAdornment ? /* @__PURE__ */ jsx2(InputAdornment, { position: "start", children: startAdornment }) : inputBeforeText ? /* @__PURE__ */ jsx2(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx2("span", { className: "mui-ls-input-affix", children: inputBeforeText }) }) : void 0);
|
|
134
|
+
const resolvedEndAdornment = inputPropsProp?.endAdornment ?? (endAdornment ? /* @__PURE__ */ jsx2(InputAdornment, { position: "end", children: endAdornment }) : inputAfterText ? /* @__PURE__ */ jsx2(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx2("span", { className: "mui-ls-input-affix", children: inputAfterText }) }) : void 0);
|
|
135
|
+
const inputSlotProps = {
|
|
136
|
+
...inputPropsProp,
|
|
137
|
+
startAdornment: resolvedStartAdornment,
|
|
138
|
+
endAdornment: resolvedEndAdornment,
|
|
139
|
+
readOnly: rest.readOnly ?? inputPropsProp?.readOnly,
|
|
140
|
+
sx: {
|
|
141
|
+
...inputPropsProp?.sx ?? {},
|
|
142
|
+
"& input, & textarea": {
|
|
143
|
+
textAlign: centerText ? "center" : void 0,
|
|
144
|
+
color: textColor ?? void 0
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const inputLabelProps = {
|
|
149
|
+
shrink: true,
|
|
150
|
+
...inputLabelPropsProp
|
|
151
|
+
};
|
|
152
|
+
const helperContent = helperText ?? (typeof error === "string" ? error : "");
|
|
153
|
+
const hasError = typeof error === "string" ? true : Boolean(error);
|
|
154
|
+
const resolvedMaxWidth = maxWidth ?? style?.maxWidth;
|
|
155
|
+
const valueProps = hasExplicitValue ? { value: normalizedValue } : {};
|
|
156
|
+
const slotProps = {
|
|
157
|
+
...slotPropsProp ?? {},
|
|
158
|
+
input: {
|
|
159
|
+
...slotPropsProp?.input ?? {},
|
|
160
|
+
...inputSlotProps,
|
|
161
|
+
sx: {
|
|
162
|
+
...slotPropsProp?.input?.sx ?? {},
|
|
163
|
+
...inputSlotProps.sx
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
inputLabel: {
|
|
167
|
+
...slotPropsProp?.inputLabel ?? {},
|
|
168
|
+
...inputLabelProps
|
|
169
|
+
},
|
|
170
|
+
htmlInput: {
|
|
171
|
+
...slotPropsProp?.htmlInput ?? {},
|
|
172
|
+
...htmlInputPropsProp ?? {}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
const TextFieldComponent = TextField;
|
|
176
|
+
return /* @__PURE__ */ jsx2(
|
|
177
|
+
FormControl,
|
|
178
|
+
{
|
|
179
|
+
variant: "outlined",
|
|
180
|
+
className: classNames2("mui-ls-input", className, {
|
|
181
|
+
noMinHeight: $noMinHeight,
|
|
182
|
+
bypassMuiColor: bypasscolor || bypasscolor === "default"
|
|
183
|
+
}),
|
|
184
|
+
style: { ...style, maxWidth: resolvedMaxWidth, width: fullWidth ? "100%" : style?.width },
|
|
185
|
+
children: /* @__PURE__ */ jsx2(
|
|
186
|
+
TextFieldComponent,
|
|
187
|
+
{
|
|
188
|
+
...rest,
|
|
189
|
+
...valueProps,
|
|
190
|
+
type,
|
|
191
|
+
id: rest.id ?? rest.name ?? labelIdFallback,
|
|
192
|
+
label: rest.label,
|
|
193
|
+
size: rest.size,
|
|
194
|
+
margin: "dense",
|
|
195
|
+
variant: "outlined",
|
|
196
|
+
color: bypasscolor === "default" || bypasscolor === "inherit" ? "primary" : bypasscolor,
|
|
197
|
+
fullWidth,
|
|
198
|
+
onChange: handleChange,
|
|
199
|
+
slotProps,
|
|
200
|
+
inputRef: ref,
|
|
201
|
+
helperText: helperContent,
|
|
202
|
+
error: hasError
|
|
203
|
+
}
|
|
204
|
+
)
|
|
205
|
+
}
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
);
|
|
209
|
+
LSInput.displayName = "LSInput";
|
|
210
|
+
|
|
211
|
+
// src/components/LSSliderInput/LSSliderInput.tsx
|
|
212
|
+
import Slider from "@mui/material/Slider";
|
|
213
|
+
import classNames3 from "classnames";
|
|
214
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
215
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
216
|
+
var normalizeSliderValue = (rawValue) => {
|
|
217
|
+
if (typeof rawValue === "number") {
|
|
218
|
+
return Number.isFinite(rawValue) ? rawValue : 0;
|
|
219
|
+
}
|
|
220
|
+
if (typeof rawValue === "string") {
|
|
221
|
+
const trimmedValue = rawValue.trim();
|
|
222
|
+
if (!trimmedValue) {
|
|
223
|
+
return 0;
|
|
224
|
+
}
|
|
225
|
+
const numericValue = Number(trimmedValue);
|
|
226
|
+
return Number.isFinite(numericValue) ? numericValue : 0;
|
|
227
|
+
}
|
|
228
|
+
return 0;
|
|
229
|
+
};
|
|
230
|
+
var LSSliderInput = ({
|
|
231
|
+
name,
|
|
232
|
+
value,
|
|
233
|
+
defaultValue,
|
|
234
|
+
isFloat,
|
|
235
|
+
isMiliseconds,
|
|
236
|
+
isFloatMiliseconds,
|
|
237
|
+
label,
|
|
238
|
+
inline,
|
|
239
|
+
hasInfo,
|
|
240
|
+
infoOpen,
|
|
241
|
+
infoClose,
|
|
242
|
+
max = Number.MAX_SAFE_INTEGER,
|
|
243
|
+
min = 0,
|
|
244
|
+
step = 1,
|
|
245
|
+
type = "number",
|
|
246
|
+
inputAfterText,
|
|
247
|
+
onChange,
|
|
248
|
+
inputProps = {},
|
|
249
|
+
helperText,
|
|
250
|
+
fullWidth = false,
|
|
251
|
+
hideInput = false,
|
|
252
|
+
hideSlider = false,
|
|
253
|
+
valueLabelFormat,
|
|
254
|
+
...rest
|
|
255
|
+
}) => {
|
|
256
|
+
const isValueFloat = Boolean(isFloat || isFloatMiliseconds || isMiliseconds);
|
|
257
|
+
const actualToDisplay = useCallback(
|
|
258
|
+
(input) => {
|
|
259
|
+
const numericValue = normalizeSliderValue(input);
|
|
260
|
+
if (!isValueFloat) {
|
|
261
|
+
return numericValue;
|
|
262
|
+
}
|
|
263
|
+
const divisor = isFloatMiliseconds ? 1e3 : 1;
|
|
264
|
+
return Number((numericValue / divisor).toFixed(1));
|
|
265
|
+
},
|
|
266
|
+
[isFloatMiliseconds, isValueFloat]
|
|
267
|
+
);
|
|
268
|
+
const displayStep = useMemo(() => actualToDisplay(step), [actualToDisplay, step]);
|
|
269
|
+
const resolvedDefaultValue = defaultValue ?? 0;
|
|
270
|
+
const [displayValue, setDisplayValue] = useState(() => actualToDisplay(defaultValue ?? value ?? resolvedDefaultValue));
|
|
271
|
+
const displayMaximum = useMemo(() => actualToDisplay(max), [actualToDisplay, max]);
|
|
272
|
+
const displayMinimum = useMemo(() => actualToDisplay(min), [actualToDisplay, min]);
|
|
273
|
+
const sliderValue = typeof displayValue === "number" ? Math.min(displayMaximum, Math.max(displayMinimum, displayValue)) : displayMinimum;
|
|
274
|
+
const stepPrecision = useMemo(() => {
|
|
275
|
+
const stepString = String(displayStep);
|
|
276
|
+
const decimalIndex = stepString.indexOf(".");
|
|
277
|
+
return decimalIndex === -1 ? 0 : stepString.length - decimalIndex - 1;
|
|
278
|
+
}, [displayStep]);
|
|
279
|
+
useEffect(() => {
|
|
280
|
+
if (value !== void 0) {
|
|
281
|
+
setDisplayValue(actualToDisplay(value));
|
|
282
|
+
}
|
|
283
|
+
}, [actualToDisplay, value]);
|
|
284
|
+
const normalizeDisplayValue = useCallback(
|
|
285
|
+
(input) => {
|
|
286
|
+
const bounded = Math.min(displayMaximum, Math.max(displayMinimum, input));
|
|
287
|
+
if (!Number.isFinite(displayStep) || displayStep <= 0) {
|
|
288
|
+
return bounded;
|
|
289
|
+
}
|
|
290
|
+
const snapped = Math.round((bounded - displayMinimum) / displayStep) * displayStep + displayMinimum;
|
|
291
|
+
return Number(snapped.toFixed(stepPrecision));
|
|
292
|
+
},
|
|
293
|
+
[displayMaximum, displayMinimum, displayStep, stepPrecision]
|
|
294
|
+
);
|
|
295
|
+
const handleInputChange = useCallback(
|
|
296
|
+
({ target: { value: inputValue } }) => {
|
|
297
|
+
setDisplayValue(inputValue ?? "");
|
|
298
|
+
if (inputValue === "" || inputValue === null) {
|
|
299
|
+
if (typeof onChange === "function") {
|
|
300
|
+
onChange(void 0);
|
|
301
|
+
}
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
const numericValue = Number(inputValue);
|
|
305
|
+
if (Number.isNaN(numericValue)) {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
const normalizedDisplayValue = normalizeDisplayValue(numericValue);
|
|
309
|
+
const updatedValue = isFloatMiliseconds ? normalizedDisplayValue * 1e3 : normalizedDisplayValue;
|
|
310
|
+
const upperBound = typeof max === "number" ? max : Number.MAX_SAFE_INTEGER;
|
|
311
|
+
const lowerBound = typeof min === "number" ? min : 0;
|
|
312
|
+
const isValid = updatedValue >= lowerBound && updatedValue <= upperBound;
|
|
313
|
+
if (isValid && typeof onChange === "function") {
|
|
314
|
+
onChange(updatedValue);
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
[isFloatMiliseconds, max, min, normalizeDisplayValue, onChange]
|
|
318
|
+
);
|
|
319
|
+
const handleSliderChange = useCallback(
|
|
320
|
+
(_, sliderInputValue) => {
|
|
321
|
+
const numericValue = typeof sliderInputValue === "number" ? sliderInputValue : sliderInputValue[0];
|
|
322
|
+
const normalizedDisplayValue = normalizeDisplayValue(numericValue);
|
|
323
|
+
setDisplayValue(normalizedDisplayValue);
|
|
324
|
+
const nextValue = isFloatMiliseconds ? normalizedDisplayValue * 1e3 : normalizedDisplayValue;
|
|
325
|
+
onChange?.(nextValue);
|
|
326
|
+
},
|
|
327
|
+
[isFloatMiliseconds, normalizeDisplayValue, onChange]
|
|
328
|
+
);
|
|
329
|
+
const controlsRow = /* @__PURE__ */ jsxs(
|
|
330
|
+
"div",
|
|
331
|
+
{
|
|
332
|
+
className: classNames3("mui-ls-slider-input-row", {
|
|
333
|
+
"mui-ls-slider-input-row--slider": !hideSlider,
|
|
334
|
+
"mui-ls-slider-input-row--input": hideInput
|
|
335
|
+
}),
|
|
336
|
+
children: [
|
|
337
|
+
!hideSlider && /* @__PURE__ */ jsx3(
|
|
338
|
+
Slider,
|
|
339
|
+
{
|
|
340
|
+
value: sliderValue,
|
|
341
|
+
onChange: handleSliderChange,
|
|
342
|
+
onBlur: rest.onBlur,
|
|
343
|
+
color: "primary",
|
|
344
|
+
valueLabelDisplay: "auto",
|
|
345
|
+
valueLabelFormat: (v) => valueLabelFormat?.(v) ?? `${v}${inputAfterText ?? ""}`,
|
|
346
|
+
min: displayMinimum,
|
|
347
|
+
max: displayMaximum,
|
|
348
|
+
step: displayStep,
|
|
349
|
+
sx: { flex: 1, minWidth: 0 }
|
|
350
|
+
}
|
|
351
|
+
),
|
|
352
|
+
!hideInput && /* @__PURE__ */ jsx3(
|
|
353
|
+
LSInput,
|
|
354
|
+
{
|
|
355
|
+
...rest,
|
|
356
|
+
...inputProps,
|
|
357
|
+
type,
|
|
358
|
+
name,
|
|
359
|
+
onChange: (_event, nextValue) => handleInputChange({ target: { value: nextValue ?? "" } }),
|
|
360
|
+
value: displayValue ?? "",
|
|
361
|
+
inputAfterText,
|
|
362
|
+
InputProps: {
|
|
363
|
+
...inputProps?.InputProps ?? {},
|
|
364
|
+
name,
|
|
365
|
+
type: "number",
|
|
366
|
+
value: displayValue,
|
|
367
|
+
min: displayMinimum,
|
|
368
|
+
max: displayMaximum,
|
|
369
|
+
step: displayStep,
|
|
370
|
+
inputMode: stepPrecision > 0 ? "decimal" : "numeric"
|
|
371
|
+
},
|
|
372
|
+
fullWidth: hideSlider ? fullWidth : false,
|
|
373
|
+
$noMinHeight: false,
|
|
374
|
+
className: hideSlider ? inputProps?.className : `${inputProps?.className ?? ""} mui-ls-slider-input-value`.trim(),
|
|
375
|
+
style: hideSlider ? inputProps?.style : { width: 112, maxWidth: 112, flexShrink: 0 },
|
|
376
|
+
...!hideSlider ? { size: "small" } : {}
|
|
377
|
+
}
|
|
378
|
+
)
|
|
379
|
+
]
|
|
380
|
+
}
|
|
381
|
+
);
|
|
382
|
+
return /* @__PURE__ */ jsxs("div", { className: "mui-ls-slider-input-root", children: [
|
|
383
|
+
/* @__PURE__ */ jsxs("fieldset", { className: "mui-ls-slider-input-fieldset", children: [
|
|
384
|
+
label && /* @__PURE__ */ jsx3("legend", { className: "mui-ls-slider-input-legend", children: label }),
|
|
385
|
+
controlsRow
|
|
386
|
+
] }),
|
|
387
|
+
helperText && /* @__PURE__ */ jsx3("small", { className: "mui-ls-slider-input-helper", children: helperText })
|
|
388
|
+
] });
|
|
389
|
+
};
|
|
390
|
+
LSSliderInput.displayName = "LSSliderInput";
|
|
391
|
+
|
|
392
|
+
// src/components/LSSelect/LSSelect.tsx
|
|
393
|
+
import FormControl2 from "@mui/material/FormControl";
|
|
394
|
+
import InputLabel from "@mui/material/InputLabel";
|
|
395
|
+
import Select from "@mui/material/Select";
|
|
396
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
397
|
+
var LSSelect = ({
|
|
398
|
+
className = "",
|
|
399
|
+
style,
|
|
400
|
+
...props
|
|
401
|
+
}) => {
|
|
402
|
+
const {
|
|
403
|
+
placeholder,
|
|
404
|
+
displayEmpty: displayEmptyProp,
|
|
405
|
+
renderValue: renderValueProp,
|
|
406
|
+
variant: _variant,
|
|
407
|
+
MenuProps,
|
|
408
|
+
...rest
|
|
409
|
+
} = props;
|
|
410
|
+
const labelKey = props.name ?? (typeof props.label === "string" ? props.label : void 0);
|
|
411
|
+
const labelId = props.label && labelKey ? `label_${labelKey}` : void 0;
|
|
412
|
+
const placeholderText = typeof placeholder === "string" ? placeholder : "";
|
|
413
|
+
const displayEmpty = displayEmptyProp ?? !!placeholderText;
|
|
414
|
+
const value = rest.multiple === true ? Array.isArray(rest.value) ? rest.value : rest.value === void 0 || rest.value === null || rest.value === "" ? [] : [rest.value] : rest.value ?? "";
|
|
415
|
+
const renderValue = renderValueProp ?? (placeholderText ? (selected) => {
|
|
416
|
+
if (selected === "" || Array.isArray(selected) && selected.length === 0) {
|
|
417
|
+
return /* @__PURE__ */ jsx4("span", { style: { color: "var(--neutralLight3)" }, children: placeholderText });
|
|
418
|
+
}
|
|
419
|
+
return Array.isArray(selected) ? selected.join(", ") : selected;
|
|
420
|
+
} : void 0);
|
|
421
|
+
const mergedMenuProps = {
|
|
422
|
+
...MenuProps ?? {},
|
|
423
|
+
slotProps: {
|
|
424
|
+
...MenuProps?.slotProps ?? {},
|
|
425
|
+
paper: {
|
|
426
|
+
...MenuProps?.slotProps?.paper ?? {},
|
|
427
|
+
sx: {
|
|
428
|
+
background: "var(--neutralDark2) !important",
|
|
429
|
+
backgroundColor: "var(--neutralDark2)",
|
|
430
|
+
color: "var(--neutralLight1)",
|
|
431
|
+
border: "1px solid var(--neutralDark4)",
|
|
432
|
+
borderRadius: "var(--radius, 1rem)",
|
|
433
|
+
boxShadow: "0 16px 32px rgba(0, 0, 0, 0.32)",
|
|
434
|
+
...MenuProps?.slotProps?.paper?.sx
|
|
435
|
+
}
|
|
436
|
+
},
|
|
437
|
+
list: {
|
|
438
|
+
...MenuProps?.slotProps?.list ?? {},
|
|
439
|
+
sx: {
|
|
440
|
+
backgroundColor: "var(--neutralDark2)",
|
|
441
|
+
color: "var(--neutralLight1)",
|
|
442
|
+
...MenuProps?.slotProps?.list?.sx
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
PaperProps: {
|
|
447
|
+
...MenuProps?.PaperProps ?? {},
|
|
448
|
+
sx: {
|
|
449
|
+
background: "var(--neutralDark2) !important",
|
|
450
|
+
backgroundColor: "var(--neutralDark2)",
|
|
451
|
+
color: "var(--neutralLight1)",
|
|
452
|
+
border: "1px solid var(--neutralDark4)",
|
|
453
|
+
borderRadius: "var(--radius, 1rem)",
|
|
454
|
+
boxShadow: "0 16px 32px rgba(0, 0, 0, 0.32)",
|
|
455
|
+
"& .MuiList-root": {
|
|
456
|
+
backgroundColor: "var(--neutralDark2)"
|
|
457
|
+
},
|
|
458
|
+
"& .MuiListSubheader-root": {
|
|
459
|
+
backgroundColor: "var(--neutralDark1)",
|
|
460
|
+
color: "var(--neutralLight2)"
|
|
461
|
+
},
|
|
462
|
+
"& .MuiMenuItem-root": {
|
|
463
|
+
color: "var(--neutralLight1)"
|
|
464
|
+
},
|
|
465
|
+
...MenuProps?.PaperProps?.sx
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
return /* @__PURE__ */ jsxs2(
|
|
470
|
+
FormControl2,
|
|
471
|
+
{
|
|
472
|
+
variant: "outlined",
|
|
473
|
+
className: `${className} mui-ls-select-form-control`,
|
|
474
|
+
sx: {
|
|
475
|
+
marginBottom: ".3rem",
|
|
476
|
+
marginTop: ".5rem",
|
|
477
|
+
minWidth: "100px",
|
|
478
|
+
width: "100%"
|
|
479
|
+
},
|
|
480
|
+
size: rest.size,
|
|
481
|
+
style,
|
|
482
|
+
children: [
|
|
483
|
+
props.label && /* @__PURE__ */ jsx4(InputLabel, { shrink: true, id: labelId, children: props.label }),
|
|
484
|
+
/* @__PURE__ */ jsx4(
|
|
485
|
+
Select,
|
|
486
|
+
{
|
|
487
|
+
MenuProps: mergedMenuProps,
|
|
488
|
+
className: "mui-ls-select",
|
|
489
|
+
variant: "outlined",
|
|
490
|
+
labelId,
|
|
491
|
+
label: props.label,
|
|
492
|
+
displayEmpty,
|
|
493
|
+
renderValue,
|
|
494
|
+
...rest,
|
|
495
|
+
value,
|
|
496
|
+
children: props.children
|
|
497
|
+
}
|
|
498
|
+
)
|
|
499
|
+
]
|
|
500
|
+
}
|
|
501
|
+
);
|
|
502
|
+
};
|
|
503
|
+
LSSelect.displayName = "LSSelect";
|
|
504
|
+
|
|
505
|
+
// src/components/LSCheckbox/LSCheckbox.tsx
|
|
506
|
+
import Checkbox from "@mui/material/Checkbox";
|
|
507
|
+
import FormControlLabel from "@mui/material/FormControlLabel";
|
|
508
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
509
|
+
import { useController, useFormContext } from "react-hook-form";
|
|
510
|
+
import classNames4 from "classnames";
|
|
511
|
+
import { Fragment, jsx as jsx5 } from "react/jsx-runtime";
|
|
512
|
+
var LSCheckbox = forwardRef2(({ className = "", checked, inputRef, slotProps, ...props }, ref) => {
|
|
513
|
+
const CheckboxComponent = Checkbox;
|
|
514
|
+
return /* @__PURE__ */ jsx5(
|
|
515
|
+
CheckboxComponent,
|
|
516
|
+
{
|
|
517
|
+
...props,
|
|
518
|
+
checked,
|
|
519
|
+
className: classNames4("ls-checkbox", className, { "Mui-disabled": props.disabled }),
|
|
520
|
+
ref,
|
|
521
|
+
slotProps: {
|
|
522
|
+
...slotProps ?? {},
|
|
523
|
+
input: {
|
|
524
|
+
...slotProps?.input ?? {},
|
|
525
|
+
ref: inputRef ?? slotProps?.input?.ref
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
);
|
|
530
|
+
});
|
|
531
|
+
LSCheckbox.displayName = "LSCheckbox";
|
|
532
|
+
function LSCheckboxField({
|
|
533
|
+
name,
|
|
534
|
+
label,
|
|
535
|
+
control,
|
|
536
|
+
className = "",
|
|
537
|
+
disabled,
|
|
538
|
+
labelPlacement = "end",
|
|
539
|
+
checkboxProps
|
|
540
|
+
}) {
|
|
541
|
+
const formContext = useFormContext();
|
|
542
|
+
const resolvedControl = control ?? formContext?.control;
|
|
543
|
+
if (!resolvedControl) return /* @__PURE__ */ jsx5(Fragment, {});
|
|
544
|
+
return /* @__PURE__ */ jsx5(
|
|
545
|
+
LSCheckboxFieldInner,
|
|
546
|
+
{
|
|
547
|
+
name,
|
|
548
|
+
label,
|
|
549
|
+
control: resolvedControl,
|
|
550
|
+
className,
|
|
551
|
+
disabled,
|
|
552
|
+
labelPlacement,
|
|
553
|
+
checkboxProps
|
|
554
|
+
}
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
function LSCheckboxFieldInner({
|
|
558
|
+
name,
|
|
559
|
+
label,
|
|
560
|
+
control,
|
|
561
|
+
className = "",
|
|
562
|
+
disabled,
|
|
563
|
+
labelPlacement = "end",
|
|
564
|
+
checkboxProps
|
|
565
|
+
}) {
|
|
566
|
+
const { field } = useController({ name, control });
|
|
567
|
+
return /* @__PURE__ */ jsx5(
|
|
568
|
+
FormControlLabel,
|
|
569
|
+
{
|
|
570
|
+
className: classNames4("ls-checkbox-row", className),
|
|
571
|
+
labelPlacement,
|
|
572
|
+
disabled,
|
|
573
|
+
control: /* @__PURE__ */ jsx5(
|
|
574
|
+
LSCheckbox,
|
|
575
|
+
{
|
|
576
|
+
...checkboxProps,
|
|
577
|
+
name: field.name,
|
|
578
|
+
checked: Boolean(field.value),
|
|
579
|
+
onBlur: field.onBlur,
|
|
580
|
+
onChange: (_event, checked) => field.onChange(checked),
|
|
581
|
+
inputRef: field.ref,
|
|
582
|
+
disabled: disabled ?? checkboxProps?.disabled
|
|
583
|
+
}
|
|
584
|
+
),
|
|
585
|
+
label
|
|
586
|
+
}
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// src/components/LSColorPicker/LSColorPicker.tsx
|
|
591
|
+
import { useEffect as useEffect2, useRef, useState as useState2 } from "react";
|
|
592
|
+
import GradientColorPicker from "react-best-gradient-color-picker";
|
|
593
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
594
|
+
var DEFAULT_COLOR = "#ff4076";
|
|
595
|
+
var LSColorPicker = ({ value = DEFAULT_COLOR, onChange, onBlur, className, name, label, helperText, placeholder, hideGradientControls = false, usePopup = false, disabled = false }) => {
|
|
596
|
+
const isPopupMode = usePopup === true;
|
|
597
|
+
const [open, setOpen] = useState2(false);
|
|
598
|
+
const containerRef = useRef(null);
|
|
599
|
+
const [pickerWidth, setPickerWidth] = useState2(320);
|
|
600
|
+
const showPicker = open;
|
|
601
|
+
const pickerHeight = 220;
|
|
602
|
+
const inlinePickerHeight = hideGradientControls ? pickerHeight + 84 : pickerHeight + 150;
|
|
603
|
+
const pickerContainerStyle = isPopupMode ? {
|
|
604
|
+
position: "absolute",
|
|
605
|
+
right: 0,
|
|
606
|
+
top: "calc(100% + 0.5rem)",
|
|
607
|
+
zIndex: 1e3,
|
|
608
|
+
borderRadius: "1rem",
|
|
609
|
+
background: "var(--neutralDark1)",
|
|
610
|
+
padding: "0.5rem",
|
|
611
|
+
boxShadow: "0 8px 24px rgba(0, 0, 0, 0.4)"
|
|
612
|
+
} : {
|
|
613
|
+
position: "static",
|
|
614
|
+
display: "block",
|
|
615
|
+
width: "100%",
|
|
616
|
+
height: inlinePickerHeight,
|
|
617
|
+
minHeight: inlinePickerHeight,
|
|
618
|
+
marginTop: "0.5rem",
|
|
619
|
+
borderRadius: "1rem",
|
|
620
|
+
background: "var(--neutralDark1)",
|
|
621
|
+
padding: "0.5rem",
|
|
622
|
+
boxSizing: "border-box",
|
|
623
|
+
overflow: "visible"
|
|
624
|
+
};
|
|
625
|
+
useEffect2(() => {
|
|
626
|
+
const node = containerRef.current;
|
|
627
|
+
if (!node) return void 0;
|
|
628
|
+
const updateWidth = () => {
|
|
629
|
+
const nextWidth = Math.max(node.clientWidth - 16, 220);
|
|
630
|
+
setPickerWidth(nextWidth);
|
|
631
|
+
};
|
|
632
|
+
updateWidth();
|
|
633
|
+
const observer = new ResizeObserver(() => {
|
|
634
|
+
updateWidth();
|
|
635
|
+
});
|
|
636
|
+
observer.observe(node);
|
|
637
|
+
return () => observer.disconnect();
|
|
638
|
+
}, []);
|
|
639
|
+
useEffect2(() => {
|
|
640
|
+
if (!open) return void 0;
|
|
641
|
+
const handleClickOutside = (e) => {
|
|
642
|
+
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
643
|
+
setOpen(false);
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
647
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
648
|
+
}, [open]);
|
|
649
|
+
const handleInputChange = (e) => {
|
|
650
|
+
onChange(e.target.value);
|
|
651
|
+
};
|
|
652
|
+
const toggleOpen = () => {
|
|
653
|
+
if (disabled) return;
|
|
654
|
+
setOpen((nextOpen) => !nextOpen);
|
|
655
|
+
};
|
|
656
|
+
return /* @__PURE__ */ jsxs3(
|
|
657
|
+
"div",
|
|
658
|
+
{
|
|
659
|
+
ref: containerRef,
|
|
660
|
+
className: ["ls-color-picker", className].filter(Boolean).join(" "),
|
|
661
|
+
style: {
|
|
662
|
+
position: "relative",
|
|
663
|
+
display: "flex",
|
|
664
|
+
width: "100%",
|
|
665
|
+
flexDirection: "column",
|
|
666
|
+
overflow: "visible"
|
|
667
|
+
},
|
|
668
|
+
children: [
|
|
669
|
+
/* @__PURE__ */ jsx6(
|
|
670
|
+
LSInput,
|
|
671
|
+
{
|
|
672
|
+
className: "ls-color-picker__input",
|
|
673
|
+
name,
|
|
674
|
+
label,
|
|
675
|
+
helperText,
|
|
676
|
+
value,
|
|
677
|
+
onChange: handleInputChange,
|
|
678
|
+
onBlur,
|
|
679
|
+
placeholder,
|
|
680
|
+
disabled,
|
|
681
|
+
endAdornment: /* @__PURE__ */ jsx6(
|
|
682
|
+
"button",
|
|
683
|
+
{
|
|
684
|
+
type: "button",
|
|
685
|
+
className: "ls-color-picker__preview",
|
|
686
|
+
style: { background: value },
|
|
687
|
+
onClick: toggleOpen,
|
|
688
|
+
"aria-label": isPopupMode ? "Open color picker" : "Color preview",
|
|
689
|
+
disabled
|
|
690
|
+
}
|
|
691
|
+
)
|
|
692
|
+
}
|
|
693
|
+
),
|
|
694
|
+
showPicker && /* @__PURE__ */ jsx6(
|
|
695
|
+
"div",
|
|
696
|
+
{
|
|
697
|
+
className: isPopupMode ? "ls-color-picker__picker ls-color-picker__picker--popup" : "ls-color-picker__picker ls-color-picker__picker--inline",
|
|
698
|
+
style: pickerContainerStyle,
|
|
699
|
+
children: /* @__PURE__ */ jsx6(
|
|
700
|
+
GradientColorPicker,
|
|
701
|
+
{
|
|
702
|
+
hidePresets: true,
|
|
703
|
+
hideColorGuide: true,
|
|
704
|
+
hideAdvancedSliders: true,
|
|
705
|
+
hideInputs: true,
|
|
706
|
+
hideInputType: true,
|
|
707
|
+
hideEyeDrop: false,
|
|
708
|
+
hideGradientControls,
|
|
709
|
+
hideColorTypeBtns: hideGradientControls,
|
|
710
|
+
width: pickerWidth,
|
|
711
|
+
height: pickerHeight,
|
|
712
|
+
className: "ls-color-picker__gradient",
|
|
713
|
+
value,
|
|
714
|
+
onChange,
|
|
715
|
+
style: {
|
|
716
|
+
body: { background: "transparent", color: "var(--neutralLight1, #fff)" },
|
|
717
|
+
rbgcpControlBtn: {
|
|
718
|
+
background: "var(--neutralDark4)",
|
|
719
|
+
color: "var(--neutralLight1, #fff)",
|
|
720
|
+
boxShadow: "none"
|
|
721
|
+
},
|
|
722
|
+
rbgcpControlBtnSelected: {
|
|
723
|
+
background: "var(--primary)",
|
|
724
|
+
color: "var(--neutralLight1)",
|
|
725
|
+
boxShadow: "0 6px 14px rgba(255, 64, 118, 0.28)"
|
|
726
|
+
},
|
|
727
|
+
rbgcpControlBtnWrapper: {
|
|
728
|
+
background: "var(--neutralDark4)",
|
|
729
|
+
color: "var(--neutralLight1, #fff)"
|
|
730
|
+
},
|
|
731
|
+
rbgcpControlIconBtn: {
|
|
732
|
+
background: "transparent",
|
|
733
|
+
color: "var(--neutralLight1, #fff)"
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
)
|
|
738
|
+
}
|
|
739
|
+
)
|
|
740
|
+
]
|
|
741
|
+
}
|
|
742
|
+
);
|
|
743
|
+
};
|
|
744
|
+
|
|
745
|
+
// src/components/LSDatePicker/LSDatePicker.tsx
|
|
746
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
747
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
748
|
+
var toDateTimeLocalValue = (value) => {
|
|
749
|
+
if (!value) return "";
|
|
750
|
+
const date = new Date(value);
|
|
751
|
+
if (Number.isNaN(date.getTime())) return "";
|
|
752
|
+
const offsetMs = date.getTimezoneOffset() * 60 * 1e3;
|
|
753
|
+
return new Date(date.getTime() - offsetMs).toISOString().slice(0, 16);
|
|
754
|
+
};
|
|
755
|
+
var fromDateTimeLocalValue = (value) => {
|
|
756
|
+
if (!value) return "";
|
|
757
|
+
return new Date(value).toISOString();
|
|
758
|
+
};
|
|
759
|
+
var LSDatePicker = forwardRef3(
|
|
760
|
+
({ value, onChange, onChangeStart, onChangeEnd, className, ...rest }, ref) => {
|
|
761
|
+
const handleChange = (event) => {
|
|
762
|
+
const nextValue = fromDateTimeLocalValue(event.target.value);
|
|
763
|
+
onChangeStart?.(event, nextValue);
|
|
764
|
+
onChange?.(event, nextValue);
|
|
765
|
+
onChangeEnd?.(event, nextValue);
|
|
766
|
+
};
|
|
767
|
+
return /* @__PURE__ */ jsx7(
|
|
768
|
+
LSInput,
|
|
769
|
+
{
|
|
770
|
+
...rest,
|
|
771
|
+
ref,
|
|
772
|
+
className: ["mui-ls-date-picker", className].filter(Boolean).join(" "),
|
|
773
|
+
type: "datetime-local",
|
|
774
|
+
value: toDateTimeLocalValue(value),
|
|
775
|
+
onChange: handleChange
|
|
776
|
+
}
|
|
777
|
+
);
|
|
778
|
+
}
|
|
779
|
+
);
|
|
780
|
+
LSDatePicker.displayName = "LSDatePicker";
|
|
781
|
+
|
|
782
|
+
// src/components/LSFontPicker/LSFontPicker.tsx
|
|
783
|
+
import { KeyboardArrowDown } from "@mui/icons-material";
|
|
784
|
+
import Autocomplete from "@mui/material/Autocomplete";
|
|
785
|
+
import TextField2 from "@mui/material/TextField";
|
|
786
|
+
import {
|
|
787
|
+
memo,
|
|
788
|
+
startTransition,
|
|
789
|
+
useEffect as useEffect3,
|
|
790
|
+
useMemo as useMemo2,
|
|
791
|
+
useRef as useRef2,
|
|
792
|
+
useState as useState3
|
|
793
|
+
} from "react";
|
|
794
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
795
|
+
var LSFontPicker = memo(function LSFontPicker2({
|
|
796
|
+
value,
|
|
797
|
+
onChange,
|
|
798
|
+
fonts = [],
|
|
799
|
+
localFonts = [],
|
|
800
|
+
onLoadFonts,
|
|
801
|
+
defaultValue = "Roboto",
|
|
802
|
+
placeholder = "Select a font",
|
|
803
|
+
isAlertManager = false,
|
|
804
|
+
label,
|
|
805
|
+
helperText
|
|
806
|
+
}) {
|
|
807
|
+
const AutocompleteComponent = Autocomplete;
|
|
808
|
+
const TextFieldComponent = TextField2;
|
|
809
|
+
const [inputValue, setInputValue] = useState3(value ?? defaultValue);
|
|
810
|
+
const onLoadFontsRef = useRef2(onLoadFonts);
|
|
811
|
+
const onChangeRef = useRef2(onChange);
|
|
812
|
+
const combinedFonts = useMemo2(
|
|
813
|
+
() => Array.from(/* @__PURE__ */ new Set([...localFonts, ...fonts])).sort(),
|
|
814
|
+
[fonts, localFonts]
|
|
815
|
+
);
|
|
816
|
+
const currentValue = value ?? defaultValue;
|
|
817
|
+
useEffect3(() => {
|
|
818
|
+
onLoadFontsRef.current = onLoadFonts;
|
|
819
|
+
onChangeRef.current = onChange;
|
|
820
|
+
}, [onLoadFonts, onChange]);
|
|
821
|
+
useEffect3(() => {
|
|
822
|
+
setInputValue(currentValue);
|
|
823
|
+
}, [currentValue]);
|
|
824
|
+
useEffect3(() => {
|
|
825
|
+
if (!currentValue || isAlertManager) return;
|
|
826
|
+
startTransition(() => {
|
|
827
|
+
onLoadFontsRef.current?.([currentValue]);
|
|
828
|
+
});
|
|
829
|
+
}, [currentValue, isAlertManager]);
|
|
830
|
+
const handleValueChange = (nextValue) => {
|
|
831
|
+
setInputValue(nextValue);
|
|
832
|
+
onChangeRef.current(nextValue);
|
|
833
|
+
if (!nextValue || isAlertManager) return;
|
|
834
|
+
startTransition(() => {
|
|
835
|
+
onLoadFontsRef.current?.([nextValue]);
|
|
836
|
+
});
|
|
837
|
+
};
|
|
838
|
+
return /* @__PURE__ */ jsx8("div", { className: "ls-font-picker", children: /* @__PURE__ */ jsx8(
|
|
839
|
+
AutocompleteComponent,
|
|
840
|
+
{
|
|
841
|
+
freeSolo: true,
|
|
842
|
+
disableClearable: true,
|
|
843
|
+
openOnFocus: true,
|
|
844
|
+
forcePopupIcon: true,
|
|
845
|
+
options: combinedFonts,
|
|
846
|
+
value: currentValue,
|
|
847
|
+
inputValue,
|
|
848
|
+
popupIcon: /* @__PURE__ */ jsx8(KeyboardArrowDown, {}),
|
|
849
|
+
isOptionEqualToValue: (option, selectedValue) => option === selectedValue,
|
|
850
|
+
onChange: (_event, newValue) => {
|
|
851
|
+
handleValueChange(
|
|
852
|
+
typeof newValue === "string" ? newValue : `${newValue ?? ""}`
|
|
853
|
+
);
|
|
854
|
+
},
|
|
855
|
+
onInputChange: (_event, newInputValue, reason) => {
|
|
856
|
+
if (reason === "input" || reason === "clear") {
|
|
857
|
+
handleValueChange(newInputValue);
|
|
858
|
+
}
|
|
859
|
+
},
|
|
860
|
+
slotProps: {
|
|
861
|
+
popper: {
|
|
862
|
+
sx: { zIndex: 1400 }
|
|
863
|
+
},
|
|
864
|
+
paper: {
|
|
865
|
+
sx: {
|
|
866
|
+
background: "var(--neutralDark3)",
|
|
867
|
+
border: "1px solid var(--neutralDark4)",
|
|
868
|
+
borderRadius: "var(--radius, 1rem)",
|
|
869
|
+
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.3)",
|
|
870
|
+
color: "var(--neutralLight1)",
|
|
871
|
+
marginTop: "4px"
|
|
872
|
+
}
|
|
873
|
+
},
|
|
874
|
+
popupIndicator: {
|
|
875
|
+
sx: {
|
|
876
|
+
color: "var(--neutralLight2)",
|
|
877
|
+
"&.MuiAutocomplete-popupIndicatorOpen": {
|
|
878
|
+
transform: "rotate(180deg)"
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
},
|
|
883
|
+
ListboxProps: {
|
|
884
|
+
sx: {
|
|
885
|
+
maxHeight: 300,
|
|
886
|
+
padding: 0
|
|
887
|
+
}
|
|
888
|
+
},
|
|
889
|
+
noOptionsText: "No fonts found",
|
|
890
|
+
renderOption: (props, option) => {
|
|
891
|
+
const { key, ...optionProps } = props;
|
|
892
|
+
return /* @__PURE__ */ jsx8(
|
|
893
|
+
"li",
|
|
894
|
+
{
|
|
895
|
+
...optionProps,
|
|
896
|
+
style: {
|
|
897
|
+
...optionProps.style ?? {},
|
|
898
|
+
fontFamily: `${option}, Arial, sans-serif`,
|
|
899
|
+
color: "var(--neutralLight1)",
|
|
900
|
+
borderBottom: "1px solid rgba(255, 255, 255, 0.05)",
|
|
901
|
+
padding: "0.75rem 1.25rem",
|
|
902
|
+
transition: "background-color 0.1s ease"
|
|
903
|
+
},
|
|
904
|
+
children: option
|
|
905
|
+
},
|
|
906
|
+
key
|
|
907
|
+
);
|
|
908
|
+
},
|
|
909
|
+
renderInput: (params) => /* @__PURE__ */ jsx8(
|
|
910
|
+
TextFieldComponent,
|
|
911
|
+
{
|
|
912
|
+
...params,
|
|
913
|
+
label,
|
|
914
|
+
helperText,
|
|
915
|
+
placeholder,
|
|
916
|
+
fullWidth: true,
|
|
917
|
+
className: "mui-ls-input",
|
|
918
|
+
variant: "outlined",
|
|
919
|
+
sx: {
|
|
920
|
+
"& .MuiOutlinedInput-root": {
|
|
921
|
+
paddingRight: "0.5rem"
|
|
922
|
+
}
|
|
923
|
+
},
|
|
924
|
+
InputLabelProps: {
|
|
925
|
+
shrink: true,
|
|
926
|
+
...params.InputLabelProps ?? {}
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
)
|
|
930
|
+
}
|
|
931
|
+
) });
|
|
932
|
+
});
|
|
933
|
+
|
|
934
|
+
// src/components/LSMultiSelect/LSMultiSelect.tsx
|
|
935
|
+
import { MenuItem } from "@mui/material";
|
|
936
|
+
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
937
|
+
var LSMultiSelect = ({
|
|
938
|
+
options,
|
|
939
|
+
placeholder = "Select...",
|
|
940
|
+
value,
|
|
941
|
+
onChange,
|
|
942
|
+
label
|
|
943
|
+
}) => {
|
|
944
|
+
const handleChange = (event) => {
|
|
945
|
+
const {
|
|
946
|
+
target: { value: value2 }
|
|
947
|
+
} = event;
|
|
948
|
+
onChange(typeof value2 === "string" ? value2.split(",") : value2);
|
|
949
|
+
};
|
|
950
|
+
return /* @__PURE__ */ jsx9(
|
|
951
|
+
LSSelect,
|
|
952
|
+
{
|
|
953
|
+
multiple: true,
|
|
954
|
+
label,
|
|
955
|
+
fullWidth: true,
|
|
956
|
+
className: "mui-multi-select",
|
|
957
|
+
value: value ?? [],
|
|
958
|
+
onChange: handleChange,
|
|
959
|
+
displayEmpty: true,
|
|
960
|
+
renderValue: (selected) => /* @__PURE__ */ jsxs4("div", { className: "ls-multi-select-value", children: [
|
|
961
|
+
/* @__PURE__ */ jsx9("div", { className: "ls-multi-select-value__label", children: selected.length > 0 ? selected.map(
|
|
962
|
+
(val) => options.find((opt) => opt.value === val)?.label ?? val
|
|
963
|
+
).join(", ") : placeholder }),
|
|
964
|
+
/* @__PURE__ */ jsx9("div", { className: "ls-multi-select-value__count", children: `(${selected.length})` })
|
|
965
|
+
] }),
|
|
966
|
+
MenuProps: {
|
|
967
|
+
slotProps: {
|
|
968
|
+
paper: {
|
|
969
|
+
sx: {
|
|
970
|
+
background: "var(--neutralDark2) !important",
|
|
971
|
+
backgroundColor: "var(--neutralDark2)",
|
|
972
|
+
color: "var(--neutralLight1)",
|
|
973
|
+
border: "1px solid var(--neutralDark4)",
|
|
974
|
+
borderRadius: "var(--radius, 1rem)",
|
|
975
|
+
boxShadow: "0 16px 32px rgba(0, 0, 0, 0.32)",
|
|
976
|
+
backdropFilter: "none",
|
|
977
|
+
opacity: 1,
|
|
978
|
+
maxHeight: "280px !important"
|
|
979
|
+
}
|
|
980
|
+
},
|
|
981
|
+
list: {
|
|
982
|
+
sx: {
|
|
983
|
+
backgroundColor: "var(--neutralDark2)",
|
|
984
|
+
color: "var(--neutralLight1)"
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
},
|
|
988
|
+
PaperProps: {
|
|
989
|
+
sx: {
|
|
990
|
+
background: "var(--neutralDark2) !important",
|
|
991
|
+
backgroundColor: "var(--neutralDark2)",
|
|
992
|
+
color: "var(--neutralLight1)",
|
|
993
|
+
backdropFilter: "none",
|
|
994
|
+
opacity: 1,
|
|
995
|
+
maxHeight: "280px !important",
|
|
996
|
+
border: "1px solid var(--neutralDark4)",
|
|
997
|
+
borderRadius: "var(--radius, 1rem)",
|
|
998
|
+
"& .MuiList-root": {
|
|
999
|
+
backgroundColor: "var(--neutralDark2)"
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
},
|
|
1004
|
+
children: options.map((option) => /* @__PURE__ */ jsxs4(
|
|
1005
|
+
MenuItem,
|
|
1006
|
+
{
|
|
1007
|
+
value: option.value,
|
|
1008
|
+
sx: {
|
|
1009
|
+
display: "flex",
|
|
1010
|
+
alignItems: "center",
|
|
1011
|
+
gap: "0.4rem",
|
|
1012
|
+
color: "var(--neutralLight1)",
|
|
1013
|
+
"&.Mui-selected, &.Mui-selected:hover": {
|
|
1014
|
+
background: "rgba(255, 64, 118, 0.12)"
|
|
1015
|
+
},
|
|
1016
|
+
"&:hover": {
|
|
1017
|
+
background: "rgba(255, 255, 255, 0.06)"
|
|
1018
|
+
}
|
|
1019
|
+
},
|
|
1020
|
+
children: [
|
|
1021
|
+
/* @__PURE__ */ jsx9(
|
|
1022
|
+
LSCheckbox,
|
|
1023
|
+
{
|
|
1024
|
+
checked: (value ?? []).includes(option.value),
|
|
1025
|
+
tabIndex: -1,
|
|
1026
|
+
disableRipple: true
|
|
1027
|
+
}
|
|
1028
|
+
),
|
|
1029
|
+
/* @__PURE__ */ jsx9("span", { children: option.label })
|
|
1030
|
+
]
|
|
1031
|
+
},
|
|
1032
|
+
option.value
|
|
1033
|
+
))
|
|
1034
|
+
}
|
|
1035
|
+
);
|
|
1036
|
+
};
|
|
1037
|
+
|
|
1038
|
+
// src/components/LSRadio/LSRadio.tsx
|
|
1039
|
+
import FormControlLabel2 from "@mui/material/FormControlLabel";
|
|
1040
|
+
import Radio from "@mui/material/Radio";
|
|
1041
|
+
import RadioGroup from "@mui/material/RadioGroup";
|
|
1042
|
+
import classNames5 from "classnames";
|
|
1043
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1044
|
+
var LSRadio = ({ className = "", ...props }) => {
|
|
1045
|
+
return /* @__PURE__ */ jsx10(Radio, { ...props, className: classNames5("ls-radio", className) });
|
|
1046
|
+
};
|
|
1047
|
+
var LSRadioGroup = ({ selections, className = "", optionClassName = "", row, ...props }) => {
|
|
1048
|
+
return /* @__PURE__ */ jsx10(RadioGroup, { ...props, row, className: classNames5("ls-radio-group", className, { row }), children: selections.map((selection) => /* @__PURE__ */ jsx10(
|
|
1049
|
+
FormControlLabel2,
|
|
1050
|
+
{
|
|
1051
|
+
className: classNames5("ls-radio-row", optionClassName),
|
|
1052
|
+
value: selection.value,
|
|
1053
|
+
disabled: selection.disabled,
|
|
1054
|
+
control: /* @__PURE__ */ jsx10(LSRadio, {}),
|
|
1055
|
+
label: selection.label
|
|
1056
|
+
},
|
|
1057
|
+
selection.value
|
|
1058
|
+
)) });
|
|
1059
|
+
};
|
|
1060
|
+
LSRadioGroup.displayName = "LSRadioGroup";
|
|
1061
|
+
|
|
1062
|
+
// src/components/LSTextField/LSTextField.tsx
|
|
1063
|
+
import TextField3 from "@mui/material/TextField";
|
|
1064
|
+
import { forwardRef as forwardRef4 } from "react";
|
|
1065
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
1066
|
+
var LSTextField = forwardRef4(
|
|
1067
|
+
(props, ref) => {
|
|
1068
|
+
const { InputLabelProps, InputProps, slotProps, ...rest } = props;
|
|
1069
|
+
return /* @__PURE__ */ jsx11(
|
|
1070
|
+
TextField3,
|
|
1071
|
+
{
|
|
1072
|
+
...rest,
|
|
1073
|
+
variant: "outlined",
|
|
1074
|
+
className: "mui-ls-input",
|
|
1075
|
+
slotProps: {
|
|
1076
|
+
...slotProps ?? {},
|
|
1077
|
+
input: {
|
|
1078
|
+
...slotProps?.input ?? {},
|
|
1079
|
+
...InputProps ?? {},
|
|
1080
|
+
sx: {
|
|
1081
|
+
...slotProps?.input?.sx ?? {},
|
|
1082
|
+
...InputProps?.sx ?? {}
|
|
1083
|
+
}
|
|
1084
|
+
},
|
|
1085
|
+
inputLabel: {
|
|
1086
|
+
...slotProps?.inputLabel ?? {},
|
|
1087
|
+
shrink: true,
|
|
1088
|
+
...InputLabelProps ?? {}
|
|
1089
|
+
}
|
|
1090
|
+
},
|
|
1091
|
+
ref
|
|
1092
|
+
}
|
|
1093
|
+
);
|
|
1094
|
+
}
|
|
1095
|
+
);
|
|
1096
|
+
LSTextField.displayName = "LSTextField";
|
|
1097
|
+
|
|
1098
|
+
// src/components/LSVariableInputField/LSVariableInputField.tsx
|
|
1099
|
+
import Autocomplete2, {
|
|
1100
|
+
createFilterOptions
|
|
1101
|
+
} from "@mui/material/Autocomplete";
|
|
1102
|
+
import InputAdornment2 from "@mui/material/InputAdornment";
|
|
1103
|
+
import Popover from "@mui/material/Popover";
|
|
1104
|
+
import Search from "@mui/icons-material/Search";
|
|
1105
|
+
import KeyboardArrowDown2 from "@mui/icons-material/KeyboardArrowDown";
|
|
1106
|
+
import Tooltip from "@mui/material/Tooltip";
|
|
1107
|
+
import {
|
|
1108
|
+
Fragment as Fragment2,
|
|
1109
|
+
createContext,
|
|
1110
|
+
forwardRef as forwardRef5,
|
|
1111
|
+
useCallback as useCallback2,
|
|
1112
|
+
useContext,
|
|
1113
|
+
useEffect as useEffect4,
|
|
1114
|
+
useMemo as useMemo3,
|
|
1115
|
+
useRef as useRef3,
|
|
1116
|
+
useState as useState4
|
|
1117
|
+
} from "react";
|
|
1118
|
+
import { Fragment as Fragment3, jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1119
|
+
import { createElement } from "react";
|
|
1120
|
+
var LSVariableInputContext = createContext({});
|
|
1121
|
+
var LSVariableInputProvider = ({
|
|
1122
|
+
children,
|
|
1123
|
+
value
|
|
1124
|
+
}) => {
|
|
1125
|
+
return /* @__PURE__ */ jsx12(LSVariableInputContext.Provider, { value, children });
|
|
1126
|
+
};
|
|
1127
|
+
var DEFAULT_FUNCTION_VARIABLES = [
|
|
1128
|
+
"sum_variables",
|
|
1129
|
+
"offset_count",
|
|
1130
|
+
"read_file",
|
|
1131
|
+
"read_url",
|
|
1132
|
+
"selection",
|
|
1133
|
+
"random",
|
|
1134
|
+
"random_input",
|
|
1135
|
+
"get_commands",
|
|
1136
|
+
"get_all_commands",
|
|
1137
|
+
"convert_color_to_hex",
|
|
1138
|
+
"get_latest_file_from_folder",
|
|
1139
|
+
"get_random_file_from_folder",
|
|
1140
|
+
"screenshot",
|
|
1141
|
+
"overlay_screenshot",
|
|
1142
|
+
"obs_screenshot",
|
|
1143
|
+
"obs_vertical_replay",
|
|
1144
|
+
"obs_replay",
|
|
1145
|
+
"get_queue_count",
|
|
1146
|
+
"lumia_uptime",
|
|
1147
|
+
"twitch_uptime",
|
|
1148
|
+
"youtube_uptime",
|
|
1149
|
+
"facebook_uptime",
|
|
1150
|
+
"twitch_followage",
|
|
1151
|
+
"twitch_next_ad",
|
|
1152
|
+
"twitch_get_avatar",
|
|
1153
|
+
"get_var_from_msg",
|
|
1154
|
+
"get_user_loyalty_points",
|
|
1155
|
+
"translate",
|
|
1156
|
+
"ai_prompt",
|
|
1157
|
+
"viewer_profile_summary"
|
|
1158
|
+
];
|
|
1159
|
+
var MAX_OBJECT_DEPTH = 5;
|
|
1160
|
+
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1161
|
+
var isExpandableValue = (value) => {
|
|
1162
|
+
if (isPlainObject(value)) return Object.keys(value).length > 0;
|
|
1163
|
+
if (Array.isArray(value)) return value.length > 0;
|
|
1164
|
+
return false;
|
|
1165
|
+
};
|
|
1166
|
+
var isPrimitiveValue = (value) => value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
1167
|
+
var renderPrimitiveValue = (value) => {
|
|
1168
|
+
if (value === null || value === void 0) return "";
|
|
1169
|
+
if (typeof value === "boolean") return value.toString();
|
|
1170
|
+
if (typeof value === "number") return value.toString();
|
|
1171
|
+
if (typeof value === "string") return value;
|
|
1172
|
+
return String(value);
|
|
1173
|
+
};
|
|
1174
|
+
var renderComplexPreview = (value) => {
|
|
1175
|
+
if (Array.isArray(value)) {
|
|
1176
|
+
return `Array(${value.length}) [${value.slice(0, 3).map(
|
|
1177
|
+
(item) => typeof item === "string" ? `"${item}"` : typeof item === "object" ? "{...}" : String(item)
|
|
1178
|
+
).join(", ")}${value.length > 3 ? "..." : ""}]`;
|
|
1179
|
+
}
|
|
1180
|
+
const keys = Object.keys(value);
|
|
1181
|
+
return `Object {${keys.slice(0, 2).join(", ")}${keys.length > 2 ? "..." : ""}}`;
|
|
1182
|
+
};
|
|
1183
|
+
var getVariableValueDisplay = (value) => {
|
|
1184
|
+
const isComplexValue = !isPrimitiveValue(value) && value !== null && typeof value === "object";
|
|
1185
|
+
const displayValue = isComplexValue ? renderComplexPreview(value) : renderPrimitiveValue(value);
|
|
1186
|
+
const fullValue = isComplexValue ? JSON.stringify(value, null, 2) : renderPrimitiveValue(value);
|
|
1187
|
+
return { displayValue, fullValue, isComplexValue };
|
|
1188
|
+
};
|
|
1189
|
+
var buildValueChildren = (value, parentPath, depth) => {
|
|
1190
|
+
if (depth >= MAX_OBJECT_DEPTH) return [];
|
|
1191
|
+
if (isPlainObject(value)) {
|
|
1192
|
+
return Object.keys(value).map((key) => {
|
|
1193
|
+
const childValue = value[key];
|
|
1194
|
+
const relativePath = parentPath ? `${parentPath}.${key}` : key;
|
|
1195
|
+
const expandable = depth + 1 < MAX_OBJECT_DEPTH && isExpandableValue(childValue);
|
|
1196
|
+
return {
|
|
1197
|
+
relativePath,
|
|
1198
|
+
key,
|
|
1199
|
+
displayKey: key,
|
|
1200
|
+
depth: depth + 1,
|
|
1201
|
+
value: childValue,
|
|
1202
|
+
isExpandable: expandable,
|
|
1203
|
+
children: expandable ? buildValueChildren(childValue, relativePath, depth + 1) : []
|
|
1204
|
+
};
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1207
|
+
if (Array.isArray(value)) {
|
|
1208
|
+
return value.map((item, idx) => {
|
|
1209
|
+
const relativePath = parentPath ? `${parentPath}.${idx}` : String(idx);
|
|
1210
|
+
const expandable = depth + 1 < MAX_OBJECT_DEPTH && isExpandableValue(item);
|
|
1211
|
+
return {
|
|
1212
|
+
relativePath,
|
|
1213
|
+
key: String(idx),
|
|
1214
|
+
displayKey: `[${idx}]`,
|
|
1215
|
+
depth: depth + 1,
|
|
1216
|
+
value: item,
|
|
1217
|
+
isExpandable: expandable,
|
|
1218
|
+
children: expandable ? buildValueChildren(item, relativePath, depth + 1) : []
|
|
1219
|
+
};
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
return [];
|
|
1223
|
+
};
|
|
1224
|
+
var isVariableRecord = (value) => {
|
|
1225
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
1226
|
+
const v = value;
|
|
1227
|
+
return typeof v.name === "string" && ("system" in v || "origin" in v || "value" in v);
|
|
1228
|
+
};
|
|
1229
|
+
var synthesizeRecord = (name, value) => ({
|
|
1230
|
+
name,
|
|
1231
|
+
system: false,
|
|
1232
|
+
origin: "",
|
|
1233
|
+
description: "",
|
|
1234
|
+
value: value ?? ""
|
|
1235
|
+
});
|
|
1236
|
+
var normalizeVariableRecords = (systemVariables) => {
|
|
1237
|
+
const out = {};
|
|
1238
|
+
if (!systemVariables) return out;
|
|
1239
|
+
for (const [key, raw] of Object.entries(systemVariables)) {
|
|
1240
|
+
if (raw === void 0 || raw === null) continue;
|
|
1241
|
+
out[key] = isVariableRecord(raw) ? raw : synthesizeRecord(key, raw);
|
|
1242
|
+
}
|
|
1243
|
+
return out;
|
|
1244
|
+
};
|
|
1245
|
+
var defaultTranslate = (key, fallback, options) => {
|
|
1246
|
+
if (fallback && fallback !== "-") return fallback;
|
|
1247
|
+
if (key === "overlay-variables.variables-description")
|
|
1248
|
+
return "Use variables that will automatically be replaced before sending out the text";
|
|
1249
|
+
if (key === "overlay-variables.variable" || key === "commands.variable")
|
|
1250
|
+
return "Variable";
|
|
1251
|
+
if (key === "overlay-variables.description" || key === "commands.description")
|
|
1252
|
+
return "Description";
|
|
1253
|
+
if (key === "commands.suggested-variables") return "Suggested Variables";
|
|
1254
|
+
if (key === "common.value") return "Value";
|
|
1255
|
+
if (key === "common.search" || key === "assets.search") return "Search";
|
|
1256
|
+
if (key === "variables.functionvariables") return "Function variables";
|
|
1257
|
+
if (key === "chatbot.allowed-variables") return "Allowed Variables";
|
|
1258
|
+
if (key.startsWith("variables.")) {
|
|
1259
|
+
const variableName = key.replace("variables.", "");
|
|
1260
|
+
const example = options?.example;
|
|
1261
|
+
return example === void 0 || example === null ? variableName : String(example);
|
|
1262
|
+
}
|
|
1263
|
+
return fallback ?? key;
|
|
1264
|
+
};
|
|
1265
|
+
var normalizeAllowedDefinitions = (allowedVariables) => {
|
|
1266
|
+
if (!Array.isArray(allowedVariables)) return [];
|
|
1267
|
+
const unique = /* @__PURE__ */ new Set();
|
|
1268
|
+
const definitions = [];
|
|
1269
|
+
allowedVariables.forEach((variable) => {
|
|
1270
|
+
let variableName = "";
|
|
1271
|
+
let description;
|
|
1272
|
+
let origin;
|
|
1273
|
+
let example;
|
|
1274
|
+
if (typeof variable === "string") {
|
|
1275
|
+
variableName = variable.trim();
|
|
1276
|
+
} else if (variable && typeof variable === "object") {
|
|
1277
|
+
const typedVariable = variable;
|
|
1278
|
+
const candidateName = [
|
|
1279
|
+
typedVariable.name,
|
|
1280
|
+
typedVariable.key,
|
|
1281
|
+
typedVariable.variable
|
|
1282
|
+
].find((value) => typeof value === "string");
|
|
1283
|
+
variableName = typeof candidateName === "string" ? candidateName.trim() : "";
|
|
1284
|
+
description = typeof typedVariable.description === "string" ? typedVariable.description.trim() : void 0;
|
|
1285
|
+
origin = typeof typedVariable.origin === "string" ? typedVariable.origin.trim().toLowerCase() : void 0;
|
|
1286
|
+
example = typedVariable.example;
|
|
1287
|
+
}
|
|
1288
|
+
if (!variableName || unique.has(variableName)) return;
|
|
1289
|
+
unique.add(variableName);
|
|
1290
|
+
definitions.push({ name: variableName, description, origin, example });
|
|
1291
|
+
});
|
|
1292
|
+
return definitions;
|
|
1293
|
+
};
|
|
1294
|
+
var filter = createFilterOptions({
|
|
1295
|
+
stringify: (option) => {
|
|
1296
|
+
if (typeof option === "string") return option;
|
|
1297
|
+
if (typeof option === "number" || typeof option === "boolean" || typeof option === "bigint")
|
|
1298
|
+
return String(option);
|
|
1299
|
+
if (!option || typeof option !== "object") return "";
|
|
1300
|
+
const typed = option;
|
|
1301
|
+
return [typed.label, typed.value, typed.helperText, typed.searchText].filter(
|
|
1302
|
+
(value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean"
|
|
1303
|
+
).map((value) => String(value)).join(" ");
|
|
1304
|
+
}
|
|
1305
|
+
});
|
|
1306
|
+
var visualTypeFromRecord = (variable) => {
|
|
1307
|
+
if (variable?.isFunction) return "func";
|
|
1308
|
+
if (variable?.system || variable?.locked) return "system";
|
|
1309
|
+
return "custom";
|
|
1310
|
+
};
|
|
1311
|
+
var visualTypeRank = (variableType) => {
|
|
1312
|
+
if (variableType === "custom") return 0;
|
|
1313
|
+
if (variableType === "func") return 1;
|
|
1314
|
+
return 2;
|
|
1315
|
+
};
|
|
1316
|
+
var orderItemsByVariableType = (items, getType) => {
|
|
1317
|
+
const grouped = {
|
|
1318
|
+
custom: [],
|
|
1319
|
+
func: [],
|
|
1320
|
+
system: []
|
|
1321
|
+
};
|
|
1322
|
+
items.forEach((item) => grouped[getType(item)].push(item));
|
|
1323
|
+
return [...grouped.custom, ...grouped.func, ...grouped.system];
|
|
1324
|
+
};
|
|
1325
|
+
var sortItemsByVariableTypeThenName = (items, getType, getName) => {
|
|
1326
|
+
return [...items].sort((a, b) => {
|
|
1327
|
+
const typeDiff = visualTypeRank(getType(a)) - visualTypeRank(getType(b));
|
|
1328
|
+
if (typeDiff !== 0) return typeDiff;
|
|
1329
|
+
return getName(a).localeCompare(getName(b));
|
|
1330
|
+
});
|
|
1331
|
+
};
|
|
1332
|
+
var humanizeVariableName = (rawName) => {
|
|
1333
|
+
if (!rawName) return "";
|
|
1334
|
+
return rawName.replace(/^_+|_+$/g, "").replace(/_/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (char) => char.toUpperCase());
|
|
1335
|
+
};
|
|
1336
|
+
var getVariableColorClass = (variableType, isSuggested) => {
|
|
1337
|
+
if (isSuggested && variableType !== "func")
|
|
1338
|
+
return "ls-variable-token--custom";
|
|
1339
|
+
if (variableType === "func") return "ls-variable-token--function";
|
|
1340
|
+
if (variableType === "system") return "ls-variable-token--system";
|
|
1341
|
+
return "ls-variable-token--custom";
|
|
1342
|
+
};
|
|
1343
|
+
var CHILD_VARIABLE_COLOR_CLASS = "ls-variable-token--child";
|
|
1344
|
+
var LSVariableInputField = forwardRef5((props, ref) => {
|
|
1345
|
+
const context = useContext(LSVariableInputContext);
|
|
1346
|
+
const {
|
|
1347
|
+
name,
|
|
1348
|
+
label,
|
|
1349
|
+
type,
|
|
1350
|
+
isAutoComplete,
|
|
1351
|
+
autoCompleteOptions,
|
|
1352
|
+
autoCompleteGroupBy,
|
|
1353
|
+
renderOption,
|
|
1354
|
+
hideVariables,
|
|
1355
|
+
allowedVariables,
|
|
1356
|
+
disabled,
|
|
1357
|
+
autoFocus,
|
|
1358
|
+
inputProps = {},
|
|
1359
|
+
multiline,
|
|
1360
|
+
rows,
|
|
1361
|
+
maxRows,
|
|
1362
|
+
value,
|
|
1363
|
+
placeholder,
|
|
1364
|
+
variant,
|
|
1365
|
+
ListboxComponent,
|
|
1366
|
+
onScrollListBox,
|
|
1367
|
+
onHighlightChange,
|
|
1368
|
+
onPopupClose,
|
|
1369
|
+
onPopupOpen,
|
|
1370
|
+
afterFilter,
|
|
1371
|
+
onChange,
|
|
1372
|
+
loading,
|
|
1373
|
+
getOptionLabel,
|
|
1374
|
+
isOptionEqualToValue,
|
|
1375
|
+
$disableInputChange,
|
|
1376
|
+
$getFullValueObject,
|
|
1377
|
+
$multiple,
|
|
1378
|
+
$disableCloseOnSelect,
|
|
1379
|
+
$freeSolo,
|
|
1380
|
+
$renderOption,
|
|
1381
|
+
allowedVariableOrigin,
|
|
1382
|
+
systemVariables: systemVariablesProp,
|
|
1383
|
+
functionVariables: functionVariablesProp,
|
|
1384
|
+
translate,
|
|
1385
|
+
onVariableTranslationsNeeded,
|
|
1386
|
+
isOriginConnected: isOriginConnectedProp,
|
|
1387
|
+
translationKeyExists: translationKeyExistsProp
|
|
1388
|
+
} = props;
|
|
1389
|
+
const t = translate ?? context.translate ?? defaultTranslate;
|
|
1390
|
+
const rawSystemVariables = systemVariablesProp ?? context.systemVariables ?? {};
|
|
1391
|
+
const variableRecords = useMemo3(
|
|
1392
|
+
() => normalizeVariableRecords(rawSystemVariables),
|
|
1393
|
+
[rawSystemVariables]
|
|
1394
|
+
);
|
|
1395
|
+
const functionVariables = useMemo3(
|
|
1396
|
+
() => functionVariablesProp ?? context.functionVariables ?? DEFAULT_FUNCTION_VARIABLES,
|
|
1397
|
+
[context.functionVariables, functionVariablesProp]
|
|
1398
|
+
);
|
|
1399
|
+
const requestTranslations = onVariableTranslationsNeeded ?? context.onVariableTranslationsNeeded;
|
|
1400
|
+
const isOriginConnected = isOriginConnectedProp ?? context.isOriginConnected;
|
|
1401
|
+
const translationKeyExists = translationKeyExistsProp ?? context.translationKeyExists;
|
|
1402
|
+
const containerRef = useRef3(null);
|
|
1403
|
+
const variableId = useRef3(`variable-input-${name ?? "field"}`);
|
|
1404
|
+
const [showVariables, setShowVariables] = useState4(false);
|
|
1405
|
+
const [searchQuery, setSearchQuery] = useState4("");
|
|
1406
|
+
const functionVariableSet = useMemo3(
|
|
1407
|
+
() => new Set(functionVariables),
|
|
1408
|
+
[functionVariables]
|
|
1409
|
+
);
|
|
1410
|
+
const allowedVariableDefinitions = useMemo3(
|
|
1411
|
+
() => normalizeAllowedDefinitions(allowedVariables),
|
|
1412
|
+
[allowedVariables]
|
|
1413
|
+
);
|
|
1414
|
+
const allowedVariableDefinitionLookup = useMemo3(() => {
|
|
1415
|
+
const lookup = /* @__PURE__ */ new Map();
|
|
1416
|
+
allowedVariableDefinitions.forEach(
|
|
1417
|
+
(definition) => lookup.set(definition.name, definition)
|
|
1418
|
+
);
|
|
1419
|
+
return lookup;
|
|
1420
|
+
}, [allowedVariableDefinitions]);
|
|
1421
|
+
const allowedVariableNames = useMemo3(
|
|
1422
|
+
() => allowedVariableDefinitions.map((definition) => definition.name),
|
|
1423
|
+
[allowedVariableDefinitions]
|
|
1424
|
+
);
|
|
1425
|
+
const [filteredAllowedVariables, setFilteredAllowedVariables] = useState4(allowedVariableDefinitions);
|
|
1426
|
+
const [filteredSystemVariables, setFilteredSystemVariables] = useState4([]);
|
|
1427
|
+
const [expandedPaths, setExpandedPaths] = useState4(
|
|
1428
|
+
() => /* @__PURE__ */ new Set()
|
|
1429
|
+
);
|
|
1430
|
+
const [autoExpandPaths, setAutoExpandPaths] = useState4(
|
|
1431
|
+
() => /* @__PURE__ */ new Set()
|
|
1432
|
+
);
|
|
1433
|
+
const systemVariableValueTrees = useMemo3(() => {
|
|
1434
|
+
const map = /* @__PURE__ */ new Map();
|
|
1435
|
+
Object.values(variableRecords).forEach((variable) => {
|
|
1436
|
+
if (variable && isExpandableValue(variable.value)) {
|
|
1437
|
+
map.set(variable.name, buildValueChildren(variable.value, "", 0));
|
|
1438
|
+
}
|
|
1439
|
+
});
|
|
1440
|
+
return map;
|
|
1441
|
+
}, [variableRecords]);
|
|
1442
|
+
const allowedExampleTrees = useMemo3(() => {
|
|
1443
|
+
const map = /* @__PURE__ */ new Map();
|
|
1444
|
+
allowedVariableDefinitions.forEach((definition) => {
|
|
1445
|
+
if (isExpandableValue(definition.example)) {
|
|
1446
|
+
map.set(definition.name, buildValueChildren(definition.example, "", 0));
|
|
1447
|
+
}
|
|
1448
|
+
});
|
|
1449
|
+
return map;
|
|
1450
|
+
}, [allowedVariableDefinitions]);
|
|
1451
|
+
useEffect4(() => {
|
|
1452
|
+
requestTranslations?.();
|
|
1453
|
+
}, [requestTranslations]);
|
|
1454
|
+
const isPathExpanded = useCallback2(
|
|
1455
|
+
(path) => expandedPaths.has(path) || autoExpandPaths.has(path),
|
|
1456
|
+
[autoExpandPaths, expandedPaths]
|
|
1457
|
+
);
|
|
1458
|
+
const toggleExpand = useCallback2(
|
|
1459
|
+
(path) => {
|
|
1460
|
+
const expanded = expandedPaths.has(path) || autoExpandPaths.has(path);
|
|
1461
|
+
if (expanded) {
|
|
1462
|
+
if (expandedPaths.has(path)) {
|
|
1463
|
+
setExpandedPaths((prev) => {
|
|
1464
|
+
const next = new Set(prev);
|
|
1465
|
+
next.delete(path);
|
|
1466
|
+
return next;
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1469
|
+
if (autoExpandPaths.has(path)) {
|
|
1470
|
+
setAutoExpandPaths((prev) => {
|
|
1471
|
+
const next = new Set(prev);
|
|
1472
|
+
next.delete(path);
|
|
1473
|
+
return next;
|
|
1474
|
+
});
|
|
1475
|
+
}
|
|
1476
|
+
} else {
|
|
1477
|
+
setExpandedPaths((prev) => {
|
|
1478
|
+
const next = new Set(prev);
|
|
1479
|
+
next.add(path);
|
|
1480
|
+
return next;
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1483
|
+
},
|
|
1484
|
+
[autoExpandPaths, expandedPaths]
|
|
1485
|
+
);
|
|
1486
|
+
const namespaceHas = useCallback2(
|
|
1487
|
+
(key, namespace) => {
|
|
1488
|
+
if (!translationKeyExists) return false;
|
|
1489
|
+
try {
|
|
1490
|
+
return translationKeyExists(key, namespace);
|
|
1491
|
+
} catch {
|
|
1492
|
+
return false;
|
|
1493
|
+
}
|
|
1494
|
+
},
|
|
1495
|
+
[translationKeyExists]
|
|
1496
|
+
);
|
|
1497
|
+
const resolveTranslationFromNamespace = useCallback2(
|
|
1498
|
+
(variableName, namespace) => {
|
|
1499
|
+
const normalizedNamespace = typeof namespace === "string" ? namespace.trim().toLowerCase() : "";
|
|
1500
|
+
if (!normalizedNamespace) return null;
|
|
1501
|
+
const normalizedName = variableName.trim().toLowerCase();
|
|
1502
|
+
if (!normalizedName) return null;
|
|
1503
|
+
const unprefixedName = normalizedName.startsWith(
|
|
1504
|
+
`${normalizedNamespace}_`
|
|
1505
|
+
) ? normalizedName.slice(normalizedNamespace.length + 1) : normalizedName;
|
|
1506
|
+
const prefixedName = normalizedName.startsWith(`${normalizedNamespace}_`) ? normalizedName : `${normalizedNamespace}_${normalizedName}`;
|
|
1507
|
+
const candidateKeys = [prefixedName, unprefixedName];
|
|
1508
|
+
for (const key of candidateKeys) {
|
|
1509
|
+
if (namespaceHas(key, normalizedNamespace))
|
|
1510
|
+
return t(key, void 0, { ns: normalizedNamespace });
|
|
1511
|
+
if (namespaceHas(`variables.${key}`, normalizedNamespace))
|
|
1512
|
+
return t(`variables.${key}`, void 0, { ns: normalizedNamespace });
|
|
1513
|
+
}
|
|
1514
|
+
return null;
|
|
1515
|
+
},
|
|
1516
|
+
[namespaceHas, t]
|
|
1517
|
+
);
|
|
1518
|
+
const knownOrigins = useMemo3(() => {
|
|
1519
|
+
return Array.from(
|
|
1520
|
+
new Set(
|
|
1521
|
+
Object.values(variableRecords).map(
|
|
1522
|
+
(variable) => typeof variable?.origin === "string" ? variable.origin.trim().toLowerCase() : ""
|
|
1523
|
+
).filter((origin) => origin.length > 0)
|
|
1524
|
+
)
|
|
1525
|
+
);
|
|
1526
|
+
}, [variableRecords]);
|
|
1527
|
+
const resolveAllowedVariableOrigin = useCallback2(
|
|
1528
|
+
(variableName) => {
|
|
1529
|
+
const originFromProp = typeof allowedVariableOrigin === "string" ? allowedVariableOrigin.trim().toLowerCase() : "";
|
|
1530
|
+
if (originFromProp) return originFromProp;
|
|
1531
|
+
const fromDefinition = allowedVariableDefinitionLookup.get(variableName)?.origin;
|
|
1532
|
+
if (fromDefinition) return fromDefinition;
|
|
1533
|
+
const normalizedName = variableName.trim().toLowerCase();
|
|
1534
|
+
if (!normalizedName) return void 0;
|
|
1535
|
+
const prefixCandidate = normalizedName.split("_")[0];
|
|
1536
|
+
if (prefixCandidate) {
|
|
1537
|
+
const hasScopedTranslation = namespaceHas(normalizedName, prefixCandidate) || namespaceHas(`variables.${normalizedName}`, prefixCandidate) || namespaceHas(
|
|
1538
|
+
normalizedName.slice(prefixCandidate.length + 1),
|
|
1539
|
+
prefixCandidate
|
|
1540
|
+
) || namespaceHas(
|
|
1541
|
+
`variables.${normalizedName.slice(prefixCandidate.length + 1)}`,
|
|
1542
|
+
prefixCandidate
|
|
1543
|
+
);
|
|
1544
|
+
if (hasScopedTranslation) return prefixCandidate;
|
|
1545
|
+
}
|
|
1546
|
+
const prefixedMatch = knownOrigins.find(
|
|
1547
|
+
(origin) => normalizedName.startsWith(`${origin}_`)
|
|
1548
|
+
);
|
|
1549
|
+
if (prefixedMatch) return prefixedMatch;
|
|
1550
|
+
const matchingOrigins = knownOrigins.filter(
|
|
1551
|
+
(origin) => namespaceHas(normalizedName, origin) || namespaceHas(`variables.${normalizedName}`, origin) || namespaceHas(`${origin}_${normalizedName}`, origin)
|
|
1552
|
+
);
|
|
1553
|
+
if (matchingOrigins.length === 1) return matchingOrigins[0];
|
|
1554
|
+
const inferredOrigins = Array.from(
|
|
1555
|
+
new Set(
|
|
1556
|
+
Object.values(variableRecords).filter((variable) => {
|
|
1557
|
+
const variableNameLower = typeof variable?.name === "string" ? variable.name.trim().toLowerCase() : "";
|
|
1558
|
+
const variableOrigin = typeof variable?.origin === "string" ? variable.origin.trim().toLowerCase() : "";
|
|
1559
|
+
if (!variableNameLower || !variableOrigin) return false;
|
|
1560
|
+
return variableNameLower === normalizedName || variableNameLower === `${variableOrigin}_${normalizedName}`;
|
|
1561
|
+
}).map((variable) => String(variable.origin).trim().toLowerCase()).filter((origin) => origin.length > 0)
|
|
1562
|
+
)
|
|
1563
|
+
);
|
|
1564
|
+
return inferredOrigins.length === 1 ? inferredOrigins[0] : void 0;
|
|
1565
|
+
},
|
|
1566
|
+
[
|
|
1567
|
+
allowedVariableDefinitionLookup,
|
|
1568
|
+
allowedVariableOrigin,
|
|
1569
|
+
knownOrigins,
|
|
1570
|
+
namespaceHas,
|
|
1571
|
+
variableRecords
|
|
1572
|
+
]
|
|
1573
|
+
);
|
|
1574
|
+
const resolveVariableDescription = useCallback2(
|
|
1575
|
+
(variableName, fallbackDescription, origin) => {
|
|
1576
|
+
const fromOrigin = resolveTranslationFromNamespace(variableName, origin);
|
|
1577
|
+
if (fromOrigin && fromOrigin.trim().length > 0) return fromOrigin;
|
|
1578
|
+
const defaultTranslationKey = `variables.${variableName}`;
|
|
1579
|
+
const defaultTranslated = t(defaultTranslationKey);
|
|
1580
|
+
if (typeof defaultTranslated === "string" && defaultTranslated !== defaultTranslationKey)
|
|
1581
|
+
return defaultTranslated;
|
|
1582
|
+
if (fallbackDescription && fallbackDescription.trim().length > 0)
|
|
1583
|
+
return fallbackDescription;
|
|
1584
|
+
return humanizeVariableName(variableName);
|
|
1585
|
+
},
|
|
1586
|
+
[resolveTranslationFromNamespace, t]
|
|
1587
|
+
);
|
|
1588
|
+
const getSystemVariableDescription = useCallback2(
|
|
1589
|
+
(variable) => {
|
|
1590
|
+
if (variable?.system && !variable?.pluginId) {
|
|
1591
|
+
return t(`variables.${variable.description}`, void 0, {
|
|
1592
|
+
example: variable.example,
|
|
1593
|
+
interpolation: { escapeValue: false, prefix: "{{{", suffix: "}}}" }
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
return resolveVariableDescription(
|
|
1597
|
+
variable?.name ?? "",
|
|
1598
|
+
variable?.description,
|
|
1599
|
+
variable?.origin
|
|
1600
|
+
);
|
|
1601
|
+
},
|
|
1602
|
+
[resolveVariableDescription, t]
|
|
1603
|
+
);
|
|
1604
|
+
const getAllowedVariableRecord = useCallback2(
|
|
1605
|
+
(variableName) => {
|
|
1606
|
+
const direct = variableRecords[variableName];
|
|
1607
|
+
if (direct) return direct;
|
|
1608
|
+
const normalizedOrigin = resolveAllowedVariableOrigin(variableName);
|
|
1609
|
+
if (!normalizedOrigin) return void 0;
|
|
1610
|
+
const prefixedName = variableName.startsWith(`${normalizedOrigin}_`) ? variableName : `${normalizedOrigin}_${variableName}`;
|
|
1611
|
+
return variableRecords[prefixedName];
|
|
1612
|
+
},
|
|
1613
|
+
[resolveAllowedVariableOrigin, variableRecords]
|
|
1614
|
+
);
|
|
1615
|
+
const getAllowedVariableDescription = useCallback2(
|
|
1616
|
+
(variableName) => {
|
|
1617
|
+
const variable = variableRecords[variableName];
|
|
1618
|
+
if (variable) return getSystemVariableDescription(variable);
|
|
1619
|
+
const fromDefinition = allowedVariableDefinitionLookup.get(variableName);
|
|
1620
|
+
const origin = resolveAllowedVariableOrigin(variableName);
|
|
1621
|
+
return resolveVariableDescription(
|
|
1622
|
+
variableName,
|
|
1623
|
+
fromDefinition?.description,
|
|
1624
|
+
origin
|
|
1625
|
+
);
|
|
1626
|
+
},
|
|
1627
|
+
[
|
|
1628
|
+
allowedVariableDefinitionLookup,
|
|
1629
|
+
getSystemVariableDescription,
|
|
1630
|
+
resolveAllowedVariableOrigin,
|
|
1631
|
+
resolveVariableDescription,
|
|
1632
|
+
variableRecords
|
|
1633
|
+
]
|
|
1634
|
+
);
|
|
1635
|
+
const getAllowedVariableValue = useCallback2(
|
|
1636
|
+
(variableName) => {
|
|
1637
|
+
if (!variableName) return void 0;
|
|
1638
|
+
const direct = variableRecords[variableName]?.value;
|
|
1639
|
+
if (direct !== void 0) return direct;
|
|
1640
|
+
const normalizedOrigin = resolveAllowedVariableOrigin(variableName);
|
|
1641
|
+
if (!normalizedOrigin) return void 0;
|
|
1642
|
+
const prefixedName = variableName.startsWith(`${normalizedOrigin}_`) ? variableName : `${normalizedOrigin}_${variableName}`;
|
|
1643
|
+
return variableRecords[prefixedName]?.value;
|
|
1644
|
+
},
|
|
1645
|
+
[resolveAllowedVariableOrigin, variableRecords]
|
|
1646
|
+
);
|
|
1647
|
+
const getAllowedVariableVisualType = useCallback2(
|
|
1648
|
+
(variableName) => {
|
|
1649
|
+
const record = getAllowedVariableRecord(variableName);
|
|
1650
|
+
if (record) return visualTypeFromRecord(record);
|
|
1651
|
+
if (functionVariableSet.has(variableName)) return "func";
|
|
1652
|
+
return "custom";
|
|
1653
|
+
},
|
|
1654
|
+
[functionVariableSet, getAllowedVariableRecord]
|
|
1655
|
+
);
|
|
1656
|
+
const getAllowedVariableTree = useCallback2(
|
|
1657
|
+
(definition) => {
|
|
1658
|
+
const record = getAllowedVariableRecord(definition.name);
|
|
1659
|
+
const liveTree = record ? systemVariableValueTrees.get(record.name) : void 0;
|
|
1660
|
+
if (liveTree && liveTree.length > 0) return liveTree;
|
|
1661
|
+
return allowedExampleTrees.get(definition.name);
|
|
1662
|
+
},
|
|
1663
|
+
[allowedExampleTrees, getAllowedVariableRecord, systemVariableValueTrees]
|
|
1664
|
+
);
|
|
1665
|
+
useEffect4(() => {
|
|
1666
|
+
const query = (searchQuery ?? "").toLowerCase().replace("{{", "").replace("}}", "").trim();
|
|
1667
|
+
const nextAutoExpand = /* @__PURE__ */ new Set();
|
|
1668
|
+
const collectNestedAutoExpand = (rootToken, tree) => {
|
|
1669
|
+
if (!query || !tree || tree.length === 0) return false;
|
|
1670
|
+
let hit = false;
|
|
1671
|
+
const walk = (nodes) => {
|
|
1672
|
+
nodes.forEach((node) => {
|
|
1673
|
+
if (node.relativePath.toLowerCase().includes(query) || node.key.toLowerCase().includes(query)) {
|
|
1674
|
+
hit = true;
|
|
1675
|
+
const segments = node.relativePath.split(".");
|
|
1676
|
+
for (let i = 0; i < segments.length; i++) {
|
|
1677
|
+
const rel = segments.slice(0, i).join(".");
|
|
1678
|
+
nextAutoExpand.add(rel ? `${rootToken}.${rel}` : rootToken);
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
if (node.children.length) walk(node.children);
|
|
1682
|
+
});
|
|
1683
|
+
};
|
|
1684
|
+
walk(tree);
|
|
1685
|
+
return hit;
|
|
1686
|
+
};
|
|
1687
|
+
if (allowedVariableNames.length > 0) {
|
|
1688
|
+
if (!query) {
|
|
1689
|
+
setFilteredAllowedVariables(
|
|
1690
|
+
orderItemsByVariableType(
|
|
1691
|
+
allowedVariableDefinitions,
|
|
1692
|
+
(definition) => getAllowedVariableVisualType(definition.name)
|
|
1693
|
+
)
|
|
1694
|
+
);
|
|
1695
|
+
} else {
|
|
1696
|
+
const nameMatches = [];
|
|
1697
|
+
const descMatches = [];
|
|
1698
|
+
const nestedMatches = [];
|
|
1699
|
+
allowedVariableDefinitions.forEach((definition) => {
|
|
1700
|
+
const nameLower = definition.name?.toLowerCase();
|
|
1701
|
+
const descLower = getAllowedVariableDescription(
|
|
1702
|
+
definition.name
|
|
1703
|
+
)?.toLowerCase();
|
|
1704
|
+
if (nameLower?.includes(query)) {
|
|
1705
|
+
nameMatches.push(definition);
|
|
1706
|
+
return;
|
|
1707
|
+
}
|
|
1708
|
+
if (descLower?.includes(query)) {
|
|
1709
|
+
descMatches.push(definition);
|
|
1710
|
+
return;
|
|
1711
|
+
}
|
|
1712
|
+
const tree = getAllowedVariableTree(definition);
|
|
1713
|
+
if (tree && collectNestedAutoExpand(definition.name, tree)) {
|
|
1714
|
+
nestedMatches.push(definition);
|
|
1715
|
+
}
|
|
1716
|
+
});
|
|
1717
|
+
const sortByDef = (items) => sortItemsByVariableTypeThenName(
|
|
1718
|
+
items,
|
|
1719
|
+
(definition) => getAllowedVariableVisualType(definition.name),
|
|
1720
|
+
(definition) => definition.name
|
|
1721
|
+
);
|
|
1722
|
+
setFilteredAllowedVariables([
|
|
1723
|
+
...sortByDef(nameMatches),
|
|
1724
|
+
...sortByDef(descMatches),
|
|
1725
|
+
...sortByDef(nestedMatches)
|
|
1726
|
+
]);
|
|
1727
|
+
}
|
|
1728
|
+
} else {
|
|
1729
|
+
setFilteredAllowedVariables([]);
|
|
1730
|
+
}
|
|
1731
|
+
const allowedSet = new Set(allowedVariableNames);
|
|
1732
|
+
const shouldKeep = (variable) => {
|
|
1733
|
+
if (allowedSet.has(variable.name)) return false;
|
|
1734
|
+
if (!variable.origin) return true;
|
|
1735
|
+
if (!isOriginConnected) return true;
|
|
1736
|
+
return isOriginConnected(variable.origin);
|
|
1737
|
+
};
|
|
1738
|
+
const allRecords = Object.values(variableRecords);
|
|
1739
|
+
if (!query) {
|
|
1740
|
+
const visible = allRecords.filter(shouldKeep);
|
|
1741
|
+
setFilteredSystemVariables(
|
|
1742
|
+
orderItemsByVariableType(
|
|
1743
|
+
visible,
|
|
1744
|
+
(variable) => visualTypeFromRecord(variable)
|
|
1745
|
+
)
|
|
1746
|
+
);
|
|
1747
|
+
} else {
|
|
1748
|
+
const nameMatches = [];
|
|
1749
|
+
const descMatches = [];
|
|
1750
|
+
const nestedMatches = [];
|
|
1751
|
+
allRecords.forEach((variable) => {
|
|
1752
|
+
if (!shouldKeep(variable)) return;
|
|
1753
|
+
const description = getSystemVariableDescription(variable);
|
|
1754
|
+
const nameLower = variable.name?.toLowerCase();
|
|
1755
|
+
const descLower = description?.toLowerCase();
|
|
1756
|
+
if (nameLower?.includes(query)) {
|
|
1757
|
+
nameMatches.push(variable);
|
|
1758
|
+
return;
|
|
1759
|
+
}
|
|
1760
|
+
if (descLower?.includes(query)) {
|
|
1761
|
+
descMatches.push(variable);
|
|
1762
|
+
return;
|
|
1763
|
+
}
|
|
1764
|
+
const tree = systemVariableValueTrees.get(variable.name);
|
|
1765
|
+
if (tree && collectNestedAutoExpand(variable.example ?? variable.name, tree)) {
|
|
1766
|
+
nestedMatches.push(variable);
|
|
1767
|
+
}
|
|
1768
|
+
});
|
|
1769
|
+
const sortSys = (items) => sortItemsByVariableTypeThenName(
|
|
1770
|
+
items,
|
|
1771
|
+
(variable) => visualTypeFromRecord(variable),
|
|
1772
|
+
(variable) => variable?.name ?? ""
|
|
1773
|
+
);
|
|
1774
|
+
setFilteredSystemVariables([
|
|
1775
|
+
...sortSys(nameMatches),
|
|
1776
|
+
...sortSys(descMatches),
|
|
1777
|
+
...sortSys(nestedMatches)
|
|
1778
|
+
]);
|
|
1779
|
+
}
|
|
1780
|
+
setAutoExpandPaths(nextAutoExpand);
|
|
1781
|
+
}, [
|
|
1782
|
+
searchQuery,
|
|
1783
|
+
allowedVariableDefinitions,
|
|
1784
|
+
allowedVariableNames,
|
|
1785
|
+
getAllowedVariableDescription,
|
|
1786
|
+
getAllowedVariableTree,
|
|
1787
|
+
getAllowedVariableVisualType,
|
|
1788
|
+
getSystemVariableDescription,
|
|
1789
|
+
isOriginConnected,
|
|
1790
|
+
systemVariableValueTrees,
|
|
1791
|
+
variableRecords
|
|
1792
|
+
]);
|
|
1793
|
+
const clickedVariableIcon = () => {
|
|
1794
|
+
if (!hideVariables) setShowVariables((current) => !current);
|
|
1795
|
+
};
|
|
1796
|
+
const appendValue = (newValue) => {
|
|
1797
|
+
const currentValue = Array.isArray(value) ? value.join("") : value;
|
|
1798
|
+
onChange?.(currentValue ? `${currentValue}${newValue}` : newValue);
|
|
1799
|
+
};
|
|
1800
|
+
const insertVariable = (variable) => {
|
|
1801
|
+
appendValue(`{{${variable}}}`);
|
|
1802
|
+
setShowVariables(false);
|
|
1803
|
+
};
|
|
1804
|
+
const handleFilterOptions = (options, params) => {
|
|
1805
|
+
const filtered = filter(options, params);
|
|
1806
|
+
afterFilter?.(filtered);
|
|
1807
|
+
return filtered;
|
|
1808
|
+
};
|
|
1809
|
+
const renderVariableToken = (variableName, variableType, isSuggested = false) => /* @__PURE__ */ jsxs5(
|
|
1810
|
+
"div",
|
|
1811
|
+
{
|
|
1812
|
+
className: `ls-variable-token ${getVariableColorClass(variableType, isSuggested)}`,
|
|
1813
|
+
children: [
|
|
1814
|
+
/* @__PURE__ */ jsx12("span", { className: "ls-variable-token__name", children: `{{${variableName}}}` }),
|
|
1815
|
+
variableType === "func" && /* @__PURE__ */ jsx12(
|
|
1816
|
+
"span",
|
|
1817
|
+
{
|
|
1818
|
+
className: "ls-variable-token__badge",
|
|
1819
|
+
title: t("variables.functionvariables", "Function variables"),
|
|
1820
|
+
children: "fx"
|
|
1821
|
+
}
|
|
1822
|
+
)
|
|
1823
|
+
]
|
|
1824
|
+
}
|
|
1825
|
+
);
|
|
1826
|
+
const renderExpandToggle = (path, expanded) => /* @__PURE__ */ jsx12(
|
|
1827
|
+
"button",
|
|
1828
|
+
{
|
|
1829
|
+
type: "button",
|
|
1830
|
+
onClick: (e) => {
|
|
1831
|
+
e.stopPropagation();
|
|
1832
|
+
toggleExpand(path);
|
|
1833
|
+
},
|
|
1834
|
+
className: `ls-variable-picker__expand-toggle${expanded ? " ls-variable-picker__expand-toggle--expanded" : ""}`,
|
|
1835
|
+
"aria-label": expanded ? "Collapse" : "Expand",
|
|
1836
|
+
"aria-expanded": expanded,
|
|
1837
|
+
children: /* @__PURE__ */ jsx12(KeyboardArrowDown2, { style: { width: 16, height: 16 } })
|
|
1838
|
+
}
|
|
1839
|
+
);
|
|
1840
|
+
const renderExpandSpacer = () => /* @__PURE__ */ jsx12("span", { className: "ls-variable-picker__expand-spacer", "aria-hidden": true });
|
|
1841
|
+
const getVariableValuePreview = (variableValue) => {
|
|
1842
|
+
const { displayValue, fullValue } = getVariableValueDisplay(variableValue);
|
|
1843
|
+
return { displayValue, fullValue };
|
|
1844
|
+
};
|
|
1845
|
+
const renderVariableValueInput = (displayValue, fullValue) => /* @__PURE__ */ jsx12(
|
|
1846
|
+
"input",
|
|
1847
|
+
{
|
|
1848
|
+
className: "ls-variable-picker__value-input",
|
|
1849
|
+
title: fullValue,
|
|
1850
|
+
readOnly: true,
|
|
1851
|
+
value: fullValue || displayValue,
|
|
1852
|
+
onClick: (e) => e.stopPropagation(),
|
|
1853
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
1854
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
1855
|
+
"aria-label": t("common.value", "Value")
|
|
1856
|
+
}
|
|
1857
|
+
);
|
|
1858
|
+
const renderValueChildRows = (rootToken, nodes) => nodes.map((node) => {
|
|
1859
|
+
const fullToken = `${rootToken}.${node.relativePath}`;
|
|
1860
|
+
const expanded = node.isExpandable && isPathExpanded(fullToken);
|
|
1861
|
+
const { displayValue, fullValue } = getVariableValuePreview(node.value);
|
|
1862
|
+
return /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
1863
|
+
/* @__PURE__ */ jsxs5(
|
|
1864
|
+
"div",
|
|
1865
|
+
{
|
|
1866
|
+
className: "ls-variable-picker__row ls-variable-picker__row--child",
|
|
1867
|
+
onClick: () => {
|
|
1868
|
+
if (node.isExpandable && !expanded) toggleExpand(fullToken);
|
|
1869
|
+
else insertVariable(fullToken);
|
|
1870
|
+
},
|
|
1871
|
+
children: [
|
|
1872
|
+
/* @__PURE__ */ jsxs5(
|
|
1873
|
+
"div",
|
|
1874
|
+
{
|
|
1875
|
+
className: "ls-variable-picker__token-cell",
|
|
1876
|
+
style: { paddingLeft: `${node.depth * 1.25}rem` },
|
|
1877
|
+
children: [
|
|
1878
|
+
node.isExpandable ? renderExpandToggle(fullToken, expanded) : renderExpandSpacer(),
|
|
1879
|
+
/* @__PURE__ */ jsx12(
|
|
1880
|
+
"div",
|
|
1881
|
+
{
|
|
1882
|
+
className: `ls-variable-token ${CHILD_VARIABLE_COLOR_CLASS}`,
|
|
1883
|
+
children: /* @__PURE__ */ jsx12("span", { className: "ls-variable-token__name", children: `{{${fullToken}}}` })
|
|
1884
|
+
}
|
|
1885
|
+
)
|
|
1886
|
+
]
|
|
1887
|
+
}
|
|
1888
|
+
),
|
|
1889
|
+
/* @__PURE__ */ jsx12("div", { className: "ls-variable-picker__description", children: node.displayKey }),
|
|
1890
|
+
/* @__PURE__ */ jsx12("div", { className: "ls-variable-picker__value", title: fullValue, children: renderVariableValueInput(displayValue, fullValue) })
|
|
1891
|
+
]
|
|
1892
|
+
}
|
|
1893
|
+
),
|
|
1894
|
+
expanded && renderValueChildRows(rootToken, node.children)
|
|
1895
|
+
] }, fullToken);
|
|
1896
|
+
});
|
|
1897
|
+
const toOptionLabelString = (input) => {
|
|
1898
|
+
if (typeof input === "string") return input;
|
|
1899
|
+
if (typeof input === "number" || typeof input === "boolean" || typeof input === "bigint")
|
|
1900
|
+
return String(input);
|
|
1901
|
+
if (input === null || input === void 0) return "";
|
|
1902
|
+
if (typeof input === "object") {
|
|
1903
|
+
const labelCandidate = input.label;
|
|
1904
|
+
if (typeof labelCandidate === "string") return labelCandidate;
|
|
1905
|
+
if (typeof labelCandidate === "number" || typeof labelCandidate === "boolean" || typeof labelCandidate === "bigint")
|
|
1906
|
+
return String(labelCandidate);
|
|
1907
|
+
const valueCandidate = input.value;
|
|
1908
|
+
if (typeof valueCandidate === "string") return valueCandidate;
|
|
1909
|
+
if (typeof valueCandidate === "number" || typeof valueCandidate === "boolean" || typeof valueCandidate === "bigint")
|
|
1910
|
+
return String(valueCandidate);
|
|
1911
|
+
try {
|
|
1912
|
+
return JSON.stringify(input);
|
|
1913
|
+
} catch {
|
|
1914
|
+
return "[object Object]";
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
return String(input);
|
|
1918
|
+
};
|
|
1919
|
+
const resolveOptionLabel = (option) => {
|
|
1920
|
+
if (typeof getOptionLabel === "function") {
|
|
1921
|
+
try {
|
|
1922
|
+
const customLabel = getOptionLabel(option);
|
|
1923
|
+
return toOptionLabelString(
|
|
1924
|
+
customLabel === void 0 ? option : customLabel
|
|
1925
|
+
);
|
|
1926
|
+
} catch {
|
|
1927
|
+
return toOptionLabelString(option);
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
return toOptionLabelString(option);
|
|
1931
|
+
};
|
|
1932
|
+
const defaultRenderOption = (optionProps, option) => {
|
|
1933
|
+
const opt = option;
|
|
1934
|
+
const thumb = opt?.imageUrl ?? opt?.thumb ?? opt?.iconUrl ?? opt?.previewImageUrl;
|
|
1935
|
+
const helperText = typeof opt?.helperText === "string" ? opt.helperText : "";
|
|
1936
|
+
const isSelected = opt?.value === value;
|
|
1937
|
+
return /* @__PURE__ */ createElement(
|
|
1938
|
+
"li",
|
|
1939
|
+
{
|
|
1940
|
+
...optionProps,
|
|
1941
|
+
key: String(opt?.label ?? opt?.value ?? ""),
|
|
1942
|
+
className: [
|
|
1943
|
+
optionProps.className,
|
|
1944
|
+
"ls-variable-option",
|
|
1945
|
+
isSelected ? "ls-variable-option--selected" : ""
|
|
1946
|
+
].filter(Boolean).join(" ")
|
|
1947
|
+
},
|
|
1948
|
+
thumb ? /* @__PURE__ */ jsx12(
|
|
1949
|
+
"img",
|
|
1950
|
+
{
|
|
1951
|
+
src: thumb,
|
|
1952
|
+
className: "ls-variable-option__thumb",
|
|
1953
|
+
alt: ""
|
|
1954
|
+
}
|
|
1955
|
+
) : null,
|
|
1956
|
+
/* @__PURE__ */ jsxs5("div", { className: "ls-variable-option__body", children: [
|
|
1957
|
+
/* @__PURE__ */ jsx12("div", { className: "ls-variable-option__label", children: resolveOptionLabel(opt) }),
|
|
1958
|
+
helperText ? /* @__PURE__ */ jsx12("div", { className: "ls-variable-option__helper", children: helperText }) : null
|
|
1959
|
+
] })
|
|
1960
|
+
);
|
|
1961
|
+
};
|
|
1962
|
+
const showSuggestedSection = allowedVariableNames.length > 0 && filteredAllowedVariables.length > 0;
|
|
1963
|
+
const pickerBody = /* @__PURE__ */ jsxs5("div", { className: "ls-variable-picker ls-variable-picker--three-col", children: [
|
|
1964
|
+
/* @__PURE__ */ jsxs5("div", { className: "ls-variable-picker__intro", children: [
|
|
1965
|
+
/* @__PURE__ */ jsx12("div", { className: "ls-variable-picker__intro-text", children: t(
|
|
1966
|
+
"overlay-variables.variables-description",
|
|
1967
|
+
"Use variables that will automatically be replaced before sending out the text"
|
|
1968
|
+
) }),
|
|
1969
|
+
/* @__PURE__ */ jsx12(
|
|
1970
|
+
LSInput,
|
|
1971
|
+
{
|
|
1972
|
+
autoFocus: true,
|
|
1973
|
+
startAdornment: /* @__PURE__ */ jsx12(Search, { style: { color: "#fff", width: 20, height: 20 } }),
|
|
1974
|
+
placeholder: t("common.search", "Search"),
|
|
1975
|
+
value: searchQuery,
|
|
1976
|
+
onChange: (e) => setSearchQuery(e.target.value),
|
|
1977
|
+
type: "text"
|
|
1978
|
+
}
|
|
1979
|
+
)
|
|
1980
|
+
] }),
|
|
1981
|
+
/* @__PURE__ */ jsxs5("div", { className: "ls-variable-picker__header", children: [
|
|
1982
|
+
/* @__PURE__ */ jsx12("div", { style: { paddingLeft: "2.2rem" }, children: t("commands.variable", "Variable") }),
|
|
1983
|
+
/* @__PURE__ */ jsx12("div", { children: t("commands.description", "Description") }),
|
|
1984
|
+
/* @__PURE__ */ jsx12("div", { children: t("common.value", "Value") })
|
|
1985
|
+
] }),
|
|
1986
|
+
/* @__PURE__ */ jsxs5("div", { className: "ls-variable-picker__list", children: [
|
|
1987
|
+
showSuggestedSection && /* @__PURE__ */ jsxs5("fieldset", { className: "ls-variable-picker__field", children: [
|
|
1988
|
+
/* @__PURE__ */ jsx12("legend", { className: "ls-variable-picker__legend", children: t("commands.suggested-variables", "Suggested Variables") }),
|
|
1989
|
+
filteredAllowedVariables.map((definition, idx) => {
|
|
1990
|
+
const variableType = getAllowedVariableVisualType(
|
|
1991
|
+
definition.name
|
|
1992
|
+
);
|
|
1993
|
+
const tree = getAllowedVariableTree(definition);
|
|
1994
|
+
const { displayValue, fullValue } = getVariableValuePreview(
|
|
1995
|
+
getAllowedVariableValue(definition.name) ?? definition.example
|
|
1996
|
+
);
|
|
1997
|
+
const expandable = !!tree && tree.length > 0;
|
|
1998
|
+
const expanded = expandable && isPathExpanded(definition.name);
|
|
1999
|
+
const isLast = idx === filteredAllowedVariables.length - 1;
|
|
2000
|
+
const rowCls = `ls-variable-picker__row${isLast && !expanded ? " ls-variable-picker__row--no-border" : ""}`;
|
|
2001
|
+
return /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
2002
|
+
/* @__PURE__ */ jsxs5(
|
|
2003
|
+
"div",
|
|
2004
|
+
{
|
|
2005
|
+
className: rowCls,
|
|
2006
|
+
onClick: () => {
|
|
2007
|
+
if (expandable && !expanded)
|
|
2008
|
+
toggleExpand(definition.name);
|
|
2009
|
+
else insertVariable(definition.name);
|
|
2010
|
+
},
|
|
2011
|
+
children: [
|
|
2012
|
+
/* @__PURE__ */ jsxs5("div", { className: "ls-variable-picker__token-cell", children: [
|
|
2013
|
+
expandable ? renderExpandToggle(definition.name, expanded) : renderExpandSpacer(),
|
|
2014
|
+
renderVariableToken(definition.name, variableType, true)
|
|
2015
|
+
] }),
|
|
2016
|
+
/* @__PURE__ */ jsx12("div", { className: "ls-variable-picker__description", children: getAllowedVariableDescription(definition.name) }),
|
|
2017
|
+
/* @__PURE__ */ jsx12(
|
|
2018
|
+
"div",
|
|
2019
|
+
{
|
|
2020
|
+
className: "ls-variable-picker__value",
|
|
2021
|
+
title: fullValue,
|
|
2022
|
+
children: renderVariableValueInput(displayValue, fullValue)
|
|
2023
|
+
}
|
|
2024
|
+
)
|
|
2025
|
+
]
|
|
2026
|
+
}
|
|
2027
|
+
),
|
|
2028
|
+
expanded && tree && renderValueChildRows(definition.name, tree)
|
|
2029
|
+
] }, definition.name);
|
|
2030
|
+
})
|
|
2031
|
+
] }),
|
|
2032
|
+
filteredSystemVariables?.map((variable) => {
|
|
2033
|
+
const variableType = visualTypeFromRecord(variable);
|
|
2034
|
+
const { displayValue, fullValue } = getVariableValuePreview(
|
|
2035
|
+
variable.value
|
|
2036
|
+
);
|
|
2037
|
+
const rootToken = variable.example ?? variable.name;
|
|
2038
|
+
const tree = systemVariableValueTrees.get(variable.name);
|
|
2039
|
+
const expandable = !!tree && tree.length > 0;
|
|
2040
|
+
const expanded = expandable && isPathExpanded(rootToken);
|
|
2041
|
+
return /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
2042
|
+
/* @__PURE__ */ jsxs5(
|
|
2043
|
+
"div",
|
|
2044
|
+
{
|
|
2045
|
+
className: "ls-variable-picker__row",
|
|
2046
|
+
onClick: () => {
|
|
2047
|
+
if (expandable && !expanded) toggleExpand(rootToken);
|
|
2048
|
+
else insertVariable(rootToken);
|
|
2049
|
+
},
|
|
2050
|
+
children: [
|
|
2051
|
+
/* @__PURE__ */ jsxs5("div", { className: "ls-variable-picker__token-cell", children: [
|
|
2052
|
+
expandable ? renderExpandToggle(rootToken, expanded) : renderExpandSpacer(),
|
|
2053
|
+
renderVariableToken(variable.name, variableType)
|
|
2054
|
+
] }),
|
|
2055
|
+
/* @__PURE__ */ jsx12("div", { className: "ls-variable-picker__description", children: getSystemVariableDescription(variable) }),
|
|
2056
|
+
/* @__PURE__ */ jsx12("div", { className: "ls-variable-picker__value", title: fullValue, children: renderVariableValueInput(displayValue, fullValue) })
|
|
2057
|
+
]
|
|
2058
|
+
}
|
|
2059
|
+
),
|
|
2060
|
+
expanded && tree && renderValueChildRows(rootToken, tree)
|
|
2061
|
+
] }, variable.name);
|
|
2062
|
+
})
|
|
2063
|
+
] })
|
|
2064
|
+
] });
|
|
2065
|
+
const textField = (params = {}) => /* @__PURE__ */ jsx12(
|
|
2066
|
+
VariableInputTextField,
|
|
2067
|
+
{
|
|
2068
|
+
t,
|
|
2069
|
+
params,
|
|
2070
|
+
id: variableId.current,
|
|
2071
|
+
containerRef,
|
|
2072
|
+
name,
|
|
2073
|
+
label,
|
|
2074
|
+
type,
|
|
2075
|
+
variant,
|
|
2076
|
+
disabled,
|
|
2077
|
+
autoFocus,
|
|
2078
|
+
multiline,
|
|
2079
|
+
placeholder,
|
|
2080
|
+
rows,
|
|
2081
|
+
maxRows,
|
|
2082
|
+
value,
|
|
2083
|
+
onChange: $disableInputChange ? void 0 : onChange,
|
|
2084
|
+
clickedVariableIcon,
|
|
2085
|
+
inputProps,
|
|
2086
|
+
allowedVariables,
|
|
2087
|
+
showVariableIcon: !hideVariables && (!isAutoComplete || allowedVariableDefinitions.length > 0),
|
|
2088
|
+
ref
|
|
2089
|
+
}
|
|
2090
|
+
);
|
|
2091
|
+
return /* @__PURE__ */ jsxs5(Fragment3, { children: [
|
|
2092
|
+
/* @__PURE__ */ jsx12(
|
|
2093
|
+
Popover,
|
|
2094
|
+
{
|
|
2095
|
+
anchorEl: containerRef.current,
|
|
2096
|
+
anchorOrigin: { vertical: "bottom", horizontal: "left" },
|
|
2097
|
+
transformOrigin: { vertical: "top", horizontal: "left" },
|
|
2098
|
+
open: !hideVariables && showVariables,
|
|
2099
|
+
onClose: clickedVariableIcon,
|
|
2100
|
+
slotProps: {
|
|
2101
|
+
paper: {
|
|
2102
|
+
sx: {
|
|
2103
|
+
color: "var(--neutralLight2, #cac9d5)",
|
|
2104
|
+
backgroundColor: "var(--neutralDark1, #171628)",
|
|
2105
|
+
// Paper has no padding of its own — the picker body's `p-2` is the
|
|
2106
|
+
// single source of internal spacing. Adding paper padding on top of
|
|
2107
|
+
// that compounds the inset and forces premature horizontal scroll.
|
|
2108
|
+
padding: 0,
|
|
2109
|
+
border: "1px solid var(--neutralDark4, #393853)",
|
|
2110
|
+
borderRadius: "var(--radius, 1rem)",
|
|
2111
|
+
overflow: "hidden"
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
},
|
|
2115
|
+
children: pickerBody
|
|
2116
|
+
}
|
|
2117
|
+
),
|
|
2118
|
+
isAutoComplete ? /* @__PURE__ */ jsx12(
|
|
2119
|
+
Autocomplete2,
|
|
2120
|
+
{
|
|
2121
|
+
disableClearable: true,
|
|
2122
|
+
openOnFocus: true,
|
|
2123
|
+
includeInputInList: true,
|
|
2124
|
+
multiple: $multiple,
|
|
2125
|
+
freeSolo: $freeSolo,
|
|
2126
|
+
disableCloseOnSelect: $disableCloseOnSelect,
|
|
2127
|
+
groupBy: autoCompleteGroupBy,
|
|
2128
|
+
options: autoCompleteOptions ?? [],
|
|
2129
|
+
isOptionEqualToValue,
|
|
2130
|
+
value,
|
|
2131
|
+
disabled,
|
|
2132
|
+
loading,
|
|
2133
|
+
getOptionLabel: resolveOptionLabel,
|
|
2134
|
+
onChange: (_e, nextValue) => {
|
|
2135
|
+
if ($getFullValueObject) {
|
|
2136
|
+
onChange?.(nextValue);
|
|
2137
|
+
return;
|
|
2138
|
+
}
|
|
2139
|
+
if ($multiple) {
|
|
2140
|
+
const list = Array.isArray(nextValue) ? nextValue : nextValue ? [nextValue] : [];
|
|
2141
|
+
const mapped = list.map((entry) => {
|
|
2142
|
+
if (entry && typeof entry === "object" && "value" in entry) {
|
|
2143
|
+
return entry.value;
|
|
2144
|
+
}
|
|
2145
|
+
return entry;
|
|
2146
|
+
});
|
|
2147
|
+
onChange?.(mapped);
|
|
2148
|
+
return;
|
|
2149
|
+
}
|
|
2150
|
+
if (nextValue && typeof nextValue === "object" && "value" in nextValue) {
|
|
2151
|
+
onChange?.(nextValue.value);
|
|
2152
|
+
return;
|
|
2153
|
+
}
|
|
2154
|
+
onChange?.(nextValue);
|
|
2155
|
+
},
|
|
2156
|
+
onInputChange: $disableInputChange ? void 0 : (_e, nextValue) => onChange?.(nextValue),
|
|
2157
|
+
filterOptions: handleFilterOptions,
|
|
2158
|
+
renderOption: $renderOption ?? renderOption ?? defaultRenderOption,
|
|
2159
|
+
slots: ListboxComponent ? { listbox: ListboxComponent } : void 0,
|
|
2160
|
+
slotProps: {
|
|
2161
|
+
popper: {
|
|
2162
|
+
className: "ls-variable-autocomplete-popper"
|
|
2163
|
+
},
|
|
2164
|
+
paper: {
|
|
2165
|
+
className: "ls-variable-autocomplete-paper",
|
|
2166
|
+
sx: {
|
|
2167
|
+
border: "1px solid var(--neutralDark4, var(--cardborder, #393853))",
|
|
2168
|
+
borderRadius: "var(--radius, 1rem)",
|
|
2169
|
+
backgroundColor: "var(--neutralDark2, var(--cardbackground, #211f45))",
|
|
2170
|
+
color: "var(--neutralLight1, var(--white, #fff))",
|
|
2171
|
+
boxShadow: "0 16px 32px rgba(0, 0, 0, 0.32)",
|
|
2172
|
+
overflow: "hidden"
|
|
2173
|
+
}
|
|
2174
|
+
},
|
|
2175
|
+
listbox: {
|
|
2176
|
+
className: "ls-variable-autocomplete-listbox",
|
|
2177
|
+
onScroll: onScrollListBox,
|
|
2178
|
+
sx: {
|
|
2179
|
+
padding: "0.25rem 0",
|
|
2180
|
+
backgroundColor: "var(--neutralDark2, var(--cardbackground, #211f45))",
|
|
2181
|
+
color: "var(--neutralLight1, var(--white, #fff))",
|
|
2182
|
+
"& .MuiAutocomplete-option": {
|
|
2183
|
+
display: "flex",
|
|
2184
|
+
minHeight: 44,
|
|
2185
|
+
alignItems: "center",
|
|
2186
|
+
padding: "0.625rem 1rem",
|
|
2187
|
+
color: "var(--neutralLight1, var(--white, #fff))",
|
|
2188
|
+
fontSize: "1rem",
|
|
2189
|
+
lineHeight: 1.35,
|
|
2190
|
+
transition: "background-color 120ms ease, color 120ms ease"
|
|
2191
|
+
},
|
|
2192
|
+
"& .MuiAutocomplete-option:hover, & .MuiAutocomplete-option.Mui-focused, & .MuiAutocomplete-option[data-focus='true'], & .MuiAutocomplete-option[aria-selected='true']": {
|
|
2193
|
+
backgroundColor: "var(--cardHover, var(--transwhite, rgba(255, 255, 255, 0.05)))",
|
|
2194
|
+
color: "var(--neutralLight1, var(--white, #fff))"
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
},
|
|
2198
|
+
popupIndicator: {
|
|
2199
|
+
className: "ls-variable-autocomplete-popup-indicator",
|
|
2200
|
+
sx: {
|
|
2201
|
+
color: "var(--neutralLight1, var(--white, #fff))",
|
|
2202
|
+
"& svg": {
|
|
2203
|
+
color: "var(--neutralLight1, var(--white, #fff))",
|
|
2204
|
+
fill: "currentColor"
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
},
|
|
2209
|
+
onHighlightChange,
|
|
2210
|
+
onOpen: onPopupOpen,
|
|
2211
|
+
onClose: onPopupClose,
|
|
2212
|
+
renderInput: (params) => textField(params)
|
|
2213
|
+
}
|
|
2214
|
+
) : textField()
|
|
2215
|
+
] });
|
|
2216
|
+
});
|
|
2217
|
+
LSVariableInputField.displayName = "LSVariableInputField";
|
|
2218
|
+
var VariableInputTextField = forwardRef5(
|
|
2219
|
+
({
|
|
2220
|
+
t,
|
|
2221
|
+
id,
|
|
2222
|
+
name,
|
|
2223
|
+
label,
|
|
2224
|
+
type,
|
|
2225
|
+
variant,
|
|
2226
|
+
disabled,
|
|
2227
|
+
autoFocus,
|
|
2228
|
+
multiline,
|
|
2229
|
+
placeholder,
|
|
2230
|
+
rows,
|
|
2231
|
+
maxRows,
|
|
2232
|
+
value,
|
|
2233
|
+
onChange,
|
|
2234
|
+
inputProps,
|
|
2235
|
+
clickedVariableIcon,
|
|
2236
|
+
params = {},
|
|
2237
|
+
containerRef,
|
|
2238
|
+
showVariableIcon
|
|
2239
|
+
}, ref) => {
|
|
2240
|
+
const inputPropsInputProps = inputProps?.InputProps ?? {};
|
|
2241
|
+
const paramsInputProps = params?.InputProps ?? {};
|
|
2242
|
+
const inputPropsSlotInputProps = inputProps?.slotProps?.input ?? {};
|
|
2243
|
+
const paramsSlotInputProps = params?.slotProps?.input ?? {};
|
|
2244
|
+
const explicitStartAdornment = inputProps?.startAdornment;
|
|
2245
|
+
const resolvedExplicitStartAdornment = explicitStartAdornment ? /* @__PURE__ */ jsx12(InputAdornment2, { position: "start", children: explicitStartAdornment }) : void 0;
|
|
2246
|
+
const startAdornment = paramsInputProps.startAdornment ?? paramsSlotInputProps.startAdornment ?? inputPropsInputProps.startAdornment ?? inputPropsSlotInputProps.startAdornment ?? resolvedExplicitStartAdornment;
|
|
2247
|
+
const endAdornment = paramsInputProps.endAdornment ?? paramsSlotInputProps.endAdornment ?? inputPropsInputProps.endAdornment ?? inputPropsSlotInputProps.endAdornment;
|
|
2248
|
+
return /* @__PURE__ */ jsx12(
|
|
2249
|
+
LSTextField,
|
|
2250
|
+
{
|
|
2251
|
+
id,
|
|
2252
|
+
name,
|
|
2253
|
+
label,
|
|
2254
|
+
type,
|
|
2255
|
+
color: "primary",
|
|
2256
|
+
variant,
|
|
2257
|
+
disabled,
|
|
2258
|
+
autoFocus,
|
|
2259
|
+
multiline,
|
|
2260
|
+
placeholder,
|
|
2261
|
+
rows,
|
|
2262
|
+
maxRows,
|
|
2263
|
+
value,
|
|
2264
|
+
fullWidth: true,
|
|
2265
|
+
className: `mui-ls-input ${params?.className ?? ""} ${inputProps?.className ?? ""}`.trim(),
|
|
2266
|
+
onChange: onChange ? (e) => onChange(e.target.value) : void 0,
|
|
2267
|
+
...inputProps,
|
|
2268
|
+
...params,
|
|
2269
|
+
InputProps: {
|
|
2270
|
+
...inputPropsSlotInputProps,
|
|
2271
|
+
...inputPropsInputProps,
|
|
2272
|
+
...paramsSlotInputProps,
|
|
2273
|
+
...paramsInputProps,
|
|
2274
|
+
startAdornment,
|
|
2275
|
+
endAdornment: /* @__PURE__ */ jsxs5(Fragment3, { children: [
|
|
2276
|
+
endAdornment ?? null,
|
|
2277
|
+
showVariableIcon ? /* @__PURE__ */ jsx12(
|
|
2278
|
+
Tooltip,
|
|
2279
|
+
{
|
|
2280
|
+
title: t("chatbot.allowed-variables", "Allowed Variables"),
|
|
2281
|
+
children: /* @__PURE__ */ jsx12(
|
|
2282
|
+
InputAdornment2,
|
|
2283
|
+
{
|
|
2284
|
+
position: "end",
|
|
2285
|
+
onClick: clickedVariableIcon,
|
|
2286
|
+
ref: containerRef,
|
|
2287
|
+
className: "ls-variable-input-adornment",
|
|
2288
|
+
children: "{}"
|
|
2289
|
+
}
|
|
2290
|
+
)
|
|
2291
|
+
}
|
|
2292
|
+
) : null
|
|
2293
|
+
] })
|
|
2294
|
+
},
|
|
2295
|
+
inputRef: ref
|
|
2296
|
+
}
|
|
2297
|
+
);
|
|
2298
|
+
}
|
|
2299
|
+
);
|
|
2300
|
+
VariableInputTextField.displayName = "VariableInputTextField";
|
|
2301
|
+
export {
|
|
2302
|
+
LSButton,
|
|
2303
|
+
LSCheckbox,
|
|
2304
|
+
LSCheckboxField,
|
|
2305
|
+
LSColorPicker,
|
|
2306
|
+
LSDatePicker,
|
|
2307
|
+
LSFontPicker,
|
|
2308
|
+
LSInput,
|
|
2309
|
+
LSMultiSelect,
|
|
2310
|
+
LSRadio,
|
|
2311
|
+
LSRadioGroup,
|
|
2312
|
+
LSSelect,
|
|
2313
|
+
LSSliderInput,
|
|
2314
|
+
LSTextField,
|
|
2315
|
+
LSVariableInputField,
|
|
2316
|
+
LSVariableInputProvider
|
|
2317
|
+
};
|