Skip to content

Commit ee916ba

Browse files
committed
feat: move to brandi
1 parent 906a858 commit ee916ba

71 files changed

Lines changed: 1543 additions & 1878 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/pluggableWidgets/datagrid-web/src/features/pagination/pagination.model.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

packages/pluggableWidgets/datagrid-web/src/model/containers/Datagrid.container.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,31 @@ import {
66
createClickActionHelper,
77
createFocusController,
88
createSelectionHelper,
9-
createSetPageAction,
10-
createSetPageSizeAction,
11-
currentPageAtom,
129
DatasourceService,
1310
layoutAtom,
14-
pageSizeAtom,
1511
SelectActionsProvider,
1612
TaskProgressService
1713
} from "@mendix/widget-plugin-grid/main";
14+
import {
15+
createSetPageAction,
16+
createSetPageSizeAction,
17+
currentPageAtom,
18+
customPaginationAtom,
19+
dynamicPageAtom,
20+
dynamicPageSizeAtom,
21+
DynamicPaginationFeature,
22+
PageControlService,
23+
pageSizeAtom,
24+
PaginationViewModel
25+
} from "@mendix/widget-plugin-grid/pagination/main";
1826
import { SelectionCounterViewModel } from "@mendix/widget-plugin-grid/selection-counter/SelectionCounter.viewModel-atoms";
1927
import { DerivedPropsGate } from "@mendix/widget-plugin-mobx-kit/main";
2028
import { generateUUID } from "@mendix/widget-plugin-platform/framework/generate-uuid";
2129
import { Container, injected } from "brandi";
2230
import { MainGateProps } from "../../../typings/MainGateProps";
2331
import { WidgetRootViewModel } from "../../features/base/WidgetRoot.viewModel";
2432
import { EmptyPlaceholderViewModel } from "../../features/empty-message/EmptyPlaceholder.viewModel";
25-
import { DynamicPaginationFeature } from "../../features/pagination/DynamicPagination.feature";
26-
import { PageControlService } from "../../features/pagination/PageControl.service";
2733
import { paginationConfig } from "../../features/pagination/pagination.config";
28-
import { customPaginationAtom, dynamicPageAtom, dynamicPageSizeAtom } from "../../features/pagination/pagination.model";
29-
import { PaginationViewModel } from "../../features/pagination/Pagination.viewModel";
3034
import { createCellEventsController } from "../../features/row-interaction/CellEventsController";
3135
import { creteCheckboxEventsController } from "../../features/row-interaction/CheckboxEventsController";
3236
import { SelectAllModule } from "../../features/select-all/SelectAllModule.container";
@@ -39,16 +43,16 @@ import { rowClassProvider } from "../models/rows.model";
3943
import { DatasourceParamsController } from "../services/DatasourceParamsController";
4044
import { DerivedLoaderController } from "../services/DerivedLoaderController";
4145
import { SelectionGate } from "../services/SelectionGate.service";
42-
import { CORE_TOKENS as CORE, DG_TOKENS as DG, SA_TOKENS } from "../tokens";
4346
import { GridSizeStore } from "../stores/GridSize.store";
47+
import { CORE_TOKENS as CORE, DG_TOKENS as DG, SA_TOKENS } from "../tokens";
4448

4549
// base
4650
injected(ColumnGroupStore, CORE.setupService, CORE.mainGate, CORE.config, DG.filterHost);
4751
injected(DatasourceParamsController, CORE.setupService, DG.query, DG.combinedFilter, CORE.columnsStore);
4852
injected(DatasourceService, CORE.setupService, DG.queryGate, DG.refreshInterval.optional);
4953
injected(GridBasicData, CORE.mainGate);
5054
injected(WidgetRootViewModel, CORE.mainGate, CORE.config, DG.exportProgressService, SA_TOKENS.selectionDialogVM);
51-
injected(GridSizeStore, CORE.atoms.hasMoreItems, DG.paginationConfig, DG.setPageAction);
55+
injected(GridSizeStore, CORE.atoms.hasMoreItems, DG.paginationConfig, DG.setPageAction.optional);
5256

5357
/** Pagination **/
5458
injected(createSetPageAction, DG.query, DG.paginationConfig, DG.currentPage, DG.pageSize);

packages/pluggableWidgets/datagrid-web/src/model/tokens.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ import {
1010
SelectAllService,
1111
SelectionDynamicProps,
1212
SelectionHelperService,
13-
SetPageAction,
1413
TaskProgressService
1514
} from "@mendix/widget-plugin-grid/main";
15+
import {
16+
DynamicPaginationFeature,
17+
GridPageControl,
18+
PageSizeStore,
19+
PaginationViewModel,
20+
SetPageAction
21+
} from "@mendix/widget-plugin-grid/pagination/main";
1622
import { SelectAllFeature } from "@mendix/widget-plugin-grid/select-all/select-all.feature";
1723
import {
1824
BarStore,
@@ -27,9 +33,6 @@ import { CSSProperties, ReactNode } from "react";
2733
import { MainGateProps } from "../../typings/MainGateProps";
2834
import { WidgetRootViewModel } from "../features/base/WidgetRoot.viewModel";
2935
import { EmptyPlaceholderViewModel } from "../features/empty-message/EmptyPlaceholder.viewModel";
30-
import { DynamicPaginationFeature } from "../features/pagination/DynamicPagination.feature";
31-
import { GridPageControl } from "../features/pagination/GridPageControl";
32-
import { PaginationViewModel } from "../features/pagination/Pagination.viewModel";
3336
import { PaginationConfig } from "../features/pagination/pagination.config";
3437
import { CellEventsController } from "../features/row-interaction/CellEventsController";
3538
import { CheckboxEventsController } from "../features/row-interaction/CheckboxEventsController";
@@ -45,7 +48,6 @@ import { RowClassProvider } from "./models/rows.model";
4548
import { DatagridSetupService } from "./services/DatagridSetup.service";
4649
import { DerivedLoaderController, DerivedLoaderControllerConfig } from "./services/DerivedLoaderController";
4750
import { TextsService } from "./services/Texts.service";
48-
import { PageSizeStore } from "./stores/PageSize.store";
4951
import { GridSizeStore } from "./stores/GridSize.store";
5052

5153
/** Tokens to resolve dependencies from the container. */

packages/pluggableWidgets/gallery-web/src/Gallery.editorPreview.tsx

Lines changed: 8 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,19 @@
11
import { enableStaticRendering } from "mobx-react-lite";
22
enableStaticRendering(true);
33

4-
import { useClickActionHelper } from "@mendix/widget-plugin-grid/helpers/ClickActionHelper";
5-
import { useFocusTargetController } from "@mendix/widget-plugin-grid/keyboard-navigation/useFocusTargetController";
6-
import { getColumnAndRowBasedOnIndex } from "@mendix/widget-plugin-grid/selection";
7-
import { getGlobalSortContext } from "@mendix/widget-plugin-sorting/react/context";
8-
import { SortStoreHost } from "@mendix/widget-plugin-sorting/stores/SortStoreHost";
9-
import { GUID, ObjectItem } from "mendix";
10-
import { createElement, ReactElement, ReactNode, RefObject, useCallback, useMemo } from "react";
4+
import { createElement, ReactElement } from "react";
115
import { GalleryPreviewProps } from "../typings/GalleryProps";
12-
import { Gallery as GalleryComponent } from "./components/Gallery";
13-
import { useItemEventsController } from "./features/item-interaction/ItemEventsController";
14-
import { useGridPositionsPreview } from "./features/useGridPositionsPreview";
15-
import { useItemPreviewHelper } from "./helpers/ItemPreviewHelper";
16-
import { useItemSelectHelper } from "./helpers/useItemSelectHelper";
176
import "./ui/GalleryPreview.scss";
187

19-
const SortAPI = getGlobalSortContext();
20-
218
function Preview(props: GalleryPreviewProps): ReactElement {
22-
const { emptyPlaceholder } = props;
23-
const { numberOfColumns, numberOfRows, containerRef, numberOfItems } = useGridPositionsPreview({
24-
phoneItems: props.phoneItems ?? 1,
25-
tabletItems: props.tabletItems ?? 1,
26-
desktopItems: props.desktopItems ?? 1,
27-
totalItems: props.pageSize ?? 3
28-
});
29-
30-
const items: ObjectItem[] = Array.from({ length: numberOfItems }).map((_, index) => ({
31-
id: String(index) as GUID
32-
}));
33-
34-
const selectHelper = useItemSelectHelper(props.itemSelection, undefined);
35-
36-
const getPositionCallback = useCallback(
37-
(index: number) => getColumnAndRowBasedOnIndex(numberOfColumns, items.length, index),
38-
[numberOfColumns, items.length]
39-
);
40-
41-
const focusController = useFocusTargetController({
42-
rows: numberOfRows,
43-
columns: numberOfColumns,
44-
pageSize: props.pageSize ?? 0
45-
});
46-
47-
const clickActionHelper = useClickActionHelper({ onClick: props.onClick, onClickTrigger: "none" });
48-
49-
const itemEventsController = useItemEventsController(
50-
selectHelper,
51-
clickActionHelper,
52-
focusController,
53-
numberOfColumns,
54-
props.itemSelectionMode
55-
);
56-
57-
const sortAPI = useMemo(
58-
() =>
59-
({
60-
version: 1,
61-
host: new SortStoreHost()
62-
}) as const,
63-
[]
64-
);
65-
669
return (
67-
<div ref={containerRef as RefObject<HTMLDivElement>}>
68-
<GalleryComponent
69-
className={props.class}
70-
desktopItems={props.desktopItems!}
71-
emptyPlaceholderRenderer={useCallback(
72-
(renderWrapper: (children: ReactNode) => ReactElement) => (
73-
<emptyPlaceholder.renderer caption="Empty list message: Place widgets here">
74-
{renderWrapper(null)}
75-
</emptyPlaceholder.renderer>
76-
),
77-
[emptyPlaceholder]
78-
)}
79-
header={
80-
<SortAPI.Provider value={sortAPI}>
81-
<props.filtersPlaceholder.renderer caption="Place widgets like filter widget(s) and action button(s) here">
82-
<div />
83-
</props.filtersPlaceholder.renderer>
84-
</SortAPI.Provider>
85-
}
86-
showHeader
87-
hasMoreItems={false}
88-
items={items}
89-
itemHelper={useItemPreviewHelper({
90-
contentValue: props.content,
91-
hasOnClick: props.onClick !== null
92-
})}
93-
numberOfItems={props.pageSize!}
94-
page={0}
95-
pageSize={props.pageSize!}
96-
paging={props.pagination === "buttons"}
97-
paginationPosition={props.pagingPosition}
98-
paginationType={props.pagination}
99-
showPagingButtons={props.showPagingButtons}
100-
showEmptyStatePreview={props.showEmptyPlaceholder === "custom"}
101-
phoneItems={props.phoneItems!}
102-
tabletItems={props.tabletItems!}
103-
selectHelper={selectHelper}
104-
itemEventsController={itemEventsController}
105-
focusController={focusController}
106-
getPosition={getPositionCallback}
107-
showRefreshIndicator={false}
108-
preview
109-
/>
10+
<div>
11+
FIX ME: Preview for gallery
12+
<div>
13+
<props.content.renderer>
14+
<div />
15+
</props.content.renderer>
16+
</div>
11017
</div>
11118
);
11219
}

packages/pluggableWidgets/gallery-web/src/Gallery.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import { ContainerProvider } from "brandi-react";
2-
import { observer } from "mobx-react-lite";
32
import { ReactElement } from "react";
43
import { GalleryContainerProps } from "../typings/GalleryProps";
4+
import { GalleryWidget } from "./components/GalleryWidget";
55
import { useGalleryContainer } from "./model/hooks/useGalleryContainer";
66

7-
const GalleryWidget = observer(function GalleryWidget(): ReactElement {
8-
return <div />;
9-
});
10-
117
export function Gallery(props: GalleryContainerProps): ReactElement {
128
const container = useGalleryContainer(props);
139

packages/pluggableWidgets/gallery-web/src/Gallery.xml

Lines changed: 71 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@
9595
<enumerationValue key="loadMore">Load more</enumerationValue>
9696
</enumerationValues>
9797
</property>
98+
<property key="useCustomPagination" type="boolean" defaultValue="false">
99+
<caption>Custom pagination</caption>
100+
<description />
101+
</property>
102+
<property key="customPagination" type="widgets" required="false">
103+
<caption>Custom pagination</caption>
104+
<description />
105+
</property>
98106
<property key="showTotalCount" type="boolean" defaultValue="false">
99107
<caption>Show total count</caption>
100108
<description />
@@ -124,6 +132,27 @@
124132
<translation lang="nl_NL">Laad meer</translation>
125133
</translations>
126134
</property>
135+
<property key="dynamicPageSize" type="attribute" required="false">
136+
<caption>Page size attribute</caption>
137+
<description>Attribute to set the page size dynamically.</description>
138+
<attributeTypes>
139+
<attributeType name="Integer" />
140+
</attributeTypes>
141+
</property>
142+
<property key="dynamicPage" type="attribute" required="false">
143+
<caption>Page attribute</caption>
144+
<description>Attribute to set the page dynamically.</description>
145+
<attributeTypes>
146+
<attributeType name="Integer" />
147+
</attributeTypes>
148+
</property>
149+
<property key="totalCountValue" type="attribute" required="false">
150+
<caption>Total count</caption>
151+
<description>Attribute to store current total count</description>
152+
<attributeTypes>
153+
<attributeType name="Integer" />
154+
</attributeTypes>
155+
</property>
127156
</propertyGroup>
128157
<propertyGroup caption="Items">
129158
<property key="showEmptyPlaceholder" type="enumeration" defaultValue="none">
@@ -162,6 +191,48 @@
162191
<description />
163192
</property>
164193
</propertyGroup>
194+
<propertyGroup caption="Captions">
195+
<property key="selectedCountTemplateSingular" type="textTemplate" required="false">
196+
<caption>Row count singular</caption>
197+
<description>Must include '%d' to denote number position</description>
198+
<translations>
199+
<translation lang="en_US">%d row selected</translation>
200+
<translation lang="nl_NL">%d rij geselecteerd</translation>
201+
</translations>
202+
</property>
203+
<property key="selectedCountTemplatePlural" type="textTemplate" required="false">
204+
<caption>Row count plural</caption>
205+
<description>Must include '%d' to denote number position</description>
206+
<translations>
207+
<translation lang="en_US">%d rows selected</translation>
208+
<translation lang="nl_NL">%d rijen geselecteerd</translation>
209+
</translations>
210+
</property>
211+
<property key="selectAllText" type="textTemplate">
212+
<caption>Select all text</caption>
213+
<description />
214+
<translations>
215+
<translation lang="en_US">Select all rows in the data source</translation>
216+
<translation lang="nl_NL">Selecteer alle rijen in de gegevensbron</translation>
217+
</translations>
218+
</property>
219+
<property key="selectAllTemplate" type="textTemplate">
220+
<caption>Select all template</caption>
221+
<description>This caption used when total count is available.</description>
222+
<translations>
223+
<translation lang="en_US">Select all %d rows in the data source</translation>
224+
<translation lang="nl_NL">Selecteer alle %d rijen in de gegevensbron</translation>
225+
</translations>
226+
</property>
227+
<property key="allSelectedText" type="textTemplate">
228+
<caption>Select status template</caption>
229+
<description />
230+
<translations>
231+
<translation lang="en_US">All %d rows selected.</translation>
232+
<translation lang="nl_NL">Alle %d rijen geselecteerd.</translation>
233+
</translations>
234+
</property>
235+
</propertyGroup>
165236
</propertyGroup>
166237
<propertyGroup caption="Personalization">
167238
<propertyGroup caption="Configuration">
@@ -212,22 +283,6 @@
212283
<caption>Item description</caption>
213284
<description>Assistive technology will read this upon reaching each gallery item.</description>
214285
</property>
215-
<property key="selectedCountTemplateSingular" type="textTemplate" required="false">
216-
<caption>Item count singular</caption>
217-
<description>Must include '%d' to denote number position</description>
218-
<translations>
219-
<translation lang="en_US">%d item selected</translation>
220-
<translation lang="nl_NL">%d item geselecteerd</translation>
221-
</translations>
222-
</property>
223-
<property key="selectedCountTemplatePlural" type="textTemplate" required="false">
224-
<caption>Item count plural</caption>
225-
<description>Must include '%d' to denote number position</description>
226-
<translations>
227-
<translation lang="en_US">%d items selected</translation>
228-
<translation lang="nl_NL">%d items geselecteerd</translation>
229-
</translations>
230-
</property>
231286
</propertyGroup>
232287
</propertyGroup>
233288
</properties>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { observer } from "mobx-react-lite";
2+
import { ReactNode } from "react";
3+
import { useEmptyPlaceholderVM } from "../model/hooks/injection-hooks";
4+
5+
export const EmptyPlaceholder = observer(function EmptyPlaceholder(): ReactNode {
6+
const vm = useEmptyPlaceholderVM();
7+
8+
if (!vm.content) return null;
9+
10+
return (
11+
<section className="widget-gallery-empty" aria-label={vm.sectionAriaLabel}>
12+
<div className="empty-placeholder">{vm.content}</div>
13+
</section>
14+
);
15+
});

0 commit comments

Comments
 (0)