@viamedici-spc/configurator-react 1.1.0-alpha0001 → 1.1.0-alpha0002

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +122 -1
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,2 +1,123 @@
1
+ <div >
2
+ <strong>Viamedici SPC</strong>
3
+ </div>
4
+
1
5
  # configurator-react
2
- React TypeScript library to build configurator web applications based on the Viamedici Headless Configuration API (HCA).
6
+
7
+ [![npm version](https://img.shields.io/npm/v/@viamedici-spc/configurator-react)](https://www.npmjs.com/package/@viamedici-spc/configurator-react)
8
+ [![license](https://img.shields.io/npm/l/@viamedici-spc/configurator-react)](https://github.com/viamedici-spc/configurator-react/blob/main/LICENSE)
9
+ [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/viamedici-spc/configurator-react/main.yml?branch=main)](https://github.com/viamedici-spc/configurator-react/actions/workflows/main.yml?query=branch%3Amain)
10
+
11
+ ## Introduction
12
+
13
+ This **React** library simplifies the process of building configurator web applications using the _Viamedici Headless
14
+ Configuration Engine_ (HCE).
15
+
16
+ It offers all the features of the HCE through strongly typed **hooks** and **logic components**, eliminating the need to
17
+ interact directly with the HCE's REST API.
18
+
19
+ This library is intended for use in a browser environment and is not compatible with server-side rendering.
20
+
21
+ ## UI Framework Independence
22
+
23
+ The library is designed to be UI framework-agnostic, allowing you to use any UI framework or component library of your choice to build your
24
+ configurator application.
25
+
26
+ It provides powerful hooks and logic-only components that can be easily integrated into your styled components.
27
+
28
+ ## Features
29
+
30
+ The library includes additional features that make it even easier to build a configurator.
31
+
32
+ For a complete list of features, please refer to the base library [configurator-ts](https://github.com/viamedici-spc/configurator-ts).
33
+
34
+ ## Demo App
35
+
36
+ The [Demo App](https://github.com/viamedici-spc/configurator-react-demo) is a comprehensive showcase of the features provided by this library and the HCE. It demonstrates how to effectively integrate and utilize this library within a React-based Single Page Application (SPA).
37
+
38
+ ## Getting Started
39
+
40
+ ### 1. Install Package
41
+
42
+ This library supports both **ESM** and **CommonJS**.
43
+
44
+ ```bash
45
+ npm install @viamedici-spc/configurator-react
46
+ yarn add @viamedici-spc/configurator-react
47
+ ```
48
+
49
+ ### 2. Create a Client
50
+
51
+ Set up the connection parameters for the HCE by creating a client.
52
+
53
+ ```typescript
54
+ import {createClient} from "@viamedici-spc/configurator-ts";
55
+
56
+ const client = createClient({
57
+ sessionHandler: {
58
+ accessToken: "<your access token>",
59
+ },
60
+ hcaEngineBaseUrl: "https://spc.cloud.ceventis.de/hca/api/engine",
61
+ });
62
+ ```
63
+
64
+ ### 3. Define a Configuration Model
65
+
66
+ Define the Configuration Model you want to use.
67
+
68
+ ```typescript
69
+ const configurationModelSource = {
70
+ type: ConfigurationModelSourceType.Channel,
71
+ deploymentName: "Car-Root",
72
+ channel: "release",
73
+ } satisfies ConfigurationModelFromChannel;
74
+ ```
75
+
76
+ ### 4. Setup Configuration Component
77
+
78
+ Wrap the configuration area with the `Configuration` component as its root component.
79
+
80
+ This component manages the configuration state and provides a configuration context for all child components.
81
+
82
+ Use React’s Suspense feature to render configuration-related components only when the configuration is ready.
83
+
84
+ ```tsx
85
+ <Configuration configuratorClient={configuratorClient}
86
+ configurationModelSource={configurationModelSource}>
87
+ <Suspense fallback={<span>Configuration loading …</span>}>
88
+ <ConfigurationSuspender>
89
+ <PaintingColorAttribute/>
90
+ </ConfigurationSuspender>
91
+ </Suspense>
92
+ </Configuration>
93
+ ```
94
+
95
+ ### 5. Create an Attribute Component
96
+
97
+ Now, create a component for the `PaintingColor` attribute of the _Configuration Model_.
98
+
99
+ This component displays the currently selected value of the attribute.
100
+
101
+ The button triggers a decision to select (include) the value Green.
102
+
103
+ ```tsx
104
+ function PaintingColorAttribute() {
105
+ const {attribute, makeDecision} = useChoiceAttribute({localId: "Painting Color"});
106
+ const selectedValue = AttributeInterpreter.getSelectedChoiceValues(attribute)[0] ?? "<nothing>"
107
+
108
+ return (
109
+ <div>
110
+ <div>
111
+ Selected value: {selectedValue}
112
+ </div>
113
+ <button onClick={() => makeDecision("Green", ChoiceValueDecisionState.Included)}>
114
+ Select Green
115
+ </button>
116
+ </div>
117
+ )
118
+ }
119
+ ```
120
+
121
+ ## License
122
+
123
+ This project is licensed under the MIT License - see the LICENSE file for details.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@viamedici-spc/configurator-react",
3
- "version": "1.1.0-alpha0001",
4
- "description": "React TypeScript library to build configurator web applications based on the Viamedici Headless Configuration API (HCA).",
3
+ "version": "1.1.0-alpha0002",
4
+ "description": "React library to build configurator web applications based on the Viamedici Headless Configuration Engine (HCE).",
5
5
  "sideEffects": false,
6
6
  "files": [
7
7
  "dist"
@@ -28,7 +28,7 @@
28
28
  "product",
29
29
  "configuration",
30
30
  "spc",
31
- "hca",
31
+ "hce",
32
32
  "csp",
33
33
  "constraint",
34
34
  "satisfaction",