@flowerforce/flower-react 3.1.1-beta.0 β†’ 3.1.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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 3.1.1 (2024-06-11)
2
+
3
+
4
+ ### 🩹 Fixes
5
+
6
+ - enableReduxDevtool prop inside FlowerProvider ([ff0e57a](https://github.com/flowerforce/flower/commit/ff0e57a))
7
+
1
8
  ## 3.1.0 (2024-06-06)
2
9
 
3
10
 
package/README.md CHANGED
@@ -59,6 +59,7 @@ function Root() {
59
59
  )
60
60
  }
61
61
  ```
62
+ > You can pass the prop `enableReduxDevtool` to the `FlowerProvider` to show the Flower Store data inside the redux devtool of your browser.
62
63
 
63
64
  ## How to use
64
65
 
@@ -121,7 +122,8 @@ import {
121
122
  export const Page = () => {
122
123
  return (
123
124
  <Flower name="demo">
124
- <FlowerRoute id="start" to={{ step1: null }} /> {/* autonext */}
125
+ {/* autonext */}
126
+ <FlowerRoute id="start" to={{ step1: null }} />
125
127
  <FlowerNode
126
128
  id="step1"
127
129
  to={{
@@ -225,7 +227,7 @@ export const Page = () => {
225
227
  id="step1"
226
228
  to={{
227
229
  step3: {
228
- rules={{ $and: [{ skipStep2: { $eq: true } }] }}
230
+ rules: { $and: [{ skipStep2: { $eq: true } }] }
229
231
  },
230
232
  step2: null
231
233
  }}
@@ -432,7 +434,14 @@ export const Page = () => {
432
434
  <>
433
435
  <button onClick={() => next()}>click me and go next</button>
434
436
 
435
- <Flower name="demo">...</Flower>
437
+ <Flower name="demo">
438
+ <FlowerNode id="step1" to={{ step2: null }}>
439
+ ...
440
+ <button onClick={() => next()}>click me and go next</button>
441
+ </FlowerNode>
442
+
443
+ <FlowerNode id="step2">...</FlowerNode>
444
+ </Flower>
436
445
  </>
437
446
  )
438
447
  }
@@ -816,7 +825,7 @@ Devtool({
816
825
  ```jsx
817
826
  Devtool({
818
827
  remote: 'passKey',
819
- sourceMap: require('./.flower.source-map.json')
828
+ sourceMap: require('./.flower.sourcemap.json')
820
829
  })
821
830
  ```
822
831
 
@@ -824,20 +833,86 @@ To generate the source maps, add the command flower-sourcemap to your package.
824
833
 
825
834
  ```json
826
835
  "scripts": {
827
- "build-sourcemap": "flower generate-sourcemap -p NEWPASSKEY"
836
+ "build-sourcemap": "flower generate-sourcemap"
828
837
  },
829
838
  ```
830
839
 
831
840
 
832
841
  ```bash
833
- flower sourcemap --help
842
+ flower generate-sourcemap --help
843
+
844
+ -p, --pattern <type> Add glob for search <Flower/> files (default: "src/**/*.{js,ts,tsx,jsx}")
845
+ -d, --dirsave <type> The directory where to save the sourcemap (default: "src")
846
+ -h, --help Quick overview of usage options
847
+ -w, --watch Watch for files changes
848
+ ```
849
+
850
+
851
+ > When you execute this command, you will receive the secretKey, which must be inserted into the `remote` field within the Devtool function.
852
+
853
+ # Using React components with the VS Code extension
854
+
855
+ With Flower, you can configure and use your components through a **graphical interface**. After creating the component in code, you need to associate it with a `JSON configuration file`. This file will be used by Flower to provide users the ability to configure each component's props via a graphical interface, **without writing code**.
856
+
857
+
858
+ For example, let's configure a `Text` component so that it can be used through Flower's graphical interface.
859
+
860
+ ## Step-by-Step Guide
861
+
862
+ 1) `Create the JSON File`
863
+
864
+ First, create the JSON file at the same level as the component file.
865
+
866
+ ```
867
+ src
868
+ β”‚
869
+ β”‚
870
+ └───components
871
+ β”‚ β”‚
872
+ β”‚ └───Text
873
+ β”‚ β”‚ index.tsx
874
+ β”‚ β”‚ text.flower.json
875
+ β”‚ β”‚ ...
876
+ ...
877
+ ```
878
+
879
+ 2) `Insert the Basic Structure`
880
+
881
+ Once the file is created, insert the basic structure of the JSON file, which will be common to any component:
834
882
 
835
- -p, --passKey <type> Choose pass key for devtool inspect (default: "RANDOM STRING")
836
- -f, --pattern <type> Add glob for search <Flower/> files (default: "src/**/*.{js,ts,tsx,jsx}")
837
- -s, --dirsave <type> Directory on save sourcemap (default: "src")
838
- -h, --help Display help for command
883
+ ```json
884
+ {
885
+ "type": "component",
886
+ "name": "Text",
887
+ "category": "UI",
888
+ "description": "This is the Text component",
889
+ "editing": []
890
+ }
839
891
  ```
840
892
 
893
+ The keys in the JSON file have the following purposes:
894
+ - `type`: indicates what is being described with this JSON file, in this case, a component
895
+ - `name`: the name of the component being configured
896
+ - `category`: components are grouped into categories in Flower's graphical interface, so you can choose a category to which the component belongs
897
+ - `description`: a brief description of the component that will be displayed in the graphical interface. This is particularly useful for understanding the functionality of a specific component without reading the code
898
+ - `editing`: in this key, we will insert the options that will allow us to configure the component's behavior directly from the graphical interface
899
+
900
+ Once you have completed these two steps, you will be able to use your `Text component` through the graphical interface.
901
+
902
+ ## Configuring the editing Field
903
+
904
+ Within the editing field, you can insert a series of entries that will allow us to choose the values of the props to pass to the component.
905
+
906
+ The editing field is an array of objects, one for each prop we want to configure, which contain the following keys:
907
+
908
+ 1) `type`: Represents the type of field that will be used within the graphical interface. Possible basic values are `Input`, `Select`, `Switch`, `ButtonGroup`. In addition to these basic types, you can choose the `Rules` type, which allows you to insert rules directly from the graphical interface, and the `SelectNode` type, which allows you to have a Select populated with the nodes present in the flow.
909
+ 2) `id`: Represents the name of the prop being configured
910
+ 3) `label`: The label that will be displayed above the field in the graphical interface
911
+ 4) `default`: Specifies a default value for that prop in case no value is configured on the graphical interface
912
+ 5) `options`: An array of objects with keys `label` and `value` for the `Select` type, and `name` and `value` for the `ButtonGroup` type
913
+
914
+ In any case, there is a JSON schema that will guide you in writing the file associated with each component.
915
+
841
916
 
842
917
  # Documentation
843
918
 
package/dist/index.cjs.js CHANGED
@@ -65,11 +65,11 @@ const store = ({
65
65
  name: 'flower'
66
66
  } : false
67
67
  });
68
- class FlowerProvider extends React.Component {
68
+ class FlowerProvider extends React.PureComponent {
69
69
  constructor(props) {
70
70
  super(props);
71
71
  this.store = store({
72
- enableDevtool: props.enableDevtool
72
+ enableDevtool: props.enableReduxDevtool
73
73
  });
74
74
  }
75
75
  render() {
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import React, { createContext, Component, memo, useRef, useState, useMemo, Children, useEffect, useContext, useCallback, useLayoutEffect } from 'react';
1
+ import React, { createContext, PureComponent, memo, useRef, useState, useMemo, Children, useEffect, useContext, useCallback, useLayoutEffect } from 'react';
2
2
  import _keyBy from 'lodash/keyBy';
3
3
  import { CoreUtils, FlowerCoreReducers, FlowerStateUtils, Selectors, Emitter, MatchRules } from '@flowerforce/flower-core';
4
4
  import _get from 'lodash/get';
@@ -63,11 +63,11 @@ const store = ({
63
63
  name: 'flower'
64
64
  } : false
65
65
  });
66
- class FlowerProvider extends Component {
66
+ class FlowerProvider extends PureComponent {
67
67
  constructor(props) {
68
68
  super(props);
69
69
  this.store = store({
70
- enableDevtool: props.enableDevtool
70
+ enableDevtool: props.enableReduxDevtool
71
71
  });
72
72
  }
73
73
  render() {
@@ -1,4 +1,4 @@
1
- import React, { PropsWithChildren, Component } from 'react';
1
+ import React, { PropsWithChildren, PureComponent } from 'react';
2
2
  import { Action } from '@reduxjs/toolkit';
3
3
  import { FlowerProviderProps } from './components/types/FlowerProvider';
4
4
  export declare const useDispatch: import("react-redux").UseDispatch<import("redux").Dispatch<Action>>;
@@ -13,11 +13,13 @@ export declare const store: ({ enableDevtool }: {
13
13
  flower: Record<string, import("packages/flower-core/dist/src").Flower<Record<string, any>>>;
14
14
  }, undefined, import("redux").UnknownAction>;
15
15
  }>, import("redux").StoreEnhancer]>>;
16
- declare class FlowerProvider extends Component<PropsWithChildren, FlowerProviderProps> {
16
+ declare class FlowerProvider extends PureComponent<PropsWithChildren<{
17
+ enableReduxDevtool?: boolean;
18
+ }>, FlowerProviderProps> {
17
19
  private store;
18
- constructor(props: PropsWithChildren & {
19
- enableDevtool?: boolean;
20
- });
20
+ constructor(props: PropsWithChildren<{
21
+ enableReduxDevtool?: boolean;
22
+ }>);
21
23
  render(): React.JSX.Element;
22
24
  }
23
25
  export default FlowerProvider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowerforce/flower-react",
3
- "version": "3.1.1-beta.0",
3
+ "version": "3.1.1",
4
4
  "description": "FlowerJS components, hooks and utils for React.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,7 +34,7 @@
34
34
  "typescript": "^5.4.5"
35
35
  },
36
36
  "dependencies": {
37
- "@flowerforce/flower-core": "3.1.1-beta.0",
37
+ "@flowerforce/flower-core": "3.1.1",
38
38
  "@reduxjs/toolkit": "^2.2.4",
39
39
  "lodash": "^4.17.21",
40
40
  "react-redux": "^9.1.2",