Compare commits

..

No commits in common. "017b6445fbcc67c07a2bb20e6c4e7e39a5133e1c" and "249c283819b99b8c8f6bf8d9ee2808eda1fd5aa5" have entirely different histories.

5 changed files with 16 additions and 32 deletions

View File

@ -1,17 +1,5 @@
# @warkypublic/zustandsyncstore # @warkypublic/zustandsyncstore
## 0.0.22
### Patch Changes
- 7c1d478: Possible selection fixes
## 0.0.21
### Patch Changes
- 6664c98: Calls onchange on cell click since selection does not change.
## 0.0.20 ## 0.0.20
### Patch Changes ### Patch Changes

View File

@ -1,7 +1,7 @@
{ {
"name": "@warkypublic/oranguru", "name": "@warkypublic/oranguru",
"author": "Warky Devs", "author": "Warky Devs",
"version": "0.0.22", "version": "0.0.20",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",

View File

@ -238,9 +238,9 @@ export const GridlerDataGrid = () => {
JSON.stringify(currentSelection?.current) !== JSON.stringify(selection.current) JSON.stringify(currentSelection?.current) !== JSON.stringify(selection.current)
) { ) {
setState('_gridSelection', { ...selection, rows }); setState('_gridSelection', { ...selection, rows });
//if (JSON.stringify(currentSelection?.rows) !== JSON.stringify(rows)) { if (JSON.stringify(currentSelection?.rows) !== JSON.stringify(rows)) {
setState('_gridSelectionRows', rows); setState('_gridSelectionRows', rows);
//} }
} }
//console.log('Selection', selection); //console.log('Selection', selection);

View File

@ -282,12 +282,7 @@ export const Computer = React.memo(() => {
const firstRow = firstBuffer?.[keyField]; const firstRow = firstBuffer?.[keyField];
const currentValues = getState('values') ?? []; const currentValues = getState('values') ?? [];
if ( if (firstRow && firstRow > 0 && (currentValues.length ?? 0) === 0) {
!(values && values.length > 0) &&
firstRow &&
firstRow > 0 &&
(currentValues.length ?? 0) === 0
) {
const values = [firstBuffer, ...(currentValues as Array<Record<string, unknown>>)]; const values = [firstBuffer, ...(currentValues as Array<Record<string, unknown>>)];
const onChange = getState('onChange'); const onChange = getState('onChange');
@ -345,12 +340,10 @@ export const Computer = React.memo(() => {
if (selectedRowKey) { if (selectedRowKey) {
const onChange = getState('onChange'); const onChange = getState('onChange');
const selected = [{ [getState('keyField') ?? 'id']: selectedRowKey }]; const selected = [{ [getState('keyField') ?? 'id']: selectedRowKey }];
if (JSON.stringify(getState('values')) !== JSON.stringify(selected)) { if (onChange) {
if (onChange) { onChange(selected);
onChange(selected); } else {
} else { setState('values', selected);
setState('values', selected);
}
} }
} }

View File

@ -463,10 +463,13 @@ const { Provider, useStore: useGridlerStore } = createSyncStore<GridlerStoreStat
const [col, row] = cell; const [col, row] = cell;
if (state.glideProps?.onCellClicked) { if (state.glideProps?.onCellClicked) {
state.glideProps?.onCellClicked?.(cell, event); state.glideProps?.onCellClicked?.(cell, event);
} } else {
if (state.values?.length) { if (state.values?.length) {
if (state.onChange) { if (state.onChange) {
state.onChange(state.values); state.onChange(state.values);
} else {
state.setState('values', state.values);
}
} }
} }