@open-xamu-co/ui-common-types 3.1.0-next.3 → 3.1.0-next.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-xamu-co/ui-common-types",
3
- "version": "3.1.0-next.3",
3
+ "version": "3.1.0-next.5",
4
4
  "description": "Xamu shared types",
5
5
  "author": "@xamu-co",
6
6
  "main": "src/index.ts",
package/src/locale.ts CHANGED
@@ -246,30 +246,46 @@ export type tLocaleTable = {
246
246
  /** @example "Show all" */
247
247
  table_show_all: string;
248
248
  swal: {
249
- /** @example "Are you sure you want to delete this element?" */
249
+ /** @example "Are you sure you want to delete this item?" */
250
250
  table_delete_node_title: string;
251
- /** @example "Remember that you wont be able to recover this element data and you will lost all of your work" */
251
+ /** @example "Remember that you wont be able to recover this item data and you will lost all of your work" */
252
252
  table_delete_node_disclaimer: string;
253
253
  /** @example "Successfull deletion" */
254
254
  table_deleted: string;
255
- /** @example "Are you sure you want to delete this element? | Are you sure you want to delete these {count} elements?" */
255
+ /** @example "The item was deleted, the list will refresh automatically" */
256
+ table_deleted_text: string;
257
+ /** @example "Are you sure you want to delete this item? | Are you sure you want to delete these {count} items?" */
256
258
  table_delete_nodes_title: string;
257
- /** @example "Remember that you wont be able to recover these elements data and you will lost all of your work" */
259
+ /** @example "Remember that you wont be able to recover these items data and you will lost all of your work" */
258
260
  table_delete_nodes_disclaimer: string;
259
- /** @example "The item may not have been deleted | The items may not have been deleted" */
261
+ /** @example "Deletion went wrong" */
260
262
  table_possibly_not_deleted: string;
263
+ /** @example "The item may not have been deleted | The items may not have been deleted" */
264
+ table_possibly_not_deleted_text: string;
261
265
  /** @example "Successfull update" */
262
266
  table_updated: string;
263
- /** @example "The item may not have been updated | The items may not have been updated" */
267
+ /** @example "The item was updated, the list will refresh automatically" */
268
+ table_updated_text: string;
269
+ /** @example "Update went wrong" */
264
270
  table_possibly_not_updated: string;
265
- /** @example "Successfull update" */
271
+ /** @example "The item may not have been updated | The items may not have been updated" */
272
+ table_possibly_not_updated_text: string;
273
+ /** @example "Successfull creation" */
266
274
  table_created: string;
267
- /** @example "The item may not have been created | The items may not have been created" */
275
+ /** @example "The item was created, you can already find it in the list" */
276
+ table_created_text: string;
277
+ /** @example "Creation went wrong" */
268
278
  table_possibly_not_created: string;
269
- /** @example "Successfull cloning" */
279
+ /** @example "The item may not have been created | The items may not have been created" */
280
+ table_possibly_not_created_text: string;
281
+ /** @example "Successfull clonation" */
270
282
  table_cloned: string;
271
- /** @example "The item may not have been cloned | The items may not have been cloned" */
283
+ /** @example "The item was cloned, you can already find it in the list" */
284
+ table_cloned_text: string;
285
+ /** @example "Clonation went wrong" */
272
286
  table_possibly_not_cloned: string;
287
+ /** @example "The item may not have been cloned | The items may not have been cloned" */
288
+ table_possibly_not_cloned_text: string;
273
289
  };
274
290
  };
275
291
 
package/src/plugin.ts CHANGED
@@ -146,4 +146,11 @@ export interface iPluginOptions<ComponentType = unknown> {
146
146
  * @default console.log
147
147
  */
148
148
  logger?: tLogger;
149
+ /**
150
+ * Function used to encode the pagination cursor
151
+ *
152
+ * @default node.id
153
+ */
154
+ cursorEncoder?: (<T>(node: T) => string) | (<T>(node: T) => number);
155
+ internals?: Record<string, any>;
149
156
  }
package/src/values.ts CHANGED
@@ -6,19 +6,35 @@ export interface iSelectOption {
6
6
  hidden?: boolean;
7
7
  }
8
8
 
9
- export type iNodeFnResponse = [boolean?, Event?, (() => void)?];
9
+ /**
10
+ * Response from node functions
11
+ *
12
+ * Action result, event and callback
13
+ */
14
+ export type iNodeFnResponse<T extends Record<string, any> = never> = [
15
+ (boolean | T)?,
16
+ Event?,
17
+ (() => void)?,
18
+ ];
10
19
 
11
20
  /**
12
21
  * Funtions that uses a node and perform some action
13
22
  *
14
23
  * Useful for table actions like creating, updating and deleting nodes
24
+ *
25
+ * Undefined would mean no action was performed
26
+ * True or an T type object would mean action was performed successfully
27
+ * False would mean action failed
15
28
  */
16
29
  export type iNodeFn<T extends Record<string, any>, Ta extends [T?, ...any[]] = [T]> = (
17
30
  ...args: Ta
18
- ) => boolean | undefined | iNodeFnResponse | Promise<boolean | undefined | iNodeFnResponse>;
31
+ ) => boolean | undefined | iNodeFnResponse<T> | Promise<boolean | undefined | iNodeFnResponse<T>>;
19
32
 
20
33
  /**
21
- * used on FactoryTable and related components
34
+ * Used on Table and related components
35
+ *
36
+ * @action Any task performed at each row cell (property)
37
+ * @nested Any task performed at a relation table within a modal
22
38
  */
23
39
  export interface iProperty<
24
40
  T extends Record<string, any> = Record<string, any>,
@@ -28,6 +44,9 @@ export interface iProperty<
28
44
  /**
29
45
  * Function to create a node within the relation
30
46
  * The parent is given since the node doesn't exist yet
47
+ *
48
+ * @action Showcases an button to create a new node/value within this property/relation
49
+ * @nested Passed down to the related table if any
31
50
  */
32
51
  createNode?: iNodeFn<P, [P?]>;
33
52
  /**
@@ -36,18 +55,28 @@ export interface iProperty<
36
55
  disableCreateNode?: (p: P) => boolean;
37
56
  /**
38
57
  * Function to clone a node within the relation
58
+ * Set to false to omit cloning this property/relation
59
+ *
60
+ * @action No inline action
61
+ * @nested Passed down to the related table if any
39
62
  */
40
- cloneNode?: iNodeFn<T, [T?]>;
63
+ cloneNode?: iNodeFn<T, [T?]> | false;
41
64
  /**
42
65
  * Function to update a node within the relation
66
+ *
67
+ * @action Showcases an button to update this node/value within this property/relation
68
+ * @nested Passed down to the related table if any
43
69
  */
44
70
  updateNode?: iNodeFn<T, [T?, P?]>;
45
71
  /**
46
72
  * Function to delete a node within the relation
73
+ *
74
+ * @action No inline action
75
+ * @nested Passed down to the related table if any
47
76
  */
48
77
  deleteNode?: iNodeFn<T, [T?]>;
49
78
  /**
50
- * Render using this component instead
79
+ * Render row cell (property) using this component instead
51
80
  */
52
81
  component?: ComponentType;
53
82
  /**