@babylonjs/shared-ui-components 5.28.0 → 5.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/colorPicker/colorComponentEntry.d.ts +18 -18
- package/colorPicker/colorComponentEntry.js +36 -36
- package/colorPicker/colorPicker.d.ts +43 -43
- package/colorPicker/colorPicker.js +136 -136
- package/colorPicker/hexColor.d.ts +20 -20
- package/colorPicker/hexColor.js +42 -42
- package/components/Button.d.ts +10 -10
- package/components/Button.js +6 -6
- package/components/Icon.d.ts +6 -6
- package/components/Icon.js +6 -6
- package/components/Label.d.ts +7 -7
- package/components/Label.js +6 -6
- package/components/MessageDialog.d.ts +7 -7
- package/components/MessageDialog.js +22 -22
- package/components/Toggle.d.ts +8 -8
- package/components/Toggle.js +15 -15
- package/components/bars/CommandBarComponent.d.ts +16 -16
- package/components/bars/CommandBarComponent.js +68 -68
- package/components/bars/CommandBarComponent.js.map +1 -1
- package/components/bars/CommandButtonComponent.d.ts +11 -11
- package/components/bars/CommandButtonComponent.js +6 -6
- package/components/bars/CommandDropdownComponent.d.ts +26 -26
- package/components/bars/CommandDropdownComponent.js +48 -48
- package/components/classNames.d.ts +2 -2
- package/components/classNames.js +18 -18
- package/components/colorPicker/ColorComponentEntry.d.ts +18 -18
- package/components/colorPicker/ColorComponentEntry.js +37 -37
- package/components/colorPicker/ColorPicker.d.ts +43 -43
- package/components/colorPicker/ColorPicker.js +137 -137
- package/components/colorPicker/HexColor.d.ts +20 -20
- package/components/colorPicker/HexColor.js +45 -45
- package/components/layout/DraggableIcon.d.ts +23 -0
- package/components/layout/DraggableIcon.js +18 -0
- package/components/layout/DraggableIcon.js.map +1 -0
- package/components/layout/FlexibleColumn.d.ts +17 -0
- package/components/layout/FlexibleColumn.js +12 -0
- package/components/layout/FlexibleColumn.js.map +1 -0
- package/components/layout/FlexibleDragHandler.d.ts +18 -0
- package/components/layout/FlexibleDragHandler.js +88 -0
- package/components/layout/FlexibleDragHandler.js.map +1 -0
- package/components/layout/FlexibleDropZone.d.ts +19 -0
- package/components/layout/FlexibleDropZone.js +12 -0
- package/components/layout/FlexibleDropZone.js.map +1 -0
- package/components/layout/FlexibleGridContainer.d.ts +10 -0
- package/components/layout/FlexibleGridContainer.js +23 -0
- package/components/layout/FlexibleGridContainer.js.map +1 -0
- package/components/layout/FlexibleGridLayout.d.ts +16 -0
- package/components/layout/FlexibleGridLayout.js +24 -0
- package/components/layout/FlexibleGridLayout.js.map +1 -0
- package/components/layout/FlexibleResizeBar.d.ts +40 -0
- package/components/layout/FlexibleResizeBar.js +21 -0
- package/components/layout/FlexibleResizeBar.js.map +1 -0
- package/components/layout/FlexibleTab.d.ts +34 -0
- package/components/layout/FlexibleTab.js +36 -0
- package/components/layout/FlexibleTab.js.map +1 -0
- package/components/layout/FlexibleTabsContainer.d.ts +28 -0
- package/components/layout/FlexibleTabsContainer.js +54 -0
- package/components/layout/FlexibleTabsContainer.js.map +1 -0
- package/components/layout/LayoutContext.d.ts +12 -0
- package/components/layout/LayoutContext.js +3 -0
- package/components/layout/LayoutContext.js.map +1 -0
- package/components/layout/types.d.ts +82 -0
- package/components/layout/types.js +13 -0
- package/components/layout/types.js.map +1 -0
- package/components/layout/utils.d.ts +25 -0
- package/components/layout/utils.js +68 -0
- package/components/layout/utils.js.map +1 -0
- package/components/lines/ColorLineComponent.d.ts +40 -40
- package/components/lines/ColorLineComponent.js +145 -145
- package/components/lines/ColorPickerLineComponent.d.ts +33 -33
- package/components/lines/ColorPickerLineComponent.js +61 -61
- package/components/lines/FileButtonLineComponent.d.ts +16 -16
- package/components/lines/FileButtonLineComponent.js +21 -21
- package/components/lines/NumericInputComponent.d.ts +31 -31
- package/components/lines/NumericInputComponent.js +86 -86
- package/lines/booleanLineComponent.d.ts +11 -11
- package/lines/booleanLineComponent.js +14 -14
- package/lines/buttonLineComponent.d.ts +12 -12
- package/lines/buttonLineComponent.js +10 -10
- package/lines/checkBoxLineComponent.d.ts +36 -36
- package/lines/checkBoxLineComponent.js +88 -88
- package/lines/color3LineComponent.d.ts +18 -18
- package/lines/color3LineComponent.js +9 -9
- package/lines/color4LineComponent.d.ts +18 -18
- package/lines/color4LineComponent.js +9 -9
- package/lines/colorLineComponent.d.ts +40 -40
- package/lines/colorLineComponent.js +144 -144
- package/lines/colorPickerComponent.d.ts +31 -31
- package/lines/colorPickerComponent.js +60 -60
- package/lines/draggableLineComponent.d.ts +9 -9
- package/lines/draggableLineComponent.js +12 -12
- package/lines/fileButtonLineComponent.d.ts +17 -17
- package/lines/fileButtonLineComponent.js +20 -20
- package/lines/fileMultipleButtonLineComponent.d.ts +17 -17
- package/lines/fileMultipleButtonLineComponent.js +20 -20
- package/lines/floatLineComponent.d.ts +50 -50
- package/lines/floatLineComponent.js +175 -175
- package/lines/hexLineComponent.d.ts +40 -40
- package/lines/hexLineComponent.js +121 -121
- package/lines/iSelectedLineContainer.d.ts +4 -4
- package/lines/iSelectedLineContainer.js +1 -1
- package/lines/iconButtonLineComponent.d.ts +11 -11
- package/lines/iconButtonLineComponent.js +10 -10
- package/lines/iconComponent.d.ts +9 -9
- package/lines/iconComponent.js +7 -7
- package/lines/indentedTextLineComponent.d.ts +16 -16
- package/lines/indentedTextLineComponent.js +26 -26
- package/lines/inputArrowsComponent.d.ts +13 -13
- package/lines/inputArrowsComponent.js +37 -37
- package/lines/lineContainerComponent.d.ts +19 -19
- package/lines/lineContainerComponent.js +49 -49
- package/lines/linkButtonComponent.d.ts +16 -16
- package/lines/linkButtonComponent.js +20 -20
- package/lines/matrixLineComponent.d.ts +36 -36
- package/lines/matrixLineComponent.js +102 -102
- package/lines/messageLineComponent.d.ts +12 -12
- package/lines/messageLineComponent.js +14 -14
- package/lines/numericInputComponent.d.ts +31 -31
- package/lines/numericInputComponent.js +85 -85
- package/lines/optionsLineComponent.d.ts +48 -48
- package/lines/optionsLineComponent.js +118 -118
- package/lines/popup.d.ts +4 -4
- package/lines/popup.js +67 -67
- package/lines/radioLineComponent.d.ts +21 -21
- package/lines/radioLineComponent.js +26 -26
- package/lines/sliderLineComponent.d.ts +37 -37
- package/lines/sliderLineComponent.js +89 -89
- package/lines/targetsProxy.d.ts +11 -11
- package/lines/targetsProxy.js +42 -42
- package/lines/textInputLineComponent.d.ts +47 -47
- package/lines/textInputLineComponent.js +154 -154
- package/lines/textLineComponent.d.ts +21 -21
- package/lines/textLineComponent.js +30 -30
- package/lines/unitButton.d.ts +8 -8
- package/lines/unitButton.js +7 -7
- package/lines/valueLineComponent.d.ts +15 -15
- package/lines/valueLineComponent.js +12 -12
- package/lines/vector2LineComponent.d.ts +36 -36
- package/lines/vector2LineComponent.js +63 -63
- package/lines/vector3LineComponent.d.ts +41 -41
- package/lines/vector3LineComponent.js +74 -74
- package/lines/vector4LineComponent.d.ts +42 -42
- package/lines/vector4LineComponent.js +81 -81
- package/nodeGraphSystem/displayLedger.d.ts +5 -5
- package/nodeGraphSystem/displayLedger.js +3 -3
- package/nodeGraphSystem/frameNodePort.d.ts +25 -25
- package/nodeGraphSystem/frameNodePort.js +59 -59
- package/nodeGraphSystem/graphCanvas.d.ts +117 -111
- package/nodeGraphSystem/graphCanvas.js +1137 -1131
- package/nodeGraphSystem/graphCanvas.js.map +1 -1
- package/nodeGraphSystem/graphFrame.d.ts +153 -153
- package/nodeGraphSystem/graphFrame.js +1328 -1328
- package/nodeGraphSystem/graphNode.d.ts +81 -79
- package/nodeGraphSystem/graphNode.js +465 -459
- package/nodeGraphSystem/graphNode.js.map +1 -1
- package/nodeGraphSystem/interfaces/displayManager.d.ts +13 -13
- package/nodeGraphSystem/interfaces/displayManager.js +1 -1
- package/nodeGraphSystem/interfaces/nodeContainer.d.ts +6 -6
- package/nodeGraphSystem/interfaces/nodeContainer.js +1 -1
- package/nodeGraphSystem/interfaces/nodeData.d.ts +15 -15
- package/nodeGraphSystem/interfaces/nodeData.js +1 -1
- package/nodeGraphSystem/interfaces/nodeLocationInfo.d.ts +26 -26
- package/nodeGraphSystem/interfaces/nodeLocationInfo.js +1 -1
- package/nodeGraphSystem/interfaces/portData.d.ts +28 -28
- package/nodeGraphSystem/interfaces/portData.js +7 -7
- package/nodeGraphSystem/interfaces/propertyComponentProps.d.ts +6 -6
- package/nodeGraphSystem/interfaces/propertyComponentProps.js +1 -1
- package/nodeGraphSystem/interfaces/selectionChangedOptions.d.ts +11 -11
- package/nodeGraphSystem/interfaces/selectionChangedOptions.js +1 -1
- package/nodeGraphSystem/nodeLink.d.ts +31 -31
- package/nodeGraphSystem/nodeLink.js +182 -182
- package/nodeGraphSystem/nodePort.d.ts +35 -35
- package/nodeGraphSystem/nodePort.js +128 -128
- package/nodeGraphSystem/propertyLedger.d.ts +8 -8
- package/nodeGraphSystem/propertyLedger.js +3 -3
- package/nodeGraphSystem/stateManager.d.ts +45 -45
- package/nodeGraphSystem/stateManager.js +18 -18
- package/nodeGraphSystem/tools.d.ts +5 -5
- package/nodeGraphSystem/tools.js +36 -36
- package/nodeGraphSystem/typeLedger.d.ts +8 -8
- package/nodeGraphSystem/typeLedger.js +2 -2
- package/nodeGraphSystem/types/framePortData.d.ts +7 -7
- package/nodeGraphSystem/types/framePortData.js +1 -1
- package/package.json +4 -3
- package/propertyChangedEvent.d.ts +7 -7
- package/propertyChangedEvent.js +2 -2
- package/stories/Button.stories.d.ts +10 -10
- package/stories/Button.stories.js +19 -19
- package/stories/Icon.stories.d.ts +9 -9
- package/stories/Icon.stories.js +16 -16
- package/stories/Label.stories.d.ts +8 -8
- package/stories/Label.stories.js +10 -10
- package/stories/MessageDialog.stories.d.ts +9 -9
- package/stories/MessageDialog.stories.js +19 -19
- package/stories/Toggle.stories.d.ts +9 -9
- package/stories/Toggle.stories.js +17 -17
- package/stories/bars/CommandBarComponent.stories.d.ts +11 -11
- package/stories/bars/CommandBarComponent.stories.js +12 -12
- package/stories/bars/CommandButtonComponent.stories.d.ts +6 -6
- package/stories/bars/CommandButtonComponent.stories.js +6 -6
- package/stories/colorPicker/ColorPicker.stories.d.ts +11 -11
- package/stories/colorPicker/ColorPicker.stories.js +4 -4
- package/stories/layout/FlexibleGridLayout.stories.d.ts +46 -0
- package/stories/layout/FlexibleGridLayout.stories.js +48 -0
- package/stories/layout/FlexibleGridLayout.stories.js.map +1 -0
- package/stories/lines/ColorLineComponent.stories.d.ts +21 -21
- package/stories/lines/ColorLineComponent.stories.js +9 -9
- package/stories/lines/ColorPickerLineComponent.stories.d.ts +14 -14
- package/stories/lines/ColorPickerLineComponent.stories.js +10 -10
- package/stories/lines/FileButtonLineComponent.stories.d.ts +6 -6
- package/stories/lines/FileButtonLineComponent.stories.js +5 -5
- package/stories/lines/NumericInputComponent.stories.d.ts +11 -11
- package/stories/lines/NumericInputComponent.stories.js +5 -5
- package/stringTools.d.ts +11 -11
- package/stringTools.js +88 -88
- package/tabs/propertyGrids/gui/checkboxPropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/checkboxPropertyGridComponent.js +15 -15
- package/tabs/propertyGrids/gui/colorPickerPropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/colorPickerPropertyGridComponent.js +14 -14
- package/tabs/propertyGrids/gui/commonControlPropertyGridComponent.d.ts +17 -17
- package/tabs/propertyGrids/gui/commonControlPropertyGridComponent.js +55 -55
- package/tabs/propertyGrids/gui/controlPropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/controlPropertyGridComponent.js +12 -12
- package/tabs/propertyGrids/gui/ellipsePropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/ellipsePropertyGridComponent.js +15 -15
- package/tabs/propertyGrids/gui/gridPropertyGridComponent.d.ts +17 -17
- package/tabs/propertyGrids/gui/gridPropertyGridComponent.js +38 -38
- package/tabs/propertyGrids/gui/imageBasedSliderPropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/imageBasedSliderPropertyGridComponent.js +16 -16
- package/tabs/propertyGrids/gui/imagePropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/imagePropertyGridComponent.js +25 -25
- package/tabs/propertyGrids/gui/inputTextPropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/inputTextPropertyGridComponent.js +17 -17
- package/tabs/propertyGrids/gui/linePropertyGridComponent.d.ts +16 -16
- package/tabs/propertyGrids/gui/linePropertyGridComponent.js +27 -27
- package/tabs/propertyGrids/gui/radioButtonPropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/radioButtonPropertyGridComponent.js +17 -17
- package/tabs/propertyGrids/gui/rectanglePropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/rectanglePropertyGridComponent.js +15 -15
- package/tabs/propertyGrids/gui/scrollViewerPropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/scrollViewerPropertyGridComponent.js +15 -15
- package/tabs/propertyGrids/gui/sliderPropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/sliderPropertyGridComponent.js +16 -16
- package/tabs/propertyGrids/gui/stackPanelPropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/stackPanelPropertyGridComponent.js +14 -14
- package/tabs/propertyGrids/gui/textBlockPropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/textBlockPropertyGridComponent.js +34 -34
- package/tabs/propertyGrids/lockObject.d.ts +9 -9
- package/tabs/propertyGrids/lockObject.js +11 -11
@@ -1,86 +1,86 @@
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
-
import * as React from "react";
|
3
|
-
export class NumericInputComponent extends React.Component {
|
4
|
-
constructor(props) {
|
5
|
-
super(props);
|
6
|
-
this._localChange = false;
|
7
|
-
this.state = { value: this.props.value.toFixed(this.props.precision !== undefined ? this.props.precision : 3) };
|
8
|
-
}
|
9
|
-
componentWillUnmount() {
|
10
|
-
if (this.props.lockObject) {
|
11
|
-
this.props.lockObject.lock = false;
|
12
|
-
}
|
13
|
-
}
|
14
|
-
shouldComponentUpdate(nextProps, nextState) {
|
15
|
-
if (this._localChange) {
|
16
|
-
return true;
|
17
|
-
}
|
18
|
-
if (nextProps.value.toString() !== nextState.value) {
|
19
|
-
nextState.value = nextProps.value.toFixed(this.props.precision !== undefined ? this.props.precision : 3);
|
20
|
-
return true;
|
21
|
-
}
|
22
|
-
return false;
|
23
|
-
}
|
24
|
-
updateValue(valueString) {
|
25
|
-
if (/[^0-9.-]/g.test(valueString)) {
|
26
|
-
return;
|
27
|
-
}
|
28
|
-
const valueAsNumber = parseFloat(valueString);
|
29
|
-
this._localChange = true;
|
30
|
-
this.setState({ value: valueString });
|
31
|
-
if (isNaN(valueAsNumber)) {
|
32
|
-
return;
|
33
|
-
}
|
34
|
-
this.props.onChange(valueAsNumber);
|
35
|
-
}
|
36
|
-
onBlur() {
|
37
|
-
this._localChange = false;
|
38
|
-
const valueAsNumber = parseFloat(this.state.value);
|
39
|
-
if (this.props.lockObject) {
|
40
|
-
this.props.lockObject.lock = false;
|
41
|
-
}
|
42
|
-
if (isNaN(valueAsNumber)) {
|
43
|
-
this.props.onChange(this.props.value);
|
44
|
-
return;
|
45
|
-
}
|
46
|
-
this.props.onChange(valueAsNumber);
|
47
|
-
}
|
48
|
-
incrementValue(amount) {
|
49
|
-
let currentValue = parseFloat(this.state.value);
|
50
|
-
if (isNaN(currentValue)) {
|
51
|
-
currentValue = 0;
|
52
|
-
}
|
53
|
-
this.updateValue((currentValue + amount).toFixed(this.props.precision !== undefined ? this.props.precision : 3));
|
54
|
-
}
|
55
|
-
onKeyDown(evt) {
|
56
|
-
const step = this.props.step || 1;
|
57
|
-
const handleArrowKey = (sign) => {
|
58
|
-
if (evt.shiftKey) {
|
59
|
-
sign *= 10;
|
60
|
-
if (evt.ctrlKey || evt.metaKey) {
|
61
|
-
sign *= 10;
|
62
|
-
}
|
63
|
-
}
|
64
|
-
this.incrementValue(sign * step);
|
65
|
-
evt.preventDefault();
|
66
|
-
};
|
67
|
-
if (evt.key === "ArrowUp") {
|
68
|
-
handleArrowKey(1);
|
69
|
-
}
|
70
|
-
else if (evt.key === "ArrowDown") {
|
71
|
-
handleArrowKey(-1);
|
72
|
-
}
|
73
|
-
}
|
74
|
-
render() {
|
75
|
-
return (_jsxs("div", { className: "numeric", 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: "numeric-label", title: this.props.label, children: `${this.props.label}: ` })), _jsx("input", { type: "number", step: this.props.step, className: "numeric-input", value: this.state.value, onChange: (evt) => this.updateValue(evt.target.value), onKeyDown: (evt) => this.onKeyDown(evt), onFocus: () => {
|
76
|
-
if (this.props.lockObject) {
|
77
|
-
this.props.lockObject.lock = true;
|
78
|
-
}
|
79
|
-
}, onBlur: () => this.onBlur() })] }));
|
80
|
-
}
|
81
|
-
}
|
82
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
83
|
-
NumericInputComponent.defaultProps = {
|
84
|
-
step: 1,
|
85
|
-
};
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import * as React from "react";
|
3
|
+
export class NumericInputComponent extends React.Component {
|
4
|
+
constructor(props) {
|
5
|
+
super(props);
|
6
|
+
this._localChange = false;
|
7
|
+
this.state = { value: this.props.value.toFixed(this.props.precision !== undefined ? this.props.precision : 3) };
|
8
|
+
}
|
9
|
+
componentWillUnmount() {
|
10
|
+
if (this.props.lockObject) {
|
11
|
+
this.props.lockObject.lock = false;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
shouldComponentUpdate(nextProps, nextState) {
|
15
|
+
if (this._localChange) {
|
16
|
+
return true;
|
17
|
+
}
|
18
|
+
if (nextProps.value.toString() !== nextState.value) {
|
19
|
+
nextState.value = nextProps.value.toFixed(this.props.precision !== undefined ? this.props.precision : 3);
|
20
|
+
return true;
|
21
|
+
}
|
22
|
+
return false;
|
23
|
+
}
|
24
|
+
updateValue(valueString) {
|
25
|
+
if (/[^0-9.-]/g.test(valueString)) {
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
const valueAsNumber = parseFloat(valueString);
|
29
|
+
this._localChange = true;
|
30
|
+
this.setState({ value: valueString });
|
31
|
+
if (isNaN(valueAsNumber)) {
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
this.props.onChange(valueAsNumber);
|
35
|
+
}
|
36
|
+
onBlur() {
|
37
|
+
this._localChange = false;
|
38
|
+
const valueAsNumber = parseFloat(this.state.value);
|
39
|
+
if (this.props.lockObject) {
|
40
|
+
this.props.lockObject.lock = false;
|
41
|
+
}
|
42
|
+
if (isNaN(valueAsNumber)) {
|
43
|
+
this.props.onChange(this.props.value);
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
this.props.onChange(valueAsNumber);
|
47
|
+
}
|
48
|
+
incrementValue(amount) {
|
49
|
+
let currentValue = parseFloat(this.state.value);
|
50
|
+
if (isNaN(currentValue)) {
|
51
|
+
currentValue = 0;
|
52
|
+
}
|
53
|
+
this.updateValue((currentValue + amount).toFixed(this.props.precision !== undefined ? this.props.precision : 3));
|
54
|
+
}
|
55
|
+
onKeyDown(evt) {
|
56
|
+
const step = this.props.step || 1;
|
57
|
+
const handleArrowKey = (sign) => {
|
58
|
+
if (evt.shiftKey) {
|
59
|
+
sign *= 10;
|
60
|
+
if (evt.ctrlKey || evt.metaKey) {
|
61
|
+
sign *= 10;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
this.incrementValue(sign * step);
|
65
|
+
evt.preventDefault();
|
66
|
+
};
|
67
|
+
if (evt.key === "ArrowUp") {
|
68
|
+
handleArrowKey(1);
|
69
|
+
}
|
70
|
+
else if (evt.key === "ArrowDown") {
|
71
|
+
handleArrowKey(-1);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
render() {
|
75
|
+
return (_jsxs("div", { className: "numeric", 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: "numeric-label", title: this.props.label, children: `${this.props.label}: ` })), _jsx("input", { type: "number", step: this.props.step, className: "numeric-input", value: this.state.value, onChange: (evt) => this.updateValue(evt.target.value), onKeyDown: (evt) => this.onKeyDown(evt), onFocus: () => {
|
76
|
+
if (this.props.lockObject) {
|
77
|
+
this.props.lockObject.lock = true;
|
78
|
+
}
|
79
|
+
}, onBlur: () => this.onBlur() })] }));
|
80
|
+
}
|
81
|
+
}
|
82
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
83
|
+
NumericInputComponent.defaultProps = {
|
84
|
+
step: 1,
|
85
|
+
};
|
86
86
|
//# sourceMappingURL=numericInputComponent.js.map
|
@@ -1,48 +1,48 @@
|
|
1
|
-
import * as React from "react";
|
2
|
-
import type { Observable } from "@babylonjs/core/Misc/observable.js";
|
3
|
-
import type { PropertyChangedEvent } from "../propertyChangedEvent";
|
4
|
-
import type { IInspectableOptions } from "@babylonjs/core/Misc/iInspectable.js";
|
5
|
-
export declare const Null_Value: number;
|
6
|
-
export interface IOptionsLineComponentProps {
|
7
|
-
label: string;
|
8
|
-
target: any;
|
9
|
-
propertyName: string;
|
10
|
-
options: IInspectableOptions[];
|
11
|
-
addInput?: boolean;
|
12
|
-
noDirectUpdate?: boolean;
|
13
|
-
onSelect?: (value: number | string) => void;
|
14
|
-
extractValue?: (target: any) => number | string;
|
15
|
-
addVal?: (newVal: {
|
16
|
-
label: string;
|
17
|
-
value: number;
|
18
|
-
}, prevVal: number) => void;
|
19
|
-
onPropertyChangedObservable?: Observable<PropertyChangedEvent>;
|
20
|
-
allowNullValue?: boolean;
|
21
|
-
icon?: string;
|
22
|
-
iconLabel?: string;
|
23
|
-
className?: string;
|
24
|
-
valuesAreStrings?: boolean;
|
25
|
-
defaultIfNull?: number;
|
26
|
-
fromFontDropdown?: boolean;
|
27
|
-
valueProp?: number;
|
28
|
-
fallbackValue?: number;
|
29
|
-
}
|
30
|
-
export declare class OptionsLineComponent extends React.Component<IOptionsLineComponentProps, {
|
31
|
-
value: number | string;
|
32
|
-
addCustom: boolean;
|
33
|
-
}> {
|
34
|
-
private _localChange;
|
35
|
-
private _remapValueIn;
|
36
|
-
private _remapValueOut;
|
37
|
-
private _getValue;
|
38
|
-
constructor(props: IOptionsLineComponentProps);
|
39
|
-
shouldComponentUpdate(nextProps: IOptionsLineComponentProps, nextState: {
|
40
|
-
value: number;
|
41
|
-
addCustom: boolean;
|
42
|
-
}): boolean;
|
43
|
-
raiseOnPropertyChanged(newValue: number, previousValue: number): void;
|
44
|
-
setValue(value: string | number): void;
|
45
|
-
updateValue(valueString: string): void;
|
46
|
-
updateCustomValue(): void;
|
47
|
-
render(): JSX.Element;
|
48
|
-
}
|
1
|
+
import * as React from "react";
|
2
|
+
import type { Observable } from "@babylonjs/core/Misc/observable.js";
|
3
|
+
import type { PropertyChangedEvent } from "../propertyChangedEvent";
|
4
|
+
import type { IInspectableOptions } from "@babylonjs/core/Misc/iInspectable.js";
|
5
|
+
export declare const Null_Value: number;
|
6
|
+
export interface IOptionsLineComponentProps {
|
7
|
+
label: string;
|
8
|
+
target: any;
|
9
|
+
propertyName: string;
|
10
|
+
options: IInspectableOptions[];
|
11
|
+
addInput?: boolean;
|
12
|
+
noDirectUpdate?: boolean;
|
13
|
+
onSelect?: (value: number | string) => void;
|
14
|
+
extractValue?: (target: any) => number | string;
|
15
|
+
addVal?: (newVal: {
|
16
|
+
label: string;
|
17
|
+
value: number;
|
18
|
+
}, prevVal: number) => void;
|
19
|
+
onPropertyChangedObservable?: Observable<PropertyChangedEvent>;
|
20
|
+
allowNullValue?: boolean;
|
21
|
+
icon?: string;
|
22
|
+
iconLabel?: string;
|
23
|
+
className?: string;
|
24
|
+
valuesAreStrings?: boolean;
|
25
|
+
defaultIfNull?: number;
|
26
|
+
fromFontDropdown?: boolean;
|
27
|
+
valueProp?: number;
|
28
|
+
fallbackValue?: number;
|
29
|
+
}
|
30
|
+
export declare class OptionsLineComponent extends React.Component<IOptionsLineComponentProps, {
|
31
|
+
value: number | string;
|
32
|
+
addCustom: boolean;
|
33
|
+
}> {
|
34
|
+
private _localChange;
|
35
|
+
private _remapValueIn;
|
36
|
+
private _remapValueOut;
|
37
|
+
private _getValue;
|
38
|
+
constructor(props: IOptionsLineComponentProps);
|
39
|
+
shouldComponentUpdate(nextProps: IOptionsLineComponentProps, nextState: {
|
40
|
+
value: number;
|
41
|
+
addCustom: boolean;
|
42
|
+
}): boolean;
|
43
|
+
raiseOnPropertyChanged(newValue: number, previousValue: number): void;
|
44
|
+
setValue(value: string | number): void;
|
45
|
+
updateValue(valueString: string): void;
|
46
|
+
updateCustomValue(): void;
|
47
|
+
render(): JSX.Element;
|
48
|
+
}
|
@@ -1,119 +1,119 @@
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
-
import * as React from "react";
|
3
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
4
|
-
export const Null_Value = Number.MAX_SAFE_INTEGER;
|
5
|
-
const DEFAULT_FALLBACK_VALUE = -1;
|
6
|
-
export class OptionsLineComponent extends React.Component {
|
7
|
-
constructor(props) {
|
8
|
-
// Initialize default props
|
9
|
-
super(props);
|
10
|
-
this._localChange = false;
|
11
|
-
this.state = { value: this._remapValueIn(this._getValue(props)), addCustom: false };
|
12
|
-
}
|
13
|
-
_remapValueIn(value) {
|
14
|
-
return this.props.allowNullValue && value === null ? Null_Value : value;
|
15
|
-
}
|
16
|
-
_remapValueOut(value) {
|
17
|
-
return this.props.allowNullValue && value === Null_Value ? null : value;
|
18
|
-
}
|
19
|
-
_getValue(props) {
|
20
|
-
if (props.extractValue) {
|
21
|
-
return props.extractValue(props.target);
|
22
|
-
}
|
23
|
-
return props.target && props.propertyName ? props.target[props.propertyName] : props.options[props.defaultIfNull || 0];
|
24
|
-
}
|
25
|
-
shouldComponentUpdate(nextProps, nextState) {
|
26
|
-
if (this._localChange) {
|
27
|
-
this._localChange = false;
|
28
|
-
return true;
|
29
|
-
}
|
30
|
-
const newValue = this._remapValueIn(nextProps.extractValue ? nextProps.extractValue(nextProps.target) : nextProps.target[nextProps.propertyName]);
|
31
|
-
if (newValue != null && newValue !== nextState.value) {
|
32
|
-
nextState.value = newValue;
|
33
|
-
return true;
|
34
|
-
}
|
35
|
-
if (this.props.options !== nextProps.options) {
|
36
|
-
return true;
|
37
|
-
}
|
38
|
-
return false;
|
39
|
-
}
|
40
|
-
raiseOnPropertyChanged(newValue, previousValue) {
|
41
|
-
if (!this.props.onPropertyChangedObservable) {
|
42
|
-
return;
|
43
|
-
}
|
44
|
-
this.props.onPropertyChangedObservable.notifyObservers({
|
45
|
-
object: this.props.target,
|
46
|
-
property: this.props.propertyName,
|
47
|
-
value: newValue,
|
48
|
-
initialValue: previousValue,
|
49
|
-
allowNullValue: this.props.allowNullValue,
|
50
|
-
});
|
51
|
-
}
|
52
|
-
setValue(value) {
|
53
|
-
this.setState({ value: value });
|
54
|
-
}
|
55
|
-
updateValue(valueString) {
|
56
|
-
var _a, _b;
|
57
|
-
let value = this.props.valuesAreStrings ? valueString : parseInt(valueString);
|
58
|
-
if (isNaN(Number(value))) {
|
59
|
-
for (let i = 0; i < this.props.options.length; i++) {
|
60
|
-
if (((_a = this.props.options.at(i)) === null || _a === void 0 ? void 0 : _a.label) === valueString) {
|
61
|
-
value = Number((_b = this.props.options.at(i)) === null || _b === void 0 ? void 0 : _b.value);
|
62
|
-
}
|
63
|
-
}
|
64
|
-
}
|
65
|
-
if (value === 0 && this.props.fromFontDropdown) {
|
66
|
-
this.setState({ addCustom: true });
|
67
|
-
}
|
68
|
-
this._localChange = true;
|
69
|
-
const store = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];
|
70
|
-
if (!this.props.noDirectUpdate) {
|
71
|
-
this.props.target[this.props.propertyName] = this._remapValueOut(value);
|
72
|
-
}
|
73
|
-
//selecting a regular option from font dropdown
|
74
|
-
if (value != 0 && this.props.fromFontDropdown) {
|
75
|
-
this.setState({ value: value });
|
76
|
-
if (this.props.onSelect) {
|
77
|
-
this.props.onSelect(value);
|
78
|
-
}
|
79
|
-
//selecting 'custom font' from font dropdown
|
80
|
-
}
|
81
|
-
else if (this.props.fromFontDropdown) {
|
82
|
-
if (this.props.onSelect) {
|
83
|
-
this.props.onSelect(this.state.value);
|
84
|
-
}
|
85
|
-
}
|
86
|
-
//selecting from a dropdown that's not font dropdown
|
87
|
-
else {
|
88
|
-
this.setState({ value: value });
|
89
|
-
if (this.props.onSelect) {
|
90
|
-
this.props.onSelect(value);
|
91
|
-
}
|
92
|
-
}
|
93
|
-
const newValue = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];
|
94
|
-
this.raiseOnPropertyChanged(newValue, store);
|
95
|
-
}
|
96
|
-
updateCustomValue() {
|
97
|
-
this.setState({ addCustom: false });
|
98
|
-
}
|
99
|
-
render() {
|
100
|
-
var _a;
|
101
|
-
const fallback = this.props.fallbackValue !== undefined ? this.props.fallbackValue : DEFAULT_FALLBACK_VALUE;
|
102
|
-
return (_jsxs("div", { className: `listLine ${(_a = this.props.className) !== null && _a !== void 0 ? _a : ""}`, children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, color: "black", className: "icon" }), _jsx("div", { className: "label", title: this.props.label, children: this.props.label }), _jsx("div", { className: "options", children: this.state.addCustom ? (_jsx("input", { type: "text", placeholder: "Enter a custom font here", onKeyDown: (event) => {
|
103
|
-
event.key === "Enter" && this.props.addVal != undefined
|
104
|
-
? (this.props.addVal({ label: event.target.value, value: this.props.options.length + 1 }, Number(this.state.value)),
|
105
|
-
this.updateCustomValue(),
|
106
|
-
this.forceUpdate())
|
107
|
-
: null;
|
108
|
-
}, onBlur: (event) => {
|
109
|
-
this.props.addVal != undefined
|
110
|
-
? (this.props.addVal({ label: event.target.value, value: this.props.options.length + 1 }, Number(this.state.value)),
|
111
|
-
this.updateCustomValue(),
|
112
|
-
this.forceUpdate())
|
113
|
-
: null;
|
114
|
-
} })) : (_jsx("select", { onChange: (evt) => this.updateValue(evt.target.value), value: this.state.value === null || this.state.value === undefined ? fallback : this.state.value, children: this.props.options.map((option, i) => {
|
115
|
-
return (_jsx("option", { selected: option.selected, value: option.value, title: option.label, children: option.label }, option.label + i));
|
116
|
-
}) })) })] }));
|
117
|
-
}
|
118
|
-
}
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import * as React from "react";
|
3
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
4
|
+
export const Null_Value = Number.MAX_SAFE_INTEGER;
|
5
|
+
const DEFAULT_FALLBACK_VALUE = -1;
|
6
|
+
export class OptionsLineComponent extends React.Component {
|
7
|
+
constructor(props) {
|
8
|
+
// Initialize default props
|
9
|
+
super(props);
|
10
|
+
this._localChange = false;
|
11
|
+
this.state = { value: this._remapValueIn(this._getValue(props)), addCustom: false };
|
12
|
+
}
|
13
|
+
_remapValueIn(value) {
|
14
|
+
return this.props.allowNullValue && value === null ? Null_Value : value;
|
15
|
+
}
|
16
|
+
_remapValueOut(value) {
|
17
|
+
return this.props.allowNullValue && value === Null_Value ? null : value;
|
18
|
+
}
|
19
|
+
_getValue(props) {
|
20
|
+
if (props.extractValue) {
|
21
|
+
return props.extractValue(props.target);
|
22
|
+
}
|
23
|
+
return props.target && props.propertyName ? props.target[props.propertyName] : props.options[props.defaultIfNull || 0];
|
24
|
+
}
|
25
|
+
shouldComponentUpdate(nextProps, nextState) {
|
26
|
+
if (this._localChange) {
|
27
|
+
this._localChange = false;
|
28
|
+
return true;
|
29
|
+
}
|
30
|
+
const newValue = this._remapValueIn(nextProps.extractValue ? nextProps.extractValue(nextProps.target) : nextProps.target[nextProps.propertyName]);
|
31
|
+
if (newValue != null && newValue !== nextState.value) {
|
32
|
+
nextState.value = newValue;
|
33
|
+
return true;
|
34
|
+
}
|
35
|
+
if (this.props.options !== nextProps.options) {
|
36
|
+
return true;
|
37
|
+
}
|
38
|
+
return false;
|
39
|
+
}
|
40
|
+
raiseOnPropertyChanged(newValue, previousValue) {
|
41
|
+
if (!this.props.onPropertyChangedObservable) {
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
this.props.onPropertyChangedObservable.notifyObservers({
|
45
|
+
object: this.props.target,
|
46
|
+
property: this.props.propertyName,
|
47
|
+
value: newValue,
|
48
|
+
initialValue: previousValue,
|
49
|
+
allowNullValue: this.props.allowNullValue,
|
50
|
+
});
|
51
|
+
}
|
52
|
+
setValue(value) {
|
53
|
+
this.setState({ value: value });
|
54
|
+
}
|
55
|
+
updateValue(valueString) {
|
56
|
+
var _a, _b;
|
57
|
+
let value = this.props.valuesAreStrings ? valueString : parseInt(valueString);
|
58
|
+
if (isNaN(Number(value))) {
|
59
|
+
for (let i = 0; i < this.props.options.length; i++) {
|
60
|
+
if (((_a = this.props.options.at(i)) === null || _a === void 0 ? void 0 : _a.label) === valueString) {
|
61
|
+
value = Number((_b = this.props.options.at(i)) === null || _b === void 0 ? void 0 : _b.value);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
65
|
+
if (value === 0 && this.props.fromFontDropdown) {
|
66
|
+
this.setState({ addCustom: true });
|
67
|
+
}
|
68
|
+
this._localChange = true;
|
69
|
+
const store = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];
|
70
|
+
if (!this.props.noDirectUpdate) {
|
71
|
+
this.props.target[this.props.propertyName] = this._remapValueOut(value);
|
72
|
+
}
|
73
|
+
//selecting a regular option from font dropdown
|
74
|
+
if (value != 0 && this.props.fromFontDropdown) {
|
75
|
+
this.setState({ value: value });
|
76
|
+
if (this.props.onSelect) {
|
77
|
+
this.props.onSelect(value);
|
78
|
+
}
|
79
|
+
//selecting 'custom font' from font dropdown
|
80
|
+
}
|
81
|
+
else if (this.props.fromFontDropdown) {
|
82
|
+
if (this.props.onSelect) {
|
83
|
+
this.props.onSelect(this.state.value);
|
84
|
+
}
|
85
|
+
}
|
86
|
+
//selecting from a dropdown that's not font dropdown
|
87
|
+
else {
|
88
|
+
this.setState({ value: value });
|
89
|
+
if (this.props.onSelect) {
|
90
|
+
this.props.onSelect(value);
|
91
|
+
}
|
92
|
+
}
|
93
|
+
const newValue = this.props.extractValue ? this.props.extractValue(this.props.target) : this.props.target[this.props.propertyName];
|
94
|
+
this.raiseOnPropertyChanged(newValue, store);
|
95
|
+
}
|
96
|
+
updateCustomValue() {
|
97
|
+
this.setState({ addCustom: false });
|
98
|
+
}
|
99
|
+
render() {
|
100
|
+
var _a;
|
101
|
+
const fallback = this.props.fallbackValue !== undefined ? this.props.fallbackValue : DEFAULT_FALLBACK_VALUE;
|
102
|
+
return (_jsxs("div", { className: `listLine ${(_a = this.props.className) !== null && _a !== void 0 ? _a : ""}`, children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, color: "black", className: "icon" }), _jsx("div", { className: "label", title: this.props.label, children: this.props.label }), _jsx("div", { className: "options", children: this.state.addCustom ? (_jsx("input", { type: "text", placeholder: "Enter a custom font here", onKeyDown: (event) => {
|
103
|
+
event.key === "Enter" && this.props.addVal != undefined
|
104
|
+
? (this.props.addVal({ label: event.target.value, value: this.props.options.length + 1 }, Number(this.state.value)),
|
105
|
+
this.updateCustomValue(),
|
106
|
+
this.forceUpdate())
|
107
|
+
: null;
|
108
|
+
}, onBlur: (event) => {
|
109
|
+
this.props.addVal != undefined
|
110
|
+
? (this.props.addVal({ label: event.target.value, value: this.props.options.length + 1 }, Number(this.state.value)),
|
111
|
+
this.updateCustomValue(),
|
112
|
+
this.forceUpdate())
|
113
|
+
: null;
|
114
|
+
} })) : (_jsx("select", { onChange: (evt) => this.updateValue(evt.target.value), value: this.state.value === null || this.state.value === undefined ? fallback : this.state.value, children: this.props.options.map((option, i) => {
|
115
|
+
return (_jsx("option", { selected: option.selected, value: option.value, title: option.label, children: option.label }, option.label + i));
|
116
|
+
}) })) })] }));
|
117
|
+
}
|
118
|
+
}
|
119
119
|
//# sourceMappingURL=optionsLineComponent.js.map
|
package/lines/popup.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
export declare class Popup {
|
2
|
-
static CreatePopup(title: string, windowVariableName: string, width?: number, height?: number): HTMLDivElement | null;
|
3
|
-
private static _CopyStyles;
|
4
|
-
}
|
1
|
+
export declare class Popup {
|
2
|
+
static CreatePopup(title: string, windowVariableName: string, width?: number, height?: number): HTMLDivElement | null;
|
3
|
+
private static _CopyStyles;
|
4
|
+
}
|
package/lines/popup.js
CHANGED
@@ -1,68 +1,68 @@
|
|
1
|
-
export class Popup {
|
2
|
-
static CreatePopup(title, windowVariableName, width = 300, height = 800) {
|
3
|
-
const windowCreationOptionsList = {
|
4
|
-
width: width,
|
5
|
-
height: height,
|
6
|
-
top: (window.innerHeight - width) / 2 + window.screenY,
|
7
|
-
left: (window.innerWidth - height) / 2 + window.screenX,
|
8
|
-
};
|
9
|
-
const windowCreationOptions = Object.keys(windowCreationOptionsList)
|
10
|
-
.map((key) => key + "=" + windowCreationOptionsList[key])
|
11
|
-
.join(",");
|
12
|
-
const popupWindow = window.open("", title, windowCreationOptions);
|
13
|
-
if (!popupWindow) {
|
14
|
-
return null;
|
15
|
-
}
|
16
|
-
const parentDocument = popupWindow.document;
|
17
|
-
// Font
|
18
|
-
const newLinkEl = parentDocument.createElement("link");
|
19
|
-
newLinkEl.rel = "stylesheet";
|
20
|
-
newLinkEl.href = "https://use.typekit.net/cta4xsb.css";
|
21
|
-
parentDocument.head.appendChild(newLinkEl);
|
22
|
-
parentDocument.title = title;
|
23
|
-
parentDocument.body.style.width = "100%";
|
24
|
-
parentDocument.body.style.height = "100%";
|
25
|
-
parentDocument.body.style.margin = "0";
|
26
|
-
parentDocument.body.style.padding = "0";
|
27
|
-
const parentControl = parentDocument.createElement("div");
|
28
|
-
parentControl.style.width = "100%";
|
29
|
-
parentControl.style.height = "100%";
|
30
|
-
parentControl.style.margin = "0";
|
31
|
-
parentControl.style.padding = "0";
|
32
|
-
popupWindow.document.body.appendChild(parentControl);
|
33
|
-
this._CopyStyles(window.document, parentDocument);
|
34
|
-
setTimeout(() => {
|
35
|
-
// need this for late bindings
|
36
|
-
this._CopyStyles(window.document, parentDocument);
|
37
|
-
}, 0);
|
38
|
-
this[windowVariableName] = popupWindow;
|
39
|
-
return parentControl;
|
40
|
-
}
|
41
|
-
static _CopyStyles(sourceDoc, targetDoc) {
|
42
|
-
for (let index = 0; index < sourceDoc.styleSheets.length; index++) {
|
43
|
-
const styleSheet = sourceDoc.styleSheets[index];
|
44
|
-
try {
|
45
|
-
if (styleSheet.cssRules) {
|
46
|
-
// for <style> elements
|
47
|
-
const newStyleEl = sourceDoc.createElement("style");
|
48
|
-
for (const cssRule of styleSheet.cssRules) {
|
49
|
-
// write the text of each rule into the body of the style element
|
50
|
-
newStyleEl.appendChild(sourceDoc.createTextNode(cssRule.cssText));
|
51
|
-
}
|
52
|
-
targetDoc.head.appendChild(newStyleEl);
|
53
|
-
}
|
54
|
-
else if (styleSheet.href) {
|
55
|
-
// for <link> elements loading CSS from a URL
|
56
|
-
const newLinkEl = sourceDoc.createElement("link");
|
57
|
-
newLinkEl.rel = "stylesheet";
|
58
|
-
newLinkEl.href = styleSheet.href;
|
59
|
-
targetDoc.head.appendChild(newLinkEl);
|
60
|
-
}
|
61
|
-
}
|
62
|
-
catch (e) {
|
63
|
-
console.log(e);
|
64
|
-
}
|
65
|
-
}
|
66
|
-
}
|
67
|
-
}
|
1
|
+
export class Popup {
|
2
|
+
static CreatePopup(title, windowVariableName, width = 300, height = 800) {
|
3
|
+
const windowCreationOptionsList = {
|
4
|
+
width: width,
|
5
|
+
height: height,
|
6
|
+
top: (window.innerHeight - width) / 2 + window.screenY,
|
7
|
+
left: (window.innerWidth - height) / 2 + window.screenX,
|
8
|
+
};
|
9
|
+
const windowCreationOptions = Object.keys(windowCreationOptionsList)
|
10
|
+
.map((key) => key + "=" + windowCreationOptionsList[key])
|
11
|
+
.join(",");
|
12
|
+
const popupWindow = window.open("", title, windowCreationOptions);
|
13
|
+
if (!popupWindow) {
|
14
|
+
return null;
|
15
|
+
}
|
16
|
+
const parentDocument = popupWindow.document;
|
17
|
+
// Font
|
18
|
+
const newLinkEl = parentDocument.createElement("link");
|
19
|
+
newLinkEl.rel = "stylesheet";
|
20
|
+
newLinkEl.href = "https://use.typekit.net/cta4xsb.css";
|
21
|
+
parentDocument.head.appendChild(newLinkEl);
|
22
|
+
parentDocument.title = title;
|
23
|
+
parentDocument.body.style.width = "100%";
|
24
|
+
parentDocument.body.style.height = "100%";
|
25
|
+
parentDocument.body.style.margin = "0";
|
26
|
+
parentDocument.body.style.padding = "0";
|
27
|
+
const parentControl = parentDocument.createElement("div");
|
28
|
+
parentControl.style.width = "100%";
|
29
|
+
parentControl.style.height = "100%";
|
30
|
+
parentControl.style.margin = "0";
|
31
|
+
parentControl.style.padding = "0";
|
32
|
+
popupWindow.document.body.appendChild(parentControl);
|
33
|
+
this._CopyStyles(window.document, parentDocument);
|
34
|
+
setTimeout(() => {
|
35
|
+
// need this for late bindings
|
36
|
+
this._CopyStyles(window.document, parentDocument);
|
37
|
+
}, 0);
|
38
|
+
this[windowVariableName] = popupWindow;
|
39
|
+
return parentControl;
|
40
|
+
}
|
41
|
+
static _CopyStyles(sourceDoc, targetDoc) {
|
42
|
+
for (let index = 0; index < sourceDoc.styleSheets.length; index++) {
|
43
|
+
const styleSheet = sourceDoc.styleSheets[index];
|
44
|
+
try {
|
45
|
+
if (styleSheet.cssRules) {
|
46
|
+
// for <style> elements
|
47
|
+
const newStyleEl = sourceDoc.createElement("style");
|
48
|
+
for (const cssRule of styleSheet.cssRules) {
|
49
|
+
// write the text of each rule into the body of the style element
|
50
|
+
newStyleEl.appendChild(sourceDoc.createTextNode(cssRule.cssText));
|
51
|
+
}
|
52
|
+
targetDoc.head.appendChild(newStyleEl);
|
53
|
+
}
|
54
|
+
else if (styleSheet.href) {
|
55
|
+
// for <link> elements loading CSS from a URL
|
56
|
+
const newLinkEl = sourceDoc.createElement("link");
|
57
|
+
newLinkEl.rel = "stylesheet";
|
58
|
+
newLinkEl.href = styleSheet.href;
|
59
|
+
targetDoc.head.appendChild(newLinkEl);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
catch (e) {
|
63
|
+
console.log(e);
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
68
|
//# sourceMappingURL=popup.js.map
|