@vuu-ui/vuu-data-editing 3.3.3 → 3.3.4

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,5 +1,5 @@
1
1
  {
2
- "version": "3.3.3",
2
+ "version": "3.3.4",
3
3
  "description": "Shared data editing APIs and React components for VUU UI",
4
4
  "main": "./src/index.js",
5
5
  "author": "heswell",
@@ -12,13 +12,13 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "@salt-ds/core": "1.54.1",
15
- "@vuu-ui/vuu-ui-controls": "3.3.3",
16
- "@vuu-ui/vuu-utils": "3.3.3"
15
+ "@vuu-ui/vuu-ui-controls": "3.3.4",
16
+ "@vuu-ui/vuu-utils": "3.3.4"
17
17
  },
18
18
  "devDependencies": {
19
- "@vuu-ui/vuu-data-types": "3.3.3",
20
- "@vuu-ui/vuu-protocol-types": "3.3.3",
21
- "@vuu-ui/vuu-table-types": "3.3.3"
19
+ "@vuu-ui/vuu-data-types": "3.3.4",
20
+ "@vuu-ui/vuu-protocol-types": "3.3.4",
21
+ "@vuu-ui/vuu-table-types": "3.3.4"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "react": "^19.2.3"
@@ -33,6 +33,7 @@ class EditSession extends EventEmitter {
33
33
  #sessionDataSource;
34
34
  #newRowState = {
35
35
  columns: [],
36
+ requiredColumns: [],
36
37
  draftRevision: 0,
37
38
  errors: {},
38
39
  submitting: false,
@@ -124,13 +125,14 @@ class EditSession extends EventEmitter {
124
125
  return this.#newRowState.columns.at(-1) === columnName;
125
126
  }
126
127
  isNewRowComplete() {
127
- return this.#newRowState.columns.every((column)=>{
128
+ const requiredColumns = this.#newRowState.requiredColumns ?? this.#newRowState.columns;
129
+ return requiredColumns.every((column)=>{
128
130
  const value = this.#newRowState.values[column];
129
131
  return void 0 !== value && ("string" != typeof value || "" !== value.trim());
130
132
  });
131
133
  }
132
- configureNewRow(columns) {
133
- if (columns.length === this.#newRowState.columns.length && columns.every((column, index)=>column === this.#newRowState.columns[index])) return;
134
+ configureNewRow(columns, requiredColumns) {
135
+ if (columns.length === this.#newRowState.columns.length && columns.every((column, index)=>column === this.#newRowState.columns[index]) && (!requiredColumns || void 0 !== this.#newRowState.requiredColumns && requiredColumns.length === this.#newRowState.requiredColumns.length && requiredColumns.every((column, index)=>column === this.#newRowState.requiredColumns?.[index]))) return;
134
136
  const columnSet = new Set(columns);
135
137
  const errors = Object.fromEntries(Object.entries(this.#newRowState.errors).filter(([column])=>columnSet.has(column)));
136
138
  this.#setNewRowState({
@@ -138,6 +140,9 @@ class EditSession extends EventEmitter {
138
140
  columns: [
139
141
  ...columns
140
142
  ],
143
+ requiredColumns: requiredColumns ? [
144
+ ...requiredColumns
145
+ ] : void 0,
141
146
  errors
142
147
  });
143
148
  }
@@ -156,7 +161,8 @@ class EditSession extends EventEmitter {
156
161
  });
157
162
  }
158
163
  async addNewRow() {
159
- const missingErrors = Object.fromEntries(this.#newRowState.columns.filter((column)=>{
164
+ const requiredColumns = this.#newRowState.requiredColumns ?? this.#newRowState.columns;
165
+ const missingErrors = Object.fromEntries(requiredColumns.filter((column)=>{
160
166
  const value = this.#newRowState.values[column];
161
167
  return void 0 === value || "string" == typeof value && "" === value.trim();
162
168
  }).map((column)=>[
@@ -202,6 +208,7 @@ class EditSession extends EventEmitter {
202
208
  }
203
209
  this.#setNewRowState({
204
210
  columns: this.#newRowState.columns,
211
+ requiredColumns: this.#newRowState.requiredColumns,
205
212
  draftRevision: this.#newRowState.draftRevision + 1,
206
213
  errors: {},
207
214
  submitting: false,
@@ -16,6 +16,7 @@ export type EditSessionConstructorProps = {
16
16
  };
17
17
  export type NewRowState = {
18
18
  columns: readonly string[];
19
+ requiredColumns?: readonly string[];
19
20
  draftRevision: number;
20
21
  errors: Readonly<Record<string, string>>;
21
22
  submitting: boolean;
@@ -64,7 +65,7 @@ export declare class EditSession extends EventEmitter<EditSessionEvents> {
64
65
  isNewRow(key: string): key is "__vuu_new_row__";
65
66
  isNewRowFinalColumn(columnName: string): boolean;
66
67
  isNewRowComplete(): boolean;
67
- configureNewRow(columns: readonly string[]): void;
68
+ configureNewRow(columns: readonly string[], requiredColumns?: readonly string[]): void;
68
69
  setNewRowValue(column: string, value: VuuRowDataItemType): void;
69
70
  addNewRow(): Promise<RpcResult>;
70
71
  deleteSelectedRows(): Promise<void>;