fontdue-js 2.8.1 → 2.8.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 2.8.2
2
+
3
+ - Fixed hydration issue with the test mode banner
4
+
5
+ ## 2.8.1
6
+
7
+ - Fixed broken build
8
+
1
9
  ## 2.8.0
2
10
 
3
11
  - Adds support for new "limit licenses" option on collections
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @generated SignedSource<<f6cfa46ddcfb4ef0838d894753924f32>>
2
+ * @generated SignedSource<<ffdc64bc9c520bed1ab130ee6260cba2>>
3
3
  * @lightSyntaxTransform
4
4
  * @nogrep
5
5
  */
@@ -7,12 +7,8 @@ import { ConcreteRequest } from 'relay-runtime';
7
7
  export type TestModeBannerQuery$variables = Record<PropertyKey, never>;
8
8
  export type TestModeBannerQuery$data = {
9
9
  readonly viewer: {
10
- readonly adminUser: {
11
- readonly name: string | null;
12
- } | null;
13
10
  readonly testMode: {
14
11
  readonly isActive: boolean;
15
- readonly switchUrl: string;
16
12
  };
17
13
  };
18
14
  };
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  /**
8
- * @generated SignedSource<<f6cfa46ddcfb4ef0838d894753924f32>>
8
+ * @generated SignedSource<<ffdc64bc9c520bed1ab130ee6260cba2>>
9
9
  * @lightSyntaxTransform
10
10
  * @nogrep
11
11
  */
@@ -16,43 +16,21 @@ exports.default = void 0;
16
16
 
17
17
  const node = function () {
18
18
  var v0 = {
19
+ "alias": null,
20
+ "args": null,
21
+ "concreteType": "TestMode",
22
+ "kind": "LinkedField",
23
+ "name": "testMode",
24
+ "plural": false,
25
+ "selections": [{
19
26
  "alias": null,
20
27
  "args": null,
21
- "concreteType": "TestMode",
22
- "kind": "LinkedField",
23
- "name": "testMode",
24
- "plural": false,
25
- "selections": [{
26
- "alias": null,
27
- "args": null,
28
- "kind": "ScalarField",
29
- "name": "isActive",
30
- "storageKey": null
31
- }, {
32
- "alias": null,
33
- "args": null,
34
- "kind": "ScalarField",
35
- "name": "switchUrl",
36
- "storageKey": null
37
- }],
38
- "storageKey": null
39
- },
40
- v1 = {
41
- "alias": null,
42
- "args": null,
43
- "concreteType": "User",
44
- "kind": "LinkedField",
45
- "name": "adminUser",
46
- "plural": false,
47
- "selections": [{
48
- "alias": null,
49
- "args": null,
50
- "kind": "ScalarField",
51
- "name": "name",
52
- "storageKey": null
53
- }],
28
+ "kind": "ScalarField",
29
+ "name": "isActive",
54
30
  "storageKey": null
55
- };
31
+ }],
32
+ "storageKey": null
33
+ };
56
34
  return {
57
35
  "fragment": {
58
36
  "argumentDefinitions": [],
@@ -66,7 +44,7 @@ const node = function () {
66
44
  "kind": "LinkedField",
67
45
  "name": "viewer",
68
46
  "plural": false,
69
- "selections": [v0 /*: any*/, v1 /*: any*/],
47
+ "selections": [v0 /*: any*/],
70
48
  "storageKey": null
71
49
  }],
72
50
  "type": "RootQueryType",
@@ -84,7 +62,7 @@ const node = function () {
84
62
  "kind": "LinkedField",
85
63
  "name": "viewer",
86
64
  "plural": false,
87
- "selections": [v0 /*: any*/, v1 /*: any*/, {
65
+ "selections": [v0 /*: any*/, {
88
66
  "alias": null,
89
67
  "args": null,
90
68
  "kind": "ScalarField",
@@ -95,15 +73,15 @@ const node = function () {
95
73
  }]
96
74
  },
97
75
  "params": {
98
- "cacheID": "734dcbb0302bfd117e64314cb94029d8",
76
+ "cacheID": "2cb9255aeee9b1b3edd823ee2f62d8cc",
99
77
  "id": null,
100
78
  "metadata": {},
101
79
  "name": "TestModeBannerQuery",
102
80
  "operationKind": "query",
103
- "text": "query TestModeBannerQuery {\n viewer {\n testMode {\n isActive\n switchUrl\n }\n adminUser {\n name\n }\n id\n }\n}\n"
81
+ "text": "query TestModeBannerQuery {\n viewer {\n testMode {\n isActive\n }\n id\n }\n}\n"
104
82
  }
105
83
  };
106
84
  }();
107
- node.hash = "82e974c3c8bdef284e02f896ed1680c1";
85
+ node.hash = "60ad67ee88ec6b74dd04bdf5572e7faf";
108
86
  var _default = node;
109
87
  exports.default = _default;
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import { VariableSettings } from '../../utils';
3
+ interface StyleSelect_props {
4
+ collections: {
5
+ name: string;
6
+ isVariableFont: boolean;
7
+ fontStyles: readonly {
8
+ id: string;
9
+ name: string;
10
+ variableInstances: readonly {
11
+ name: string;
12
+ coordinates: readonly {
13
+ axis: string;
14
+ value: number;
15
+ }[];
16
+ }[] | null;
17
+ }[] | null;
18
+ }[];
19
+ value: {
20
+ fontStyleId: string | null;
21
+ variableSettings?: VariableSettings;
22
+ };
23
+ onChange: (value: {
24
+ fontStyleId: string;
25
+ variableSettings?: VariableSettings;
26
+ }) => void;
27
+ }
28
+ export default function StyleSelect({ collections, value, onChange }: StyleSelect_props): React.JSX.Element;
29
+ export {};
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = StyleSelect;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _Select = _interopRequireDefault(require("../Select"));
9
+ var _utils = require("../../utils");
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ function StyleSelect(_ref) {
12
+ let {
13
+ collections,
14
+ value,
15
+ onChange
16
+ } = _ref;
17
+ const handleChange = e => {
18
+ const value = e.target.value;
19
+ if (value.includes(':::')) {
20
+ var _fontStyle$variableIn;
21
+ const [fontStyleId, variableInstanceName] = value.split(':::');
22
+ const fontStyle = collections.flatMap(coll => coll.fontStyles).find(style => style.id === fontStyleId);
23
+ const instance = fontStyle === null || fontStyle === void 0 ? void 0 : (_fontStyle$variableIn = fontStyle.variableInstances) === null || _fontStyle$variableIn === void 0 ? void 0 : _fontStyle$variableIn.find(_ref2 => {
24
+ let {
25
+ name
26
+ } = _ref2;
27
+ return name === variableInstanceName;
28
+ });
29
+ let variableSettings;
30
+ if (instance) variableSettings = (0, _utils.variableInstanceSettings)(instance);
31
+ onChange({
32
+ fontStyleId,
33
+ variableSettings
34
+ });
35
+ } else {
36
+ onChange({
37
+ fontStyleId: value
38
+ });
39
+ }
40
+ };
41
+ let selectValue = value.fontStyleId;
42
+ if (value.variableSettings) {
43
+ var _fontStyle$variableIn2;
44
+ const fontStyle = collections.flatMap(coll => coll.fontStyles).find(style => style.id === value.fontStyleId);
45
+ const instance = fontStyle === null || fontStyle === void 0 ? void 0 : (_fontStyle$variableIn2 = fontStyle.variableInstances) === null || _fontStyle$variableIn2 === void 0 ? void 0 : _fontStyle$variableIn2.find(instance => (0, _utils.compareVariableSettings)(instance, value.variableSettings));
46
+ if (instance) {
47
+ selectValue = `${value.fontStyleId}:::${instance.name}`;
48
+ }
49
+ }
50
+ return /*#__PURE__*/_react.default.createElement(_Select.default, {
51
+ options: collections.flatMap(coll => {
52
+ var _coll$fontStyles2;
53
+ if (coll.isVariableFont) {
54
+ var _coll$fontStyles;
55
+ return ((_coll$fontStyles = coll.fontStyles) === null || _coll$fontStyles === void 0 ? void 0 : _coll$fontStyles.flatMap(style => {
56
+ var _style$variableInstan;
57
+ return (_style$variableInstan = style.variableInstances) === null || _style$variableInstan === void 0 ? void 0 : _style$variableInstan.map(instance => ({
58
+ value: `${style.id}:::${instance.name}`,
59
+ text: `${coll.name} ${instance.name}`
60
+ })).filter(_utils.notEmpty);
61
+ }).filter(_utils.notEmpty)) ?? [];
62
+ }
63
+ return ((_coll$fontStyles2 = coll.fontStyles) === null || _coll$fontStyles2 === void 0 ? void 0 : _coll$fontStyles2.map(style => ({
64
+ value: style.id,
65
+ text: `${coll.name} ${style.name}`
66
+ })).filter(_utils.notEmpty)) ?? [];
67
+ }),
68
+ value: selectValue,
69
+ onChange: handleChange
70
+ });
71
+ }
@@ -12,8 +12,8 @@ Object.defineProperty(exports, "FontdueProvider_props", {
12
12
  exports.default = FontdueProvider;
13
13
  var _react = _interopRequireDefault(require("react"));
14
14
  var _Stylesheet = require("../Stylesheet");
15
- var _index = _interopRequireDefault(require("../TestModeBanner/index.server"));
16
- var _index2 = _interopRequireDefault(require("../ThemeConfig/index.server"));
15
+ var _TestModeBanner = _interopRequireDefault(require("../TestModeBanner"));
16
+ var _index = _interopRequireDefault(require("../ThemeConfig/index.server"));
17
17
  var _FontdueProviderClientComponent = _interopRequireWildcard(require("./FontdueProviderClientComponent"));
18
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
19
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -23,5 +23,5 @@ async function FontdueProvider(_ref) {
23
23
  children,
24
24
  ...rest
25
25
  } = _ref;
26
- return /*#__PURE__*/_react.default.createElement(_FontdueProviderClientComponent.default, rest, /*#__PURE__*/_react.default.createElement(_Stylesheet.StylesheetContainer, null), /*#__PURE__*/_react.default.createElement(_index.default, null), /*#__PURE__*/_react.default.createElement(_index2.default, null), children);
26
+ return /*#__PURE__*/_react.default.createElement(_FontdueProviderClientComponent.default, rest, /*#__PURE__*/_react.default.createElement(_Stylesheet.StylesheetContainer, null), /*#__PURE__*/_react.default.createElement(_TestModeBanner.default, null), /*#__PURE__*/_react.default.createElement(_index.default, null), children);
27
27
  }
@@ -0,0 +1 @@
1
+ export default function Switch(): void;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = Switch;
7
+ function Switch() {}
@@ -1,7 +1,2 @@
1
1
  import React from 'react';
2
- import { TestModeBannerQuery } from '../../__generated__/TestModeBannerQuery.graphql';
3
- import { SerializablePreloadedQuery } from '../../relay/loadSerializableQuery';
4
- export declare function TestModeBannerPreloadedQueryRenderer({ preloadedQuery, }: {
5
- preloadedQuery: SerializablePreloadedQuery<TestModeBannerQuery>;
6
- }): React.JSX.Element;
7
2
  export default function TestModeBanner(): React.JSX.Element;
@@ -4,30 +4,21 @@
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.TestModeBannerPreloadedQueryRenderer = TestModeBannerPreloadedQueryRenderer;
8
7
  exports.default = TestModeBanner;
9
8
  var _TestModeBannerQuery2 = _interopRequireDefault(require("../../__generated__/TestModeBannerQuery.graphql"));
10
9
  var _react = _interopRequireDefault(require("react"));
11
10
  var _reactRelay = require("react-relay");
12
- var _useSerializablePreloadedQuery = _interopRequireDefault(require("../../relay/useSerializablePreloadedQuery"));
13
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
- const getSwitchable = switchUrl => new URL(switchUrl).hostname === location.hostname;
15
12
  function TestModeBannerComponent(_ref) {
16
- var _data$viewer;
17
13
  let {
18
14
  data
19
15
  } = _ref;
20
- if (!((_data$viewer = data.viewer) !== null && _data$viewer !== void 0 && _data$viewer.adminUser)) return null;
21
16
  const {
22
- isActive,
23
- switchUrl
17
+ isActive
24
18
  } = data.viewer.testMode;
25
- const switchable = getSwitchable(switchUrl);
26
19
 
27
- // current host !== the tenant switchUrl implies that this site is running
28
- // as a 'standalone' app. we don't know the location of the test app, so this
29
- // link doesn't work. let's hide the banner completely if we're in live mode
30
- if (!isActive && !switchable) return null;
20
+ // hide the banner completely if we're in live mode
21
+ if (!isActive) return null;
31
22
  return /*#__PURE__*/_react.default.createElement("div", {
32
23
  className: "test-mode-banner__banner",
33
24
  "data-test-mode": isActive
@@ -35,23 +26,9 @@ function TestModeBannerComponent(_ref) {
35
26
  className: "test-mode-banner__content"
36
27
  }, /*#__PURE__*/_react.default.createElement("div", {
37
28
  className: "test-mode-banner__title"
38
- }, "Viewing ", isActive ? 'test data' : 'live data'), /*#__PURE__*/_react.default.createElement("div", {
39
- className: "test-mode-banner__rest"
40
- }, switchable && /*#__PURE__*/_react.default.createElement("a", {
41
- href: switchUrl
42
- }, "Switch to ", isActive ? 'live' : 'test', " data"))));
43
- }
44
- const query = (_TestModeBannerQuery2.default.hash && _TestModeBannerQuery2.default.hash !== "82e974c3c8bdef284e02f896ed1680c1" && console.error("The definition of 'TestModeBannerQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _TestModeBannerQuery2.default);
45
- function TestModeBannerPreloadedQueryRenderer(_ref2) {
46
- let {
47
- preloadedQuery
48
- } = _ref2;
49
- const queryRef = (0, _useSerializablePreloadedQuery.default)(preloadedQuery);
50
- const data = (0, _reactRelay.usePreloadedQuery)(query, queryRef);
51
- return /*#__PURE__*/_react.default.createElement(TestModeBannerComponent, {
52
- data: data
53
- });
29
+ }, "Viewing test data")));
54
30
  }
31
+ const query = (_TestModeBannerQuery2.default.hash && _TestModeBannerQuery2.default.hash !== "60ad67ee88ec6b74dd04bdf5572e7faf" && console.error("The definition of 'TestModeBannerQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _TestModeBannerQuery2.default);
55
32
  function TestModeBanner() {
56
33
  const data = (0, _reactRelay.useLazyLoadQuery)(query, {});
57
34
  return /*#__PURE__*/_react.default.createElement(TestModeBannerComponent, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fontdue-js",
3
- "version": "2.8.1",
3
+ "version": "2.8.2",
4
4
  "scripts": {
5
5
  "build": "npm run relay && run-p build-js build-css build-ts-declarations",
6
6
  "build-js": "babel src --out-dir dist --extensions .ts,.tsx,.js,.jsx",