@babylonjs/shared-ui-components 8.12.1 → 8.13.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 (73) hide show
  1. package/fluent/hoc/buttonLine.d.ts +12 -0
  2. package/fluent/hoc/buttonLine.js +18 -0
  3. package/fluent/hoc/buttonLine.js.map +1 -0
  4. package/fluent/hoc/colorPropertyLine.d.ts +15 -0
  5. package/fluent/hoc/colorPropertyLine.js +17 -0
  6. package/fluent/hoc/colorPropertyLine.js.map +1 -0
  7. package/fluent/hoc/fluentToolWrapper.d.ts +23 -0
  8. package/fluent/hoc/fluentToolWrapper.js +16 -0
  9. package/fluent/hoc/fluentToolWrapper.js.map +1 -0
  10. package/fluent/hoc/linkPropertyLine.d.ts +15 -0
  11. package/fluent/hoc/linkPropertyLine.js +13 -0
  12. package/fluent/hoc/linkPropertyLine.js.map +1 -0
  13. package/fluent/hoc/propertyLine.d.ts +28 -0
  14. package/fluent/hoc/propertyLine.js +66 -0
  15. package/fluent/hoc/propertyLine.js.map +1 -0
  16. package/fluent/hoc/switchPropertyLine.d.ts +9 -0
  17. package/fluent/hoc/switchPropertyLine.js +15 -0
  18. package/fluent/hoc/switchPropertyLine.js.map +1 -0
  19. package/fluent/hoc/syncedSliderLine.d.ts +27 -0
  20. package/fluent/hoc/syncedSliderLine.js +20 -0
  21. package/fluent/hoc/syncedSliderLine.js.map +1 -0
  22. package/fluent/hoc/textPropertyLine.d.ts +13 -0
  23. package/fluent/hoc/textPropertyLine.js +12 -0
  24. package/fluent/hoc/textPropertyLine.js.map +1 -0
  25. package/fluent/hoc/vectorPropertyLine.d.ts +18 -0
  26. package/fluent/hoc/vectorPropertyLine.js +19 -0
  27. package/fluent/hoc/vectorPropertyLine.js.map +1 -0
  28. package/fluent/primitives/checkbox.d.ts +8 -0
  29. package/fluent/primitives/checkbox.js +22 -0
  30. package/fluent/primitives/checkbox.js.map +1 -0
  31. package/fluent/primitives/dropdown.d.ts +23 -0
  32. package/fluent/primitives/dropdown.js +21 -0
  33. package/fluent/primitives/dropdown.js.map +1 -0
  34. package/fluent/primitives/input.d.ts +8 -0
  35. package/fluent/primitives/input.js +40 -0
  36. package/fluent/primitives/input.js.map +1 -0
  37. package/fluent/primitives/link.d.ts +1 -0
  38. package/fluent/primitives/link.js +3 -0
  39. package/fluent/primitives/link.js.map +1 -0
  40. package/fluent/primitives/switch.d.ts +8 -0
  41. package/fluent/primitives/switch.js +31 -0
  42. package/fluent/primitives/switch.js.map +1 -0
  43. package/fluent/primitives/syncedSlider.d.ts +18 -0
  44. package/fluent/primitives/syncedSlider.js +45 -0
  45. package/fluent/primitives/syncedSlider.js.map +1 -0
  46. package/fluent/primitives/text.d.ts +1 -0
  47. package/fluent/primitives/text.js +3 -0
  48. package/fluent/primitives/text.js.map +1 -0
  49. package/fluent/primitives/textarea.d.ts +8 -0
  50. package/fluent/primitives/textarea.js +27 -0
  51. package/fluent/primitives/textarea.js.map +1 -0
  52. package/lines/buttonLineComponent.d.ts +2 -0
  53. package/lines/buttonLineComponent.js +9 -1
  54. package/lines/buttonLineComponent.js.map +1 -1
  55. package/lines/checkBoxLineComponent.d.ts +2 -0
  56. package/lines/checkBoxLineComponent.js +14 -1
  57. package/lines/checkBoxLineComponent.js.map +1 -1
  58. package/lines/optionsLineComponent.d.ts +3 -1
  59. package/lines/optionsLineComponent.js +16 -5
  60. package/lines/optionsLineComponent.js.map +1 -1
  61. package/lines/sliderLineComponent.d.ts +2 -0
  62. package/lines/sliderLineComponent.js +9 -1
  63. package/lines/sliderLineComponent.js.map +1 -1
  64. package/lines/textInputLineComponent.d.ts +7 -4
  65. package/lines/textInputLineComponent.js +25 -6
  66. package/lines/textInputLineComponent.js.map +1 -1
  67. package/lines/textLineComponent.d.ts +4 -1
  68. package/lines/textLineComponent.js +41 -13
  69. package/lines/textLineComponent.js.map +1 -1
  70. package/lines/vector3LineComponent.d.ts +3 -1
  71. package/lines/vector3LineComponent.js +12 -6
  72. package/lines/vector3LineComponent.js.map +1 -1
  73. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/fluent/primitives/input.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG5C,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE9E,MAAM,cAAc,GAAG,UAAU,CAAC;IAC9B,IAAI,EAAE;QACF,MAAM,EAAE,MAAM;KACjB;IACD,KAAK,EAAE;QACH,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,MAAM,EAAE,+BAA+B;QAC9C,UAAU,EAAE,CAAC;KAChB;CACJ,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAwC,CAAC,KAAK,EAAE,EAAE;IAChE,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAEtD,SAAS,CAAC,GAAG,EAAE;QACX,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,8CAA8C;IAC/E,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAElB,MAAM,YAAY,GAAG,CAAC,KAAoC,EAAE,IAAS,EAAE,EAAE;QACrE,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC,4BAA4B;QACrD,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACjB,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,oDAAoD;QACrF,CAAC;QACD,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,wCAAwC;IAC1E,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,CAAC,KAAsC,EAAE,EAAE;QAC7D,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC,4BAA4B;QACrD,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;YAClB,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,qDAAqD;QACjF,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,KAAC,WAAW,OAAK,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,GAAI,CAAC;AACzK,CAAC,CAAC","sourcesContent":["import type { FunctionComponent, KeyboardEvent, ChangeEvent } from \"react\";\r\nimport { useEffect, useState } from \"react\";\r\n\r\nimport type { InputProps as FluentInputProps } from \"@fluentui/react-components\";\r\nimport { Input as FluentInput, makeStyles } from \"@fluentui/react-components\";\r\n\r\nconst useInputStyles = makeStyles({\r\n text: {\r\n height: \"auto\",\r\n },\r\n float: {\r\n height: \"auto\",\r\n width: \"80px\", // Fixed width for number input\r\n flexShrink: 0,\r\n },\r\n});\r\n\r\n/**\r\n * This is an input text box that stops propagation of change events and sets its width based on the type of input (text or number)\r\n * @param props\r\n * @returns\r\n */\r\nexport const Input: FunctionComponent<FluentInputProps> = (props) => {\r\n const classes = useInputStyles();\r\n const [value, setValue] = useState(props.value ?? \"\");\r\n\r\n useEffect(() => {\r\n setValue(props.value ?? \"\"); // Update local state when props.value changes\r\n }, [props.value]);\r\n\r\n const handleChange = (event: ChangeEvent<HTMLInputElement>, data: any) => {\r\n event.stopPropagation(); // Prevent event propagation\r\n if (props.onChange) {\r\n props.onChange(event, data); // Call the original onChange handler passed as prop\r\n }\r\n setValue(event.target.value); // Update local state with the new value\r\n };\r\n\r\n const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\r\n event.stopPropagation(); // Prevent event propagation\r\n if (props.onKeyDown) {\r\n props.onKeyDown(event); // Call the original onKeyDown handler passed as prop\r\n }\r\n };\r\n\r\n return <FluentInput {...props} value={value} className={props.type === \"number\" ? classes.float : classes.text} onChange={handleChange} onKeyDown={handleKeyDown} />;\r\n};\r\n"]}
@@ -0,0 +1 @@
1
+ export { Link } from "@fluentui/react-components";
@@ -0,0 +1,3 @@
1
+ // No special styling / functionality yet!
2
+ export { Link } from "@fluentui/react-components";
3
+ //# sourceMappingURL=link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/fluent/primitives/link.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAE1C,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC","sourcesContent":["// No special styling / functionality yet!\r\n\r\nexport { Link } from \"@fluentui/react-components\";\r\n"]}
@@ -0,0 +1,8 @@
1
+ import type { SwitchProps as FluentSwitchProps } from "@fluentui/react-components";
2
+ import type { FunctionComponent } from "react";
3
+ /**
4
+ * This is a primitive fluent boolean switch component whose only knowledge is the shared styling across all tools
5
+ * @param props
6
+ * @returns Switch component
7
+ */
8
+ export declare const Switch: FunctionComponent<FluentSwitchProps>;
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { makeStyles, Switch as FluentSwitch } from "@fluentui/react-components";
3
+ import { useEffect, useState } from "react";
4
+ const useSwitchStyles = makeStyles({
5
+ switch: {
6
+ marginLeft: "auto",
7
+ },
8
+ indicator: {
9
+ marginRight: 0, // Remove the default right margin so the switch aligns well on the right side inside panels like the properties pane.
10
+ },
11
+ });
12
+ /**
13
+ * This is a primitive fluent boolean switch component whose only knowledge is the shared styling across all tools
14
+ * @param props
15
+ * @returns Switch component
16
+ */
17
+ export const Switch = (props) => {
18
+ const classes = useSwitchStyles();
19
+ const [checked, setChecked] = useState(() => props.checked ?? false);
20
+ useEffect(() => {
21
+ if (props.checked != undefined) {
22
+ setChecked(props.checked); // Update local state when props.checked changes
23
+ }
24
+ }, [props.checked]);
25
+ const onChange = (event, data) => {
26
+ props.onChange && props.onChange(event, data);
27
+ setChecked(event.target.checked);
28
+ };
29
+ return _jsx(FluentSwitch, { ...props, className: classes.switch, indicator: { className: classes.indicator }, checked: checked, onChange: onChange });
30
+ };
31
+ //# sourceMappingURL=switch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/fluent/primitives/switch.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,MAAM,eAAe,GAAG,UAAU,CAAC;IAC/B,MAAM,EAAE;QACJ,UAAU,EAAE,MAAM;KACrB;IACD,SAAS,EAAE;QACP,WAAW,EAAE,CAAC,EAAE,sHAAsH;KACzI;CACJ,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAyC,CAAC,KAAK,EAAE,EAAE;IAClE,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;IAClC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC;IAErE,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,KAAK,CAAC,OAAO,IAAI,SAAS,EAAE,CAAC;YAC7B,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,gDAAgD;QAC/E,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAEpB,MAAM,QAAQ,GAAG,CAAC,KAAoC,EAAE,IAAwB,EAAE,EAAE;QAChF,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC9C,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC,CAAC;IAEF,OAAO,KAAC,YAAY,OAAK,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAAC;AACrJ,CAAC,CAAC","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\n\r\nimport type { SwitchOnChangeData, SwitchProps as FluentSwitchProps } from \"@fluentui/react-components\";\r\nimport type { ChangeEvent, FunctionComponent } from \"react\";\r\n\r\nimport { makeStyles, Switch as FluentSwitch } from \"@fluentui/react-components\";\r\nimport { useEffect, useState } from \"react\";\r\n\r\nconst useSwitchStyles = makeStyles({\r\n switch: {\r\n marginLeft: \"auto\",\r\n },\r\n indicator: {\r\n marginRight: 0, // Remove the default right margin so the switch aligns well on the right side inside panels like the properties pane.\r\n },\r\n});\r\n\r\n/**\r\n * This is a primitive fluent boolean switch component whose only knowledge is the shared styling across all tools\r\n * @param props\r\n * @returns Switch component\r\n */\r\nexport const Switch: FunctionComponent<FluentSwitchProps> = (props) => {\r\n const classes = useSwitchStyles();\r\n const [checked, setChecked] = useState(() => props.checked ?? false);\r\n\r\n useEffect(() => {\r\n if (props.checked != undefined) {\r\n setChecked(props.checked); // Update local state when props.checked changes\r\n }\r\n }, [props.checked]);\r\n\r\n const onChange = (event: ChangeEvent<HTMLInputElement>, data: SwitchOnChangeData) => {\r\n props.onChange && props.onChange(event, data);\r\n setChecked(event.target.checked);\r\n };\r\n\r\n return <FluentSwitch {...props} className={classes.switch} indicator={{ className: classes.indicator }} checked={checked} onChange={onChange} />;\r\n};\r\n"]}
@@ -0,0 +1,18 @@
1
+ import type { InputProps, SliderProps } from "@fluentui/react-components";
2
+ import type { FunctionComponent } from "react";
3
+ export type SyncedSliderProps = Omit<InputProps & SliderProps, "onChange" | "value"> & {
4
+ /**
5
+ * Callback to notify parent of value change, override both of the slider/input handlers
6
+ */
7
+ onChange: (value: number) => void;
8
+ /**
9
+ * Controlled value for the slider and input
10
+ */
11
+ value: number;
12
+ };
13
+ /**
14
+ * Component which synchronizes a slider and an input field, allowing the user to change a value using either control
15
+ * @param props
16
+ * @returns SyncedSlider component
17
+ */
18
+ export declare const SyncedSliderInput: FunctionComponent<SyncedSliderProps>;
@@ -0,0 +1,45 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { makeStyles, Slider } from "@fluentui/react-components";
3
+ import { Input } from "./input.js";
4
+ import { useEffect, useState } from "react";
5
+ const useSyncedSliderStyles = makeStyles({
6
+ syncedSlider: {
7
+ display: "flex",
8
+ alignItems: "center",
9
+ gap: "1rem",
10
+ width: "100%", // Only fill available space
11
+ },
12
+ slider: {
13
+ flexGrow: 1, // Let slider grow
14
+ minWidth: 0, // Allow shrink if needed
15
+ },
16
+ input: {
17
+ width: "80px", // Fixed width for number input
18
+ flexShrink: 0,
19
+ },
20
+ });
21
+ /**
22
+ * Component which synchronizes a slider and an input field, allowing the user to change a value using either control
23
+ * @param props
24
+ * @returns SyncedSlider component
25
+ */
26
+ export const SyncedSliderInput = (props) => {
27
+ const classes = useSyncedSliderStyles();
28
+ const [value, setValue] = useState(props.value);
29
+ useEffect(() => {
30
+ setValue(props.value ?? ""); // Update local state when props.value changes
31
+ }, [props.value]);
32
+ const handleSliderChange = (_, data) => {
33
+ setValue(data.value);
34
+ props.onChange(data.value); // Notify parent
35
+ };
36
+ const handleInputChange = (e) => {
37
+ const newValue = Number(e.target.value);
38
+ if (!isNaN(newValue)) {
39
+ setValue(newValue);
40
+ props.onChange(newValue); // Notify parent
41
+ }
42
+ };
43
+ return (_jsxs("div", { className: classes.syncedSlider, children: [_jsx(Slider, { ...props, className: classes.slider, value: value, onChange: handleSliderChange }), _jsx(Input, { ...props, type: "number", value: value.toString(), onChange: handleInputChange })] }));
44
+ };
45
+ //# sourceMappingURL=syncedSlider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syncedSlider.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/fluent/primitives/syncedSlider.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,MAAM,qBAAqB,GAAG,UAAU,CAAC;IACrC,YAAY,EAAE;QACV,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,QAAQ;QACpB,GAAG,EAAE,MAAM;QACX,KAAK,EAAE,MAAM,EAAE,4BAA4B;KAC9C;IACD,MAAM,EAAE;QACJ,QAAQ,EAAE,CAAC,EAAE,kBAAkB;QAC/B,QAAQ,EAAE,CAAC,EAAE,yBAAyB;KACzC;IACD,KAAK,EAAE;QACH,KAAK,EAAE,MAAM,EAAE,+BAA+B;QAC9C,UAAU,EAAE,CAAC;KAChB;CACJ,CAAC,CAAC;AAaH;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAyC,CAAC,KAAK,EAAE,EAAE;IAC7E,MAAM,OAAO,GAAG,qBAAqB,EAAE,CAAC;IACxC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAS,KAAK,CAAC,KAAK,CAAC,CAAC;IAExD,SAAS,CAAC,GAAG,EAAE;QACX,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,8CAA8C;IAC/E,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAElB,MAAM,kBAAkB,GAAG,CAAC,CAAgC,EAAE,IAAwB,EAAE,EAAE;QACtF,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,gBAAgB;IAChD,CAAC,CAAC;IAEF,MAAM,iBAAiB,GAAG,CAAC,CAAgC,EAAE,EAAE;QAC3D,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnB,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACnB,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,gBAAgB;QAC9C,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,CACH,eAAK,SAAS,EAAE,OAAO,CAAC,YAAY,aAChC,KAAC,MAAM,OAAK,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,kBAAkB,GAAI,EAC5F,KAAC,KAAK,OAAK,KAAK,EAAE,IAAI,EAAC,QAAQ,EAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,iBAAiB,GAAI,IACtF,CACT,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type { InputProps, SliderOnChangeData, SliderProps } from \"@fluentui/react-components\";\r\nimport { makeStyles, Slider } from \"@fluentui/react-components\";\r\nimport { Input } from \"./input\";\r\nimport type { ChangeEvent, FunctionComponent } from \"react\";\r\nimport { useEffect, useState } from \"react\";\r\n\r\nconst useSyncedSliderStyles = makeStyles({\r\n syncedSlider: {\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n gap: \"1rem\",\r\n width: \"100%\", // Only fill available space\r\n },\r\n slider: {\r\n flexGrow: 1, // Let slider grow\r\n minWidth: 0, // Allow shrink if needed\r\n },\r\n input: {\r\n width: \"80px\", // Fixed width for number input\r\n flexShrink: 0,\r\n },\r\n});\r\n\r\nexport type SyncedSliderProps = Omit<InputProps & SliderProps, \"onChange\" | \"value\"> & {\r\n /**\r\n * Callback to notify parent of value change, override both of the slider/input handlers\r\n */\r\n onChange: (value: number) => void;\r\n /**\r\n * Controlled value for the slider and input\r\n */\r\n value: number;\r\n};\r\n\r\n/**\r\n * Component which synchronizes a slider and an input field, allowing the user to change a value using either control\r\n * @param props\r\n * @returns SyncedSlider component\r\n */\r\nexport const SyncedSliderInput: FunctionComponent<SyncedSliderProps> = (props) => {\r\n const classes = useSyncedSliderStyles();\r\n const [value, setValue] = useState<number>(props.value);\r\n\r\n useEffect(() => {\r\n setValue(props.value ?? \"\"); // Update local state when props.value changes\r\n }, [props.value]);\r\n\r\n const handleSliderChange = (_: ChangeEvent<HTMLInputElement>, data: SliderOnChangeData) => {\r\n setValue(data.value);\r\n props.onChange(data.value); // Notify parent\r\n };\r\n\r\n const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {\r\n const newValue = Number(e.target.value);\r\n if (!isNaN(newValue)) {\r\n setValue(newValue);\r\n props.onChange(newValue); // Notify parent\r\n }\r\n };\r\n\r\n return (\r\n <div className={classes.syncedSlider}>\r\n <Slider {...props} className={classes.slider} value={value} onChange={handleSliderChange} />\r\n <Input {...props} type=\"number\" value={value.toString()} onChange={handleInputChange} />\r\n </div>\r\n );\r\n};\r\n"]}
@@ -0,0 +1 @@
1
+ export { Text } from "@fluentui/react-components";
@@ -0,0 +1,3 @@
1
+ export { Text } from "@fluentui/react-components";
2
+ // No special styling / functionality yet!
3
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/fluent/primitives/text.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElD,0CAA0C","sourcesContent":["export { Text } from \"@fluentui/react-components\";\r\n\r\n// No special styling / functionality yet!\r\n"]}
@@ -0,0 +1,8 @@
1
+ import type { TextareaProps as FluentTextareaProps } from "@fluentui/react-components";
2
+ import type { FunctionComponent } from "react";
3
+ /**
4
+ * This is a texarea box that stops propagation of change/keydown events
5
+ * @param props
6
+ * @returns
7
+ */
8
+ export declare const Textarea: FunctionComponent<FluentTextareaProps>;
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Textarea as FluentTextarea, makeStyles } from "@fluentui/react-components";
3
+ const useInputStyles = makeStyles({
4
+ textarea: {},
5
+ });
6
+ /**
7
+ * This is a texarea box that stops propagation of change/keydown events
8
+ * @param props
9
+ * @returns
10
+ */
11
+ export const Textarea = (props) => {
12
+ const classes = useInputStyles();
13
+ const handleChange = (event, data) => {
14
+ event.stopPropagation(); // Prevent event propagation
15
+ if (props.onChange) {
16
+ props.onChange(event, data); // Call the original onChange handler passed as prop
17
+ }
18
+ };
19
+ const handleKeyDown = (event) => {
20
+ event.stopPropagation(); // Prevent event propagation
21
+ if (props.onKeyDown) {
22
+ props.onKeyDown(event); // Call the original onKeyDown handler passed as prop
23
+ }
24
+ };
25
+ return _jsx(FluentTextarea, { ...props, className: classes.textarea, onChange: handleChange, onKeyDown: handleKeyDown });
26
+ };
27
+ //# sourceMappingURL=textarea.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textarea.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/fluent/primitives/textarea.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAGpF,MAAM,cAAc,GAAG,UAAU,CAAC;IAC9B,QAAQ,EAAE,EAAE;CACf,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAA2C,CAAC,KAAK,EAAE,EAAE;IACtE,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,MAAM,YAAY,GAAG,CAAC,KAAuC,EAAE,IAAS,EAAE,EAAE;QACxE,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC,4BAA4B;QACrD,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACjB,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,oDAAoD;QACrF,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,CAAC,KAAyC,EAAE,EAAE;QAChE,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC,4BAA4B;QACrD,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;YAClB,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,qDAAqD;QACjF,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,KAAC,cAAc,OAAK,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,GAAI,CAAC;AACxH,CAAC,CAAC","sourcesContent":["import type { TextareaProps as FluentTextareaProps } from \"@fluentui/react-components\";\r\nimport { Textarea as FluentTextarea, makeStyles } from \"@fluentui/react-components\";\r\nimport type { FunctionComponent, KeyboardEvent, ChangeEvent } from \"react\";\r\n\r\nconst useInputStyles = makeStyles({\r\n textarea: {},\r\n});\r\n\r\n/**\r\n * This is a texarea box that stops propagation of change/keydown events\r\n * @param props\r\n * @returns\r\n */\r\nexport const Textarea: FunctionComponent<FluentTextareaProps> = (props) => {\r\n const classes = useInputStyles();\r\n const handleChange = (event: ChangeEvent<HTMLTextAreaElement>, data: any) => {\r\n event.stopPropagation(); // Prevent event propagation\r\n if (props.onChange) {\r\n props.onChange(event, data); // Call the original onChange handler passed as prop\r\n }\r\n };\r\n\r\n const handleKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {\r\n event.stopPropagation(); // Prevent event propagation\r\n if (props.onKeyDown) {\r\n props.onKeyDown(event); // Call the original onKeyDown handler passed as prop\r\n }\r\n };\r\n\r\n return <FluentTextarea {...props} className={classes.textarea} onChange={handleChange} onKeyDown={handleKeyDown} />;\r\n};\r\n"]}
@@ -8,5 +8,7 @@ export interface IButtonLineComponentProps {
8
8
  }
9
9
  export declare class ButtonLineComponent extends React.Component<IButtonLineComponentProps> {
10
10
  constructor(props: IButtonLineComponentProps);
11
+ renderFluent(): import("react/jsx-runtime").JSX.Element;
12
+ renderOriginal(): import("react/jsx-runtime").JSX.Element;
11
13
  render(): import("react/jsx-runtime").JSX.Element;
12
14
  }
@@ -1,11 +1,19 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
+ import { ButtonLine } from "../fluent/hoc/buttonLine.js";
4
+ import { ToolContext } from "../fluent/hoc/fluentToolWrapper.js";
3
5
  export class ButtonLineComponent extends React.Component {
4
6
  constructor(props) {
5
7
  super(props);
6
8
  }
7
- render() {
9
+ renderFluent() {
10
+ return _jsx(ButtonLine, { label: this.props.label, icon: this.props.icon, title: this.props.label, onClick: this.props.onClick, disabled: this.props.isDisabled });
11
+ }
12
+ renderOriginal() {
8
13
  return (_jsxs("div", { className: "buttonLine" + (this.props.isDisabled ? " disabled" : ""), children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsx("button", { onClick: () => this.props.onClick(), children: this.props.label })] }));
9
14
  }
15
+ render() {
16
+ return _jsx(ToolContext.Consumer, { children: ({ useFluent }) => (useFluent ? this.renderFluent() : this.renderOriginal()) });
17
+ }
10
18
  }
11
19
  //# sourceMappingURL=buttonLineComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"buttonLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/buttonLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,MAAM,OAAO,mBAAoB,SAAQ,KAAK,CAAC,SAAoC;IAC/E,YAAY,KAAgC;QACxC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAEQ,MAAM;QACX,OAAO,CACH,eAAK,SAAS,EAAE,YAAY,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,aACpE,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,cAAK,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,SAAS,EAAC,MAAM,GAAG,EAC1H,iBAAQ,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,YAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAU,IACtE,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\n\r\nexport interface IButtonLineComponentProps {\r\n label: string;\r\n onClick: () => void;\r\n icon?: string;\r\n iconLabel?: string;\r\n isDisabled?: boolean;\r\n}\r\n\r\nexport class ButtonLineComponent extends React.Component<IButtonLineComponentProps> {\r\n constructor(props: IButtonLineComponentProps) {\r\n super(props);\r\n }\r\n\r\n override render() {\r\n return (\r\n <div className={\"buttonLine\" + (this.props.isDisabled ? \" disabled\" : \"\")}>\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <button onClick={() => this.props.onClick()}>{this.props.label}</button>\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"buttonLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/buttonLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAU9D,MAAM,OAAO,mBAAoB,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fluentToolWrapper\";\r\n\r\nexport interface IButtonLineComponentProps {\r\n label: string;\r\n onClick: () => void;\r\n icon?: string;\r\n iconLabel?: string;\r\n isDisabled?: boolean;\r\n}\r\n\r\nexport class ButtonLineComponent extends React.Component<IButtonLineComponentProps> {\r\n constructor(props: IButtonLineComponentProps) {\r\n super(props);\r\n }\r\n\r\n renderFluent() {\r\n return <ButtonLine label={this.props.label} icon={this.props.icon} title={this.props.label} onClick={this.props.onClick} disabled={this.props.isDisabled} />;\r\n }\r\n renderOriginal() {\r\n return (\r\n <div className={\"buttonLine\" + (this.props.isDisabled ? \" disabled\" : \"\")}>\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <button onClick={() => this.props.onClick()}>{this.props.label}</button>\r\n </div>\r\n );\r\n }\r\n\r\n override render() {\r\n return <ToolContext.Consumer>{({ useFluent }) => (useFluent ? this.renderFluent() : this.renderOriginal())}</ToolContext.Consumer>;\r\n }\r\n}\r\n"]}
@@ -33,5 +33,7 @@ export declare class CheckBoxLineComponent extends React.Component<ICheckBoxLine
33
33
  }): boolean;
34
34
  onChange(): void;
35
35
  onCopyClick(): void;
36
+ renderOriginal(): import("react/jsx-runtime").JSX.Element;
37
+ renderFluent(): import("react/jsx-runtime").JSX.Element;
36
38
  render(): import("react/jsx-runtime").JSX.Element;
37
39
  }
@@ -4,6 +4,9 @@ import { copyCommandToClipboard, getClassNameWithNamespace } from "../copyComman
4
4
  import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
5
5
  import { conflictingValuesPlaceholder } from "./targetsProxy.js";
6
6
  import copyIcon from "../imgs/copy.svg";
7
+ import { ToolContext } from "../fluent/hoc/fluentToolWrapper.js";
8
+ import { SwitchPropertyLine } from "../fluent/hoc/switchPropertyLine.js";
9
+ import { Checkbox } from "../fluent/primitives/checkbox.js";
7
10
  import toggleOnIcon40px from "../imgs/toggleOnIcon_40px.svg";
8
11
  import toggleOffIcon40px from "../imgs/toggleOffIcon_40px.svg";
9
12
  import toggleOnIcon30px from "../imgs/toggleOnIcon_30px.svg";
@@ -100,10 +103,20 @@ export class CheckBoxLineComponent extends React.Component {
100
103
  copyCommandToClipboard("undefined");
101
104
  }
102
105
  }
103
- render() {
106
+ renderOriginal() {
104
107
  const icons = this.props.large ? Icons.size40 : Icons.size30;
105
108
  const icon = this.state.isConflict ? icons.mixed : this.state.isSelected ? icons.on : icons.off;
106
109
  return (_jsxs("div", { className: "checkBoxLine", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), this.props.label && (_jsx("div", { className: "label", title: this.props.iconLabel, children: this.props.label })), this.props.faIcons && (_jsx(FontAwesomeIcon, { className: `cbx ${this.props.disabled ? "disabled" : ""}`, icon: this.state.isSelected ? this.props.faIcons.enabled : this.props.faIcons.disabled, onClick: () => !this.props.disabled && this.onChange() })), !this.props.faIcons && (_jsx("div", { className: "checkBox", children: _jsxs("label", { className: `container lbl${this.props.disabled ? " disabled" : ""} ${this.state.isSelected ? "checked" : ""}`, children: [_jsx("input", { type: "checkbox", className: `cbx hidden ${this.state.isConflict ? "conflict" : ""}`, checked: this.state.isSelected, onChange: () => this.onChange(), disabled: !!this.props.disabled }), _jsx("img", { className: "icon", src: icon, alt: this.props.label })] }) })), _jsx("div", { className: "copy hoverIcon", onClick: () => this.onCopyClick(), title: "Copy to clipboard", children: _jsx("img", { src: copyIcon, alt: "Copy" }) })] }));
107
110
  }
111
+ renderFluent() {
112
+ // if faIcons are sent (to mimic a checkbox) use fluent checkbox
113
+ if (this.props.faIcons) {
114
+ return _jsx(Checkbox, { disabled: this.props.disabled, checked: this.state.isSelected, onClick: () => !this.props.disabled && this.onChange() });
115
+ }
116
+ return _jsx(SwitchPropertyLine, { label: this.props.label || "", checked: this.state.isSelected, onChange: () => this.onChange(), disabled: !!this.props.disabled });
117
+ }
118
+ render() {
119
+ return _jsx(ToolContext.Consumer, { children: ({ useFluent }) => (useFluent ? this.renderFluent() : this.renderOriginal()) });
120
+ }
108
121
  }
109
122
  //# sourceMappingURL=checkBoxLineComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkBoxLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/checkBoxLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAE9F,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,QAAQ,MAAM,kBAAkB,CAAC;AAiBxC,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,iBAAiB,MAAM,gCAAgC,CAAC;AAC/D,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,mBAAmB,MAAM,kCAAkC,CAAC;AACnE,OAAO,iBAAiB,MAAM,gCAAgC,CAAC;AAE/D,MAAM,KAAK,GAAG;IACV,MAAM,EAAE;QACJ,EAAE,EAAE,gBAAgB;QACpB,KAAK,EAAE,mBAAmB;QAC1B,GAAG,EAAE,iBAAiB;KACzB;IACD,MAAM,EAAE;QACJ,EAAE,EAAE,gBAAgB;QACpB,KAAK,EAAE,EAAE,EAAE,WAAW;QACtB,GAAG,EAAE,iBAAiB;KACzB;CACJ,CAAC;AAEF,MAAM,OAAO,qBAAsB,SAAQ,KAAK,CAAC,SAA0G;IAEvJ,YAAY,KAAkC;QAC1C,KAAK,CAAC,KAAK,CAAC,CAAC;QAFT,iBAAY,GAAG,KAAK,CAAC;QAIzB,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YACtC,IAAI,CAAC,KAAK,GAAG;gBACT,UAAU,EAAE,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS,CA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AE,EAAE,aAChH,gBACI,IAAI,EAAC,UAAU,EACf,SAAS,EAAE,cAAc,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,EAClE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAC9B,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,EAC/B,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GACjC,EACF,cAAK,SAAS,EAAC,MAAM,EAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAI,IACtD,GACN,CACT,EACD,cAAK,SAAS,EAAC,gBAAgB,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,KAAK,EAAC,mBAAmB,YACxF,cAAK,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAC,MAAM,GAAG,GAC/B,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 { copyCommandToClipboard, getClassNameWithNamespace } from \"../copyCommandToClipboard\";\r\nimport type { IconDefinition } from \"@fortawesome/fontawesome-common-types\";\r\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\r\nimport { conflictingValuesPlaceholder } from \"./targetsProxy\";\r\nimport copyIcon from \"../imgs/copy.svg\";\r\n\r\nexport interface ICheckBoxLineComponentProps {\r\n label?: string;\r\n target?: any;\r\n propertyName?: string;\r\n isSelected?: boolean | (() => boolean);\r\n onSelect?: (value: boolean) => void;\r\n onValueChanged?: () => void;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n disabled?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n faIcons?: { enabled: IconDefinition; disabled: IconDefinition };\r\n large?: boolean;\r\n}\r\n\r\nimport toggleOnIcon40px from \"../imgs/toggleOnIcon_40px.svg\";\r\nimport toggleOffIcon40px from \"../imgs/toggleOffIcon_40px.svg\";\r\nimport toggleOnIcon30px from \"../imgs/toggleOnIcon_30px.svg\";\r\nimport toggleMixedIcon30px from \"../imgs/toggleMixedIcon_30px.svg\";\r\nimport toggleOffIcon30px from \"../imgs/toggleOffIcon_30px.svg\";\r\n\r\nconst Icons = {\r\n size30: {\r\n on: toggleOnIcon30px,\r\n mixed: toggleMixedIcon30px,\r\n off: toggleOffIcon30px,\r\n },\r\n size40: {\r\n on: toggleOnIcon40px,\r\n mixed: \"\", // unneeded\r\n off: toggleOffIcon40px,\r\n },\r\n};\r\n\r\nexport class CheckBoxLineComponent extends React.Component<ICheckBoxLineComponentProps, { isSelected: boolean; isDisabled?: boolean; isConflict: boolean }> {\r\n private _localChange = false;\r\n constructor(props: ICheckBoxLineComponentProps) {\r\n super(props);\r\n\r\n if (this.props.isSelected !== undefined) {\r\n this.state = {\r\n isSelected: typeof this.props.isSelected === \"boolean\" ? this.props.isSelected : this.props.isSelected(),\r\n isConflict: false,\r\n };\r\n } else {\r\n this.state = {\r\n isSelected: this.props.target[this.props.propertyName!] === true,\r\n isConflict: this.props.target[this.props.propertyName!] === conflictingValuesPlaceholder,\r\n };\r\n }\r\n\r\n if (this.props.disabled) {\r\n this.state = { ...this.state, isDisabled: this.props.disabled };\r\n }\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: ICheckBoxLineComponentProps, nextState: { isSelected: boolean; isDisabled: boolean; isConflict: boolean }) {\r\n let selected: boolean;\r\n\r\n if (nextProps.isSelected !== undefined) {\r\n selected = typeof nextProps.isSelected === \"boolean\" ? nextProps.isSelected : nextProps.isSelected();\r\n } else {\r\n selected = nextProps.target[nextProps.propertyName!] === true;\r\n if (nextProps.target[nextProps.propertyName!] === conflictingValuesPlaceholder) {\r\n nextState.isConflict = true;\r\n }\r\n }\r\n\r\n if (selected !== nextState.isSelected || this._localChange) {\r\n nextState.isSelected = selected;\r\n this._localChange = false;\r\n return true;\r\n }\r\n\r\n if (nextProps.disabled !== nextState.isDisabled) {\r\n return true;\r\n }\r\n\r\n return nextProps.label !== this.props.label || nextProps.target !== this.props.target || nextState.isConflict !== this.state.isConflict;\r\n }\r\n\r\n onChange() {\r\n this._localChange = true;\r\n if (this.props.onSelect) {\r\n this.props.onSelect(!this.state.isSelected);\r\n } else {\r\n if (this.props.onPropertyChangedObservable) {\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: this.props.target,\r\n property: this.props.propertyName!,\r\n value: !this.state.isSelected,\r\n initialValue: this.state.isSelected,\r\n });\r\n }\r\n\r\n if (this.props.target && this.props.propertyName) {\r\n this.props.target[this.props.propertyName] = !this.state.isSelected;\r\n }\r\n }\r\n\r\n if (this.props.onValueChanged) {\r\n this.props.onValueChanged();\r\n }\r\n\r\n this.setState({ isSelected: !this.state.isSelected, isConflict: false });\r\n }\r\n\r\n // Copy to clipboard the code this checkbox actually does\r\n // Example : mesh.checkCollisions = true;\r\n onCopyClick() {\r\n if (this.props && this.props.target) {\r\n const { className, babylonNamespace } = getClassNameWithNamespace(this.props.target);\r\n const targetName = \"globalThis.debugNode\";\r\n const targetProperty = this.props.propertyName;\r\n const value = this.props.target[this.props.propertyName!];\r\n const strCommand = targetName + \".\" + targetProperty + \" = \" + value + \";// (debugNode as \" + babylonNamespace + className + \")\";\r\n copyCommandToClipboard(strCommand);\r\n } else {\r\n copyCommandToClipboard(\"undefined\");\r\n }\r\n }\r\n\r\n override render() {\r\n const icons = this.props.large ? Icons.size40 : Icons.size30;\r\n const icon = this.state.isConflict ? icons.mixed : this.state.isSelected ? icons.on : icons.off;\r\n return (\r\n <div className=\"checkBoxLine\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n {this.props.label && (\r\n <div className=\"label\" title={this.props.iconLabel}>\r\n {this.props.label}\r\n </div>\r\n )}\r\n {this.props.faIcons && (\r\n <FontAwesomeIcon\r\n className={`cbx ${this.props.disabled ? \"disabled\" : \"\"}`}\r\n icon={this.state.isSelected ? this.props.faIcons.enabled : this.props.faIcons.disabled}\r\n onClick={() => !this.props.disabled && this.onChange()}\r\n />\r\n )}\r\n {!this.props.faIcons && (\r\n <div className=\"checkBox\">\r\n <label className={`container lbl${this.props.disabled ? \" disabled\" : \"\"} ${this.state.isSelected ? \"checked\" : \"\"}`}>\r\n <input\r\n type=\"checkbox\"\r\n className={`cbx hidden ${this.state.isConflict ? \"conflict\" : \"\"}`}\r\n checked={this.state.isSelected}\r\n onChange={() => this.onChange()}\r\n disabled={!!this.props.disabled}\r\n />\r\n <img className=\"icon\" src={icon} alt={this.props.label} />\r\n </label>\r\n </div>\r\n )}\r\n <div className=\"copy hoverIcon\" onClick={() => this.onCopyClick()} title=\"Copy to clipboard\">\r\n <img src={copyIcon} alt=\"Copy\" />\r\n </div>\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"checkBoxLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/checkBoxLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAE9F,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,QAAQ,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAiBzD,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,iBAAiB,MAAM,gCAAgC,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,EAAE,KAAK,EAAC,mBAAmB,YACxF,cAAK,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAC,MAAM,GAAG,GAC/B,IACJ,CACT,CAAC;IACN,CAAC;IAED,YAAY;QACR,gEAAgE;QAChE,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YACrB,OAAO,KAAC,QAAQ,IAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAAE,GAAI,CAAC;QAC/I,CAAC;QACD,OAAO,KAAC,kBAAkB,IAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAI,CAAC;IACnK,CAAC;IAEQ,MAAM;QACX,OAAO,KAAC,WAAW,CAAC,QAAQ,cAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,GAAwB,CAAC;IACvI,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport type { PropertyChangedEvent } from \"./../propertyChangedEvent\";\r\nimport { copyCommandToClipboard, getClassNameWithNamespace } from \"../copyCommandToClipboard\";\r\nimport type { IconDefinition } from \"@fortawesome/fontawesome-common-types\";\r\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\r\nimport { conflictingValuesPlaceholder } from \"./targetsProxy\";\r\nimport copyIcon from \"../imgs/copy.svg\";\r\nimport { ToolContext } from \"../fluent/hoc/fluentToolWrapper\";\r\nimport { SwitchPropertyLine } from \"../fluent/hoc/switchPropertyLine\";\r\nimport { Checkbox } from \"../fluent/primitives/checkbox\";\r\n\r\nexport interface ICheckBoxLineComponentProps {\r\n label?: string;\r\n target?: any;\r\n propertyName?: string;\r\n isSelected?: boolean | (() => boolean);\r\n onSelect?: (value: boolean) => void;\r\n onValueChanged?: () => void;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n disabled?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n faIcons?: { enabled: IconDefinition; disabled: IconDefinition };\r\n large?: boolean;\r\n}\r\n\r\nimport toggleOnIcon40px from \"../imgs/toggleOnIcon_40px.svg\";\r\nimport toggleOffIcon40px from \"../imgs/toggleOffIcon_40px.svg\";\r\nimport toggleOnIcon30px from \"../imgs/toggleOnIcon_30px.svg\";\r\nimport toggleMixedIcon30px from \"../imgs/toggleMixedIcon_30px.svg\";\r\nimport toggleOffIcon30px from \"../imgs/toggleOffIcon_30px.svg\";\r\n\r\nconst Icons = {\r\n size30: {\r\n on: toggleOnIcon30px,\r\n mixed: toggleMixedIcon30px,\r\n off: toggleOffIcon30px,\r\n },\r\n size40: {\r\n on: toggleOnIcon40px,\r\n mixed: \"\", // unneeded\r\n off: toggleOffIcon40px,\r\n },\r\n};\r\n\r\nexport class CheckBoxLineComponent extends React.Component<ICheckBoxLineComponentProps, { isSelected: boolean; isDisabled?: boolean; isConflict: boolean }> {\r\n private _localChange = false;\r\n constructor(props: ICheckBoxLineComponentProps) {\r\n super(props);\r\n\r\n if (this.props.isSelected !== undefined) {\r\n this.state = {\r\n isSelected: typeof this.props.isSelected === \"boolean\" ? this.props.isSelected : this.props.isSelected(),\r\n isConflict: false,\r\n };\r\n } else {\r\n this.state = {\r\n isSelected: this.props.target[this.props.propertyName!] === true,\r\n isConflict: this.props.target[this.props.propertyName!] === conflictingValuesPlaceholder,\r\n };\r\n }\r\n\r\n if (this.props.disabled) {\r\n this.state = { ...this.state, isDisabled: this.props.disabled };\r\n }\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: ICheckBoxLineComponentProps, nextState: { isSelected: boolean; isDisabled: boolean; isConflict: boolean }) {\r\n let selected: boolean;\r\n\r\n if (nextProps.isSelected !== undefined) {\r\n selected = typeof nextProps.isSelected === \"boolean\" ? nextProps.isSelected : nextProps.isSelected();\r\n } else {\r\n selected = nextProps.target[nextProps.propertyName!] === true;\r\n if (nextProps.target[nextProps.propertyName!] === conflictingValuesPlaceholder) {\r\n nextState.isConflict = true;\r\n }\r\n }\r\n\r\n if (selected !== nextState.isSelected || this._localChange) {\r\n nextState.isSelected = selected;\r\n this._localChange = false;\r\n return true;\r\n }\r\n\r\n if (nextProps.disabled !== nextState.isDisabled) {\r\n return true;\r\n }\r\n\r\n return nextProps.label !== this.props.label || nextProps.target !== this.props.target || nextState.isConflict !== this.state.isConflict;\r\n }\r\n\r\n onChange() {\r\n this._localChange = true;\r\n if (this.props.onSelect) {\r\n this.props.onSelect(!this.state.isSelected);\r\n } else {\r\n if (this.props.onPropertyChangedObservable) {\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: this.props.target,\r\n property: this.props.propertyName!,\r\n value: !this.state.isSelected,\r\n initialValue: this.state.isSelected,\r\n });\r\n }\r\n\r\n if (this.props.target && this.props.propertyName) {\r\n this.props.target[this.props.propertyName] = !this.state.isSelected;\r\n }\r\n }\r\n\r\n if (this.props.onValueChanged) {\r\n this.props.onValueChanged();\r\n }\r\n\r\n this.setState({ isSelected: !this.state.isSelected, isConflict: false });\r\n }\r\n\r\n // Copy to clipboard the code this checkbox actually does\r\n // Example : mesh.checkCollisions = true;\r\n onCopyClick() {\r\n if (this.props && this.props.target) {\r\n const { className, babylonNamespace } = getClassNameWithNamespace(this.props.target);\r\n const targetName = \"globalThis.debugNode\";\r\n const targetProperty = this.props.propertyName;\r\n const value = this.props.target[this.props.propertyName!];\r\n const strCommand = targetName + \".\" + targetProperty + \" = \" + value + \";// (debugNode as \" + babylonNamespace + className + \")\";\r\n copyCommandToClipboard(strCommand);\r\n } else {\r\n copyCommandToClipboard(\"undefined\");\r\n }\r\n }\r\n\r\n renderOriginal() {\r\n const icons = this.props.large ? Icons.size40 : Icons.size30;\r\n const icon = this.state.isConflict ? icons.mixed : this.state.isSelected ? icons.on : icons.off;\r\n return (\r\n <div className=\"checkBoxLine\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n {this.props.label && (\r\n <div className=\"label\" title={this.props.iconLabel}>\r\n {this.props.label}\r\n </div>\r\n )}\r\n {this.props.faIcons && (\r\n <FontAwesomeIcon\r\n className={`cbx ${this.props.disabled ? \"disabled\" : \"\"}`}\r\n icon={this.state.isSelected ? this.props.faIcons.enabled : this.props.faIcons.disabled}\r\n onClick={() => !this.props.disabled && this.onChange()}\r\n />\r\n )}\r\n {!this.props.faIcons && (\r\n <div className=\"checkBox\">\r\n <label className={`container lbl${this.props.disabled ? \" disabled\" : \"\"} ${this.state.isSelected ? \"checked\" : \"\"}`}>\r\n <input\r\n type=\"checkbox\"\r\n className={`cbx hidden ${this.state.isConflict ? \"conflict\" : \"\"}`}\r\n checked={this.state.isSelected}\r\n onChange={() => this.onChange()}\r\n disabled={!!this.props.disabled}\r\n />\r\n <img className=\"icon\" src={icon} alt={this.props.label} />\r\n </label>\r\n </div>\r\n )}\r\n <div className=\"copy hoverIcon\" onClick={() => this.onCopyClick()} title=\"Copy to clipboard\">\r\n <img src={copyIcon} alt=\"Copy\" />\r\n </div>\r\n </div>\r\n );\r\n }\r\n\r\n renderFluent() {\r\n // if faIcons are sent (to mimic a checkbox) use fluent checkbox\r\n if (this.props.faIcons) {\r\n return <Checkbox disabled={this.props.disabled} checked={this.state.isSelected} onClick={() => !this.props.disabled && this.onChange()} />;\r\n }\r\n return <SwitchPropertyLine label={this.props.label || \"\"} checked={this.state.isSelected} onChange={() => this.onChange()} disabled={!!this.props.disabled} />;\r\n }\r\n\r\n override render() {\r\n return <ToolContext.Consumer>{({ useFluent }) => (useFluent ? this.renderFluent() : this.renderOriginal())}</ToolContext.Consumer>;\r\n }\r\n}\r\n"]}
@@ -33,6 +33,8 @@ export declare class OptionsLine extends React.Component<IOptionsLineProps, {
33
33
  raiseOnPropertyChanged(newValue: number, previousValue: number): void;
34
34
  setValue(value: string | number): void;
35
35
  updateValue(valueString: string): void;
36
- onCopyClick(): void;
36
+ onCopyClickStr(): string;
37
+ private _renderFluent;
38
+ private _renderOriginal;
37
39
  render(): import("react/jsx-runtime").JSX.Element;
38
40
  }
@@ -2,6 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import { copyCommandToClipboard, getClassNameWithNamespace } from "../copyCommandToClipboard.js";
4
4
  import copyIcon from "../imgs/copy.svg";
5
+ import { PropertyLine } from "../fluent/hoc/propertyLine.js";
6
+ import { Dropdown } from "../fluent/primitives/dropdown.js";
7
+ import { ToolContext } from "../fluent/hoc/fluentToolWrapper.js";
5
8
  // eslint-disable-next-line @typescript-eslint/naming-convention
6
9
  export const Null_Value = Number.MAX_SAFE_INTEGER;
7
10
  export class OptionsLine extends React.Component {
@@ -65,23 +68,31 @@ export class OptionsLine extends React.Component {
65
68
  }
66
69
  // Copy to clipboard the code this option actually does
67
70
  // Example : material.sideOrientation = 1;
68
- onCopyClick() {
71
+ onCopyClickStr() {
69
72
  if (this.props && this.props.target) {
70
73
  const { className, babylonNamespace } = getClassNameWithNamespace(this.props.target);
71
74
  const targetName = "globalThis.debugNode";
72
75
  const targetProperty = this.props.propertyName;
73
76
  const value = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];
74
77
  const strCommand = targetName + "." + targetProperty + " = " + value + ";// (debugNode as " + babylonNamespace + className + ")";
75
- copyCommandToClipboard(strCommand);
78
+ return strCommand;
76
79
  }
77
80
  else {
78
- copyCommandToClipboard("undefined");
81
+ return "undefined";
79
82
  }
80
83
  }
81
- render() {
84
+ _renderFluent() {
85
+ return (_jsx(PropertyLine, { label: this.props.label, onCopy: () => this.onCopyClickStr(), children: _jsx(Dropdown, { options: this.props.options, onSelect: (val) => {
86
+ val !== undefined && this.updateValue(val);
87
+ }, defaultValue: this.props.options.find((o) => o.value === this.state.value || o.selected) }) }));
88
+ }
89
+ _renderOriginal() {
82
90
  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: this.state.value ?? "", children: this.props.options.map((option, i) => {
83
91
  return (_jsx("option", { selected: option.selected, value: option.value, title: option.label, children: option.label }, option.label + i));
84
- }) }) }), _jsx("div", { className: "copy hoverIcon", onClick: () => this.onCopyClick(), title: "Copy to clipboard", children: _jsx("img", { src: copyIcon, alt: "Copy" }) })] }));
92
+ }) }) }), _jsx("div", { className: "copy hoverIcon", onClick: () => copyCommandToClipboard(this.onCopyClickStr()), title: "Copy to clipboard", children: _jsx("img", { src: copyIcon, alt: "Copy" }) })] }));
93
+ }
94
+ render() {
95
+ return _jsx(ToolContext.Consumer, { children: ({ useFluent }) => (useFluent ? this._renderFluent() : this._renderOriginal()) });
85
96
  }
86
97
  }
87
98
  //# 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;AAG/B,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAE9F,OAAO,QAAQ,MAA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,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,EACN,cAAK,SAAS,EAAC,gBAAgB,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,KAAK,EAAC,mBAAmB,YACxF,cAAK,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAC,MAAM,GAAG,GAC/B,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 { copyCommandToClipboard, getClassNameWithNamespace } from \"../copyCommandToClipboard\";\r\nimport type { IInspectableOptions } from \"core/Misc/iInspectable\";\r\nimport copyIcon from \"../imgs/copy.svg\";\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 IOptionsLineProps {\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 OptionsLine extends React.Component<IOptionsLineProps, { 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: IOptionsLineProps) {\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: IOptionsLineProps) {\r\n super(props);\r\n\r\n this.state = { value: this._remapValueIn(this._getValue(props)) };\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IOptionsLineProps, 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 // Copy to clipboard the code this option actually does\r\n // Example : material.sideOrientation = 1;\r\n onCopyClick() {\r\n if (this.props && this.props.target) {\r\n const { className, babylonNamespace } = getClassNameWithNamespace(this.props.target);\r\n const targetName = \"globalThis.debugNode\";\r\n const targetProperty = this.props.propertyName;\r\n const value = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];\r\n const strCommand = targetName + \".\" + targetProperty + \" = \" + value + \";// (debugNode as \" + babylonNamespace + className + \")\";\r\n copyCommandToClipboard(strCommand);\r\n } else {\r\n copyCommandToClipboard(\"undefined\");\r\n }\r\n }\r\n\r\n override 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 className=\"copy hoverIcon\" onClick={() => this.onCopyClick()} title=\"Copy to clipboard\">\r\n <img src={copyIcon} alt=\"Copy\" />\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;AAG/B,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAE9F,OAAO,QAAQ,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MA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CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,GAAwB,CAAC;IACzI,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport { copyCommandToClipboard, getClassNameWithNamespace } from \"../copyCommandToClipboard\";\r\nimport type { IInspectableOptions } from \"core/Misc/iInspectable\";\r\nimport copyIcon from \"../imgs/copy.svg\";\r\nimport { PropertyLine } from \"../fluent/hoc/propertyLine\";\r\nimport { Dropdown } from \"../fluent/primitives/dropdown\";\r\nimport { ToolContext } from \"../fluent/hoc/fluentToolWrapper\";\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 IOptionsLineProps {\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 OptionsLine extends React.Component<IOptionsLineProps, { 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: IOptionsLineProps) {\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: IOptionsLineProps) {\r\n super(props);\r\n\r\n this.state = { value: this._remapValueIn(this._getValue(props)) };\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IOptionsLineProps, 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 // Copy to clipboard the code this option actually does\r\n // Example : material.sideOrientation = 1;\r\n onCopyClickStr() {\r\n if (this.props && this.props.target) {\r\n const { className, babylonNamespace } = getClassNameWithNamespace(this.props.target);\r\n const targetName = \"globalThis.debugNode\";\r\n const targetProperty = this.props.propertyName;\r\n const value = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];\r\n const strCommand = targetName + \".\" + targetProperty + \" = \" + value + \";// (debugNode as \" + babylonNamespace + className + \")\";\r\n return strCommand;\r\n } else {\r\n return \"undefined\";\r\n }\r\n }\r\n\r\n private _renderFluent() {\r\n return (\r\n <PropertyLine label={this.props.label} onCopy={() => this.onCopyClickStr()}>\r\n <Dropdown\r\n options={this.props.options}\r\n onSelect={(val: string) => {\r\n val !== undefined && this.updateValue(val);\r\n }}\r\n defaultValue={this.props.options.find((o) => o.value === this.state.value || o.selected)}\r\n />\r\n </PropertyLine>\r\n );\r\n }\r\n\r\n private _renderOriginal() {\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 className=\"copy hoverIcon\" onClick={() => copyCommandToClipboard(this.onCopyClickStr())} title=\"Copy to clipboard\">\r\n <img src={copyIcon} alt=\"Copy\" />\r\n </div>\r\n </div>\r\n );\r\n }\r\n override render() {\r\n return <ToolContext.Consumer>{({ useFluent }) => (useFluent ? this._renderFluent() : this._renderOriginal())}</ToolContext.Consumer>;\r\n }\r\n}\r\n"]}
@@ -34,6 +34,8 @@ export declare class SliderLineComponent extends React.Component<ISliderLineComp
34
34
  onInput(newValueString: any): void;
35
35
  prepareDataToRead(value: number): number;
36
36
  onCopyClick(): void;
37
+ renderFluent(): import("react/jsx-runtime").JSX.Element;
38
+ renderOriginal(): import("react/jsx-runtime").JSX.Element;
37
39
  render(): import("react/jsx-runtime").JSX.Element;
38
40
  }
39
41
  export {};
@@ -4,6 +4,8 @@ import { copyCommandToClipboard, getClassNameWithNamespace } from "../copyComman
4
4
  import { Tools } from "@babylonjs/core/Misc/tools.js";
5
5
  import { FloatLineComponent } from "./floatLineComponent.js";
6
6
  import copyIcon from "../imgs/copy.svg";
7
+ import { ToolContext } from "../fluent/hoc/fluentToolWrapper.js";
8
+ import { SyncedSliderLine } from "../fluent/hoc/syncedSliderLine.js";
7
9
  export class SliderLineComponent extends React.Component {
8
10
  constructor(props) {
9
11
  super(props);
@@ -98,7 +100,10 @@ export class SliderLineComponent extends React.Component {
98
100
  copyCommandToClipboard("undefined");
99
101
  }
100
102
  }
101
- render() {
103
+ renderFluent() {
104
+ return (_jsx(SyncedSliderLine, { label: this.props.label, target: this.state, propertyKey: "value", onChange: (val) => this.onChange(val), step: this.props.step, min: this.props.minimum, max: this.props.maximum }));
105
+ }
106
+ renderOriginal() {
102
107
  return (_jsxs("div", { className: "sliderLine", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), (!this.props.icon || this.props.label != "") && (_jsx("div", { className: this.props.margin ? "label withMargins" : "label", title: this.props.label, children: this.props.label })), _jsx(FloatLineComponent, { lockObject: this.props.lockObject, isInteger: this.props.decimalCount === 0, smallUI: true, label: "", target: this.state, digits: this.props.decimalCount === undefined ? 4 : this.props.decimalCount, propertyName: "value", min: this.props.allowOverflow ? undefined : this.props.minimum, max: this.props.allowOverflow ? undefined : this.props.maximum, onEnter: () => {
103
108
  const changed = this.prepareDataToRead(this.state.value);
104
109
  this.onChange(changed);
@@ -107,5 +112,8 @@ export class SliderLineComponent extends React.Component {
107
112
  this.onChange(changed);
108
113
  }, onPropertyChangedObservable: this.props.onPropertyChangedObservable, unit: this.props.unit }), _jsx("div", { className: "slider", children: _jsx("input", { className: "range" + (this.props.allowOverflow && (this.state.value > this.props.maximum || this.state.value < this.props.minimum) ? " overflow" : ""), type: "range", step: this.props.step, min: this.prepareDataToRead(this.props.minimum), max: this.prepareDataToRead(this.props.maximum), value: this.prepareDataToRead(this.state.value), onInput: (evt) => this.onInput(evt.target.value), onChange: (evt) => this.onChange(evt.target.value) }) }), _jsx("div", { className: "copy hoverIcon", onClick: () => this.onCopyClick(), title: "Copy to clipboard", children: _jsx("img", { src: copyIcon, alt: "Copy" }) })] }));
109
114
  }
115
+ render() {
116
+ return _jsx(ToolContext.Consumer, { children: ({ useFluent }) => (useFluent ? this.renderFluent() : this.renderOriginal()) });
117
+ }
110
118
  }
111
119
  //# sourceMappingURL=sliderLineComponent.js.map