Compare commits

..

No commits in common. "e6560aa990ae9807ea2bfc33c195858d28e1dd3f" and "1284f46aa935595374ac6bccf5cace516cba2b3c" have entirely different histories.

10 changed files with 12 additions and 70 deletions

View File

@ -1,11 +1,5 @@
# @warkypublic/zustandsyncstore
## 0.0.16
### Patch Changes
- 5e922df: A Few fixes
## 0.0.15
### Patch Changes

View File

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

View File

@ -50,7 +50,6 @@ export const GridlerDataGrid = () => {
headerHeight,
heightProp,
mounted,
onCellActivated,
onCellClicked,
onCellEdited,
onColumnMoved,
@ -81,7 +80,6 @@ export const GridlerDataGrid = () => {
headerHeight: s.headerHeight,
heightProp: s.height,
mounted: s.mounted,
onCellActivated: s.onCellActivated,
onCellClicked: s.onCellClicked,
onCellEdited: s.onCellEdited,
onColumnMoved: s.onColumnMoved,
@ -180,7 +178,6 @@ export const GridlerDataGrid = () => {
gridSelection={_gridSelection}
headerHeight={headerHeight ?? 32}
headerIcons={{ sort: SortSprite, sortdown: SortDownSprite, sortup: SortUpSprite }}
onCellActivated={onCellActivated}
onCellClicked={onCellClicked}
onCellContextMenu={(cell, event) => {
event.preventDefault();
@ -222,15 +219,6 @@ export const GridlerDataGrid = () => {
rows = rows.hasIndex(y) ? rows : rows.add(y);
}
}
if (rows.length === 0) {
for (const r of currentSelection?.rows ?? []) {
const validRowID = getRowBuffer ? getRowBuffer(r)?.[keyField] : null;
if (!validRowID) {
continue;
}
rows = rows.hasIndex(r) ? rows : rows.add(r);
}
}
if (
JSON.stringify(currentSelection?.columns) !== JSON.stringify(selection.columns) ||

View File

@ -160,11 +160,10 @@ export interface GridlerState {
getState: <K extends keyof GridlerStoreState>(key: K) => GridlerStoreState[K];
hasLocalData: boolean;
isEmpty: boolean;
loadingData?: boolean;
loadingData?: boolean;
loadPage: (page: number, clearMode?: 'all' | 'page') => Promise<void>;
mounted: boolean;
onCellActivated: (cell: Item) => void;
onCellClicked: (cell: Item, event: CellClickedEventArgs) => void;
onCellEdited: (cell: Item, newVal: EditableGridCell) => void;
onColumnMoved: (from: number, to: number) => void;
@ -401,7 +400,7 @@ const { Provider, useStore: useGridlerStore } = createSyncStore<GridlerStoreStat
);
})
.catch((e) => {
console.error('loadPage Error: ', page, e);
console.warn('loadPage Error: ', page, e);
state._events.dispatchEvent(
new CustomEvent('loadPage_error', {
detail: { clearMode, error: e, page: pPage, state },
@ -412,17 +411,6 @@ const { Provider, useStore: useGridlerStore } = createSyncStore<GridlerStoreStat
},
maxConcurrency: 1,
mounted: false,
onCellActivated: (cell: Item): void => {
const state = get();
const [col, row] = cell;
state._events.dispatchEvent(
new CustomEvent('onCellActivated', {
detail: { cell, col, row, state },
})
);
state.glideProps?.onCellActivated?.(cell);
},
onCellClicked: (cell: Item, event: CellClickedEventArgs) => {
const state = get();
const [col, row] = cell;

View File

@ -15,16 +15,14 @@ function _GridlerRefHandler(props: PropsWithChildren, ref: Ref<GridlerRef> | und
refresh: async (parms?: any) => {
const refreshCells = getstate('refreshCells');
const loadPage = getstate('loadPage');
loadPage?.(parms?.pageIndex ?? 0, 'all').then(() => {
refreshCells?.();
});
loadPage?.(parms?.pageIndex ?? 0, 'all');
refreshCells?.();
},
reload: async (parms?: any) => {
const refreshCells = getstate('refreshCells');
const loadPage = getstate('loadPage');
loadPage?.(parms?.pageIndex ?? 0, 'all').then(() => {
refreshCells?.();
});
loadPage?.(parms?.pageIndex ?? 0, 'all');
refreshCells?.();
},
reloadRow: async (key: number | string) => {
const refreshCells = getstate('refreshCells');

View File

@ -174,10 +174,9 @@ function _GlidlerAPIAdaptorForGoLangv2<T = unknown>(props: GlidlerAPIAdaptorForG
...(cv ?? []).filter((f) => f.page !== index),
]);
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (_e) {
} catch (e) {
//console.log('APIAdaptorGoLangv2 error', e);
//addError(`Error: ${e}`, 'api', props.url);
addError(`Error: ${e}`, 'api', props.url);
}
setState('loadingData', false);
return [];

View File

@ -14,7 +14,6 @@ import type { GridlerColumn } from '../Column';
import { type GridlerProps, type GridlerState, useGridlerStore } from '../GridlerStore';
export function GlidlerFormAdaptor(props: {
changeOnActiveClick?: boolean;
descriptionField?: ((data: Record<string, unknown>) => string) | string;
getMenuItems?: GridlerProps['getMenuItems'];
onReload?: () => void;
@ -24,36 +23,13 @@ export function GlidlerFormAdaptor(props: {
) => void;
showDescriptionInMenu?: boolean;
}) {
const [getState, mounted, setState, reload, _events] = useGridlerStore((s) => [
const [getState, mounted, setState, reload] = useGridlerStore((s) => [
s.getState,
s.mounted,
s.setState,
s.reload,
s._events,
]);
useEffect(() => {
if (mounted && props.changeOnActiveClick) {
const evf = (event: CustomEvent<any>) => {
const { row, state } = event.detail;
const getRowBuffer = state.getRowBuffer as (row: number) => Record<string, unknown>;
if (getRowBuffer) {
const rowData = getRowBuffer(row);
if (!rowData) {
return;
}
props.onRequestForm('change', rowData);
}
};
_events?.addEventListener('onCellActivated', evf as any);
return () => {
if (evf) {
_events?.removeEventListener('onCellActivated', evf as any);
}
};
}
}, [props.changeOnActiveClick, mounted, _events]);
const getMenuItems = useCallback(
(
id: string,

View File

@ -126,7 +126,6 @@ export const GridlerGoAPIExampleEventlog = () => {
url={`${apiUrl}/public/process`}
/>
<Gridler.FormAdaptor
changeOnActiveClick={true}
descriptionField={'process'}
onRequestForm={(request, data) => {
console.log('Form requested', request, data);

View File

@ -120,7 +120,7 @@ const MenuItemRenderer = ({ children, label, ...props }: MantineBetterMenuInstan
props.onClick?.(e);
if (props.onClickAsync) {
setLoading(true);
props.onClickAsync(e).finally(() => setLoading(false));
props.onClickAsync().finally(() => setLoading(false));
}
}}
styles={{

View File

@ -22,7 +22,7 @@ export interface MantineBetterMenuInstanceItem extends Partial<MenuItemProps> {
items?: Array<MantineBetterMenuInstanceItem>;
label?: string;
onClick?: (e?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
onClickAsync?: (e?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => Promise<void>;
onClickAsync?: () => Promise<void>;
renderer?:
| ((props: MantineBetterMenuInstanceItem & Record<string, unknown>) => ReactNode)
| ReactNode;