JezK
Edit File: sc-pagination.cjs.entry.js.map
{"file":"sc-pagination.entry.cjs.js","mappings":";;;;;;AAAA,MAAM,eAAe,GAAG,sDAAsD,CAAC;AAC/E,2BAAe,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yFC6CW,eAAO,CAAC,UAAE,kQAGlB,UAAE,4FACG,UAAE,8PAIP,UAAE,wFACG,UAAE;;;;;;;;;;;;;;","names":[],"sources":["src/components/ui/pagination/sc-pagination.scss?tag=sc-pagination&encapsulation=shadow","src/components/ui/pagination/sc-pagination.tsx"],"sourcesContent":[":host {\n display: block;\n}\n\n.pagination-display {\n opacity: 0.8;\n}\n","import { Component, h, Prop, Watch, State, Event, EventEmitter } from '@stencil/core';\nimport { sprintf, __ } from '@wordpress/i18n';\n\n@Component({\n tag: 'sc-pagination',\n styleUrl: 'sc-pagination.scss',\n shadow: true,\n})\nexport class ScPagination {\n @Prop() page: number = 1;\n @Prop() perPage: number = 0;\n @Prop() total: number = 0;\n @Prop() totalShowing: number = 0;\n @Prop() totalPages: number = 0;\n\n @State() hasNextPage: boolean;\n @State() hasPreviousPage: boolean;\n @State() from: number;\n @State() to: number;\n\n @Event() scPrevPage: EventEmitter<void>;\n @Event() scNextPage: EventEmitter<void>;\n\n componentWillLoad() {\n this.handlePaginationChange();\n }\n\n @Watch('total')\n @Watch('totalPages')\n @Watch('page')\n @Watch('perPage')\n @Watch('totalShowing')\n handlePaginationChange() {\n // do we have a previous or next page?\n this.hasNextPage = this.total > 1 && this.page < this.totalPages;\n this.hasPreviousPage = this.totalPages > 1 && this.page > 1;\n\n // from->to.\n this.from = this.perPage * (this.page - 1) + 1;\n this.to = Math.min(this.from + this.totalShowing - 1, this.total);\n }\n\n render() {\n if (!this.hasNextPage && !this.hasPreviousPage) return null;\n return (\n <sc-flex>\n <div class=\"pagination-display\">{sprintf(__('Displaying %1d to %2d of %3d items', 'surecart'), this.from, this.to, this.total)}</div>\n <sc-flex>\n <sc-button onClick={() => this.scPrevPage.emit()} type=\"text\" disabled={!this.hasPreviousPage}>\n <sc-visually-hidden>{__('Display previous page of items', 'surecart')}</sc-visually-hidden>\n <span aria-hidden=\"true\">{__('Previous', 'surecart')}</span>\n <sc-icon aria-hidden=\"true\" name=\"arrow-left\" slot=\"prefix\" />\n </sc-button>\n <sc-button onClick={() => this.scNextPage.emit()} type=\"text\" disabled={!this.hasNextPage}>\n <sc-visually-hidden>{__('Display next page of items', 'surecart')}</sc-visually-hidden>\n <span aria-hidden=\"true\">{__('Next', 'surecart')}</span>\n <sc-icon aria-hidden=\"true\" name=\"arrow-right\" slot=\"suffix\" />\n </sc-button>\n </sc-flex>\n </sc-flex>\n );\n }\n}\n"],"version":3}