@teipublisher/pb-components 3.0.9 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10909,6 +10909,12 @@
10909
10909
  "type": "boolean",
10910
10910
  "default": "false"
10911
10911
  },
10912
+ {
10913
+ "name": "pagination-top",
10914
+ "description": "If specified, render the pagination controls above the table instead of below.",
10915
+ "type": "boolean",
10916
+ "default": "false"
10917
+ },
10912
10918
  {
10913
10919
  "name": "per-page",
10914
10920
  "type": "number",
@@ -10983,6 +10989,13 @@
10983
10989
  "type": "boolean",
10984
10990
  "default": "false"
10985
10991
  },
10992
+ {
10993
+ "name": "paginationTop",
10994
+ "attribute": "pagination-top",
10995
+ "description": "If specified, render the pagination controls above the table instead of below.",
10996
+ "type": "boolean",
10997
+ "default": "false"
10998
+ },
10986
10999
  {
10987
11000
  "name": "perPage",
10988
11001
  "attribute": "per-page",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teipublisher/pb-components",
3
- "version": "3.0.9",
3
+ "version": "3.1.0",
4
4
  "description": "Collection of webcomponents underlying TEI Publisher",
5
5
  "repository": "https://github.com/eeditiones/tei-publisher-components.git",
6
6
  "main": "index.html",
package/pb-elements.json CHANGED
@@ -10909,6 +10909,12 @@
10909
10909
  "type": "boolean",
10910
10910
  "default": "false"
10911
10911
  },
10912
+ {
10913
+ "name": "pagination-top",
10914
+ "description": "If specified, render the pagination controls above the table instead of below.",
10915
+ "type": "boolean",
10916
+ "default": "false"
10917
+ },
10912
10918
  {
10913
10919
  "name": "per-page",
10914
10920
  "type": "number",
@@ -10983,6 +10989,13 @@
10983
10989
  "type": "boolean",
10984
10990
  "default": "false"
10985
10991
  },
10992
+ {
10993
+ "name": "paginationTop",
10994
+ "attribute": "pagination-top",
10995
+ "description": "If specified, render the pagination controls above the table instead of below.",
10996
+ "type": "boolean",
10997
+ "default": "false"
10998
+ },
10986
10999
  {
10987
11000
  "name": "perPage",
10988
11001
  "attribute": "per-page",
package/src/pb-page.js CHANGED
@@ -394,6 +394,10 @@ export class PbPage extends pbMixin(LitElement) {
394
394
  this._i18nInstance = i18next.createInstance();
395
395
  this._i18nInstance.use(LanguageDetector).use(Backend);
396
396
  this._i18nInstance.init(options).then(t => {
397
+ if (!this._i18nInstance) {
398
+ // We got deconstructed already
399
+ return;
400
+ }
397
401
  initTranslation(t);
398
402
  // initialized and ready to go!
399
403
  this._updateI18n(t);
@@ -1,6 +1,5 @@
1
1
  import { LitElement } from 'lit-element';
2
2
  import { html } from 'gridjs';
3
- import './pb-popover.js';
4
3
 
5
4
  /**
6
5
  * Defines a column within `pb-table-grid`.
@@ -1,14 +1,15 @@
1
1
  import { LitElement, html, css } from 'lit-element';
2
- import { Grid } from 'gridjs';
2
+ import { Grid, PluginPosition } from 'gridjs';
3
3
  import { pbMixin, waitOnce } from './pb-mixin.js';
4
4
  import { resolveURL } from './utils.js';
5
- import { loadStylesheets, importStyles } from './theming.js';
5
+ import { importStyles, loadStylesheets, themableMixin } from './theming.js';
6
6
  import '@polymer/paper-input/paper-input';
7
7
  import '@polymer/iron-icons';
8
8
  import '@polymer/iron-form';
9
9
  import '@polymer/paper-icon-button';
10
10
  import './pb-table-column.js';
11
11
  import { registry } from './urls.js';
12
+ import { translate } from './pb-i18n.js';
12
13
 
13
14
  /**
14
15
  * A table grid based on [gridjs](https://gridjs.io/), which loads its data from a server endpoint
@@ -39,7 +40,7 @@ import { registry } from './urls.js';
39
40
  * <pb-table-column label="Died" property="death"></pb-table-column>
40
41
  * ```
41
42
  */
42
- export class PbTableGrid extends pbMixin(LitElement) {
43
+ export class PbTableGrid extends themableMixin(pbMixin(LitElement)) {
43
44
  static get properties() {
44
45
  return {
45
46
  /**
@@ -78,6 +79,13 @@ export class PbTableGrid extends pbMixin(LitElement) {
78
79
  search: {
79
80
  type: Boolean,
80
81
  },
82
+ /**
83
+ * If specified, render the pagination controls above the table instead of below.
84
+ */
85
+ paginationTop: {
86
+ type: Boolean,
87
+ attribute: 'pagination-top',
88
+ },
81
89
  _params: {
82
90
  type: Object,
83
91
  },
@@ -91,6 +99,7 @@ export class PbTableGrid extends pbMixin(LitElement) {
91
99
  this._params = {};
92
100
  this.resizable = false;
93
101
  this.search = false;
102
+ this.paginationTop = false;
94
103
  this.perPage = 10;
95
104
  this.height = null;
96
105
  this.fixedHeader = false;
@@ -130,11 +139,15 @@ export class PbTableGrid extends pbMixin(LitElement) {
130
139
  }
131
140
 
132
141
  const gridjsTheme = await loadStylesheets([`${resolveURL(this.cssPath)}/mermaid.min.css`]);
133
- const theme = importStyles(this);
134
142
  const sheets = [...this.shadowRoot.adoptedStyleSheets, gridjsTheme];
143
+ // Manually import styles for backwards compatibility with pb-components < 3 importStyles
144
+ // extracts any relevant styling rules to this element and wraps them in `:host`. Which you can
145
+ // (and should) do manually anyway
146
+ const theme = importStyles(this);
135
147
  if (theme) {
136
148
  sheets.push(theme);
137
149
  }
150
+
138
151
  this.shadowRoot.adoptedStyleSheets = sheets;
139
152
  }
140
153
 
@@ -206,6 +219,9 @@ export class PbTableGrid extends pbMixin(LitElement) {
206
219
  };
207
220
 
208
221
  this.grid = new Grid(config);
222
+ if (this.paginationTop) {
223
+ this.grid.plugin.get('pagination').position = PluginPosition.Header;
224
+ }
209
225
  this.grid.on('load', () => {
210
226
  this.emitTo('pb-results-received', {
211
227
  params: this._params,
@@ -240,9 +256,9 @@ export class PbTableGrid extends pbMixin(LitElement) {
240
256
  <paper-input
241
257
  id="search"
242
258
  name="search"
243
- label="Search"
259
+ label="${translate('search.search')}"
244
260
  value="${this._params.search || ''}"
245
- @keyup="${e => (e.keyCode == 13 ? this._submit() : null)}"
261
+ @keyup="${e => (e.keyCode === 13 ? this._submit() : null)}"
246
262
  >
247
263
  <paper-icon-button
248
264
  icon="search"