@fluid-topics/ft-app-context 1.4.4 → 2.0.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.
package/build/index.js CHANGED
@@ -1,5 +1,3 @@
1
- import { customElement } from "@fluid-topics/ft-wc-utils";
2
- import { FtAppContext } from "./ft-app-context";
3
1
  export * from "./mixins/withDateFormat";
4
2
  export * from "./redux-stores/FtAppInfoStore";
5
3
  export * from "./redux-stores/FtUserAssetsStore";
@@ -8,4 +6,3 @@ export * from "./services";
8
6
  export * from "./ft-app-context.styles";
9
7
  export * from "./ft-app-context.properties";
10
8
  export * from "./ft-app-context";
11
- customElement("ft-app-context")(FtAppContext);
@@ -1,3 +1,4 @@
1
+ import { Optional } from "@fluid-topics/ft-wc-utils";
1
2
  declare global {
2
3
  interface Window {
3
4
  FluidTopicsDateService: DateService;
@@ -10,6 +11,6 @@ interface DateServiceFormatOptions {
10
11
  }
11
12
  export declare class DateService {
12
13
  isDate(metadataKey: string): boolean;
13
- format(date: string | Date, options?: DateServiceFormatOptions): string;
14
+ format(date: Optional<string | Date>, options?: DateServiceFormatOptions): string;
14
15
  }
15
16
  export {};
@@ -1,14 +1,23 @@
1
- import { DateFormatter } from "@fluid-topics/ft-wc-utils";
1
+ import { DateFormatter, } from "@fluid-topics/ft-wc-utils";
2
2
  import { ftAppInfoStore } from "../redux-stores/FtAppInfoStore";
3
3
  export class DateService {
4
4
  isDate(metadataKey) {
5
5
  var _a, _b, _c, _d;
6
6
  const descriptors = (_b = (_a = ftAppInfoStore.getState().metadataConfiguration) === null || _a === void 0 ? void 0 : _a.descriptors) !== null && _b !== void 0 ? _b : [];
7
- return (_d = (_c = descriptors.find(descriptor => descriptor.key === metadataKey)) === null || _c === void 0 ? void 0 : _c.date) !== null && _d !== void 0 ? _d : false;
7
+ return (_d = (_c = descriptors.find((descriptor) => descriptor.key === metadataKey)) === null || _c === void 0 ? void 0 : _c.date) !== null && _d !== void 0 ? _d : false;
8
8
  }
9
9
  format(date, options) {
10
10
  var _a, _b, _c;
11
- return DateFormatter.format(date, (_a = options === null || options === void 0 ? void 0 : options.locale) !== null && _a !== void 0 ? _a : ftAppInfoStore.getState().uiLocale, (_b = options === null || options === void 0 ? void 0 : options.longFormat) !== null && _b !== void 0 ? _b : false, (_c = options === null || options === void 0 ? void 0 : options.withTime) !== null && _c !== void 0 ? _c : false);
11
+ if (date == undefined) {
12
+ return "";
13
+ }
14
+ try {
15
+ return DateFormatter.format(date, (_a = options === null || options === void 0 ? void 0 : options.locale) !== null && _a !== void 0 ? _a : ftAppInfoStore.getState().uiLocale, (_b = options === null || options === void 0 ? void 0 : options.longFormat) !== null && _b !== void 0 ? _b : false, (_c = options === null || options === void 0 ? void 0 : options.withTime) !== null && _c !== void 0 ? _c : false);
16
+ }
17
+ catch (e) {
18
+ console.error(`Date ${JSON.stringify(date)} is not valid`, e);
19
+ throw e;
20
+ }
12
21
  }
13
22
  }
14
23
  window.FluidTopicsDateService = new DateService();
package/package.json CHANGED
@@ -1,29 +1,29 @@
1
1
  {
2
- "name": "@fluid-topics/ft-app-context",
3
- "version": "1.4.4",
4
- "description": "Global application context for Fluid Topics integrations",
5
- "keywords": [
6
- "Lit"
7
- ],
8
- "author": "Fluid Topics <devtopics@antidot.net>",
9
- "license": "ISC",
10
- "main": "build/index.js",
11
- "web": "build/ft-app-context.min.js",
12
- "typings": "build/index",
13
- "files": [
14
- "build/**/*.js",
15
- "build/**/*.ts"
16
- ],
17
- "repository": {
18
- "type": "git",
19
- "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
- },
21
- "dependencies": {
22
- "@fluid-topics/ft-wc-utils": "1.4.4",
23
- "lit": "3.1.0"
24
- },
25
- "devDependencies": {
26
- "@fluid-topics/public-api": "1.0.114"
27
- },
28
- "gitHead": "fdd626e6a7b6cfef613b7060c1ac2ece1073a1da"
2
+ "name": "@fluid-topics/ft-app-context",
3
+ "version": "2.0.0",
4
+ "description": "Global application context for Fluid Topics integrations",
5
+ "keywords": [
6
+ "Lit"
7
+ ],
8
+ "author": "Fluid Topics <devtopics@antidot.net>",
9
+ "license": "ISC",
10
+ "main": "build/index.js",
11
+ "web": "build/ft-app-context.min.js",
12
+ "typings": "build/index",
13
+ "files": [
14
+ "build/**/*.js",
15
+ "build/**/*.ts"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
+ },
21
+ "dependencies": {
22
+ "@fluid-topics/ft-wc-utils": "2.0.0",
23
+ "lit": "3.1.0"
24
+ },
25
+ "devDependencies": {
26
+ "@fluid-topics/public-api": "1.0.114"
27
+ },
28
+ "gitHead": "139801842483cdd25e6c0d850431dfb2b930f394"
29
29
  }