Skip to content

Commit 47ca6f0

Browse files
authored
feat/pagination v2 (#58)
* feat(pagination): add capacity and tooltip on arrow
1 parent db37eb7 commit 47ca6f0

32 files changed

+1038
-457
lines changed

packages/libraries/cdk/src/components/surface/ocdk-surface-controller.ts

+5-15
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,15 @@ export class OcdkSurfaceController<StrategyConfig = any> {
5454
private animation = OcdkSurfaceDefaultConfig.DEFAULT_ANIMATION;
5555
private animationRequestId = 0;
5656
private closeAnimationEndTimerId = 0;
57-
private component: OcdkSurface;
5857
/** config of the surface */
5958
private config: OcdkSurfaceConfig = OcdkSurfaceDefaultConfig
6059
private customAnchorMargin?: OcdkSurfaceDistance;
6160
private customCornerPoints?: OcdkSurfaceCornerPoints;
6261
private dimensions!: OcdkSurfaceDimensions;
6362
private isSurfaceOpen = false;
6463
private itemHeight = 0;
65-
private itemWidth = 0;
6664
private maxDimensions!: OcdkSurfaceMaxDimensions;
67-
private minVisibleItem = 1;
65+
private MIN_VISIBLE_ITEM = 1;
6866
// private measurements?: OcdkAutoLayoutMeasurements;
6967
private openAnimationEndTimerId = 0;
7068
private strategy: OcdkSurfaceStrategyDefiner<StrategyConfig> = OcdkSurfaceDefaultConfig.POSITION_STRATEGY.strategy;
@@ -75,7 +73,6 @@ export class OcdkSurfaceController<StrategyConfig = any> {
7573
private logger = new OcdkLogger(`OcdkSurface #${this.uniqueId}`);
7674

7775
constructor(component: OcdkSurface) {
78-
this.component = component;
7976
this.adapter = component.adapter;
8077
this.init();
8178
}
@@ -157,7 +154,7 @@ export class OcdkSurfaceController<StrategyConfig = any> {
157154
}
158155

159156
open(): void {
160-
this.logger.log('[open]', { opened: this.component.opened });
157+
this.logger.log('[open]', { opened: this.isSurfaceOpen });
161158
if (this.isSurfaceOpen) {
162159
return;
163160
}
@@ -172,9 +169,9 @@ export class OcdkSurfaceController<StrategyConfig = any> {
172169
this.dimensions = this.adapter.getInnerDimensions();
173170
this.maxDimensions = this.adapter.getMaxDimensions();
174171
this.itemHeight = this.adapter.autoDetectItemHeight();
175-
this.itemWidth = this.adapter.autoDetectItemWidth();
176172
this.autoPosition();
177173
this.adapter.addClass(ocdkSurfaceCssClasses.OPEN);
174+
this.logger.log('[open]', { dimensions: this.dimensions });
178175
const duration = this.config.ANIMATIONS[ this.animation ].TRANSITION_CLOSE_DURATION;
179176
this.logger.log('[open]', 'remove css in', duration);
180177
this.openAnimationEndTimerId = window.setTimeout(
@@ -242,12 +239,6 @@ export class OcdkSurfaceController<StrategyConfig = any> {
242239
}
243240

244241
private autoPosition() {
245-
this.logger.log('[autoposition]');
246-
const cornerPoints = this.getCornerPoints();
247-
const wantedAnchorCorner = cornerPoints.anchor;
248-
const wantedOriginCorner = cornerPoints.origin;
249-
this.logger.log('[autoposition]', { wantedAnchorCorner });
250-
this.logger.log('[autoposition]', { wantedOriginCorner });
251242

252243
const normalizedCornerPoints = this.getNormalizedCorners();
253244

@@ -340,9 +331,8 @@ export class OcdkSurfaceController<StrategyConfig = any> {
340331
this.logger.log('[autoposition]', 'setPosition', { position });
341332
this.adapter.setPosition(position);
342333
this.adapter.setMaxHeight(maxSurfaceHeight ? maxSurfaceHeight + 'px' : '');
343-
this.adapter.setMinHeight(this.itemHeight ? (this.itemHeight * this.minVisibleItem) + 'px' : '');
344-
this.adapter.setMaxWidth(maxSurfaceWidth ? maxSurfaceWidth + 'px' : '');
345-
this.adapter.setMinWidth(this.itemWidth ? (this.itemWidth * this.minVisibleItem) + 'px' : '');
334+
this.adapter.setMinHeight(this.itemHeight ? (this.itemHeight * this.MIN_VISIBLE_ITEM) + 'px' : '');
335+
// this.adapter.setMaxWidth(maxSurfaceWidth ? maxSurfaceWidth + 'px' : '');
346336

347337
// If it is opened from the top then add is-open-below class
348338
if (!this.hasBit(originCorner, OcdkSurfaceCornerBit.BOTTOM)) {

packages/libraries/cdk/src/components/surface/ocdk-surface.ts

+1-14
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export class OcdkSurface extends HTMLElement implements OcdkSurfaceBehaviour {
2525

2626
constructor() {
2727
super();
28-
this.logger.log('constructor');
2928
this.adapter = this.getDefaultAdapter();
3029

3130
this.controller = new OcdkSurfaceController(this);
@@ -73,7 +72,6 @@ export class OcdkSurface extends HTMLElement implements OcdkSurfaceBehaviour {
7372
* @param animated - have to animated or not
7473
*/
7574
set animated(animated: boolean) {
76-
this.logger.log('animated', animated);
7775
this.processAnimated(animated, true);
7876
}
7977

@@ -92,7 +90,6 @@ export class OcdkSurface extends HTMLElement implements OcdkSurfaceBehaviour {
9290
* @param name - name of the wanted animation
9391
*/
9492
set animation(name: OcdkSurfaceAnimation | 'none' | undefined) {
95-
this.logger.log('animation', name);
9693
this.processAnimation(name, true);
9794
}
9895

@@ -106,7 +103,6 @@ export class OcdkSurface extends HTMLElement implements OcdkSurfaceBehaviour {
106103
* @param corners - tuple of corner references (anchor, origin)
107104
*/
108105
set corners(corners: [OcdkSurfaceCorner, OcdkSurfaceCorner]) {
109-
this.logger.log('corners', corners);
110106
this.controller.setCornerPoints({ anchor: corners[ 0 ], origin: corners[ 1 ] });
111107
}
112108

@@ -119,7 +115,6 @@ export class OcdkSurface extends HTMLElement implements OcdkSurfaceBehaviour {
119115
* @param opened - is opened or not
120116
*/
121117
set opened(opened: boolean) {
122-
this.logger.log('opened', opened);
123118
if (opened) {
124119
this.setAttribute('opened', '');
125120
this.controller.open();
@@ -135,8 +130,7 @@ export class OcdkSurface extends HTMLElement implements OcdkSurfaceBehaviour {
135130
* @param oldValue - previous value
136131
* @param newValue - current value
137132
*/
138-
attributeChangedCallback(name: any, oldValue: any, newValue: any | null) {
139-
this.logger.log('oldValue', { name, oldValue, newValue });
133+
attributeChangedCallback(name: any, _oldValue: any, newValue: any | null) {
140134
switch (name) {
141135
case 'animation':
142136
this.processAnimation(newValue);
@@ -158,7 +152,6 @@ export class OcdkSurface extends HTMLElement implements OcdkSurfaceBehaviour {
158152
* Hide the `surface` overlay.
159153
*/
160154
close() {
161-
this.logger.log('close');
162155
this.opened = false;
163156
}
164157

@@ -171,10 +164,6 @@ export class OcdkSurface extends HTMLElement implements OcdkSurfaceBehaviour {
171164
this.logger.log('[connectedCallback]', 'set anchor', { anchorElement: this.anchorElement });
172165
}
173166

174-
const slot = this.shadowRoot?.querySelector('slot')
175-
if (slot) {
176-
this.logger.log(slot.assignedElements());
177-
}
178167

179168
this.animated = this.animation.toLowerCase() === 'none' ? false : true;
180169
this.animation = this.animation.toLowerCase() as OcdkSurfaceAnimation;
@@ -189,7 +178,6 @@ export class OcdkSurface extends HTMLElement implements OcdkSurfaceBehaviour {
189178
* Display the `surface` overlay and display it with the selected position strategy.
190179
*/
191180
open(): void {
192-
this.logger.log('open');
193181
this.opened = true;
194182
}
195183

@@ -207,7 +195,6 @@ export class OcdkSurface extends HTMLElement implements OcdkSurfaceBehaviour {
207195
* @param element - html element to set as the anchor
208196
*/
209197
setAnchorElement(element: Element): void {
210-
this.logger.log('[setAnchorElement]', { element });
211198
this.anchorElement = element;
212199
}
213200

packages/libraries/cdk/src/components/surface/strategies/symmetry/ocdk-surface-symmetry.bl-tl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function ocdkSurfaceSymmetryBlTl(): OcdkSurfaceOnePositionStrategy<OcdkSu
3838
},
3939
appliers: {
4040
maxHeight: (opt) => opt.inspections.comfort.availableBottom,
41-
maxWidth: (opt) => opt.measurements.surfaceSize.width,
41+
maxWidth: (opt) => opt.inspections.comfort.availableRight,
4242
verticalOffset: (opt) => opt.measurements.anchorSize.height + opt.config.anchorMargin.bottom,
4343
verticalAlignment: 'top',
4444
horizontalOffset: () => 0,

packages/libraries/cdk/src/components/surface/strategies/symmetry/ocdk-surface-symmetry.br-tr.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function ocdkSurfaceSymmetryBrTr(): OcdkSurfaceOnePositionStrategy<OcdkSu
4141
},
4242
appliers: {
4343
maxHeight: (opt) => opt.inspections.comfort.availableBottom - opt.config.anchorMargin.bottom,
44-
maxWidth: (opt) => opt.measurements.surfaceSize.width,
44+
maxWidth: (opt) => opt.inspections.comfort.availableLeft,
4545
verticalOffset: (opt) => opt.measurements.anchorSize.height + opt.config.anchorMargin.bottom,
4646
verticalAlignment: 'top',
4747
horizontalOffset: () => 0,

packages/libraries/cdk/src/components/surface/strategies/symmetry/ocdk-surface-symmetry.tl-bl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function ocdkSurfaceSymmetryTlBl(): OcdkSurfaceOnePositionStrategy<OcdkSu
3636
},
3737
appliers: {
3838
maxHeight: (opt) => opt.inspections.comfort.availableTop,
39-
maxWidth: (opt) => opt.measurements.surfaceSize.width,
39+
maxWidth: (opt) => opt.inspections.comfort.availableRight,
4040
verticalOffset: (opt) => -opt.config.anchorMargin.top - opt.measurements.surfaceSize.height,
4141
verticalAlignment: 'top',
4242
horizontalOffset: () => 0,

packages/libraries/cdk/src/components/surface/strategies/symmetry/ocdk-surface-symmetry.tr-br.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function ocdkSurfaceSymmetryTrBr(): OcdkSurfaceOnePositionStrategy<OcdkSu
3939
},
4040
appliers: {
4141
maxHeight: (opt) => opt.inspections.comfort.availableTop - opt.config.anchorMargin.top,
42-
maxWidth: (opt) => opt.measurements.surfaceSize.width,
42+
maxWidth: (opt) => opt.inspections.comfort.availableLeft,
4343
verticalOffset: (opt) => -opt.config.anchorMargin.top - opt.measurements.surfaceSize.height,
4444
verticalAlignment: 'top',
4545
horizontalOffset: () => 0,

packages/libraries/core/src/components/pagination/ods-pagination-attributes.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,19 @@ export interface OdsPaginationAttributes extends OdsComponentAttributes {
1111
*/
1212
current: number;
1313
/**
14-
* The total amount of pages
14+
* The total number of items.
1515
*/
16-
total: number;
16+
totalItems?: number;
17+
/**
18+
* The total amount of pages.
19+
*/
20+
totalPages: number;
21+
/**
22+
* The label of the tooltip on the arrow previous
23+
*/
24+
labelTooltipPrevious: string;
25+
/**
26+
* The label of the tooltip on the arrow next
27+
*/
28+
labelTooltipNext: string;
1729
}

0 commit comments

Comments
 (0)