@openfin/ui-library 0.1.16 → 0.1.17-alpha.1622747411

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.
@@ -18,8 +18,8 @@ export declare const Color: {
18
18
  readonly darkGray1: "#53565F";
19
19
  readonly darkGray2: "#383A40";
20
20
  readonly darkGray3: "#24262B";
21
- readonly darkGray4: "#24262B";
22
- readonly darkGray5: "#1E1F23";
21
+ readonly darkGray4: "#1E1F23";
22
+ readonly darkGray5: "#111214";
23
23
  readonly openFinDarkest: "#3D39CD";
24
24
  readonly openFinDarker: "#4642E0";
25
25
  readonly openFin: "#504CFF";
@@ -42,8 +42,8 @@ exports.Color = {
42
42
  darkGray1: '#53565F',
43
43
  darkGray2: '#383A40',
44
44
  darkGray3: '#24262B',
45
- darkGray4: '#24262B',
46
- darkGray5: '#1E1F23',
45
+ darkGray4: '#1E1F23',
46
+ darkGray5: '#111214',
47
47
  openFinDarkest: '#3D39CD',
48
48
  openFinDarker: '#4642E0',
49
49
  openFin: '#504CFF',
package/dist/index.d.ts CHANGED
@@ -16,3 +16,4 @@ export * from './hooks/useColorScheme';
16
16
  export * from './hooks/useMediaQuery';
17
17
  export * from './hooks/usePrevious';
18
18
  export * as StoryHelpers from './storybookHelpers';
19
+ export * from './lib/whenFin';
package/dist/index.js CHANGED
@@ -41,3 +41,4 @@ __exportStar(require("./hooks/useColorScheme"), exports);
41
41
  __exportStar(require("./hooks/useMediaQuery"), exports);
42
42
  __exportStar(require("./hooks/usePrevious"), exports);
43
43
  exports.StoryHelpers = __importStar(require("./storybookHelpers"));
44
+ __exportStar(require("./lib/whenFin"), exports);
@@ -0,0 +1,6 @@
1
+ /**
2
+ * OpenFin/Non-OpenFin context expression switch.
3
+ * @param finValue Expression invoked/returned when running in the fin environment.
4
+ * @param noFinValue Expression invoked/returned when not running in the fin environment.
5
+ */
6
+ export declare function whenFin<F, N = undefined>(finValue: (() => F) | F, noFinValue?: (() => N) | N): F | N | undefined;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.whenFin = void 0;
4
+ /**
5
+ * OpenFin/Non-OpenFin context expression switch.
6
+ * @param finValue Expression invoked/returned when running in the fin environment.
7
+ * @param noFinValue Expression invoked/returned when not running in the fin environment.
8
+ */
9
+ function whenFin(finValue, noFinValue) {
10
+ const expression = typeof fin !== 'undefined' ? finValue : noFinValue;
11
+ return typeof expression === 'function' ? expression() : expression;
12
+ }
13
+ exports.whenFin = whenFin;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const whenFin_1 = require("./whenFin");
4
+ describe('whenFin', () => {
5
+ afterEach(() => {
6
+ delete global.fin;
7
+ });
8
+ describe('When `fin` is present', () => {
9
+ beforeEach(() => {
10
+ global.fin = {};
11
+ });
12
+ test('And a function provided the function is invoked', () => {
13
+ let value = 0;
14
+ whenFin_1.whenFin(() => {
15
+ value = 1;
16
+ });
17
+ expect(value).toEqual(1);
18
+ });
19
+ test('And a value provided the value is returned', () => {
20
+ const value = whenFin_1.whenFin(1, undefined);
21
+ expect(value).toEqual(1);
22
+ });
23
+ });
24
+ describe('When `fin` is not present', () => {
25
+ test('And a function provided the function is invoked', () => {
26
+ let value = 0;
27
+ whenFin_1.whenFin(() => {
28
+ value = 0;
29
+ }, () => {
30
+ value = 1;
31
+ });
32
+ expect(value).toEqual(1);
33
+ });
34
+ test('And a value provided the value is returned', () => {
35
+ const value = whenFin_1.whenFin(undefined, 1);
36
+ expect(value).toEqual(1);
37
+ });
38
+ });
39
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openfin/ui-library",
3
3
  "description": "OpenFin UI Component Library",
4
- "version": "0.1.16",
4
+ "version": "0.1.17-alpha.1622747411",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "repository": "github:openfin/ui-library",