@singularsystems/neo-react 1.0.0 → 1.0.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/dist/Modules/Types.d.ts +9 -0
- package/dist/Modules/Types.js +8 -0
- package/dist/ReactComponents/ColorPicker.d.ts +5 -3
- package/dist/ReactComponents/ColorPicker.js +24 -9
- package/dist/ReactComponents/IColorPicker.d.ts +7 -0
- package/dist/ReactComponents/IColorPicker.js +1 -0
- package/package.json +3 -3
- package/styles/ColorPicker.scss +1 -2
package/dist/Modules/Types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { INavigationHelper } from '../Routing/NavigationHelper';
|
|
|
3
3
|
import { RoutingState } from '../Routing/RoutingState';
|
|
4
4
|
import Slider, { Range } from 'rc-slider';
|
|
5
5
|
import { SketchPicker } from 'react-color';
|
|
6
|
+
import { IColorPicker } from '../ReactComponents/IColorPicker';
|
|
6
7
|
import AsyncSelect from 'react-select/async';
|
|
7
8
|
import { AxiosStatic } from 'axios';
|
|
8
9
|
import Select from 'react-select';
|
|
@@ -12,7 +13,15 @@ declare const NeoReactTypes: {
|
|
|
12
13
|
Components: {
|
|
13
14
|
Slider: AppServices.ServiceIdentifier<typeof Slider>;
|
|
14
15
|
Range: AppServices.ServiceIdentifier<typeof Range>;
|
|
16
|
+
/**
|
|
17
|
+
* Sketchpicker (from 'react-color' package) component used by the color picker.
|
|
18
|
+
* It is recommended to use the `ColorPicker` type and bind to HexColorPicker from the 'react-colorful' package.
|
|
19
|
+
*/
|
|
15
20
|
SketchPicker: AppServices.ServiceIdentifier<typeof SketchPicker>;
|
|
21
|
+
/**
|
|
22
|
+
* Returns a component that renders a color picker that accepts a color input, and onChange event handler.
|
|
23
|
+
*/
|
|
24
|
+
ColorPicker: AppServices.ServiceIdentifier<IColorPicker>;
|
|
16
25
|
ReactSelect: AppServices.ServiceIdentifier<Select>;
|
|
17
26
|
AsyncSelect: AppServices.ServiceIdentifier<AsyncSelect>;
|
|
18
27
|
IconFactory: AppServices.ServiceIdentifier<IIconFactory>;
|
package/dist/Modules/Types.js
CHANGED
|
@@ -3,7 +3,15 @@ import { AppServices } from '@singularsystems/neo-core';
|
|
|
3
3
|
var NeoReactTypes = __assign(__assign({}, AppServices.NeoTypes), { Components: {
|
|
4
4
|
Slider: new AppServices.ServiceIdentifier("NeoReact.Slider"),
|
|
5
5
|
Range: new AppServices.ServiceIdentifier("NeoReact.Range"),
|
|
6
|
+
/**
|
|
7
|
+
* Sketchpicker (from 'react-color' package) component used by the color picker.
|
|
8
|
+
* It is recommended to use the `ColorPicker` type and bind to HexColorPicker from the 'react-colorful' package.
|
|
9
|
+
*/
|
|
6
10
|
SketchPicker: new AppServices.ServiceIdentifier("NeoReact.SketchPicker"),
|
|
11
|
+
/**
|
|
12
|
+
* Returns a component that renders a color picker that accepts a color input, and onChange event handler.
|
|
13
|
+
*/
|
|
14
|
+
ColorPicker: new AppServices.ServiceIdentifier("NeoReact.ColorPicker"),
|
|
7
15
|
ReactSelect: new AppServices.ServiceIdentifier("NeoReact.ReactSelect"),
|
|
8
16
|
AsyncSelect: new AppServices.ServiceIdentifier("NeoReact.AsyncSelect"),
|
|
9
17
|
IconFactory: new AppServices.ServiceIdentifier("NeoReact.IconFactory")
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { SketchPickerProps } from 'react-color';
|
|
3
3
|
import { Model } from '@singularsystems/neo-core';
|
|
4
4
|
interface IColorPickerProps extends SketchPickerProps {
|
|
5
5
|
bind: Model.IPropertyInstance;
|
|
@@ -14,13 +14,15 @@ export default class ColorPicker extends React.Component<IColorPickerProps, ICol
|
|
|
14
14
|
visible: boolean;
|
|
15
15
|
selectedColor: any;
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
constructor(props: IColorPickerProps);
|
|
18
18
|
componentWillReceiveProps(nextProps: IColorPickerProps): void;
|
|
19
19
|
componentDidMount(): void;
|
|
20
|
-
handleChange: (color:
|
|
20
|
+
handleChange: (color: string) => void;
|
|
21
21
|
visibleToggle: () => void;
|
|
22
22
|
cancel: () => void;
|
|
23
23
|
accept: () => void;
|
|
24
24
|
render(): React.JSX.Element;
|
|
25
|
+
/** Renders the inner color picker components without the modal */
|
|
26
|
+
static render(color: string, onChange: (value: string) => void): JSX.Element;
|
|
25
27
|
}
|
|
26
28
|
export {};
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import { __decorate, __extends } from "tslib";
|
|
1
|
+
import { __decorate, __extends, __metadata } from "tslib";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { observer } from 'mobx-react';
|
|
4
4
|
import { NeoReactTypes } from '../Modules/Types';
|
|
5
5
|
import { Misc } from '@singularsystems/neo-core';
|
|
6
6
|
var ColorPicker = /** @class */ (function (_super) {
|
|
7
7
|
__extends(ColorPicker, _super);
|
|
8
|
-
function ColorPicker() {
|
|
9
|
-
var _this = _super
|
|
8
|
+
function ColorPicker(props) {
|
|
9
|
+
var _this = _super.call(this, props) || this;
|
|
10
10
|
_this.state = {
|
|
11
11
|
visible: false,
|
|
12
12
|
selectedColor: _this.props.bind.value
|
|
13
13
|
};
|
|
14
|
-
_this.sketchPickerImplementation = Misc.Globals.appService.get(NeoReactTypes.Components.SketchPicker);
|
|
15
14
|
_this.handleChange = function (color) {
|
|
16
15
|
// Set the color value
|
|
17
|
-
_this.setState({ selectedColor: color
|
|
16
|
+
_this.setState({ selectedColor: color });
|
|
18
17
|
};
|
|
19
18
|
_this.visibleToggle = function () {
|
|
20
19
|
_this.setState({ visible: !_this.state.visible });
|
|
@@ -32,8 +31,10 @@ var ColorPicker = /** @class */ (function (_super) {
|
|
|
32
31
|
_this.props.onChangeEvent();
|
|
33
32
|
}
|
|
34
33
|
};
|
|
34
|
+
_this.handleChange = _this.handleChange.bind(_this);
|
|
35
35
|
return _this;
|
|
36
36
|
}
|
|
37
|
+
ColorPicker_1 = ColorPicker;
|
|
37
38
|
ColorPicker.prototype.componentWillReceiveProps = function (nextProps) {
|
|
38
39
|
if (nextProps.bind.value !== this.state.selectedColor) {
|
|
39
40
|
// Update the state selectedColor if the color that was in the bind was changed
|
|
@@ -54,13 +55,27 @@ var ColorPicker = /** @class */ (function (_super) {
|
|
|
54
55
|
React.createElement("div", { className: "overlay-area", onClick: function () { return _this.cancel(); } }),
|
|
55
56
|
React.createElement("div", { className: "picker-container" },
|
|
56
57
|
React.createElement("div", { className: "picker-block" },
|
|
57
|
-
|
|
58
|
+
ColorPicker_1.render(this.state.selectedColor, this.handleChange),
|
|
58
59
|
React.createElement("div", { className: "action-container" },
|
|
59
60
|
React.createElement("div", { className: "btn btn-primary btn-sm", onClick: function () { return _this.accept(); } }, "Accept"),
|
|
60
|
-
React.createElement("div", { className: "btn btn-secondary btn-sm ml-1
|
|
61
|
+
React.createElement("div", { className: "btn btn-secondary btn-sm ml-1", onClick: function () { return _this.cancel(); } }, "Cancel"))))))));
|
|
61
62
|
};
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
/** Renders the inner color picker components without the modal */
|
|
64
|
+
ColorPicker.render = function (color, onChange) {
|
|
65
|
+
var sketchPicker = Misc.Globals.appService.tryGet(NeoReactTypes.Components.SketchPicker);
|
|
66
|
+
if (sketchPicker) {
|
|
67
|
+
return React.createElement(sketchPicker, { color: color, onChange: function (c) { return onChange(c.hex); } });
|
|
68
|
+
}
|
|
69
|
+
var colorPicker = Misc.Globals.appService.tryGet(NeoReactTypes.Components.ColorPicker);
|
|
70
|
+
if (colorPicker) {
|
|
71
|
+
return React.createElement(colorPicker, { color: color, onChange: onChange });
|
|
72
|
+
}
|
|
73
|
+
return React.createElement("input", { type: "color", value: color, onInput: function (e) { return onChange(e.target.value); } });
|
|
74
|
+
};
|
|
75
|
+
var ColorPicker_1;
|
|
76
|
+
ColorPicker = ColorPicker_1 = __decorate([
|
|
77
|
+
observer,
|
|
78
|
+
__metadata("design:paramtypes", [Object])
|
|
64
79
|
], ColorPicker);
|
|
65
80
|
return ColorPicker;
|
|
66
81
|
}(React.Component));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singularsystems/neo-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "React application logic and components for the Neo client library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"typescript": "5.4.2"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@singularsystems/neo-core": "1.0.
|
|
34
|
+
"@singularsystems/neo-core": "1.0.1",
|
|
35
35
|
"@types/rc-slider": "^8.6.5",
|
|
36
36
|
"@types/react-color": "^3.0.1",
|
|
37
37
|
"axios": "1.6.7",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"tslib": "2.5.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@singularsystems/neo-core": ">=1.0.
|
|
52
|
+
"@singularsystems/neo-core": ">=1.0.1",
|
|
53
53
|
"axios": ">=1.6.2",
|
|
54
54
|
"inversify": ">=5.0.1",
|
|
55
55
|
"mobx": ">=6.9.0",
|
package/styles/ColorPicker.scss
CHANGED
|
@@ -20,11 +20,10 @@ div.color-picker {
|
|
|
20
20
|
background-color: $offGrey;
|
|
21
21
|
border-radius: 5px;
|
|
22
22
|
border: 1px solid $concrete;
|
|
23
|
-
width: 234px;
|
|
24
23
|
|
|
25
24
|
div.action-container {
|
|
26
25
|
text-align: right;
|
|
27
|
-
padding-top:
|
|
26
|
+
padding-top: 5px;
|
|
28
27
|
|
|
29
28
|
.btn {
|
|
30
29
|
cursor: pointer;
|