@babylonjs/shared-ui-components 5.31.1 → 5.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/components/Button.d.ts +2 -1
  2. package/components/Button.js +2 -2
  3. package/components/Button.js.map +1 -1
  4. package/components/Button.modules.scss +5 -0
  5. package/components/Icon.js +1 -1
  6. package/components/Icon.js.map +1 -1
  7. package/components/TextInputWithSubmit.d.ts +12 -0
  8. package/components/TextInputWithSubmit.js +31 -0
  9. package/components/TextInputWithSubmit.js.map +1 -0
  10. package/components/TextInputWithSubmit.modules.scss +22 -0
  11. package/components/lines/OptionsLineComponent.d.ts +20 -0
  12. package/components/lines/OptionsLineComponent.js +39 -0
  13. package/components/lines/OptionsLineComponent.js.map +1 -0
  14. package/components/lines/OptionsLineComponent.modules.scss +12 -0
  15. package/lines/lineContainerComponent.js +3 -0
  16. package/lines/lineContainerComponent.js.map +1 -1
  17. package/lines/optionsLineComponent.d.ts +0 -11
  18. package/lines/optionsLineComponent.js +8 -56
  19. package/lines/optionsLineComponent.js.map +1 -1
  20. package/nodeGraphSystem/graphFrame.js +1 -1
  21. package/nodeGraphSystem/graphFrame.js.map +1 -1
  22. package/package.json +3 -1
  23. package/stories/bars/CommandBarComponent.stories.d.ts +4 -6
  24. package/stories/bars/CommandBarComponent.stories.js.map +1 -1
  25. package/stories/bars/CommandButtonComponent.stories.d.ts +3 -1
  26. package/stories/bars/CommandButtonComponent.stories.js.map +1 -1
  27. package/stories/colorPicker/ColorPicker.stories.d.ts +2 -6
  28. package/stories/colorPicker/ColorPicker.stories.js.map +1 -1
  29. package/stories/layout/FlexibleGridLayout.stories.d.ts +4 -40
  30. package/stories/layout/FlexibleGridLayout.stories.js +6 -6
  31. package/stories/layout/FlexibleGridLayout.stories.js.map +1 -1
  32. package/stories/lines/ColorLineComponent.stories.d.ts +2 -16
  33. package/stories/lines/ColorLineComponent.stories.js.map +1 -1
  34. package/stories/lines/ColorPickerLineComponent.stories.d.ts +2 -9
  35. package/stories/lines/ColorPickerLineComponent.stories.js.map +1 -1
  36. package/stories/lines/FileButtonLineComponent.stories.d.ts +2 -1
  37. package/stories/lines/FileButtonLineComponent.stories.js.map +1 -1
  38. package/stories/lines/NumericInputComponent.stories.d.ts +2 -6
  39. package/stories/lines/NumericInputComponent.stories.js.map +1 -1
  40. package/stories/lines/OptionsLineComponent.stories.d.ts +10 -0
  41. package/stories/lines/OptionsLineComponent.stories.js +37 -0
  42. package/stories/lines/OptionsLineComponent.stories.js.map +1 -0
@@ -4,7 +4,8 @@ export declare type ButtonProps = {
4
4
  active?: boolean;
5
5
  onClick?: () => void;
6
6
  color: "light" | "dark";
7
- size: "default" | "small" | "wide";
7
+ size: "default" | "small" | "wide" | "smaller";
8
8
  title?: string;
9
+ backgroundColor?: string;
9
10
  };
10
11
  export declare const Button: React.FC<ButtonProps>;
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import styles from "./Button.modules.scss";
3
3
  import { ClassNames } from "./classNames.js";
4
- export const Button = ({ disabled, active, onClick, children, color, size, title }) => {
5
- return (_jsx("button", { className: ClassNames({ button: true, active, wide: size === "wide", small: size === "small", light: color === "light", dark: color === "dark" }, styles), disabled: disabled, onClick: onClick, title: title, children: children }));
4
+ export const Button = ({ disabled, active, onClick, children, color, size, title, backgroundColor }) => {
5
+ return (_jsx("button", { className: ClassNames({ button: true, active, wide: size === "wide", small: size === "small", smaller: size === "smaller", light: color === "light", dark: color === "dark" }, styles), disabled: disabled, onClick: onClick, title: title, style: { backgroundColor }, children: children }));
6
6
  };
7
7
  //# sourceMappingURL=Button.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAW1C,MAAM,CAAC,MAAM,MAAM,GAA0B,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;IACzG,OAAO,CACH,iBACI,SAAS,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,KAAK,MAAM,EAAE,KAAK,EAAE,IAAI,KAAK,OAAO,EAAE,KAAK,EAAE,KAAK,KAAK,OAAO,EAAE,IAAI,EAAE,KAAK,KAAK,MAAM,EAAE,EAAE,MAAM,CAAC,EACzJ,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,YAEX,QAAQ,GACJ,CACZ,CAAC;AACN,CAAC,CAAC","sourcesContent":["import styles from \"./Button.modules.scss\";\r\nimport { ClassNames } from \"./classNames\";\r\n\r\nexport type ButtonProps = {\r\n disabled?: boolean;\r\n active?: boolean;\r\n onClick?: () => void;\r\n color: \"light\" | \"dark\";\r\n size: \"default\" | \"small\" | \"wide\";\r\n title?: string;\r\n};\r\n\r\nexport const Button: React.FC<ButtonProps> = ({ disabled, active, onClick, children, color, size, title }) => {\r\n return (\r\n <button\r\n className={ClassNames({ button: true, active, wide: size === \"wide\", small: size === \"small\", light: color === \"light\", dark: color === \"dark\" }, styles)}\r\n disabled={disabled}\r\n onClick={onClick}\r\n title={title}\r\n >\r\n {children}\r\n </button>\r\n );\r\n};\r\n"]}
1
+ {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAY1C,MAAM,CAAC,MAAM,MAAM,GAA0B,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,eAAe,EAAE,EAAE,EAAE;IAC1H,OAAO,CACH,iBACI,SAAS,EAAE,UAAU,CACjB,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,KAAK,MAAM,EAAE,KAAK,EAAE,IAAI,KAAK,OAAO,EAAE,OAAO,EAAE,IAAI,KAAK,SAAS,EAAE,KAAK,EAAE,KAAK,KAAK,OAAO,EAAE,IAAI,EAAE,KAAK,KAAK,MAAM,EAAE,EACvJ,MAAM,CACT,EACD,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,EAAE,eAAe,EAAE,YAEzB,QAAQ,GACJ,CACZ,CAAC;AACN,CAAC,CAAC","sourcesContent":["import styles from \"./Button.modules.scss\";\r\nimport { ClassNames } from \"./classNames\";\r\n\r\nexport type ButtonProps = {\r\n disabled?: boolean;\r\n active?: boolean;\r\n onClick?: () => void;\r\n color: \"light\" | \"dark\";\r\n size: \"default\" | \"small\" | \"wide\" | \"smaller\";\r\n title?: string;\r\n backgroundColor?: string;\r\n};\r\n\r\nexport const Button: React.FC<ButtonProps> = ({ disabled, active, onClick, children, color, size, title, backgroundColor }) => {\r\n return (\r\n <button\r\n className={ClassNames(\r\n { button: true, active, wide: size === \"wide\", small: size === \"small\", smaller: size === \"smaller\", light: color === \"light\", dark: color === \"dark\" },\r\n styles\r\n )}\r\n disabled={disabled}\r\n onClick={onClick}\r\n title={title}\r\n style={{ backgroundColor }}\r\n >\r\n {children}\r\n </button>\r\n );\r\n};\r\n"]}
@@ -7,6 +7,7 @@
7
7
  display: inline-flex;
8
8
  align-items: center;
9
9
  justify-content: center;
10
+ padding: 0 0;
10
11
  &.wide {
11
12
  width: 120px;
12
13
  height: 45px;
@@ -16,6 +17,10 @@
16
17
  width: 30px;
17
18
  height: 30px;
18
19
  }
20
+ &.smaller {
21
+ width: 25px;
22
+ height: 25px;
23
+ }
19
24
  &.light {
20
25
  background-color: light-background;
21
26
  color: dark-color;
@@ -2,6 +2,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { ClassNames } from "./classNames.js";
3
3
  import styles from "./Icon.modules.scss";
4
4
  export const Icon = ({ color = "dark", icon }) => {
5
- return _jsx("img", { src: icon, style: { width: "30px", height: "30px" }, className: ClassNames({ light: color === "light" }, styles) });
5
+ return _jsx("img", { src: icon, style: { width: "100%", height: "100%" }, className: ClassNames({ light: color === "light" }, styles) });
6
6
  };
7
7
  //# sourceMappingURL=Icon.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Icon.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/Icon.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAOzC,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE;IAClE,OAAO,cAAK,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,OAAO,EAAE,EAAE,MAAM,CAAC,GAAI,CAAC;AACrI,CAAC,CAAC","sourcesContent":["import { ClassNames } from \"./classNames\";\r\nimport styles from \"./Icon.modules.scss\";\r\n\r\nexport type IconProps = {\r\n color?: \"dark\" | \"light\";\r\n icon: string;\r\n};\r\n\r\nexport const Icon: React.FC<IconProps> = ({ color = \"dark\", icon }) => {\r\n return <img src={icon} style={{ width: \"30px\", height: \"30px\" }} className={ClassNames({ light: color === \"light\" }, styles)} />;\r\n};\r\n"]}
1
+ {"version":3,"file":"Icon.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/Icon.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAOzC,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE;IAClE,OAAO,cAAK,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,OAAO,EAAE,EAAE,MAAM,CAAC,GAAI,CAAC;AACrI,CAAC,CAAC","sourcesContent":["import { ClassNames } from \"./classNames\";\r\nimport styles from \"./Icon.modules.scss\";\r\n\r\nexport type IconProps = {\r\n color?: \"dark\" | \"light\";\r\n icon: string;\r\n};\r\n\r\nexport const Icon: React.FC<IconProps> = ({ color = \"dark\", icon }) => {\r\n return <img src={icon} style={{ width: \"100%\", height: \"100%\" }} className={ClassNames({ light: color === \"light\" }, styles)} />;\r\n};\r\n"]}
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ export interface ITextInputProps {
3
+ label?: string;
4
+ placeholder?: string;
5
+ submitValue: (newValue: string) => void;
6
+ validateValue?: (value: string) => boolean;
7
+ cancelSubmit?: () => void;
8
+ }
9
+ /**
10
+ * This component represents a text input that can be submitted or cancelled on buttons
11
+ */
12
+ export declare const TextInputWithSubmit: (props: ITextInputProps) => JSX.Element;
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from "react";
3
+ import { Button } from "./Button.js";
4
+ import { Icon } from "./Icon.js";
5
+ import style from "./TextInputWithSubmit.modules.scss";
6
+ import submitIcon from "../imgs/confirmGridElementDark.svg";
7
+ import cancelIcon from "../imgs/deleteGridElementDark.svg";
8
+ import { ClassNames } from "./classNames.js";
9
+ /**
10
+ * This component represents a text input that can be submitted or cancelled on buttons
11
+ */
12
+ export const TextInputWithSubmit = (props) => {
13
+ const [value, setValue] = useState("");
14
+ const [valid, setValid] = useState(props.validateValue ? props.validateValue(value) : true);
15
+ useEffect(() => {
16
+ setValid(props.validateValue ? props.validateValue(value) : true);
17
+ }, [value]);
18
+ const onChange = (event) => {
19
+ setValue(event.target.value);
20
+ };
21
+ const onClickSubmit = () => {
22
+ props.submitValue(value);
23
+ };
24
+ const onClickCancel = () => {
25
+ var _a;
26
+ (_a = props.cancelSubmit) === null || _a === void 0 ? void 0 : _a.call(props);
27
+ setValue("");
28
+ };
29
+ return (_jsxs("div", { className: ClassNames({ line: true, valid, invalid: !valid }, style), children: [props.label && _jsx("label", { children: props.label }), _jsx("input", { className: style.input, type: "text", placeholder: props.placeholder, value: value, onChange: onChange }), _jsxs("div", { children: [_jsx(Button, { color: "light", size: "smaller", backgroundColor: "inherit", onClick: onClickSubmit, disabled: !valid, children: _jsx(Icon, { icon: submitIcon, color: "dark" }) }), _jsx(Button, { color: "light", size: "smaller", backgroundColor: "inherit", onClick: onClickCancel, children: _jsx(Icon, { icon: cancelIcon, color: "dark" }) })] })] }));
30
+ };
31
+ //# sourceMappingURL=TextInputWithSubmit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextInputWithSubmit.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/TextInputWithSubmit.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,KAAK,MAAM,oCAAoC,CAAC;AAEvD,OAAO,UAAU,MAAM,oCAAoC,CAAC;AAC5D,OAAO,UAAU,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAU1C;;GAEG;AACH,MAAM,CAAC,MA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I,EAC/G,0BACI,KAAC,MAAM,IAAC,KAAK,EAAC,OAAO,EAAC,IAAI,EAAC,SAAS,EAAC,eAAe,EAAC,SAAS,EAAC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,KAAK,YACnG,KAAC,IAAI,IAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAC,MAAM,GAAQ,GACvC,EACT,KAAC,MAAM,IAAC,KAAK,EAAC,OAAO,EAAC,IAAI,EAAC,SAAS,EAAC,eAAe,EAAC,SAAS,EAAC,OAAO,EAAE,aAAa,YACjF,KAAC,IAAI,IAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAC,MAAM,GAAQ,GACvC,IACP,IACJ,CACT,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { useEffect, useState } from \"react\";\r\nimport { Button } from \"./Button\";\r\nimport { Icon } from \"./Icon\";\r\nimport style from \"./TextInputWithSubmit.modules.scss\";\r\n\r\nimport submitIcon from \"../imgs/confirmGridElementDark.svg\";\r\nimport cancelIcon from \"../imgs/deleteGridElementDark.svg\";\r\nimport { ClassNames } from \"./classNames\";\r\n\r\nexport interface ITextInputProps {\r\n label?: string;\r\n placeholder?: string;\r\n submitValue: (newValue: string) => void; // Function to call when the value is updated\r\n validateValue?: (value: string) => boolean; // Function to call to validate the value\r\n cancelSubmit?: () => void; // Function to call when the user cancels the submit\r\n}\r\n\r\n/**\r\n * This component represents a text input that can be submitted or cancelled on buttons\r\n */\r\nexport const TextInputWithSubmit = (props: ITextInputProps) => {\r\n const [value, setValue] = useState(\"\");\r\n const [valid, setValid] = useState(props.validateValue ? props.validateValue(value) : true);\r\n\r\n useEffect(() => {\r\n setValid(props.validateValue ? props.validateValue(value) : true);\r\n }, [value]);\r\n\r\n const onChange = (event: React.ChangeEvent<HTMLInputElement>) => {\r\n setValue(event.target.value);\r\n };\r\n\r\n const onClickSubmit = () => {\r\n props.submitValue(value);\r\n };\r\n\r\n const onClickCancel = () => {\r\n props.cancelSubmit?.();\r\n setValue(\"\");\r\n };\r\n\r\n return (\r\n <div className={ClassNames({ line: true, valid, invalid: !valid }, style)}>\r\n {props.label && <label>{props.label}</label>}\r\n <input className={style.input} type=\"text\" placeholder={props.placeholder} value={value} onChange={onChange} />\r\n <div>\r\n <Button color=\"light\" size=\"smaller\" backgroundColor=\"inherit\" onClick={onClickSubmit} disabled={!valid}>\r\n <Icon icon={submitIcon} color=\"dark\"></Icon>\r\n </Button>\r\n <Button color=\"light\" size=\"smaller\" backgroundColor=\"inherit\" onClick={onClickCancel}>\r\n <Icon icon={cancelIcon} color=\"dark\"></Icon>\r\n </Button>\r\n </div>\r\n </div>\r\n );\r\n};\r\n"]}
@@ -0,0 +1,22 @@
1
+ .line {
2
+ width: 100%;
3
+ height: 100%;
4
+ display: flex;
5
+ justify-content: space-between;
6
+ align-items: center;
7
+ }
8
+
9
+ .input {
10
+ border: unset;
11
+ background-color: inherit;
12
+ flex-grow: 1;
13
+ width: 100px;
14
+ }
15
+
16
+ .valid {
17
+ background-color: white;
18
+ }
19
+
20
+ .invalid {
21
+ background-color: rgba(255, 204, 204, 0.8);
22
+ }
@@ -0,0 +1,20 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * This components represents an options menu with optional
4
+ * customizable properties. Option IDs should be unique.
5
+ */
6
+ export interface IOption {
7
+ label: string;
8
+ value: string;
9
+ id: string;
10
+ }
11
+ export interface IOptionsLineComponentProps {
12
+ options: IOption[];
13
+ addOptionPlaceholder?: string;
14
+ onOptionAdded?: (newOption: IOption) => void;
15
+ onOptionSelected: (selectedOptionValue: string) => void;
16
+ selectedOptionValue: string;
17
+ validateNewOptionValue?: (newOptionValue: string) => boolean;
18
+ addOptionText?: string;
19
+ }
20
+ export declare const OptionsLineComponent: (props: IOptionsLineComponentProps) => JSX.Element;
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { TextInputWithSubmit } from "../TextInputWithSubmit.js";
4
+ import style from "./OptionsLineComponent.modules.scss";
5
+ /**
6
+ * We have two possible states. The user starts in the Default option, and can choose to
7
+ * add a new option.
8
+ */
9
+ var OptionStates;
10
+ (function (OptionStates) {
11
+ OptionStates[OptionStates["Default"] = 0] = "Default";
12
+ OptionStates[OptionStates["Adding"] = 1] = "Adding";
13
+ })(OptionStates || (OptionStates = {}));
14
+ const _OptionAddKey = "addCustomOption";
15
+ export const OptionsLineComponent = (props) => {
16
+ var _a;
17
+ const [optionState, setOptionState] = useState(OptionStates.Default); // State of the component
18
+ const onOptionChange = (evt) => {
19
+ if (evt.target.value === _OptionAddKey) {
20
+ setOptionState(OptionStates.Adding);
21
+ }
22
+ else {
23
+ props.onOptionSelected(evt.target.value);
24
+ }
25
+ };
26
+ const onOptionAdd = (value) => {
27
+ var _a;
28
+ const newOptionText = value;
29
+ const newOption = { label: newOptionText, value: newOptionText, id: Date.now().toString() };
30
+ (_a = props.onOptionAdded) === null || _a === void 0 ? void 0 : _a.call(props, newOption);
31
+ props.onOptionSelected(newOption.value);
32
+ setOptionState(OptionStates.Default);
33
+ };
34
+ const onCancelOptionAdd = () => {
35
+ setOptionState(OptionStates.Default);
36
+ };
37
+ return (_jsxs("div", { className: style.optionsLine, children: [optionState === OptionStates.Adding && (_jsx(TextInputWithSubmit, { submitValue: onOptionAdd, placeholder: props.addOptionPlaceholder, validateValue: props.validateNewOptionValue, cancelSubmit: onCancelOptionAdd })), optionState === OptionStates.Default && (_jsxs("select", { className: style.optionsSelect, onChange: onOptionChange, value: props.selectedOptionValue, children: [props.onOptionAdded && (_jsx("option", { value: _OptionAddKey, children: (_a = props.addOptionText) !== null && _a !== void 0 ? _a : "Custom" }, _OptionAddKey)), props.options.map((option) => (_jsx("option", { value: option.value, children: option.label }, option.id)))] }))] }));
38
+ };
39
+ //# sourceMappingURL=OptionsLineComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OptionsLineComponent.js","sourceRoot":"","sources":["../../../../../../dev/sharedUiCompon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AAG,GAAG,EAAE;QAC3B,cAAc,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC,CAAC;IAEF,OAAO,CACH,eAAK,SAAS,EAAE,KAAK,CAAC,WAAW,aAC5B,WAAW,KAAK,YAAY,CAAC,MAAM,IAAI,CACpC,KAAC,mBAAmB,IAChB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,KAAK,CAAC,oBAAoB,EACvC,aAAa,EAAE,KAAK,CAAC,sBAAsB,EAC3C,YAAY,EAAE,iBAAiB,GACjC,CACL,EACA,WAAW,KAAK,YAAY,CAAC,OAAO,IAAI,CACrC,kBAAQ,SAAS,EAAE,KAAK,CAAC,aAAa,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,CAAC,mBAAmB,aAC7F,KAAK,CAAC,aAAa,IAAI,CACpB,iBAA4B,KAAK,EAAE,aAAa,YAC3C,MAAA,KAAK,CAAC,aAAa,mCAAI,QAAQ,IADvB,aAAa,CAEjB,CACZ,EACA,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAC3B,iBAAwB,KAAK,EAAE,MAAM,CAAC,KAAK,YACtC,MAAM,CAAC,KAAK,IADJ,MAAM,CAAC,EAAE,CAEb,CACZ,CAAC,IACG,CACZ,IACC,CACT,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type { ChangeEvent } from \"react\";\r\nimport { useState } from \"react\";\r\nimport { TextInputWithSubmit } from \"../TextInputWithSubmit\";\r\nimport style from \"./OptionsLineComponent.modules.scss\";\r\n\r\n/**\r\n * This components represents an options menu with optional\r\n * customizable properties. Option IDs should be unique.\r\n */\r\nexport interface IOption {\r\n label: string;\r\n value: string;\r\n id: string;\r\n}\r\n\r\nexport interface IOptionsLineComponentProps {\r\n options: IOption[];\r\n addOptionPlaceholder?: string; // Placeholder text to display when adding a new option\r\n onOptionAdded?: (newOption: IOption) => void; // Optional function that can be used to add a new option to the menu\r\n onOptionSelected: (selectedOptionValue: string) => void;\r\n selectedOptionValue: string; // The value of the currently selected option\r\n validateNewOptionValue?: (newOptionValue: string) => boolean; // Optional function that can be used to validate the value of a new option\r\n addOptionText?: string; // Optional text to display on the add option button\r\n}\r\n\r\n/**\r\n * We have two possible states. The user starts in the Default option, and can choose to\r\n * add a new option.\r\n */\r\nenum OptionStates {\r\n Default = 0, // Default state,\r\n Adding = 1, // State when the user is adding a new option to the menu\r\n}\r\n\r\nconst _OptionAddKey = \"addCustomOption\";\r\n\r\nexport const OptionsLineComponent = (props: IOptionsLineComponentProps) => {\r\n const [optionState, setOptionState] = useState(OptionStates.Default); // State of the component\r\n\r\n const onOptionChange = (evt: ChangeEvent<HTMLSelectElement>) => {\r\n if (evt.target.value === _OptionAddKey) {\r\n setOptionState(OptionStates.Adding);\r\n } else {\r\n props.onOptionSelected(evt.target.value);\r\n }\r\n };\r\n\r\n const onOptionAdd = (value: string) => {\r\n const newOptionText = value;\r\n const newOption = { label: newOptionText, value: newOptionText, id: Date.now().toString() };\r\n props.onOptionAdded?.(newOption);\r\n props.onOptionSelected(newOption.value);\r\n setOptionState(OptionStates.Default);\r\n };\r\n\r\n const onCancelOptionAdd = () => {\r\n setOptionState(OptionStates.Default);\r\n };\r\n\r\n return (\r\n <div className={style.optionsLine}>\r\n {optionState === OptionStates.Adding && (\r\n <TextInputWithSubmit\r\n submitValue={onOptionAdd}\r\n placeholder={props.addOptionPlaceholder}\r\n validateValue={props.validateNewOptionValue}\r\n cancelSubmit={onCancelOptionAdd}\r\n />\r\n )}\r\n {optionState === OptionStates.Default && (\r\n <select className={style.optionsSelect} onChange={onOptionChange} value={props.selectedOptionValue}>\r\n {props.onOptionAdded && (\r\n <option key={_OptionAddKey} value={_OptionAddKey}>\r\n {props.addOptionText ?? \"Custom\"}\r\n </option>\r\n )}\r\n {props.options.map((option) => (\r\n <option key={option.id} value={option.value}>\r\n {option.label}\r\n </option>\r\n ))}\r\n </select>\r\n )}\r\n </div>\r\n );\r\n};\r\n"]}
@@ -0,0 +1,12 @@
1
+ .optionsLine {
2
+ font-family: "acumin-pro-condensed", sans-serif;
3
+ font-size: 12px;
4
+ height: 25px;
5
+ padding-left: 15px;
6
+ }
7
+
8
+ .optionsSelect {
9
+ width: 100%;
10
+ height: 100%;
11
+ border: unset;
12
+ }
@@ -34,6 +34,9 @@ export class LineContainerComponent extends React.Component {
34
34
  }, 5000);
35
35
  }
36
36
  else if (this.props.selection.selectedLineContainerTitlesNoFocus.indexOf(this.props.title) > -1) {
37
+ setTimeout(() => {
38
+ this.props.selection.selectedLineContainerTitlesNoFocus = [];
39
+ });
37
40
  this.setState({ isExpanded: true, isHighlighted: false });
38
41
  }
39
42
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"lineContainerComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/lines/lineContainerComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,4CAA8B;AAEpD,OAAO,SAAS,MAAM,iBAAiB,CAAC;AASxC,MAAM,OAAO,sBAAuB,SAAQ,KAAK,CAAC,SAAwF;IACtI,YAAY,KAAmC;QAC3C,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,MAAM,YAAY,GAAG,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAEnF,IAAI,CAAC,KAAK,GAAG,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;IACpE,CAAC;IAED,mBAAmB;QACf,MAAM,QAAQ,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;QAExC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAErD,IAAI,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,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E,CAAC,CAAC;YAC5C,CAAC,EAAE,IAAI,CAAC,CAAC;SACZ;aAAM,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,kCAAkC,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE;YAC/F,IAAI,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;SAC7D;aAAM;YACH,IAAI,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;SACxC;IACL,CAAC;IAED,MAAM;QACF,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE;YACxB,OAAO,CACH,cAAK,SAAS,EAAC,eAAe,YAC1B,cAAK,SAAS,EAAC,uBAAuB,YAAE,IAAI,CAAC,YAAY,EAAE,GAAO,GAChE,CACT,CAAC;SACL;QAED,OAAO,CACH,eAAK,SAAS,EAAC,eAAe,aAC1B,eAAK,SAAS,EAAC,uBAAuB,aACjC,IAAI,CAAC,YAAY,EAAE,EACpB,cAAK,SAAS,EAAC,UAAU,YAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAO,IACnD,EACN,cAAK,SAAS,EAAE,gCAAgC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,GAAQ,IAC1G,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport { DataStorage } from \"core/Misc/dataStorage\";\r\nimport type { ISelectedLineContainer } from \"./iSelectedLineContainer\";\r\nimport downArrow from \"./downArrow.svg\";\r\n\r\ninterface ILineContainerComponentProps {\r\n selection?: ISelectedLineContainer;\r\n title: string;\r\n children: any[] | any;\r\n closed?: boolean;\r\n}\r\n\r\nexport class LineContainerComponent extends React.Component<ILineContainerComponentProps, { isExpanded: boolean; isHighlighted: boolean }> {\r\n constructor(props: ILineContainerComponentProps) {\r\n super(props);\r\n\r\n const initialState = DataStorage.ReadBoolean(this.props.title, !this.props.closed);\r\n\r\n this.state = { isExpanded: initialState, isHighlighted: false };\r\n }\r\n\r\n switchExpandedState(): void {\r\n const newState = !this.state.isExpanded;\r\n\r\n DataStorage.WriteBoolean(this.props.title, newState);\r\n\r\n this.setState({ isExpanded: newState });\r\n }\r\n\r\n renderHeader() {\r\n const className = this.state.isExpanded ? \"collapse\" : \"collapse closed\";\r\n\r\n return (\r\n <div className=\"header\" onClick={() => this.switchExpandedState()}>\r\n <div className=\"title\">{this.props.title}</div>\r\n <div className={className}>\r\n <img className=\"img\" title={this.props.title} src={downArrow} />\r\n </div>\r\n </div>\r\n );\r\n }\r\n\r\n componentDidMount() {\r\n if (!this.props.selection) {\r\n return;\r\n }\r\n\r\n if (this.props.selection.selectedLineContainerTitles.length === 0 && this.props.selection.selectedLineContainerTitlesNoFocus.length === 0) {\r\n return;\r\n }\r\n\r\n if (this.props.selection.selectedLineContainerTitles.indexOf(this.props.title) > -1) {\r\n setTimeout(() => {\r\n this.props.selection!.selectedLineContainerTitles = [];\r\n });\r\n\r\n this.setState({ isExpanded: true, isHighlighted: true });\r\n\r\n window.setTimeout(() => {\r\n this.setState({ isHighlighted: false });\r\n }, 5000);\r\n } else if (this.props.selection.selectedLineContainerTitlesNoFocus.indexOf(this.props.title) > -1) {\r\n this.setState({ isExpanded: true, isHighlighted: false });\r\n } else {\r\n this.setState({ isExpanded: false });\r\n }\r\n }\r\n\r\n render() {\r\n if (!this.state.isExpanded) {\r\n return (\r\n <div className=\"paneContainer\">\r\n <div className=\"paneContainer-content\">{this.renderHeader()}</div>\r\n </div>\r\n );\r\n }\r\n\r\n return (\r\n <div className=\"paneContainer\">\r\n <div className=\"paneContainer-content\">\r\n {this.renderHeader()}\r\n <div className=\"paneList\">{this.props.children}</div>\r\n </div>\r\n <div className={\"paneContainer-highlight-border\" + (!this.state.isHighlighted ? \" transparent\" : \"\")}></div>\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"lineContainerComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/lines/lineContainerComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,4CAA8B;AAEpD,OAAO,SAAS,MAAM,iBAAiB,CAAC;AASxC,MAAM,OAAO,sBAAuB,SAAQ,KAAK,CAAC,SAAwF;IACtI,YAAY,KAAmC;QAC3C,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,MAAM,YAAY,GAAG,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAEnF,IAAI,CAAC,KAAK,GAAG,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;IACpE,CAAC;IAED,mBAAmB;QACf,MAAM,QAAQ,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;QAExC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAErD,IAAI,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,YAAY;QACR,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC;QAEzE,OAAO,CACH,eAAK,SAAS,EAAC,QAAQ,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,mBAAmB,EAAE,aAC7D,cAAK,SAAS,EAAC,OAAO,YAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAO,EAC/C,cAAK,SAAS,EAAE,SAAS,YACrB,cAAK,SAAS,EAAC,K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,EAAE,CAAC,CAAC;SAC7D;aAAM;YACH,IAAI,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;SACxC;IACL,CAAC;IAED,MAAM;QACF,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE;YACxB,OAAO,CACH,cAAK,SAAS,EAAC,eAAe,YAC1B,cAAK,SAAS,EAAC,uBAAuB,YAAE,IAAI,CAAC,YAAY,EAAE,GAAO,GAChE,CACT,CAAC;SACL;QAED,OAAO,CACH,eAAK,SAAS,EAAC,eAAe,aAC1B,eAAK,SAAS,EAAC,uBAAuB,aACjC,IAAI,CAAC,YAAY,EAAE,EACpB,cAAK,SAAS,EAAC,UAAU,YAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAO,IACnD,EACN,cAAK,SAAS,EAAE,gCAAgC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,GAAQ,IAC1G,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport { DataStorage } from \"core/Misc/dataStorage\";\r\nimport type { ISelectedLineContainer } from \"./iSelectedLineContainer\";\r\nimport downArrow from \"./downArrow.svg\";\r\n\r\ninterface ILineContainerComponentProps {\r\n selection?: ISelectedLineContainer;\r\n title: string;\r\n children: any[] | any;\r\n closed?: boolean;\r\n}\r\n\r\nexport class LineContainerComponent extends React.Component<ILineContainerComponentProps, { isExpanded: boolean; isHighlighted: boolean }> {\r\n constructor(props: ILineContainerComponentProps) {\r\n super(props);\r\n\r\n const initialState = DataStorage.ReadBoolean(this.props.title, !this.props.closed);\r\n\r\n this.state = { isExpanded: initialState, isHighlighted: false };\r\n }\r\n\r\n switchExpandedState(): void {\r\n const newState = !this.state.isExpanded;\r\n\r\n DataStorage.WriteBoolean(this.props.title, newState);\r\n\r\n this.setState({ isExpanded: newState });\r\n }\r\n\r\n renderHeader() {\r\n const className = this.state.isExpanded ? \"collapse\" : \"collapse closed\";\r\n\r\n return (\r\n <div className=\"header\" onClick={() => this.switchExpandedState()}>\r\n <div className=\"title\">{this.props.title}</div>\r\n <div className={className}>\r\n <img className=\"img\" title={this.props.title} src={downArrow} />\r\n </div>\r\n </div>\r\n );\r\n }\r\n\r\n componentDidMount() {\r\n if (!this.props.selection) {\r\n return;\r\n }\r\n\r\n if (this.props.selection.selectedLineContainerTitles.length === 0 && this.props.selection.selectedLineContainerTitlesNoFocus.length === 0) {\r\n return;\r\n }\r\n\r\n if (this.props.selection.selectedLineContainerTitles.indexOf(this.props.title) > -1) {\r\n setTimeout(() => {\r\n this.props.selection!.selectedLineContainerTitles = [];\r\n });\r\n\r\n this.setState({ isExpanded: true, isHighlighted: true });\r\n\r\n window.setTimeout(() => {\r\n this.setState({ isHighlighted: false });\r\n }, 5000);\r\n } else if (this.props.selection.selectedLineContainerTitlesNoFocus.indexOf(this.props.title) > -1) {\r\n setTimeout(() => {\r\n this.props.selection!.selectedLineContainerTitlesNoFocus = [];\r\n });\r\n this.setState({ isExpanded: true, isHighlighted: false });\r\n } else {\r\n this.setState({ isExpanded: false });\r\n }\r\n }\r\n\r\n render() {\r\n if (!this.state.isExpanded) {\r\n return (\r\n <div className=\"paneContainer\">\r\n <div className=\"paneContainer-content\">{this.renderHeader()}</div>\r\n </div>\r\n );\r\n }\r\n\r\n return (\r\n <div className=\"paneContainer\">\r\n <div className=\"paneContainer-content\">\r\n {this.renderHeader()}\r\n <div className=\"paneList\">{this.props.children}</div>\r\n </div>\r\n <div className={\"paneContainer-highlight-border\" + (!this.state.isHighlighted ? \" transparent\" : \"\")}></div>\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
@@ -8,14 +8,9 @@ export interface IOptionsLineComponentProps {
8
8
  target: any;
9
9
  propertyName: string;
10
10
  options: IInspectableOptions[];
11
- addInput?: boolean;
12
11
  noDirectUpdate?: boolean;
13
12
  onSelect?: (value: number | string) => void;
14
13
  extractValue?: (target: any) => number | string;
15
- addVal?: (newVal: {
16
- label: string;
17
- value: number;
18
- }, prevVal: number) => void;
19
14
  onPropertyChangedObservable?: Observable<PropertyChangedEvent>;
20
15
  allowNullValue?: boolean;
21
16
  icon?: string;
@@ -23,13 +18,9 @@ export interface IOptionsLineComponentProps {
23
18
  className?: string;
24
19
  valuesAreStrings?: boolean;
25
20
  defaultIfNull?: number;
26
- fromFontDropdown?: boolean;
27
- valueProp?: number;
28
- fallbackValue?: number;
29
21
  }
30
22
  export declare class OptionsLineComponent extends React.Component<IOptionsLineComponentProps, {
31
23
  value: number | string;
32
- addCustom: boolean;
33
24
  }> {
34
25
  private _localChange;
35
26
  private _remapValueIn;
@@ -38,11 +29,9 @@ export declare class OptionsLineComponent extends React.Component<IOptionsLineCo
38
29
  constructor(props: IOptionsLineComponentProps);
39
30
  shouldComponentUpdate(nextProps: IOptionsLineComponentProps, nextState: {
40
31
  value: number;
41
- addCustom: boolean;
42
32
  }): boolean;
43
33
  raiseOnPropertyChanged(newValue: number, previousValue: number): void;
44
34
  setValue(value: string | number): void;
45
35
  updateValue(valueString: string): void;
46
- updateCustomValue(): void;
47
36
  render(): JSX.Element;
48
37
  }
@@ -2,13 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  // eslint-disable-next-line @typescript-eslint/naming-convention
4
4
  export const Null_Value = Number.MAX_SAFE_INTEGER;
5
- const DEFAULT_FALLBACK_VALUE = -1;
6
5
  export class OptionsLineComponent extends React.Component {
7
6
  constructor(props) {
8
- // Initialize default props
9
7
  super(props);
10
8
  this._localChange = false;
11
- this.state = { value: this._remapValueIn(this._getValue(props)), addCustom: false };
9
+ this.state = { value: this._remapValueIn(this._getValue(props)) };
12
10
  }
13
11
  _remapValueIn(value) {
14
12
  return this.props.allowNullValue && value === null ? Null_Value : value;
@@ -27,14 +25,11 @@ export class OptionsLineComponent extends React.Component {
27
25
  this._localChange = false;
28
26
  return true;
29
27
  }
30
- const newValue = this._remapValueIn(nextProps.extractValue ? nextProps.extractValue(nextProps.target) : nextProps.target[nextProps.propertyName]);
28
+ const newValue = this._remapValueIn(nextProps.extractValue ? nextProps.extractValue(this.props.target) : nextProps.target[nextProps.propertyName]);
31
29
  if (newValue != null && newValue !== nextState.value) {
32
30
  nextState.value = newValue;
33
31
  return true;
34
32
  }
35
- if (this.props.options !== nextProps.options) {
36
- return true;
37
- }
38
33
  return false;
39
34
  }
40
35
  raiseOnPropertyChanged(newValue, previousValue) {
@@ -53,67 +48,24 @@ export class OptionsLineComponent extends React.Component {
53
48
  this.setState({ value: value });
54
49
  }
55
50
  updateValue(valueString) {
56
- var _a, _b;
57
- let value = this.props.valuesAreStrings ? valueString : parseInt(valueString);
58
- if (isNaN(Number(value))) {
59
- for (let i = 0; i < this.props.options.length; i++) {
60
- if (((_a = this.props.options.at(i)) === null || _a === void 0 ? void 0 : _a.label) === valueString) {
61
- value = Number((_b = this.props.options.at(i)) === null || _b === void 0 ? void 0 : _b.value);
62
- }
63
- }
64
- }
65
- if (value === 0 && this.props.fromFontDropdown) {
66
- this.setState({ addCustom: true });
67
- }
51
+ const value = this.props.valuesAreStrings ? valueString : parseInt(valueString);
68
52
  this._localChange = true;
69
53
  const store = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];
70
54
  if (!this.props.noDirectUpdate) {
71
55
  this.props.target[this.props.propertyName] = this._remapValueOut(value);
72
56
  }
73
- //selecting a regular option from font dropdown
74
- if (value != 0 && this.props.fromFontDropdown) {
75
- this.setState({ value: value });
76
- if (this.props.onSelect) {
77
- this.props.onSelect(value);
78
- }
79
- //selecting 'custom font' from font dropdown
80
- }
81
- else if (this.props.fromFontDropdown) {
82
- if (this.props.onSelect) {
83
- this.props.onSelect(this.state.value);
84
- }
85
- }
86
- //selecting from a dropdown that's not font dropdown
87
- else {
88
- this.setState({ value: value });
89
- if (this.props.onSelect) {
90
- this.props.onSelect(value);
91
- }
57
+ this.setState({ value: value });
58
+ if (this.props.onSelect) {
59
+ this.props.onSelect(value);
92
60
  }
93
61
  const newValue = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];
94
62
  this.raiseOnPropertyChanged(newValue, store);
95
63
  }
96
- updateCustomValue() {
97
- this.setState({ addCustom: false });
98
- }
99
64
  render() {
100
65
  var _a;
101
- const fallback = this.props.fallbackValue !== undefined ? this.props.fallbackValue : DEFAULT_FALLBACK_VALUE;
102
- return (_jsxs("div", { className: `listLine ${(_a = this.props.className) !== null && _a !== void 0 ? _a : ""}`, children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, color: "black", className: "icon" }), _jsx("div", { className: "label", title: this.props.label, children: this.props.label }), _jsx("div", { className: "options", children: this.state.addCustom ? (_jsx("input", { type: "text", placeholder: "Enter a custom font here", onKeyDown: (event) => {
103
- event.key === "Enter" && this.props.addVal != undefined
104
- ? (this.props.addVal({ label: event.target.value, value: this.props.options.length + 1 }, Number(this.state.value)),
105
- this.updateCustomValue(),
106
- this.forceUpdate())
107
- : null;
108
- }, onBlur: (event) => {
109
- this.props.addVal != undefined
110
- ? (this.props.addVal({ label: event.target.value, value: this.props.options.length + 1 }, Number(this.state.value)),
111
- this.updateCustomValue(),
112
- this.forceUpdate())
113
- : null;
114
- } })) : (_jsx("select", { onChange: (evt) => this.updateValue(evt.target.value), value: this.state.value === null || this.state.value === undefined ? fallback : this.state.value, children: this.props.options.map((option, i) => {
66
+ return (_jsxs("div", { className: "listLine" + (this.props.className ? " " + this.props.className : ""), children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, color: "black", className: "icon" }), _jsx("div", { className: "label", title: this.props.label, children: this.props.label }), _jsx("div", { className: "options", children: _jsx("select", { onChange: (evt) => this.updateValue(evt.target.value), value: (_a = this.state.value) !== null && _a !== void 0 ? _a : "", children: this.props.options.map((option, i) => {
115
67
  return (_jsx("option", { selected: option.selected, value: option.value, title: option.label, children: option.label }, option.label + i));
116
- }) })) })] }));
68
+ }) }) })] }));
117
69
  }
118
70
  }
119
71
  //# sourceMappingURL=optionsLineComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"optionsLineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/lines/optionsLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,gEAAgE;AAChE,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAElD,MAAM,sBAAsB,GAAG,CAAC,CAAC,CAAC;AAyBlC,MAAM,OAAO,oBAAqB,SAAQ,KAAK,CAAC,SAAqF;IAiBjI,YAAY,KAAiC;QACzC,2BAA2B;QAC3B,KAAK,CAAC,KAAK,CAAC,CAAC;QAlBT,iBAAY,GAAG,KAAK,CAAC;QAoBzB,IAAI,CAAC,KAAK,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IACxF,CAAC;IApBO,aAAa,CAAC,KAAoB;QACtC,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAM,CAAC;IAC7E,CAAC;IAEO,cAAc,CAAC,KAAa;QAChC,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5E,CAAC;IAEO,SAAS,CAAC,KAAiC;QAC/C,IAAI,KAAK,CAAC,YAAY,EAAE;YACpB,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SAC3C;QACD,OAAO,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,YAAY,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AAE,CAAC,KAAK,EAAE,EAAE;4BACd,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,SAAS;gCAC1B,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAG,KAAK,CAAC,MAA2B,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;oCACvI,IAAI,CAAC,iBAAiB,EAAE;oCACxB,IAAI,CAAC,WAAW,EAAE,CAAC;gCACrB,CAAC,CAAC,IAAI,CAAC;wBACf,CAAC,GACH,CACL,CAAC,CAAC,CAAC,CACA,iBACI,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EACrD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,YAE/F,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;4BAClC,OAAO,CACH,iBAAQ,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAyB,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,YAC7F,MAAM,CAAC,KAAK,IADuB,MAAM,CAAC,KAAK,GAAG,CAAC,CAE/C,CACZ,CAAC;wBACN,CAAC,CAAC,GACG,CACZ,GACC,IACJ,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport type { IInspectableOptions } from \"core/Misc/iInspectable\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const Null_Value = Number.MAX_SAFE_INTEGER;\r\n\r\nconst DEFAULT_FALLBACK_VALUE = -1;\r\n\r\nexport interface IOptionsLineComponentProps {\r\n label: string;\r\n target: any;\r\n propertyName: string;\r\n options: IInspectableOptions[];\r\n addInput?: boolean;\r\n noDirectUpdate?: boolean;\r\n onSelect?: (value: number | string) => void;\r\n extractValue?: (target: any) => number | string;\r\n addVal?: (newVal: { label: string; value: number }, prevVal: number) => void;\r\n\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n allowNullValue?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n className?: string;\r\n valuesAreStrings?: boolean;\r\n defaultIfNull?: number;\r\n fromFontDropdown?: boolean;\r\n valueProp?: number;\r\n fallbackValue?: number;\r\n}\r\n\r\nexport class OptionsLineComponent extends React.Component<IOptionsLineComponentProps, { value: number | string; addCustom: boolean }> {\r\n private _localChange = false;\r\n private _remapValueIn(value: number | null): number {\r\n return this.props.allowNullValue && value === null ? Null_Value : value!;\r\n }\r\n\r\n private _remapValueOut(value: number): number | null {\r\n return this.props.allowNullValue && value === Null_Value ? null : value;\r\n }\r\n\r\n private _getValue(props: IOptionsLineComponentProps) {\r\n if (props.extractValue) {\r\n return props.extractValue(props.target);\r\n }\r\n return props.target && props.propertyName ? props.target[props.propertyName] : props.options[props.defaultIfNull || 0];\r\n }\r\n\r\n constructor(props: IOptionsLineComponentProps) {\r\n // Initialize default props\r\n super(props);\r\n\r\n this.state = { value: this._remapValueIn(this._getValue(props)), addCustom: false };\r\n }\r\n\r\n shouldComponentUpdate(nextProps: IOptionsLineComponentProps, nextState: { value: number; addCustom: boolean }) {\r\n if (this._localChange) {\r\n this._localChange = false;\r\n\r\n return true;\r\n }\r\n\r\n const newValue = this._remapValueIn(nextProps.extractValue ? nextProps.extractValue(nextProps.target) : nextProps.target[nextProps.propertyName]);\r\n\r\n if (newValue != null && newValue !== nextState.value) {\r\n nextState.value = newValue;\r\n\r\n return true;\r\n }\r\n\r\n if (this.props.options !== nextProps.options) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n raiseOnPropertyChanged(newValue: number, previousValue: number) {\r\n if (!this.props.onPropertyChangedObservable) {\r\n return;\r\n }\r\n\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: this.props.target,\r\n property: this.props.propertyName,\r\n value: newValue,\r\n initialValue: previousValue,\r\n allowNullValue: this.props.allowNullValue,\r\n });\r\n }\r\n\r\n setValue(value: string | number) {\r\n this.setState({ value: value });\r\n }\r\n\r\n updateValue(valueString: string) {\r\n let value = this.props.valuesAreStrings ? valueString : parseInt(valueString);\r\n\r\n if (isNaN(Number(value))) {\r\n for (let i = 0; i < this.props.options.length; i++) {\r\n if (this.props.options.at(i)?.label === valueString) {\r\n value = Number(this.props.options.at(i)?.value);\r\n }\r\n }\r\n }\r\n\r\n if (value === 0 && this.props.fromFontDropdown) {\r\n this.setState({ addCustom: true });\r\n }\r\n\r\n this._localChange = true;\r\n\r\n const store = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];\r\n\r\n if (!this.props.noDirectUpdate) {\r\n this.props.target[this.props.propertyName] = this._remapValueOut(value as number);\r\n }\r\n\r\n //selecting a regular option from font dropdown\r\n if (value != 0 && this.props.fromFontDropdown) {\r\n this.setState({ value: value });\r\n if (this.props.onSelect) {\r\n this.props.onSelect(value);\r\n }\r\n //selecting 'custom font' from font dropdown\r\n } else if (this.props.fromFontDropdown) {\r\n if (this.props.onSelect) {\r\n this.props.onSelect(this.state.value);\r\n }\r\n }\r\n //selecting from a dropdown that's not font dropdown\r\n else {\r\n this.setState({ value: value });\r\n if (this.props.onSelect) {\r\n this.props.onSelect(value);\r\n }\r\n }\r\n\r\n const newValue = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];\r\n\r\n this.raiseOnPropertyChanged(newValue, store);\r\n }\r\n\r\n updateCustomValue() {\r\n this.setState({ addCustom: false });\r\n }\r\n\r\n render() {\r\n const fallback = this.props.fallbackValue !== undefined ? this.props.fallbackValue : DEFAULT_FALLBACK_VALUE;\r\n return (\r\n <div className={`listLine ${this.props.className ?? \"\"}`}>\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} color=\"black\" className=\"icon\" />}\r\n <div className=\"label\" title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n <div className=\"options\">\r\n {this.state.addCustom ? (\r\n <input\r\n type=\"text\"\r\n placeholder=\"Enter a custom font here\"\r\n onKeyDown={(event) => {\r\n event.key === \"Enter\" && this.props.addVal != undefined\r\n ? (this.props.addVal({ label: (event.target as HTMLInputElement).value, value: this.props.options.length + 1 }, Number(this.state.value)),\r\n this.updateCustomValue(),\r\n this.forceUpdate())\r\n : null;\r\n }}\r\n onBlur={(event) => {\r\n this.props.addVal != undefined\r\n ? (this.props.addVal({ label: (event.target as HTMLInputElement).value, value: this.props.options.length + 1 }, Number(this.state.value)),\r\n this.updateCustomValue(),\r\n this.forceUpdate())\r\n : null;\r\n }}\r\n />\r\n ) : (\r\n <select\r\n onChange={(evt) => this.updateValue(evt.target.value)}\r\n value={this.state.value === null || this.state.value === undefined ? fallback : this.state.value}\r\n >\r\n {this.props.options.map((option, i) => {\r\n return (\r\n <option selected={option.selected} key={option.label + i} value={option.value} title={option.label}>\r\n {option.label}\r\n </option>\r\n );\r\n })}\r\n </select>\r\n )}\r\n </div>\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"optionsLineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/lines/optionsLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,gEAAgE;AAChE,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAmBlD,MAAM,O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AAS,EAAC,SAAS,YACpB,iBAAQ,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,mCAAI,EAAE,YACvF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;4BAClC,OAAO,CACH,iBAAQ,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAyB,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,YAC7F,MAAM,CAAC,KAAK,IADuB,MAAM,CAAC,KAAK,GAAG,CAAC,CAE/C,CACZ,CAAC;wBACN,CAAC,CAAC,GACG,GACP,IACJ,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport type { IInspectableOptions } from \"core/Misc/iInspectable\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const Null_Value = Number.MAX_SAFE_INTEGER;\r\n\r\nexport interface IOptionsLineComponentProps {\r\n label: string;\r\n target: any;\r\n propertyName: string;\r\n options: IInspectableOptions[];\r\n noDirectUpdate?: boolean;\r\n onSelect?: (value: number | string) => void;\r\n extractValue?: (target: any) => number | string;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n allowNullValue?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n className?: string;\r\n valuesAreStrings?: boolean;\r\n defaultIfNull?: number;\r\n}\r\n\r\nexport class OptionsLineComponent extends React.Component<IOptionsLineComponentProps, { value: number | string }> {\r\n private _localChange = false;\r\n\r\n private _remapValueIn(value: number | null): number {\r\n return this.props.allowNullValue && value === null ? Null_Value : value!;\r\n }\r\n\r\n private _remapValueOut(value: number): number | null {\r\n return this.props.allowNullValue && value === Null_Value ? null : value;\r\n }\r\n\r\n private _getValue(props: IOptionsLineComponentProps) {\r\n if (props.extractValue) {\r\n return props.extractValue(props.target);\r\n }\r\n return props.target && props.propertyName ? props.target[props.propertyName] : props.options[props.defaultIfNull || 0];\r\n }\r\n\r\n constructor(props: IOptionsLineComponentProps) {\r\n super(props);\r\n\r\n this.state = { value: this._remapValueIn(this._getValue(props)) };\r\n }\r\n\r\n shouldComponentUpdate(nextProps: IOptionsLineComponentProps, nextState: { value: number }) {\r\n if (this._localChange) {\r\n this._localChange = false;\r\n return true;\r\n }\r\n\r\n const newValue = this._remapValueIn(nextProps.extractValue ? nextProps.extractValue(this.props.target) : nextProps.target[nextProps.propertyName]);\r\n if (newValue != null && newValue !== nextState.value) {\r\n nextState.value = newValue;\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n raiseOnPropertyChanged(newValue: number, previousValue: number) {\r\n if (!this.props.onPropertyChangedObservable) {\r\n return;\r\n }\r\n\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: this.props.target,\r\n property: this.props.propertyName,\r\n value: newValue,\r\n initialValue: previousValue,\r\n allowNullValue: this.props.allowNullValue,\r\n });\r\n }\r\n\r\n setValue(value: string | number) {\r\n this.setState({ value: value });\r\n }\r\n\r\n updateValue(valueString: string) {\r\n const value = this.props.valuesAreStrings ? valueString : parseInt(valueString);\r\n this._localChange = true;\r\n\r\n const store = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];\r\n\r\n if (!this.props.noDirectUpdate) {\r\n this.props.target[this.props.propertyName] = this._remapValueOut(value as number);\r\n }\r\n this.setState({ value: value });\r\n\r\n if (this.props.onSelect) {\r\n this.props.onSelect(value);\r\n }\r\n\r\n const newValue = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];\r\n\r\n this.raiseOnPropertyChanged(newValue, store);\r\n }\r\n\r\n render() {\r\n return (\r\n <div className={\"listLine\" + (this.props.className ? \" \" + this.props.className : \"\")}>\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} color=\"black\" className=\"icon\" />}\r\n <div className=\"label\" title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n <div className=\"options\">\r\n <select onChange={(evt) => this.updateValue(evt.target.value)} value={this.state.value ?? \"\"}>\r\n {this.props.options.map((option, i) => {\r\n return (\r\n <option selected={option.selected} key={option.label + i} value={option.value} title={option.label}>\r\n {option.label}\r\n </option>\r\n );\r\n })}\r\n </select>\r\n </div>\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
@@ -4,7 +4,7 @@ import { FrameNodePort } from "./frameNodePort.js";
4
4
  import { StringTools } from "../stringTools.js";
5
5
  import styles from "./graphFrame.modules.scss";
6
6
  import commonStyles from "./common.modules.scss";
7
- import { ClassNames } from "shared-ui-components/components/classNames";
7
+ import { ClassNames } from "../components/classNames.js";
8
8
  var ResizingDirection;
9
9
  (function (ResizingDirection) {
10
10
  ResizingDirection[ResizingDirection["Right"] = 0] = "Right";