pds-dev-kit-web-test 0.2.41 → 0.2.43

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.
Files changed (50) hide show
  1. package/dist/src/sub/DynamicLayout/sectionActionTypes.d.ts +0 -4
  2. package/dist/src/sub/DynamicLayout/sections/CustomSection/CustomSection.js +0 -18
  3. package/dist/src/sub/GoogleFontkit/GoogleFontApplyExample.d.ts +3 -0
  4. package/dist/src/sub/GoogleFontkit/GoogleFontApplyExample.js +93 -0
  5. package/dist/src/sub/GoogleFontkit/GoogleFontsListExample.d.ts +3 -0
  6. package/dist/src/sub/GoogleFontkit/GoogleFontsListExample.js +57 -0
  7. package/dist/src/sub/GoogleFontkit/api/getGoogleFontCss.d.ts +10 -0
  8. package/dist/src/sub/GoogleFontkit/api/getGoogleFontCss.js +53 -0
  9. package/dist/src/sub/GoogleFontkit/api/getGoogleFontDefaultText.d.ts +2 -0
  10. package/dist/src/sub/GoogleFontkit/api/getGoogleFontDefaultText.js +55 -0
  11. package/dist/src/sub/GoogleFontkit/api/getGoogleWebFonts.d.ts +10 -0
  12. package/dist/src/sub/GoogleFontkit/api/getGoogleWebFonts.js +53 -0
  13. package/dist/src/sub/GoogleFontkit/constants.d.ts +7 -0
  14. package/dist/src/sub/GoogleFontkit/constants.js +42 -0
  15. package/dist/src/sub/GoogleFontkit/headless/GoogleFontItem.d.ts +14 -0
  16. package/dist/src/sub/GoogleFontkit/headless/GoogleFontItem.js +129 -0
  17. package/dist/src/sub/GoogleFontkit/headless/GoogleFontsList.d.ts +17 -0
  18. package/dist/src/sub/GoogleFontkit/headless/GoogleFontsList.js +145 -0
  19. package/dist/src/sub/GoogleFontkit/hooks/useDebounce.d.ts +1 -0
  20. package/dist/src/sub/GoogleFontkit/hooks/useDebounce.js +14 -0
  21. package/dist/src/sub/GoogleFontkit/hooks/useIntersectionObserver.d.ts +6 -0
  22. package/dist/src/sub/GoogleFontkit/hooks/useIntersectionObserver.js +29 -0
  23. package/dist/src/sub/GoogleFontkit/index.d.ts +7 -0
  24. package/dist/src/sub/GoogleFontkit/index.js +32 -0
  25. package/dist/src/sub/GoogleFontkit/types.d.ts +44 -0
  26. package/dist/src/sub/GoogleFontkit/types.js +14 -0
  27. package/dist/src/sub/GoogleFontkit/utils/applyActiveFont.d.ts +5 -0
  28. package/dist/src/sub/GoogleFontkit/utils/applyActiveFont.js +15 -0
  29. package/dist/src/sub/GoogleFontkit/utils/callGoogleFontCSSAndApply.d.ts +2 -0
  30. package/dist/src/sub/GoogleFontkit/utils/callGoogleFontCSSAndApply.js +83 -0
  31. package/dist/src/sub/GoogleFontkit/utils/createStyleSheet.d.ts +4 -0
  32. package/dist/src/sub/GoogleFontkit/utils/createStyleSheet.js +13 -0
  33. package/dist/src/sub/GoogleFontkit/utils/extractFontStyles.d.ts +1 -0
  34. package/dist/src/sub/GoogleFontkit/utils/extractFontStyles.js +26 -0
  35. package/dist/src/sub/GoogleFontkit/utils/fillStyleSheet.d.ts +4 -0
  36. package/dist/src/sub/GoogleFontkit/utils/fillStyleSheet.js +17 -0
  37. package/dist/src/sub/GoogleFontkit/utils/getActiveFontStylesheet.d.ts +4 -0
  38. package/dist/src/sub/GoogleFontkit/utils/getActiveFontStylesheet.js +16 -0
  39. package/dist/src/sub/GoogleFontkit/utils/getFontId.d.ts +4 -0
  40. package/dist/src/sub/GoogleFontkit/utils/getFontId.js +9 -0
  41. package/dist/src/sub/GoogleFontkit/utils/getMatches.d.ts +1 -0
  42. package/dist/src/sub/GoogleFontkit/utils/getMatches.js +14 -0
  43. package/dist/src/sub/GoogleFontkit/utils/isStyleSheetExists.d.ts +4 -0
  44. package/dist/src/sub/GoogleFontkit/utils/isStyleSheetExists.js +15 -0
  45. package/dist/src/sub/GoogleFontkit/utils/parseFontVariants.d.ts +4 -0
  46. package/dist/src/sub/GoogleFontkit/utils/parseFontVariants.js +18 -0
  47. package/dist/src/sub/GoogleFontkit/utils/setStyleSheetType.d.ts +4 -0
  48. package/dist/src/sub/GoogleFontkit/utils/setStyleSheetType.js +18 -0
  49. package/package.json +1 -1
  50. package/release-note.md +3 -3
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var getGoogleFontCss_1 = __importDefault(require("../api/getGoogleFontCss"));
43
+ var getGoogleWebFonts_1 = __importDefault(require("../api/getGoogleWebFonts"));
44
+ var createStyleSheet_1 = __importDefault(require("./createStyleSheet"));
45
+ var extractFontStyles_1 = __importDefault(require("./extractFontStyles"));
46
+ var fillStyleSheet_1 = __importDefault(require("./fillStyleSheet"));
47
+ var getFontId_1 = __importDefault(require("./getFontId"));
48
+ var isStyleSheetExists_1 = __importDefault(require("./isStyleSheetExists"));
49
+ var parseFontVariants_1 = __importDefault(require("./parseFontVariants"));
50
+ function callGoogleFontCSSAndApply(key, fontFamily) {
51
+ return __awaiter(this, void 0, void 0, function () {
52
+ var items, font, css, fontStyles;
53
+ return __generator(this, function (_a) {
54
+ switch (_a.label) {
55
+ case 0: return [4 /*yield*/, (0, getGoogleWebFonts_1.default)({
56
+ key: key,
57
+ family: fontFamily
58
+ })];
59
+ case 1:
60
+ items = (_a.sent()).items;
61
+ font = items[0];
62
+ font.id = (0, getFontId_1.default)(font.family);
63
+ if ((0, isStyleSheetExists_1.default)(font.id)) {
64
+ return [2 /*return*/];
65
+ }
66
+ (0, createStyleSheet_1.default)(font.id, false);
67
+ return [4 /*yield*/, (0, getGoogleFontCss_1.default)({
68
+ family: "".concat(font.family).concat((0, parseFontVariants_1.default)(font.variants, {
69
+ prefix: ':wght@',
70
+ separator: ';'
71
+ })),
72
+ 'font-display': 'swap'
73
+ })];
74
+ case 2:
75
+ css = _a.sent();
76
+ fontStyles = (0, extractFontStyles_1.default)(css);
77
+ (0, fillStyleSheet_1.default)(font.id, fontStyles[font.id]);
78
+ return [2 /*return*/];
79
+ }
80
+ });
81
+ });
82
+ }
83
+ exports.default = callGoogleFontCSSAndApply;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Attach a new font stylesheet to the document head using the provided content
3
+ */
4
+ export default function createStylesheet(fontId: string, isPreview: boolean): void;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var constants_1 = require("../constants");
4
+ /**
5
+ * Attach a new font stylesheet to the document head using the provided content
6
+ */
7
+ function createStylesheet(fontId, isPreview) {
8
+ var stylesheetNode = document.createElement('style');
9
+ stylesheetNode.id = fontId;
10
+ stylesheetNode.setAttribute(constants_1.PREVIEW_ATTRIBUTE_NAME, isPreview.toString());
11
+ document.head.appendChild(stylesheetNode);
12
+ }
13
+ exports.default = createStylesheet;
@@ -0,0 +1 @@
1
+ export default function extractFontStyles(allFontStyles: string): Record<string, string>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var constants_1 = require("../constants");
7
+ var getFontId_1 = __importDefault(require("./getFontId"));
8
+ var getMatches_1 = __importDefault(require("./getMatches"));
9
+ function extractFontStyles(allFontStyles) {
10
+ // Run Regex to separate font-face rules
11
+ var rules = (0, getMatches_1.default)(constants_1.FONT_FACE_REGEX, allFontStyles);
12
+ // Assign font-face rules to fontIds
13
+ var fontStyles = {};
14
+ rules.forEach(function (rule) {
15
+ // Run regex to get font family
16
+ var fontFamily = (0, getMatches_1.default)(constants_1.FONT_FAMILY_REGEX, rule)[0];
17
+ var fontId = (0, getFontId_1.default)(fontFamily);
18
+ // Append rule to font font family's other rules
19
+ if (!(fontId in fontStyles)) {
20
+ fontStyles[fontId] = '';
21
+ }
22
+ fontStyles[fontId] += "@font-face {\n".concat(rule, "\n}\n\n");
23
+ });
24
+ return fontStyles;
25
+ }
26
+ exports.default = extractFontStyles;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Insert the provided styles in the font's <style> element (existing styles are replaced)
3
+ */
4
+ export default function fillStylesheet(fontId: string, styles: string): void;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Insert the provided styles in the font's <style> element (existing styles are replaced)
5
+ */
6
+ function fillStylesheet(fontId, styles) {
7
+ // const stylesheetId = getStylesheetId(fontId);
8
+ var stylesheetNode = document.getElementById(fontId);
9
+ if (stylesheetNode) {
10
+ stylesheetNode.textContent = styles;
11
+ }
12
+ else {
13
+ // eslint-disable-next-line no-console
14
+ console.error("Could not fill stylesheet: Stylesheet with ID \"".concat(fontId, "\" not found"));
15
+ }
16
+ }
17
+ exports.default = fillStylesheet;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Create/find and return the apply-font stylesheet for the provided selectorSuffix
3
+ */
4
+ export default function getActiveFontStylesheet(selectorSuffix: string): HTMLStyleElement;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Create/find and return the apply-font stylesheet for the provided selectorSuffix
5
+ */
6
+ function getActiveFontStylesheet(selectorSuffix) {
7
+ var stylesheetId = "active-font-".concat(selectorSuffix);
8
+ var activeFontStylesheet = document.getElementById(stylesheetId);
9
+ if (!activeFontStylesheet) {
10
+ activeFontStylesheet = document.createElement('style');
11
+ activeFontStylesheet.id = stylesheetId;
12
+ document.head.appendChild(activeFontStylesheet);
13
+ }
14
+ return activeFontStylesheet;
15
+ }
16
+ exports.default = getActiveFontStylesheet;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Return the fontId based on the provided font family
3
+ */
4
+ export default function getFontId(fontFamily: string): string;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Return the fontId based on the provided font family
5
+ */
6
+ function getFontId(fontFamily) {
7
+ return fontFamily.replace(/\s+/g, '-').toLowerCase();
8
+ }
9
+ exports.default = getFontId;
@@ -0,0 +1 @@
1
+ export default function getMatches(regex: RegExp, str: string): string[];
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function getMatches(regex, str) {
4
+ var matches = [];
5
+ var match;
6
+ do {
7
+ match = regex.exec(str);
8
+ if (match) {
9
+ matches.push(match[1]);
10
+ }
11
+ } while (match);
12
+ return matches;
13
+ }
14
+ exports.default = getMatches;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Check whether a font stylesheet already exists in the document head
3
+ */
4
+ export default function isStylesheetExists(fontId: string, isPreview?: boolean): boolean;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var constants_1 = require("../constants");
4
+ /**
5
+ * Check whether a font stylesheet already exists in the document head
6
+ */
7
+ function isStylesheetExists(fontId, isPreview) {
8
+ var stylesheetNode = document.getElementById(fontId);
9
+ if (isPreview === null || isPreview === undefined) {
10
+ return stylesheetNode !== null;
11
+ }
12
+ return (stylesheetNode !== null &&
13
+ stylesheetNode.getAttribute(constants_1.PREVIEW_ATTRIBUTE_NAME) === isPreview.toString());
14
+ }
15
+ exports.default = isStylesheetExists;
@@ -0,0 +1,4 @@
1
+ export default function parseVariants(variant: Array<string | number>, { prefix, separator }: {
2
+ prefix: string;
3
+ separator: string;
4
+ }): string;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function parseVariants(variant, _a) {
4
+ var prefix = _a.prefix, separator = _a.separator;
5
+ var initialAcc = '';
6
+ var fontWeights = variant.reduce(function (acc, cur) {
7
+ var conditionalPrefix = acc === '' ? '' : separator;
8
+ if (cur === 'regular') {
9
+ return "".concat(acc + conditionalPrefix).concat(400);
10
+ }
11
+ if (Number.isNaN(Number(cur))) {
12
+ return acc;
13
+ }
14
+ return "".concat(acc + conditionalPrefix).concat(cur);
15
+ }, initialAcc);
16
+ return "".concat(prefix).concat(fontWeights);
17
+ }
18
+ exports.default = parseVariants;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Update the value of a stylesheet's "data-is-preview" attribute
3
+ */
4
+ export default function setStylesheetType(fontId: string, isPreview: boolean): void;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var constants_1 = require("../constants");
4
+ /**
5
+ * Update the value of a stylesheet's "data-is-preview" attribute
6
+ */
7
+ function setStylesheetType(fontId, isPreview) {
8
+ var stylesheetId = fontId;
9
+ var stylesheetNode = document.getElementById(stylesheetId);
10
+ if (stylesheetNode) {
11
+ stylesheetNode.setAttribute(constants_1.PREVIEW_ATTRIBUTE_NAME, isPreview.toString());
12
+ }
13
+ else {
14
+ // eslint-disable-next-line no-console
15
+ console.error("Could not change stylesheet type: Stylesheet with ID \"".concat(stylesheetId, "\" not found"));
16
+ }
17
+ }
18
+ exports.default = setStylesheetType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pds-dev-kit-web-test",
3
- "version": "0.2.41",
3
+ "version": "0.2.43",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
package/release-note.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # pds-dev-kit-web-test Release Notes
2
- ## [v0.2.41]
2
+ ## [v0.2.43]
3
3
  ## 기준 pds-dev-kit-web 버전 @2.2.10
4
4
  ### sub
5
- * DynamicLayout - custom section
6
- * @CUSTOMSECTION/CB_RIGHT_CLICKED 에서 e를 넘겨줄 있도록 추가
5
+ * GoogleFontKit
6
+ * GoogleFontItem -> defaultText 기능 리턴 추가