treege 1.5.0 → 2.0.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +27 -3
  2. package/dist/features/Treege/Treege.d.ts +1 -1
  3. package/dist/features/Treege/components/Forms/AssignValueToChildren/AssignValueToChildren.d.ts +10 -0
  4. package/dist/features/Treege/components/Forms/AssignValueToChildren/Examples/ObjectMappingExample.d.ts +2 -0
  5. package/dist/features/Treege/components/Forms/FormTreeCardMutation/FormTreeCardMutation.d.ts +3 -1
  6. package/dist/features/Treege/components/Forms/FormTreeCardMutation/useFormTreeCardMutation.d.ts +20 -9
  7. package/dist/features/Treege/components/Forms/ReceiveValueFromAncestor.d.ts +11 -0
  8. package/dist/features/Treege/components/TreeGrid/useTreeGrid.d.ts +2 -0
  9. package/dist/features/Treege/context/TreegeProvider.d.ts +80 -2
  10. package/dist/hooks/useTreegeContext/useTreegeContext.d.ts +1 -1
  11. package/dist/locales/en/form-en.d.ts +17 -2
  12. package/dist/locales/fr/form-fr.d.ts +19 -4
  13. package/dist/main.d.ts +2 -2
  14. package/dist/main.js +6075 -5414
  15. package/dist/main.umd.cjs +55 -46
  16. package/dist/utils/tree/appendNode/appendNode.d.ts +2 -2
  17. package/dist/utils/tree/getAllAncestorFromTree/getAllAncestorFromTree.d.ts +12 -0
  18. package/dist/utils/tree/index.d.ts +2 -3
  19. package/dist/utils/tree/removeNode/test/mock.d.ts +3 -1
  20. package/package.json +10 -10
  21. package/dist/features/Treege/components/Feedback/DynamicSelectWarning/DynamicSelectWarning.d.ts +0 -5
  22. package/dist/features/Treege/components/Feedback/DynamicSelectWarning/index.d.ts +0 -3
  23. package/dist/features/Treege/components/Feedback/EndPointWarning/index.d.ts +0 -3
  24. package/dist/features/Treege/components/Inputs/DynamicSelectFieldFromTree/DynamicSelectFieldFromTree.d.ts +0 -8
  25. package/dist/features/Treege/components/Inputs/DynamicSelectFieldFromTree/index.d.ts +0 -3
  26. package/dist/features/Treege/components/Inputs/FieldSelectAutocompleteCreatable/index.d.ts +0 -3
  27. package/dist/features/Treege/context/TreegeContext.d.ts +0 -81
  28. package/dist/features/Treege/index.d.ts +0 -2
  29. package/dist/utils/tree/getAllAncestorNamesFromTree/getAllAncestorNamesFromTree.d.ts +0 -8
  30. package/dist/utils/tree/getAllNamesFromTree/getAllNamesFromTree.d.ts +0 -7
  31. package/dist/utils/tree/getAllNamesFromTree/test/mock.d.ts +0 -11
  32. /package/dist/features/Treege/components/Feedback/{EndPointWarning/EndPointWarning.d.ts → EndPointWarning.d.ts} +0 -0
  33. /package/dist/features/Treege/components/Inputs/{FieldSelectAutocompleteCreatable/FieldSelectAutocompleteCreatable.d.ts → FieldSelectAutocompleteCreatable.d.ts} +0 -0
  34. /package/dist/utils/tree/{getAllAncestorNamesFromTree → getAllAncestorFromTree}/test/mock.d.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # [Versions](https://github.com/Tracktor/treege/releases)
2
2
 
3
- ## v1.5.0
4
- - **[feat]** : Add date pattern
5
- - **[fix]** : Disable pattern for `radio`, `hidden`, `checkbox`, `switch`, `autocomplete`, and `dynamic select`
3
+ ## v2.0.0
4
+
5
+ ### 🚀 New Features
6
+
7
+ - Introduced components to assign and receive values from ancestor nodes in tree-based forms, improving dynamic data binding and API parameterization.
8
+ - Added an object mapping example component to aid in key path selection within nested objects.
9
+
10
+ ### ✨ Enhancements
11
+
12
+ - Redesigned form layouts with a responsive two-column grid and enhanced large modal handling.
13
+ - Expanded English and French localization with detailed guidance on dynamic data, ancestor values, and API parameters.
14
+ - Upgraded multiple dependencies to latest versions for improved stability and features.
15
+
16
+ ### 🐛 Bug Fixes
17
+
18
+ - Improved modal and dialog behaviors for better accessibility and consistency.
19
+
20
+ ### 🔨 Refactor
21
+
22
+ - Removed legacy components and utilities related to ancestor and tree name extraction.
23
+ - Consolidated and simplified ancestor retrieval utilities.
24
+ - Cleaned up ancestor references when removing nodes from the tree.
25
+
26
+ ### 🧹 Chores
27
+
28
+ - Deleted unused files and tests tied to deprecated tree utilities.
29
+ - Added new tests validating updated ancestor retrieval and node removal functionality.
@@ -1,6 +1,6 @@
1
1
  import { TreeNode } from '@tracktor/types-treege';
2
2
  export interface BackendConfig {
3
- baseUrl: string;
3
+ baseUrl?: string;
4
4
  authToken?: string;
5
5
  endpoints?: {
6
6
  workflow?: string;
@@ -0,0 +1,10 @@
1
+ import { DefaultValueFromAncestor } from '@tracktor/types-treege';
2
+ interface AssignValueToChildrenProps {
3
+ value?: DefaultValueFromAncestor | null;
4
+ onChange?: (sourceValue?: string) => void;
5
+ ancestorName: string;
6
+ displayTopDivider?: boolean;
7
+ currentType?: string;
8
+ }
9
+ declare const AssignValueToChildren: ({ onChange, value, ancestorName, displayTopDivider, currentType }: AssignValueToChildrenProps) => import("react/jsx-runtime").JSX.Element;
10
+ export default AssignValueToChildren;
@@ -0,0 +1,2 @@
1
+ declare const ObjectMappingExample: () => import("react/jsx-runtime").JSX.Element;
2
+ export default ObjectMappingExample;
@@ -1,5 +1,7 @@
1
1
  interface FormTreeCardMutationProps {
2
2
  onClose(): void;
3
+ title?: string;
4
+ setIsLarge?(largeModal: boolean): void;
3
5
  }
4
- declare const FormTreeCardMutation: ({ onClose }: FormTreeCardMutationProps) => import("react/jsx-runtime").JSX.Element;
6
+ declare const FormTreeCardMutation: ({ onClose, title, setIsLarge }: FormTreeCardMutationProps) => import("react/jsx-runtime").JSX.Element;
5
7
  export default FormTreeCardMutation;
@@ -1,5 +1,5 @@
1
1
  import { SelectChangeEvent } from '@tracktor/design-system';
2
- import { Params, Route } from '@tracktor/types-treege';
2
+ import { DefaultValueFromAncestor, Params, Route, TreeNode } from '@tracktor/types-treege';
3
3
  import { ChangeEvent, FormEvent, MouseEvent, SyntheticEvent } from 'react';
4
4
  import { default as fields } from '../../../../../src/constants/fields';
5
5
  interface Values {
@@ -8,10 +8,21 @@ interface Values {
8
8
  value: string;
9
9
  message?: string;
10
10
  }
11
- declare const useFormTreeCardMutation: () => {
11
+ interface UseFormTreeCardMutationParams {
12
+ setIsLarge?(largeModal: boolean): void;
13
+ }
14
+ declare const useFormTreeCardMutation: ({ setIsLarge }: UseFormTreeCardMutationParams) => {
15
+ ancestors: {
16
+ uuid: string;
17
+ name?: string;
18
+ }[];
19
+ collapseOptions: boolean;
20
+ currentTree: TreeNode | null;
21
+ defaultValueFromAncestor: DefaultValueFromAncestor | undefined;
12
22
  getDisabledValueField: (index: number) => boolean;
13
23
  handleAddParams: () => void;
14
24
  handleAddValue: () => void;
25
+ handleAncestorRef: (ancestorUuid?: string, ancestorName?: string) => void;
15
26
  handleChangeHelperText: ({ target }: ChangeEvent<HTMLInputElement>) => void;
16
27
  handleChangeHiddenValue: ({ target }: ChangeEvent<HTMLInputElement>) => void;
17
28
  handleChangeInitialQuery: ({ target }: ChangeEvent<HTMLInputElement>) => void;
@@ -21,8 +32,7 @@ declare const useFormTreeCardMutation: () => {
21
32
  handleChangeMessage: (nameMessage: "on" | "off") => ({ target }: ChangeEvent<HTMLInputElement>) => void;
22
33
  handleChangeMultiple: ({ target }: ChangeEvent<HTMLInputElement>) => void;
23
34
  handleChangeName: ({ target }: ChangeEvent<HTMLInputElement>) => void;
24
- handleChangeParam: (index: number, property: keyof Params, event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
25
- handleChangeParentRef: (_: SelectChangeEvent<string | undefined>, newValue: string | undefined) => void;
35
+ handleChangeParam: <K extends keyof Params>(index: number, property: K, value: Params[K]) => void;
26
36
  handleChangePath: <T extends HTMLInputElement | HTMLTextAreaElement>(property: string, event: ChangeEvent<T>) => void;
27
37
  handleChangePattern: (_: SyntheticEvent, value: null | string | {
28
38
  label: string;
@@ -38,12 +48,13 @@ declare const useFormTreeCardMutation: () => {
38
48
  } | null) => void;
39
49
  handleChangeTreeSelect: ({ target }: SelectChangeEvent) => void;
40
50
  handleChangeType: (_: SyntheticEvent, value: (typeof fields)[number]) => void;
41
- handleChangeUrl: ({ target }: ChangeEvent<HTMLInputElement>) => void;
42
51
  handleChangeUrlSelect: ({ target }: ChangeEvent<HTMLInputElement>) => void;
43
52
  handleDeleteParam: (e: MouseEvent<HTMLButtonElement>) => void;
44
53
  handleDeleteValue: ({ currentTarget }: MouseEvent<HTMLButtonElement>) => void;
45
54
  handlePresetValues: (predicate: "value" | "label" | "message") => (event: ChangeEvent<HTMLInputElement>) => void;
46
55
  handleSubmit: (e: FormEvent) => Promise<void>;
56
+ handleValueFromAncestor: (sourceValue?: string) => void;
57
+ hasAncestors: boolean;
47
58
  helperText: string;
48
59
  hiddenValue: string;
49
60
  initialQuery: boolean;
@@ -54,9 +65,8 @@ declare const useFormTreeCardMutation: () => {
54
65
  isDecisionField: boolean;
55
66
  isDisabledPast: boolean;
56
67
  isDynamicSelect: boolean;
57
- isEditModal: boolean;
58
68
  isHiddenField: boolean;
59
- isLeaf: boolean;
69
+ isLargeView: boolean;
60
70
  isMultiple: boolean;
61
71
  isMultiplePossible: boolean;
62
72
  isPatternEnabled: boolean;
@@ -70,7 +80,6 @@ declare const useFormTreeCardMutation: () => {
70
80
  on: string;
71
81
  };
72
82
  name: string;
73
- parentRef: string | null;
74
83
  pattern: string | {
75
84
  label: string;
76
85
  value: string;
@@ -94,7 +103,9 @@ declare const useFormTreeCardMutation: () => {
94
103
  })[];
95
104
  repeatable: boolean;
96
105
  required: boolean;
97
- route: Route;
106
+ route: Route | undefined;
107
+ selectAncestorName: string | undefined;
108
+ setCollapseOptions: import('react').Dispatch<import('react').SetStateAction<boolean>>;
98
109
  tag: string | null;
99
110
  treeSelected: string;
100
111
  type: import('@tracktor/types-treege').FieldType;
@@ -0,0 +1,11 @@
1
+ interface ReceiveValueFromParentProps {
2
+ id: string;
3
+ ancestors: {
4
+ uuid: string;
5
+ name?: string;
6
+ }[];
7
+ onChange?: (ancestorUuid?: string, ancestorName?: string) => void;
8
+ value?: string | null;
9
+ }
10
+ declare const ReceiveValueFromAncestor: ({ onChange, id, value, ancestors }: ReceiveValueFromParentProps) => import("react/jsx-runtime").JSX.Element | null;
11
+ export default ReceiveValueFromAncestor;
@@ -4,6 +4,8 @@ declare const useTreeGrid: () => {
4
4
  getTitleModalMutation: () => "Add a field" | "Add a field to « {{name}} »" | "Edit field « {{name}} »";
5
5
  handleChangeTree: (tree: string) => false | undefined;
6
6
  isDeleteModal: boolean;
7
+ isLargeView: boolean;
7
8
  isModalMutationOpen: boolean;
9
+ setIsLargeView: import('react').Dispatch<import('react').SetStateAction<boolean>>;
8
10
  };
9
11
  export default useTreeGrid;
@@ -1,5 +1,6 @@
1
- import { TreeNode } from '@tracktor/types-treege';
2
- import { ReactNode } from 'react';
1
+ import { CurrentTree, ModalType, TreeNode, TreePath } from '@tracktor/types-treege';
2
+ import { HierarchyPointNode } from 'd3-hierarchy';
3
+ import { ReactNode, ReducerAction, SetStateAction } from 'react';
3
4
  import { BackendConfig } from '../../../src/features/Treege/Treege';
4
5
  interface TreegeProviderProps {
5
6
  children: ReactNode;
@@ -7,5 +8,82 @@ interface TreegeProviderProps {
7
8
  initialTreeId?: string;
8
9
  backendConfig?: BackendConfig;
9
10
  }
11
+ export interface TreeDefaultValue {
12
+ /**
13
+ * This is the backend configuration
14
+ */
15
+ backendConfig?: BackendConfig;
16
+ /**
17
+ * CurrentHierarchyPointNode is the current node selected
18
+ */
19
+ currentHierarchyPointNode: null | HierarchyPointNode<TreeNode>;
20
+ /**
21
+ * This is the current tree information
22
+ * {
23
+ * "id": "treeId",
24
+ * "name": "Tree name"
25
+ * }
26
+ */
27
+ currentTree: CurrentTree;
28
+ /**
29
+ * This is the tree node object
30
+ */
31
+ tree: null | TreeNode;
32
+ /**
33
+ * This is the tree modal open state
34
+ */
35
+ treeModalOpen: boolean;
36
+ /**
37
+ * This is the tree path
38
+ * [
39
+ * {
40
+ * "label": "Tree name",
41
+ * "path": "uuid"
42
+ * }
43
+ * ]
44
+ */
45
+ treePath: TreePath[] | [];
46
+ /**
47
+ * This is the modal open state
48
+ */
49
+ modalOpen: ModalType;
50
+ /**
51
+ * This is the version of Treege
52
+ */
53
+ version: string;
54
+ /**
55
+ * This is the tree node dispatch function
56
+ * @param state
57
+ */
58
+ dispatchTree(state: ReducerAction<any>): void;
59
+ /**
60
+ * This is the function to set the modal open state
61
+ * @param state
62
+ */
63
+ setCurrentHierarchyPointNode(state: SetStateAction<null | HierarchyPointNode<TreeNode>>): void;
64
+ /**
65
+ * This is the function to set the current tree information
66
+ * Not the node to display tree
67
+ * @param state
68
+ */
69
+ setCurrentTree(state: SetStateAction<CurrentTree>): void;
70
+ /**
71
+ * This is the function to set the modal open state
72
+ * @param state
73
+ */
74
+ setModalOpen(state: SetStateAction<ModalType>): void;
75
+ /**
76
+ * This is the function to set the modal open state
77
+ * @param state
78
+ */
79
+ setTreeModalOpen(state: SetStateAction<boolean>): void;
80
+ /**
81
+ * This is the function to set the tree path
82
+ * @param state
83
+ */
84
+ setTreePath(state: SetStateAction<TreePath[] | []>): void;
85
+ }
86
+ export declare const treeDefaultValue: TreeDefaultValue;
87
+ export declare const TreegeContext: import('react').Context<TreeDefaultValue>;
10
88
  declare const TreegeProvider: ({ children, initialTree, initialTreeId, backendConfig }: TreegeProviderProps) => import("react/jsx-runtime").JSX.Element;
11
89
  export default TreegeProvider;
@@ -1,2 +1,2 @@
1
- declare const useTreegeContext: () => import('../../src/features/Treege/context/TreegeContext').TreeDefaultValue;
1
+ declare const useTreegeContext: () => import('../../src/features/Treege/context/TreegeProvider').TreeDefaultValue;
2
2
  export default useTreegeContext;
@@ -1,32 +1,45 @@
1
1
  declare const FORM_EN: {
2
- readonly additionalParams: "Additional parameters";
2
+ readonly additionalParams: "Api parameters";
3
+ readonly addressStructureHint: "An address type must be:";
3
4
  readonly ancestor: "Ancestor";
5
+ readonly ancestorValue: "Get value from: {{ancestorName}}";
4
6
  readonly apiRoute: "Api route";
5
7
  readonly cardNumber: "Card number";
6
- readonly dataMapping: "Data mapping";
8
+ readonly dataMapping: "Option mapping";
7
9
  readonly decisionField: "Decision field";
8
10
  readonly disabledPast: "Disabled Past";
11
+ readonly dynamicSelectStructureHint: "Make sure the field accepts the ancestor value.";
9
12
  readonly email: "Email";
10
13
  readonly firstNameAndLastName: "First name and last name";
11
14
  readonly helperText: "Helper text";
12
15
  readonly hiddenValue: "Hidden value";
13
16
  readonly key: "Key";
17
+ readonly keyPath: "Key path (string | number)";
18
+ readonly keyPathApiDescription: "(Option) To insert a value in a URL, use the syntax {paramName}. For example: http://api.com/userId={userId}, add {userId} in params.";
19
+ readonly keyPathAssignment: "Key path to value: {{keyPath}}";
20
+ readonly keyPathObject: "Key path to value";
14
21
  readonly label: "Label";
15
22
  readonly letter: "Letter";
23
+ readonly mapObject: "Map object";
16
24
  readonly message: "Message";
17
25
  readonly mustBeUnique: "Must be unique";
18
26
  readonly newTree: "Nouvel arbre";
19
27
  readonly noAncestorFound: "No parents found";
20
28
  readonly number: "Nombre";
21
29
  readonly numberAndLetter: "Number and letter";
30
+ readonly objectDemo: "Example of object mapping";
22
31
  readonly offMessage: "Message (disable)";
23
32
  readonly onMessage: "Message (enable)";
24
33
  readonly pattern: "Pattern";
25
34
  readonly patternMessage: "Pattern message";
26
35
  readonly phoneNumber: "Phone number";
36
+ readonly receiveValueFromParent: "Default value from ancestor";
27
37
  readonly repeatable: "Repeatable";
28
38
  readonly searchKeyPlaceholder: "text";
39
+ readonly selectStructureHint: "Must be an value existing in the values option.";
29
40
  readonly staticFields: "Static fields";
41
+ readonly staticValue: "(Option) Static value";
42
+ readonly staticValueDescription: "By default, it will use the ancestor value, but you can assign a static value.";
30
43
  readonly step: "Step";
31
44
  readonly tree: "Tree";
32
45
  readonly treeName: "Tree name";
@@ -53,8 +66,10 @@ declare const FORM_EN: {
53
66
  readonly tree: "Tree";
54
67
  readonly url: "URL";
55
68
  };
69
+ readonly typeStructureWarning: "Type structure must be: {{type}}";
56
70
  readonly url: "URL";
57
71
  readonly urlConstruction: "URL construction";
72
+ readonly useAncestorValueAsParam: "Use Ancestor value";
58
73
  readonly value: "Value";
59
74
  readonly values: "Values";
60
75
  readonly warningApiAutocomplete: {
@@ -1,32 +1,45 @@
1
1
  declare const FORM_FR: {
2
- readonly additionalParams: "Paramètres additionnels";
2
+ readonly additionalParams: "Paramètres API";
3
+ readonly addressStructureHint: "Un type d'adresse doit être :";
3
4
  readonly ancestor: "Ancêtre";
5
+ readonly ancestorValue: "Récupération de la valeur de : {{ancestorName}}";
4
6
  readonly apiRoute: "Api route";
5
7
  readonly cardNumber: "Numéro de carte";
6
- readonly dataMapping: "Mapping de données";
8
+ readonly dataMapping: "Mapping des options";
7
9
  readonly decisionField: "Champs de décision";
8
10
  readonly disabledPast: "Passé désactivé";
11
+ readonly dynamicSelectStructureHint: "Assurez-vous que le champ accepte la valeur de l'ancêtre.";
9
12
  readonly email: "Email";
10
13
  readonly firstNameAndLastName: "Prénom et nom";
11
14
  readonly helperText: "Texte d'information";
12
15
  readonly hiddenValue: "Valeur caché";
13
16
  readonly key: "Clé";
17
+ readonly keyPath: "Chemin de la clé (string | number)";
18
+ readonly keyPathApiDescription: "Pour insérer une valeur dans une URL, utilisez la syntaxe {paramName}. Par exemple : http://api.com/userId={userId}, ajouter {userId} en params.";
19
+ readonly keyPathAssignment: "Chemin vers la valeur : {{keyPath}}";
20
+ readonly keyPathObject: "Clé vers la valeur";
14
21
  readonly label: "Label";
15
22
  readonly letter: "Lettre";
23
+ readonly mapObject: "Mapper l'objet";
16
24
  readonly message: "Message";
17
25
  readonly mustBeUnique: "Doit être unique";
18
26
  readonly newTree: "Nouvel arbre";
19
- readonly noAncestorFound: "Aucun parent trouvé";
27
+ readonly noAncestorFound: "Aucun parent trouvé ";
20
28
  readonly number: "Chiffre";
21
29
  readonly numberAndLetter: "Chiffre et lettre";
30
+ readonly objectDemo: "Exemple de mapping d'objet";
22
31
  readonly offMessage: "Message (désactiver)";
23
32
  readonly onMessage: "Message (activer)";
24
33
  readonly pattern: "Expression régulière";
25
34
  readonly patternMessage: "Message d'aide invalide";
26
35
  readonly phoneNumber: "Numéro de téléphone";
36
+ readonly receiveValueFromParent: "Valeur par défaut depuis l'ancêtre";
27
37
  readonly repeatable: "Répétable";
28
38
  readonly searchKeyPlaceholder: "text";
39
+ readonly selectStructureHint: "Doit être une valeur existante dans les options de valeurs.";
29
40
  readonly staticFields: "Champs statiques";
41
+ readonly staticValue: "(Option) Valeur statique";
42
+ readonly staticValueDescription: "Par défaut, il utilisera la valeur de l'ancêtre, mais vous pouvez assigner une valeur statique.";
30
43
  readonly step: "Étape";
31
44
  readonly tree: "Arbre";
32
45
  readonly treeName: "Nom de l'arbre";
@@ -53,8 +66,10 @@ declare const FORM_FR: {
53
66
  readonly tree: "Arbre";
54
67
  readonly url: "URL";
55
68
  };
69
+ readonly typeStructureWarning: "Le type d'input doit être : {{type}}";
56
70
  readonly url: "URL";
57
71
  readonly urlConstruction: "Construction de l'URL";
72
+ readonly useAncestorValueAsParam: "Utiliser une valeur ancêtre";
58
73
  readonly value: "Valeur";
59
74
  readonly values: "Valeurs";
60
75
  readonly warningApiAutocomplete: {
@@ -63,7 +78,7 @@ declare const FORM_FR: {
63
78
  };
64
79
  readonly warningApiSelect: {
65
80
  readonly response: "à l'emplacement de votre variable.";
66
- readonly url: "Pour intégrer automatiquement la valeur du parent dans l'URL";
81
+ readonly url: "Pour intégrer la valeur du parent dans l'URL";
67
82
  readonly warning: "placez {{}}";
68
83
  };
69
84
  };
package/dist/main.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { default as Treege } from './src/features/Treege';
2
- export * from './src/features/Treege';
1
+ export { default as Treege } from './src/features/Treege/Treege';
2
+ export * from './src/features/Treege/Treege';
3
3
  export { default as TreePlusIcon } from './src/components/DataDisplay/Icons/TreePlusIcon';
4
4
  export * from './src/components/DataDisplay/Icons/TreePlusIcon';