pds-dev-kit-web-test 2.3.9 → 2.3.10

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/components/SectionMatcher/SectionMatcher.js +3 -0
  2. package/dist/src/sub/DynamicLayout/pagesPreviewMock.d.ts +1112 -446
  3. package/dist/src/sub/DynamicLayout/pagesPreviewMock.js +2071 -814
  4. package/dist/src/sub/DynamicLayout/sectionActionTypes.d.ts +10 -0
  5. package/dist/src/sub/DynamicLayout/sections/CustomSection/CustomSection.d.ts +6 -0
  6. package/dist/src/sub/DynamicLayout/sections/CustomSection/CustomSection.js +80 -64
  7. package/dist/src/sub/DynamicLayout/sections/CustomSection/NewCustomSection.d.ts +3 -0
  8. package/dist/src/sub/DynamicLayout/sections/CustomSection/NewCustomSection.js +70 -0
  9. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/ComponentBlockMatcher.d.ts +2 -1
  10. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/ComponentBlockMatcher.js +3 -3
  11. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/Button/Button.js +1 -1
  12. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/Text/Text.d.ts +3 -1
  13. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/Text/Text.js +57 -1
  14. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/Text/index.d.ts +1 -0
  15. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/Text/index.js +8 -0
  16. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/componentBlocks/components/S_CB_Box.js +1 -1
  17. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/index.d.ts +1 -1
  18. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/ComponentBlock/index.js +3 -3
  19. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/index.d.ts +1 -1
  20. package/dist/src/sub/DynamicLayout/sections/CustomSection/components/index.js +2 -2
  21. package/dist/src/sub/DynamicLayout/sections/CustomSection/customSectionContext.d.ts +10 -0
  22. package/dist/src/sub/DynamicLayout/sections/CustomSection/customSectionContext.js +21 -0
  23. package/dist/src/sub/DynamicLayout/sections/CustomSection/newUtils/textUtil.js +12 -1
  24. package/dist/src/sub/DynamicLayout/sections/TempCustomSection/FlexGridItem.d.ts +11 -0
  25. package/dist/src/sub/DynamicLayout/sections/TempCustomSection/FlexGridItem.js +69 -0
  26. package/dist/src/sub/DynamicLayout/sections/TempCustomSection/TempCustomSection.d.ts +7 -0
  27. package/dist/src/sub/DynamicLayout/sections/TempCustomSection/TempCustomSection.js +87 -0
  28. package/dist/src/sub/DynamicLayout/sections/TempCustomSection/useIsMounted.d.ts +1 -0
  29. package/dist/src/sub/DynamicLayout/sections/TempCustomSection/useIsMounted.js +15 -0
  30. package/dist/src/sub/DynamicLayout/sections/TempCustomSection/useResizableObserver.d.ts +12 -0
  31. package/dist/src/sub/DynamicLayout/sections/TempCustomSection/useResizableObserver.js +74 -0
  32. package/package.json +5 -2
  33. package/dist/src/sub/SandollFontKit/api/getSandollFonts.d.ts +0 -14
  34. package/dist/src/sub/SandollFontKit/api/getSandollFonts.js +0 -247
  35. package/dist/src/sub/SandollFontKit/api/types.d.ts +0 -50
  36. package/dist/src/sub/SandollFontKit/api/types.js +0 -2
  37. package/dist/src/sub/SandollFontKit/constants.d.ts +0 -9
  38. package/dist/src/sub/SandollFontKit/constants.js +0 -33
  39. package/dist/src/sub/SandollFontKit/headless/SandollFontItem.d.ts +0 -13
  40. package/dist/src/sub/SandollFontKit/headless/SandollFontItem.js +0 -64
  41. package/dist/src/sub/SandollFontKit/headless/SandollFontsList.d.ts +0 -18
  42. package/dist/src/sub/SandollFontKit/headless/SandollFontsList.js +0 -74
  43. package/dist/src/sub/SandollFontKit/hooks/useQueryParamsReducer.d.ts +0 -30
  44. package/dist/src/sub/SandollFontKit/hooks/useQueryParamsReducer.js +0 -69
  45. package/dist/src/sub/SandollFontKit/index.d.ts +0 -5
  46. package/dist/src/sub/SandollFontKit/index.js +0 -28
  47. package/dist/src/sub/SandollFontKit/types.d.ts +0 -14
  48. package/dist/src/sub/SandollFontKit/types.js +0 -2
  49. package/dist/src/sub/SandollFontKit/utils/createSandollFontLink.d.ts +0 -2
  50. package/dist/src/sub/SandollFontKit/utils/createSandollFontLink.js +0 -24
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pds-dev-kit-web-test",
3
- "version": "2.3.9",
3
+ "version": "2.3.10",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
@@ -22,9 +22,10 @@
22
22
  "i18next-intervalplural-postprocessor": "^3.0.0",
23
23
  "lottie-react": "^2.3.1",
24
24
  "nuka-carousel": "^4.8.4",
25
- "publ-echo": "^0.0.45",
25
+ "publ-echo": "^0.0.84",
26
26
  "react-hook-form": "^7.28.1",
27
27
  "react-i18next": "^11.12.0",
28
+ "react-measure": "^2.5.2",
28
29
  "react-router-dom": "^5.2.0",
29
30
  "react-scripts": "4.0.3",
30
31
  "smoothscroll-polyfill": "^0.4.4",
@@ -85,6 +86,8 @@
85
86
  "@storybook/react": "^6.3.12",
86
87
  "@types/lodash": "^4.14.175",
87
88
  "@types/node": "^16.10.2",
89
+ "@types/react-grid-layout": "^1.3.5",
90
+ "@types/react-measure": "^2.0.12",
88
91
  "@types/react-router-dom": "^5.3.3",
89
92
  "@types/smoothscroll-polyfill": "^0.3.1",
90
93
  "@types/styled-components": "^5.1.9",
@@ -1,14 +0,0 @@
1
- import type { FontResponse, PublHeaders, SandollFontsQueryParams } from './types';
2
- export declare const DEFAULT_PAGINATION: {
3
- page: number;
4
- limit: number;
5
- };
6
- export declare const DEFAULT_FILTER: {
7
- sort: string;
8
- order: string;
9
- };
10
- export declare const DEFAULT_SEARCHQUERY: {
11
- usecase: string;
12
- searchTerm: string;
13
- };
14
- export declare function fetchSandollFonts(baseURL: string, searchParams: SandollFontsQueryParams, publHeaders: PublHeaders): Promise<FontResponse>;
@@ -1,247 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.fetchSandollFonts = exports.DEFAULT_SEARCHQUERY = exports.DEFAULT_FILTER = exports.DEFAULT_PAGINATION = void 0;
40
- exports.DEFAULT_PAGINATION = { page: 1, limit: 100 };
41
- exports.DEFAULT_FILTER = { sort: 'trending', order: 'ASC' };
42
- exports.DEFAULT_SEARCHQUERY = { usecase: 'EDITOR', searchTerm: '' };
43
- function fetchSandollFonts(baseURL, searchParams, publHeaders) {
44
- return __awaiter(this, void 0, void 0, function () {
45
- var url, searchQuery, pagination, filter, categories, response, error_1, mocks;
46
- return __generator(this, function (_a) {
47
- switch (_a.label) {
48
- case 0:
49
- url = new URL('/seller/api/v2/channel-management/font-manager/sandoll/available-fonts', baseURL);
50
- searchQuery = searchParams.searchQuery, pagination = searchParams.pagination, filter = searchParams.filter, categories = searchParams.categories;
51
- // Set query parameters
52
- url.searchParams.append('usecase', searchQuery.usecase || 'EDITOR');
53
- if (searchQuery.searchTerm) {
54
- url.searchParams.append('searchTerm', searchQuery.searchTerm);
55
- }
56
- url.searchParams.append('page', pagination.page.toString());
57
- url.searchParams.append('limit', pagination.limit.toString());
58
- url.searchParams.append('sort', filter.sort);
59
- url.searchParams.append('order', filter.order);
60
- url.searchParams.append('categories', categories.join(''));
61
- _a.label = 1;
62
- case 1:
63
- _a.trys.push([1, 3, , 5]);
64
- return [4 /*yield*/, fetch(url.toString(), {
65
- method: 'GET',
66
- headers: {
67
- Authorization: "Bearer ".concat(publHeaders.channelToken),
68
- 'x-publ-channel-id': "".concat(publHeaders.channelId)
69
- }
70
- })];
71
- case 2:
72
- response = _a.sent();
73
- return [2 /*return*/, response.json()];
74
- case 3:
75
- error_1 = _a.sent();
76
- return [4 /*yield*/, fetchMock(searchParams)];
77
- case 4:
78
- mocks = _a.sent();
79
- return [2 /*return*/, mocks];
80
- case 5: return [2 /*return*/];
81
- }
82
- });
83
- });
84
- }
85
- exports.fetchSandollFonts = fetchSandollFonts;
86
- function fetchMock(searchParams) {
87
- var searchQuery = searchParams.searchQuery, pagination = searchParams.pagination, filter = searchParams.filter, categories = searchParams.categories;
88
- var filteredFonts = mockAvailableFonts.filter(function (font) {
89
- var matchesSearchTerm = searchQuery.searchTerm
90
- ? font.fontName.toLowerCase().includes(searchQuery.searchTerm.toLowerCase())
91
- : true;
92
- var matchesCategories = categories.length > 0 ? categories.includes(font.category) : true;
93
- return matchesSearchTerm && matchesCategories;
94
- });
95
- var sortedFonts = filteredFonts.sort(function (a, b) {
96
- if (filter.sort === 'alpha') {
97
- return filter.order === 'ASC'
98
- ? a.fontName.localeCompare(b.fontName)
99
- : b.fontName.localeCompare(a.fontName);
100
- }
101
- // 다른 정렬 옵션에 대한 처리
102
- return 0;
103
- });
104
- var paginatedFonts = sortedFonts.slice((pagination.page - 1) * pagination.limit, pagination.page * pagination.limit);
105
- return new Promise(function (res) {
106
- setTimeout(function () {
107
- res({
108
- data: {
109
- availableFonts: paginatedFonts,
110
- pagination: {
111
- page: pagination.page,
112
- limit: pagination.limit
113
- },
114
- supportedOptions: null
115
- }
116
- });
117
- }, 250);
118
- });
119
- }
120
- var mockAvailableFonts = [
121
- {
122
- id: '1',
123
- distinctId: 'font1',
124
- fontEnumValue: 'SANDOLL_FONT_1',
125
- provider: 'ProviderA',
126
- fontName: 'Sandoll Gothic',
127
- fontFamilyName: 'Sandoll Gothic Family',
128
- supportedWeights: [100, 300, 400, 500, 700, 900],
129
- providerFontId: 'providerA_font1',
130
- providerFontName: 'ProviderA Sandoll Gothic',
131
- providerFontFamilyId: 'providerA_family1',
132
- providerFontFamilyName: 'ProviderA Sandoll Gothic Family',
133
- category: 'sans-serif',
134
- providerCssInfoDict: {
135
- fontFamily: 'Sandoll Gothic',
136
- fontWeight: 400
137
- }
138
- },
139
- {
140
- id: '2',
141
- distinctId: 'font2',
142
- fontEnumValue: 'SANDOLL_FONT_2',
143
- provider: 'ProviderB',
144
- fontName: 'Sandoll Serif',
145
- fontFamilyName: 'Sandoll Serif Family',
146
- supportedWeights: [200, 400, 600, 800],
147
- providerFontId: 'providerB_font2',
148
- providerFontName: 'ProviderB Sandoll Serif',
149
- providerFontFamilyId: 'providerB_family2',
150
- providerFontFamilyName: 'ProviderB Sandoll Serif Family',
151
- category: 'serif',
152
- providerCssInfoDict: {
153
- fontFamily: 'Sandoll Serif',
154
- fontWeight: 600
155
- }
156
- },
157
- {
158
- id: '3',
159
- distinctId: 'font3',
160
- fontEnumValue: 'SANDOLL_FONT_3',
161
- provider: 'ProviderC',
162
- fontName: 'Sandoll Sans',
163
- fontFamilyName: 'Sandoll Sans Family',
164
- supportedWeights: [100, 200, 400, 700],
165
- providerFontId: 'providerC_font3',
166
- providerFontName: 'ProviderC Sandoll Sans',
167
- providerFontFamilyId: 'providerC_family3',
168
- providerFontFamilyName: 'ProviderC Sandoll Sans Family',
169
- category: 'sans-serif',
170
- providerCssInfoDict: {
171
- fontFamily: 'Sandoll Sans',
172
- fontWeight: 700
173
- }
174
- },
175
- {
176
- id: '4',
177
- distinctId: 'font4',
178
- fontEnumValue: 'SANDOLL_FONT_4',
179
- provider: 'ProviderD',
180
- fontName: 'Sandoll Display',
181
- fontFamilyName: 'Sandoll Display Family',
182
- supportedWeights: [300, 500, 700, 900],
183
- providerFontId: 'providerD_font4',
184
- providerFontName: 'ProviderD Sandoll Display',
185
- providerFontFamilyId: 'providerD_family4',
186
- providerFontFamilyName: 'ProviderD Sandoll Display Family',
187
- category: 'deco',
188
- providerCssInfoDict: {
189
- fontFamily: 'Sandoll Display',
190
- fontWeight: 500
191
- }
192
- },
193
- {
194
- id: '5',
195
- distinctId: 'font5',
196
- fontEnumValue: 'SANDOLL_FONT_5',
197
- provider: 'ProviderE',
198
- fontName: 'Sandoll Mono',
199
- fontFamilyName: 'Sandoll Mono Family',
200
- supportedWeights: [100, 300, 400, 600, 800],
201
- providerFontId: 'providerE_font5',
202
- providerFontName: 'ProviderE Sandoll Mono',
203
- providerFontFamilyId: 'providerE_family5',
204
- providerFontFamilyName: 'ProviderE Sandoll Mono Family',
205
- category: 'blackLetter',
206
- providerCssInfoDict: {
207
- fontFamily: 'Sandoll Mono',
208
- fontWeight: 400
209
- }
210
- },
211
- {
212
- id: '6',
213
- distinctId: 'font6',
214
- fontEnumValue: 'SANDOLL_FONT_6',
215
- provider: 'ProviderF',
216
- fontName: 'Sandoll Classic',
217
- fontFamilyName: 'Sandoll Classic Family',
218
- supportedWeights: [100, 200, 400, 600, 700],
219
- providerFontId: 'providerF_font6',
220
- providerFontName: 'ProviderF Sandoll Classic',
221
- providerFontFamilyId: 'providerF_family6',
222
- providerFontFamilyName: 'ProviderF Sandoll Classic Family',
223
- category: 'serif',
224
- providerCssInfoDict: {
225
- fontFamily: 'Sandoll Classic',
226
- fontWeight: 400
227
- }
228
- },
229
- {
230
- id: '7',
231
- distinctId: 'font7',
232
- fontEnumValue: 'SANDOLL_FONT_7',
233
- provider: 'ProviderG',
234
- fontName: 'Sandoll Modern',
235
- fontFamilyName: 'Sandoll Modern Family',
236
- supportedWeights: [300, 400, 500, 700],
237
- providerFontId: 'providerG_font7',
238
- providerFontName: 'ProviderG Sandoll Modern',
239
- providerFontFamilyId: 'providerG_family7',
240
- providerFontFamilyName: 'ProviderG Sandoll Modern Family',
241
- category: 'sans-serif',
242
- providerCssInfoDict: {
243
- fontFamily: 'Sandoll Modern',
244
- fontWeight: 500
245
- }
246
- }
247
- ];
@@ -1,50 +0,0 @@
1
- import type { SANDOLL_CategoryType } from '../types';
2
- export type Pagination = {
3
- page: number;
4
- limit: number;
5
- };
6
- export type Filter = {
7
- sort: 'trending' | 'popularity' | 'date' | 'alpha';
8
- order: 'ASC' | 'DESC';
9
- };
10
- export type SearchQuery = {
11
- usecase?: 'EDITOR';
12
- searchTerm?: string;
13
- };
14
- export type SandollFont = {
15
- id: string;
16
- distinctId: string;
17
- fontEnumValue: string;
18
- provider: string;
19
- fontName: string;
20
- fontFamilyName: string;
21
- supportedWeights: number[];
22
- providerFontId: string;
23
- providerFontName: string;
24
- providerFontFamilyId: string;
25
- providerFontFamilyName: string;
26
- providerCssInfoDict: CSSInfoDict;
27
- category: SANDOLL_CategoryType;
28
- };
29
- export type CSSInfoDict = {
30
- fontFamily: string;
31
- fontWeight: number;
32
- };
33
- export type SupportedOptionMap = {};
34
- export type FontResponse = {
35
- data: {
36
- availableFonts: SandollFont[];
37
- supportedOptions: SupportedOptionMap;
38
- pagination: Pagination;
39
- };
40
- };
41
- export type SandollFontsQueryParams = {
42
- pagination: Pagination;
43
- searchQuery: SearchQuery;
44
- filter: Filter;
45
- categories: SANDOLL_CategoryType[];
46
- };
47
- export type PublHeaders = {
48
- channelToken: string;
49
- channelId: string;
50
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,9 +0,0 @@
1
- import type { SANDOLL_CategoryType, SANDOLL_CategoryIconType, SANDOLL_SortOptionType } from './types';
2
- export declare const SANDOLL_SORT_OPTIONS: SANDOLL_SortOptionType[];
3
- export declare const SANDOLL_DEFAULT_SORT: {
4
- text: string;
5
- value: SANDOLL_SortOptionType;
6
- };
7
- export declare const SANDOLL_SORT_OPTION_KEY_MAP: Record<SANDOLL_SortOptionType, string>;
8
- export declare const SANDOLL_CATEGORIES: SANDOLL_CategoryType[];
9
- export declare const SANDOLL_CATEGORY_ICONS: SANDOLL_CategoryIconType;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SANDOLL_CATEGORY_ICONS = exports.SANDOLL_CATEGORIES = exports.SANDOLL_SORT_OPTION_KEY_MAP = exports.SANDOLL_DEFAULT_SORT = exports.SANDOLL_SORT_OPTIONS = void 0;
4
- exports.SANDOLL_SORT_OPTIONS = ['date', 'alpha'];
5
- exports.SANDOLL_DEFAULT_SORT = {
6
- text: 'str_key_seller_scene_x00001pages_dleditor_modal_fontselect_section_sandoll_filter_viewoption_option_latest',
7
- value: 'date'
8
- };
9
- exports.SANDOLL_SORT_OPTION_KEY_MAP = {
10
- date: 'str_key_seller_scene_x00001pages_dleditor_modal_fontselect_section_sandoll_filter_viewoption_option_latest',
11
- alpha: 'str_key_seller_scene_x00001pages_dleditor_modal_fontselect_section_sandoll_filter_viewoption_option_name'
12
- };
13
- exports.SANDOLL_CATEGORIES = [
14
- 'serif',
15
- 'sans-serif',
16
- 'slab',
17
- 'blackLetter',
18
- 'deco',
19
- 'symbol',
20
- 'round',
21
- 'script'
22
- ];
23
- // NOTE: remove as
24
- exports.SANDOLL_CATEGORY_ICONS = {
25
- serif: 'ic_typeface_serif_20',
26
- 'sans-serif': 'ic_typeface_sans_serif_20',
27
- slab: 'ic_typeface_slab_20',
28
- round: 'ic_typeface_round_20',
29
- script: 'ic_typeface_script_20',
30
- deco: 'ic_typeface_deco_20',
31
- symbol: 'ic_typeface_symbol_20',
32
- blackLetter: 'ic_typeface_blackletter_20'
33
- };
@@ -1,13 +0,0 @@
1
- import { type LegacyRef } from 'react';
2
- import type { SANDOLL_Font } from '../types';
3
- type HeadlessProps = {
4
- isLoading: boolean;
5
- isVisible: boolean;
6
- ref: LegacyRef<HTMLElement>;
7
- };
8
- type Props = {
9
- font: SANDOLL_Font;
10
- children: (args: HeadlessProps) => JSX.Element;
11
- };
12
- declare function SandollFontItem({ font, children }: Props): JSX.Element;
13
- export default SandollFontItem;
@@ -1,64 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
39
- var react_1 = require("react");
40
- var GoogleFontkit_1 = require("../../GoogleFontkit");
41
- function SandollFontItem(_a) {
42
- var font = _a.font, children = _a.children;
43
- var _b = (0, react_1.useState)(false), isLoading = _b[0], setIsLoading = _b[1];
44
- var ref = (0, react_1.useRef)(null);
45
- var entry = (0, GoogleFontkit_1.useIntersectionObserver)(ref, {});
46
- var isVisible = !!(entry === null || entry === void 0 ? void 0 : entry.isIntersecting);
47
- (0, react_1.useEffect)(function () {
48
- if (!isVisible) {
49
- return;
50
- }
51
- function getCss() {
52
- return __awaiter(this, void 0, void 0, function () {
53
- return __generator(this, function (_a) {
54
- setIsLoading(true);
55
- setIsLoading(false);
56
- return [2 /*return*/];
57
- });
58
- });
59
- }
60
- getCss();
61
- }, [font, isVisible]);
62
- return children({ isLoading: isLoading, isVisible: isVisible, ref: ref });
63
- }
64
- exports.default = SandollFontItem;
@@ -1,18 +0,0 @@
1
- /// <reference types="react" />
2
- import { QueryParamDispatchFunction } from '../hooks/useQueryParamsReducer';
3
- import type { PublHeaders, SandollFontsQueryParams } from '../api/types';
4
- import type { SANDOLL_Font } from '../types';
5
- type HeadlessProps = {
6
- isLoading: boolean;
7
- fonts: SANDOLL_Font[];
8
- queryParams: SandollFontsQueryParams;
9
- queryParamDispatch: QueryParamDispatchFunction;
10
- };
11
- type Props = {
12
- baseURL: string;
13
- defaultQueryParams?: SandollFontsQueryParams;
14
- publHeaders: PublHeaders;
15
- children: (args: HeadlessProps) => JSX.Element;
16
- };
17
- declare function SandollFontsList({ baseURL, defaultQueryParams, publHeaders, children }: Props): JSX.Element;
18
- export default SandollFontsList;
@@ -1,74 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
39
- var react_1 = require("react");
40
- var getSandollFonts_1 = require("../api/getSandollFonts");
41
- var useQueryParamsReducer_1 = require("../hooks/useQueryParamsReducer");
42
- function SandollFontsList(_a) {
43
- var baseURL = _a.baseURL, _b = _a.defaultQueryParams, defaultQueryParams = _b === void 0 ? useQueryParamsReducer_1.DEFAULT_QUERY_PARAMS : _b, publHeaders = _a.publHeaders, children = _a.children;
44
- var _c = (0, useQueryParamsReducer_1.useQueryParamsReducer)(defaultQueryParams), queryParams = _c[0], queryParamDispatch = _c[1];
45
- var _d = (0, react_1.useState)(false), isLoading = _d[0], setIsLoading = _d[1];
46
- var _e = (0, react_1.useState)([]), fonts = _e[0], setFonts = _e[1];
47
- (0, react_1.useEffect)(function () {
48
- function fetchFontsList() {
49
- return __awaiter(this, void 0, void 0, function () {
50
- var res;
51
- return __generator(this, function (_a) {
52
- switch (_a.label) {
53
- case 0:
54
- setIsLoading(true);
55
- return [4 /*yield*/, (0, getSandollFonts_1.fetchSandollFonts)(baseURL, queryParams, publHeaders)];
56
- case 1:
57
- res = _a.sent();
58
- setFonts(res.data.availableFonts);
59
- setIsLoading(false);
60
- return [2 /*return*/];
61
- }
62
- });
63
- });
64
- }
65
- fetchFontsList();
66
- }, [baseURL, queryParams, publHeaders]);
67
- return children({
68
- isLoading: isLoading,
69
- fonts: fonts,
70
- queryParams: queryParams,
71
- queryParamDispatch: queryParamDispatch
72
- });
73
- }
74
- exports.default = SandollFontsList;
@@ -1,30 +0,0 @@
1
- import { Dispatch } from 'react';
2
- import type { SandollFontsQueryParams } from '../api/types';
3
- import type { SANDOLL_CategoryType } from '../types';
4
- type Filter = {
5
- sort: 'trending' | 'popularity' | 'date' | 'alpha';
6
- order: 'ASC' | 'DESC';
7
- };
8
- type Action = {
9
- type: 'SET_PAGE';
10
- payload: number;
11
- } | {
12
- type: 'SET_LIMIT';
13
- payload: number;
14
- } | {
15
- type: 'SET_SEARCH_TERM';
16
- payload: string;
17
- } | {
18
- type: 'SET_SORT';
19
- payload: Filter['sort'];
20
- } | {
21
- type: 'SET_ORDER';
22
- payload: Filter['order'];
23
- } | {
24
- type: 'TOGGLE_CATEGORIES';
25
- payload: SANDOLL_CategoryType;
26
- };
27
- export type QueryParamDispatchFunction = Dispatch<Action>;
28
- export declare const DEFAULT_QUERY_PARAMS: SandollFontsQueryParams;
29
- export declare function useQueryParamsReducer(initialQueryParams: SandollFontsQueryParams): [SandollFontsQueryParams, Dispatch<Action>];
30
- export {};
@@ -1,69 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
- if (ar || !(i in from)) {
16
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
- ar[i] = from[i];
18
- }
19
- }
20
- return to.concat(ar || Array.prototype.slice.call(from));
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.useQueryParamsReducer = exports.DEFAULT_QUERY_PARAMS = void 0;
24
- var react_1 = require("react");
25
- // Initial state
26
- exports.DEFAULT_QUERY_PARAMS = {
27
- pagination: {
28
- page: 1,
29
- limit: 100
30
- },
31
- searchQuery: {
32
- usecase: 'EDITOR',
33
- searchTerm: ''
34
- },
35
- filter: {
36
- sort: 'date',
37
- order: 'ASC'
38
- },
39
- categories: ['blackLetter', 'deco', 'round', 'sans-serif', 'script', 'serif', 'slab', 'symbol']
40
- };
41
- // Reducer function
42
- function queryParamsReducer(state, action) {
43
- switch (action.type) {
44
- case 'SET_PAGE':
45
- return __assign(__assign({}, state), { pagination: __assign(__assign({}, state.pagination), { page: action.payload }) });
46
- case 'SET_LIMIT':
47
- return __assign(__assign({}, state), { pagination: __assign(__assign({}, state.pagination), { limit: action.payload }) });
48
- case 'SET_SEARCH_TERM':
49
- return __assign(__assign({}, state), { searchQuery: __assign(__assign({}, state.searchQuery), { searchTerm: action.payload }) });
50
- case 'SET_SORT':
51
- return __assign(__assign({}, state), { filter: __assign(__assign({}, state.filter), { sort: action.payload }) });
52
- case 'SET_ORDER':
53
- return __assign(__assign({}, state), { filter: __assign(__assign({}, state.filter), { order: action.payload }) });
54
- case 'TOGGLE_CATEGORIES': {
55
- var category_1 = action.payload;
56
- var categories = state.categories.includes(category_1)
57
- ? state.categories.filter(function (c) { return c !== category_1; })
58
- : __spreadArray(__spreadArray([], state.categories, true), [category_1], false);
59
- return __assign(__assign({}, state), { categories: categories });
60
- }
61
- default:
62
- return state;
63
- }
64
- }
65
- // Usage of useReducer with the defined reducer and initial state
66
- function useQueryParamsReducer(initialQueryParams) {
67
- return (0, react_1.useReducer)(queryParamsReducer, initialQueryParams);
68
- }
69
- exports.useQueryParamsReducer = useQueryParamsReducer;