@babylonjs/shared-ui-components 8.5.0 → 8.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/layout/utils.js +4 -0
- package/components/layout/utils.js.map +1 -1
- package/components/lines/ColorLineComponent.js +5 -4
- package/components/lines/ColorLineComponent.js.map +1 -1
- package/components/lines/FileButtonLineComponent.d.ts +1 -1
- package/components/lines/FileButtonLineComponent.js +2 -2
- package/components/lines/FileButtonLineComponent.js.map +1 -1
- package/components/lines/OptionsLineComponent.js +3 -3
- package/components/lines/OptionsLineComponent.js.map +1 -1
- package/components/reactGraphSystem/GraphLinesContainer.js +1 -0
- package/components/reactGraphSystem/GraphLinesContainer.js.map +1 -1
- package/components/reactGraphSystem/NodeRenderer.js +2 -2
- package/components/reactGraphSystem/NodeRenderer.js.map +1 -1
- package/components/reactGraphSystem/useGraphContext.js +1 -0
- package/components/reactGraphSystem/useGraphContext.js.map +1 -1
- package/constToOptionsMaps.d.ts +3 -3
- package/constToOptionsMaps.js +5 -5
- package/constToOptionsMaps.js.map +1 -1
- package/copyCommandToClipboard.js +8 -6
- package/copyCommandToClipboard.js.map +1 -1
- package/historyStack.js +2 -1
- package/historyStack.js.map +1 -1
- package/lines/checkBoxLineComponent.js.map +1 -1
- package/lines/colorLineComponent.js +6 -5
- package/lines/colorLineComponent.js.map +1 -1
- package/lines/fileButtonLineComponent.d.ts +1 -1
- package/lines/fileButtonLineComponent.js +2 -2
- package/lines/fileButtonLineComponent.js.map +1 -1
- package/lines/fileMultipleButtonLineComponent.d.ts +1 -1
- package/lines/fileMultipleButtonLineComponent.js +2 -2
- package/lines/fileMultipleButtonLineComponent.js.map +1 -1
- package/lines/floatLineComponent.js.map +1 -1
- package/lines/optionsLineComponent.js.map +1 -1
- package/lines/sliderLineComponent.js +2 -1
- package/lines/sliderLineComponent.js.map +1 -1
- package/lines/targetsProxy.js +6 -2
- package/lines/targetsProxy.js.map +1 -1
- package/lines/textInputLineComponent.js +4 -4
- package/lines/textInputLineComponent.js.map +1 -1
- package/lines/textureButtonLineComponent.d.ts +1 -1
- package/lines/textureButtonLineComponent.js +2 -2
- package/lines/textureButtonLineComponent.js.map +1 -1
- package/lines/unitButton.js +2 -1
- package/lines/unitButton.js.map +1 -1
- package/nodeGraphSystem/frameNodePort.js.map +1 -1
- package/nodeGraphSystem/graphCanvas.js.map +1 -1
- package/nodeGraphSystem/graphFrame.js +6 -5
- package/nodeGraphSystem/graphFrame.js.map +1 -1
- package/nodeGraphSystem/graphNode.js.map +1 -1
- package/nodeGraphSystem/interfaces/displayManager.js.map +1 -1
- package/nodeGraphSystem/nodeLink.js.map +1 -1
- package/nodeGraphSystem/nodePort.js.map +1 -1
- package/nodeGraphSystem/searchBox.js.map +1 -1
- package/nodeGraphSystem/tools.js +3 -3
- package/nodeGraphSystem/tools.js.map +1 -1
- package/package.json +1 -1
- package/popupHelper.js.map +1 -1
- package/stringTools.js +6 -6
- package/stringTools.js.map +1 -1
@@ -5,6 +5,7 @@
|
|
5
5
|
* @param row
|
6
6
|
* @returns
|
7
7
|
*/
|
8
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
8
9
|
export const getPosInLayout = (layout, column, row) => {
|
9
10
|
if (!layout.columns) {
|
10
11
|
throw new Error("Attempted to get position on empty layout");
|
@@ -24,6 +25,7 @@ export const getPosInLayout = (layout, column, row) => {
|
|
24
25
|
* @param column
|
25
26
|
* @param row
|
26
27
|
*/
|
28
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
27
29
|
export const removeLayoutRowAndRedistributePercentages = (layout, column, row) => {
|
28
30
|
if (!layout.columns) {
|
29
31
|
throw new Error("Attempted to get position on empty layout");
|
@@ -54,6 +56,7 @@ export const removeLayoutRowAndRedistributePercentages = (layout, column, row) =
|
|
54
56
|
* @param p2 the number
|
55
57
|
* @returns the sum of the percentage string and the number
|
56
58
|
*/
|
59
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
57
60
|
export const addPercentageStringToNumber = (p1, p2) => {
|
58
61
|
// Convert both values to numbers
|
59
62
|
const np1 = Number.parseFloat(p1.replace("%", ""));
|
@@ -66,6 +69,7 @@ export const addPercentageStringToNumber = (p1, p2) => {
|
|
66
69
|
* @param p the percentage string
|
67
70
|
* @returns the parsed number
|
68
71
|
*/
|
72
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
69
73
|
export const parsePercentage = (p) => {
|
70
74
|
return Number.parseFloat(p.replace("%", ""));
|
71
75
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/layout/utils.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAc,EAAE,MAAc,EAAE,GAAY,EAAgC,EAAE;IACzG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IACjE,CAAC;IACD,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,IAAI,CAAC,YAAY,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IACjE,CAAC;IACD,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACpB,OAAO,YAAY,CAAC;IACxB,CAAC;IACD,OAAO,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yCAAyC,GAAG,CAAC,MAAc,EAAE,MAAc,EAAE,GAAW,EAAE,EAAE;IACrG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IACjE,CAAC;IACD,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CA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;IACjD,OAAO,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC","sourcesContent":["import type { Layout, LayoutColumn, LayoutTabsRow } from \"./types\";\r\n\r\n/**\r\n * Given a column and row number in the layout, return the corresponding column/row\r\n * @param layout\r\n * @param column\r\n * @param row\r\n * @returns\r\n */\r\nexport const getPosInLayout = (layout: Layout, column: number, row?: number): LayoutColumn | LayoutTabsRow => {\r\n if (!layout.columns) {\r\n throw new Error(\"Attempted to get position on empty layout\");\r\n }\r\n const columnLayout = layout.columns[column];\r\n if (!columnLayout) {\r\n throw new Error(\"Attempted to get an invalid layout column\");\r\n }\r\n if (row === undefined) {\r\n return columnLayout;\r\n }\r\n return columnLayout.rows[row];\r\n};\r\n\r\n/**\r\n * Remove a row in position row, column from the layout, and redistribute heights of remaining rows\r\n * @param layout\r\n * @param column\r\n * @param row\r\n */\r\nexport const removeLayoutRowAndRedistributePercentages = (layout: Layout, column: number, row: number) => {\r\n if (!layout.columns) {\r\n throw new Error(\"Attempted to get position on empty layout\");\r\n }\r\n const columnLayout = layout.columns[column];\r\n if (!columnLayout) {\r\n throw new Error(\"Attempted to get an invalid layout column\");\r\n }\r\n const rowLayout = columnLayout.rows[row];\r\n if (!rowLayout) {\r\n throw new Error(\"Attempted to get an invalid layout row\");\r\n }\r\n const rowHeight = rowLayout.height;\r\n if (rowHeight === undefined) {\r\n throw new Error(\"Attempted to remove a row with no height\");\r\n }\r\n // Remove row from layout\r\n columnLayout.rows.splice(row, 1);\r\n\r\n // Redistribute this row's height to the remaining rows\r\n const percToAdd = parsePercentage(rowHeight) / columnLayout.rows.length;\r\n columnLayout.rows.forEach((row: any) => {\r\n row.height = addPercentageStringToNumber(row.height, percToAdd) + \"%\";\r\n });\r\n};\r\n\r\n/**\r\n * Add a percentage string to a number\r\n * @param p1 the percentage string\r\n * @param p2 the number\r\n * @returns the sum of the percentage string and the number\r\n */\r\nexport const addPercentageStringToNumber = (p1: string, p2: number): number => {\r\n // Convert both values to numbers\r\n const np1 = Number.parseFloat(p1.replace(\"%\", \"\"));\r\n const np2 = p2;\r\n\r\n const nr = np1 + np2;\r\n return nr;\r\n};\r\n\r\n/**\r\n * Parses a percentage string into a number\r\n * @param p the percentage string\r\n * @returns the parsed number\r\n */\r\nexport const parsePercentage = (p: string): number => {\r\n return Number.parseFloat(p.replace(\"%\", \"\"));\r\n};\r\n"]}
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/layout/utils.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAc,EAAE,MAAc,EAAE,GAAY,EAAgC,EAAE;IACzG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IACjE,CAAC;IACD,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,IAAI,CAAC,YAAY,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IACjE,CAAC;IACD,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACpB,OAAO,YAAY,CAAC;IACxB,CAAC;IACD,OAAO,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF;;;;;GAKG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,yCAAyC,GAAG,CAAC,MAAc,EAAE,MAAc,EAAE,GAAW,EAAE,EAAE;IACrG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IACjE,CAAC;IACD,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,IAA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AS,EAAU,EAAE;IACjD,OAAO,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC","sourcesContent":["import type { Layout, LayoutColumn, LayoutTabsRow } from \"./types\";\r\n\r\n/**\r\n * Given a column and row number in the layout, return the corresponding column/row\r\n * @param layout\r\n * @param column\r\n * @param row\r\n * @returns\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const getPosInLayout = (layout: Layout, column: number, row?: number): LayoutColumn | LayoutTabsRow => {\r\n if (!layout.columns) {\r\n throw new Error(\"Attempted to get position on empty layout\");\r\n }\r\n const columnLayout = layout.columns[column];\r\n if (!columnLayout) {\r\n throw new Error(\"Attempted to get an invalid layout column\");\r\n }\r\n if (row === undefined) {\r\n return columnLayout;\r\n }\r\n return columnLayout.rows[row];\r\n};\r\n\r\n/**\r\n * Remove a row in position row, column from the layout, and redistribute heights of remaining rows\r\n * @param layout\r\n * @param column\r\n * @param row\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const removeLayoutRowAndRedistributePercentages = (layout: Layout, column: number, row: number) => {\r\n if (!layout.columns) {\r\n throw new Error(\"Attempted to get position on empty layout\");\r\n }\r\n const columnLayout = layout.columns[column];\r\n if (!columnLayout) {\r\n throw new Error(\"Attempted to get an invalid layout column\");\r\n }\r\n const rowLayout = columnLayout.rows[row];\r\n if (!rowLayout) {\r\n throw new Error(\"Attempted to get an invalid layout row\");\r\n }\r\n const rowHeight = rowLayout.height;\r\n if (rowHeight === undefined) {\r\n throw new Error(\"Attempted to remove a row with no height\");\r\n }\r\n // Remove row from layout\r\n columnLayout.rows.splice(row, 1);\r\n\r\n // Redistribute this row's height to the remaining rows\r\n const percToAdd = parsePercentage(rowHeight) / columnLayout.rows.length;\r\n columnLayout.rows.forEach((row: any) => {\r\n row.height = addPercentageStringToNumber(row.height, percToAdd) + \"%\";\r\n });\r\n};\r\n\r\n/**\r\n * Add a percentage string to a number\r\n * @param p1 the percentage string\r\n * @param p2 the number\r\n * @returns the sum of the percentage string and the number\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const addPercentageStringToNumber = (p1: string, p2: number): number => {\r\n // Convert both values to numbers\r\n const np1 = Number.parseFloat(p1.replace(\"%\", \"\"));\r\n const np2 = p2;\r\n\r\n const nr = np1 + np2;\r\n return nr;\r\n};\r\n\r\n/**\r\n * Parses a percentage string into a number\r\n * @param p the percentage string\r\n * @returns the parsed number\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const parsePercentage = (p: string): number => {\r\n return Number.parseFloat(p.replace(\"%\", \"\"));\r\n};\r\n"]}
|
@@ -8,7 +8,7 @@ import { ColorPickerLineComponent } from "./ColorPickerLineComponent.js";
|
|
8
8
|
import * as style from "./ColorLineComponent.module.scss";
|
9
9
|
import copyIcon from "../../imgs/copy.svg";
|
10
10
|
import { JoinClassNames } from "../classNames.js";
|
11
|
-
const
|
11
|
+
const EmptyColor = new Color4(0, 0, 0, 0);
|
12
12
|
export class ColorLineComponent extends React.Component {
|
13
13
|
constructor(props) {
|
14
14
|
super(props);
|
@@ -35,8 +35,9 @@ export class ColorLineComponent extends React.Component {
|
|
35
35
|
getValue(props = this.props) {
|
36
36
|
const target = props.target;
|
37
37
|
const property = target[props.propertyName];
|
38
|
-
if (!property)
|
39
|
-
return
|
38
|
+
if (!property) {
|
39
|
+
return EmptyColor;
|
40
|
+
}
|
40
41
|
if (typeof property === "string") {
|
41
42
|
// if (property === conflictingValuesPlaceholder) {
|
42
43
|
// return emptyColor;
|
@@ -112,7 +113,7 @@ export class ColorLineComponent extends React.Component {
|
|
112
113
|
}
|
113
114
|
_convertToColor(color) {
|
114
115
|
if (color === "" || color === "transparent") {
|
115
|
-
return
|
116
|
+
return EmptyColor;
|
116
117
|
}
|
117
118
|
if (color.substring(0, 1) !== "#" || (color.length !== 7 && color.length !== 9)) {
|
118
119
|
const d = document.createElement("div");
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ColorLineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/lines/ColorLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,4CAA8B;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAEpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,OAAO,KAAK,KAAK,MAAM,kCAAkC,CAAC;AAE1D,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAoB1C,MAAM,OAAO,kBAAmB,SAAQ,KAAK,CAAC,SAA6D;IACvG,YAAY,KAA+B;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,IAAI,CAAC,KAAK,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;QAE3D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;QACjC,MAAM,CAAC,cAAc,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,mEAAmE;IAC/G,CAAC;IAEQ,qBAAqB,CAAC,SAAmC,EAAE,SAAmC;QACnG,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC;QACnC,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC5C,IAAI,UAAU,KAAK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,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,KAAK,EAAC,GAAG,EACT,YAAY,EAAC,KAAK,EAClB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAC/C,EACF,KAAC,qBAAqB,IAClB,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,KAAK,EAAC,GAAG,EACT,YAAY,EAAC,OAAO,EACpB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAC/C,EACF,KAAC,qBAAqB,IAClB,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,KAAK,EAAC,GAAG,EACT,YAAY,EAAC,MAAM,EACnB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAC/C,EACD,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,CACxB,KAAC,qBAAqB,IAClB,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,KAAK,EAAC,GAAG,EACT,YAAY,EAAC,OAAO,EACpB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAC/C,CACL,IACC,CACT,IACC,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport { Color3, Color4 } from \"core/Maths/math.color\";\r\nimport { NumericInputComponent } from \"./NumericInputComponent\";\r\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\r\nimport { faMinus, faPlus } from \"@fortawesome/free-solid-svg-icons\";\r\nimport type { PropertyChangedEvent } from \"../../propertyChangedEvent\";\r\nimport { ColorPickerLineComponent } from \"./ColorPickerLineComponent\";\r\nimport type { LockObject } from \"../../tabs/propertyGrids/lockObject\";\r\nimport * as style from \"./ColorLineComponent.module.scss\";\r\n\r\nimport copyIcon from \"../../imgs/copy.svg\";\r\nimport { JoinClassNames } from \"../classNames\";\r\nconst emptyColor = new Color4(0, 0, 0, 0);\r\n\r\nexport interface IColorLineComponentProps {\r\n label: string;\r\n target: any;\r\n propertyName: string;\r\n onPropertyChangedObservable: Observable<PropertyChangedEvent>;\r\n onChange?: () => void;\r\n isLinear?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n disableAlpha?: boolean;\r\n lockObject: LockObject;\r\n}\r\n\r\ninterface IColorLineComponentState {\r\n isExpanded: boolean;\r\n color: Color4;\r\n}\r\n\r\nexport class ColorLineComponent extends React.Component<IColorLineComponentProps, IColorLineComponentState> {\r\n constructor(props: IColorLineComponentProps) {\r\n super(props);\r\n\r\n this.state = { isExpanded: false, color: this.getValue() };\r\n\r\n const target = this.props.target;\r\n target._isLinearColor = props.isLinear; // so that replayRecorder can append toLinearSpace() as appropriate\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IColorLineComponentProps, nextState: IColorLineComponentState) {\r\n const stateColor = nextState.color;\r\n const propsColor = this.getValue(nextProps);\r\n if (stateColor !== this.state.color) {\r\n nextState.color = stateColor;\r\n return true;\r\n }\r\n if (propsColor !== this.state.color) {\r\n nextState.color = propsColor;\r\n return true;\r\n }\r\n if (nextState.isExpanded !== this.state.isExpanded) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n getValue(props = this.props): Color4 {\r\n const target = props.target;\r\n const property = target[props.propertyName];\r\n if (!property) return emptyColor;\r\n if (typeof property === \"string\") {\r\n // if (property === conflictingValuesPlaceholder) {\r\n // return emptyColor;\r\n // }\r\n return this._convertToColor(property);\r\n } else {\r\n if (props.isLinear) {\r\n return property.toGammaSpace();\r\n }\r\n return property.clone();\r\n }\r\n }\r\n\r\n setColorFromString(colorString: string) {\r\n const color = this._convertToColor(colorString);\r\n this.setColor(color);\r\n }\r\n\r\n setColor(newColor: Color4) {\r\n this.setState({ color: newColor.clone() });\r\n if (this.props.isLinear) {\r\n newColor.toLinearSpaceToRef(newColor);\r\n }\r\n // whether to set properties to color3 or color4\r\n const setColor = this.props.disableAlpha ? this._toColor3(newColor) : newColor;\r\n\r\n const target = this.props.target;\r\n const initialValue = target[this.props.propertyName];\r\n const value = typeof target[this.props.propertyName] === \"string\" ? setColor.toHexString() : setColor;\r\n // make the change\r\n target[this.props.propertyName] = value;\r\n // notify observers\r\n if (this.props.onPropertyChangedObservable) {\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: target,\r\n property: this.props.propertyName,\r\n value,\r\n initialValue,\r\n });\r\n }\r\n\r\n if (this.props.onChange) {\r\n this.props.onChange();\r\n }\r\n }\r\n\r\n switchExpandState() {\r\n this.setState({ isExpanded: !this.state.isExpanded });\r\n }\r\n\r\n updateStateR(value: number) {\r\n this.setColor(new Color4(value, this.state.color.g, this.state.color.b, this.state.color.a));\r\n }\r\n\r\n updateStateG(value: number) {\r\n this.setColor(new Color4(this.state.color.r, value, this.state.color.b, this.state.color.a));\r\n }\r\n\r\n updateStateB(value: number) {\r\n this.setColor(new Color4(this.state.color.r, this.state.color.g, value, this.state.color.a));\r\n }\r\n\r\n updateStateA(value: number) {\r\n if (this.props.disableAlpha) {\r\n return;\r\n }\r\n this.setColor(new Color4(this.state.color.r, this.state.color.g, this.state.color.b, value));\r\n }\r\n\r\n copyToClipboard() {\r\n const element = document.createElement(\"div\");\r\n element.textContent = this.state.color.toHexString();\r\n document.body.appendChild(element);\r\n\r\n if (window.getSelection) {\r\n const range = document.createRange();\r\n range.selectNode(element);\r\n window.getSelection()!.removeAllRanges();\r\n window.getSelection()!.addRange(range);\r\n }\r\n\r\n document.execCommand(\"copy\");\r\n element.remove();\r\n }\r\n\r\n private _convertToColor(color: string): Color4 {\r\n if (color === \"\" || color === \"transparent\") {\r\n return emptyColor;\r\n }\r\n\r\n if (color.substring(0, 1) !== \"#\" || (color.length !== 7 && color.length !== 9)) {\r\n const d = document.createElement(\"div\");\r\n d.style.color = color;\r\n document.body.append(d);\r\n const rgb = window.getComputedStyle(d).color;\r\n document.body.removeChild(d);\r\n\r\n const rgbArray = rgb\r\n .substring(4, rgb.length - 1)\r\n .replace(/ /g, \"\")\r\n .split(\",\");\r\n\r\n const alpha = rgbArray.length > 3 ? parseInt(rgbArray[3]) / 255 : 1.0;\r\n\r\n return new Color4(parseInt(rgbArray[0]) / 255, parseInt(rgbArray[1]) / 255, parseInt(rgbArray[2]) / 255, alpha);\r\n }\r\n\r\n if (this.props.disableAlpha) {\r\n const color3 = Color3.FromHexString(color);\r\n return new Color4(color3.r, color3.g, color3.b, 1.0);\r\n }\r\n\r\n return Color4.FromHexString(color);\r\n }\r\n\r\n private _toColor3(color: Color4) {\r\n return new Color3(color.r, color.g, color.b);\r\n }\r\n\r\n override render() {\r\n const chevron = this.state.isExpanded ? <FontAwesomeIcon icon={faMinus} /> : <FontAwesomeIcon icon={faPlus} />;\r\n\r\n return (\r\n <div className={style.color3Line}>\r\n <div className={style.firstLine}>\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <div className={style.label} title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n <div className={style.color3}>\r\n <ColorPickerLineComponent\r\n lockObject={this.props.lockObject}\r\n linearHint={this.props.isLinear}\r\n value={this.props.disableAlpha ? this._toColor3(this.state.color) : this.state.color}\r\n onColorChanged={(colorString) => {\r\n this.setColorFromString(colorString);\r\n }}\r\n />\r\n </div>\r\n <div className={JoinClassNames(style, \"copy\", \"hoverIcon\")} onClick={() => this.copyToClipboard()} title=\"Copy to clipboard\">\r\n <img src={copyIcon} alt=\"Copy\" />\r\n </div>\r\n <div className={JoinClassNames(\"expand\", \"hoverIcon\")} onClick={() => this.switchExpandState()} title=\"Expand\">\r\n {chevron}\r\n </div>\r\n </div>\r\n {this.state.isExpanded && (\r\n <div className={style.secondLine}>\r\n <NumericInputComponent\r\n lockObject={this.props.lockObject}\r\n label=\"r\"\r\n labelTooltip=\"Red\"\r\n value={this.state.color.r}\r\n onChange={(value) => this.updateStateR(value)}\r\n />\r\n <NumericInputComponent\r\n lockObject={this.props.lockObject}\r\n label=\"g\"\r\n labelTooltip=\"Green\"\r\n value={this.state.color.g}\r\n onChange={(value) => this.updateStateG(value)}\r\n />\r\n <NumericInputComponent\r\n lockObject={this.props.lockObject}\r\n label=\"b\"\r\n labelTooltip=\"Blue\"\r\n value={this.state.color.b}\r\n onChange={(value) => this.updateStateB(value)}\r\n />\r\n {this.props.disableAlpha || (\r\n <NumericInputComponent\r\n lockObject={this.props.lockObject}\r\n label=\"a\"\r\n labelTooltip=\"Alpha\"\r\n value={this.state.color.a}\r\n onChange={(value) => this.updateStateA(value)}\r\n />\r\n )}\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
1
|
+
{"version":3,"file":"ColorLineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/lines/ColorLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,4CAA8B;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAEpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,OAAO,KAAK,KAAK,MAAM,kC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AC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAC/C,EACF,KAAC,qBAAqB,IAClB,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,KAAK,EAAC,GAAG,EACT,YAAY,EAAC,MAAM,EACnB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAC/C,EACD,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,CACxB,KAAC,qBAAqB,IAClB,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,KAAK,EAAC,GAAG,EACT,YAAY,EAAC,OAAO,EACpB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAC/C,CACL,IACC,CACT,IACC,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport { Color3, Color4 } from \"core/Maths/math.color\";\r\nimport { NumericInputComponent } from \"./NumericInputComponent\";\r\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\r\nimport { faMinus, faPlus } from \"@fortawesome/free-solid-svg-icons\";\r\nimport type { PropertyChangedEvent } from \"../../propertyChangedEvent\";\r\nimport { ColorPickerLineComponent } from \"./ColorPickerLineComponent\";\r\nimport type { LockObject } from \"../../tabs/propertyGrids/lockObject\";\r\nimport * as style from \"./ColorLineComponent.module.scss\";\r\n\r\nimport copyIcon from \"../../imgs/copy.svg\";\r\nimport { JoinClassNames } from \"../classNames\";\r\nconst EmptyColor = new Color4(0, 0, 0, 0);\r\n\r\nexport interface IColorLineComponentProps {\r\n label: string;\r\n target: any;\r\n propertyName: string;\r\n onPropertyChangedObservable: Observable<PropertyChangedEvent>;\r\n onChange?: () => void;\r\n isLinear?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n disableAlpha?: boolean;\r\n lockObject: LockObject;\r\n}\r\n\r\ninterface IColorLineComponentState {\r\n isExpanded: boolean;\r\n color: Color4;\r\n}\r\n\r\nexport class ColorLineComponent extends React.Component<IColorLineComponentProps, IColorLineComponentState> {\r\n constructor(props: IColorLineComponentProps) {\r\n super(props);\r\n\r\n this.state = { isExpanded: false, color: this.getValue() };\r\n\r\n const target = this.props.target;\r\n target._isLinearColor = props.isLinear; // so that replayRecorder can append toLinearSpace() as appropriate\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IColorLineComponentProps, nextState: IColorLineComponentState) {\r\n const stateColor = nextState.color;\r\n const propsColor = this.getValue(nextProps);\r\n if (stateColor !== this.state.color) {\r\n nextState.color = stateColor;\r\n return true;\r\n }\r\n if (propsColor !== this.state.color) {\r\n nextState.color = propsColor;\r\n return true;\r\n }\r\n if (nextState.isExpanded !== this.state.isExpanded) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n getValue(props = this.props): Color4 {\r\n const target = props.target;\r\n const property = target[props.propertyName];\r\n if (!property) {\r\n return EmptyColor;\r\n }\r\n if (typeof property === \"string\") {\r\n // if (property === conflictingValuesPlaceholder) {\r\n // return emptyColor;\r\n // }\r\n return this._convertToColor(property);\r\n } else {\r\n if (props.isLinear) {\r\n return property.toGammaSpace();\r\n }\r\n return property.clone();\r\n }\r\n }\r\n\r\n setColorFromString(colorString: string) {\r\n const color = this._convertToColor(colorString);\r\n this.setColor(color);\r\n }\r\n\r\n setColor(newColor: Color4) {\r\n this.setState({ color: newColor.clone() });\r\n if (this.props.isLinear) {\r\n newColor.toLinearSpaceToRef(newColor);\r\n }\r\n // whether to set properties to color3 or color4\r\n const setColor = this.props.disableAlpha ? this._toColor3(newColor) : newColor;\r\n\r\n const target = this.props.target;\r\n const initialValue = target[this.props.propertyName];\r\n const value = typeof target[this.props.propertyName] === \"string\" ? setColor.toHexString() : setColor;\r\n // make the change\r\n target[this.props.propertyName] = value;\r\n // notify observers\r\n if (this.props.onPropertyChangedObservable) {\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: target,\r\n property: this.props.propertyName,\r\n value,\r\n initialValue,\r\n });\r\n }\r\n\r\n if (this.props.onChange) {\r\n this.props.onChange();\r\n }\r\n }\r\n\r\n switchExpandState() {\r\n this.setState({ isExpanded: !this.state.isExpanded });\r\n }\r\n\r\n updateStateR(value: number) {\r\n this.setColor(new Color4(value, this.state.color.g, this.state.color.b, this.state.color.a));\r\n }\r\n\r\n updateStateG(value: number) {\r\n this.setColor(new Color4(this.state.color.r, value, this.state.color.b, this.state.color.a));\r\n }\r\n\r\n updateStateB(value: number) {\r\n this.setColor(new Color4(this.state.color.r, this.state.color.g, value, this.state.color.a));\r\n }\r\n\r\n updateStateA(value: number) {\r\n if (this.props.disableAlpha) {\r\n return;\r\n }\r\n this.setColor(new Color4(this.state.color.r, this.state.color.g, this.state.color.b, value));\r\n }\r\n\r\n copyToClipboard() {\r\n const element = document.createElement(\"div\");\r\n element.textContent = this.state.color.toHexString();\r\n document.body.appendChild(element);\r\n\r\n if (window.getSelection) {\r\n const range = document.createRange();\r\n range.selectNode(element);\r\n window.getSelection()!.removeAllRanges();\r\n window.getSelection()!.addRange(range);\r\n }\r\n\r\n document.execCommand(\"copy\");\r\n element.remove();\r\n }\r\n\r\n private _convertToColor(color: string): Color4 {\r\n if (color === \"\" || color === \"transparent\") {\r\n return EmptyColor;\r\n }\r\n\r\n if (color.substring(0, 1) !== \"#\" || (color.length !== 7 && color.length !== 9)) {\r\n const d = document.createElement(\"div\");\r\n d.style.color = color;\r\n document.body.append(d);\r\n const rgb = window.getComputedStyle(d).color;\r\n document.body.removeChild(d);\r\n\r\n const rgbArray = rgb\r\n .substring(4, rgb.length - 1)\r\n .replace(/ /g, \"\")\r\n .split(\",\");\r\n\r\n const alpha = rgbArray.length > 3 ? parseInt(rgbArray[3]) / 255 : 1.0;\r\n\r\n return new Color4(parseInt(rgbArray[0]) / 255, parseInt(rgbArray[1]) / 255, parseInt(rgbArray[2]) / 255, alpha);\r\n }\r\n\r\n if (this.props.disableAlpha) {\r\n const color3 = Color3.FromHexString(color);\r\n return new Color4(color3.r, color3.g, color3.b, 1.0);\r\n }\r\n\r\n return Color4.FromHexString(color);\r\n }\r\n\r\n private _toColor3(color: Color4) {\r\n return new Color3(color.r, color.g, color.b);\r\n }\r\n\r\n override render() {\r\n const chevron = this.state.isExpanded ? <FontAwesomeIcon icon={faMinus} /> : <FontAwesomeIcon icon={faPlus} />;\r\n\r\n return (\r\n <div className={style.color3Line}>\r\n <div className={style.firstLine}>\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <div className={style.label} title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n <div className={style.color3}>\r\n <ColorPickerLineComponent\r\n lockObject={this.props.lockObject}\r\n linearHint={this.props.isLinear}\r\n value={this.props.disableAlpha ? this._toColor3(this.state.color) : this.state.color}\r\n onColorChanged={(colorString) => {\r\n this.setColorFromString(colorString);\r\n }}\r\n />\r\n </div>\r\n <div className={JoinClassNames(style, \"copy\", \"hoverIcon\")} onClick={() => this.copyToClipboard()} title=\"Copy to clipboard\">\r\n <img src={copyIcon} alt=\"Copy\" />\r\n </div>\r\n <div className={JoinClassNames(\"expand\", \"hoverIcon\")} onClick={() => this.switchExpandState()} title=\"Expand\">\r\n {chevron}\r\n </div>\r\n </div>\r\n {this.state.isExpanded && (\r\n <div className={style.secondLine}>\r\n <NumericInputComponent\r\n lockObject={this.props.lockObject}\r\n label=\"r\"\r\n labelTooltip=\"Red\"\r\n value={this.state.color.r}\r\n onChange={(value) => this.updateStateR(value)}\r\n />\r\n <NumericInputComponent\r\n lockObject={this.props.lockObject}\r\n label=\"g\"\r\n labelTooltip=\"Green\"\r\n value={this.state.color.g}\r\n onChange={(value) => this.updateStateG(value)}\r\n />\r\n <NumericInputComponent\r\n lockObject={this.props.lockObject}\r\n label=\"b\"\r\n labelTooltip=\"Blue\"\r\n value={this.state.color.b}\r\n onChange={(value) => this.updateStateB(value)}\r\n />\r\n {this.props.disableAlpha || (\r\n <NumericInputComponent\r\n lockObject={this.props.lockObject}\r\n label=\"a\"\r\n labelTooltip=\"Alpha\"\r\n value={this.state.color.a}\r\n onChange={(value) => this.updateStateA(value)}\r\n />\r\n )}\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
@@ -7,7 +7,7 @@ export interface IFileButtonLineComponentProps {
|
|
7
7
|
iconLabel?: string;
|
8
8
|
}
|
9
9
|
export declare class FileButtonLineComponent extends React.Component<IFileButtonLineComponentProps> {
|
10
|
-
private static
|
10
|
+
private static _IdGenerator;
|
11
11
|
private _id;
|
12
12
|
private _uploadInputRef;
|
13
13
|
constructor(props: IFileButtonLineComponentProps);
|
@@ -4,7 +4,7 @@ import * as styles from "./FileButtonLineComponent.module.scss";
|
|
4
4
|
export class FileButtonLineComponent extends React.Component {
|
5
5
|
constructor(props) {
|
6
6
|
super(props);
|
7
|
-
this._id = FileButtonLineComponent.
|
7
|
+
this._id = FileButtonLineComponent._IdGenerator++;
|
8
8
|
this._uploadInputRef = React.createRef();
|
9
9
|
}
|
10
10
|
onChange(evt) {
|
@@ -18,5 +18,5 @@ export class FileButtonLineComponent extends React.Component {
|
|
18
18
|
return (_jsxs("div", { className: styles.buttonLine, children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel }), _jsx("label", { htmlFor: "file-upload" + this._id, className: styles.fileUpload, children: this.props.label }), _jsx("input", { ref: this._uploadInputRef, id: "file-upload" + this._id, type: "file", accept: this.props.accept, onChange: (evt) => this.onChange(evt) })] }));
|
19
19
|
}
|
20
20
|
}
|
21
|
-
FileButtonLineComponent.
|
21
|
+
FileButtonLineComponent._IdGenerator = 0;
|
22
22
|
//# sourceMappingURL=FileButtonLineComponent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"FileButtonLineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/lines/FileButtonLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uCAAuC,CAAC;AAUhE,MAAM,OAAO,uBAAwB,SAAQ,KAAK,CAAC,SAAwC;IAKvF,YAAY,KAAoC;QAC5C,KAAK,CAAC,KAAK,CAAC,CAAC;QAJT,QAAG,GAAG,uBAAuB,CAAC,YAAY,EAAE,CAAC;QAKjD,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAC7C,CAAC;IAED,QAAQ,CAAC,GAAQ;QACb,MAAM,KAAK,GAAW,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;QACvC,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACjC,CAAC;QAED,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC;IAC1B,CAAC;IAEQ,MAAM;QACX,OAAO,CACH,eAAK,SAAS,EAAE,MAAM,CAAC,UAAU,aAC5B,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,GAAI,EACzG,gBAAO,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,UAAU,YACjE,IAAI,CAAC,KAAK,CAAC,KAAK,GACb,EACR,gBAAO,GAAG,EAAE,IAAI,CAAC,eAAe,EAAE,EAAE,EAAE,aAAa,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,EAAC,MAAM,EAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAI,IAC9I,CACT,CAAC;IACN,CAAC;;AA5Bc,oCAAY,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["import * as React from \"react\";\r\nimport * as styles from \"./FileButtonLineComponent.module.scss\";\r\n\r\nexport interface IFileButtonLineComponentProps {\r\n label: string;\r\n onClick: (file: File) => void;\r\n accept: string;\r\n icon?: string;\r\n iconLabel?: string;\r\n}\r\n\r\nexport class FileButtonLineComponent extends React.Component<IFileButtonLineComponentProps> {\r\n private static
|
1
|
+
{"version":3,"file":"FileButtonLineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/lines/FileButtonLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,uCAAuC,CAAC;AAUhE,MAAM,OAAO,uBAAwB,SAAQ,KAAK,CAAC,SAAwC;IAKvF,YAAY,KAAoC;QAC5C,KAAK,CAAC,KAAK,CAAC,CAAC;QAJT,QAAG,GAAG,uBAAuB,CAAC,YAAY,EAAE,CAAC;QAKjD,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAC7C,CAAC;IAED,QAAQ,CAAC,GAAQ;QACb,MAAM,KAAK,GAAW,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;QACvC,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACjC,CAAC;QAED,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC;IAC1B,CAAC;IAEQ,MAAM;QACX,OAAO,CACH,eAAK,SAAS,EAAE,MAAM,CAAC,UAAU,aAC5B,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,GAAI,EACzG,gBAAO,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,UAAU,YACjE,IAAI,CAAC,KAAK,CAAC,KAAK,GACb,EACR,gBAAO,GAAG,EAAE,IAAI,CAAC,eAAe,EAAE,EAAE,EAAE,aAAa,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,EAAC,MAAM,EAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAI,IAC9I,CACT,CAAC;IACN,CAAC;;AA5Bc,oCAAY,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["import * as React from \"react\";\r\nimport * as styles from \"./FileButtonLineComponent.module.scss\";\r\n\r\nexport interface IFileButtonLineComponentProps {\r\n label: string;\r\n onClick: (file: File) => void;\r\n accept: string;\r\n icon?: string;\r\n iconLabel?: string;\r\n}\r\n\r\nexport class FileButtonLineComponent extends React.Component<IFileButtonLineComponentProps> {\r\n private static _IdGenerator = 0;\r\n private _id = FileButtonLineComponent._IdGenerator++;\r\n private _uploadInputRef: React.RefObject<HTMLInputElement>;\r\n\r\n constructor(props: IFileButtonLineComponentProps) {\r\n super(props);\r\n this._uploadInputRef = React.createRef();\r\n }\r\n\r\n onChange(evt: any) {\r\n const files: File[] = evt.target.files;\r\n if (files && files.length) {\r\n this.props.onClick(files[0]);\r\n }\r\n\r\n evt.target.value = \"\";\r\n }\r\n\r\n override render() {\r\n return (\r\n <div className={styles.buttonLine}>\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} />}\r\n <label htmlFor={\"file-upload\" + this._id} className={styles.fileUpload}>\r\n {this.props.label}\r\n </label>\r\n <input ref={this._uploadInputRef} id={\"file-upload\" + this._id} type=\"file\" accept={this.props.accept} onChange={(evt) => this.onChange(evt)} />\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
@@ -11,11 +11,11 @@ var OptionStates;
|
|
11
11
|
OptionStates[OptionStates["Default"] = 0] = "Default";
|
12
12
|
OptionStates[OptionStates["Adding"] = 1] = "Adding";
|
13
13
|
})(OptionStates || (OptionStates = {}));
|
14
|
-
const
|
14
|
+
const OptionAddKey = "addCustomOption";
|
15
15
|
export const OptionsLineComponent = (props) => {
|
16
16
|
const [optionState, setOptionState] = useState(OptionStates.Default); // State of the component
|
17
17
|
const onOptionChange = (evt) => {
|
18
|
-
if (evt.target.value ===
|
18
|
+
if (evt.target.value === OptionAddKey) {
|
19
19
|
setOptionState(OptionStates.Adding);
|
20
20
|
}
|
21
21
|
else {
|
@@ -32,6 +32,6 @@ export const OptionsLineComponent = (props) => {
|
|
32
32
|
const onCancelOptionAdd = () => {
|
33
33
|
setOptionState(OptionStates.Default);
|
34
34
|
};
|
35
|
-
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:
|
35
|
+
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: props.addOptionText ?? "Custom" }, OptionAddKey)), props.options.map((option) => (_jsx("option", { value: option.value, children: option.label }, option.id)))] }))] }));
|
36
36
|
};
|
37
37
|
//# sourceMappingURL=OptionsLineComponent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"OptionsLineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/lines/OptionsLineComponent.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,oCAAoC,CAAC;AAsB5D;;;GAGG;AACH,IAAK,YAGJ;AAHD,WAAK,YAAY;IACb,qDAAW,CAAA;IACX,mDAAU,CAAA;AACd,CAAC,EAHI,YAAY,KAAZ,YAAY,QAGhB;AAED,MAAM,
|
1
|
+
{"version":3,"file":"OptionsLineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/lines/OptionsLineComponent.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,oCAAoC,CAAC;AAsB5D;;;GAGG;AACH,IAAK,YAGJ;AAHD,WAAK,YAAY;IACb,qDAAW,CAAA;IACX,mDAAU,CAAA;AACd,CAAC,EAHI,YAAY,KAAZ,YAAY,QAGhB;AAED,MAAM,YAAY,GAAG,iBAAiB,CAAC;AAEvC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAiC,EAAE,EAAE;IACtE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,yBAAyB;IAE/F,MAAM,c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IAAI,CACpB,iBAA2B,KAAK,EAAE,YAAY,YACzC,KAAK,CAAC,aAAa,IAAI,QAAQ,IADvB,YAAY,CAEhB,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 * as style from \"./OptionsLineComponent.module.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"]}
|
@@ -13,6 +13,7 @@ export const GraphLinesContainer = (props) => {
|
|
13
13
|
return item.parentContainerId === props.id;
|
14
14
|
},
|
15
15
|
collect: (monitor) => ({
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
16
17
|
start: monitor.getItem(),
|
17
18
|
delta: monitor.getDifferenceFromInitialOffset(),
|
18
19
|
}),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"GraphLinesContainer.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/reactGraphSystem/GraphLinesContainer.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAYvD;;;;GAIG;AACH,MAAM,CAAC,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AAC;AACN,CAAC,CAAC","sourcesContent":["import type { FC, PropsWithChildren } from \"react\";\r\nimport type { DropTargetMonitor } from \"react-dnd\";\r\nimport { useDrop } from \"react-dnd\";\r\nimport { GraphLine, MarkerArrowId } from \"./GraphLine\";\r\n\r\n/**\r\n * props for the GraphLineContainer\r\n */\r\nexport interface IGraphLinesContainerProps {\r\n /**\r\n * id of the container\r\n */\r\n id: string;\r\n}\r\n\r\n/**\r\n * this component handles the dragging of new connections\r\n * @param props\r\n * @returns\r\n */\r\nexport const GraphLinesContainer: FC<PropsWithChildren<IGraphLinesContainerProps>> = (props) => {\r\n const [{ start, delta }, dropRef] = useDrop(() => ({\r\n accept: \"connector\",\r\n canDrop: (item: any) => {\r\n return item.parentContainerId === props.id;\r\n },\r\n collect: (monitor: DropTargetMonitor) => ({\r\n start: monitor.getItem() as any,\r\n delta: monitor.getDifferenceFromInitialOffset() as any,\r\n }),\r\n }));\r\n return (\r\n <svg width=\"100%\" height=\"100%\" ref={dropRef}>\r\n <defs>\r\n <marker id={MarkerArrowId} markerWidth=\"15\" markerHeight=\"15\" refX=\"5\" refY=\"5\" orient=\"auto\">\r\n <path d=\"M 0 0 L 10 5 L 0 10 z\" stroke=\"black\" />\r\n </marker>\r\n </defs>\r\n {props.children}\r\n {start && start.parentContainerId === props.id && start.x !== undefined && start.y !== undefined && delta && (\r\n <GraphLine x1={start.x} y1={start.y} x2={start.x + delta.x} y2={start.y + delta.y} selected={false} />\r\n )}\r\n </svg>\r\n );\r\n};\r\n"]}
|
1
|
+
{"version":3,"file":"GraphLinesContainer.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/reactGraphSystem/GraphLinesContainer.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAYvD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAqD,CAAC,KAA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CAAC","sourcesContent":["import type { FC, PropsWithChildren } from \"react\";\r\nimport type { DropTargetMonitor } from \"react-dnd\";\r\nimport { useDrop } from \"react-dnd\";\r\nimport { GraphLine, MarkerArrowId } from \"./GraphLine\";\r\n\r\n/**\r\n * props for the GraphLineContainer\r\n */\r\nexport interface IGraphLinesContainerProps {\r\n /**\r\n * id of the container\r\n */\r\n id: string;\r\n}\r\n\r\n/**\r\n * this component handles the dragging of new connections\r\n * @param props\r\n * @returns\r\n */\r\nexport const GraphLinesContainer: FC<PropsWithChildren<IGraphLinesContainerProps>> = (props) => {\r\n const [{ start, delta }, dropRef] = useDrop(() => ({\r\n accept: \"connector\",\r\n canDrop: (item: any) => {\r\n return item.parentContainerId === props.id;\r\n },\r\n collect: (monitor: DropTargetMonitor) => ({\r\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\r\n start: monitor.getItem() as any,\r\n delta: monitor.getDifferenceFromInitialOffset() as any,\r\n }),\r\n }));\r\n return (\r\n <svg width=\"100%\" height=\"100%\" ref={dropRef}>\r\n <defs>\r\n <marker id={MarkerArrowId} markerWidth=\"15\" markerHeight=\"15\" refX=\"5\" refY=\"5\" orient=\"auto\">\r\n <path d=\"M 0 0 L 10 5 L 0 10 z\" stroke=\"black\" />\r\n </marker>\r\n </defs>\r\n {props.children}\r\n {start && start.parentContainerId === props.id && start.x !== undefined && start.y !== undefined && delta && (\r\n <GraphLine x1={start.x} y1={start.y} x2={start.x + delta.x} y2={start.y + delta.y} selected={false} />\r\n )}\r\n </svg>\r\n );\r\n};\r\n"]}
|
@@ -6,7 +6,7 @@ import { SingleGraphNode } from "./GraphNode.js";
|
|
6
6
|
import { GraphNodesContainer } from "./GraphNodesContainer.js";
|
7
7
|
import { GraphLinesContainer } from "./GraphLinesContainer.js";
|
8
8
|
import { GraphContextManager } from "./GraphContextManager.js";
|
9
|
-
const
|
9
|
+
const FullscreenStyle = { width: "100%", height: "100%" };
|
10
10
|
/**
|
11
11
|
* This component is a bridge between the app logic related to the graph, and the actual rendering
|
12
12
|
* of it. It manages the nodes' positions and selection states.
|
@@ -57,7 +57,7 @@ export const NodeRenderer = (props) => {
|
|
57
57
|
};
|
58
58
|
}, [selectedLine, selectedNode]);
|
59
59
|
const graphContext = useMemo(() => ({ updatePos, onNodesConnected, onLineSelected, onNodeSelected }), []);
|
60
|
-
return (_jsx("div", { style:
|
60
|
+
return (_jsx("div", { style: FullscreenStyle, children: _jsx(GraphContextManager.Provider, { value: graphContext, children: _jsxs(GraphContainer, { children: [_jsx(GraphNodesContainer, { id: props.id, onNodeMoved: updatePos, children: nodes.map(({ id, label, customData }) => {
|
61
61
|
const posInRecord = pos[id] || { x: 0, y: 0 };
|
62
62
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
63
63
|
const CustomComponent = customData && customData.type && props.customComponents && props.customComponents[customData.type];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"NodeRenderer.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/reactGraphSystem/NodeRenderer.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,MAAM,eAAe,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAkD1D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAA4C,EAAE,EAAE;IACzE,MAAM,EAAE,KAAK,EAA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AAC;AACN,CAAC,CAAC","sourcesContent":["import type { ComponentType, PropsWithChildren } from \"react\";\r\nimport { useState, useEffect, useMemo } from \"react\";\r\nimport { GraphContainer } from \"./GraphContainer\";\r\nimport { GraphLine } from \"./GraphLine\";\r\nimport { SingleGraphNode } from \"./GraphNode\";\r\nimport { GraphNodesContainer } from \"./GraphNodesContainer\";\r\nimport { GraphLinesContainer } from \"./GraphLinesContainer\";\r\nimport { GraphContextManager } from \"./GraphContextManager\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nconst fullscreenStyle = { width: \"100%\", height: \"100%\" };\r\n\r\nexport type IVisualRecordsType = Record<string, { x: number; y: number }>;\r\nexport type IConnectionType = { id: string; sourceId: string; targetId: string };\r\nexport type ICustomDataType = { type: string; value: any };\r\nexport type INodeType = { id: string; label: string; customData?: ICustomDataType };\r\n\r\n/**\r\n * props for the node renderer\r\n */\r\nexport interface INodeRendererProps {\r\n /**\r\n * array of connections between nodes\r\n */\r\n connections: IConnectionType[];\r\n /**\r\n * function called when a new connection is created\r\n */\r\n updateConnections: (sourceId: string, targetId: string) => void;\r\n /**\r\n * function called when a connection is deleted\r\n */\r\n deleteLine: (lineId: string) => void;\r\n /**\r\n * function called when a node is deleted\r\n */\r\n deleteNode: (nodeId: string) => void;\r\n /**\r\n * array of all nodes\r\n */\r\n nodes: INodeType[];\r\n /**\r\n * id of the node to highlight\r\n */\r\n highlightedNode?: Nullable<string>;\r\n /**\r\n * function to be called if a node is selected\r\n */\r\n selectNode?: (nodeId: Nullable<string>) => void;\r\n /**\r\n * id of this renderer\r\n */\r\n id: string;\r\n /**\r\n * optional list of custom components to be rendered inside nodes of\r\n * a certain type\r\n */\r\n customComponents?: Record<string, ComponentType<any>>;\r\n}\r\n\r\n/**\r\n * This component is a bridge between the app logic related to the graph, and the actual rendering\r\n * of it. It manages the nodes' positions and selection states.\r\n * @param props\r\n * @returns\r\n */\r\nexport const NodeRenderer = (props: PropsWithChildren<INodeRendererProps>) => {\r\n const { nodes, connections, updateConnections, highlightedNode } = props;\r\n // Store the nodes positions\r\n const [pos, setPos] = useState<IVisualRecordsType>({});\r\n const [selectedLine, setSelectedLine] = useState<string | null>(null);\r\n const [selectedNode, setSelectedNode] = useState<string | null>(null);\r\n\r\n const updatePos = (id: string, x: number, y: number) => {\r\n setPos((currentPos) => {\r\n const currPos = currentPos[id] || { x: 0, y: 0 };\r\n currentPos[id] = { x: currPos.x + x, y: currPos.y + y };\r\n return { ...currentPos };\r\n });\r\n };\r\n\r\n const onNodesConnected = (sourceId: string, targetId: string) => {\r\n updateConnections(sourceId, targetId);\r\n };\r\n\r\n const onLineSelected = (lineId: string) => {\r\n setSelectedLine(lineId);\r\n setSelectedNode(null);\r\n };\r\n\r\n const onNodeSelected = (nodeId: string) => {\r\n setSelectedNode(nodeId);\r\n setSelectedLine(null);\r\n };\r\n\r\n useEffect(() => {\r\n props.selectNode && props.selectNode(selectedNode);\r\n }, [selectedNode]);\r\n\r\n const onKeyDown = (evt: KeyboardEvent) => {\r\n if (evt.key === \"Delete\") {\r\n if (selectedLine) {\r\n props.deleteLine(selectedLine);\r\n } else if (selectedNode) {\r\n props.deleteNode(selectedNode);\r\n }\r\n }\r\n };\r\n\r\n useEffect(() => {\r\n document.addEventListener(\"keydown\", onKeyDown);\r\n return () => {\r\n document.removeEventListener(\"keydown\", onKeyDown);\r\n };\r\n }, [selectedLine, selectedNode]);\r\n\r\n const graphContext = useMemo(() => ({ updatePos, onNodesConnected, onLineSelected, onNodeSelected }), []);\r\n return (\r\n <div style={fullscreenStyle}>\r\n <GraphContextManager.Provider value={graphContext}>\r\n <GraphContainer>\r\n <GraphNodesContainer id={props.id} onNodeMoved={updatePos}>\r\n {nodes.map(({ id, label, customData }) => {\r\n const posInRecord = pos[id] || { x: 0, y: 0 };\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n const CustomComponent = customData && customData.type && props.customComponents && props.customComponents[customData.type];\r\n return (\r\n <SingleGraphNode\r\n parentContainerId={props.id}\r\n key={id}\r\n id={id}\r\n name={label}\r\n x={posInRecord.x}\r\n y={posInRecord.y}\r\n selected={id === selectedNode}\r\n highlighted={id === highlightedNode}\r\n >\r\n {CustomComponent && <CustomComponent {...customData.value} />}\r\n </SingleGraphNode>\r\n );\r\n })}\r\n </GraphNodesContainer>\r\n <GraphLinesContainer id={props.id}>\r\n {connections.map(({ id, sourceId, targetId }) => {\r\n const sourcePos = pos[sourceId] || { x: 0, y: 0 };\r\n const targetPos = pos[targetId] || { x: 0, y: 0 };\r\n return <GraphLine key={id} id={id} x1={sourcePos.x} y1={sourcePos.y} x2={targetPos.x} y2={targetPos.y} selected={id === selectedLine} />;\r\n })}\r\n </GraphLinesContainer>\r\n </GraphContainer>\r\n </GraphContextManager.Provider>\r\n </div>\r\n );\r\n};\r\n"]}
|
1
|
+
{"version":3,"file":"NodeRenderer.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/reactGraphSystem/NodeRenderer.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,MAAM,eAAe,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAsD1D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAA4C,EAAE,EAAE;IACzE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,eAAe,EAAE,GAAG,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ithChildren } from \"react\";\r\nimport { useState, useEffect, useMemo } from \"react\";\r\nimport { GraphContainer } from \"./GraphContainer\";\r\nimport { GraphLine } from \"./GraphLine\";\r\nimport { SingleGraphNode } from \"./GraphNode\";\r\nimport { GraphNodesContainer } from \"./GraphNodesContainer\";\r\nimport { GraphLinesContainer } from \"./GraphLinesContainer\";\r\nimport { GraphContextManager } from \"./GraphContextManager\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nconst FullscreenStyle = { width: \"100%\", height: \"100%\" };\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport type IVisualRecordsType = Record<string, { x: number; y: number }>;\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport type IConnectionType = { id: string; sourceId: string; targetId: string };\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport type ICustomDataType = { type: string; value: any };\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport type INodeType = { id: string; label: string; customData?: ICustomDataType };\r\n\r\n/**\r\n * props for the node renderer\r\n */\r\nexport interface INodeRendererProps {\r\n /**\r\n * array of connections between nodes\r\n */\r\n connections: IConnectionType[];\r\n /**\r\n * function called when a new connection is created\r\n */\r\n updateConnections: (sourceId: string, targetId: string) => void;\r\n /**\r\n * function called when a connection is deleted\r\n */\r\n deleteLine: (lineId: string) => void;\r\n /**\r\n * function called when a node is deleted\r\n */\r\n deleteNode: (nodeId: string) => void;\r\n /**\r\n * array of all nodes\r\n */\r\n nodes: INodeType[];\r\n /**\r\n * id of the node to highlight\r\n */\r\n highlightedNode?: Nullable<string>;\r\n /**\r\n * function to be called if a node is selected\r\n */\r\n selectNode?: (nodeId: Nullable<string>) => void;\r\n /**\r\n * id of this renderer\r\n */\r\n id: string;\r\n /**\r\n * optional list of custom components to be rendered inside nodes of\r\n * a certain type\r\n */\r\n customComponents?: Record<string, ComponentType<any>>;\r\n}\r\n\r\n/**\r\n * This component is a bridge between the app logic related to the graph, and the actual rendering\r\n * of it. It manages the nodes' positions and selection states.\r\n * @param props\r\n * @returns\r\n */\r\nexport const NodeRenderer = (props: PropsWithChildren<INodeRendererProps>) => {\r\n const { nodes, connections, updateConnections, highlightedNode } = props;\r\n // Store the nodes positions\r\n const [pos, setPos] = useState<IVisualRecordsType>({});\r\n const [selectedLine, setSelectedLine] = useState<string | null>(null);\r\n const [selectedNode, setSelectedNode] = useState<string | null>(null);\r\n\r\n const updatePos = (id: string, x: number, y: number) => {\r\n setPos((currentPos) => {\r\n const currPos = currentPos[id] || { x: 0, y: 0 };\r\n currentPos[id] = { x: currPos.x + x, y: currPos.y + y };\r\n return { ...currentPos };\r\n });\r\n };\r\n\r\n const onNodesConnected = (sourceId: string, targetId: string) => {\r\n updateConnections(sourceId, targetId);\r\n };\r\n\r\n const onLineSelected = (lineId: string) => {\r\n setSelectedLine(lineId);\r\n setSelectedNode(null);\r\n };\r\n\r\n const onNodeSelected = (nodeId: string) => {\r\n setSelectedNode(nodeId);\r\n setSelectedLine(null);\r\n };\r\n\r\n useEffect(() => {\r\n props.selectNode && props.selectNode(selectedNode);\r\n }, [selectedNode]);\r\n\r\n const onKeyDown = (evt: KeyboardEvent) => {\r\n if (evt.key === \"Delete\") {\r\n if (selectedLine) {\r\n props.deleteLine(selectedLine);\r\n } else if (selectedNode) {\r\n props.deleteNode(selectedNode);\r\n }\r\n }\r\n };\r\n\r\n useEffect(() => {\r\n document.addEventListener(\"keydown\", onKeyDown);\r\n return () => {\r\n document.removeEventListener(\"keydown\", onKeyDown);\r\n };\r\n }, [selectedLine, selectedNode]);\r\n\r\n const graphContext = useMemo(() => ({ updatePos, onNodesConnected, onLineSelected, onNodeSelected }), []);\r\n return (\r\n <div style={FullscreenStyle}>\r\n <GraphContextManager.Provider value={graphContext}>\r\n <GraphContainer>\r\n <GraphNodesContainer id={props.id} onNodeMoved={updatePos}>\r\n {nodes.map(({ id, label, customData }) => {\r\n const posInRecord = pos[id] || { x: 0, y: 0 };\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n const CustomComponent = customData && customData.type && props.customComponents && props.customComponents[customData.type];\r\n return (\r\n <SingleGraphNode\r\n parentContainerId={props.id}\r\n key={id}\r\n id={id}\r\n name={label}\r\n x={posInRecord.x}\r\n y={posInRecord.y}\r\n selected={id === selectedNode}\r\n highlighted={id === highlightedNode}\r\n >\r\n {CustomComponent && <CustomComponent {...customData.value} />}\r\n </SingleGraphNode>\r\n );\r\n })}\r\n </GraphNodesContainer>\r\n <GraphLinesContainer id={props.id}>\r\n {connections.map(({ id, sourceId, targetId }) => {\r\n const sourcePos = pos[sourceId] || { x: 0, y: 0 };\r\n const targetPos = pos[targetId] || { x: 0, y: 0 };\r\n return <GraphLine key={id} id={id} x1={sourcePos.x} y1={sourcePos.y} x2={targetPos.x} y2={targetPos.y} selected={id === selectedLine} />;\r\n })}\r\n </GraphLinesContainer>\r\n </GraphContainer>\r\n </GraphContextManager.Provider>\r\n </div>\r\n );\r\n};\r\n"]}
|
@@ -4,6 +4,7 @@ import { GraphContextManager } from "./GraphContextManager.js";
|
|
4
4
|
* utility hook to assist using the graph context
|
5
5
|
* @returns
|
6
6
|
*/
|
7
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
7
8
|
export const useGraphContext = () => {
|
8
9
|
const context = useContext(GraphContextManager);
|
9
10
|
return context;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useGraphContext.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/reactGraphSystem/useGraphContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAChC,MAAM,OAAO,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAC;IAChD,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import { useContext } from \"react\";\r\nimport { GraphContextManager } from \"./GraphContextManager\";\r\n\r\n/**\r\n * utility hook to assist using the graph context\r\n * @returns\r\n */\r\nexport const useGraphContext = () => {\r\n const context = useContext(GraphContextManager);\r\n return context;\r\n};\r\n"]}
|
1
|
+
{"version":3,"file":"useGraphContext.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/reactGraphSystem/useGraphContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;GAGG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAChC,MAAM,OAAO,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAC;IAChD,OAAO,OAAO,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import { useContext } from \"react\";\r\nimport { GraphContextManager } from \"./GraphContextManager\";\r\n\r\n/**\r\n * utility hook to assist using the graph context\r\n * @returns\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const useGraphContext = () => {\r\n const context = useContext(GraphContextManager);\r\n return context;\r\n};\r\n"]}
|
package/constToOptionsMaps.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/**
|
2
2
|
* Used by both particleSystem and alphaBlendModes
|
3
3
|
*/
|
4
|
-
export declare const
|
4
|
+
export declare const CommonBlendModes: {
|
5
5
|
label: string;
|
6
6
|
value: number;
|
7
7
|
}[];
|
@@ -10,14 +10,14 @@ export declare const commonBlendModes: {
|
|
10
10
|
* The below ParticleSystem consts were defined before new Engine alpha blend modes were added, so we have to reference
|
11
11
|
* the ParticleSystem.FOO consts explicitly (as the underlying const values are different - they get mapped to engine consts within baseParticleSystem.ts)
|
12
12
|
*/
|
13
|
-
export declare const
|
13
|
+
export declare const BlendModeOptions: {
|
14
14
|
label: string;
|
15
15
|
value: number;
|
16
16
|
}[];
|
17
17
|
/**
|
18
18
|
* Used to populated the alphaMode dropdown in our various tools (Node Editor, Inspector, etc.)
|
19
19
|
*/
|
20
|
-
export declare const
|
20
|
+
export declare const AlphaModeOptions: {
|
21
21
|
label: string;
|
22
22
|
value: number;
|
23
23
|
}[];
|
package/constToOptionsMaps.js
CHANGED
@@ -3,7 +3,7 @@ import { ParticleSystem } from "@babylonjs/core/Particles.js";
|
|
3
3
|
/**
|
4
4
|
* Used by both particleSystem and alphaBlendModes
|
5
5
|
*/
|
6
|
-
export const
|
6
|
+
export const CommonBlendModes = [
|
7
7
|
{ label: "Maximized", value: Constants.ALPHA_MAXIMIZED },
|
8
8
|
{ label: "Pre-multiplied", value: Constants.ALPHA_PREMULTIPLIED },
|
9
9
|
{ label: "Pre-multiplied Porter Duff", value: Constants.ALPHA_PREMULTIPLIED_PORTERDUFF },
|
@@ -21,22 +21,22 @@ export const commonBlendModes = [
|
|
21
21
|
* The below ParticleSystem consts were defined before new Engine alpha blend modes were added, so we have to reference
|
22
22
|
* the ParticleSystem.FOO consts explicitly (as the underlying const values are different - they get mapped to engine consts within baseParticleSystem.ts)
|
23
23
|
*/
|
24
|
-
export const
|
24
|
+
export const BlendModeOptions = [
|
25
25
|
{ label: "Add", value: ParticleSystem.BLENDMODE_ADD },
|
26
26
|
{ label: "Multiply", value: ParticleSystem.BLENDMODE_MULTIPLY },
|
27
27
|
{ label: "Multiply Add", value: ParticleSystem.BLENDMODE_MULTIPLYADD },
|
28
28
|
{ label: "One One", value: ParticleSystem.BLENDMODE_ONEONE },
|
29
29
|
{ label: "Standard", value: ParticleSystem.BLENDMODE_STANDARD },
|
30
30
|
{ label: "Subtract", value: ParticleSystem.BLENDMODE_SUBTRACT },
|
31
|
-
].concat(
|
31
|
+
].concat(CommonBlendModes);
|
32
32
|
/**
|
33
33
|
* Used to populated the alphaMode dropdown in our various tools (Node Editor, Inspector, etc.)
|
34
34
|
*/
|
35
|
-
export const
|
35
|
+
export const AlphaModeOptions = [
|
36
36
|
{ label: "Combine", value: Constants.ALPHA_COMBINE },
|
37
37
|
{ label: "One One", value: Constants.ALPHA_ONEONE },
|
38
38
|
{ label: "Add", value: Constants.ALPHA_ADD },
|
39
39
|
{ label: "Subtract", value: Constants.ALPHA_SUBTRACT },
|
40
40
|
{ label: "Multiply", value: Constants.ALPHA_MULTIPLY },
|
41
|
-
].concat(
|
41
|
+
].concat(CommonBlendModes);
|
42
42
|
//# sourceMappingURL=constToOptionsMaps.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constToOptionsMaps.js","sourceRoot":"","sources":["../../../dev/sharedUiComponents/src/constToOptionsMaps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,mCAAqB;AACzC,OAAO,EAAE,cAAc,EAAE,qCAAuB;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,CAAC,eAAe,EAAE;IACxD,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,mBAAmB,EAAE;IACjE,EAAE,KAAK,EAAE,4BAA4B,EAAE,KAAK,EAAE,SAAS,CAAC,8BAA8B,EAAE;IACxF,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,CAAC,gBAAgB,EAAE;IAC3D,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,SAAS,CAAC,mBAAmB,EAAE;IAChE,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,kBAAkB,EAAE;IAChE,EAAE,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,SAAS,CAAC,qBAAqB,EAAE;IACtE,EAAE,KAAK,EAAE,iCAAiC,EAAE,KAAK,EAAE,SAAS,CAAC,6BAA6B,EAAE;IAC5F,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,oBAAoB,EAAE;IAClE,EAAE,KAAK,EAAE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em and alphaBlendModes\r\n */\r\nexport const
|
1
|
+
{"version":3,"file":"constToOptionsMaps.js","sourceRoot":"","sources":["../../../dev/sharedUiComponents/src/constToOptionsMaps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,mCAAqB;AACzC,OAAO,EAAE,cAAc,EAAE,qCAAuB;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,CAAC,eAAe,EAAE;IACxD,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,mBAAmB,EAAE;IACjE,EAAE,KAAK,EAAE,4BAA4B,EAAE,KAAK,EAAE,SAAS,CAAC,8BAA8B,EAAE;IACxF,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,CAAC,gBAAgB,EAAE;IAC3D,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,SAAS,CAAC,mBAAmB,EAAE;IAChE,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,kBAAkB,EAAE;IAChE,EAAE,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,SAAS,CAAC,qBAAqB,EAAE;IACtE,EAAE,KAAK,EAAE,iCAAiC,EAAE,KAAK,EAAE,SAAS,CAAC,6BAA6B,EAAE;IAC5F,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,CAAC,oBAAoB,EAAE;IAClE,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,CAAC,eAAe,EAAE;IACxD,EAAE,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,CAAC,sBAAsB,EAAE;CACzE,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,CAAC,aAAa,EAAE;IACrD,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,CAAC,kBAAkB,EAAE;IAC/D,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,cAAc,CAAC,qBAAqB,EAAE;IACtE,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,cAAc,CAAC,gBAAgB,EAAE;IAC5D,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,CAAC,kBAAkB,EAAE;IAC/D,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,CAAC,kBAAkB,EAAE;CAClE,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAE3B;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC,aAAa,EAAE;IACpD,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC,YAAY,EAAE;IACnD,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,SAAS,EAAE;IAC5C,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,cAAc,EAAE;IACtD,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,cAAc,EAAE;CACzD,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["import { Constants } from \"core/Engines\";\r\nimport { ParticleSystem } from \"core/Particles\";\r\n\r\n/**\r\n * Used by both particleSystem and alphaBlendModes\r\n */\r\nexport const CommonBlendModes = [\r\n { label: \"Maximized\", value: Constants.ALPHA_MAXIMIZED },\r\n { label: \"Pre-multiplied\", value: Constants.ALPHA_PREMULTIPLIED },\r\n { label: \"Pre-multiplied Porter Duff\", value: Constants.ALPHA_PREMULTIPLIED_PORTERDUFF },\r\n { label: \"Screen Mode\", value: Constants.ALPHA_SCREENMODE },\r\n { label: \"OneOne OneOne\", value: Constants.ALPHA_ONEONE_ONEONE },\r\n { label: \"Alpha to Color\", value: Constants.ALPHA_ALPHATOCOLOR },\r\n { label: \"Reverse One Minus\", value: Constants.ALPHA_REVERSEONEMINUS },\r\n { label: \"Source+Dest * (1 - SourceAlpha)\", value: Constants.ALPHA_SRC_DSTONEMINUSSRCALPHA },\r\n { label: \"OneOne OneZero\", value: Constants.ALPHA_ONEONE_ONEZERO },\r\n { label: \"Exclusion\", value: Constants.ALPHA_EXCLUSION },\r\n { label: \"Layer Accumulate\", value: Constants.ALPHA_LAYER_ACCUMULATE },\r\n];\r\n\r\n/**\r\n * Used to populated the blendMode dropdown in our various tools (Node Editor, Inspector, etc.)\r\n * The below ParticleSystem consts were defined before new Engine alpha blend modes were added, so we have to reference\r\n * the ParticleSystem.FOO consts explicitly (as the underlying const values are different - they get mapped to engine consts within baseParticleSystem.ts)\r\n */\r\nexport const BlendModeOptions = [\r\n { label: \"Add\", value: ParticleSystem.BLENDMODE_ADD },\r\n { label: \"Multiply\", value: ParticleSystem.BLENDMODE_MULTIPLY },\r\n { label: \"Multiply Add\", value: ParticleSystem.BLENDMODE_MULTIPLYADD },\r\n { label: \"One One\", value: ParticleSystem.BLENDMODE_ONEONE },\r\n { label: \"Standard\", value: ParticleSystem.BLENDMODE_STANDARD },\r\n { label: \"Subtract\", value: ParticleSystem.BLENDMODE_SUBTRACT },\r\n].concat(CommonBlendModes);\r\n\r\n/**\r\n * Used to populated the alphaMode dropdown in our various tools (Node Editor, Inspector, etc.)\r\n */\r\nexport const AlphaModeOptions = [\r\n { label: \"Combine\", value: Constants.ALPHA_COMBINE },\r\n { label: \"One One\", value: Constants.ALPHA_ONEONE },\r\n { label: \"Add\", value: Constants.ALPHA_ADD },\r\n { label: \"Subtract\", value: Constants.ALPHA_SUBTRACT },\r\n { label: \"Multiply\", value: Constants.ALPHA_MULTIPLY },\r\n].concat(CommonBlendModes);\r\n"]}
|
@@ -1,14 +1,15 @@
|
|
1
1
|
import { GetClassName } from "@babylonjs/core/Misc/typeStore.js";
|
2
2
|
// Check if BABYLON namespace exists
|
3
|
-
let
|
4
|
-
const
|
5
|
-
if (typeof
|
6
|
-
if (typeof
|
7
|
-
|
3
|
+
let BabylonNamespace = "";
|
4
|
+
const GlobalObject = typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : undefined;
|
5
|
+
if (typeof GlobalObject !== "undefined") {
|
6
|
+
if (typeof GlobalObject.BABYLON !== "undefined") {
|
7
|
+
BabylonNamespace = "BABYLON.";
|
8
8
|
}
|
9
9
|
}
|
10
10
|
// Inspired by previous copyToClipboard() function which was copying Color3
|
11
11
|
// Copies strCommand to clipboard
|
12
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
12
13
|
export function copyCommandToClipboard(strCommand) {
|
13
14
|
const element = document.createElement("div");
|
14
15
|
element.textContent = strCommand;
|
@@ -24,11 +25,12 @@ export function copyCommandToClipboard(strCommand) {
|
|
24
25
|
}
|
25
26
|
// Return the class name of the considered target
|
26
27
|
// babylonNamespace is either "" (ES6) or "BABYLON."
|
28
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
27
29
|
export function getClassNameWithNamespace(obj) {
|
28
30
|
let className = GetClassName(obj);
|
29
31
|
if (className.includes("BABYLON.")) {
|
30
32
|
className = className.split("BABYLON.")[1];
|
31
33
|
}
|
32
|
-
return { className, babylonNamespace };
|
34
|
+
return { className, babylonNamespace: BabylonNamespace };
|
33
35
|
}
|
34
36
|
//# sourceMappingURL=copyCommandToClipboard.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"copyCommandToClipboard.js","sourceRoot":"","sources":["../../../dev/sharedUiComponents/src/copyCommandToClipboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,0CAA4B;AAEnD,oCAAoC;AACpC,IAAI,gBAAgB,GAAG,EAAE,CAAC;AAC1B,MAAM,YAAY,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,C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I,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACjC,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC;AAC7D,CAAC","sourcesContent":["import { GetClassName } from \"core/Misc/typeStore\";\r\n\r\n// Check if BABYLON namespace exists\r\nlet BabylonNamespace = \"\";\r\nconst GlobalObject = typeof global !== \"undefined\" ? global : typeof window !== \"undefined\" ? window : undefined;\r\nif (typeof GlobalObject !== \"undefined\") {\r\n if (typeof (<any>GlobalObject).BABYLON !== \"undefined\") {\r\n BabylonNamespace = \"BABYLON.\";\r\n }\r\n}\r\n\r\n// Inspired by previous copyToClipboard() function which was copying Color3\r\n// Copies strCommand to clipboard\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function copyCommandToClipboard(strCommand: string) {\r\n const element = document.createElement(\"div\");\r\n element.textContent = strCommand;\r\n document.body.appendChild(element);\r\n\r\n if (window.getSelection) {\r\n const range = document.createRange();\r\n range.selectNode(element);\r\n window.getSelection()!.removeAllRanges();\r\n window.getSelection()!.addRange(range);\r\n }\r\n\r\n document.execCommand(\"copy\");\r\n element.remove();\r\n}\r\n\r\n// Return the class name of the considered target\r\n// babylonNamespace is either \"\" (ES6) or \"BABYLON.\"\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function getClassNameWithNamespace(obj: any): { className: string; babylonNamespace: string } {\r\n let className = GetClassName(obj);\r\n if (className.includes(\"BABYLON.\")) {\r\n className = className.split(\"BABYLON.\")[1];\r\n }\r\n return { className, babylonNamespace: BabylonNamespace };\r\n}\r\n"]}
|
package/historyStack.js
CHANGED
@@ -69,8 +69,9 @@ export class HistoryStack {
|
|
69
69
|
this._locked = false;
|
70
70
|
}
|
71
71
|
_generateJSONDiff(obj1, obj2) {
|
72
|
-
if (obj1 === obj2)
|
72
|
+
if (obj1 === obj2) {
|
73
73
|
return undefined;
|
74
|
+
}
|
74
75
|
if (obj1 === null || obj2 === null || typeof obj1 !== "object" || typeof obj2 !== "object") {
|
75
76
|
if (obj1 !== obj2 && obj2 === undefined) {
|
76
77
|
return "@d@";
|