@wisemen/vue-core-actions 0.2.4 → 0.4.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.
@@ -1,5 +1,6 @@
1
1
  import { RegisteredActionContext } from '../register';
2
2
  import { Action } from '../types/action.type.ts';
3
+ import { TableSelectionState } from '../types/tableSelection.type.ts';
3
4
  interface ActionContextOptions {
4
5
  keyboardEvent?: KeyboardEvent;
5
6
  menuType?: 'commandMenu' | 'contextualMenu';
@@ -13,6 +14,7 @@ declare function executeAction(action: Action, ctx: RegisteredActionContext, opt
13
14
  }): Promise<void>;
14
15
  export declare const useActionManagerStore: import('pinia').StoreDefinition<"actionManager", Pick<{
15
16
  actionContext: (options: ActionContextOptions) => RegisteredActionContext;
17
+ clearTableSelection: () => void;
16
18
  executeAction: typeof executeAction;
17
19
  focusedModels: import('vue').Ref<{
18
20
  key: string;
@@ -23,8 +25,30 @@ export declare const useActionManagerStore: import('pinia').StoreDefinition<"act
23
25
  }[]>;
24
26
  metadata: import('vue').Ref<any, any>;
25
27
  registerMetadata: (meta: RegisteredActionContext["metadata"]) => void;
28
+ selectedModels: import('vue').Ref<{
29
+ key: string;
30
+ modelName: string;
31
+ }[], import('..').ActionModel[] | {
32
+ key: string;
33
+ modelName: string;
34
+ }[]>;
26
35
  setFocusedModels: (models: RegisteredActionContext["models"]) => void;
36
+ setSelectedModels: (models: RegisteredActionContext["models"]) => void;
37
+ setTableSelection: (selection: TableSelectionState | null) => void;
27
38
  setViewModels: (models: RegisteredActionContext["models"]) => void;
39
+ tableSelection: import('vue').Ref<{
40
+ items: string[];
41
+ type: "exclude";
42
+ } | {
43
+ items: string[];
44
+ type: "include";
45
+ } | null, TableSelectionState | {
46
+ items: string[];
47
+ type: "exclude";
48
+ } | {
49
+ items: string[];
50
+ type: "include";
51
+ } | null>;
28
52
  unregisterMetadata: (key: string) => void;
29
53
  viewModels: import('vue').Ref<{
30
54
  key: string;
@@ -33,8 +57,9 @@ export declare const useActionManagerStore: import('pinia').StoreDefinition<"act
33
57
  key: string;
34
58
  modelName: string;
35
59
  }[]>;
36
- }, "metadata" | "focusedModels" | "viewModels">, Pick<{
60
+ }, "metadata" | "focusedModels" | "selectedModels" | "tableSelection" | "viewModels">, Pick<{
37
61
  actionContext: (options: ActionContextOptions) => RegisteredActionContext;
62
+ clearTableSelection: () => void;
38
63
  executeAction: typeof executeAction;
39
64
  focusedModels: import('vue').Ref<{
40
65
  key: string;
@@ -45,8 +70,30 @@ export declare const useActionManagerStore: import('pinia').StoreDefinition<"act
45
70
  }[]>;
46
71
  metadata: import('vue').Ref<any, any>;
47
72
  registerMetadata: (meta: RegisteredActionContext["metadata"]) => void;
73
+ selectedModels: import('vue').Ref<{
74
+ key: string;
75
+ modelName: string;
76
+ }[], import('..').ActionModel[] | {
77
+ key: string;
78
+ modelName: string;
79
+ }[]>;
48
80
  setFocusedModels: (models: RegisteredActionContext["models"]) => void;
81
+ setSelectedModels: (models: RegisteredActionContext["models"]) => void;
82
+ setTableSelection: (selection: TableSelectionState | null) => void;
49
83
  setViewModels: (models: RegisteredActionContext["models"]) => void;
84
+ tableSelection: import('vue').Ref<{
85
+ items: string[];
86
+ type: "exclude";
87
+ } | {
88
+ items: string[];
89
+ type: "include";
90
+ } | null, TableSelectionState | {
91
+ items: string[];
92
+ type: "exclude";
93
+ } | {
94
+ items: string[];
95
+ type: "include";
96
+ } | null>;
50
97
  unregisterMetadata: (key: string) => void;
51
98
  viewModels: import('vue').Ref<{
52
99
  key: string;
@@ -57,6 +104,7 @@ export declare const useActionManagerStore: import('pinia').StoreDefinition<"act
57
104
  }[]>;
58
105
  }, never>, Pick<{
59
106
  actionContext: (options: ActionContextOptions) => RegisteredActionContext;
107
+ clearTableSelection: () => void;
60
108
  executeAction: typeof executeAction;
61
109
  focusedModels: import('vue').Ref<{
62
110
  key: string;
@@ -67,8 +115,30 @@ export declare const useActionManagerStore: import('pinia').StoreDefinition<"act
67
115
  }[]>;
68
116
  metadata: import('vue').Ref<any, any>;
69
117
  registerMetadata: (meta: RegisteredActionContext["metadata"]) => void;
118
+ selectedModels: import('vue').Ref<{
119
+ key: string;
120
+ modelName: string;
121
+ }[], import('..').ActionModel[] | {
122
+ key: string;
123
+ modelName: string;
124
+ }[]>;
70
125
  setFocusedModels: (models: RegisteredActionContext["models"]) => void;
126
+ setSelectedModels: (models: RegisteredActionContext["models"]) => void;
127
+ setTableSelection: (selection: TableSelectionState | null) => void;
71
128
  setViewModels: (models: RegisteredActionContext["models"]) => void;
129
+ tableSelection: import('vue').Ref<{
130
+ items: string[];
131
+ type: "exclude";
132
+ } | {
133
+ items: string[];
134
+ type: "include";
135
+ } | null, TableSelectionState | {
136
+ items: string[];
137
+ type: "exclude";
138
+ } | {
139
+ items: string[];
140
+ type: "include";
141
+ } | null>;
72
142
  unregisterMetadata: (key: string) => void;
73
143
  viewModels: import('vue').Ref<{
74
144
  key: string;
@@ -77,5 +147,5 @@ export declare const useActionManagerStore: import('pinia').StoreDefinition<"act
77
147
  key: string;
78
148
  modelName: string;
79
149
  }[]>;
80
- }, "actionContext" | "executeAction" | "registerMetadata" | "setFocusedModels" | "setViewModels" | "unregisterMetadata">>;
150
+ }, "actionContext" | "clearTableSelection" | "executeAction" | "registerMetadata" | "setFocusedModels" | "setSelectedModels" | "setTableSelection" | "setViewModels" | "unregisterMetadata">>;
81
151
  export {};
@@ -1,5 +1,6 @@
1
1
  import { Router } from 'vue-router';
2
2
  import { ActionModel } from './actionModel.type.ts';
3
+ import { TableSelectionState } from './tableSelection.type.ts';
3
4
  /**
4
5
  * Contextual information available to actions during execution or evaluation.
5
6
  * Provides access to models, routing state, user input, and UI context.
@@ -39,6 +40,11 @@ export interface ActionContext<TModelMap = Record<string, ActionModel>, TRoutes
39
40
  * All models currently available in the application, regardless of selection or focus state.
40
41
  */
41
42
  allModels: TModelMap[keyof TModelMap][];
43
+ /**
44
+ * Clears the current data table selection, if any table is registering its
45
+ * selection with the action manager.
46
+ */
47
+ clearTableSelection: () => void;
42
48
  /**
43
49
  * Models that currently have keyboard or UI focus.
44
50
  * A subset of {@link allModels}.
@@ -78,12 +84,22 @@ export interface ActionContext<TModelMap = Record<string, ActionModel>, TRoutes
78
84
  * Empty string when no input has been provided.
79
85
  */
80
86
  searchInput: string;
87
+ /**
88
+ * Models that are currently selected
89
+ * A subset of {@link allModels}.
90
+ */
91
+ selectedModels: TModelMap[keyof TModelMap][];
81
92
  /**
82
93
  * Pagination offsets from previous `subActions` calls, keyed by action id.
83
94
  * Set by the host menu when triggering a "load more" scroll event.
84
95
  * Prefer `getPaginationOffsetForSubActionId` over reading this directly.
85
96
  */
86
97
  subActionsMeta?: Record<string, number | null>;
98
+ /**
99
+ * The current selection state of a data table, if a table is registering its
100
+ * selection with the action manager. `null` when no table selection is active.
101
+ */
102
+ tableSelection: TableSelectionState | null;
87
103
  /**
88
104
  * Returns the targeted model filtered to only those matching the given model type.
89
105
  *
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The selection state of a data table, expressed as either an explicit set of
3
+ * selected item keys (`'include'`) or a set of deselected item keys against an
4
+ * otherwise fully selected table (`'exclude'`).
5
+ */
6
+ export type TableSelectionState = {
7
+ items: string[];
8
+ type: 'exclude';
9
+ } | {
10
+ items: string[];
11
+ type: 'include';
12
+ };
@@ -2,7 +2,7 @@ import { Component } from 'vue';
2
2
  import { Action, ActionAvatar, SearchSubActionsConfig } from '../types/action.type.ts';
3
3
  import { ActionContext } from '../types/actionContext.type.ts';
4
4
  export type ActionFactory = (() => Action[]) | Action;
5
- export declare function applicableActions(actions: Action[], ctx: ActionContext, onUpdate?: (partial: Action[]) => void, parentAction?: Action): Promise<Action[]>;
5
+ export declare function applicableActions(actions: Action[], ctx: ActionContext, onUpdate?: (partial: Action[]) => void, parentAction?: Action, isGroupingDisabled?: boolean): Promise<Action[]>;
6
6
  export declare function resolveApplicable(action: Action, ctx: ActionContext): boolean;
7
7
  export declare function resolveActionValue<T>(value: ((ctx: ActionContext) => T) | T, ctx: ActionContext): T;
8
8
  export declare function resolveActionName(action: Action, ctx: ActionContext): string;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "type": "module",
7
- "version": "0.2.4",
7
+ "version": "0.4.0",
8
8
  "private": false,
9
9
  "license": "SEE LICENSE IN LICENSE.md",
10
10
  "repository": {
@@ -57,11 +57,11 @@
57
57
  "typescript": "5.9.3",
58
58
  "vite": "^8.1.0",
59
59
  "vite-plugin-dts": "4.5.4",
60
- "vitest": "4.1.0",
60
+ "vitest": "4.1.10",
61
61
  "vue": "3.5.27",
62
62
  "vue-tsc": "3.2.2",
63
- "@wisemen/vue-core-icons": "0.0.4",
64
- "@wisemen/eslint-config-vue": "2.1.5"
63
+ "@wisemen/eslint-config-vue": "2.1.6",
64
+ "@wisemen/vue-core-icons": "0.0.4"
65
65
  },
66
66
  "scripts": {
67
67
  "build": "vite build",