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

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.
@@ -42,12 +42,12 @@ exports.DEFAULT_FILTER = { sort: 'trending', order: 'ASC' };
42
42
  exports.DEFAULT_SEARCHQUERY = { usecase: 'EDITOR', searchTerm: '' };
43
43
  function fetchSandollFonts(baseURL, searchParams, publHeaders) {
44
44
  return __awaiter(this, void 0, void 0, function () {
45
- var url, searchQuery, pagination, filter, response;
45
+ var url, searchQuery, pagination, filter, categories, response, error_1, mocks;
46
46
  return __generator(this, function (_a) {
47
47
  switch (_a.label) {
48
48
  case 0:
49
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;
50
+ searchQuery = searchParams.searchQuery, pagination = searchParams.pagination, filter = searchParams.filter, categories = searchParams.categories;
51
51
  // Set query parameters
52
52
  url.searchParams.append('usecase', searchQuery.usecase || 'EDITOR');
53
53
  if (searchQuery.searchTerm) {
@@ -57,6 +57,10 @@ function fetchSandollFonts(baseURL, searchParams, publHeaders) {
57
57
  url.searchParams.append('limit', pagination.limit.toString());
58
58
  url.searchParams.append('sort', filter.sort);
59
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]);
60
64
  return [4 /*yield*/, fetch(url.toString(), {
61
65
  method: 'GET',
62
66
  headers: {
@@ -64,14 +68,180 @@ function fetchSandollFonts(baseURL, searchParams, publHeaders) {
64
68
  'x-publ-channel-id': "".concat(publHeaders.channelId)
65
69
  }
66
70
  })];
67
- case 1:
71
+ case 2:
68
72
  response = _a.sent();
69
- if (!response.ok) {
70
- throw new Error('Network response was not ok');
71
- }
72
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*/];
73
81
  }
74
82
  });
75
83
  });
76
84
  }
77
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
+ ];
@@ -24,6 +24,7 @@ export type SandollFont = {
24
24
  providerFontFamilyId: string;
25
25
  providerFontFamilyName: string;
26
26
  providerCssInfoDict: CSSInfoDict;
27
+ category: SANDOLL_CategoryType;
27
28
  };
28
29
  export type CSSInfoDict = {
29
30
  fontFamily: string;
@@ -35,13 +35,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
- var __importDefault = (this && this.__importDefault) || function (mod) {
39
- return (mod && mod.__esModule) ? mod : { "default": mod };
40
- };
41
38
  Object.defineProperty(exports, "__esModule", { value: true });
42
39
  var react_1 = require("react");
43
40
  var GoogleFontkit_1 = require("../../GoogleFontkit");
44
- var delay_1 = __importDefault(require("../utils/delay"));
45
41
  function SandollFontItem(_a) {
46
42
  var font = _a.font, children = _a.children;
47
43
  var _b = (0, react_1.useState)(false), isLoading = _b[0], setIsLoading = _b[1];
@@ -55,15 +51,9 @@ function SandollFontItem(_a) {
55
51
  function getCss() {
56
52
  return __awaiter(this, void 0, void 0, function () {
57
53
  return __generator(this, function (_a) {
58
- switch (_a.label) {
59
- case 0:
60
- setIsLoading(true);
61
- return [4 /*yield*/, (0, delay_1.default)(500)];
62
- case 1:
63
- _a.sent();
64
- setIsLoading(false);
65
- return [2 /*return*/];
66
- }
54
+ setIsLoading(true);
55
+ setIsLoading(false);
56
+ return [2 /*return*/];
67
57
  });
68
58
  });
69
59
  }
@@ -36,7 +36,7 @@ exports.DEFAULT_QUERY_PARAMS = {
36
36
  sort: 'date',
37
37
  order: 'ASC'
38
38
  },
39
- categories: ['sans-serif']
39
+ categories: ['blackLetter', 'deco', 'round', 'sans-serif', 'script', 'serif', 'slab', 'symbol']
40
40
  };
41
41
  // Reducer function
42
42
  function queryParamsReducer(state, action) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pds-dev-kit-web-test",
3
- "version": "2.3.8",
3
+ "version": "2.3.9",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
@@ -1 +0,0 @@
1
- export default function delay(ms: number): Promise<unknown>;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function delay(ms) {
4
- return new Promise(function (resolve) { return setTimeout(resolve, ms); });
5
- }
6
- exports.default = delay;