@fluid-topics/ft-wc-utils 1.1.81 → 1.1.83

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.
@@ -0,0 +1,10 @@
1
+ import type { Moment } from "moment";
2
+ declare global {
3
+ interface Window {
4
+ moment?: Moment;
5
+ }
6
+ }
7
+ export declare class DateFormatter {
8
+ static format(date: string, locale: string, longDateFormat: boolean, dateTimeFormat: boolean): string;
9
+ private static getDateFormat;
10
+ }
@@ -0,0 +1,22 @@
1
+ export class DateFormatter {
2
+ static format(date, locale, longDateFormat, dateTimeFormat) {
3
+ if (!window.moment) {
4
+ return date;
5
+ }
6
+ return window.moment(date).locale(locale).format(this.getDateFormat(longDateFormat, dateTimeFormat));
7
+ }
8
+ static getDateFormat(longDateFormat, dateTimeFormat) {
9
+ if (longDateFormat) {
10
+ if (dateTimeFormat) {
11
+ return "lll";
12
+ }
13
+ return "ll";
14
+ }
15
+ else {
16
+ if (dateTimeFormat) {
17
+ return "L LT";
18
+ }
19
+ return "L";
20
+ }
21
+ }
22
+ }
@@ -7,13 +7,14 @@ export declare class FtLitElement extends ScopedRegistryLitElement {
7
7
  exportpartsPrefix?: string;
8
8
  exportpartsPrefixes?: string[];
9
9
  customStylesheet?: string;
10
- private adoptedCustomStyleSheet;
11
10
  private useAdoptedStyleSheets;
11
+ private adoptedCustomStyleSheet;
12
12
  private readonly [constructorPrototype];
13
13
  private readonly [constructorName];
14
14
  constructor();
15
15
  adoptedCallback(): void;
16
16
  connectedCallback(): void;
17
+ protected importDynamicDependencies(): void;
17
18
  protected updated(props: PropertyValues): void;
18
19
  protected contentAvailableCallback(props: PropertyValues): void;
19
20
  private applyCustomStylesheet;
@@ -5,7 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  var _a;
8
- import { property } from "lit/decorators.js";
8
+ import { property, state } from "lit/decorators.js";
9
9
  import { jsonProperty } from "./decorators";
10
10
  import { Debouncer } from "./Debouncer";
11
11
  import { ScopedRegistryLitElement } from "./ScopedRegistryLitElement";
@@ -15,8 +15,8 @@ const exportpartsDebouncer = Symbol("exportpartsDebouncer");
15
15
  export class FtLitElement extends ScopedRegistryLitElement {
16
16
  constructor() {
17
17
  super();
18
- this.adoptedCustomStyleSheet = new CSSStyleSheet();
19
18
  this.useAdoptedStyleSheets = true;
19
+ this.adoptedCustomStyleSheet = new CSSStyleSheet();
20
20
  this[_a] = new Debouncer(5);
21
21
  this[constructorName] = this.constructor.name;
22
22
  this[constructorPrototype] = this.constructor.prototype;
@@ -32,11 +32,15 @@ export class FtLitElement extends ScopedRegistryLitElement {
32
32
  if (this.shadowRoot && !this.shadowRoot.adoptedStyleSheets.includes(this.adoptedCustomStyleSheet)) {
33
33
  this.shadowRoot.adoptedStyleSheets = [...this.shadowRoot.adoptedStyleSheets, this.adoptedCustomStyleSheet];
34
34
  }
35
+ this.useAdoptedStyleSheets = true;
35
36
  }
36
37
  catch (e) {
37
38
  this.useAdoptedStyleSheets = false;
38
39
  console.error("Cannot use adopted stylesheets", e);
39
40
  }
41
+ this.importDynamicDependencies();
42
+ }
43
+ importDynamicDependencies() {
40
44
  }
41
45
  updated(props) {
42
46
  super.updated(props);
@@ -50,18 +54,19 @@ export class FtLitElement extends ScopedRegistryLitElement {
50
54
  }
51
55
  applyCustomStylesheet(props) {
52
56
  var _b, _c, _d;
57
+ ((_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());
53
58
  if (this.useAdoptedStyleSheets) {
54
59
  if (props.has("customStylesheet")) {
55
60
  try {
56
- this.adoptedCustomStyleSheet.replaceSync((_b = this.customStylesheet) !== null && _b !== void 0 ? _b : "");
61
+ this.adoptedCustomStyleSheet.replaceSync((_d = this.customStylesheet) !== null && _d !== void 0 ? _d : "");
57
62
  }
58
63
  catch (e) {
59
64
  console.error(e, this.customStylesheet);
65
+ this.useAdoptedStyleSheets = false;
60
66
  }
61
67
  }
62
68
  }
63
69
  else {
64
- ((_d = (_c = this.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelectorAll(".ft-lit-element--custom-stylesheet")) !== null && _d !== void 0 ? _d : []).forEach(e => e.remove());
65
70
  if (this.customStylesheet) {
66
71
  const customStyles = document.createElement("style");
67
72
  customStyles.classList.add("ft-lit-element--custom-stylesheet");
@@ -118,3 +123,6 @@ __decorate([
118
123
  __decorate([
119
124
  property()
120
125
  ], FtLitElement.prototype, "customStylesheet", void 0);
126
+ __decorate([
127
+ state()
128
+ ], FtLitElement.prototype, "useAdoptedStyleSheets", void 0);
@@ -1,5 +1,5 @@
1
1
  import { property } from "lit/decorators.js";
2
- import { deepEqual } from "./helpers";
2
+ import { hasChanged } from "./helpers";
3
3
  export const customElement = (tagName) => (clazz) => {
4
4
  if (!window.customElements.get(tagName)) {
5
5
  window.customElements.define(tagName, clazz);
@@ -25,7 +25,7 @@ export function jsonProperty(defaultValue, options) {
25
25
  return JSON.stringify(value);
26
26
  }
27
27
  },
28
- hasChanged: (a, b) => !deepEqual(a, b),
28
+ hasChanged,
29
29
  ...(options !== null && options !== void 0 ? options : {})
30
30
  });
31
31
  }