@remvst/configurable-react 1.0.0 → 1.1.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.
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { GroupConfigurable } from '@remvst/configurable';
|
|
3
|
+
import { ComponentProps } from './component-props';
|
|
4
|
+
import { ConfigurableToComponent } from './mapping';
|
|
5
|
+
interface Props extends ComponentProps<GroupConfigurable> {
|
|
6
|
+
readonly mapper: ConfigurableToComponent;
|
|
7
|
+
}
|
|
8
|
+
export default class CompositeConfigurableComponent extends React.Component<Props> {
|
|
9
|
+
render(): JSX.Element;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
class CompositeConfigurableComponent extends react_1.default.Component {
|
|
8
|
+
render() {
|
|
9
|
+
const { configurable, mapper } = this.props;
|
|
10
|
+
const subComponents = configurable.entries.map((subConfigurable, i) => {
|
|
11
|
+
return (react_1.default.createElement("div", { key: i, className: "group-configurable-item" }, mapper(subConfigurable, mapper)));
|
|
12
|
+
});
|
|
13
|
+
return (react_1.default.createElement("div", { className: "group-configurable" }, subComponents));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.default = CompositeConfigurableComponent;
|
package/lib/index.js
CHANGED
|
@@ -14,11 +14,15 @@ const boolean_configurable_component_1 = __importDefault(require("./boolean-conf
|
|
|
14
14
|
const color_configurable_component_1 = __importDefault(require("./color-configurable-component"));
|
|
15
15
|
const enum_configurable_component_1 = __importDefault(require("./enum-configurable-component"));
|
|
16
16
|
const button_configurable_component_1 = __importDefault(require("./button-configurable-component"));
|
|
17
|
+
const group_configurable_component_1 = __importDefault(require("./group-configurable-component"));
|
|
17
18
|
const invalidatable_component_1 = __importDefault(require("./invalidatable-component"));
|
|
18
19
|
function defaultComponents(configurable, mapper) {
|
|
19
20
|
if (configurable instanceof configurable_1.CompositeConfigurable) {
|
|
20
21
|
return (react_1.default.createElement(composite_configurable_component_1.default, { configurable: configurable, mapper: mapper }));
|
|
21
22
|
}
|
|
23
|
+
if (configurable instanceof configurable_1.GroupConfigurable) {
|
|
24
|
+
return (react_1.default.createElement(group_configurable_component_1.default, { configurable: configurable, mapper: mapper }));
|
|
25
|
+
}
|
|
22
26
|
if (configurable instanceof configurable_1.ColorConfigurable) {
|
|
23
27
|
return (react_1.default.createElement(color_configurable_component_1.default, { configurable: configurable }));
|
|
24
28
|
}
|
|
@@ -37,7 +41,8 @@ function defaultComponents(configurable, mapper) {
|
|
|
37
41
|
if (configurable instanceof configurable_1.ButtonConfigurable) {
|
|
38
42
|
return (react_1.default.createElement(button_configurable_component_1.default, { configurable: configurable }));
|
|
39
43
|
}
|
|
40
|
-
|
|
44
|
+
console.log(configurable_1.GroupConfigurable, configurable.constructor, configurable_1.GroupConfigurable === configurable.constructor);
|
|
45
|
+
throw new Error(`Unrecognized component type ${configurable.constructor.name}`);
|
|
41
46
|
}
|
|
42
47
|
exports.defaultComponents = defaultComponents;
|
|
43
48
|
function configurableToComponents(configurable, mapper = defaultComponents) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remvst/configurable-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@remvst/configurable": "1.
|
|
13
|
+
"@remvst/configurable": "1.2.0",
|
|
14
14
|
"react": "^18.2.0",
|
|
15
15
|
"react-dom": "^18.2.0",
|
|
16
16
|
"@types/react-dom": "^18.0.6",
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { GroupConfigurable } from '@remvst/configurable';
|
|
3
|
+
import { ComponentProps } from './component-props';
|
|
4
|
+
import { ConfigurableToComponent } from './mapping';
|
|
5
|
+
|
|
6
|
+
interface Props extends ComponentProps<GroupConfigurable> {
|
|
7
|
+
readonly mapper: ConfigurableToComponent;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default class CompositeConfigurableComponent extends React.Component<Props> {
|
|
11
|
+
render() {
|
|
12
|
+
const { configurable, mapper } = this.props;
|
|
13
|
+
|
|
14
|
+
const subComponents = configurable.entries.map((subConfigurable, i) => {
|
|
15
|
+
return (
|
|
16
|
+
<div key={i} className="group-configurable-item">
|
|
17
|
+
{mapper(subConfigurable, mapper)}
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div className="group-configurable">
|
|
24
|
+
{subComponents}
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/index.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ReactElement } from 'react';
|
|
2
|
-
import { BooleanConfigurable, ButtonConfigurable, ColorConfigurable, CompositeConfigurable, Configurable, EnumConfigurable, NumberConfigurable, StringConfigurable } from '@remvst/configurable';
|
|
2
|
+
import { BooleanConfigurable, ButtonConfigurable, ColorConfigurable, CompositeConfigurable, Configurable, EnumConfigurable, NumberConfigurable, StringConfigurable, GroupConfigurable } from '@remvst/configurable';
|
|
3
3
|
import CompositeConfigurableComponent from './composite-configurable-component';
|
|
4
4
|
import NumberConfigurableComponent from './number-configurable-component';
|
|
5
5
|
import StringConfigurableComponent from './string-configurable-component';
|
|
@@ -7,6 +7,7 @@ import BooleanConfigurableComponent from './boolean-configurable-component';
|
|
|
7
7
|
import ColorConfigurableComponent from './color-configurable-component';
|
|
8
8
|
import EnumConfigurableComponent from './enum-configurable-component';
|
|
9
9
|
import ButtonConfigurableComponent from './button-configurable-component';
|
|
10
|
+
import GroupConfigurableComponent from './group-configurable-component';
|
|
10
11
|
import InvalidatableComponent from './invalidatable-component';
|
|
11
12
|
import { ConfigurableToComponent } from './mapping';
|
|
12
13
|
|
|
@@ -14,6 +15,9 @@ export function defaultComponents(configurable: Configurable, mapper: Configurab
|
|
|
14
15
|
if (configurable instanceof CompositeConfigurable) {
|
|
15
16
|
return (<CompositeConfigurableComponent configurable={configurable} mapper={mapper} />);
|
|
16
17
|
}
|
|
18
|
+
if (configurable instanceof GroupConfigurable) {
|
|
19
|
+
return (<GroupConfigurableComponent configurable={configurable} mapper={mapper} />);
|
|
20
|
+
}
|
|
17
21
|
if (configurable instanceof ColorConfigurable) {
|
|
18
22
|
return (<ColorConfigurableComponent configurable={configurable} />);
|
|
19
23
|
}
|
|
@@ -32,7 +36,8 @@ export function defaultComponents(configurable: Configurable, mapper: Configurab
|
|
|
32
36
|
if (configurable instanceof ButtonConfigurable) {
|
|
33
37
|
return (<ButtonConfigurableComponent configurable={configurable} />);
|
|
34
38
|
}
|
|
35
|
-
|
|
39
|
+
console.log(GroupConfigurable, configurable.constructor, GroupConfigurable === configurable.constructor)
|
|
40
|
+
throw new Error(`Unrecognized component type ${configurable.constructor.name}`);
|
|
36
41
|
}
|
|
37
42
|
|
|
38
43
|
export function configurableToComponents(
|