@fluid-topics/ft-wc-utils 1.1.50 → 1.1.52

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.
@@ -4,16 +4,17 @@ declare const constructorPrototype: unique symbol;
4
4
  declare const constructorName: unique symbol;
5
5
  declare const exportpartsDebouncer: unique symbol;
6
6
  export declare class FtLitElement extends ScopedRegistryLitElement {
7
+ exportpartsPrefix?: string;
8
+ exportpartsPrefixes?: string[];
9
+ customStylesheet?: string;
10
+ private adoptedCustomStyleSheet;
7
11
  private readonly [constructorPrototype];
8
12
  private readonly [constructorName];
9
13
  constructor();
10
14
  adoptedCallback(): void;
11
- exportpartsPrefix?: string;
12
- exportpartsPrefixes?: string[];
13
- customStylesheet?: string;
15
+ connectedCallback(): void;
14
16
  protected updated(props: PropertyValues): void;
15
17
  protected contentAvailableCallback(props: PropertyValues): void;
16
- private insertCustomStylesheet;
17
18
  private [exportpartsDebouncer];
18
19
  private scheduleExportpartsUpdate;
19
20
  private setExportpartsAttribute;
@@ -15,6 +15,7 @@ const exportpartsDebouncer = Symbol("exportpartsDebouncer");
15
15
  export class FtLitElement extends ScopedRegistryLitElement {
16
16
  constructor() {
17
17
  super();
18
+ this.adoptedCustomStyleSheet = new CSSStyleSheet();
18
19
  this[_a] = new Debouncer(5);
19
20
  this[constructorName] = this.constructor.name;
20
21
  this[constructorPrototype] = this.constructor.prototype;
@@ -24,26 +25,25 @@ export class FtLitElement extends ScopedRegistryLitElement {
24
25
  Object.setPrototypeOf(this, this[constructorPrototype]);
25
26
  }
26
27
  }
28
+ connectedCallback() {
29
+ super.connectedCallback();
30
+ if (this.shadowRoot && !this.shadowRoot.adoptedStyleSheets.includes(this.adoptedCustomStyleSheet)) {
31
+ this.shadowRoot.adoptedStyleSheets = [...this.shadowRoot.adoptedStyleSheets, this.adoptedCustomStyleSheet];
32
+ }
33
+ }
27
34
  updated(props) {
35
+ var _b;
28
36
  super.updated(props);
37
+ if (props.has("customStylesheet")) {
38
+ this.adoptedCustomStyleSheet.replace((_b = this.customStylesheet) !== null && _b !== void 0 ? _b : "");
39
+ }
29
40
  this.updateComplete.then(() => {
30
41
  this.contentAvailableCallback(props);
31
- this.insertCustomStylesheet();
32
42
  this.scheduleExportpartsUpdate();
33
43
  });
34
44
  }
35
45
  contentAvailableCallback(props) {
36
46
  }
37
- insertCustomStylesheet() {
38
- var _b, _c;
39
- ((_c = (_b = this.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelectorAll(".ft-lit-element--custom-stylesheet")) !== null && _c !== void 0 ? _c : []).forEach(e => e.remove());
40
- if (this.customStylesheet) {
41
- const customStyles = document.createElement("style");
42
- customStyles.classList.add("ft-lit-element--custom-stylesheet");
43
- customStyles.innerHTML = this.customStylesheet;
44
- this.shadowRoot.append(customStyles);
45
- }
46
- }
47
47
  scheduleExportpartsUpdate() {
48
48
  var _b, _c, _d;
49
49
  if (((_b = this.exportpartsPrefix) === null || _b === void 0 ? void 0 : _b.trim()) || ((_d = (_c = this.exportpartsPrefixes) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0 > 0)) {
package/build/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import "./silent-define";
2
+ import "construct-style-sheets-polyfill";
2
3
  declare global {
3
4
  interface Window {
4
5
  safari?: {
package/build/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  var _a, _b, _c, _d;
2
2
  import "./silent-define";
3
+ import "construct-style-sheets-polyfill";
3
4
  import * as lit from "lit";
4
5
  import * as litDecorators from "lit/decorators.js";
5
6
  import * as litRepeat from "lit/directives/repeat.js";
@@ -2,12 +2,28 @@ function quote(value) {
2
2
  return `"${value}"`;
3
3
  }
4
4
  export function serializeRequest(baseUrl, request) {
5
- var _a;
5
+ var _a, _b, _c, _d;
6
6
  const params = new URLSearchParams({
7
7
  "content-lang": (_a = request.contentLocale) !== null && _a !== void 0 ? _a : "all",
8
- "query": request.query
9
8
  });
10
- if (request.filters.length > 0) {
9
+ if (((_b = request.query) === null || _b === void 0 ? void 0 : _b.length) > 0) {
10
+ params.append("query", request.query);
11
+ }
12
+ if (request.scope && request.scope !== "DEFAULT") {
13
+ params.append("scope", request.scope.toLowerCase());
14
+ }
15
+ if (request.virtualField) {
16
+ params.append("virtual-field", request.virtualField.toLowerCase());
17
+ }
18
+ if (request.periodFilter) {
19
+ let period = request.periodFilter.period;
20
+ const periodStr = period ? `_${period.from}_${period.to}` : "";
21
+ params.append("period", request.periodFilter.periodType.toLowerCase() + periodStr);
22
+ }
23
+ if (((_c = request.sort) === null || _c === void 0 ? void 0 : _c.length) > 0 && request.sort[0].key === "ft:lastEdition") {
24
+ params.append("sort", "last_update");
25
+ }
26
+ if (((_d = request.filters) === null || _d === void 0 ? void 0 : _d.length) > 0) {
11
27
  const filters = request.filters.map(filter => {
12
28
  const values = filter.values
13
29
  .map(value => value.replace(/_/g, "\\\\\\\\_")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-wc-utils",
3
- "version": "1.1.50",
3
+ "version": "1.1.52",
4
4
  "description": "Internal web components tools",
5
5
  "author": "Fluid Topics <devtopics@antidot.net>",
6
6
  "license": "ISC",
@@ -20,8 +20,9 @@
20
20
  "@types/mark.js": "8.11.12",
21
21
  "@webcomponents/scoped-custom-element-registry": "0.0.9",
22
22
  "composed-offset-position": "^0.0.4",
23
+ "construct-style-sheets-polyfill": "3.1.0",
23
24
  "lit": "3.1.0",
24
25
  "mark.js": "8.11.1"
25
26
  },
26
- "gitHead": "d7ba5acbdff08358500d0c3eec6c95bd9d406cb2"
27
+ "gitHead": "8b2c90df3e7d82be373f6e963272a37ebf57b017"
27
28
  }