@liiift-studio/sanity-font-manager 2.4.0 → 2.5.1
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/dist/UploadModal-ADNRGQUI.mjs +6 -0
- package/dist/UploadModal-WPK2CXLR.js +6 -0
- package/dist/chunk-JCDZ7SWZ.js +7711 -0
- package/dist/chunk-TMDE4A54.mjs +7711 -0
- package/dist/index.js +666 -1647
- package/dist/index.mjs +319 -1209
- package/package.json +5 -5
- package/src/components/BatchUploadFonts.jsx +57 -44
- package/src/components/BulkActions.jsx +99 -0
- package/src/components/ExistingDocumentResolver.jsx +152 -0
- package/src/components/FontReviewCard.jsx +455 -0
- package/src/components/SingleUploaderTool.jsx +3 -4
- package/src/components/UploadModal.jsx +304 -0
- package/src/components/UploadScriptsComponent.jsx +23 -21
- package/src/components/UploadStep1Settings.jsx +272 -0
- package/src/components/UploadStep2Review.jsx +474 -0
- package/src/components/UploadStep3Execute.jsx +234 -0
- package/src/components/UploadStep3bInstances.jsx +396 -0
- package/src/components/UploadSummary.jsx +196 -0
- package/src/index.js +46 -0
- package/src/utils/buildUploadPlan.js +326 -0
- package/src/utils/executeUploadPlan.js +430 -0
- package/src/utils/executionReducer.js +56 -0
- package/src/utils/fontHelpers.js +267 -0
- package/src/utils/generateCssFile.js +79 -77
- package/src/utils/generateFontData.js +47 -94
- package/src/utils/getEmptyFontKit.js +19 -17
- package/src/utils/parseFont.js +55 -0
- package/src/utils/parseVariableFontInstances.js +237 -147
- package/src/utils/planReducer.js +517 -0
- package/src/utils/planTypes.js +183 -0
- package/src/utils/processFontFiles.js +121 -78
- package/src/utils/regenerateFontData.js +2 -2
- package/src/utils/resolveExistingFont.js +87 -0
- package/src/utils/updateTypefaceDocument.js +15 -2
- package/src/utils/uploadFontFiles.js +405 -405
package/dist/index.js
CHANGED
|
@@ -1,1009 +1,83 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// src/index.js
|
|
30
|
-
var index_exports = {};
|
|
31
|
-
__export(index_exports, {
|
|
32
|
-
BatchUploadFonts: () => BatchUploadFonts,
|
|
33
|
-
DISCOUNT_REQUIREMENT_TYPES: () => DISCOUNT_REQUIREMENT_TYPES,
|
|
34
|
-
DISCOUNT_REQUIREMENT_TYPES_OBJECT: () => DISCOUNT_REQUIREMENT_TYPES_OBJECT,
|
|
35
|
-
FontScriptUploaderComponent: () => FontScriptUploaderComponent,
|
|
36
|
-
GenerateCollectionsPairsComponent: () => GenerateCollectionsPairsComponent,
|
|
37
|
-
HtmlDescription: () => HtmlDescription,
|
|
38
|
-
KeyValueInput: () => KeyValueInput,
|
|
39
|
-
KeyValueReferenceInput: () => KeyValueReferenceInput,
|
|
40
|
-
NestedObjectArraySelector: () => NestedObjectArraySelector,
|
|
41
|
-
PriceInput: () => PriceInput_default,
|
|
42
|
-
PrimaryCollectionGeneratorTypeface: () => PrimaryCollectionGeneratorTypeface,
|
|
43
|
-
RegenerateSubfamiliesComponent: () => RegenerateSubfamiliesComponent,
|
|
44
|
-
SCRIPTS: () => SCRIPTS,
|
|
45
|
-
SCRIPTS_OBJECT: () => SCRIPTS_OBJECT,
|
|
46
|
-
SetOTF: () => SetOTF,
|
|
47
|
-
SingleUploaderTool: () => SingleUploaderTool,
|
|
48
|
-
StatusDisplay: () => StatusDisplay_default,
|
|
49
|
-
StyleCountInput: () => StyleCountInput,
|
|
50
|
-
UpdateScriptsComponent: () => UpdateScriptsComponent,
|
|
51
|
-
UploadButton: () => UploadButton_default,
|
|
52
|
-
UploadScriptsComponent: () => UploadScriptsComponent,
|
|
53
|
-
VariableInstanceReferencesInput: () => VariableInstanceReferencesInput,
|
|
54
|
-
addItalicToFontTitle: () => addItalicToFontTitle,
|
|
55
|
-
createFontObject: () => createFontObject,
|
|
56
|
-
createStylesField: () => createStylesField,
|
|
57
|
-
determineWeight: () => determineWeight,
|
|
58
|
-
expandAbbreviations: () => expandAbbreviations,
|
|
59
|
-
extractFontMetadata: () => extractFontMetadata,
|
|
60
|
-
extractWeightFromFullName: () => extractWeightFromFullName,
|
|
61
|
-
extractWeightName: () => extractWeightName,
|
|
62
|
-
formatFontTitle: () => formatFontTitle,
|
|
63
|
-
generateCssFile: () => generateCssFile,
|
|
64
|
-
generateFontData: () => generateFontData,
|
|
65
|
-
generateFontFile: () => generateFontFile,
|
|
66
|
-
generateStyleKeywords: () => generateStyleKeywords,
|
|
67
|
-
generateSubset: () => generateSubset,
|
|
68
|
-
getEmptyFontKit: () => getEmptyFontKit,
|
|
69
|
-
logFontInfo: () => logFontInfo,
|
|
70
|
-
openTypeField: () => openTypeField,
|
|
71
|
-
parseVariableFontInstances: () => parseVariableFontInstances_default,
|
|
72
|
-
processFontFiles: () => processFontFiles,
|
|
73
|
-
processItalicKeywords: () => processItalicKeywords,
|
|
74
|
-
processSubfamilyName: () => processSubfamilyName,
|
|
75
|
-
readFontFile: () => readFontFile,
|
|
76
|
-
removeWeightNames: () => removeWeightNames,
|
|
77
|
-
renameFontDocuments: () => renameFontDocuments,
|
|
78
|
-
reverseSpellingLookup: () => reverseSpellingLookup,
|
|
79
|
-
sanitizeForSanityId: () => sanitizeForSanityId,
|
|
80
|
-
sortFontObjects: () => sortFontObjects,
|
|
81
|
-
styleCountField: () => styleCountField,
|
|
82
|
-
stylisticSetField: () => stylisticSetField,
|
|
83
|
-
updateFontPrices: () => updateFontPrices,
|
|
84
|
-
updateTypefaceDocument: () => updateTypefaceDocument,
|
|
85
|
-
uploadFontFiles: () => uploadFontFiles,
|
|
86
|
-
useNestedObjects: () => useNestedObjects,
|
|
87
|
-
useSanityClient: () => useSanityClient
|
|
88
|
-
});
|
|
89
|
-
module.exports = __toCommonJS(index_exports);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
90
23
|
|
|
91
|
-
// src/components/BatchUploadFonts.jsx
|
|
92
|
-
var import_react5 = __toESM(require("react"));
|
|
93
|
-
var import_ui4 = require("@sanity/ui");
|
|
94
|
-
var import_icons = require("@sanity/icons");
|
|
95
|
-
var import_sanity3 = require("sanity");
|
|
96
24
|
|
|
97
|
-
// src/hooks/useSanityClient.js
|
|
98
|
-
var import_react = require("react");
|
|
99
|
-
var import_sanity = require("sanity");
|
|
100
|
-
function useSanityClient() {
|
|
101
|
-
const client = (0, import_sanity.useClient)({ apiVersion: "2021-10-23" });
|
|
102
|
-
return (0, import_react.useMemo)(() => client, [client]);
|
|
103
|
-
}
|
|
104
25
|
|
|
105
|
-
// src/utils/processFontFiles.js
|
|
106
|
-
var fontkit = __toESM(require("fontkit"));
|
|
107
|
-
var import_nanoid = require("nanoid");
|
|
108
|
-
|
|
109
|
-
// src/utils/generateKeywords.js
|
|
110
|
-
var coreWeights = ["Hairline", "ExtraThin", "Thin", "Mager", "Maigre", "ExtraLight", "Light", "Chiaro", "Lite", "Leicht", "Demi", "Book", "Buch", "Regular", "Normal", "Medium", "Stark", "Thick", "Kr\xE4ftig", "Viertelfett", "Halbfett", "Dreiviertelfett", "Dark", "Bold", "Neretto", "Gras", "Fett", "Extrafett", "Black", "Nero", "Heavy", "Nerissimo", "Ultra", "Fat", "Poster"];
|
|
111
|
-
var modifiers = ["Demi", "Semi", "Extra", "Ultra", "Super", "Plus"];
|
|
112
|
-
var coreItalics = ["Italic", "Slant", "Oblique", "Cursive", "Rotalic", "Reverse", "Crab Claw", "Crabclaw", "South Paw", "Southpaw", "Backwards", "Backslant", "Backslanted", "Back Slant"];
|
|
113
|
-
var alternativeSpelling = {
|
|
114
|
-
Backslant: ["Bsl"],
|
|
115
|
-
Backwards: ["Bck"],
|
|
116
|
-
Black: ["Blak", "Blk"],
|
|
117
|
-
Bold: ["Bd", "Bld"],
|
|
118
|
-
// B omitted — too ambiguous
|
|
119
|
-
Condensed: ["Cond", "Cnd"],
|
|
120
|
-
Crabclaw: ["Crab", "Claw"],
|
|
121
|
-
Cursive: ["Cur"],
|
|
122
|
-
Dark: ["Drk"],
|
|
123
|
-
Expanded: ["Exp"],
|
|
124
|
-
Extra: ["Xt", "Xtra", "Xtr", "X"],
|
|
125
|
-
// X omitted as standalone — too ambiguous
|
|
126
|
-
ExtraBlack: ["Xblk", "XBlk", "Xblck", "XBlck"],
|
|
127
|
-
ExtraBold: ["Xbd", "XBd", "Xbld", "XBld", "Xbold", "XBold", "ExBold", "Exbold", "Exbd", "ExBd", "Exbld", "ExBld"],
|
|
128
|
-
ExtraCondensed: ["XCond", "Xcnd"],
|
|
129
|
-
ExtraExpanded: ["XExp"],
|
|
130
|
-
ExtraLight: ["Xlight", "XLight", "Xlt", "XLt", "Xlgt", "XLgt", "Xl", "XL", "Xlght", "XLght"],
|
|
131
|
-
ExtraThin: ["Xthin", "Xthn", "Xth", "XThin", "XThn", "XTh", "XT"],
|
|
132
|
-
Extended: ["Ext"],
|
|
133
|
-
Hairline: ["Hl", "Hln", "Hlnn", "Hlnne", "Hlnnne"],
|
|
134
|
-
Italic: ["Ital", "It"],
|
|
135
|
-
Light: ["Lt", "Lght"],
|
|
136
|
-
Medium: ["Med", "Md", "md", "med"],
|
|
137
|
-
Oblique: ["Obl"],
|
|
138
|
-
Plus: ["Pls"],
|
|
139
|
-
Regular: ["Reg", "Rg"],
|
|
140
|
-
Reverse: ["Rev"],
|
|
141
|
-
Rotalic: ["Rot"],
|
|
142
|
-
SemiBold: ["SmBd", "Sb", "Sbd", "Sbld", "Sbold", "Semibd", "SemiBd", "Semibld", "SemiBld", "semiBd", "semiBld"],
|
|
143
|
-
Slant: ["Sl"],
|
|
144
|
-
Southpaw: ["South", "Paw"],
|
|
145
|
-
Super: ["Supr"],
|
|
146
|
-
Thin: ["Thn"],
|
|
147
|
-
Ultra: ["Ult", "Ultre", "Ul", "Ulta"],
|
|
148
|
-
XX: ["XXt", "XXtra", "XXtr", "XX"],
|
|
149
|
-
XXBlack: ["XXblk", "XXBlk", "XXblck", "XXBlck"],
|
|
150
|
-
XXLight: ["XXlight", "XXLight", "XXlt", "XXLt", "XXlgt", "XXLgt", "XXl", "XXL", "XXlght", "XXLght"],
|
|
151
|
-
XXX: ["XXXt", "XXXtra", "XXXtr", "XXX"],
|
|
152
|
-
XXXLight: ["XXXlight", "XXXLight", "XXXlt", "XXXLt", "XXXlgt", "XXXLgt", "XXXl", "XXXL", "XXXlght", "XXXLght"]
|
|
153
|
-
};
|
|
154
|
-
function reverseSpellingLookup(str) {
|
|
155
|
-
let exactMatch = "";
|
|
156
|
-
Object.keys(alternativeSpelling).forEach(function(key) {
|
|
157
|
-
alternativeSpelling[key].forEach(function(alternative) {
|
|
158
|
-
if (str === alternative) {
|
|
159
|
-
exactMatch = key;
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
if (exactMatch) return exactMatch;
|
|
164
|
-
let result = "";
|
|
165
|
-
let longestMatch = 0;
|
|
166
|
-
Object.keys(alternativeSpelling).forEach(function(key) {
|
|
167
|
-
alternativeSpelling[key].forEach(function(alternative) {
|
|
168
|
-
const regex = new RegExp(`\\b${alternative}\\b`);
|
|
169
|
-
if (regex.test(str) && alternative.length > longestMatch) {
|
|
170
|
-
result = key;
|
|
171
|
-
longestMatch = alternative.length;
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
return result;
|
|
176
|
-
}
|
|
177
|
-
function expandAbbreviations(str) {
|
|
178
|
-
if (!str) return str;
|
|
179
|
-
return str.split(" ").map((word) => {
|
|
180
|
-
const expanded = reverseSpellingLookup(word);
|
|
181
|
-
return expanded || word;
|
|
182
|
-
}).join(" ");
|
|
183
|
-
}
|
|
184
|
-
function removeWeightNames(str) {
|
|
185
|
-
if (!str) return str;
|
|
186
|
-
return str.split(" ").map((word) => {
|
|
187
|
-
coreWeights.forEach((weight) => {
|
|
188
|
-
if (word === weight) word = "";
|
|
189
|
-
modifiers.forEach((modifier) => {
|
|
190
|
-
if (word === modifier || modifier + weight === word) word = "";
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
const expanded = reverseSpellingLookup(word);
|
|
194
|
-
if (expanded) return "";
|
|
195
|
-
return word;
|
|
196
|
-
}).join(" ").trim();
|
|
197
|
-
}
|
|
198
|
-
function generateStyleKeywords() {
|
|
199
|
-
let weightKeywordList = [];
|
|
200
|
-
let italicKeywordList = [];
|
|
201
|
-
weightKeywordList = [...coreWeights];
|
|
202
|
-
modifiers.forEach((modifier) => {
|
|
203
|
-
coreWeights.forEach((weight) => {
|
|
204
|
-
weightKeywordList.push(modifier + weight);
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
weightKeywordList = [...weightKeywordList, ...modifiers];
|
|
208
|
-
italicKeywordList = [...coreItalics];
|
|
209
|
-
weightKeywordList = weightKeywordList.map(function(el) {
|
|
210
|
-
var newEls = [];
|
|
211
|
-
Object.keys(alternativeSpelling).forEach(function(key) {
|
|
212
|
-
if (el.indexOf(key) !== -1) {
|
|
213
|
-
alternativeSpelling[key].forEach(function(alternative) {
|
|
214
|
-
let newSpelling = el.replace(key, alternative);
|
|
215
|
-
newEls.push(newSpelling);
|
|
216
|
-
Object.keys(alternativeSpelling).forEach(function(key2) {
|
|
217
|
-
if (newSpelling.indexOf(key2) !== -1) {
|
|
218
|
-
alternativeSpelling[key2].forEach(function(alternative2) {
|
|
219
|
-
let newSpelling2 = newSpelling.replace(key2, alternative2);
|
|
220
|
-
newEls.push(newSpelling2);
|
|
221
|
-
Object.keys(alternativeSpelling).forEach(function(key3) {
|
|
222
|
-
if (newSpelling2.indexOf(key3) !== -1) {
|
|
223
|
-
alternativeSpelling[key3].forEach(function(alternative3) {
|
|
224
|
-
newEls.push(newSpelling2.replace(key3, alternative3));
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
newEls.push(el);
|
|
235
|
-
return newEls;
|
|
236
|
-
}).reduce(function(a, b) {
|
|
237
|
-
return a.concat(b);
|
|
238
|
-
});
|
|
239
|
-
italicKeywordList = italicKeywordList.map(function(el) {
|
|
240
|
-
var newEls = [];
|
|
241
|
-
Object.keys(alternativeSpelling).forEach(function(key) {
|
|
242
|
-
if (el.indexOf(key) !== -1) {
|
|
243
|
-
alternativeSpelling[key].forEach(function(alternative) {
|
|
244
|
-
newEls.push(el.replace(key, alternative));
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
newEls.push(el);
|
|
249
|
-
return newEls;
|
|
250
|
-
}).reduce(function(a, b) {
|
|
251
|
-
return a.concat(b);
|
|
252
|
-
});
|
|
253
|
-
weightKeywordList = weightKeywordList.sort((a, b) => b.length - a.length);
|
|
254
|
-
italicKeywordList = italicKeywordList.sort((a, b) => b.length - a.length);
|
|
255
|
-
weightKeywordList = weightKeywordList.filter((item, pos) => weightKeywordList.indexOf(item) === pos);
|
|
256
|
-
italicKeywordList = italicKeywordList.filter((item, pos) => italicKeywordList.indexOf(item) === pos);
|
|
257
|
-
return { weightKeywordList, italicKeywordList };
|
|
258
|
-
}
|
|
259
26
|
|
|
260
|
-
// src/utils/sanitizeForSanityId.js
|
|
261
|
-
var import_slugify = __toESM(require("slugify"));
|
|
262
|
-
function sanitizeForSanityId(str) {
|
|
263
|
-
if (!str || typeof str !== "string") {
|
|
264
|
-
return "font-" + Date.now();
|
|
265
|
-
}
|
|
266
|
-
let sanitized = str.toLowerCase().trim();
|
|
267
|
-
sanitized = sanitized.replace(/\+/g, "plus");
|
|
268
|
-
sanitized = sanitized.replace(/&/g, "and");
|
|
269
|
-
sanitized = sanitized.replace(/@/g, "at");
|
|
270
|
-
sanitized = (0, import_slugify.default)(sanitized, {
|
|
271
|
-
replacement: "-",
|
|
272
|
-
remove: /[^\w\s-]/g,
|
|
273
|
-
lower: true,
|
|
274
|
-
strict: true,
|
|
275
|
-
locale: "en",
|
|
276
|
-
trim: true
|
|
277
|
-
});
|
|
278
|
-
sanitized = sanitized.replace(/[^a-z0-9\-_]/g, "-");
|
|
279
|
-
sanitized = sanitized.replace(/-+/g, "-");
|
|
280
|
-
sanitized = sanitized.replace(/^[-_]+|[-_]+$/g, "");
|
|
281
|
-
if (sanitized && !/^[a-z_]/.test(sanitized)) {
|
|
282
|
-
sanitized = "font_" + sanitized;
|
|
283
|
-
}
|
|
284
|
-
if (!sanitized) {
|
|
285
|
-
sanitized = "font_" + Date.now();
|
|
286
|
-
}
|
|
287
|
-
if (sanitized.length > 128) {
|
|
288
|
-
const hash = Math.random().toString(36).substring(2, 8);
|
|
289
|
-
sanitized = sanitized.substring(0, 120) + "_" + hash;
|
|
290
|
-
}
|
|
291
|
-
if (!/^[a-z_][a-z0-9\-_]*$/.test(sanitized)) {
|
|
292
|
-
console.warn(`ID sanitization produced invalid result: "${sanitized}", using fallback`);
|
|
293
|
-
sanitized = "font_" + Date.now();
|
|
294
|
-
}
|
|
295
|
-
return sanitized;
|
|
296
|
-
}
|
|
297
27
|
|
|
298
|
-
// src/utils/processFontFiles.js
|
|
299
|
-
var readFontFile = (file) => {
|
|
300
|
-
return new Promise((resolve, reject) => {
|
|
301
|
-
const reader = new FileReader();
|
|
302
|
-
reader.onload = (event) => {
|
|
303
|
-
resolve(new Uint8Array(event.target.result));
|
|
304
|
-
};
|
|
305
|
-
reader.onerror = (error) => {
|
|
306
|
-
reject(error);
|
|
307
|
-
};
|
|
308
|
-
reader.readAsArrayBuffer(file);
|
|
309
|
-
});
|
|
310
|
-
};
|
|
311
|
-
var processFontFiles = async (files, title, weightKeywordList, italicKeywordList, setStatus, preserveShortenedNames = false, preserveFileNames = false) => {
|
|
312
|
-
let failedFiles = [];
|
|
313
|
-
let subfamilies = {};
|
|
314
|
-
let fontsObjects = {};
|
|
315
|
-
let newPreferredStyle = { weight: -100, style: "Italic", _ref: "" };
|
|
316
|
-
for (let i = 0; i < files.length; i++) {
|
|
317
|
-
const file = files[i];
|
|
318
|
-
const fontBuffer = await readFontFile(file);
|
|
319
|
-
const font = fontkit.create(fontBuffer);
|
|
320
|
-
console.log("File name: ", file.name);
|
|
321
|
-
if (file.name.endsWith(".woff2") || file.name.endsWith(".woff")) {
|
|
322
|
-
await handleWebfontMetadata(file, font, files);
|
|
323
|
-
}
|
|
324
|
-
let { weightName, subfamilyName, fontTitle, style, italicKW, variableFont } = extractFontMetadata(
|
|
325
|
-
font,
|
|
326
|
-
title,
|
|
327
|
-
weightKeywordList,
|
|
328
|
-
italicKeywordList,
|
|
329
|
-
preserveShortenedNames
|
|
330
|
-
);
|
|
331
|
-
let id;
|
|
332
|
-
let originalFilename = null;
|
|
333
|
-
if (preserveFileNames) {
|
|
334
|
-
originalFilename = file.name.replace(/\.(ttf|otf|woff2?|eot|svg)$/i, "");
|
|
335
|
-
const normalizedName = originalFilename.replace(/-/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\s+/g, " ").trim();
|
|
336
|
-
fontTitle = normalizedName;
|
|
337
|
-
id = sanitizeForSanityId(normalizedName);
|
|
338
|
-
} else {
|
|
339
|
-
id = sanitizeForSanityId(fontTitle);
|
|
340
|
-
}
|
|
341
|
-
logFontInfo(id, fontTitle, font, file.name, subfamilyName, style, weightName, variableFont, italicKW);
|
|
342
|
-
subfamilies[id] = subfamilyName;
|
|
343
|
-
if (fontsObjects[id]) {
|
|
344
|
-
fontsObjects[id].files = [...fontsObjects[id].files, file];
|
|
345
|
-
if (preserveFileNames && originalFilename) {
|
|
346
|
-
fontsObjects[id].originalFilename = originalFilename;
|
|
347
|
-
}
|
|
348
|
-
} else {
|
|
349
|
-
fontsObjects[id] = createFontObject(
|
|
350
|
-
id,
|
|
351
|
-
fontTitle,
|
|
352
|
-
title,
|
|
353
|
-
font,
|
|
354
|
-
variableFont,
|
|
355
|
-
weightName,
|
|
356
|
-
subfamilyName,
|
|
357
|
-
file,
|
|
358
|
-
preserveFileNames ? originalFilename : null
|
|
359
|
-
);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
fontsObjects = sortFontObjects(fontsObjects);
|
|
363
|
-
const uniqueSubfamilies = [...new Set(Object.values(subfamilies))];
|
|
364
|
-
console.log("Subfamilies:", subfamilies);
|
|
365
|
-
console.log("Unique subfamilies:", uniqueSubfamilies, uniqueSubfamilies.length);
|
|
366
|
-
console.log("Font objects:", fontsObjects);
|
|
367
|
-
return { fontsObjects, subfamilies, uniqueSubfamilies, newPreferredStyle, failedFiles };
|
|
368
|
-
};
|
|
369
|
-
var handleWebfontMetadata = async (file, font, files) => {
|
|
370
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
371
|
-
if (!((_b = (_a = font == null ? void 0 : font.name) == null ? void 0 : _a.records) == null ? void 0 : _b.fullName) || ((_d = (_c = font == null ? void 0 : font.name) == null ? void 0 : _c.records) == null ? void 0 : _d.fullName) === "" || !/^[A-Z0-9]+$/.test((_f = (_e = font == null ? void 0 : font.name) == null ? void 0 : _e.records) == null ? void 0 : _f.fullName)) {
|
|
372
|
-
const ttfFile = files.find((f) => f.name === file.name.replace(".woff2", ".ttf").replace(".woff", ".ttf"));
|
|
373
|
-
if (ttfFile) {
|
|
374
|
-
const ttfFileBuffer = await readFontFile(ttfFile);
|
|
375
|
-
const ttfFileData = fontkit.create(ttfFileBuffer);
|
|
376
|
-
if (ttfFileData) font.name.records = (_g = ttfFileData == null ? void 0 : ttfFileData.name) == null ? void 0 : _g.records;
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
};
|
|
380
|
-
var extractFontMetadata = (font, title, weightKeywordList, italicKeywordList, preserveShortenedNames = false) => {
|
|
381
|
-
var _a, _b, _c, _d, _e, _f;
|
|
382
|
-
let weightName = extractWeightName(font, italicKeywordList);
|
|
383
|
-
if (!preserveShortenedNames) {
|
|
384
|
-
weightName = expandAbbreviations(weightName);
|
|
385
|
-
}
|
|
386
|
-
if ((weightName === "" || weightName.toLowerCase() === "roman") && ((_b = (_a = font == null ? void 0 : font.name) == null ? void 0 : _a.records) == null ? void 0 : _b.fullName)) {
|
|
387
|
-
weightName = extractWeightFromFullName(font, title);
|
|
388
|
-
if (!preserveShortenedNames) {
|
|
389
|
-
weightName = expandAbbreviations(weightName);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
const variableFont = (font == null ? void 0 : font.variationAxes) && Object.keys(font.variationAxes).length > 0;
|
|
393
|
-
let subfamilyName = ((_f = (_e = (_d = (_c = font == null ? void 0 : font.name) == null ? void 0 : _c.records) == null ? void 0 : _d.fullName) == null ? void 0 : _e.en) == null ? void 0 : _f.replace(title.trim(), "").trim()) || font.subfamilyName.trim().replace(title.trim(), "").trim();
|
|
394
|
-
if (!preserveShortenedNames) {
|
|
395
|
-
subfamilyName = expandAbbreviations(subfamilyName);
|
|
396
|
-
}
|
|
397
|
-
let fontTitle = font == null ? void 0 : font.fullName.trim();
|
|
398
|
-
let style = (font == null ? void 0 : font.italicAngle) !== 0 || (font == null ? void 0 : font.fullName.toLowerCase().includes("italic")) ? "Italic" : "Regular";
|
|
399
|
-
const italicKW = processItalicKeywords(font, fontTitle, italicKeywordList);
|
|
400
|
-
subfamilyName = processSubfamilyName(subfamilyName, weightKeywordList, italicKW, preserveShortenedNames);
|
|
401
|
-
fontTitle = formatFontTitle(fontTitle, preserveShortenedNames);
|
|
402
|
-
subfamilyName = subfamilyName === "" ? "Regular" : subfamilyName.replace(/\s+/g, " ").trim();
|
|
403
|
-
if (subfamilyName !== "") {
|
|
404
|
-
weightName = weightName.replace(`${subfamilyName} `, "").replace(` ${subfamilyName}`, "").trim();
|
|
405
|
-
}
|
|
406
|
-
if (variableFont) {
|
|
407
|
-
if (!fontTitle.toLowerCase().includes("vf")) {
|
|
408
|
-
fontTitle = fontTitle + " VF";
|
|
409
|
-
}
|
|
410
|
-
subfamilyName = "";
|
|
411
|
-
}
|
|
412
|
-
if (!(variableFont && fontTitle.toLowerCase().includes("italic"))) {
|
|
413
|
-
fontTitle = addItalicToFontTitle(font, fontTitle, italicKW, style, preserveShortenedNames);
|
|
414
|
-
}
|
|
415
|
-
return { weightName, subfamilyName, fontTitle, style, italicKW, variableFont };
|
|
416
|
-
};
|
|
417
|
-
var extractWeightName = (font, italicKW) => {
|
|
418
|
-
var _a, _b, _c, _d;
|
|
419
|
-
let weightName = ((_b = (_a = font == null ? void 0 : font.name) == null ? void 0 : _a.records) == null ? void 0 : _b.preferredSubfamily) || ((_d = (_c = font == null ? void 0 : font.name) == null ? void 0 : _c.records) == null ? void 0 : _d.fontSubfamily);
|
|
420
|
-
if (typeof weightName === "object") {
|
|
421
|
-
weightName = (weightName == null ? void 0 : weightName.en) || (weightName.constructor === Object ? weightName[Object.keys(weightName)[0]] : null);
|
|
422
|
-
}
|
|
423
|
-
if ((font == null ? void 0 : font.variationAxes) && Object.keys(font.variationAxes).length > 0) {
|
|
424
|
-
return "Variable";
|
|
425
|
-
}
|
|
426
|
-
if (italicKW) {
|
|
427
|
-
italicKW.forEach((keyword) => {
|
|
428
|
-
const kwRegex = new RegExp(`\\b${keyword.trim()}\\b`, "i");
|
|
429
|
-
if (kwRegex.test(weightName)) {
|
|
430
|
-
weightName = weightName.replace(kwRegex, "").trim();
|
|
431
|
-
}
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
return weightName == null ? void 0 : weightName.toString().replace("Italic", "").replace("It", "").replace("Slanted", "").replace("Slant", "").replace("Backslant", "").trim();
|
|
435
|
-
};
|
|
436
|
-
var extractWeightFromFullName = (font, title) => {
|
|
437
|
-
var _a, _b;
|
|
438
|
-
let weightName = (_b = (_a = font == null ? void 0 : font.name) == null ? void 0 : _a.records) == null ? void 0 : _b.fullName;
|
|
439
|
-
weightName = (weightName == null ? void 0 : weightName.en) ? weightName.en : (weightName == null ? void 0 : weightName.constructor) === Object ? weightName[Object.keys(weightName)[0]] : weightName;
|
|
440
|
-
weightName = weightName == null ? void 0 : weightName.replace(title + " ", "").replace(title, "").trim();
|
|
441
|
-
weightName = weightName == null ? void 0 : weightName.replace("Italic", "").replace("It", "").replace("Slanted", "").replace("Slant", "").trim();
|
|
442
|
-
return weightName;
|
|
443
|
-
};
|
|
444
|
-
var processSubfamilyName = (subfamilyName, weightKeywordList, italicKeywordList, preserveShortenedNames = false) => {
|
|
445
|
-
weightKeywordList.forEach((keyword) => {
|
|
446
|
-
const kwRegex = new RegExp(`\\b${keyword.trim()}\\b`, "i");
|
|
447
|
-
if (kwRegex.test(subfamilyName)) {
|
|
448
|
-
subfamilyName = subfamilyName.replace(kwRegex, "").trim();
|
|
449
|
-
}
|
|
450
|
-
subfamilyName = removeWeightNames(subfamilyName) || subfamilyName;
|
|
451
|
-
if (!preserveShortenedNames) {
|
|
452
|
-
subfamilyName = expandAbbreviations(subfamilyName);
|
|
453
|
-
}
|
|
454
|
-
});
|
|
455
|
-
italicKeywordList.forEach((keyword) => {
|
|
456
|
-
const kwRegex = new RegExp(`\\b${keyword.trim()}\\b`, "i");
|
|
457
|
-
if (kwRegex.test(subfamilyName)) {
|
|
458
|
-
subfamilyName = subfamilyName.replace(kwRegex, "").trim();
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
|
-
return subfamilyName;
|
|
462
|
-
};
|
|
463
|
-
var processItalicKeywords = (font, fontTitle, italicKeywordList) => {
|
|
464
|
-
let italicKW = [];
|
|
465
|
-
italicKeywordList.forEach((keyword) => {
|
|
466
|
-
const kw = keyword.trim();
|
|
467
|
-
const kwRegex = new RegExp(`\\b${kw}\\b`, "i");
|
|
468
|
-
if (kwRegex.test(fontTitle)) {
|
|
469
|
-
fontTitle = fontTitle.replace(kwRegex, "").trim();
|
|
470
|
-
italicKW.push(kw);
|
|
471
|
-
}
|
|
472
|
-
if ((font == null ? void 0 : font.fullName) && typeof font.fullName === "string" && font.fullName.toLowerCase().includes(kw.toLowerCase())) {
|
|
473
|
-
if (!italicKW.includes(kw)) italicKW.push(kw);
|
|
474
|
-
}
|
|
475
|
-
});
|
|
476
|
-
return italicKW;
|
|
477
|
-
};
|
|
478
|
-
var formatFontTitle = (fontTitle, preserveShortenedNames = false) => {
|
|
479
|
-
const hasItalic = fontTitle.toLowerCase().includes("italic");
|
|
480
|
-
fontTitle = fontTitle.replace(/-/g, " ");
|
|
481
|
-
return fontTitle.replace(/\s+/g, " ").trim().split(" ").map((word) => {
|
|
482
|
-
if (hasItalic && word.toLowerCase() === "italic") return "Italic";
|
|
483
|
-
let fullWord = word;
|
|
484
|
-
if (!preserveShortenedNames) {
|
|
485
|
-
fullWord = reverseSpellingLookup(word) || word;
|
|
486
|
-
}
|
|
487
|
-
return fullWord[0].toUpperCase() + fullWord.slice(1);
|
|
488
|
-
}).join(" ");
|
|
489
|
-
};
|
|
490
|
-
var addItalicToFontTitle = (font, fontTitle, italicKW, style, preserveShortenedNames = false) => {
|
|
491
|
-
const hasItalicAngle = (font == null ? void 0 : font.italicAngle) !== 0;
|
|
492
|
-
const hasItalicInName = font == null ? void 0 : font.fullName.toLowerCase().includes("italic");
|
|
493
|
-
if (italicKW.length > 0 || hasItalicAngle || hasItalicInName) {
|
|
494
|
-
italicKW = [...new Set(italicKW)];
|
|
495
|
-
if (italicKW.length === 0 && (hasItalicAngle || hasItalicInName)) {
|
|
496
|
-
italicKW = ["Italic"];
|
|
497
|
-
}
|
|
498
|
-
if (!preserveShortenedNames) {
|
|
499
|
-
italicKW = italicKW.map((item) => reverseSpellingLookup(item) || item);
|
|
500
|
-
}
|
|
501
|
-
italicKW = [...new Set(italicKW)];
|
|
502
|
-
if (italicKW.length > 1 && italicKW.includes("Italic")) {
|
|
503
|
-
italicKW = ["Italic"];
|
|
504
|
-
}
|
|
505
|
-
const fontTitleLower = fontTitle.toLowerCase();
|
|
506
|
-
italicKW = italicKW.filter((keyword) => {
|
|
507
|
-
const keywordLower = keyword.toLowerCase();
|
|
508
|
-
const kwRegex = new RegExp(`\\b${keywordLower}\\b`);
|
|
509
|
-
const isSubstring = fontTitleLower.split(" ").some(
|
|
510
|
-
(word) => word.includes(keywordLower) || keywordLower.includes(word)
|
|
511
|
-
);
|
|
512
|
-
return !kwRegex.test(fontTitleLower) && !isSubstring;
|
|
513
|
-
});
|
|
514
|
-
if (italicKW.length > 0) {
|
|
515
|
-
fontTitle = fontTitle.trim() + " " + italicKW.join(" ");
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
return fontTitle;
|
|
519
|
-
};
|
|
520
|
-
var createFontObject = (id, fontTitle, title, font, variableFont, weightName, subfamilyName, file, originalFilename = null) => {
|
|
521
|
-
const fontObject = {
|
|
522
|
-
_key: (0, import_nanoid.nanoid)(),
|
|
523
|
-
_id: id,
|
|
524
|
-
title: fontTitle,
|
|
525
|
-
slug: { _type: "slug", current: id },
|
|
526
|
-
typefaceName: title,
|
|
527
|
-
style: (font == null ? void 0 : font.italicAngle) !== 0 || (font == null ? void 0 : font.fullName.toLowerCase().includes("italic")) ? "Italic" : "Regular",
|
|
528
|
-
variableFont,
|
|
529
|
-
weightName,
|
|
530
|
-
subfamily: subfamilyName,
|
|
531
|
-
normalWeight: true,
|
|
532
|
-
weight: Number(determineWeight(font, weightName)),
|
|
533
|
-
fileInput: {},
|
|
534
|
-
files: [file],
|
|
535
|
-
fontKit: font
|
|
536
|
-
};
|
|
537
|
-
if (originalFilename) {
|
|
538
|
-
fontObject.originalFilename = originalFilename;
|
|
539
|
-
}
|
|
540
|
-
return fontObject;
|
|
541
|
-
};
|
|
542
|
-
var determineWeight = (font, weightName) => {
|
|
543
|
-
var _a;
|
|
544
|
-
if ((_a = font["OS/2"]) == null ? void 0 : _a.usWeightClass) {
|
|
545
|
-
return Number(font["OS/2"].usWeightClass);
|
|
546
|
-
}
|
|
547
|
-
const wn = (weightName == null ? void 0 : weightName.toLowerCase()) || "";
|
|
548
|
-
if (/hairline|extra thin|extrathin/.test(wn)) return 100;
|
|
549
|
-
if (/thin|extra light|extralight/.test(wn)) return 200;
|
|
550
|
-
if (/light|book/.test(wn)) return 300;
|
|
551
|
-
if (/regular|normal/.test(wn)) return 400;
|
|
552
|
-
if (/medium/.test(wn)) return 500;
|
|
553
|
-
if (/semi bold|semibold/.test(wn)) return 600;
|
|
554
|
-
if (/extra bold|extrabold/.test(wn)) return 800;
|
|
555
|
-
if (/bold/.test(wn)) return 700;
|
|
556
|
-
if (/black|ultra/.test(wn)) return 900;
|
|
557
|
-
return 400;
|
|
558
|
-
};
|
|
559
|
-
var sortFontObjects = (fontsObjects) => {
|
|
560
|
-
return Object.fromEntries(
|
|
561
|
-
Object.entries(fontsObjects).sort((a, b) => {
|
|
562
|
-
const weightA = Number(a[1].weight);
|
|
563
|
-
const weightB = Number(b[1].weight);
|
|
564
|
-
if (weightA === weightB) {
|
|
565
|
-
if (a[1].style === "Regular" && b[1].style === "Italic") return -1;
|
|
566
|
-
if (a[1].style === "Italic" && b[1].style === "Regular") return 1;
|
|
567
|
-
return 0;
|
|
568
|
-
}
|
|
569
|
-
return weightA - weightB;
|
|
570
|
-
})
|
|
571
|
-
);
|
|
572
|
-
};
|
|
573
|
-
var logFontInfo = (id, fontTitle, font, fileName, subfamilyName, style, weightName, variableFont, italicKW) => {
|
|
574
|
-
console.log("=== Font Info ====");
|
|
575
|
-
console.log("Font id: ", id);
|
|
576
|
-
console.log("Font title: ", fontTitle);
|
|
577
|
-
console.log("Fontkit fullName: ", font.fullName);
|
|
578
|
-
console.log("Fontkit family name: ", font.familyName);
|
|
579
|
-
console.log("File name: ", fileName);
|
|
580
|
-
console.log("Subfamily: ", subfamilyName);
|
|
581
|
-
console.log("Style: ", style);
|
|
582
|
-
console.log("Weight: ", weightName);
|
|
583
|
-
console.log("Variable: ", variableFont);
|
|
584
|
-
console.log("italicKW: ", italicKW);
|
|
585
|
-
console.log("Font italic angle: ", (font == null ? void 0 : font.italicAngle) !== 0 || (font == null ? void 0 : font.fullName.toLowerCase().includes("italic")) ? "Italic" : "Regular");
|
|
586
|
-
console.log("=======");
|
|
587
|
-
};
|
|
588
28
|
|
|
589
|
-
// src/utils/uploadFontFiles.js
|
|
590
|
-
var import_nanoid3 = require("nanoid");
|
|
591
|
-
|
|
592
|
-
// src/utils/generateCssFile.js
|
|
593
|
-
var import_base_64 = __toESM(require("base-64"));
|
|
594
|
-
var import_buffer = require("buffer");
|
|
595
|
-
var fontkit2 = __toESM(require("fontkit"));
|
|
596
|
-
function _arrayBufferToBase64(buffer) {
|
|
597
|
-
var binary = "";
|
|
598
|
-
var bytes = new Uint8Array(buffer);
|
|
599
|
-
var len = bytes.byteLength;
|
|
600
|
-
for (var i = 0; i < len; i++) {
|
|
601
|
-
binary += String.fromCharCode(bytes[i]);
|
|
602
|
-
}
|
|
603
|
-
return import_base_64.default.encode(binary);
|
|
604
|
-
}
|
|
605
|
-
function buildVFDescriptors(font) {
|
|
606
|
-
const cssAxes = {};
|
|
607
|
-
const skipped = [];
|
|
608
|
-
try {
|
|
609
|
-
const va = font.variationAxes;
|
|
610
|
-
if (!va) return { descriptors: "", skipped: [] };
|
|
611
|
-
for (const [tag, axis] of Object.entries(va)) {
|
|
612
|
-
const lo = Math.min(axis.min, axis.max);
|
|
613
|
-
const hi = Math.max(axis.min, axis.max);
|
|
614
|
-
if (lo === hi) {
|
|
615
|
-
skipped.push(tag);
|
|
616
|
-
continue;
|
|
617
|
-
}
|
|
618
|
-
if (tag === "wght") {
|
|
619
|
-
cssAxes["font-weight"] = `${lo} ${hi}`;
|
|
620
|
-
} else if (tag === "wdth") {
|
|
621
|
-
cssAxes["font-stretch"] = `${lo}% ${hi}%`;
|
|
622
|
-
} else if (tag === "slnt") {
|
|
623
|
-
cssAxes["font-style"] = `oblique ${lo}deg ${hi}deg`;
|
|
624
|
-
} else if (tag === "ital" && !cssAxes["font-style"]) {
|
|
625
|
-
if (hi > 0) cssAxes["font-style"] = "italic";
|
|
626
|
-
else skipped.push(tag);
|
|
627
|
-
} else {
|
|
628
|
-
skipped.push(tag);
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
} catch (_) {
|
|
632
|
-
}
|
|
633
|
-
const descriptors = Object.entries(cssAxes).map(([k, v]) => `${k}:${v}`).join(";") + (Object.keys(cssAxes).length ? ";" : "");
|
|
634
|
-
return { descriptors, skipped };
|
|
635
|
-
}
|
|
636
|
-
var FALLBACK_STACKS = {
|
|
637
|
-
"sans-serif": "local('Arial'), local('Helvetica Neue'), local('Roboto'), local('Liberation Sans')",
|
|
638
|
-
"serif": "local('Georgia'), local('Times New Roman'), local('Times')",
|
|
639
|
-
"monospace": "local('Courier New'), local('Courier'), local('Menlo'), local('Monaco')",
|
|
640
|
-
// Display and script fonts have no universally suitable system fallback; default to sans-serif
|
|
641
|
-
"default": "local('Arial'), local('Helvetica Neue'), local('Roboto'), local('Liberation Sans')"
|
|
642
|
-
};
|
|
643
|
-
var FAMILY_CLASS_MAP = {
|
|
644
|
-
1: "serif",
|
|
645
|
-
2: "serif",
|
|
646
|
-
3: "serif",
|
|
647
|
-
4: "serif",
|
|
648
|
-
5: "serif",
|
|
649
|
-
7: "serif",
|
|
650
|
-
8: "sans-serif"
|
|
651
|
-
};
|
|
652
|
-
var SERIF_NAMES = /jubilat|corundum|dapifer|birra|daith/i;
|
|
653
|
-
var SANS_NAMES = /halyard|gamay|omnes|kit/i;
|
|
654
|
-
function detectFontCategory(font, fontName) {
|
|
655
|
-
var _a;
|
|
656
|
-
if (fontName && SERIF_NAMES.test(fontName)) return "serif";
|
|
657
|
-
if (fontName && SANS_NAMES.test(fontName)) return "sans-serif";
|
|
658
|
-
try {
|
|
659
|
-
const familyClass = ((_a = font["OS/2"]) == null ? void 0 : _a.sFamilyClass) ?? 0;
|
|
660
|
-
const highByte = familyClass >> 8 & 255;
|
|
661
|
-
return FAMILY_CLASS_MAP[highByte] ?? "default";
|
|
662
|
-
} catch {
|
|
663
|
-
return "default";
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
function calcFallbackData(arrayBuffer, fontName) {
|
|
667
|
-
try {
|
|
668
|
-
let font = fontkit2.create(import_buffer.Buffer.from(arrayBuffer));
|
|
669
|
-
let upm = font.unitsPerEm;
|
|
670
|
-
let category = detectFontCategory(font, fontName);
|
|
671
|
-
return {
|
|
672
|
-
fallbackSrc: FALLBACK_STACKS[category],
|
|
673
|
-
ascentOverride: `${(font.ascent / upm * 100).toFixed(2)}%`,
|
|
674
|
-
descentOverride: `${(Math.abs(font.descent) / upm * 100).toFixed(2)}%`,
|
|
675
|
-
lineGapOverride: `${(font.lineGap / upm * 100).toFixed(2)}%`
|
|
676
|
-
};
|
|
677
|
-
} catch (err) {
|
|
678
|
-
console.error("Failed to extract fallback font data:", err);
|
|
679
|
-
return {
|
|
680
|
-
fallbackSrc: FALLBACK_STACKS["default"],
|
|
681
|
-
ascentOverride: "100%",
|
|
682
|
-
descentOverride: "0%",
|
|
683
|
-
lineGapOverride: "0%"
|
|
684
|
-
};
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
async function generateCssFile({
|
|
688
|
-
woff2File,
|
|
689
|
-
fileInput,
|
|
690
|
-
language = null,
|
|
691
|
-
fileName,
|
|
692
|
-
fontName,
|
|
693
|
-
variableFont,
|
|
694
|
-
weight,
|
|
695
|
-
style = "Normal",
|
|
696
|
-
client
|
|
697
|
-
}) {
|
|
698
|
-
try {
|
|
699
|
-
let arrayBuffer = await woff2File.arrayBuffer();
|
|
700
|
-
let b64 = _arrayBufferToBase64(arrayBuffer);
|
|
701
|
-
let fontkitFont = fontkit2.create(import_buffer.Buffer.from(arrayBuffer));
|
|
702
|
-
let { fallbackSrc, ascentOverride, descentOverride, lineGapOverride } = calcFallbackData(arrayBuffer, fontName);
|
|
703
|
-
let cssString;
|
|
704
|
-
if (variableFont) {
|
|
705
|
-
let { descriptors, skipped } = buildVFDescriptors(fontkitFont);
|
|
706
|
-
let skipComment = skipped.length ? `/* axes present but have no @font-face descriptor: ${skipped.join(", ")}` + (skipped.includes("opsz") ? " \u2014 add font-optical-sizing:auto to your element CSS" : "") + " */" : "";
|
|
707
|
-
cssString = `${skipComment}@font-face{font-family:'${fontName}';src:url(data:application/font-woff2;charset=utf-8;base64,${b64})format('woff2-variations');${descriptors}font-display:swap;}`;
|
|
708
|
-
} else {
|
|
709
|
-
let fontStyle = style === "Italic" ? "italic" : "normal";
|
|
710
|
-
cssString = `@font-face{font-family:'${fontName}';src:url(data:application/font-woff2;charset=utf-8;base64,${b64})format('woff2');font-weight:${weight};font-style:${fontStyle};font-display:swap;}`;
|
|
711
|
-
}
|
|
712
|
-
let fallbackCssString = `@font-face{font-family:'${fontName} Fallback';src:${fallbackSrc};ascent-override:${ascentOverride};descent-override:${descentOverride};line-gap-override:${lineGapOverride};}`;
|
|
713
|
-
let uploadBuffer = import_buffer.Buffer.from(cssString + fallbackCssString, "utf-8");
|
|
714
|
-
let doc = await client.assets.upload("file", uploadBuffer, { filename: fileName + ".css" });
|
|
715
|
-
let newFileInput = language == null ? {
|
|
716
|
-
...fileInput,
|
|
717
|
-
css: {
|
|
718
|
-
_type: "file",
|
|
719
|
-
asset: {
|
|
720
|
-
_type: "reference",
|
|
721
|
-
_ref: doc._id
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
} : {
|
|
725
|
-
...fileInput,
|
|
726
|
-
[language]: {
|
|
727
|
-
...fileInput[language],
|
|
728
|
-
css: {
|
|
729
|
-
_type: "file",
|
|
730
|
-
asset: {
|
|
731
|
-
_type: "reference",
|
|
732
|
-
_ref: doc._id
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
};
|
|
737
|
-
return newFileInput;
|
|
738
|
-
} catch (err) {
|
|
739
|
-
console.error(err);
|
|
740
|
-
throw err;
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
29
|
|
|
744
|
-
// src/utils/generateFontData.js
|
|
745
|
-
var import_buffer2 = require("buffer");
|
|
746
|
-
var fontkit3 = __toESM(require("fontkit"));
|
|
747
|
-
async function generateFontData({ fileInput, url, fontKit, fontId, client, commit = true }) {
|
|
748
|
-
var _a;
|
|
749
|
-
if (fontId.startsWith("drafts.")) {
|
|
750
|
-
fontId = fontId.replace("drafts.", "");
|
|
751
|
-
}
|
|
752
|
-
console.log("generate-font-data ", fontId, commit);
|
|
753
|
-
let srcUrl;
|
|
754
|
-
if (!url || url == null) {
|
|
755
|
-
srcUrl = await client.fetch(`*[_id == $id]{url}`, { id: fileInput.ttf.asset._ref });
|
|
756
|
-
console.log("src url ", srcUrl);
|
|
757
|
-
srcUrl = srcUrl[0].url;
|
|
758
|
-
} else {
|
|
759
|
-
srcUrl = url;
|
|
760
|
-
}
|
|
761
|
-
let font = fontKit;
|
|
762
|
-
if (!fontKit || fontKit == null) {
|
|
763
|
-
let buffer = await fetch(srcUrl);
|
|
764
|
-
buffer = await buffer.arrayBuffer();
|
|
765
|
-
buffer = import_buffer2.Buffer.from(buffer);
|
|
766
|
-
font = fontkit3.create(buffer);
|
|
767
|
-
}
|
|
768
|
-
let variableAxes;
|
|
769
|
-
try {
|
|
770
|
-
variableAxes = font.variationAxes;
|
|
771
|
-
} catch (err) {
|
|
772
|
-
console.error("err: ", err);
|
|
773
|
-
}
|
|
774
|
-
let variableInstances;
|
|
775
|
-
try {
|
|
776
|
-
variableInstances = font.namedVariations;
|
|
777
|
-
} catch (e) {
|
|
778
|
-
console.log("variable instances 2 error : ", e.message);
|
|
779
|
-
let fvar = (_a = font == null ? void 0 : font.fvar) == null ? void 0 : _a.instance;
|
|
780
|
-
fvar == null ? void 0 : fvar.forEach((fv) => {
|
|
781
|
-
var _a2, _b, _c, _d, _e, _f;
|
|
782
|
-
if ((fv == null ? void 0 : fv.nameID) === 2) fv.name = (_c = (_b = (_a2 = font == null ? void 0 : font._tables) == null ? void 0 : _a2.name) == null ? void 0 : _b.records) == null ? void 0 : _c.fontSubfamily;
|
|
783
|
-
if ((fv == null ? void 0 : fv.nameID) === 17) fv.name = (_f = (_e = (_d = font == null ? void 0 : font._tables) == null ? void 0 : _d.name) == null ? void 0 : _e.records) == null ? void 0 : _f.preferredSubfamily;
|
|
784
|
-
});
|
|
785
|
-
variableInstances = {};
|
|
786
|
-
fvar.forEach((v) => {
|
|
787
|
-
let key = v.name;
|
|
788
|
-
if (typeof key === "object") {
|
|
789
|
-
key = Object.values(key)[0];
|
|
790
|
-
}
|
|
791
|
-
let coordKeys = Object.keys(variableAxes);
|
|
792
|
-
let coord = {};
|
|
793
|
-
coordKeys.forEach((ck, ckIndex) => {
|
|
794
|
-
coord[ck] = v.coord[ckIndex];
|
|
795
|
-
});
|
|
796
|
-
variableInstances[key] = coord;
|
|
797
|
-
});
|
|
798
|
-
}
|
|
799
|
-
console.log("font : ", font);
|
|
800
|
-
console.log("variable instances : ", variableInstances);
|
|
801
|
-
console.log("variable axes : ", variableAxes);
|
|
802
|
-
let opentypeFeatures = font.availableFeatures;
|
|
803
|
-
let glyphCount = font.numGlyphs;
|
|
804
|
-
let characterSet = font.characterSet;
|
|
805
|
-
let metaData = {
|
|
806
|
-
postscriptName: font.postscriptName,
|
|
807
|
-
fullName: font.fullName,
|
|
808
|
-
familyName: font.familyName,
|
|
809
|
-
subfamilyName: font.subfamilyName,
|
|
810
|
-
copyright: font.copyright,
|
|
811
|
-
version: font.version.replaceAll("Version ", ""),
|
|
812
|
-
genDate: (/* @__PURE__ */ new Date()).toISOString()
|
|
813
|
-
};
|
|
814
|
-
let metrics = {
|
|
815
|
-
unitsPerEm: font.unitsPerEm,
|
|
816
|
-
ascender: font.ascent,
|
|
817
|
-
descender: font.descent,
|
|
818
|
-
lineGap: font.lineGap,
|
|
819
|
-
underlinePosition: font.underlinePosition,
|
|
820
|
-
underlineThickness: font.underlineThickness,
|
|
821
|
-
italicAngle: font.italicAngle,
|
|
822
|
-
capHeight: font.capHeight,
|
|
823
|
-
xHeight: font.xHeight,
|
|
824
|
-
boundingBox: font.bbox
|
|
825
|
-
};
|
|
826
|
-
let variableFont = false;
|
|
827
|
-
if (variableAxes && variableAxes != null && Object.keys(variableAxes).length > 0 && variableInstances && variableInstances != null && Object.keys(variableInstances).length > 0) {
|
|
828
|
-
variableFont = true;
|
|
829
|
-
}
|
|
830
|
-
let patch = {
|
|
831
|
-
metrics,
|
|
832
|
-
metaData,
|
|
833
|
-
variableFont,
|
|
834
|
-
variableAxes: JSON.stringify(variableAxes),
|
|
835
|
-
variableInstances: JSON.stringify(variableInstances),
|
|
836
|
-
glyphCount,
|
|
837
|
-
opentypeFeatures: { chars: opentypeFeatures },
|
|
838
|
-
characterSet: { chars: characterSet }
|
|
839
|
-
};
|
|
840
|
-
console.log("data : ", patch);
|
|
841
|
-
if (commit) patch = await client.patch(fontId).set(patch).commit({ autoGenerateArrayKeys: true });
|
|
842
|
-
return patch;
|
|
843
|
-
}
|
|
844
30
|
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
console.log("Available static fonts:", staticFonts.map((sf) => sf.title));
|
|
893
|
-
const instanceMappings = [];
|
|
894
|
-
Object.keys(variableInstances).forEach((instanceName) => {
|
|
895
|
-
let matchingFont = null;
|
|
896
|
-
matchingFont = staticFonts.find((sf) => sf.title === instanceName);
|
|
897
|
-
if (!matchingFont && staticFonts.some((sf) => {
|
|
898
|
-
var _a;
|
|
899
|
-
return (_a = sf.metaData) == null ? void 0 : _a.fullName;
|
|
900
|
-
})) {
|
|
901
|
-
matchingFont = staticFonts.find((sf) => {
|
|
902
|
-
var _a, _b, _c, _d;
|
|
903
|
-
if (!((_a = sf.metaData) == null ? void 0 : _a.fullName)) return false;
|
|
904
|
-
let fullName = sf.metaData.fullName;
|
|
905
|
-
const WORDS_TO_REMOVE = ["VF", "var", "variable", "VAR", "vf"];
|
|
906
|
-
const variableName = (_c = (_b = font.metaData) == null ? void 0 : _b.familyName) == null ? void 0 : _c.replace(new RegExp(`\\b(${WORDS_TO_REMOVE.join("|")})\\b`, "gi"), "").replace(/\s{2,}/g, " ").trim();
|
|
907
|
-
if (variableName && fullName.startsWith(variableName)) {
|
|
908
|
-
fullName = fullName.substring(variableName.length).trim();
|
|
909
|
-
}
|
|
910
|
-
if (variableName) {
|
|
911
|
-
const words = variableName.split(/\s+/).map((w) => w.trim()).filter(Boolean);
|
|
912
|
-
if (words.length > 0) {
|
|
913
|
-
const regex = new RegExp(`\\b(${words.join("|")})\\b`, "gi");
|
|
914
|
-
const stripped = fullName.replace(regex, "").replace(/\s{2,}/g, " ").trim();
|
|
915
|
-
if (stripped !== "") fullName = stripped;
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
if (fullName.startsWith(font.typefaceName)) {
|
|
919
|
-
fullName = fullName.substring(font.typefaceName.length).trim();
|
|
920
|
-
}
|
|
921
|
-
if (((_d = sf.style) == null ? void 0 : _d.toLowerCase()) === "italic" && !fullName.toLowerCase().endsWith("italic") && !fullName.toLowerCase().endsWith("slanted")) {
|
|
922
|
-
fullName = fullName + " Italic";
|
|
923
|
-
}
|
|
924
|
-
if (fullName.trim().toLowerCase().endsWith("regular")) {
|
|
925
|
-
if (instanceName.trim().toLowerCase() + " regular" === fullName.trim().toLowerCase()) return true;
|
|
926
|
-
}
|
|
927
|
-
if (fullName.trim().toLowerCase().startsWith("regular")) {
|
|
928
|
-
if ("regular " + instanceName.trim().toLowerCase() === fullName.trim().toLowerCase()) return true;
|
|
929
|
-
}
|
|
930
|
-
if (fullName.trim().toLowerCase().endsWith("italic")) {
|
|
931
|
-
if (instanceName.trim().toLowerCase().endsWith("italic")) {
|
|
932
|
-
const k = instanceName.trim().toLowerCase().slice(0, -6).trim() + " regular italic";
|
|
933
|
-
if (k === fullName.trim().toLowerCase()) return true;
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
return fullName.trim().toLowerCase() === instanceName.trim().toLowerCase();
|
|
937
|
-
});
|
|
938
|
-
}
|
|
939
|
-
if (!matchingFont) {
|
|
940
|
-
const expandedName = instanceName.split(" ").map((word) => expandAbbreviations(word)).join(" ");
|
|
941
|
-
matchingFont = staticFonts.find((sf) => {
|
|
942
|
-
const nameWithoutTypeface = sf.title.replace(font.typefaceName, "").trim();
|
|
943
|
-
return nameWithoutTypeface === expandedName;
|
|
944
|
-
});
|
|
945
|
-
}
|
|
946
|
-
if (!matchingFont) {
|
|
947
|
-
const isItalic = instanceName.toLowerCase().includes("italic");
|
|
948
|
-
const weightTerms = [
|
|
949
|
-
{ term: "thin", weight: "100" },
|
|
950
|
-
{ term: "extralight", weight: "200" },
|
|
951
|
-
{ term: "extra light", weight: "200" },
|
|
952
|
-
{ term: "light", weight: "300" },
|
|
953
|
-
{ term: "regular", weight: "400" },
|
|
954
|
-
{ term: "normal", weight: "400" },
|
|
955
|
-
{ term: "medium", weight: "500" },
|
|
956
|
-
{ term: "semibold", weight: "600" },
|
|
957
|
-
{ term: "semi bold", weight: "600" },
|
|
958
|
-
{ term: "bold", weight: "700" },
|
|
959
|
-
{ term: "extrabold", weight: "800" },
|
|
960
|
-
{ term: "extra bold", weight: "800" },
|
|
961
|
-
{ term: "black", weight: "900" },
|
|
962
|
-
{ term: "heavy", weight: "900" }
|
|
963
|
-
];
|
|
964
|
-
let instanceWeight = "400";
|
|
965
|
-
for (const { term, weight } of weightTerms) {
|
|
966
|
-
if (instanceName.toLowerCase().includes(term)) {
|
|
967
|
-
instanceWeight = weight;
|
|
968
|
-
break;
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
matchingFont = staticFonts.find(
|
|
972
|
-
(sf) => sf.weight === instanceWeight && (isItalic && sf.style === "Italic" || !isItalic && sf.style === "Regular")
|
|
973
|
-
);
|
|
974
|
-
}
|
|
975
|
-
if (!matchingFont) {
|
|
976
|
-
matchingFont = staticFonts.find((sf) => {
|
|
977
|
-
if (!sf.weightName) return false;
|
|
978
|
-
const cleanInstance = instanceName.toLowerCase().replace(/italic/i, "").trim();
|
|
979
|
-
const cleanWeight = sf.weightName.toLowerCase().replace(/italic/i, "").trim();
|
|
980
|
-
return cleanInstance === cleanWeight;
|
|
981
|
-
});
|
|
982
|
-
}
|
|
983
|
-
if (!matchingFont && staticFonts.some((sf) => {
|
|
984
|
-
var _a;
|
|
985
|
-
return (_a = sf.metaData) == null ? void 0 : _a.fullName;
|
|
986
|
-
})) {
|
|
987
|
-
matchingFont = staticFonts.find((sf) => {
|
|
988
|
-
var _a;
|
|
989
|
-
if (!((_a = sf.metaData) == null ? void 0 : _a.fullName)) return false;
|
|
990
|
-
const typefacePattern = new RegExp(`^${font.typefaceName}\\s+`, "i");
|
|
991
|
-
const stylePart = sf.metaData.fullName.replace(typefacePattern, "").trim();
|
|
992
|
-
return instanceName.toLowerCase() === stylePart.toLowerCase();
|
|
993
|
-
});
|
|
994
|
-
}
|
|
995
|
-
console.log(`Instance "${instanceName}" matched with:`, matchingFont ? matchingFont.title : "No match found");
|
|
996
|
-
instanceMappings.push({
|
|
997
|
-
key: instanceName,
|
|
998
|
-
value: matchingFont ? { _type: "reference", _ref: matchingFont._id, _weak: true } : null,
|
|
999
|
-
_key: (0, import_nanoid2.nanoid)()
|
|
1000
|
-
});
|
|
1001
|
-
});
|
|
1002
|
-
return instanceMappings;
|
|
1003
|
-
};
|
|
1004
|
-
var parseVariableFontInstances_default = parseVariableFontInstances;
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
var _chunkJCDZ7SWZjs = require('./chunk-JCDZ7SWZ.js');
|
|
64
|
+
|
|
65
|
+
// src/components/BatchUploadFonts.jsx
|
|
66
|
+
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
|
67
|
+
var _ui = require('@sanity/ui');
|
|
68
|
+
var _icons = require('@sanity/icons');
|
|
69
|
+
var _sanity = require('sanity');
|
|
70
|
+
|
|
71
|
+
// src/hooks/useSanityClient.js
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
function useSanityClient() {
|
|
75
|
+
const client = _sanity.useClient.call(void 0, { apiVersion: "2021-10-23" });
|
|
76
|
+
return _react.useMemo.call(void 0, () => client, [client]);
|
|
77
|
+
}
|
|
1005
78
|
|
|
1006
79
|
// src/utils/uploadFontFiles.js
|
|
80
|
+
var _nanoid = require('nanoid');
|
|
1007
81
|
var uploadFontFiles = async (fontsObjects, subfamilies, client, inputPrice, stylesObject, setStatus, setError, preserveFileNames = false) => {
|
|
1008
82
|
let fontRefs = [];
|
|
1009
83
|
let variableRefs = [];
|
|
@@ -1040,7 +114,7 @@ var uploadFontFiles = async (fontsObjects, subfamilies, client, inputPrice, styl
|
|
|
1040
114
|
if (fileType === "woff2") {
|
|
1041
115
|
console.log(`[${i + 1}/${fontObjectKeys.length}][${j + 1}/${files.length}] Generating CSS for: ${fontObject.title}`);
|
|
1042
116
|
setStatus(`[${i + 1}/${fontObjectKeys.length}][${j + 1}/${files.length}] Generating CSS for: ${fontObject.title}`);
|
|
1043
|
-
newFileInput = await generateCssFile({
|
|
117
|
+
newFileInput = await _chunkJCDZ7SWZjs.generateCssFile.call(void 0, {
|
|
1044
118
|
woff2File: file,
|
|
1045
119
|
fileInput: newFileInput,
|
|
1046
120
|
fontName: fontObject.title,
|
|
@@ -1054,7 +128,7 @@ var uploadFontFiles = async (fontsObjects, subfamilies, client, inputPrice, styl
|
|
|
1054
128
|
if (fileType === "ttf") {
|
|
1055
129
|
console.log(`[${i + 1}/${fontObjectKeys.length}][${j + 1}/${files.length}] Generating font data for: ${fontObject.title}`);
|
|
1056
130
|
setStatus(`[${i + 1}/${fontObjectKeys.length}][${j + 1}/${files.length}] Generating font data for: ${fontObject.title}`);
|
|
1057
|
-
const metadata = await generateFontData({
|
|
131
|
+
const metadata = await _chunkJCDZ7SWZjs.generateFontData.call(void 0, {
|
|
1058
132
|
fontId: fontObject._id,
|
|
1059
133
|
url: baseAsset.url,
|
|
1060
134
|
fontKit,
|
|
@@ -1100,7 +174,7 @@ var determineFileType = (file) => {
|
|
|
1100
174
|
if (file.name.endsWith(".svg")) return "svg";
|
|
1101
175
|
return "";
|
|
1102
176
|
};
|
|
1103
|
-
var
|
|
177
|
+
var resolveExistingFont2 = async (font, client) => {
|
|
1104
178
|
const result = { exact: null, candidates: [], recommendation: "create" };
|
|
1105
179
|
try {
|
|
1106
180
|
const idMatches = await client.fetch(
|
|
@@ -1161,13 +235,13 @@ var resolveExistingFont = async (font, client) => {
|
|
|
1161
235
|
};
|
|
1162
236
|
var createOrUpdateFontDocument = async (font, client, setError) => {
|
|
1163
237
|
try {
|
|
1164
|
-
const { exact, candidates, recommendation } = await
|
|
238
|
+
const { exact, candidates, recommendation } = await resolveExistingFont2(font, client);
|
|
1165
239
|
const { files, fontKit } = font;
|
|
1166
240
|
delete font.files;
|
|
1167
241
|
delete font.fontKit;
|
|
1168
242
|
delete font.originalFilename;
|
|
1169
243
|
if (font.variableFont && font.variableInstances) {
|
|
1170
|
-
const instanceMappings = await parseVariableFontInstances(font, client);
|
|
244
|
+
const instanceMappings = await _chunkJCDZ7SWZjs.parseVariableFontInstances.call(void 0, font, client);
|
|
1171
245
|
if (instanceMappings.length > 0) {
|
|
1172
246
|
font.variableInstanceReferences = instanceMappings;
|
|
1173
247
|
}
|
|
@@ -1183,7 +257,7 @@ var createOrUpdateFontDocument = async (font, client, setError) => {
|
|
|
1183
257
|
fontResponse = await createNewFont(font, client);
|
|
1184
258
|
}
|
|
1185
259
|
return {
|
|
1186
|
-
_key: (0,
|
|
260
|
+
_key: _nanoid.nanoid.call(void 0, ),
|
|
1187
261
|
_type: "reference",
|
|
1188
262
|
_ref: fontResponse._id,
|
|
1189
263
|
_weak: true
|
|
@@ -1226,7 +300,7 @@ var createNewFont = async (font, client) => {
|
|
|
1226
300
|
console.log("Creating new font:", font._id, font.title);
|
|
1227
301
|
if (font.metaData) cleanMetadataValues(font);
|
|
1228
302
|
const newDocument = {
|
|
1229
|
-
_key: (0,
|
|
303
|
+
_key: _nanoid.nanoid.call(void 0, ),
|
|
1230
304
|
_id: font._id,
|
|
1231
305
|
_type: "font",
|
|
1232
306
|
...font
|
|
@@ -1263,89 +337,7 @@ var addToVariableRefs = (fontRef, font, variableRefs, stylesObject) => {
|
|
|
1263
337
|
}
|
|
1264
338
|
};
|
|
1265
339
|
|
|
1266
|
-
// src/utils/updateTypefaceDocument.js
|
|
1267
|
-
var import_nanoid4 = require("nanoid");
|
|
1268
|
-
var updateTypefaceDocument = async (doc_id, fontRefs, variableRefs, subfamilies, uniqueSubfamilies, subfamiliesArray, preferredStyleRef, newPreferredStyle, stylesObject, client, setStatus, setError) => {
|
|
1269
|
-
console.log("Updating typeface document with new fonts:", { fontRefs, variableRefs, subfamilies, uniqueSubfamilies });
|
|
1270
|
-
setStatus("Updating typeface references...");
|
|
1271
|
-
let patch = {
|
|
1272
|
-
"styles.fonts": stylesObject.fonts ? [...stylesObject.fonts, ...fontRefs] : [...fontRefs],
|
|
1273
|
-
"styles.variableFont": (stylesObject == null ? void 0 : stylesObject.variableFont) ? [...stylesObject.variableFont, ...variableRefs] : [...variableRefs]
|
|
1274
|
-
};
|
|
1275
|
-
setStatus("Organising font subfamilies...");
|
|
1276
|
-
subfamiliesArray = subfamiliesArray || [];
|
|
1277
|
-
uniqueSubfamilies.forEach((subfamilyName) => {
|
|
1278
|
-
if (!subfamiliesArray.find((sf) => sf.title === subfamilyName)) {
|
|
1279
|
-
subfamiliesArray.push({
|
|
1280
|
-
title: subfamilyName,
|
|
1281
|
-
_key: (0, import_nanoid4.nanoid)(),
|
|
1282
|
-
_type: "object",
|
|
1283
|
-
fonts: []
|
|
1284
|
-
});
|
|
1285
|
-
}
|
|
1286
|
-
});
|
|
1287
|
-
if (subfamiliesArray.length > 0) {
|
|
1288
|
-
Object.entries(subfamilies).forEach(([id, subfamilyName]) => {
|
|
1289
|
-
if (id.toLowerCase().includes("vf")) return;
|
|
1290
|
-
const subfamilyIndex = subfamiliesArray.findIndex((sf) => sf.title === subfamilyName);
|
|
1291
|
-
if (subfamilyIndex !== -1) {
|
|
1292
|
-
subfamiliesArray[subfamilyIndex].fonts.push({
|
|
1293
|
-
_ref: id,
|
|
1294
|
-
_key: (0, import_nanoid4.nanoid)(),
|
|
1295
|
-
_type: "reference",
|
|
1296
|
-
_weak: true
|
|
1297
|
-
});
|
|
1298
|
-
}
|
|
1299
|
-
});
|
|
1300
|
-
subfamiliesArray = subfamiliesArray.map((subfamily) => ({
|
|
1301
|
-
...subfamily,
|
|
1302
|
-
fonts: subfamily.fonts.filter(
|
|
1303
|
-
(font, index, self) => index === self.findIndex((f) => f._ref === font._ref)
|
|
1304
|
-
)
|
|
1305
|
-
}));
|
|
1306
|
-
}
|
|
1307
|
-
patch["styles.subfamilies"] = subfamiliesArray;
|
|
1308
|
-
await updatePreferredStyle(doc_id, preferredStyleRef, newPreferredStyle, patch, client);
|
|
1309
|
-
console.log("doc_id: ", doc_id);
|
|
1310
|
-
console.log("Typeface patch: ", patch);
|
|
1311
|
-
console.log("New preferred style: ", newPreferredStyle);
|
|
1312
|
-
console.log("SubfamiliesArray:", subfamiliesArray);
|
|
1313
|
-
try {
|
|
1314
|
-
await client.patch(doc_id).set(patch).commit();
|
|
1315
|
-
console.log(`Updated document: ${doc_id}`);
|
|
1316
|
-
if (doc_id.startsWith("drafts.")) {
|
|
1317
|
-
await updatePublishedDocument(doc_id, patch, client);
|
|
1318
|
-
}
|
|
1319
|
-
} catch (err) {
|
|
1320
|
-
console.error("Error updating document:", err.message);
|
|
1321
|
-
setStatus("Error updating typeface");
|
|
1322
|
-
setError(true);
|
|
1323
|
-
}
|
|
1324
|
-
};
|
|
1325
|
-
var updatePreferredStyle = async (doc_id, preferredStyleRef, newPreferredStyle, patch, client) => {
|
|
1326
|
-
const isCurrentlyEmpty = !(preferredStyleRef == null ? void 0 : preferredStyleRef._ref) || preferredStyleRef._ref === "" || preferredStyleRef._ref === null;
|
|
1327
|
-
const hasCandidate = (newPreferredStyle == null ? void 0 : newPreferredStyle._ref) && newPreferredStyle._ref !== "";
|
|
1328
|
-
if (isCurrentlyEmpty && hasCandidate) {
|
|
1329
|
-
patch.preferredStyle = {
|
|
1330
|
-
_type: "reference",
|
|
1331
|
-
_ref: newPreferredStyle._ref,
|
|
1332
|
-
_weak: true
|
|
1333
|
-
};
|
|
1334
|
-
}
|
|
1335
|
-
};
|
|
1336
|
-
var updatePublishedDocument = async (doc_id, patch, client) => {
|
|
1337
|
-
const publishedId = doc_id.replace("drafts.", "");
|
|
1338
|
-
const publishedDoc = await client.fetch(`*[_id == $publishedId]`, { publishedId }).then((res) => res[0]);
|
|
1339
|
-
if (publishedDoc) {
|
|
1340
|
-
await client.patch(publishedId).set(patch).commit();
|
|
1341
|
-
console.log(`Updated published document: ${publishedId}`);
|
|
1342
|
-
} else {
|
|
1343
|
-
console.log(`No published document found for ${publishedId}, skipping`);
|
|
1344
|
-
}
|
|
1345
|
-
};
|
|
1346
|
-
|
|
1347
340
|
// src/utils/regenerateFontData.js
|
|
1348
|
-
var fontkit4 = __toESM(require("fontkit"));
|
|
1349
341
|
var renameFontDocuments = async ({
|
|
1350
342
|
client,
|
|
1351
343
|
typefaceName,
|
|
@@ -1414,9 +406,9 @@ var renameFontDocuments = async ({
|
|
|
1414
406
|
const res = await fetch(ttfAsset.url);
|
|
1415
407
|
file = await res.blob();
|
|
1416
408
|
}
|
|
1417
|
-
const fontBuffer = await readFontFile(file);
|
|
1418
|
-
const font =
|
|
1419
|
-
const { weightName, subfamilyName, fontTitle } = extractFontMetadata(
|
|
409
|
+
const fontBuffer = await _chunkJCDZ7SWZjs.readFontFile.call(void 0, file);
|
|
410
|
+
const font = await _chunkJCDZ7SWZjs.parseFont.call(void 0, fontBuffer, `${fontDoc._id}.ttf`);
|
|
411
|
+
const { weightName, subfamilyName, fontTitle } = _chunkJCDZ7SWZjs.extractFontMetadata.call(void 0,
|
|
1420
412
|
font,
|
|
1421
413
|
typefaceName,
|
|
1422
414
|
weightKeywordList,
|
|
@@ -1526,45 +518,31 @@ var updateFontPrices = async ({
|
|
|
1526
518
|
};
|
|
1527
519
|
|
|
1528
520
|
// src/components/StatusDisplay.jsx
|
|
1529
|
-
|
|
1530
|
-
|
|
521
|
+
|
|
522
|
+
|
|
1531
523
|
var StatusDisplay = ({ status, error, action }) => {
|
|
1532
|
-
return /* @__PURE__ */
|
|
524
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { paddingTop: 1, paddingBottom: 3, align: "center", justify: "space-between" }, /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { align: "center", gap: 2 }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1 }, "Status:"), /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, style: { color: error ? "red" : "green" } }, status)), action && action);
|
|
1533
525
|
};
|
|
1534
526
|
var StatusDisplay_default = StatusDisplay;
|
|
1535
527
|
|
|
1536
|
-
// src/components/PriceInput.jsx
|
|
1537
|
-
var import_react3 = __toESM(require("react"));
|
|
1538
|
-
var import_ui2 = require("@sanity/ui");
|
|
1539
|
-
var PriceInput = ({ inputPrice, handleInputChange }) => /* @__PURE__ */ import_react3.default.createElement(import_ui2.Flex, { align: "center", gap: 2 }, /* @__PURE__ */ import_react3.default.createElement(import_ui2.Text, { size: 1, muted: true }, "Price:"), /* @__PURE__ */ import_react3.default.createElement(import_ui2.Text, { size: 1, muted: true }, "$"), /* @__PURE__ */ import_react3.default.createElement(
|
|
1540
|
-
"input",
|
|
1541
|
-
{
|
|
1542
|
-
value: inputPrice,
|
|
1543
|
-
onChange: handleInputChange,
|
|
1544
|
-
type: "number",
|
|
1545
|
-
style: { textAlign: "end", padding: "5px", maxWidth: "75px" }
|
|
1546
|
-
}
|
|
1547
|
-
), /* @__PURE__ */ import_react3.default.createElement(import_ui2.Text, { size: 1, muted: true }, "per style"));
|
|
1548
|
-
var PriceInput_default = PriceInput;
|
|
1549
|
-
|
|
1550
528
|
// src/components/RegenerateSubfamiliesComponent.jsx
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
|
|
1555
533
|
var RegenerateSubfamiliesComponent = () => {
|
|
1556
|
-
const [status, setStatus] = (0,
|
|
1557
|
-
const [ready, setReady] = (0,
|
|
1558
|
-
const [error, setError] = (0,
|
|
534
|
+
const [status, setStatus] = _react.useState.call(void 0, "");
|
|
535
|
+
const [ready, setReady] = _react.useState.call(void 0, true);
|
|
536
|
+
const [error, setError] = _react.useState.call(void 0, false);
|
|
1559
537
|
const client = useSanityClient();
|
|
1560
|
-
const doc_id = (0,
|
|
1561
|
-
const title = (0,
|
|
1562
|
-
const slug = (0,
|
|
1563
|
-
const stylesObject = (0,
|
|
538
|
+
const doc_id = _sanity.useFormValue.call(void 0, ["_id"]);
|
|
539
|
+
const title = _sanity.useFormValue.call(void 0, ["title"]);
|
|
540
|
+
const slug = _sanity.useFormValue.call(void 0, ["slug"]);
|
|
541
|
+
const stylesObject = _sanity.useFormValue.call(void 0, ["styles"]) || { fonts: [], variableFont: [] };
|
|
1564
542
|
const handleClick = () => {
|
|
1565
543
|
regenerateSubfamilies({ title, stylesObject, slug, doc_id, client, setStatus, setReady, setError });
|
|
1566
544
|
};
|
|
1567
|
-
return /* @__PURE__ */
|
|
545
|
+
return /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, status && /* @__PURE__ */ _react2.default.createElement(_ui.Box, { padding: 3, style: { borderRadius: "4px", marginBottom: "10px" } }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, style: { color: error ? "red" : "green" } }, status)), /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "ghost", tone: "primary", width: "fill", padding: 3, onClick: handleClick, disabled: !ready }, /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 2 }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { align: "center" }, "Regenerate Subfamilies"))));
|
|
1568
546
|
};
|
|
1569
547
|
var regenerateSubfamilies = async ({ title, stylesObject, slug, doc_id, client, setStatus, setReady, setError }) => {
|
|
1570
548
|
try {
|
|
@@ -1610,7 +588,7 @@ var groupFontsBySubfamily = (fonts) => {
|
|
|
1610
588
|
if ((_a = font.title) == null ? void 0 : _a.includes("VF")) {
|
|
1611
589
|
subfamilies[`VF_${font.title}`] = [font];
|
|
1612
590
|
} else {
|
|
1613
|
-
const subfamilyName = font.subfamily ? expandAbbreviations(font.subfamily) : "Regular";
|
|
591
|
+
const subfamilyName = font.subfamily ? _chunkJCDZ7SWZjs.expandAbbreviations.call(void 0, font.subfamily) : "Regular";
|
|
1614
592
|
if (!subfamilies[subfamilyName]) subfamilies[subfamilyName] = [];
|
|
1615
593
|
subfamilies[subfamilyName].push(font);
|
|
1616
594
|
}
|
|
@@ -1620,11 +598,11 @@ var groupFontsBySubfamily = (fonts) => {
|
|
|
1620
598
|
var createSubfamiliesArray = (subfamilies) => {
|
|
1621
599
|
return Object.keys(subfamilies).map((subfamilyName) => ({
|
|
1622
600
|
title: subfamilyName,
|
|
1623
|
-
_key: (0,
|
|
601
|
+
_key: _nanoid.nanoid.call(void 0, ),
|
|
1624
602
|
_type: "object",
|
|
1625
603
|
fonts: subfamilies[subfamilyName].map((font) => ({
|
|
1626
604
|
_ref: font._id,
|
|
1627
|
-
_key: (0,
|
|
605
|
+
_key: _nanoid.nanoid.call(void 0, ),
|
|
1628
606
|
_type: "reference",
|
|
1629
607
|
_weak: true
|
|
1630
608
|
}))
|
|
@@ -1658,6 +636,7 @@ var updateTypefaceSubfamilies = async (doc_id, stylesObject, newSubfamiliesArray
|
|
|
1658
636
|
};
|
|
1659
637
|
|
|
1660
638
|
// src/components/BatchUploadFonts.jsx
|
|
639
|
+
var UploadModal2 = _react.lazy.call(void 0, () => Promise.resolve().then(() => _interopRequireWildcard(require("./UploadModal-WPK2CXLR.js"))));
|
|
1661
640
|
var ACCEPTED_EXTENSIONS = ["ttf", "otf", "woff", "woff2", "eot", "svg"];
|
|
1662
641
|
var formatElapsed = (s) => {
|
|
1663
642
|
const m = Math.floor(s / 60);
|
|
@@ -1665,28 +644,29 @@ var formatElapsed = (s) => {
|
|
|
1665
644
|
return m > 0 ? `${m}m ${sec}s` : `${sec}s`;
|
|
1666
645
|
};
|
|
1667
646
|
var BatchUploadFonts = () => {
|
|
1668
|
-
const [status, setStatus] = (0,
|
|
1669
|
-
const [ready, setReady] = (0,
|
|
1670
|
-
const [inputPrice, setInputPrice] = (0,
|
|
1671
|
-
const [error, setError] = (0,
|
|
1672
|
-
const [preserveShortenedNames, setPreserveShortenedNames] = (0,
|
|
1673
|
-
const [preserveFileNames, setPreserveFileNames] = (0,
|
|
1674
|
-
const [showUtilities, setShowUtilities] = (0,
|
|
1675
|
-
const [pendingFiles, setPendingFiles] = (0,
|
|
1676
|
-
const [isDragging, setIsDragging] = (0,
|
|
1677
|
-
const [elapsedSeconds, setElapsedSeconds] = (0,
|
|
1678
|
-
const
|
|
1679
|
-
const
|
|
1680
|
-
const
|
|
647
|
+
const [status, setStatus] = _react.useState.call(void 0, "ready");
|
|
648
|
+
const [ready, setReady] = _react.useState.call(void 0, true);
|
|
649
|
+
const [inputPrice, setInputPrice] = _react.useState.call(void 0, "0");
|
|
650
|
+
const [error, setError] = _react.useState.call(void 0, false);
|
|
651
|
+
const [preserveShortenedNames, setPreserveShortenedNames] = _react.useState.call(void 0, true);
|
|
652
|
+
const [preserveFileNames, setPreserveFileNames] = _react.useState.call(void 0, false);
|
|
653
|
+
const [showUtilities, setShowUtilities] = _react.useState.call(void 0, false);
|
|
654
|
+
const [pendingFiles, setPendingFiles] = _react.useState.call(void 0, []);
|
|
655
|
+
const [isDragging, setIsDragging] = _react.useState.call(void 0, false);
|
|
656
|
+
const [elapsedSeconds, setElapsedSeconds] = _react.useState.call(void 0, 0);
|
|
657
|
+
const [showUploadModal, setShowUploadModal] = _react.useState.call(void 0, false);
|
|
658
|
+
const fileInputRef = _react.useRef.call(void 0, null);
|
|
659
|
+
const elapsedTimerRef = _react.useRef.call(void 0, null);
|
|
660
|
+
const wakeLockRef = _react.useRef.call(void 0, null);
|
|
1681
661
|
const client = useSanityClient();
|
|
1682
|
-
const doc_id = (0,
|
|
1683
|
-
const title = (0,
|
|
1684
|
-
const preferredStyleRef = (0,
|
|
1685
|
-
const slug = (0,
|
|
1686
|
-
const stylesObject = (0,
|
|
662
|
+
const doc_id = _sanity.useFormValue.call(void 0, ["_id"]);
|
|
663
|
+
const title = _sanity.useFormValue.call(void 0, ["title"]);
|
|
664
|
+
const preferredStyleRef = _sanity.useFormValue.call(void 0, ["preferredStyle"]);
|
|
665
|
+
const slug = _sanity.useFormValue.call(void 0, ["slug"]);
|
|
666
|
+
const stylesObject = _sanity.useFormValue.call(void 0, ["styles"]) || { fonts: [], variableFont: [] };
|
|
1687
667
|
const subfamiliesArray = (stylesObject == null ? void 0 : stylesObject.subfamilies) || [];
|
|
1688
|
-
const { weightKeywordList, italicKeywordList } = (0,
|
|
1689
|
-
(0,
|
|
668
|
+
const { weightKeywordList, italicKeywordList } = _react.useMemo.call(void 0, () => _chunkJCDZ7SWZjs.generateStyleKeywords.call(void 0, ), []);
|
|
669
|
+
_react.useEffect.call(void 0, () => {
|
|
1690
670
|
if (ready !== true) {
|
|
1691
671
|
setElapsedSeconds(0);
|
|
1692
672
|
elapsedTimerRef.current = setInterval(() => {
|
|
@@ -1697,7 +677,7 @@ var BatchUploadFonts = () => {
|
|
|
1697
677
|
}
|
|
1698
678
|
return () => clearInterval(elapsedTimerRef.current);
|
|
1699
679
|
}, [ready]);
|
|
1700
|
-
(0,
|
|
680
|
+
_react.useEffect.call(void 0, () => {
|
|
1701
681
|
if (ready !== true) {
|
|
1702
682
|
const handler = (e) => {
|
|
1703
683
|
e.preventDefault();
|
|
@@ -1707,7 +687,7 @@ var BatchUploadFonts = () => {
|
|
|
1707
687
|
return () => window.removeEventListener("beforeunload", handler);
|
|
1708
688
|
}
|
|
1709
689
|
}, [ready]);
|
|
1710
|
-
(0,
|
|
690
|
+
_react.useEffect.call(void 0, () => {
|
|
1711
691
|
var _a;
|
|
1712
692
|
if (ready !== true) {
|
|
1713
693
|
(_a = navigator.wakeLock) == null ? void 0 : _a.request("screen").then((lock) => {
|
|
@@ -1762,32 +742,32 @@ var BatchUploadFonts = () => {
|
|
|
1762
742
|
setStatus2("Upload completed successfully");
|
|
1763
743
|
}
|
|
1764
744
|
};
|
|
1765
|
-
const handleFileSelect = (0,
|
|
745
|
+
const handleFileSelect = _react.useCallback.call(void 0, (e) => {
|
|
1766
746
|
const files = filterFontFiles(e.target.files);
|
|
1767
747
|
if (files.length > 0) setPendingFiles((prev) => [...prev, ...files]);
|
|
1768
748
|
e.target.value = "";
|
|
1769
749
|
}, []);
|
|
1770
|
-
const handleRemoveFile = (0,
|
|
750
|
+
const handleRemoveFile = _react.useCallback.call(void 0, (file) => {
|
|
1771
751
|
setPendingFiles((prev) => prev.filter((f) => f !== file));
|
|
1772
752
|
}, []);
|
|
1773
|
-
const handleDragEnter = (0,
|
|
753
|
+
const handleDragEnter = _react.useCallback.call(void 0, (e) => {
|
|
1774
754
|
e.preventDefault();
|
|
1775
755
|
setIsDragging(true);
|
|
1776
756
|
}, []);
|
|
1777
|
-
const handleDragOver = (0,
|
|
757
|
+
const handleDragOver = _react.useCallback.call(void 0, (e) => {
|
|
1778
758
|
e.preventDefault();
|
|
1779
759
|
}, []);
|
|
1780
|
-
const handleDragLeave = (0,
|
|
760
|
+
const handleDragLeave = _react.useCallback.call(void 0, (e) => {
|
|
1781
761
|
e.preventDefault();
|
|
1782
762
|
setIsDragging(false);
|
|
1783
763
|
}, []);
|
|
1784
|
-
const handleDrop = (0,
|
|
764
|
+
const handleDrop = _react.useCallback.call(void 0, (e) => {
|
|
1785
765
|
e.preventDefault();
|
|
1786
766
|
setIsDragging(false);
|
|
1787
767
|
const files = filterFontFiles(e.dataTransfer.files);
|
|
1788
768
|
if (files.length > 0) setPendingFiles((prev) => [...prev, ...files]);
|
|
1789
769
|
}, []);
|
|
1790
|
-
const handleConfirmUpload = (0,
|
|
770
|
+
const handleConfirmUpload = _react.useCallback.call(void 0, async () => {
|
|
1791
771
|
try {
|
|
1792
772
|
setStatus("Uploading font files...");
|
|
1793
773
|
setReady("upload");
|
|
@@ -1798,7 +778,7 @@ var BatchUploadFonts = () => {
|
|
|
1798
778
|
}
|
|
1799
779
|
const sortedFiles = sortFilesByType(pendingFiles);
|
|
1800
780
|
setPendingFiles([]);
|
|
1801
|
-
const { fontsObjects, subfamilies, uniqueSubfamilies, newPreferredStyle, failedFiles } = await processFontFiles(
|
|
781
|
+
const { fontsObjects, subfamilies, uniqueSubfamilies, newPreferredStyle, failedFiles } = await _chunkJCDZ7SWZjs.processFontFiles.call(void 0,
|
|
1802
782
|
sortedFiles,
|
|
1803
783
|
title,
|
|
1804
784
|
weightKeywordList,
|
|
@@ -1817,7 +797,7 @@ var BatchUploadFonts = () => {
|
|
|
1817
797
|
setError,
|
|
1818
798
|
preserveFileNames
|
|
1819
799
|
);
|
|
1820
|
-
await updateTypefaceDocument(
|
|
800
|
+
await _chunkJCDZ7SWZjs.updateTypefaceDocument.call(void 0,
|
|
1821
801
|
doc_id,
|
|
1822
802
|
fontRefs,
|
|
1823
803
|
variableRefs,
|
|
@@ -1840,7 +820,7 @@ var BatchUploadFonts = () => {
|
|
|
1840
820
|
setReady(true);
|
|
1841
821
|
setError(false);
|
|
1842
822
|
}, [pendingFiles, stylesObject, title, slug, doc_id, inputPrice, weightKeywordList, italicKeywordList, client, preferredStyleRef, subfamiliesArray, preserveShortenedNames, preserveFileNames]);
|
|
1843
|
-
const handleRenameExistingFonts = (0,
|
|
823
|
+
const handleRenameExistingFonts = _react.useCallback.call(void 0, async () => {
|
|
1844
824
|
try {
|
|
1845
825
|
setStatus("Processing font documents...");
|
|
1846
826
|
setReady("rename");
|
|
@@ -1869,14 +849,14 @@ var BatchUploadFonts = () => {
|
|
|
1869
849
|
}
|
|
1870
850
|
setReady(true);
|
|
1871
851
|
}, [title, client, slug, weightKeywordList, italicKeywordList, preserveShortenedNames]);
|
|
1872
|
-
const handleChangeFontPrice = (0,
|
|
852
|
+
const handleChangeFontPrice = _react.useCallback.call(void 0, async () => {
|
|
1873
853
|
setStatus("Updating font prices...");
|
|
1874
854
|
setReady("price");
|
|
1875
855
|
setError(false);
|
|
1876
856
|
await updateFontPrices({ client, title, slug, inputPrice, doc_id, setStatus, setError });
|
|
1877
857
|
setReady(true);
|
|
1878
858
|
}, [title, slug, client, doc_id, inputPrice]);
|
|
1879
|
-
const handleRegenerateCssFiles = (0,
|
|
859
|
+
const handleRegenerateCssFiles = _react.useCallback.call(void 0, async () => {
|
|
1880
860
|
var _a, _b, _c, _d;
|
|
1881
861
|
try {
|
|
1882
862
|
setStatus("Regenerating CSS files...");
|
|
@@ -1934,7 +914,7 @@ var BatchUploadFonts = () => {
|
|
|
1934
914
|
const woff2Blob = await woff2Response.blob();
|
|
1935
915
|
const woff2File = new File([woff2Blob], `${fontDoc._id}.woff2`, { type: "font/woff2" });
|
|
1936
916
|
setStatus(`Regenerating CSS for font ${i + 1}/${fontRefs.length}: ${fontDoc.title}`);
|
|
1937
|
-
const updatedFileInput = await generateCssFile({
|
|
917
|
+
const updatedFileInput = await _chunkJCDZ7SWZjs.generateCssFile.call(void 0, {
|
|
1938
918
|
woff2File,
|
|
1939
919
|
fileInput: fontDoc.fileInput,
|
|
1940
920
|
fileName: fontDoc._id,
|
|
@@ -1967,18 +947,18 @@ var BatchUploadFonts = () => {
|
|
|
1967
947
|
setError(false);
|
|
1968
948
|
setStatus("ready");
|
|
1969
949
|
};
|
|
1970
|
-
const renderTooltipLabel = (label, description) => /* @__PURE__ */
|
|
1971
|
-
|
|
950
|
+
const renderTooltipLabel = (label, description) => /* @__PURE__ */ _react2.default.createElement(
|
|
951
|
+
_ui.Tooltip,
|
|
1972
952
|
{
|
|
1973
|
-
content: /* @__PURE__ */
|
|
953
|
+
content: /* @__PURE__ */ _react2.default.createElement(_ui.Box, { padding: 2, style: { maxWidth: 260 } }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, style: { lineHeight: 1.6 } }, description)),
|
|
1974
954
|
placement: "top",
|
|
1975
955
|
portal: true
|
|
1976
956
|
},
|
|
1977
|
-
/* @__PURE__ */
|
|
957
|
+
/* @__PURE__ */ _react2.default.createElement(_ui.Flex, { align: "center", gap: 1, style: { cursor: "default" } }, /* @__PURE__ */ _react2.default.createElement(_ui.Label, null, label), /* @__PURE__ */ _react2.default.createElement(_icons.InfoOutlineIcon, { style: { opacity: 0.5, display: "block" } }))
|
|
1978
958
|
);
|
|
1979
|
-
const renderProcessing = () => /* @__PURE__ */
|
|
1980
|
-
const renderDropZone = () => /* @__PURE__ */
|
|
1981
|
-
|
|
959
|
+
const renderProcessing = () => /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 3, paddingY: 2 }, /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { align: "center", gap: 3 }, /* @__PURE__ */ _react2.default.createElement(_ui.Spinner, null), /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, muted: true }, status)), /* @__PURE__ */ _react2.default.createElement(_ui.Card, { tone: "caution", border: true, radius: 2, padding: 2 }, /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { align: "center", justify: "space-between", gap: 2 }, /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { align: "center", gap: 2 }, /* @__PURE__ */ _react2.default.createElement(_icons.WarningOutlineIcon, { style: { flexShrink: 0 } }), /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, weight: "semibold" }, "Do not close or reload this tab")), /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, muted: true, style: { flexShrink: 0 } }, formatElapsed(elapsedSeconds)))));
|
|
960
|
+
const renderDropZone = () => /* @__PURE__ */ _react2.default.createElement(
|
|
961
|
+
_ui.Box,
|
|
1982
962
|
{
|
|
1983
963
|
onDragEnter: handleDragEnter,
|
|
1984
964
|
onDragOver: handleDragOver,
|
|
@@ -1994,7 +974,7 @@ var BatchUploadFonts = () => {
|
|
|
1994
974
|
cursor: "default"
|
|
1995
975
|
}
|
|
1996
976
|
},
|
|
1997
|
-
/* @__PURE__ */
|
|
977
|
+
/* @__PURE__ */ _react2.default.createElement(
|
|
1998
978
|
"input",
|
|
1999
979
|
{
|
|
2000
980
|
ref: fileInputRef,
|
|
@@ -2005,8 +985,8 @@ var BatchUploadFonts = () => {
|
|
|
2005
985
|
onChange: handleFileSelect
|
|
2006
986
|
}
|
|
2007
987
|
),
|
|
2008
|
-
/* @__PURE__ */
|
|
2009
|
-
|
|
988
|
+
/* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 3 }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, muted: true }, isDragging ? "Release to add files" : "Drop font files here"), /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { justify: "center" }, /* @__PURE__ */ _react2.default.createElement(
|
|
989
|
+
_ui.Button,
|
|
2010
990
|
{
|
|
2011
991
|
mode: "ghost",
|
|
2012
992
|
tone: "primary",
|
|
@@ -2022,8 +1002,8 @@ var BatchUploadFonts = () => {
|
|
|
2022
1002
|
);
|
|
2023
1003
|
const renderFileList = () => {
|
|
2024
1004
|
const sorted = sortFilesByType(pendingFiles);
|
|
2025
|
-
return /* @__PURE__ */
|
|
2026
|
-
|
|
1005
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 2 }, /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { align: "center", justify: "space-between" }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, muted: true }, pendingFiles.length, " file", pendingFiles.length === 1 ? "" : "s", " selected"), /* @__PURE__ */ _react2.default.createElement(
|
|
1006
|
+
_ui.Button,
|
|
2027
1007
|
{
|
|
2028
1008
|
mode: "bleed",
|
|
2029
1009
|
tone: "default",
|
|
@@ -2032,27 +1012,27 @@ var BatchUploadFonts = () => {
|
|
|
2032
1012
|
text: "Clear all",
|
|
2033
1013
|
onClick: () => setPendingFiles([])
|
|
2034
1014
|
}
|
|
2035
|
-
)), /* @__PURE__ */
|
|
1015
|
+
)), /* @__PURE__ */ _react2.default.createElement(_ui.Box, { style: { maxHeight: "260px", overflowY: "auto", display: "flex", flexDirection: "column", gap: "4px" } }, sorted.map((file, i) => {
|
|
2036
1016
|
const ext = file.name.split(".").pop().toUpperCase();
|
|
2037
|
-
return /* @__PURE__ */
|
|
2038
|
-
|
|
1017
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Card, { key: `${file.name}-${file.size}-${i}`, border: true, radius: 1, paddingX: 2, paddingY: 2 }, /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { justify: "space-between", align: "center", gap: 2 }, /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { gap: 3, align: "center", style: { flex: 1, minWidth: 0 } }, /* @__PURE__ */ _react2.default.createElement(
|
|
1018
|
+
_ui.Text,
|
|
2039
1019
|
{
|
|
2040
1020
|
size: 0,
|
|
2041
1021
|
style: { fontFamily: "monospace", minWidth: "2.5rem", flexShrink: 0 }
|
|
2042
1022
|
},
|
|
2043
1023
|
ext
|
|
2044
|
-
), /* @__PURE__ */
|
|
2045
|
-
|
|
1024
|
+
), /* @__PURE__ */ _react2.default.createElement(_ui.Box, { style: { flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1 }, file.name))), /* @__PURE__ */ _react2.default.createElement(
|
|
1025
|
+
_ui.Button,
|
|
2046
1026
|
{
|
|
2047
1027
|
mode: "bleed",
|
|
2048
1028
|
tone: "critical",
|
|
2049
|
-
icon:
|
|
1029
|
+
icon: _icons.TrashIcon,
|
|
2050
1030
|
padding: 2,
|
|
2051
1031
|
onClick: () => handleRemoveFile(file)
|
|
2052
1032
|
}
|
|
2053
1033
|
)));
|
|
2054
|
-
})), /* @__PURE__ */
|
|
2055
|
-
|
|
1034
|
+
})), /* @__PURE__ */ _react2.default.createElement(
|
|
1035
|
+
_ui.Box,
|
|
2056
1036
|
{
|
|
2057
1037
|
onDragEnter: handleDragEnter,
|
|
2058
1038
|
onDragOver: handleDragOver,
|
|
@@ -2067,7 +1047,7 @@ var BatchUploadFonts = () => {
|
|
|
2067
1047
|
transition: "border-color 0.12s, background 0.12s"
|
|
2068
1048
|
}
|
|
2069
1049
|
},
|
|
2070
|
-
/* @__PURE__ */
|
|
1050
|
+
/* @__PURE__ */ _react2.default.createElement(
|
|
2071
1051
|
"input",
|
|
2072
1052
|
{
|
|
2073
1053
|
ref: fileInputRef,
|
|
@@ -2078,8 +1058,8 @@ var BatchUploadFonts = () => {
|
|
|
2078
1058
|
onChange: handleFileSelect
|
|
2079
1059
|
}
|
|
2080
1060
|
),
|
|
2081
|
-
/* @__PURE__ */
|
|
2082
|
-
|
|
1061
|
+
/* @__PURE__ */ _react2.default.createElement(_ui.Flex, { align: "center", justify: "center", gap: 2 }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, muted: true }, isDragging ? "Release to add" : "Drop more files or"), /* @__PURE__ */ _react2.default.createElement(
|
|
1062
|
+
_ui.Button,
|
|
2083
1063
|
{
|
|
2084
1064
|
mode: "bleed",
|
|
2085
1065
|
tone: "primary",
|
|
@@ -2092,29 +1072,30 @@ var BatchUploadFonts = () => {
|
|
|
2092
1072
|
}
|
|
2093
1073
|
}
|
|
2094
1074
|
))
|
|
2095
|
-
), /* @__PURE__ */
|
|
2096
|
-
|
|
1075
|
+
), /* @__PURE__ */ _react2.default.createElement(
|
|
1076
|
+
_ui.Button,
|
|
2097
1077
|
{
|
|
2098
1078
|
mode: "ghost",
|
|
2099
1079
|
tone: "primary",
|
|
2100
|
-
icon:
|
|
1080
|
+
icon: _icons.UploadIcon,
|
|
2101
1081
|
text: `Upload ${pendingFiles.length} Font${pendingFiles.length === 1 ? "" : "s"}`,
|
|
2102
1082
|
style: { width: "100%" },
|
|
2103
1083
|
onClick: handleConfirmUpload
|
|
2104
1084
|
}
|
|
2105
1085
|
));
|
|
2106
1086
|
};
|
|
2107
|
-
|
|
1087
|
+
const hasRequiredFields = title && title !== "" && slug && slug !== "";
|
|
1088
|
+
return /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, !hasRequiredFields && /* @__PURE__ */ _react2.default.createElement(_ui.Card, { border: true, padding: 4, radius: 2, tone: "caution" }, /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { align: "center", gap: 3 }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 2 }, /* @__PURE__ */ _react2.default.createElement(_icons.WarningOutlineIcon, null)), /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 2 }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, weight: "semibold" }, !title || title === "" ? "Title required to use font uploader" : "Slug required to use font uploader"), /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, muted: true }, "Add a ", !title || title === "" ? "title" : "slug", " to this typeface document, then return to the Styles tab to upload fonts.")))), hasRequiredFields && /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, /* @__PURE__ */ _react2.default.createElement(
|
|
2108
1089
|
StatusDisplay_default,
|
|
2109
1090
|
{
|
|
2110
1091
|
status,
|
|
2111
1092
|
error,
|
|
2112
|
-
action: /* @__PURE__ */
|
|
2113
|
-
|
|
1093
|
+
action: /* @__PURE__ */ _react2.default.createElement(
|
|
1094
|
+
_ui.Button,
|
|
2114
1095
|
{
|
|
2115
1096
|
mode: showUtilities ? "default" : "ghost",
|
|
2116
1097
|
tone: "primary",
|
|
2117
|
-
icon:
|
|
1098
|
+
icon: _icons.ControlsIcon,
|
|
2118
1099
|
text: "Utilities",
|
|
2119
1100
|
fontSize: 1,
|
|
2120
1101
|
padding: 2,
|
|
@@ -2122,17 +1103,32 @@ var BatchUploadFonts = () => {
|
|
|
2122
1103
|
}
|
|
2123
1104
|
)
|
|
2124
1105
|
}
|
|
2125
|
-
), /* @__PURE__ */
|
|
2126
|
-
|
|
1106
|
+
), /* @__PURE__ */ _react2.default.createElement(
|
|
1107
|
+
_ui.Button,
|
|
2127
1108
|
{
|
|
2128
|
-
|
|
2129
|
-
|
|
1109
|
+
mode: "default",
|
|
1110
|
+
tone: "primary",
|
|
1111
|
+
icon: _icons.UploadIcon,
|
|
1112
|
+
text: "Upload Fonts",
|
|
1113
|
+
fontSize: 2,
|
|
1114
|
+
padding: 4,
|
|
1115
|
+
onClick: () => setShowUploadModal(true),
|
|
1116
|
+
style: { width: "100%" }
|
|
2130
1117
|
}
|
|
2131
|
-
),
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
1118
|
+
), showUploadModal && /* @__PURE__ */ _react2.default.createElement(_react.Suspense, { fallback: /* @__PURE__ */ _react2.default.createElement(_ui.Spinner, null) }, /* @__PURE__ */ _react2.default.createElement(
|
|
1119
|
+
UploadModal2,
|
|
1120
|
+
{
|
|
1121
|
+
open: showUploadModal,
|
|
1122
|
+
onClose: () => setShowUploadModal(false),
|
|
1123
|
+
client,
|
|
1124
|
+
docId: doc_id,
|
|
1125
|
+
typefaceTitle: title,
|
|
1126
|
+
stylesObject,
|
|
1127
|
+
preferredStyleRef,
|
|
1128
|
+
slug
|
|
1129
|
+
}
|
|
1130
|
+
)), showUtilities && /* @__PURE__ */ _react2.default.createElement(_ui.Card, { border: true, padding: 3, shadow: 1, radius: 2, marginTop: 3 }, /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 4 }, /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 2 }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, weight: "semibold", style: { lineHeight: 1.6 } }, "Regenerate Subfamilies"), /* @__PURE__ */ _react2.default.createElement(RegenerateSubfamiliesComponent, null)), /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 3 }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, weight: "semibold", style: { lineHeight: 1.6 } }, "Rename Fonts (name table, Full Name)"), /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { align: "center", gap: 2 }, /* @__PURE__ */ _react2.default.createElement(
|
|
1131
|
+
_ui.Switch,
|
|
2136
1132
|
{
|
|
2137
1133
|
checked: preserveShortenedNames,
|
|
2138
1134
|
onChange: (e) => setPreserveShortenedNames(e.target.checked)
|
|
@@ -2140,44 +1136,35 @@ var BatchUploadFonts = () => {
|
|
|
2140
1136
|
), renderTooltipLabel(
|
|
2141
1137
|
"Preserve shortened names",
|
|
2142
1138
|
'Abbreviations in font names are kept as-is (e.g. "XNarrow" stays "XNarrow", "Bd" stays "Bd").'
|
|
2143
|
-
)), /* @__PURE__ */
|
|
2144
|
-
import_ui4.Switch,
|
|
2145
|
-
{
|
|
2146
|
-
checked: preserveFileNames,
|
|
2147
|
-
onChange: (e) => setPreserveFileNames(e.target.checked)
|
|
2148
|
-
}
|
|
2149
|
-
), renderTooltipLabel(
|
|
2150
|
-
"Preserve file names",
|
|
2151
|
-
"Original filename capitalisation is used for asset naming instead of the normalised font title."
|
|
2152
|
-
)))), /* @__PURE__ */ import_react5.default.createElement(import_ui4.Box, { marginTop: 3 }, pendingFiles.length === 0 ? renderDropZone() : renderFileList())) : renderProcessing())));
|
|
1139
|
+
)), ready === "rename" ? renderProcessing() : /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "ghost", tone: "primary", text: "Rename Existing Fonts", style: { width: "100%" }, onClick: handleRenameExistingFonts, disabled: ready !== true })), /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 3 }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, weight: "semibold", style: { lineHeight: 1.6 } }, "Update Font Prices"), ready === "price" ? renderProcessing() : /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 2 }, /* @__PURE__ */ _react2.default.createElement(_chunkJCDZ7SWZjs.PriceInput_default, { inputPrice, handleInputChange }), /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "ghost", tone: "primary", text: "Update All Font Prices", style: { width: "100%" }, onClick: handleChangeFontPrice, disabled: ready !== true }))), /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 3 }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, weight: "semibold", style: { lineHeight: 1.6 } }, "Regenerate CSS"), /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, muted: true, style: { lineHeight: 1.6 } }, "Rebuilds the CSS @font-face files for all fonts in the typeface fonts list."), ready === "css" ? renderProcessing() : /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "ghost", tone: "primary", text: "Regenerate CSS Files", style: { width: "100%" }, onClick: handleRegenerateCssFiles, disabled: ready !== true }))))));
|
|
2153
1140
|
};
|
|
2154
1141
|
|
|
2155
1142
|
// src/components/GenerateCollectionsPairsComponent.jsx
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
var
|
|
2160
|
-
|
|
1143
|
+
|
|
1144
|
+
|
|
1145
|
+
|
|
1146
|
+
var _slugify = require('slugify'); var _slugify2 = _interopRequireDefault(_slugify);
|
|
1147
|
+
|
|
2161
1148
|
var GenerateCollectionsPairsComponent = () => {
|
|
2162
|
-
const [status, setStatus] = (0,
|
|
2163
|
-
const [ready, setReady] = (0,
|
|
2164
|
-
const [collectionPrice, setCollectionPrice] = (0,
|
|
1149
|
+
const [status, setStatus] = _react.useState.call(void 0, "ready");
|
|
1150
|
+
const [ready, setReady] = _react.useState.call(void 0, true);
|
|
1151
|
+
const [collectionPrice, setCollectionPrice] = _react.useState.call(void 0,
|
|
2165
1152
|
process.env.SANITY_STUDIO_DEFAULT_COLLECTION_PRICE || 20
|
|
2166
1153
|
);
|
|
2167
|
-
const [pairPrice, setPairPrice] = (0,
|
|
1154
|
+
const [pairPrice, setPairPrice] = _react.useState.call(void 0,
|
|
2168
1155
|
process.env.SANITY_STUDIO_DEFAULT_PAIR_PRICE || 75
|
|
2169
1156
|
);
|
|
2170
1157
|
const client = useSanityClient();
|
|
2171
|
-
const doc_id = (0,
|
|
2172
|
-
const title = (0,
|
|
2173
|
-
const slug = (0,
|
|
2174
|
-
const stylesObject = (0,
|
|
2175
|
-
const createSanityCollection = (0,
|
|
1158
|
+
const doc_id = _sanity.useFormValue.call(void 0, ["_id"]);
|
|
1159
|
+
const title = _sanity.useFormValue.call(void 0, ["title"]);
|
|
1160
|
+
const slug = _sanity.useFormValue.call(void 0, ["slug"]);
|
|
1161
|
+
const stylesObject = _sanity.useFormValue.call(void 0, ["styles"]);
|
|
1162
|
+
const createSanityCollection = _react.useCallback.call(void 0, async (fontsList, collectionSlug, newTitle) => {
|
|
2176
1163
|
const newSlug = collectionSlug.toLowerCase().trim();
|
|
2177
1164
|
const fontRefs = fontsList.map((font) => ({
|
|
2178
|
-
_key: (0,
|
|
1165
|
+
_key: _nanoid.nanoid.call(void 0, ),
|
|
2179
1166
|
_type: "reference",
|
|
2180
|
-
_ref: font._id
|
|
1167
|
+
_ref: _nullishCoalesce(font._id, () => ( font._ref)),
|
|
2181
1168
|
_weak: true
|
|
2182
1169
|
}));
|
|
2183
1170
|
let preferredStyle = { weight: fontsList[0].weight, style: fontsList[0].style, _ref: fontsList[0]._ref };
|
|
@@ -2191,7 +1178,7 @@ var GenerateCollectionsPairsComponent = () => {
|
|
|
2191
1178
|
});
|
|
2192
1179
|
const price = (collectionPrice ? Number(collectionPrice) : 0) * fontRefs.length;
|
|
2193
1180
|
await client.createOrReplace({
|
|
2194
|
-
_key: (0,
|
|
1181
|
+
_key: _nanoid.nanoid.call(void 0, ),
|
|
2195
1182
|
_id: newSlug,
|
|
2196
1183
|
_type: "collection",
|
|
2197
1184
|
state: "active",
|
|
@@ -2204,18 +1191,18 @@ var GenerateCollectionsPairsComponent = () => {
|
|
|
2204
1191
|
}).catch((err) => {
|
|
2205
1192
|
console.error("Error creating collection:", err.message);
|
|
2206
1193
|
});
|
|
2207
|
-
return { _ref: newSlug, _type: "reference", _weak: true, _key: (0,
|
|
1194
|
+
return { _ref: newSlug, _type: "reference", _weak: true, _key: _nanoid.nanoid.call(void 0, ) };
|
|
2208
1195
|
}, [collectionPrice, client]);
|
|
2209
|
-
const createSanityPair = (0,
|
|
1196
|
+
const createSanityPair = _react.useCallback.call(void 0, async (pair, pairSlug, newTitle) => {
|
|
2210
1197
|
const newSlug = pairSlug.toLowerCase().trim();
|
|
2211
1198
|
const fontRefs = pair.map((font) => ({
|
|
2212
|
-
_key: (0,
|
|
1199
|
+
_key: _nanoid.nanoid.call(void 0, ),
|
|
2213
1200
|
_type: "reference",
|
|
2214
1201
|
_ref: font._id,
|
|
2215
1202
|
_weak: true
|
|
2216
1203
|
}));
|
|
2217
1204
|
await client.createOrReplace({
|
|
2218
|
-
_key: (0,
|
|
1205
|
+
_key: _nanoid.nanoid.call(void 0, ),
|
|
2219
1206
|
_id: newSlug,
|
|
2220
1207
|
_type: "pair",
|
|
2221
1208
|
preferredStyle: { _type: "reference", _ref: fontRefs[0]._ref, _weak: true },
|
|
@@ -2226,9 +1213,9 @@ var GenerateCollectionsPairsComponent = () => {
|
|
|
2226
1213
|
}).catch((err) => {
|
|
2227
1214
|
console.error("Error creating pair:", err.message);
|
|
2228
1215
|
});
|
|
2229
|
-
return { _ref: newSlug, _type: "reference", _weak: true, _key: (0,
|
|
1216
|
+
return { _ref: newSlug, _type: "reference", _weak: true, _key: _nanoid.nanoid.call(void 0, ) };
|
|
2230
1217
|
}, [pairPrice, client]);
|
|
2231
|
-
const handleGenerateCollections = (0,
|
|
1218
|
+
const handleGenerateCollections = _react.useCallback.call(void 0, async () => {
|
|
2232
1219
|
setStatus("Generating collections...");
|
|
2233
1220
|
setReady(false);
|
|
2234
1221
|
try {
|
|
@@ -2236,8 +1223,8 @@ var GenerateCollectionsPairsComponent = () => {
|
|
|
2236
1223
|
`*[_type == "typeface" && _id == $id]{ "fonts": styles.fonts[] -> }[0]`,
|
|
2237
1224
|
{ id: doc_id }
|
|
2238
1225
|
);
|
|
2239
|
-
const sanityFonts = (result == null ? void 0 : result.fonts)
|
|
2240
|
-
const subfamilies = (stylesObject == null ? void 0 : stylesObject.subfamilies)
|
|
1226
|
+
const sanityFonts = _nullishCoalesce((result == null ? void 0 : result.fonts), () => ( []));
|
|
1227
|
+
const subfamilies = _nullishCoalesce((stylesObject == null ? void 0 : stylesObject.subfamilies), () => ( []));
|
|
2241
1228
|
const totalCollections = subfamilies.length + 3;
|
|
2242
1229
|
const fullFamily = [], uprights = [], italics = [];
|
|
2243
1230
|
for (const font of sanityFonts) {
|
|
@@ -2264,7 +1251,7 @@ var GenerateCollectionsPairsComponent = () => {
|
|
|
2264
1251
|
setStatus(`[${i + 4}/${totalCollections}] Generating ${subfamilies[i].title} collection`);
|
|
2265
1252
|
const ref = await createSanityCollection(
|
|
2266
1253
|
subfamilies[i].fonts,
|
|
2267
|
-
`${slug.current}-${(0,
|
|
1254
|
+
`${slug.current}-${_slugify2.default.call(void 0, subfamilies[i].title)}-family`,
|
|
2268
1255
|
`${title} ${subfamilies[i].title} Family`
|
|
2269
1256
|
);
|
|
2270
1257
|
if (ref) typefacePatch.push(ref);
|
|
@@ -2277,7 +1264,7 @@ var GenerateCollectionsPairsComponent = () => {
|
|
|
2277
1264
|
}
|
|
2278
1265
|
setReady(true);
|
|
2279
1266
|
}, [doc_id, title, slug, stylesObject, collectionPrice, client, createSanityCollection]);
|
|
2280
|
-
const handleGeneratePairs = (0,
|
|
1267
|
+
const handleGeneratePairs = _react.useCallback.call(void 0, async () => {
|
|
2281
1268
|
var _a;
|
|
2282
1269
|
setStatus("Generating pairs...");
|
|
2283
1270
|
setReady(false);
|
|
@@ -2286,7 +1273,7 @@ var GenerateCollectionsPairsComponent = () => {
|
|
|
2286
1273
|
`*[_type == "typeface" && _id == $id]{ "fonts": styles.fonts[] -> }[0]`,
|
|
2287
1274
|
{ id: doc_id }
|
|
2288
1275
|
);
|
|
2289
|
-
const sanityFonts = (result == null ? void 0 : result.fonts)
|
|
1276
|
+
const sanityFonts = _nullishCoalesce((result == null ? void 0 : result.fonts), () => ( []));
|
|
2290
1277
|
const regular = [], italic = [];
|
|
2291
1278
|
for (const font of sanityFonts) {
|
|
2292
1279
|
if (font.style === "Regular") regular.push(font);
|
|
@@ -2306,21 +1293,21 @@ var GenerateCollectionsPairsComponent = () => {
|
|
|
2306
1293
|
let pairSlug, pairTitle;
|
|
2307
1294
|
if (reg.subfamily && reg.subfamily !== "") {
|
|
2308
1295
|
if (reg.subfamily === "Regular") {
|
|
2309
|
-
pairSlug = `${slug.current}-${(0,
|
|
1296
|
+
pairSlug = `${slug.current}-${_slugify2.default.call(void 0, reg.weightName)}s`;
|
|
2310
1297
|
pairTitle = `${title} ${reg.weightName}s`;
|
|
2311
1298
|
} else {
|
|
2312
|
-
pairSlug = `${slug.current}-${(0,
|
|
1299
|
+
pairSlug = `${slug.current}-${_slugify2.default.call(void 0, reg.subfamily)}-${_slugify2.default.call(void 0, reg.weightName)}s`;
|
|
2313
1300
|
pairTitle = `${title} ${reg.subfamily} ${reg.weightName}s`;
|
|
2314
1301
|
}
|
|
2315
1302
|
} else {
|
|
2316
|
-
pairSlug = `${slug.current}-${(0,
|
|
1303
|
+
pairSlug = `${slug.current}-${_slugify2.default.call(void 0, reg.weightName)}s`;
|
|
2317
1304
|
pairTitle = `${title} ${reg.weightName}s`;
|
|
2318
1305
|
}
|
|
2319
1306
|
setStatus(`[${i + 1}/${pairs.length}] Generating ${pairTitle}`);
|
|
2320
1307
|
const ref = await createSanityPair(pairs[i], pairSlug, pairTitle);
|
|
2321
1308
|
if (ref) typefacePatch.push(ref);
|
|
2322
1309
|
}
|
|
2323
|
-
const preferredStyle = ((_a = regular[0]) == null ? void 0 : _a._id)
|
|
1310
|
+
const preferredStyle = _nullishCoalesce(((_a = regular[0]) == null ? void 0 : _a._id), () => ( ""));
|
|
2324
1311
|
await client.patch(doc_id).set({
|
|
2325
1312
|
preferredStyle: { _ref: preferredStyle, _type: "reference", _weak: true },
|
|
2326
1313
|
styles: { ...stylesObject, pairs: typefacePatch }
|
|
@@ -2333,7 +1320,7 @@ var GenerateCollectionsPairsComponent = () => {
|
|
|
2333
1320
|
setReady(true);
|
|
2334
1321
|
}, [doc_id, title, slug, stylesObject, pairPrice, client, createSanityPair]);
|
|
2335
1322
|
if (!title || !slug) return null;
|
|
2336
|
-
return /* @__PURE__ */
|
|
1323
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 2 }, /* @__PURE__ */ _react2.default.createElement(StatusDisplay_default, { status, error: false }), /* @__PURE__ */ _react2.default.createElement(_ui.Card, { border: true, padding: 2, shadow: 1, radius: 2 }, ready ? /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 3 }, /* @__PURE__ */ _react2.default.createElement(_ui.Grid, { columns: [2], gap: 4, marginTop: 1, marginBottom: 1 }, /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 2 }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, muted: true }, "Collection price / font"), /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { align: "center", gap: 2 }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, muted: true }, "$"), /* @__PURE__ */ _react2.default.createElement(
|
|
2337
1324
|
"input",
|
|
2338
1325
|
{
|
|
2339
1326
|
value: collectionPrice,
|
|
@@ -2341,7 +1328,7 @@ var GenerateCollectionsPairsComponent = () => {
|
|
|
2341
1328
|
type: "number",
|
|
2342
1329
|
style: { textAlign: "end", padding: "5px", maxWidth: "75px" }
|
|
2343
1330
|
}
|
|
2344
|
-
))), /* @__PURE__ */
|
|
1331
|
+
))), /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 2 }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, muted: true }, "Pair price"), /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { align: "center", gap: 2 }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, muted: true }, "$"), /* @__PURE__ */ _react2.default.createElement(
|
|
2345
1332
|
"input",
|
|
2346
1333
|
{
|
|
2347
1334
|
value: pairPrice,
|
|
@@ -2349,27 +1336,27 @@ var GenerateCollectionsPairsComponent = () => {
|
|
|
2349
1336
|
type: "number",
|
|
2350
1337
|
style: { textAlign: "end", padding: "5px", maxWidth: "75px" }
|
|
2351
1338
|
}
|
|
2352
|
-
)))), /* @__PURE__ */
|
|
1339
|
+
)))), /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "ghost", tone: "primary", text: "Generate Collections", style: { width: "100%" }, onClick: handleGenerateCollections }), /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "ghost", tone: "primary", text: "Generate Pairs", style: { width: "100%" }, onClick: handleGeneratePairs })) : /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { align: "center", justify: "center", gap: 3, padding: 4 }, /* @__PURE__ */ _react2.default.createElement(_ui.Spinner, null), /* @__PURE__ */ _react2.default.createElement(_ui.Text, { muted: true, size: 1 }, status))));
|
|
2353
1340
|
};
|
|
2354
1341
|
|
|
2355
1342
|
// src/components/UpdateScriptsComponent.jsx
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
1343
|
+
|
|
1344
|
+
|
|
1345
|
+
|
|
2359
1346
|
var UpdateScriptsComponent = (props) => {
|
|
2360
1347
|
const { onChange } = props;
|
|
2361
1348
|
const client = useSanityClient();
|
|
2362
|
-
const scripts = (0,
|
|
2363
|
-
const fonts = (0,
|
|
2364
|
-
const isReadyRef = (0,
|
|
2365
|
-
const [message, setMessage] = (0,
|
|
2366
|
-
(0,
|
|
1349
|
+
const scripts = _sanity.useFormValue.call(void 0, ["scripts"]) || [];
|
|
1350
|
+
const fonts = _sanity.useFormValue.call(void 0, ["styles", "fonts"]);
|
|
1351
|
+
const isReadyRef = _react.useRef.call(void 0, false);
|
|
1352
|
+
const [message, setMessage] = _react.useState.call(void 0, "");
|
|
1353
|
+
_react.useEffect.call(void 0, () => {
|
|
2367
1354
|
const timer = setTimeout(() => {
|
|
2368
1355
|
isReadyRef.current = true;
|
|
2369
1356
|
}, 100);
|
|
2370
1357
|
return () => clearTimeout(timer);
|
|
2371
1358
|
}, []);
|
|
2372
|
-
const updateFromFonts = (0,
|
|
1359
|
+
const updateFromFonts = _react.useCallback.call(void 0, async () => {
|
|
2373
1360
|
if (!fonts || fonts.length === 0) {
|
|
2374
1361
|
setMessage("No fonts found to extract scripts from");
|
|
2375
1362
|
return;
|
|
@@ -2393,11 +1380,11 @@ var UpdateScriptsComponent = (props) => {
|
|
|
2393
1380
|
}
|
|
2394
1381
|
return acc;
|
|
2395
1382
|
}, []);
|
|
2396
|
-
if (isReadyRef.current) onChange((0,
|
|
1383
|
+
if (isReadyRef.current) onChange(_sanity.set.call(void 0, newScripts));
|
|
2397
1384
|
setMessage("Scripts updated");
|
|
2398
1385
|
}, [onChange, fonts, client]);
|
|
2399
|
-
return /* @__PURE__ */
|
|
2400
|
-
|
|
1386
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 3 }, /* @__PURE__ */ _react2.default.createElement(
|
|
1387
|
+
_ui.Button,
|
|
2401
1388
|
{
|
|
2402
1389
|
mode: "ghost",
|
|
2403
1390
|
tone: "primary",
|
|
@@ -2405,16 +1392,14 @@ var UpdateScriptsComponent = (props) => {
|
|
|
2405
1392
|
text: "Update Scripts from Font Files",
|
|
2406
1393
|
onClick: updateFromFonts
|
|
2407
1394
|
}
|
|
2408
|
-
), message && /* @__PURE__ */
|
|
1395
|
+
), message && /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, style: { color: "green" } }, message), props.renderDefault(props));
|
|
2409
1396
|
};
|
|
2410
1397
|
|
|
2411
1398
|
// src/components/SingleUploaderTool.jsx
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
var import_buffer3 = require("buffer");
|
|
2417
|
-
var fontkit5 = __toESM(require("fontkit"));
|
|
1399
|
+
|
|
1400
|
+
|
|
1401
|
+
|
|
1402
|
+
|
|
2418
1403
|
|
|
2419
1404
|
// src/utils/generateFontFile.js
|
|
2420
1405
|
async function generateFontFile({
|
|
@@ -2489,28 +1474,28 @@ var SingleUploaderTool = (props) => {
|
|
|
2489
1474
|
var _a, _b, _c, _d;
|
|
2490
1475
|
const client = useSanityClient();
|
|
2491
1476
|
const { elementProps: { ref }, onChange } = props;
|
|
2492
|
-
const [message, setMessage] = (0,
|
|
2493
|
-
const [status, setStatus] = (0,
|
|
2494
|
-
const [error, setError] = (0,
|
|
2495
|
-
const [filenames, setFilenames] = (0,
|
|
2496
|
-
const [showAdvanced, setShowAdvanced] = (0,
|
|
2497
|
-
const fileInput = (0,
|
|
2498
|
-
const doc_id = (0,
|
|
2499
|
-
const doc_title = (0,
|
|
2500
|
-
const doc_typefaceName = (0,
|
|
2501
|
-
const doc_variableFont = (0,
|
|
2502
|
-
const doc_weight = (0,
|
|
2503
|
-
const doc_style = (0,
|
|
2504
|
-
const doc_slug = (0,
|
|
2505
|
-
const doc_metaData = (0,
|
|
2506
|
-
const { weightKeywordList, italicKeywordList } = (0,
|
|
2507
|
-
(0,
|
|
1477
|
+
const [message, setMessage] = _react.useState.call(void 0, "");
|
|
1478
|
+
const [status, setStatus] = _react.useState.call(void 0, "ready");
|
|
1479
|
+
const [error, setError] = _react.useState.call(void 0, false);
|
|
1480
|
+
const [filenames, setFilenames] = _react.useState.call(void 0, {});
|
|
1481
|
+
const [showAdvanced, setShowAdvanced] = _react.useState.call(void 0, false);
|
|
1482
|
+
const fileInput = _sanity.useFormValue.call(void 0, ["fileInput"]);
|
|
1483
|
+
const doc_id = _sanity.useFormValue.call(void 0, ["_id"]);
|
|
1484
|
+
const doc_title = _sanity.useFormValue.call(void 0, ["title"]);
|
|
1485
|
+
const doc_typefaceName = _sanity.useFormValue.call(void 0, ["typefaceName"]);
|
|
1486
|
+
const doc_variableFont = _sanity.useFormValue.call(void 0, ["variableFont"]);
|
|
1487
|
+
const doc_weight = _sanity.useFormValue.call(void 0, ["weight"]);
|
|
1488
|
+
const doc_style = _sanity.useFormValue.call(void 0, ["style"]);
|
|
1489
|
+
const doc_slug = _sanity.useFormValue.call(void 0, ["slug"]);
|
|
1490
|
+
const doc_metaData = _sanity.useFormValue.call(void 0, ["metaData"]);
|
|
1491
|
+
const { weightKeywordList, italicKeywordList } = _react.useMemo.call(void 0, () => _chunkJCDZ7SWZjs.generateStyleKeywords.call(void 0, ), []);
|
|
1492
|
+
_react.useEffect.call(void 0, () => {
|
|
2508
1493
|
handleSetFilenames();
|
|
2509
1494
|
}, [fileInput]);
|
|
2510
|
-
const handleSetFilenames = (0,
|
|
1495
|
+
const handleSetFilenames = _react.useCallback.call(void 0, async () => {
|
|
2511
1496
|
var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
2512
|
-
const woff2WebRef = ((_b2 = (_a2 = fileInput == null ? void 0 : fileInput.woff2_web) == null ? void 0 : _a2.asset) == null ? void 0 : _b2._ref)
|
|
2513
|
-
const woff2SubsetRef = ((_d2 = (_c2 = fileInput == null ? void 0 : fileInput.woff2_subset) == null ? void 0 : _c2.asset) == null ? void 0 : _d2._ref)
|
|
1497
|
+
const woff2WebRef = _nullishCoalesce(((_b2 = (_a2 = fileInput == null ? void 0 : fileInput.woff2_web) == null ? void 0 : _a2.asset) == null ? void 0 : _b2._ref), () => ( null));
|
|
1498
|
+
const woff2SubsetRef = _nullishCoalesce(((_d2 = (_c2 = fileInput == null ? void 0 : fileInput.woff2_subset) == null ? void 0 : _c2.asset) == null ? void 0 : _d2._ref), () => ( null));
|
|
2514
1499
|
const assetIds = [
|
|
2515
1500
|
(_f = (_e = fileInput == null ? void 0 : fileInput.ttf) == null ? void 0 : _e.asset) == null ? void 0 : _f._ref,
|
|
2516
1501
|
(_h = (_g = fileInput == null ? void 0 : fileInput.otf) == null ? void 0 : _g.asset) == null ? void 0 : _h._ref,
|
|
@@ -2544,7 +1529,7 @@ var SingleUploaderTool = (props) => {
|
|
|
2544
1529
|
}, {});
|
|
2545
1530
|
setFilenames(fontNames);
|
|
2546
1531
|
}, [fileInput, client]);
|
|
2547
|
-
const handleGenerateCssFile = (0,
|
|
1532
|
+
const handleGenerateCssFile = _react.useCallback.call(void 0, async () => {
|
|
2548
1533
|
var _a2, _b2;
|
|
2549
1534
|
setMessage("Building CSS: " + doc_title + ".css");
|
|
2550
1535
|
setStatus("Building CSS file");
|
|
@@ -2557,7 +1542,7 @@ var SingleUploaderTool = (props) => {
|
|
|
2557
1542
|
{ id: woff2AssetRef }
|
|
2558
1543
|
);
|
|
2559
1544
|
const blob = await (await fetch(woff2Asset.url)).blob();
|
|
2560
|
-
const newFileInput = await generateCssFile({
|
|
1545
|
+
const newFileInput = await _chunkJCDZ7SWZjs.generateCssFile.call(void 0, {
|
|
2561
1546
|
woff2File: blob,
|
|
2562
1547
|
fileInput,
|
|
2563
1548
|
fontName: doc_title,
|
|
@@ -2572,7 +1557,7 @@ var SingleUploaderTool = (props) => {
|
|
|
2572
1557
|
setMessage("");
|
|
2573
1558
|
setStatus("ready");
|
|
2574
1559
|
}, 2e3);
|
|
2575
|
-
onChange((0,
|
|
1560
|
+
onChange(_sanity.set.call(void 0, newFileInput));
|
|
2576
1561
|
} catch (err) {
|
|
2577
1562
|
console.error("Error building CSS file:", err);
|
|
2578
1563
|
setMessage("Error building CSS file: " + err.message);
|
|
@@ -2585,7 +1570,7 @@ var SingleUploaderTool = (props) => {
|
|
|
2585
1570
|
}, 3e3);
|
|
2586
1571
|
}
|
|
2587
1572
|
}, [fileInput, onChange, doc_title, doc_variableFont, doc_weight, client]);
|
|
2588
|
-
const handleGenerateFontFile = (0,
|
|
1573
|
+
const handleGenerateFontFile = _react.useCallback.call(void 0, async (code, sourceFile) => {
|
|
2589
1574
|
var _a2;
|
|
2590
1575
|
const isMissing = Array.isArray(code);
|
|
2591
1576
|
const label = code === "all" ? "all font files" : isMissing ? "missing files" : code + " file";
|
|
@@ -2625,7 +1610,7 @@ var SingleUploaderTool = (props) => {
|
|
|
2625
1610
|
}, 3e3);
|
|
2626
1611
|
}
|
|
2627
1612
|
}, [doc_id, doc_title, doc_variableFont, doc_style, doc_weight, doc_slug, fileInput, client]);
|
|
2628
|
-
const handleGenerateFontData = (0,
|
|
1613
|
+
const handleGenerateFontData = _react.useCallback.call(void 0, async () => {
|
|
2629
1614
|
var _a2, _b2;
|
|
2630
1615
|
setMessage("Building font data...");
|
|
2631
1616
|
setStatus("Building font data");
|
|
@@ -2648,16 +1633,16 @@ var SingleUploaderTool = (props) => {
|
|
|
2648
1633
|
);
|
|
2649
1634
|
if (!(ttfAsset == null ? void 0 : ttfAsset.url)) throw new Error("Could not fetch TTF file URL");
|
|
2650
1635
|
const arrayBuffer = await (await fetch(ttfAsset.url)).arrayBuffer();
|
|
2651
|
-
const font =
|
|
2652
|
-
const { weightName, subfamilyName, style, variableFont } = extractFontMetadata(
|
|
1636
|
+
const font = await _chunkJCDZ7SWZjs.parseFont.call(void 0, arrayBuffer, `${doc_id}.ttf`);
|
|
1637
|
+
const { weightName, subfamilyName, style, variableFont } = _chunkJCDZ7SWZjs.extractFontMetadata.call(void 0,
|
|
2653
1638
|
font,
|
|
2654
1639
|
doc_typefaceName,
|
|
2655
1640
|
weightKeywordList,
|
|
2656
1641
|
italicKeywordList
|
|
2657
1642
|
);
|
|
2658
|
-
const weight = determineWeight(font, weightName);
|
|
1643
|
+
const weight = _chunkJCDZ7SWZjs.determineWeight.call(void 0, font, weightName);
|
|
2659
1644
|
await client.patch(doc_id).set({ weightName, subfamily: subfamilyName, style, variableFont, weight }).commit();
|
|
2660
|
-
const fontData = await generateFontData({
|
|
1645
|
+
const fontData = await _chunkJCDZ7SWZjs.generateFontData.call(void 0, {
|
|
2661
1646
|
url: ttfAsset.url,
|
|
2662
1647
|
fontKit: font,
|
|
2663
1648
|
fontId: doc_id,
|
|
@@ -2671,7 +1656,7 @@ var SingleUploaderTool = (props) => {
|
|
|
2671
1656
|
variableFont,
|
|
2672
1657
|
variableInstances: fontData.variableInstances
|
|
2673
1658
|
};
|
|
2674
|
-
const instanceMappings = await parseVariableFontInstances(fontObj, client);
|
|
1659
|
+
const instanceMappings = await _chunkJCDZ7SWZjs.parseVariableFontInstances.call(void 0, fontObj, client);
|
|
2675
1660
|
if (instanceMappings.length > 0) {
|
|
2676
1661
|
await client.patch(doc_id).set({ variableInstanceReferences: instanceMappings }).commit();
|
|
2677
1662
|
}
|
|
@@ -2694,7 +1679,7 @@ var SingleUploaderTool = (props) => {
|
|
|
2694
1679
|
}, 3e3);
|
|
2695
1680
|
}
|
|
2696
1681
|
}, [fileInput, doc_id, doc_typefaceName, client, weightKeywordList, italicKeywordList]);
|
|
2697
|
-
const handleGenerateSubsetAndWeb = (0,
|
|
1682
|
+
const handleGenerateSubsetAndWeb = _react.useCallback.call(void 0, async () => {
|
|
2698
1683
|
var _a2, _b2;
|
|
2699
1684
|
try {
|
|
2700
1685
|
const woff2AssetRef = (_b2 = (_a2 = fileInput == null ? void 0 : fileInput.woff2) == null ? void 0 : _a2.asset) == null ? void 0 : _b2._ref;
|
|
@@ -2733,7 +1718,7 @@ var SingleUploaderTool = (props) => {
|
|
|
2733
1718
|
}, 3e3);
|
|
2734
1719
|
}
|
|
2735
1720
|
}, [fileInput, doc_id, doc_title, doc_variableFont, doc_style, doc_weight, doc_slug, client]);
|
|
2736
|
-
const handleUploadTopLevelFile = (0,
|
|
1721
|
+
const handleUploadTopLevelFile = _react.useCallback.call(void 0, async (event, fieldName) => {
|
|
2737
1722
|
try {
|
|
2738
1723
|
const file = event.target.files[0];
|
|
2739
1724
|
if (!file) return;
|
|
@@ -2747,7 +1732,7 @@ var SingleUploaderTool = (props) => {
|
|
|
2747
1732
|
...fileInput,
|
|
2748
1733
|
[fieldName]: { _type: "file", asset: { _ref: asset._id, _type: "reference" } }
|
|
2749
1734
|
};
|
|
2750
|
-
onChange((0,
|
|
1735
|
+
onChange(_sanity.set.call(void 0, newFileInput));
|
|
2751
1736
|
setMessage(`${fieldName} uploaded`);
|
|
2752
1737
|
setStatus(`${fieldName} uploaded successfully`);
|
|
2753
1738
|
setTimeout(() => {
|
|
@@ -2766,7 +1751,7 @@ var SingleUploaderTool = (props) => {
|
|
|
2766
1751
|
}, 3e3);
|
|
2767
1752
|
}
|
|
2768
1753
|
}, [fileInput, onChange, doc_slug, client]);
|
|
2769
|
-
const handleUpload = (0,
|
|
1754
|
+
const handleUpload = _react.useCallback.call(void 0, async (event, code) => {
|
|
2770
1755
|
try {
|
|
2771
1756
|
const file = event.target.files[0];
|
|
2772
1757
|
if (!file) {
|
|
@@ -2790,7 +1775,7 @@ var SingleUploaderTool = (props) => {
|
|
|
2790
1775
|
if (code === "woff2") {
|
|
2791
1776
|
setMessage("Building CSS: " + doc_title + ".css");
|
|
2792
1777
|
setStatus("Building CSS file");
|
|
2793
|
-
newFileInput = await generateCssFile({
|
|
1778
|
+
newFileInput = await _chunkJCDZ7SWZjs.generateCssFile.call(void 0, {
|
|
2794
1779
|
woff2File: file,
|
|
2795
1780
|
fileInput: newFileInput,
|
|
2796
1781
|
fontName: doc_title,
|
|
@@ -2804,19 +1789,19 @@ var SingleUploaderTool = (props) => {
|
|
|
2804
1789
|
setStatus("CSS file built successfully");
|
|
2805
1790
|
}
|
|
2806
1791
|
if (code === "ttf") {
|
|
2807
|
-
const fontBuffer = await readFontFile(file);
|
|
2808
|
-
const font =
|
|
2809
|
-
const { weightName, subfamilyName, style, variableFont } = extractFontMetadata(
|
|
1792
|
+
const fontBuffer = await _chunkJCDZ7SWZjs.readFontFile.call(void 0, file);
|
|
1793
|
+
const font = await _chunkJCDZ7SWZjs.parseFont.call(void 0, fontBuffer, file.name);
|
|
1794
|
+
const { weightName, subfamilyName, style, variableFont } = _chunkJCDZ7SWZjs.extractFontMetadata.call(void 0,
|
|
2810
1795
|
font,
|
|
2811
1796
|
doc_typefaceName,
|
|
2812
1797
|
weightKeywordList,
|
|
2813
1798
|
italicKeywordList
|
|
2814
1799
|
);
|
|
2815
|
-
const weight = determineWeight(font, weightName);
|
|
1800
|
+
const weight = _chunkJCDZ7SWZjs.determineWeight.call(void 0, font, weightName);
|
|
2816
1801
|
const normalizedId = doc_id.startsWith("drafts.") ? doc_id.replace("drafts.", "") : doc_id;
|
|
2817
1802
|
await client.patch(normalizedId).set({ weightName, subfamily: subfamilyName, style, variableFont, weight }).commit();
|
|
2818
1803
|
}
|
|
2819
|
-
onChange((0,
|
|
1804
|
+
onChange(_sanity.set.call(void 0, newFileInput));
|
|
2820
1805
|
setTimeout(() => {
|
|
2821
1806
|
setMessage("");
|
|
2822
1807
|
setStatus("ready");
|
|
@@ -2833,7 +1818,7 @@ var SingleUploaderTool = (props) => {
|
|
|
2833
1818
|
}, 3e3);
|
|
2834
1819
|
}
|
|
2835
1820
|
}, [fileInput, onChange, doc_title, doc_typefaceName, doc_variableFont, doc_weight, doc_slug, doc_id, client, weightKeywordList, italicKeywordList]);
|
|
2836
|
-
const handleDelete = (0,
|
|
1821
|
+
const handleDelete = _react.useCallback.call(void 0, async (code) => {
|
|
2837
1822
|
var _a2, _b2;
|
|
2838
1823
|
try {
|
|
2839
1824
|
setMessage(`Deleting ${code} file...`);
|
|
@@ -2846,7 +1831,7 @@ var SingleUploaderTool = (props) => {
|
|
|
2846
1831
|
setError(true);
|
|
2847
1832
|
return;
|
|
2848
1833
|
}
|
|
2849
|
-
onChange((0,
|
|
1834
|
+
onChange(_sanity.unset.call(void 0, [code]));
|
|
2850
1835
|
await client.delete(asset);
|
|
2851
1836
|
setMessage(`${code} file deleted`);
|
|
2852
1837
|
setStatus(`${code} file deleted successfully`);
|
|
@@ -2866,7 +1851,7 @@ var SingleUploaderTool = (props) => {
|
|
|
2866
1851
|
}, 3e3);
|
|
2867
1852
|
}
|
|
2868
1853
|
}, [fileInput, onChange, client]);
|
|
2869
|
-
const handleDeleteTopLevel = (0,
|
|
1854
|
+
const handleDeleteTopLevel = _react.useCallback.call(void 0, async (fieldName) => {
|
|
2870
1855
|
var _a2, _b2;
|
|
2871
1856
|
try {
|
|
2872
1857
|
setMessage(`Deleting ${fieldName}...`);
|
|
@@ -2879,7 +1864,7 @@ var SingleUploaderTool = (props) => {
|
|
|
2879
1864
|
setError(true);
|
|
2880
1865
|
return;
|
|
2881
1866
|
}
|
|
2882
|
-
onChange((0,
|
|
1867
|
+
onChange(_sanity.unset.call(void 0, [fieldName]));
|
|
2883
1868
|
await client.delete(asset);
|
|
2884
1869
|
setMessage(`${fieldName} deleted`);
|
|
2885
1870
|
setStatus(`${fieldName} deleted successfully`);
|
|
@@ -2899,12 +1884,12 @@ var SingleUploaderTool = (props) => {
|
|
|
2899
1884
|
}, 3e3);
|
|
2900
1885
|
}
|
|
2901
1886
|
}, [fileInput, onChange, client]);
|
|
2902
|
-
const handleDeleteAll = (0,
|
|
1887
|
+
const handleDeleteAll = _react.useCallback.call(void 0, async () => {
|
|
2903
1888
|
try {
|
|
2904
1889
|
setMessage("Deleting all files and metadata...");
|
|
2905
1890
|
setStatus("Deleting all files and metadata");
|
|
2906
1891
|
setError(false);
|
|
2907
|
-
onChange((0,
|
|
1892
|
+
onChange(_sanity.unset.call(void 0, []));
|
|
2908
1893
|
await client.patch(doc_id).set({
|
|
2909
1894
|
characterSet: { chars: [] },
|
|
2910
1895
|
glyphCount: 0,
|
|
@@ -2953,30 +1938,30 @@ var SingleUploaderTool = (props) => {
|
|
|
2953
1938
|
const formatUpper = format.toUpperCase();
|
|
2954
1939
|
const hasFile = !!((_b2 = (_a2 = fileInput == null ? void 0 : fileInput[format]) == null ? void 0 : _a2.asset) == null ? void 0 : _b2._ref);
|
|
2955
1940
|
const fileUrl = hasFile ? `https://cdn.sanity.io/files/${process.env.SANITY_STUDIO_PROJECT_ID}/${process.env.SANITY_STUDIO_DATASET}/${fileInput[format].asset._ref.replace("file-", "").replace("-", ".")}` : null;
|
|
2956
|
-
return /* @__PURE__ */
|
|
1941
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Card, { border: true, radius: 1, paddingX: 2, paddingY: 3 }, /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { justify: "space-between", align: "center", gap: 2 }, /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { gap: 3, align: "center", style: { flex: 1, minWidth: 0 } }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 0, style: { fontFamily: "monospace", minWidth: "2.5rem", flexShrink: 0, opacity: hasFile ? 1 : 0.5 } }, formatUpper), hasFile ? /* @__PURE__ */ _react2.default.createElement(_ui.Box, { style: { flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, /* @__PURE__ */ _react2.default.createElement("a", { href: fileUrl, target: "_blank", rel: "noreferrer" }, (filenames == null ? void 0 : filenames[format]) || "File")) : /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, muted: true }, "\u2014")), status === "ready" && /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { gap: 1, align: "center", style: { flexShrink: 0 } }, buildSource && (fileInput == null ? void 0 : fileInput[buildSource]) && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "ghost", tone: "primary", fontSize: 1, padding: 2, onClick: () => handleGenerateFontFile(format, fileInput[buildSource]), text: "Build" }), /* @__PURE__ */ _react2.default.createElement(_ui.Button, { as: "label", mode: "ghost", tone: "primary", fontSize: 1, padding: 2, style: { cursor: "pointer" } }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1 }, "Upload"), /* @__PURE__ */ _react2.default.createElement("input", { ref, type: "file", hidden: true, onChange: (e) => handleUpload(e, format) })), hasFile && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "bleed", tone: "critical", icon: _icons.TrashIcon, padding: 2, onClick: () => handleDelete(format) }))));
|
|
2957
1942
|
};
|
|
2958
1943
|
const renderTopLevelAssetSection = (label, fieldName, assetRef, filename, onBuild) => {
|
|
2959
1944
|
const hasFile = !!assetRef;
|
|
2960
1945
|
const fileUrl = hasFile ? `https://cdn.sanity.io/files/${process.env.SANITY_STUDIO_PROJECT_ID}/${process.env.SANITY_STUDIO_DATASET}/${assetRef.replace("file-", "").replace("-", ".")}` : null;
|
|
2961
|
-
return /* @__PURE__ */
|
|
1946
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Card, { border: true, radius: 1, paddingX: 2, paddingY: 3 }, /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { justify: "space-between", align: "center", gap: 2 }, /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { gap: 3, align: "center", style: { flex: 1, minWidth: 0 } }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 0, style: { fontFamily: "monospace", minWidth: "2.5rem", flexShrink: 0, opacity: hasFile ? 1 : 0.5 } }, label), hasFile ? /* @__PURE__ */ _react2.default.createElement(_ui.Box, { style: { flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, /* @__PURE__ */ _react2.default.createElement("a", { href: fileUrl, target: "_blank", rel: "noreferrer" }, filename || "File")) : /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, muted: true }, "\u2014")), status === "ready" && /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { gap: 1, align: "center", style: { flexShrink: 0 } }, onBuild && (fileInput == null ? void 0 : fileInput.woff2) && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "ghost", tone: "primary", fontSize: 1, padding: 2, onClick: onBuild, text: "Build" }), /* @__PURE__ */ _react2.default.createElement(_ui.Button, { as: "label", mode: "ghost", tone: "primary", fontSize: 1, padding: 2, style: { cursor: "pointer" } }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1 }, "Upload"), /* @__PURE__ */ _react2.default.createElement("input", { type: "file", hidden: true, onChange: (e) => handleUploadTopLevelFile(e, fieldName) })), hasFile && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "bleed", tone: "critical", icon: _icons.TrashIcon, padding: 2, onClick: () => handleDeleteTopLevel(fieldName) }))));
|
|
2962
1947
|
};
|
|
2963
1948
|
const renderCssSection = () => {
|
|
2964
1949
|
var _a2, _b2;
|
|
2965
1950
|
const hasFile = !!((_b2 = (_a2 = fileInput == null ? void 0 : fileInput.css) == null ? void 0 : _a2.asset) == null ? void 0 : _b2._ref);
|
|
2966
1951
|
const fileUrl = hasFile ? `https://cdn.sanity.io/files/${process.env.SANITY_STUDIO_PROJECT_ID}/${process.env.SANITY_STUDIO_DATASET}/${fileInput.css.asset._ref.replace("file-", "").replace("-", ".")}` : null;
|
|
2967
|
-
return /* @__PURE__ */
|
|
1952
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Card, { border: true, radius: 1, paddingX: 2, paddingY: 3 }, /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { justify: "space-between", align: "center", gap: 2 }, /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { gap: 3, align: "center", style: { flex: 1, minWidth: 0 } }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 0, style: { fontFamily: "monospace", minWidth: "2.5rem", flexShrink: 0, opacity: hasFile ? 1 : 0.5 } }, "CSS"), hasFile ? /* @__PURE__ */ _react2.default.createElement(_ui.Box, { style: { flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, /* @__PURE__ */ _react2.default.createElement("a", { href: fileUrl, target: "_blank", rel: "noreferrer" }, (filenames == null ? void 0 : filenames.css) || "File")) : /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, muted: true }, "\u2014")), status === "ready" && /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { gap: 1, align: "center", style: { flexShrink: 0 } }, (fileInput == null ? void 0 : fileInput.woff2) && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "ghost", tone: "primary", fontSize: 1, padding: 2, onClick: () => handleGenerateCssFile(), text: "Build" }), hasFile && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "bleed", tone: "critical", icon: _icons.TrashIcon, padding: 2, onClick: () => handleDelete("css") }))));
|
|
2968
1953
|
};
|
|
2969
|
-
const renderDataSection = () => /* @__PURE__ */
|
|
2970
|
-
return /* @__PURE__ */
|
|
1954
|
+
const renderDataSection = () => /* @__PURE__ */ _react2.default.createElement(_ui.Card, { border: true, radius: 1, paddingX: 2, paddingY: 3 }, /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { justify: "space-between", align: "center", gap: 2 }, /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { gap: 3, align: "center", style: { flex: 1, minWidth: 0 } }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 0, style: { fontFamily: "monospace", minWidth: "2.5rem", flexShrink: 0, opacity: (doc_metaData == null ? void 0 : doc_metaData.version) ? 1 : 0.5 } }, "DATA"), (doc_metaData == null ? void 0 : doc_metaData.version) ? /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1 }, "v", doc_metaData.version, " ", /* @__PURE__ */ _react2.default.createElement(_ui.Text, { as: "span", size: 1, muted: true }, "(", doc_metaData.genDate, ")")) : /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, muted: true }, "\u2014")), status === "ready" && (fileInput == null ? void 0 : fileInput.ttf) && /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { gap: 1, align: "center", style: { flexShrink: 0 } }, /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "ghost", tone: "primary", fontSize: 1, padding: 2, onClick: () => handleGenerateFontData(), text: "Build" }))));
|
|
1955
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 2 }, /* @__PURE__ */ _react2.default.createElement(
|
|
2971
1956
|
StatusDisplay_default,
|
|
2972
1957
|
{
|
|
2973
1958
|
status,
|
|
2974
1959
|
error,
|
|
2975
|
-
action: /* @__PURE__ */
|
|
2976
|
-
|
|
1960
|
+
action: /* @__PURE__ */ _react2.default.createElement(
|
|
1961
|
+
_ui.Button,
|
|
2977
1962
|
{
|
|
2978
1963
|
mode: "bleed",
|
|
2979
|
-
icon:
|
|
1964
|
+
icon: _icons.ControlsIcon,
|
|
2980
1965
|
padding: 2,
|
|
2981
1966
|
tone: showAdvanced ? "primary" : "default",
|
|
2982
1967
|
title: "Show advanced file formats",
|
|
@@ -2984,8 +1969,8 @@ var SingleUploaderTool = (props) => {
|
|
|
2984
1969
|
}
|
|
2985
1970
|
)
|
|
2986
1971
|
}
|
|
2987
|
-
), renderFontSection("ttf"), status === "ready" && (fileInput == null ? void 0 : fileInput.ttf) && /* @__PURE__ */
|
|
2988
|
-
|
|
1972
|
+
), renderFontSection("ttf"), status === "ready" && (fileInput == null ? void 0 : fileInput.ttf) && /* @__PURE__ */ _react2.default.createElement(_ui.Grid, { columns: [1, 2], gap: 2 }, /* @__PURE__ */ _react2.default.createElement(
|
|
1973
|
+
_ui.Button,
|
|
2989
1974
|
{
|
|
2990
1975
|
mode: "ghost",
|
|
2991
1976
|
tone: "primary",
|
|
@@ -2993,8 +1978,8 @@ var SingleUploaderTool = (props) => {
|
|
|
2993
1978
|
text: "Rebuild All from TTF",
|
|
2994
1979
|
style: { width: "100%" }
|
|
2995
1980
|
}
|
|
2996
|
-
), /* @__PURE__ */
|
|
2997
|
-
|
|
1981
|
+
), /* @__PURE__ */ _react2.default.createElement(
|
|
1982
|
+
_ui.Button,
|
|
2998
1983
|
{
|
|
2999
1984
|
mode: "ghost",
|
|
3000
1985
|
tone: "primary",
|
|
@@ -3013,19 +1998,18 @@ var SingleUploaderTool = (props) => {
|
|
|
3013
1998
|
text: "Build Missing",
|
|
3014
1999
|
style: { width: "100%" }
|
|
3015
2000
|
}
|
|
3016
|
-
)), renderFontSection("otf", "woff"), renderFontSection("woff", "ttf"), renderFontSection("woff2", "ttf"), showAdvanced && renderTopLevelAssetSection("WEB", "woff2_web", (_b = (_a = fileInput == null ? void 0 : fileInput.woff2_web) == null ? void 0 : _a.asset) == null ? void 0 : _b._ref, filenames == null ? void 0 : filenames.woff2_web, handleGenerateSubsetAndWeb), showAdvanced && renderTopLevelAssetSection("SUBSET", "woff2_subset", (_d = (_c = fileInput == null ? void 0 : fileInput.woff2_subset) == null ? void 0 : _c.asset) == null ? void 0 : _d._ref, filenames == null ? void 0 : filenames.woff2_subset, handleGenerateSubsetAndWeb), showAdvanced && renderFontSection("eot", "ttf"), showAdvanced && renderFontSection("svg", "ttf"), renderCssSection(), showAdvanced && renderDataSection(), status === "ready" && ((fileInput == null ? void 0 : fileInput.ttf) || (fileInput == null ? void 0 : fileInput.otf) || (fileInput == null ? void 0 : fileInput.woff) || (fileInput == null ? void 0 : fileInput.woff2)) && /* @__PURE__ */
|
|
2001
|
+
)), renderFontSection("otf", "woff"), renderFontSection("woff", "ttf"), renderFontSection("woff2", "ttf"), showAdvanced && renderTopLevelAssetSection("WEB", "woff2_web", (_b = (_a = fileInput == null ? void 0 : fileInput.woff2_web) == null ? void 0 : _a.asset) == null ? void 0 : _b._ref, filenames == null ? void 0 : filenames.woff2_web, handleGenerateSubsetAndWeb), showAdvanced && renderTopLevelAssetSection("SUBSET", "woff2_subset", (_d = (_c = fileInput == null ? void 0 : fileInput.woff2_subset) == null ? void 0 : _c.asset) == null ? void 0 : _d._ref, filenames == null ? void 0 : filenames.woff2_subset, handleGenerateSubsetAndWeb), showAdvanced && renderFontSection("eot", "ttf"), showAdvanced && renderFontSection("svg", "ttf"), renderCssSection(), showAdvanced && renderDataSection(), status === "ready" && ((fileInput == null ? void 0 : fileInput.ttf) || (fileInput == null ? void 0 : fileInput.otf) || (fileInput == null ? void 0 : fileInput.woff) || (fileInput == null ? void 0 : fileInput.woff2)) && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "ghost", tone: "critical", onClick: () => handleDeleteAll(), text: "Delete All", style: { width: "100%" } }));
|
|
3017
2002
|
};
|
|
3018
2003
|
|
|
3019
2004
|
// src/components/UploadScriptsComponent.jsx
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
var import_nanoid7 = require("nanoid");
|
|
2005
|
+
|
|
2006
|
+
|
|
2007
|
+
|
|
2008
|
+
|
|
2009
|
+
|
|
3026
2010
|
|
|
3027
2011
|
// src/utils/utils.js
|
|
3028
|
-
|
|
2012
|
+
|
|
3029
2013
|
var HtmlDescription = ({ children }) => {
|
|
3030
2014
|
return children || "";
|
|
3031
2015
|
};
|
|
@@ -3042,17 +2026,17 @@ var DISCOUNT_REQUIREMENT_TYPES_OBJECT = DISCOUNT_REQUIREMENT_TYPES.map((type) =>
|
|
|
3042
2026
|
var UploadScriptsComponent = (props) => {
|
|
3043
2027
|
const { elementProps: { ref } } = props;
|
|
3044
2028
|
const client = useSanityClient();
|
|
3045
|
-
const [selectedScript, setSelectedScript] = (0,
|
|
3046
|
-
const [status, setStatus] =
|
|
3047
|
-
const [ready, setReady] =
|
|
3048
|
-
let doc_id = (0,
|
|
3049
|
-
const title = (0,
|
|
3050
|
-
const slug = (0,
|
|
3051
|
-
const scripts = (0,
|
|
3052
|
-
const stylesObject = (0,
|
|
2029
|
+
const [selectedScript, setSelectedScript] = _react.useState.call(void 0, "");
|
|
2030
|
+
const [status, setStatus] = _react2.default.useState("");
|
|
2031
|
+
const [ready, setReady] = _react2.default.useState(true);
|
|
2032
|
+
let doc_id = _sanity.useFormValue.call(void 0, ["_id"]);
|
|
2033
|
+
const title = _sanity.useFormValue.call(void 0, ["title"]);
|
|
2034
|
+
const slug = _sanity.useFormValue.call(void 0, ["slug"]);
|
|
2035
|
+
const scripts = _sanity.useFormValue.call(void 0, ["scripts"]) || [];
|
|
2036
|
+
const stylesObject = _sanity.useFormValue.call(void 0, ["styles"]);
|
|
3053
2037
|
let subfamiliesArray = (stylesObject == null ? void 0 : stylesObject.subfamilies) || [];
|
|
3054
|
-
const { weightKeywordList, italicKeywordList } = (0,
|
|
3055
|
-
() => generateStyleKeywords(),
|
|
2038
|
+
const { weightKeywordList, italicKeywordList } = _react.useMemo.call(void 0,
|
|
2039
|
+
() => _chunkJCDZ7SWZjs.generateStyleKeywords.call(void 0, ),
|
|
3056
2040
|
[]
|
|
3057
2041
|
);
|
|
3058
2042
|
const readFontFile3 = (file) => {
|
|
@@ -3067,8 +2051,7 @@ var UploadScriptsComponent = (props) => {
|
|
|
3067
2051
|
reader.readAsArrayBuffer(file);
|
|
3068
2052
|
});
|
|
3069
2053
|
};
|
|
3070
|
-
const handleUpload = (0,
|
|
3071
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
2054
|
+
const handleUpload = _react.useCallback.call(void 0, async (event, script) => {
|
|
3072
2055
|
setReady(false);
|
|
3073
2056
|
try {
|
|
3074
2057
|
let failedFiles = [];
|
|
@@ -3085,21 +2068,22 @@ var UploadScriptsComponent = (props) => {
|
|
|
3085
2068
|
for (var i = 0; i < event.target.files.length; i++) {
|
|
3086
2069
|
const file = event.target.files[i];
|
|
3087
2070
|
const fontBuffer = await readFontFile3(file);
|
|
3088
|
-
const font =
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
weightName =
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
weightName = (
|
|
3096
|
-
weightName = weightName
|
|
3097
|
-
weightName = weightName == null ? void 0 : weightName.replace("Italic", "").replace("It", "").trim();
|
|
2071
|
+
const font = await _chunkJCDZ7SWZjs.parseFont.call(void 0, fontBuffer, file.name);
|
|
2072
|
+
const fullName = _chunkJCDZ7SWZjs.getNameString.call(void 0, font, 4);
|
|
2073
|
+
const familyName = _chunkJCDZ7SWZjs.getNameString.call(void 0, font, 1);
|
|
2074
|
+
console.log("Reading font:", fullName, file.name);
|
|
2075
|
+
let weightName = _chunkJCDZ7SWZjs.getNameString.call(void 0, font, 17) || _chunkJCDZ7SWZjs.getNameString.call(void 0, font, 2) || "";
|
|
2076
|
+
weightName = weightName.replace("Italic", "").replace("It", "").trim();
|
|
2077
|
+
if ((weightName == "" || weightName.toLowerCase() == "roman") && fullName) {
|
|
2078
|
+
weightName = fullName.replace(title + " ", "").replace(title, "").trim();
|
|
2079
|
+
weightName = weightName.replace("Italic", "").replace("It", "").trim();
|
|
3098
2080
|
}
|
|
3099
|
-
|
|
3100
|
-
let
|
|
3101
|
-
let
|
|
3102
|
-
let
|
|
2081
|
+
const axes = _chunkJCDZ7SWZjs.getVariationAxes.call(void 0, font);
|
|
2082
|
+
let variableFont = axes !== null;
|
|
2083
|
+
let subfamilyName = familyName.toLowerCase().trim().replace(title.toLowerCase().trim(), "").trim();
|
|
2084
|
+
let fontTitle = fullName;
|
|
2085
|
+
const italicAngle = _chunkJCDZ7SWZjs.getItalicAngle.call(void 0, font);
|
|
2086
|
+
let style = italicAngle !== 0 || fullName.toLowerCase().includes("italic") ? "Italic" : "Regular";
|
|
3103
2087
|
if (fontTitle.toLowerCase().trim().includes(script)) {
|
|
3104
2088
|
fontTitle = fontTitle.toLowerCase().trim().replace(script, "").trim();
|
|
3105
2089
|
fontTitle = fontTitle.split(" ").map((word) => {
|
|
@@ -3134,17 +2118,17 @@ var UploadScriptsComponent = (props) => {
|
|
|
3134
2118
|
}
|
|
3135
2119
|
if (variableFont && !fontTitle.toLowerCase().trim().endsWith(" vf")) fontTitle = fontTitle + " VF";
|
|
3136
2120
|
if (italicKW.length > 0) {
|
|
3137
|
-
italicKW = italicKW.map((item) => reverseSpellingLookup(item));
|
|
2121
|
+
italicKW = italicKW.map((item) => _chunkJCDZ7SWZjs.reverseSpellingLookup.call(void 0, item));
|
|
3138
2122
|
fontTitle = fontTitle + italicKW.join(" ");
|
|
3139
2123
|
style = "Italic";
|
|
3140
2124
|
}
|
|
3141
|
-
let id = (0,
|
|
2125
|
+
let id = _slugify2.default.call(void 0, fontTitle.toLowerCase().trim());
|
|
3142
2126
|
console.log("=== Font Info ====");
|
|
3143
2127
|
console.log(" ");
|
|
3144
2128
|
console.log("font id : ", id);
|
|
3145
2129
|
console.log("font title : ", fontTitle);
|
|
3146
|
-
console.log("
|
|
3147
|
-
console.log("
|
|
2130
|
+
console.log("Full name:", fullName);
|
|
2131
|
+
console.log("Family name:", familyName);
|
|
3148
2132
|
console.log("file name : ", file.name);
|
|
3149
2133
|
console.log("subfamily : ", subfamilyName);
|
|
3150
2134
|
console.log("style : ", style);
|
|
@@ -3158,18 +2142,17 @@ var UploadScriptsComponent = (props) => {
|
|
|
3158
2142
|
fontsObjects[id].files = [...fontsObjects[id].files, file];
|
|
3159
2143
|
} else {
|
|
3160
2144
|
let fontObject = {
|
|
3161
|
-
_key: (0,
|
|
2145
|
+
_key: _nanoid.nanoid.call(void 0, ),
|
|
3162
2146
|
_id: id,
|
|
3163
2147
|
title: fontTitle,
|
|
3164
2148
|
slug: { _type: "slug", current: id },
|
|
3165
2149
|
typefaceName: title,
|
|
3166
2150
|
// Change to match Typeface Document
|
|
3167
|
-
style
|
|
2151
|
+
style,
|
|
3168
2152
|
variableFont,
|
|
3169
2153
|
weightName,
|
|
3170
2154
|
normalWeight: true,
|
|
3171
|
-
|
|
3172
|
-
weight: ((_k = font["OS/2"]) == null ? void 0 : _k.usWeightClass) ? Number((_l = font["OS/2"]) == null ? void 0 : _l.usWeightClass) : /hairline|extra thin|extrathin/.test(weightName == null ? void 0 : weightName.toLowerCase()) ? 100 : /thin|extra light|extralight/.test(weightName == null ? void 0 : weightName.toLowerCase()) ? 200 : /light|book/.test(weightName == null ? void 0 : weightName.toLowerCase()) ? 300 : /regular|normal/.test(weightName == null ? void 0 : weightName.toLowerCase()) ? 400 : /medium/.test(weightName == null ? void 0 : weightName.toLowerCase()) ? 500 : /semi bold|semibold/.test(weightName == null ? void 0 : weightName.toLowerCase()) ? 600 : /bold/.test(weightName == null ? void 0 : weightName.toLowerCase()) ? 700 : /extra bold|extrabold/.test(weightName == null ? void 0 : weightName.toLowerCase()) ? 800 : /black|ultra/.test(weightName == null ? void 0 : weightName.toLowerCase()) ? 900 : 400,
|
|
2155
|
+
weight: _chunkJCDZ7SWZjs.getWeightClass.call(void 0, font) || (/hairline|extra thin|extrathin/.test(weightName == null ? void 0 : weightName.toLowerCase()) ? 100 : /thin|extra light|extralight/.test(weightName == null ? void 0 : weightName.toLowerCase()) ? 200 : /light|book/.test(weightName == null ? void 0 : weightName.toLowerCase()) ? 300 : /regular|normal/.test(weightName == null ? void 0 : weightName.toLowerCase()) ? 400 : /medium/.test(weightName == null ? void 0 : weightName.toLowerCase()) ? 500 : /semi bold|semibold/.test(weightName == null ? void 0 : weightName.toLowerCase()) ? 600 : /bold/.test(weightName == null ? void 0 : weightName.toLowerCase()) ? 700 : /extra bold|extrabold/.test(weightName == null ? void 0 : weightName.toLowerCase()) ? 800 : /black|ultra/.test(weightName == null ? void 0 : weightName.toLowerCase()) ? 900 : 400),
|
|
3173
2156
|
files: [file],
|
|
3174
2157
|
fontKit: font,
|
|
3175
2158
|
scriptFileInput: { [script]: {} }
|
|
@@ -3218,7 +2201,7 @@ var UploadScriptsComponent = (props) => {
|
|
|
3218
2201
|
if (file.name.endsWith(".woff2")) {
|
|
3219
2202
|
console.log("generating css file for: ", fontObject.title);
|
|
3220
2203
|
setStatus("generating css file for: " + fontObject.title);
|
|
3221
|
-
newFileInput = await generateCssFile({
|
|
2204
|
+
newFileInput = await _chunkJCDZ7SWZjs.generateCssFile.call(void 0, {
|
|
3222
2205
|
woff2File: file,
|
|
3223
2206
|
fileInput: newFileInput,
|
|
3224
2207
|
// script: script,
|
|
@@ -3271,7 +2254,7 @@ var UploadScriptsComponent = (props) => {
|
|
|
3271
2254
|
fontResponse = await client.patch(font._id).set({ scriptFileInput: font.scriptFileInput }).commit();
|
|
3272
2255
|
} else {
|
|
3273
2256
|
fontResponse = await client.createOrReplace({
|
|
3274
|
-
_key: (0,
|
|
2257
|
+
_key: _nanoid.nanoid.call(void 0, ),
|
|
3275
2258
|
_id: font._id,
|
|
3276
2259
|
_type: "font",
|
|
3277
2260
|
...font
|
|
@@ -3284,7 +2267,7 @@ var UploadScriptsComponent = (props) => {
|
|
|
3284
2267
|
})];
|
|
3285
2268
|
continue;
|
|
3286
2269
|
}
|
|
3287
|
-
const fontRef = { _key: (0,
|
|
2270
|
+
const fontRef = { _key: _nanoid.nanoid.call(void 0, ), _type: "reference", _ref: fontResponse._id, _weak: true };
|
|
3288
2271
|
console.log("font response : ", fontResponse);
|
|
3289
2272
|
console.log("existing styles object : ", stylesObject);
|
|
3290
2273
|
if (!font.variableFont) {
|
|
@@ -3352,8 +2335,8 @@ var UploadScriptsComponent = (props) => {
|
|
|
3352
2335
|
console.log("failed files : ", failedFiles);
|
|
3353
2336
|
const names = failedFiles.map((file) => file.name);
|
|
3354
2337
|
console.log("names : ", failedFiles.map((file) => {
|
|
3355
|
-
var
|
|
3356
|
-
return (
|
|
2338
|
+
var _a, _b;
|
|
2339
|
+
return (_b = (_a = file == null ? void 0 : file.fk) == null ? void 0 : _a.name) == null ? void 0 : _b.records;
|
|
3357
2340
|
}));
|
|
3358
2341
|
setStatus("fonts uploaded with errors. Failed files : " + names.join(", "));
|
|
3359
2342
|
} else {
|
|
@@ -3366,26 +2349,26 @@ var UploadScriptsComponent = (props) => {
|
|
|
3366
2349
|
}
|
|
3367
2350
|
setReady(true);
|
|
3368
2351
|
}, [title, slug, doc_id]);
|
|
3369
|
-
return /* @__PURE__ */
|
|
3370
|
-
|
|
2352
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Stack, null, !ready && /* @__PURE__ */ _react2.default.createElement(_ui.Text, null, /* @__PURE__ */ _react2.default.createElement("br", null), status, /* @__PURE__ */ _react2.default.createElement("br", null), /* @__PURE__ */ _react2.default.createElement("br", null)), ready && /* @__PURE__ */ _react2.default.createElement(_ui.Stack, null, /* @__PURE__ */ _react2.default.createElement(_ui.Grid, { columns: !!(selectedScript && selectedScript !== "") ? 2 : 1, gap: 2 }, /* @__PURE__ */ _react2.default.createElement(
|
|
2353
|
+
_ui.Select,
|
|
3371
2354
|
{
|
|
3372
2355
|
id: "menu-button-example",
|
|
3373
2356
|
onChange: (e) => setSelectedScript(e.target.value)
|
|
3374
2357
|
},
|
|
3375
|
-
/* @__PURE__ */
|
|
2358
|
+
/* @__PURE__ */ _react2.default.createElement("option", { key: "script-none", value: "" }, " "),
|
|
3376
2359
|
SCRIPTS.map(
|
|
3377
2360
|
(script, i) => {
|
|
3378
2361
|
var _a;
|
|
3379
|
-
return /* @__PURE__ */
|
|
2362
|
+
return /* @__PURE__ */ _react2.default.createElement("option", { key: "script-" + i, value: script }, ((_a = script[0]) == null ? void 0 : _a.toUpperCase()) + script.slice(1));
|
|
3380
2363
|
}
|
|
3381
2364
|
)
|
|
3382
|
-
), !!(selectedScript && selectedScript !== "") && /* @__PURE__ */
|
|
3383
|
-
|
|
2365
|
+
), !!(selectedScript && selectedScript !== "") && /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, /* @__PURE__ */ _react2.default.createElement("label", { htmlFor: "upload-scripts-file" }, /* @__PURE__ */ _react2.default.createElement(
|
|
2366
|
+
_ui.Button,
|
|
3384
2367
|
{
|
|
3385
2368
|
style: { pointerEvents: "none" },
|
|
3386
2369
|
text: "Upload (ttf/otf/woff/woff2/etc..)"
|
|
3387
2370
|
}
|
|
3388
|
-
)), /* @__PURE__ */
|
|
2371
|
+
)), /* @__PURE__ */ _react2.default.createElement(
|
|
3389
2372
|
"input",
|
|
3390
2373
|
{
|
|
3391
2374
|
ref,
|
|
@@ -3400,9 +2383,9 @@ var UploadScriptsComponent = (props) => {
|
|
|
3400
2383
|
};
|
|
3401
2384
|
|
|
3402
2385
|
// src/components/FontScriptUploaderComponent.jsx
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
2386
|
+
|
|
2387
|
+
|
|
2388
|
+
|
|
3406
2389
|
var FontScriptUploaderComponent = (props) => {
|
|
3407
2390
|
const client = useSanityClient();
|
|
3408
2391
|
const {
|
|
@@ -3410,23 +2393,23 @@ var FontScriptUploaderComponent = (props) => {
|
|
|
3410
2393
|
onChange,
|
|
3411
2394
|
value = ""
|
|
3412
2395
|
} = props;
|
|
3413
|
-
const [expanded, setExpanded] = (0,
|
|
3414
|
-
const [message, setMessage] = (0,
|
|
3415
|
-
const [status, setStatus] = (0,
|
|
3416
|
-
const [filenames, setFilenames] = (0,
|
|
3417
|
-
let scriptFileInput = (0,
|
|
3418
|
-
let fileInput = (0,
|
|
3419
|
-
let doc_id = (0,
|
|
3420
|
-
let doc_title = (0,
|
|
3421
|
-
let doc_variableFont = (0,
|
|
3422
|
-
let doc_weight = (0,
|
|
3423
|
-
let doc_style = (0,
|
|
3424
|
-
let doc_slug = (0,
|
|
3425
|
-
(0,
|
|
2396
|
+
const [expanded, setExpanded] = _react.useState.call(void 0, SCRIPTS.reduce((acc, language) => ({ ...acc, [language]: true }), {}));
|
|
2397
|
+
const [message, setMessage] = _react.useState.call(void 0, {});
|
|
2398
|
+
const [status, setStatus] = _react.useState.call(void 0, "ready");
|
|
2399
|
+
const [filenames, setFilenames] = _react.useState.call(void 0, {});
|
|
2400
|
+
let scriptFileInput = _sanity.useFormValue.call(void 0, ["scriptFileInput"]) || [];
|
|
2401
|
+
let fileInput = _sanity.useFormValue.call(void 0, ["fileInput"]);
|
|
2402
|
+
let doc_id = _sanity.useFormValue.call(void 0, ["_id"]);
|
|
2403
|
+
let doc_title = _sanity.useFormValue.call(void 0, ["title"]);
|
|
2404
|
+
let doc_variableFont = _sanity.useFormValue.call(void 0, ["variableFont"]);
|
|
2405
|
+
let doc_weight = _sanity.useFormValue.call(void 0, ["weight"]);
|
|
2406
|
+
let doc_style = _sanity.useFormValue.call(void 0, ["style"]);
|
|
2407
|
+
let doc_slug = _sanity.useFormValue.call(void 0, ["slug"]);
|
|
2408
|
+
_react.useEffect.call(void 0, () => {
|
|
3426
2409
|
if (!scriptFileInput || Object.keys(scriptFileInput).length === 0) return;
|
|
3427
2410
|
handleSetFilenames();
|
|
3428
2411
|
}, [scriptFileInput]);
|
|
3429
|
-
const handleSetFilenames = (0,
|
|
2412
|
+
const handleSetFilenames = _react.useCallback.call(void 0, async () => {
|
|
3430
2413
|
console.log("Set font names ", scriptFileInput);
|
|
3431
2414
|
let allIds = [];
|
|
3432
2415
|
const assetIds = SCRIPTS.reduce((acc, language) => {
|
|
@@ -3460,7 +2443,7 @@ var FontScriptUploaderComponent = (props) => {
|
|
|
3460
2443
|
});
|
|
3461
2444
|
setFilenames(fontNames);
|
|
3462
2445
|
}, [scriptFileInput]);
|
|
3463
|
-
const handleGenerateCssFile = (0,
|
|
2446
|
+
const handleGenerateCssFile = _react.useCallback.call(void 0, async (language) => {
|
|
3464
2447
|
var _a, _b, _c;
|
|
3465
2448
|
setMessage({ ...message, [language]: "Generating css: " + doc_title + ".css" });
|
|
3466
2449
|
const woff2AssetRef = (_c = (_b = (_a = scriptFileInput[language]) == null ? void 0 : _a.woff2) == null ? void 0 : _b.asset) == null ? void 0 : _c._ref;
|
|
@@ -3470,7 +2453,7 @@ var FontScriptUploaderComponent = (props) => {
|
|
|
3470
2453
|
);
|
|
3471
2454
|
let blob = await fetch(woff2Buffer.url);
|
|
3472
2455
|
blob = await blob.blob();
|
|
3473
|
-
let newFileInput = await generateCssFile({
|
|
2456
|
+
let newFileInput = await _chunkJCDZ7SWZjs.generateCssFile.call(void 0, {
|
|
3474
2457
|
woff2File: blob,
|
|
3475
2458
|
fileInput: scriptFileInput,
|
|
3476
2459
|
language,
|
|
@@ -3485,9 +2468,9 @@ var FontScriptUploaderComponent = (props) => {
|
|
|
3485
2468
|
setTimeout(() => {
|
|
3486
2469
|
setMessage({});
|
|
3487
2470
|
}, 2e3);
|
|
3488
|
-
onChange((0,
|
|
2471
|
+
onChange(_sanity.set.call(void 0, newFileInput));
|
|
3489
2472
|
}, [scriptFileInput, onChange, doc_title, doc_variableFont]);
|
|
3490
|
-
const handleGenerateFontFile = (0,
|
|
2473
|
+
const handleGenerateFontFile = _react.useCallback.call(void 0, async (code, sourceFile, language) => {
|
|
3491
2474
|
var _a;
|
|
3492
2475
|
setMessage({ ...message, [language]: "Generating files: ", code });
|
|
3493
2476
|
let url = `https://cdn.sanity.io/files/${process.env.SANITY_STUDIO_PROJECT_ID}/${process.env.SANITY_STUDIO_DATASET}/${(_a = sourceFile == null ? void 0 : sourceFile.asset) == null ? void 0 : _a._ref.replace("file-", "").replace("-", ".")}`;
|
|
@@ -3524,7 +2507,7 @@ var FontScriptUploaderComponent = (props) => {
|
|
|
3524
2507
|
setMessage({});
|
|
3525
2508
|
}, 2e3);
|
|
3526
2509
|
}, []);
|
|
3527
|
-
const handleUpload = (0,
|
|
2510
|
+
const handleUpload = _react.useCallback.call(void 0, async (event, language, code) => {
|
|
3528
2511
|
console.log("Handle upload ", scriptFileInput, language, code);
|
|
3529
2512
|
let file = event.target.files[0];
|
|
3530
2513
|
let filename = doc_slug.current + "-" + language + "." + file.name.split(".").pop();
|
|
@@ -3555,7 +2538,7 @@ var FontScriptUploaderComponent = (props) => {
|
|
|
3555
2538
|
if (code === "woff2") {
|
|
3556
2539
|
console.log("woff2");
|
|
3557
2540
|
setMessage({ ...message, [language]: "Generating Css: " + doc_title + ".css" });
|
|
3558
|
-
newFileInput = await generateCssFile({
|
|
2541
|
+
newFileInput = await _chunkJCDZ7SWZjs.generateCssFile.call(void 0, {
|
|
3559
2542
|
woff2File: file,
|
|
3560
2543
|
fileInput: newFileInput,
|
|
3561
2544
|
language,
|
|
@@ -3568,16 +2551,16 @@ var FontScriptUploaderComponent = (props) => {
|
|
|
3568
2551
|
});
|
|
3569
2552
|
setMessage({ ...message, [language]: "" + doc_title + ".css generated!" });
|
|
3570
2553
|
}
|
|
3571
|
-
onChange((0,
|
|
2554
|
+
onChange(_sanity.set.call(void 0, newFileInput));
|
|
3572
2555
|
}, [scriptFileInput, onChange, doc_title, doc_variableFont, doc_slug]);
|
|
3573
|
-
const handleDelete = (0,
|
|
2556
|
+
const handleDelete = _react.useCallback.call(void 0, async (code, language) => {
|
|
3574
2557
|
var _a, _b;
|
|
3575
2558
|
console.log("Delete : ", code, language);
|
|
3576
2559
|
setMessage({ ...message, [language]: `deleting ${language} ${code}` });
|
|
3577
2560
|
const asset = (_b = (_a = scriptFileInput[language][code]) == null ? void 0 : _a.asset) == null ? void 0 : _b._ref;
|
|
3578
2561
|
let newFileInput = { ...scriptFileInput };
|
|
3579
2562
|
delete newFileInput[language][code];
|
|
3580
|
-
onChange((0,
|
|
2563
|
+
onChange(_sanity.unset.call(void 0, [language, code]));
|
|
3581
2564
|
await client.delete(asset).then((result) => {
|
|
3582
2565
|
setMessage({ ...message, [language]: "deleted asset: ", result });
|
|
3583
2566
|
setTimeout(() => {
|
|
@@ -3588,10 +2571,10 @@ var FontScriptUploaderComponent = (props) => {
|
|
|
3588
2571
|
setMessage({ ...message, [language]: "WARNING: " + e.message });
|
|
3589
2572
|
});
|
|
3590
2573
|
}, [doc_id, scriptFileInput, onChange]);
|
|
3591
|
-
const handleDeleteAll = (0,
|
|
2574
|
+
const handleDeleteAll = _react.useCallback.call(void 0, async (language) => {
|
|
3592
2575
|
var _a, _b;
|
|
3593
2576
|
setMessage({ ...message, [language]: "deleting..." });
|
|
3594
|
-
onChange((0,
|
|
2577
|
+
onChange(_sanity.unset.call(void 0, [language]));
|
|
3595
2578
|
console.log("Delete all : ", scriptFileInput[language]);
|
|
3596
2579
|
for (var i = 0; i < Object.keys(scriptFileInput[language]).length; i++) {
|
|
3597
2580
|
let refKey = Object.keys(scriptFileInput[language])[i];
|
|
@@ -3609,18 +2592,18 @@ var FontScriptUploaderComponent = (props) => {
|
|
|
3609
2592
|
}
|
|
3610
2593
|
}
|
|
3611
2594
|
}, [scriptFileInput]);
|
|
3612
|
-
return /* @__PURE__ */
|
|
2595
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 4 }, SCRIPTS && scriptFileInput && SCRIPTS.map((language, i) => {
|
|
3613
2596
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga;
|
|
3614
|
-
return /* @__PURE__ */ import_react11.default.createElement(import_ui9.Stack, { space: 2, key: "language-" + i, style: { borderBottom: "1px solid var(--card-border-color)", paddingBottom: 8 } }, /* @__PURE__ */ import_react11.default.createElement(import_ui9.Flex, { gap: 2 }, /* @__PURE__ */ import_react11.default.createElement(import_ui9.Text, { weight: "semibold" }, ((_a = language[0]) == null ? void 0 : _a.toUpperCase()) + language.slice(1)), message && message[language] && message[language] !== "" && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Text, { style: { color: "green" } }, message[language])), expanded[language] && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Stack, { space: 2 }, /* @__PURE__ */ import_react11.default.createElement(import_ui9.Flex, { justify: "space-between", align: "center" }, /* @__PURE__ */ import_react11.default.createElement(import_ui9.Text, null, "TTF:\xA0", !((_d = (_c = (_b = scriptFileInput[language]) == null ? void 0 : _b.ttf) == null ? void 0 : _c.asset) == null ? void 0 : _d._ref) ? ((_e = filenames[language]) == null ? void 0 : _e.ttf) ? /* @__PURE__ */ import_react11.default.createElement("b", null, filenames[language].ttf) : /* @__PURE__ */ import_react11.default.createElement("b", null, "Empty") : /* @__PURE__ */ import_react11.default.createElement("a", { href: `https://cdn.sanity.io/files/${process.env.SANITY_STUDIO_PROJECT_ID}/${process.env.SANITY_STUDIO_DATASET}/${(_h = (_g = (_f = scriptFileInput[language]) == null ? void 0 : _f.ttf) == null ? void 0 : _g.asset) == null ? void 0 : _h._ref.replace("file-", "").replace("-", ".")}`, target: "_blank" }, ((_i = filenames[language]) == null ? void 0 : _i.ttf) ? /* @__PURE__ */ import_react11.default.createElement("b", null, filenames[language].ttf) : /* @__PURE__ */ import_react11.default.createElement("b", null, "File"))), status === "ready" && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Flex, { gap: 1 }, /* @__PURE__ */ import_react11.default.createElement("label", null, /* @__PURE__ */ import_react11.default.createElement(import_ui9.Button, { as: "span", mode: "ghost" }, "Upload"), /* @__PURE__ */ import_react11.default.createElement("input", { ref, type: "file", style: { display: "none" }, onChange: (event) => handleUpload(event, language, "ttf") })), ((_j = value[language]) == null ? void 0 : _j.ttf) && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Button, { mode: "ghost", tone: "critical", onClick: () => handleDelete("ttf", language) }, "\xD7"))), status === "ready" && ((_k = value[language]) == null ? void 0 : _k.ttf) && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Button, { mode: "default", onClick: () => handleGenerateFontFile("all", value[language].ttf, language) }, "Regenerate Files from TTF"), /* @__PURE__ */ import_react11.default.createElement(import_ui9.Flex, { justify: "space-between", align: "center" }, /* @__PURE__ */ import_react11.default.createElement(import_ui9.Text, null, "OTF:\xA0", !((_n = (_m = (_l = scriptFileInput[language]) == null ? void 0 : _l.otf) == null ? void 0 : _m.asset) == null ? void 0 : _n._ref) ? ((_o = filenames[language]) == null ? void 0 : _o.otf) ? /* @__PURE__ */ import_react11.default.createElement("b", null, (_p = filenames[language]) == null ? void 0 : _p.otf) : /* @__PURE__ */ import_react11.default.createElement("b", null, "Empty") : /* @__PURE__ */ import_react11.default.createElement("a", { href: `https://cdn.sanity.io/files/${process.env.SANITY_STUDIO_PROJECT_ID}/${process.env.SANITY_STUDIO_DATASET}/${(_s = (_r = (_q = scriptFileInput[language]) == null ? void 0 : _q.otf) == null ? void 0 : _r.asset) == null ? void 0 : _s._ref.replace("file-", "").replace("-", ".")}`, target: "_blank" }, ((_t = filenames[language]) == null ? void 0 : _t.otf) ? /* @__PURE__ */ import_react11.default.createElement("b", null, (_u = filenames[language]) == null ? void 0 : _u.otf) : /* @__PURE__ */ import_react11.default.createElement("b", null, "File"))), status === "ready" && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Flex, { gap: 1 }, ((_v = value[language]) == null ? void 0 : _v.woff) && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Button, { mode: "default", onClick: () => handleGenerateFontFile("otf", value[language].woff, language) }, "Build"), /* @__PURE__ */ import_react11.default.createElement("label", null, /* @__PURE__ */ import_react11.default.createElement(import_ui9.Button, { as: "span", mode: "ghost" }, "Upload"), /* @__PURE__ */ import_react11.default.createElement("input", { ref, type: "file", style: { display: "none" }, onChange: async (event) => handleUpload(event, language, "otf") })), ((_w = value[language]) == null ? void 0 : _w.otf) && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Button, { mode: "ghost", tone: "critical", onClick: () => handleDelete("otf", language) }, "\xD7"))), /* @__PURE__ */ import_react11.default.createElement(import_ui9.Flex, { justify: "space-between", align: "center" }, /* @__PURE__ */ import_react11.default.createElement(import_ui9.Text, null, "WOFF:\xA0", !((_z = (_y = (_x = scriptFileInput[language]) == null ? void 0 : _x.woff) == null ? void 0 : _y.asset) == null ? void 0 : _z._ref) ? ((_A = filenames[language]) == null ? void 0 : _A.woff) ? /* @__PURE__ */ import_react11.default.createElement("b", null, (_B = filenames[language]) == null ? void 0 : _B.woff) : /* @__PURE__ */ import_react11.default.createElement("b", null, "Empty") : /* @__PURE__ */ import_react11.default.createElement("a", { href: `https://cdn.sanity.io/files/${process.env.SANITY_STUDIO_PROJECT_ID}/${process.env.SANITY_STUDIO_DATASET}/${(_E = (_D = (_C = scriptFileInput[language]) == null ? void 0 : _C.woff) == null ? void 0 : _D.asset) == null ? void 0 : _E._ref.replace("file-", "").replace("-", ".")}`, target: "_blank" }, ((_F = filenames[language]) == null ? void 0 : _F.woff) ? /* @__PURE__ */ import_react11.default.createElement("b", null, (_G = filenames[language]) == null ? void 0 : _G.woff) : /* @__PURE__ */ import_react11.default.createElement("b", null, "File"))), status === "ready" && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Flex, { gap: 1 }, ((_H = value[language]) == null ? void 0 : _H.ttf) && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Button, { mode: "default", onClick: () => handleGenerateFontFile("woff", value[language].ttf, language) }, "Build"), /* @__PURE__ */ import_react11.default.createElement("label", null, /* @__PURE__ */ import_react11.default.createElement(import_ui9.Button, { as: "span", mode: "ghost" }, "Upload"), /* @__PURE__ */ import_react11.default.createElement("input", { ref, type: "file", style: { display: "none" }, onChange: async (event) => handleUpload(event, language, "woff") })), ((_I = value[language]) == null ? void 0 : _I.woff) && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Button, { mode: "ghost", tone: "critical", onClick: () => handleDelete("woff", language) }, "\xD7"))), /* @__PURE__ */ import_react11.default.createElement(import_ui9.Flex, { justify: "space-between", align: "center" }, /* @__PURE__ */ import_react11.default.createElement(import_ui9.Text, null, "WOFF2:\xA0", !((_L = (_K = (_J = scriptFileInput[language]) == null ? void 0 : _J.woff2) == null ? void 0 : _K.asset) == null ? void 0 : _L._ref) ? ((_M = filenames[language]) == null ? void 0 : _M.woff2) ? /* @__PURE__ */ import_react11.default.createElement("b", null, (_N = filenames[language]) == null ? void 0 : _N.woff2) : /* @__PURE__ */ import_react11.default.createElement("b", null, "Empty") : /* @__PURE__ */ import_react11.default.createElement("a", { href: `https://cdn.sanity.io/files/${process.env.SANITY_STUDIO_PROJECT_ID}/${process.env.SANITY_STUDIO_DATASET}/${(_Q = (_P = (_O = scriptFileInput[language]) == null ? void 0 : _O.woff2) == null ? void 0 : _P.asset) == null ? void 0 : _Q._ref.replace("file-", "").replace("-", ".")}`, target: "_blank" }, ((_R = filenames[language]) == null ? void 0 : _R.woff2) ? /* @__PURE__ */ import_react11.default.createElement("b", null, (_S = filenames[language]) == null ? void 0 : _S.woff2) : /* @__PURE__ */ import_react11.default.createElement("b", null, "File"))), status === "ready" && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Flex, { gap: 1 }, ((_T = value[language]) == null ? void 0 : _T.ttf) && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Button, { mode: "default", onClick: () => handleGenerateFontFile("woff2", value[language].ttf, language) }, "Build"), /* @__PURE__ */ import_react11.default.createElement("label", null, /* @__PURE__ */ import_react11.default.createElement(import_ui9.Button, { as: "span", mode: "ghost" }, "Upload"), /* @__PURE__ */ import_react11.default.createElement("input", { ref, type: "file", style: { display: "none" }, onChange: async (event) => handleUpload(event, language, "woff2") })), ((_U = value[language]) == null ? void 0 : _U.woff2) && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Button, { mode: "ghost", tone: "critical", onClick: () => handleDelete("woff2", language) }, "\xD7"))), /* @__PURE__ */ import_react11.default.createElement(import_ui9.Flex, { justify: "space-between", align: "center" }, /* @__PURE__ */ import_react11.default.createElement(import_ui9.Text, null, "EOT:\xA0", !((_X = (_W = (_V = scriptFileInput[language]) == null ? void 0 : _V.eot) == null ? void 0 : _W.asset) == null ? void 0 : _X._ref) ? ((_Y = filenames[language]) == null ? void 0 : _Y.eot) ? /* @__PURE__ */ import_react11.default.createElement("b", null, (_Z = filenames[language]) == null ? void 0 : _Z.eot) : /* @__PURE__ */ import_react11.default.createElement("b", null, "Empty") : /* @__PURE__ */ import_react11.default.createElement("a", { href: `https://cdn.sanity.io/files/${process.env.SANITY_STUDIO_PROJECT_ID}/${process.env.SANITY_STUDIO_DATASET}/${(_aa = (_$ = (__ = scriptFileInput[language]) == null ? void 0 : __.eot) == null ? void 0 : _$.asset) == null ? void 0 : _aa._ref.replace("file-", "").replace("-", ".")}`, target: "_blank" }, ((_ba = filenames[language]) == null ? void 0 : _ba.eot) ? /* @__PURE__ */ import_react11.default.createElement("b", null, (_ca = filenames[language]) == null ? void 0 : _ca.eot) : /* @__PURE__ */ import_react11.default.createElement("b", null, "File"))), status === "ready" && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Flex, { gap: 1 }, ((_da = value[language]) == null ? void 0 : _da.ttf) && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Button, { mode: "default", onClick: () => handleGenerateFontFile("eot", value[language].ttf, language) }, "Build"), /* @__PURE__ */ import_react11.default.createElement("label", null, /* @__PURE__ */ import_react11.default.createElement(import_ui9.Button, { as: "span", mode: "ghost" }, "Upload"), /* @__PURE__ */ import_react11.default.createElement("input", { ref, type: "file", style: { display: "none" }, onChange: async (event) => handleUpload(event, language, "eot") })), ((_ea = value[language]) == null ? void 0 : _ea.eot) && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Button, { mode: "ghost", tone: "critical", onClick: () => handleDelete("eot", language) }, "\xD7"))), /* @__PURE__ */ import_react11.default.createElement(import_ui9.Flex, { justify: "space-between", align: "center" }, /* @__PURE__ */ import_react11.default.createElement(import_ui9.Text, null, "SVG:\xA0", !((_ha = (_ga = (_fa = scriptFileInput[language]) == null ? void 0 : _fa.svg) == null ? void 0 : _ga.asset) == null ? void 0 : _ha._ref) ? ((_ia = filenames[language]) == null ? void 0 : _ia.svg) ? /* @__PURE__ */ import_react11.default.createElement("b", null, (_ja = filenames[language]) == null ? void 0 : _ja.svg) : /* @__PURE__ */ import_react11.default.createElement("b", null, "Empty") : /* @__PURE__ */ import_react11.default.createElement("a", { href: `https://cdn.sanity.io/files/${process.env.SANITY_STUDIO_PROJECT_ID}/${process.env.SANITY_STUDIO_DATASET}/${(_ma = (_la = (_ka = scriptFileInput[language]) == null ? void 0 : _ka.svg) == null ? void 0 : _la.asset) == null ? void 0 : _ma._ref.replace("file-", "").replace("-", ".")}`, target: "_blank" }, ((_na = filenames[language]) == null ? void 0 : _na.svg) ? /* @__PURE__ */ import_react11.default.createElement("b", null, (_oa = filenames[language]) == null ? void 0 : _oa.svg) : /* @__PURE__ */ import_react11.default.createElement("b", null, "File"))), status === "ready" && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Flex, { gap: 1 }, ((_pa = value[language]) == null ? void 0 : _pa.ttf) && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Button, { mode: "default", onClick: () => handleGenerateFontFile("svg", value[language].ttf, language) }, "Build"), /* @__PURE__ */ import_react11.default.createElement("label", null, /* @__PURE__ */ import_react11.default.createElement(import_ui9.Button, { as: "span", mode: "ghost" }, "Upload"), /* @__PURE__ */ import_react11.default.createElement("input", { ref, type: "file", style: { display: "none" }, onChange: async (event) => handleUpload(event, language, "svg") })), ((_qa = value[language]) == null ? void 0 : _qa.svg) && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Button, { mode: "ghost", tone: "critical", onClick: () => handleDelete("svg", language) }, "\xD7"))), /* @__PURE__ */ import_react11.default.createElement(import_ui9.Flex, { justify: "space-between", align: "center" }, /* @__PURE__ */ import_react11.default.createElement(import_ui9.Text, null, "CSS:\xA0", !((_ta = (_sa = (_ra = scriptFileInput[language]) == null ? void 0 : _ra.css) == null ? void 0 : _sa.asset) == null ? void 0 : _ta._ref) ? ((_ua = filenames[language]) == null ? void 0 : _ua.css) ? /* @__PURE__ */ import_react11.default.createElement("b", null, (_va = filenames[language]) == null ? void 0 : _va.css) : /* @__PURE__ */ import_react11.default.createElement("b", null, "Empty") : /* @__PURE__ */ import_react11.default.createElement("a", { href: `https://cdn.sanity.io/files/${process.env.SANITY_STUDIO_PROJECT_ID}/${process.env.SANITY_STUDIO_DATASET}/${(_ya = (_xa = (_wa = scriptFileInput[language]) == null ? void 0 : _wa.css) == null ? void 0 : _xa.asset) == null ? void 0 : _ya._ref.replace("file-", "").replace("-", ".")}`, target: "_blank" }, ((_za = filenames[language]) == null ? void 0 : _za.css) ? /* @__PURE__ */ import_react11.default.createElement("b", null, (_Aa = filenames[language]) == null ? void 0 : _Aa.css) : /* @__PURE__ */ import_react11.default.createElement("b", null, "File"))), status === "ready" && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Flex, { gap: 1 }, ((_Ba = value[language]) == null ? void 0 : _Ba.woff2) && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Button, { mode: "default", onClick: () => handleGenerateCssFile(language) }, "Build"), ((_Ca = value[language]) == null ? void 0 : _Ca.css) && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Button, { mode: "ghost", tone: "critical", onClick: () => handleDelete("css", language) }, "\xD7"))), status === "ready" && (((_Da = value[language]) == null ? void 0 : _Da.ttf) || ((_Ea = value[language]) == null ? void 0 : _Ea.otf) || ((_Fa = value[language]) == null ? void 0 : _Fa.woff) || ((_Ga = value[language]) == null ? void 0 : _Ga.woff2)) && /* @__PURE__ */ import_react11.default.createElement(import_ui9.Button, { mode: "ghost", tone: "critical", onClick: () => handleDeleteAll(language), style: { width: "100%" } }, "Delete All")));
|
|
2597
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 2, key: "language-" + i, style: { borderBottom: "1px solid var(--card-border-color)", paddingBottom: 8 } }, /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { gap: 2 }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { weight: "semibold" }, ((_a = language[0]) == null ? void 0 : _a.toUpperCase()) + language.slice(1)), message && message[language] && message[language] !== "" && /* @__PURE__ */ _react2.default.createElement(_ui.Text, { style: { color: "green" } }, message[language])), expanded[language] && /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 2 }, /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { justify: "space-between", align: "center" }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, null, "TTF:\xA0", !((_d = (_c = (_b = scriptFileInput[language]) == null ? void 0 : _b.ttf) == null ? void 0 : _c.asset) == null ? void 0 : _d._ref) ? ((_e = filenames[language]) == null ? void 0 : _e.ttf) ? /* @__PURE__ */ _react2.default.createElement("b", null, filenames[language].ttf) : /* @__PURE__ */ _react2.default.createElement("b", null, "Empty") : /* @__PURE__ */ _react2.default.createElement("a", { href: `https://cdn.sanity.io/files/${process.env.SANITY_STUDIO_PROJECT_ID}/${process.env.SANITY_STUDIO_DATASET}/${(_h = (_g = (_f = scriptFileInput[language]) == null ? void 0 : _f.ttf) == null ? void 0 : _g.asset) == null ? void 0 : _h._ref.replace("file-", "").replace("-", ".")}`, target: "_blank" }, ((_i = filenames[language]) == null ? void 0 : _i.ttf) ? /* @__PURE__ */ _react2.default.createElement("b", null, filenames[language].ttf) : /* @__PURE__ */ _react2.default.createElement("b", null, "File"))), status === "ready" && /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { gap: 1 }, /* @__PURE__ */ _react2.default.createElement("label", null, /* @__PURE__ */ _react2.default.createElement(_ui.Button, { as: "span", mode: "ghost" }, "Upload"), /* @__PURE__ */ _react2.default.createElement("input", { ref, type: "file", style: { display: "none" }, onChange: (event) => handleUpload(event, language, "ttf") })), ((_j = value[language]) == null ? void 0 : _j.ttf) && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "ghost", tone: "critical", onClick: () => handleDelete("ttf", language) }, "\xD7"))), status === "ready" && ((_k = value[language]) == null ? void 0 : _k.ttf) && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "default", onClick: () => handleGenerateFontFile("all", value[language].ttf, language) }, "Regenerate Files from TTF"), /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { justify: "space-between", align: "center" }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, null, "OTF:\xA0", !((_n = (_m = (_l = scriptFileInput[language]) == null ? void 0 : _l.otf) == null ? void 0 : _m.asset) == null ? void 0 : _n._ref) ? ((_o = filenames[language]) == null ? void 0 : _o.otf) ? /* @__PURE__ */ _react2.default.createElement("b", null, (_p = filenames[language]) == null ? void 0 : _p.otf) : /* @__PURE__ */ _react2.default.createElement("b", null, "Empty") : /* @__PURE__ */ _react2.default.createElement("a", { href: `https://cdn.sanity.io/files/${process.env.SANITY_STUDIO_PROJECT_ID}/${process.env.SANITY_STUDIO_DATASET}/${(_s = (_r = (_q = scriptFileInput[language]) == null ? void 0 : _q.otf) == null ? void 0 : _r.asset) == null ? void 0 : _s._ref.replace("file-", "").replace("-", ".")}`, target: "_blank" }, ((_t = filenames[language]) == null ? void 0 : _t.otf) ? /* @__PURE__ */ _react2.default.createElement("b", null, (_u = filenames[language]) == null ? void 0 : _u.otf) : /* @__PURE__ */ _react2.default.createElement("b", null, "File"))), status === "ready" && /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { gap: 1 }, ((_v = value[language]) == null ? void 0 : _v.woff) && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "default", onClick: () => handleGenerateFontFile("otf", value[language].woff, language) }, "Build"), /* @__PURE__ */ _react2.default.createElement("label", null, /* @__PURE__ */ _react2.default.createElement(_ui.Button, { as: "span", mode: "ghost" }, "Upload"), /* @__PURE__ */ _react2.default.createElement("input", { ref, type: "file", style: { display: "none" }, onChange: async (event) => handleUpload(event, language, "otf") })), ((_w = value[language]) == null ? void 0 : _w.otf) && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "ghost", tone: "critical", onClick: () => handleDelete("otf", language) }, "\xD7"))), /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { justify: "space-between", align: "center" }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, null, "WOFF:\xA0", !((_z = (_y = (_x = scriptFileInput[language]) == null ? void 0 : _x.woff) == null ? void 0 : _y.asset) == null ? void 0 : _z._ref) ? ((_A = filenames[language]) == null ? void 0 : _A.woff) ? /* @__PURE__ */ _react2.default.createElement("b", null, (_B = filenames[language]) == null ? void 0 : _B.woff) : /* @__PURE__ */ _react2.default.createElement("b", null, "Empty") : /* @__PURE__ */ _react2.default.createElement("a", { href: `https://cdn.sanity.io/files/${process.env.SANITY_STUDIO_PROJECT_ID}/${process.env.SANITY_STUDIO_DATASET}/${(_E = (_D = (_C = scriptFileInput[language]) == null ? void 0 : _C.woff) == null ? void 0 : _D.asset) == null ? void 0 : _E._ref.replace("file-", "").replace("-", ".")}`, target: "_blank" }, ((_F = filenames[language]) == null ? void 0 : _F.woff) ? /* @__PURE__ */ _react2.default.createElement("b", null, (_G = filenames[language]) == null ? void 0 : _G.woff) : /* @__PURE__ */ _react2.default.createElement("b", null, "File"))), status === "ready" && /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { gap: 1 }, ((_H = value[language]) == null ? void 0 : _H.ttf) && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "default", onClick: () => handleGenerateFontFile("woff", value[language].ttf, language) }, "Build"), /* @__PURE__ */ _react2.default.createElement("label", null, /* @__PURE__ */ _react2.default.createElement(_ui.Button, { as: "span", mode: "ghost" }, "Upload"), /* @__PURE__ */ _react2.default.createElement("input", { ref, type: "file", style: { display: "none" }, onChange: async (event) => handleUpload(event, language, "woff") })), ((_I = value[language]) == null ? void 0 : _I.woff) && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "ghost", tone: "critical", onClick: () => handleDelete("woff", language) }, "\xD7"))), /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { justify: "space-between", align: "center" }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, null, "WOFF2:\xA0", !((_L = (_K = (_J = scriptFileInput[language]) == null ? void 0 : _J.woff2) == null ? void 0 : _K.asset) == null ? void 0 : _L._ref) ? ((_M = filenames[language]) == null ? void 0 : _M.woff2) ? /* @__PURE__ */ _react2.default.createElement("b", null, (_N = filenames[language]) == null ? void 0 : _N.woff2) : /* @__PURE__ */ _react2.default.createElement("b", null, "Empty") : /* @__PURE__ */ _react2.default.createElement("a", { href: `https://cdn.sanity.io/files/${process.env.SANITY_STUDIO_PROJECT_ID}/${process.env.SANITY_STUDIO_DATASET}/${(_Q = (_P = (_O = scriptFileInput[language]) == null ? void 0 : _O.woff2) == null ? void 0 : _P.asset) == null ? void 0 : _Q._ref.replace("file-", "").replace("-", ".")}`, target: "_blank" }, ((_R = filenames[language]) == null ? void 0 : _R.woff2) ? /* @__PURE__ */ _react2.default.createElement("b", null, (_S = filenames[language]) == null ? void 0 : _S.woff2) : /* @__PURE__ */ _react2.default.createElement("b", null, "File"))), status === "ready" && /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { gap: 1 }, ((_T = value[language]) == null ? void 0 : _T.ttf) && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "default", onClick: () => handleGenerateFontFile("woff2", value[language].ttf, language) }, "Build"), /* @__PURE__ */ _react2.default.createElement("label", null, /* @__PURE__ */ _react2.default.createElement(_ui.Button, { as: "span", mode: "ghost" }, "Upload"), /* @__PURE__ */ _react2.default.createElement("input", { ref, type: "file", style: { display: "none" }, onChange: async (event) => handleUpload(event, language, "woff2") })), ((_U = value[language]) == null ? void 0 : _U.woff2) && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "ghost", tone: "critical", onClick: () => handleDelete("woff2", language) }, "\xD7"))), /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { justify: "space-between", align: "center" }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, null, "EOT:\xA0", !((_X = (_W = (_V = scriptFileInput[language]) == null ? void 0 : _V.eot) == null ? void 0 : _W.asset) == null ? void 0 : _X._ref) ? ((_Y = filenames[language]) == null ? void 0 : _Y.eot) ? /* @__PURE__ */ _react2.default.createElement("b", null, (_Z = filenames[language]) == null ? void 0 : _Z.eot) : /* @__PURE__ */ _react2.default.createElement("b", null, "Empty") : /* @__PURE__ */ _react2.default.createElement("a", { href: `https://cdn.sanity.io/files/${process.env.SANITY_STUDIO_PROJECT_ID}/${process.env.SANITY_STUDIO_DATASET}/${(_aa = (_$ = (__ = scriptFileInput[language]) == null ? void 0 : __.eot) == null ? void 0 : _$.asset) == null ? void 0 : _aa._ref.replace("file-", "").replace("-", ".")}`, target: "_blank" }, ((_ba = filenames[language]) == null ? void 0 : _ba.eot) ? /* @__PURE__ */ _react2.default.createElement("b", null, (_ca = filenames[language]) == null ? void 0 : _ca.eot) : /* @__PURE__ */ _react2.default.createElement("b", null, "File"))), status === "ready" && /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { gap: 1 }, ((_da = value[language]) == null ? void 0 : _da.ttf) && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "default", onClick: () => handleGenerateFontFile("eot", value[language].ttf, language) }, "Build"), /* @__PURE__ */ _react2.default.createElement("label", null, /* @__PURE__ */ _react2.default.createElement(_ui.Button, { as: "span", mode: "ghost" }, "Upload"), /* @__PURE__ */ _react2.default.createElement("input", { ref, type: "file", style: { display: "none" }, onChange: async (event) => handleUpload(event, language, "eot") })), ((_ea = value[language]) == null ? void 0 : _ea.eot) && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "ghost", tone: "critical", onClick: () => handleDelete("eot", language) }, "\xD7"))), /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { justify: "space-between", align: "center" }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, null, "SVG:\xA0", !((_ha = (_ga = (_fa = scriptFileInput[language]) == null ? void 0 : _fa.svg) == null ? void 0 : _ga.asset) == null ? void 0 : _ha._ref) ? ((_ia = filenames[language]) == null ? void 0 : _ia.svg) ? /* @__PURE__ */ _react2.default.createElement("b", null, (_ja = filenames[language]) == null ? void 0 : _ja.svg) : /* @__PURE__ */ _react2.default.createElement("b", null, "Empty") : /* @__PURE__ */ _react2.default.createElement("a", { href: `https://cdn.sanity.io/files/${process.env.SANITY_STUDIO_PROJECT_ID}/${process.env.SANITY_STUDIO_DATASET}/${(_ma = (_la = (_ka = scriptFileInput[language]) == null ? void 0 : _ka.svg) == null ? void 0 : _la.asset) == null ? void 0 : _ma._ref.replace("file-", "").replace("-", ".")}`, target: "_blank" }, ((_na = filenames[language]) == null ? void 0 : _na.svg) ? /* @__PURE__ */ _react2.default.createElement("b", null, (_oa = filenames[language]) == null ? void 0 : _oa.svg) : /* @__PURE__ */ _react2.default.createElement("b", null, "File"))), status === "ready" && /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { gap: 1 }, ((_pa = value[language]) == null ? void 0 : _pa.ttf) && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "default", onClick: () => handleGenerateFontFile("svg", value[language].ttf, language) }, "Build"), /* @__PURE__ */ _react2.default.createElement("label", null, /* @__PURE__ */ _react2.default.createElement(_ui.Button, { as: "span", mode: "ghost" }, "Upload"), /* @__PURE__ */ _react2.default.createElement("input", { ref, type: "file", style: { display: "none" }, onChange: async (event) => handleUpload(event, language, "svg") })), ((_qa = value[language]) == null ? void 0 : _qa.svg) && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "ghost", tone: "critical", onClick: () => handleDelete("svg", language) }, "\xD7"))), /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { justify: "space-between", align: "center" }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, null, "CSS:\xA0", !((_ta = (_sa = (_ra = scriptFileInput[language]) == null ? void 0 : _ra.css) == null ? void 0 : _sa.asset) == null ? void 0 : _ta._ref) ? ((_ua = filenames[language]) == null ? void 0 : _ua.css) ? /* @__PURE__ */ _react2.default.createElement("b", null, (_va = filenames[language]) == null ? void 0 : _va.css) : /* @__PURE__ */ _react2.default.createElement("b", null, "Empty") : /* @__PURE__ */ _react2.default.createElement("a", { href: `https://cdn.sanity.io/files/${process.env.SANITY_STUDIO_PROJECT_ID}/${process.env.SANITY_STUDIO_DATASET}/${(_ya = (_xa = (_wa = scriptFileInput[language]) == null ? void 0 : _wa.css) == null ? void 0 : _xa.asset) == null ? void 0 : _ya._ref.replace("file-", "").replace("-", ".")}`, target: "_blank" }, ((_za = filenames[language]) == null ? void 0 : _za.css) ? /* @__PURE__ */ _react2.default.createElement("b", null, (_Aa = filenames[language]) == null ? void 0 : _Aa.css) : /* @__PURE__ */ _react2.default.createElement("b", null, "File"))), status === "ready" && /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { gap: 1 }, ((_Ba = value[language]) == null ? void 0 : _Ba.woff2) && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "default", onClick: () => handleGenerateCssFile(language) }, "Build"), ((_Ca = value[language]) == null ? void 0 : _Ca.css) && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "ghost", tone: "critical", onClick: () => handleDelete("css", language) }, "\xD7"))), status === "ready" && (((_Da = value[language]) == null ? void 0 : _Da.ttf) || ((_Ea = value[language]) == null ? void 0 : _Ea.otf) || ((_Fa = value[language]) == null ? void 0 : _Fa.woff) || ((_Ga = value[language]) == null ? void 0 : _Ga.woff2)) && /* @__PURE__ */ _react2.default.createElement(_ui.Button, { mode: "ghost", tone: "critical", onClick: () => handleDeleteAll(language), style: { width: "100%" } }, "Delete All")));
|
|
3615
2598
|
}));
|
|
3616
2599
|
};
|
|
3617
2600
|
|
|
3618
2601
|
// src/components/UploadButton.jsx
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
var UploadButton = (0,
|
|
3622
|
-
return /* @__PURE__ */
|
|
3623
|
-
|
|
2602
|
+
|
|
2603
|
+
|
|
2604
|
+
var UploadButton = _react.forwardRef.call(void 0, ({ handleUpload }, ref) => {
|
|
2605
|
+
return /* @__PURE__ */ _react2.default.createElement(
|
|
2606
|
+
_ui.Button,
|
|
3624
2607
|
{
|
|
3625
2608
|
mode: "ghost",
|
|
3626
2609
|
tone: "primary",
|
|
@@ -3628,8 +2611,8 @@ var UploadButton = (0, import_react12.forwardRef)(({ handleUpload }, ref) => {
|
|
|
3628
2611
|
padding: 3,
|
|
3629
2612
|
style: { position: "relative" }
|
|
3630
2613
|
},
|
|
3631
|
-
/* @__PURE__ */
|
|
3632
|
-
/* @__PURE__ */
|
|
2614
|
+
/* @__PURE__ */ _react2.default.createElement(_ui.Text, { align: "center" }, "Upload (ttf/otf/woff/woff2/etc...)"),
|
|
2615
|
+
/* @__PURE__ */ _react2.default.createElement(
|
|
3633
2616
|
"input",
|
|
3634
2617
|
{
|
|
3635
2618
|
ref,
|
|
@@ -3653,84 +2636,84 @@ UploadButton.displayName = "UploadButton";
|
|
|
3653
2636
|
var UploadButton_default = UploadButton;
|
|
3654
2637
|
|
|
3655
2638
|
// src/components/KeyValueInput.jsx
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
2639
|
+
|
|
2640
|
+
|
|
2641
|
+
|
|
2642
|
+
|
|
3660
2643
|
function KeyValueInput({ value = [], onChange }) {
|
|
3661
|
-
const [pairs, setPairs] = (0,
|
|
3662
|
-
const handlePairChange = (0,
|
|
2644
|
+
const [pairs, setPairs] = _react.useState.call(void 0, value);
|
|
2645
|
+
const handlePairChange = _react.useCallback.call(void 0, (index, field2, fieldValue) => {
|
|
3663
2646
|
const updatedPairs = pairs.map((pair, idx) => idx === index ? { ...pair, [field2]: fieldValue } : pair);
|
|
3664
2647
|
setPairs(updatedPairs);
|
|
3665
|
-
onChange((0,
|
|
2648
|
+
onChange(_sanity.set.call(void 0, updatedPairs));
|
|
3666
2649
|
}, [pairs, onChange]);
|
|
3667
|
-
const handleAddPair = (0,
|
|
2650
|
+
const handleAddPair = _react.useCallback.call(void 0, () => {
|
|
3668
2651
|
const newPair = { key: "", value: "", _key: Math.random().toString(36).substr(2, 9) };
|
|
3669
2652
|
const updatedPairs = [...pairs, newPair];
|
|
3670
2653
|
setPairs(updatedPairs);
|
|
3671
|
-
onChange((0,
|
|
2654
|
+
onChange(_sanity.set.call(void 0, updatedPairs));
|
|
3672
2655
|
}, [pairs, onChange]);
|
|
3673
|
-
const handleRemovePair = (0,
|
|
2656
|
+
const handleRemovePair = _react.useCallback.call(void 0, (index) => {
|
|
3674
2657
|
const updatedPairs = pairs.filter((_, idx) => idx !== index);
|
|
3675
2658
|
setPairs(updatedPairs);
|
|
3676
|
-
onChange((0,
|
|
2659
|
+
onChange(_sanity.set.call(void 0, updatedPairs));
|
|
3677
2660
|
}, [pairs, onChange]);
|
|
3678
|
-
const handleMoveUp = (0,
|
|
2661
|
+
const handleMoveUp = _react.useCallback.call(void 0, (index) => {
|
|
3679
2662
|
if (index === 0) return;
|
|
3680
2663
|
const updatedPairs = [...pairs];
|
|
3681
2664
|
[updatedPairs[index], updatedPairs[index - 1]] = [updatedPairs[index - 1], updatedPairs[index]];
|
|
3682
2665
|
setPairs(updatedPairs);
|
|
3683
|
-
onChange((0,
|
|
2666
|
+
onChange(_sanity.set.call(void 0, updatedPairs));
|
|
3684
2667
|
}, [pairs, onChange]);
|
|
3685
|
-
const handleMoveDown = (0,
|
|
2668
|
+
const handleMoveDown = _react.useCallback.call(void 0, (index) => {
|
|
3686
2669
|
if (index === pairs.length - 1) return;
|
|
3687
2670
|
const updatedPairs = [...pairs];
|
|
3688
2671
|
[updatedPairs[index], updatedPairs[index + 1]] = [updatedPairs[index + 1], updatedPairs[index]];
|
|
3689
2672
|
setPairs(updatedPairs);
|
|
3690
|
-
onChange((0,
|
|
2673
|
+
onChange(_sanity.set.call(void 0, updatedPairs));
|
|
3691
2674
|
}, [pairs, onChange]);
|
|
3692
|
-
return /* @__PURE__ */
|
|
3693
|
-
|
|
2675
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 3 }, pairs.map((pair, index) => /* @__PURE__ */ _react2.default.createElement(_ui.Grid, { className: "manualButtonWrap", columns: [2], key: index, gap: 0, style: { position: "relative" } }, /* @__PURE__ */ _react2.default.createElement("div", { style: { position: "absolute", height: "100%", top: "0", left: "-10px", width: "min-content", transform: "translate(-100%, 0%)" } }, /* @__PURE__ */ _react2.default.createElement("button", { className: "manualButton manualButtonUp", style: { fontSize: "15px", height: "50%" }, onClick: () => handleMoveUp(index) }, /* @__PURE__ */ _react2.default.createElement(_icons.ArrowUpIcon, null)), /* @__PURE__ */ _react2.default.createElement("button", { className: "manualButton manualButtonDown", style: { fontSize: "15px", height: "50%" }, onClick: () => handleMoveDown(index) }, /* @__PURE__ */ _react2.default.createElement(_icons.ArrowDownIcon, null))), /* @__PURE__ */ _react2.default.createElement(
|
|
2676
|
+
_ui.TextInput,
|
|
3694
2677
|
{
|
|
3695
2678
|
value: pair.key,
|
|
3696
2679
|
onChange: (e) => handlePairChange(index, "key", e.target.value),
|
|
3697
2680
|
placeholder: "Key"
|
|
3698
2681
|
}
|
|
3699
|
-
), /* @__PURE__ */
|
|
3700
|
-
|
|
2682
|
+
), /* @__PURE__ */ _react2.default.createElement("div", { style: { marginLeft: "-1px" } }, /* @__PURE__ */ _react2.default.createElement(
|
|
2683
|
+
_ui.TextInput,
|
|
3701
2684
|
{
|
|
3702
2685
|
value: pair.value,
|
|
3703
2686
|
onChange: (e) => handlePairChange(index, "value", e.target.value),
|
|
3704
2687
|
placeholder: "Value"
|
|
3705
2688
|
}
|
|
3706
|
-
)), /* @__PURE__ */
|
|
2689
|
+
)), /* @__PURE__ */ _react2.default.createElement(
|
|
3707
2690
|
"button",
|
|
3708
2691
|
{
|
|
3709
2692
|
className: "manualButton",
|
|
3710
2693
|
onClick: () => handleRemovePair(index),
|
|
3711
2694
|
style: { position: "absolute", top: "0", right: "-10px", transform: "translate(100%, 0%)" }
|
|
3712
2695
|
},
|
|
3713
|
-
/* @__PURE__ */
|
|
3714
|
-
))), /* @__PURE__ */
|
|
2696
|
+
/* @__PURE__ */ _react2.default.createElement(_icons.TrashIcon, null)
|
|
2697
|
+
))), /* @__PURE__ */ _react2.default.createElement(_ui.Button, { tone: "primary", onClick: handleAddPair, icon: _icons.AddIcon, text: "Add Row" }));
|
|
3715
2698
|
}
|
|
3716
2699
|
|
|
3717
2700
|
// src/components/KeyValueReferenceInput.jsx
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
2701
|
+
|
|
2702
|
+
|
|
2703
|
+
|
|
2704
|
+
|
|
2705
|
+
|
|
3723
2706
|
function KeyValueReferenceInput(props) {
|
|
3724
2707
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3725
2708
|
const { value = [], onChange, schemaType, referenceType, fetchReferences, topActions } = props;
|
|
3726
|
-
const [pairs, setPairs] = (0,
|
|
3727
|
-
const [referenceData, setReferenceData] = (0,
|
|
3728
|
-
const [isDialogOpen, setIsDialogOpen] = (0,
|
|
3729
|
-
const [editingIndex, setEditingIndex] = (0,
|
|
3730
|
-
const [availableReferences, setAvailableReferences] = (0,
|
|
2709
|
+
const [pairs, setPairs] = _react.useState.call(void 0, value);
|
|
2710
|
+
const [referenceData, setReferenceData] = _react.useState.call(void 0, {});
|
|
2711
|
+
const [isDialogOpen, setIsDialogOpen] = _react.useState.call(void 0, false);
|
|
2712
|
+
const [editingIndex, setEditingIndex] = _react.useState.call(void 0, null);
|
|
2713
|
+
const [availableReferences, setAvailableReferences] = _react.useState.call(void 0, []);
|
|
3731
2714
|
const sanityClient = useSanityClient();
|
|
3732
|
-
const formDocument = (0,
|
|
3733
|
-
(0,
|
|
2715
|
+
const formDocument = _sanity.useFormValue.call(void 0, []);
|
|
2716
|
+
_react.useEffect.call(void 0, () => {
|
|
3734
2717
|
const refIds = pairs.filter((p) => {
|
|
3735
2718
|
var _a2;
|
|
3736
2719
|
return (_a2 = p.value) == null ? void 0 : _a2._ref;
|
|
@@ -3759,36 +2742,36 @@ function KeyValueReferenceInput(props) {
|
|
|
3759
2742
|
setReferenceData(fallback);
|
|
3760
2743
|
});
|
|
3761
2744
|
}, [pairs, sanityClient]);
|
|
3762
|
-
const handlePairChange = (0,
|
|
2745
|
+
const handlePairChange = _react.useCallback.call(void 0, (index, field2, fieldValue) => {
|
|
3763
2746
|
const updatedPairs = pairs.map((pair, idx) => idx === index ? { ...pair, [field2]: fieldValue } : pair);
|
|
3764
2747
|
setPairs(updatedPairs);
|
|
3765
|
-
onChange((0,
|
|
2748
|
+
onChange(_sanity.set.call(void 0, updatedPairs));
|
|
3766
2749
|
}, [pairs, onChange]);
|
|
3767
|
-
const handleAddPair = (0,
|
|
3768
|
-
const updatedPairs = [...pairs, { key: "", value: null, _key: (0,
|
|
2750
|
+
const handleAddPair = _react.useCallback.call(void 0, () => {
|
|
2751
|
+
const updatedPairs = [...pairs, { key: "", value: null, _key: _nanoid.nanoid.call(void 0, ) }];
|
|
3769
2752
|
setPairs(updatedPairs);
|
|
3770
|
-
onChange((0,
|
|
2753
|
+
onChange(_sanity.set.call(void 0, updatedPairs));
|
|
3771
2754
|
}, [pairs, onChange]);
|
|
3772
|
-
const handleRemovePair = (0,
|
|
2755
|
+
const handleRemovePair = _react.useCallback.call(void 0, (index) => {
|
|
3773
2756
|
const updatedPairs = pairs.filter((_, idx) => idx !== index);
|
|
3774
2757
|
setPairs(updatedPairs);
|
|
3775
|
-
onChange((0,
|
|
2758
|
+
onChange(_sanity.set.call(void 0, updatedPairs));
|
|
3776
2759
|
}, [pairs, onChange]);
|
|
3777
|
-
const handleMoveUp = (0,
|
|
2760
|
+
const handleMoveUp = _react.useCallback.call(void 0, (index) => {
|
|
3778
2761
|
if (index === 0) return;
|
|
3779
2762
|
const updatedPairs = [...pairs];
|
|
3780
2763
|
[updatedPairs[index], updatedPairs[index - 1]] = [updatedPairs[index - 1], updatedPairs[index]];
|
|
3781
2764
|
setPairs(updatedPairs);
|
|
3782
|
-
onChange((0,
|
|
2765
|
+
onChange(_sanity.set.call(void 0, updatedPairs));
|
|
3783
2766
|
}, [pairs, onChange]);
|
|
3784
|
-
const handleMoveDown = (0,
|
|
2767
|
+
const handleMoveDown = _react.useCallback.call(void 0, (index) => {
|
|
3785
2768
|
if (index === pairs.length - 1) return;
|
|
3786
2769
|
const updatedPairs = [...pairs];
|
|
3787
2770
|
[updatedPairs[index], updatedPairs[index + 1]] = [updatedPairs[index + 1], updatedPairs[index]];
|
|
3788
2771
|
setPairs(updatedPairs);
|
|
3789
|
-
onChange((0,
|
|
2772
|
+
onChange(_sanity.set.call(void 0, updatedPairs));
|
|
3790
2773
|
}, [pairs, onChange]);
|
|
3791
|
-
const openReferenceSelector = (0,
|
|
2774
|
+
const openReferenceSelector = _react.useCallback.call(void 0, async (index) => {
|
|
3792
2775
|
setEditingIndex(index);
|
|
3793
2776
|
if (!sanityClient) {
|
|
3794
2777
|
console.error("KeyValueReferenceInput: Sanity client not available");
|
|
@@ -3810,11 +2793,11 @@ function KeyValueReferenceInput(props) {
|
|
|
3810
2793
|
console.error("Error fetching available references:", err);
|
|
3811
2794
|
}
|
|
3812
2795
|
}, [sanityClient, fetchReferences, referenceType, formDocument]);
|
|
3813
|
-
const closeDialog = (0,
|
|
2796
|
+
const closeDialog = _react.useCallback.call(void 0, () => {
|
|
3814
2797
|
setIsDialogOpen(false);
|
|
3815
2798
|
setEditingIndex(null);
|
|
3816
2799
|
}, []);
|
|
3817
|
-
const handleReferenceSelect = (0,
|
|
2800
|
+
const handleReferenceSelect = _react.useCallback.call(void 0, (reference) => {
|
|
3818
2801
|
if (editingIndex === null) return;
|
|
3819
2802
|
handlePairChange(editingIndex, "value", { _type: "reference", _ref: reference._id, _weak: true });
|
|
3820
2803
|
closeDialog();
|
|
@@ -3826,62 +2809,62 @@ function KeyValueReferenceInput(props) {
|
|
|
3826
2809
|
const valueTitle = (valueField == null ? void 0 : valueField.title) || "Value";
|
|
3827
2810
|
const keyPlaceholder = (keyField == null ? void 0 : keyField.placeholder) || "Enter key";
|
|
3828
2811
|
const pickerLabel = referenceType || valueTitle.toLowerCase();
|
|
3829
|
-
return /* @__PURE__ */
|
|
2812
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 3 }, topActions && /* @__PURE__ */ _react2.default.createElement(_ui.Box, { paddingBottom: 2 }, topActions), /* @__PURE__ */ _react2.default.createElement(_ui.Box, null, /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 2 }, pairs.map((pair, index) => {
|
|
3830
2813
|
var _a2;
|
|
3831
|
-
return /* @__PURE__ */
|
|
3832
|
-
|
|
2814
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Box, { key: index, style: { position: "relative" } }, /* @__PURE__ */ _react2.default.createElement("div", { style: { position: "absolute", height: "100%", top: "0", left: "-5px", width: "min-content", transform: "translate(-100%, 0%)" } }, /* @__PURE__ */ _react2.default.createElement("button", { className: "manualButton manualButtonUp", style: { fontSize: "15px", height: "50%" }, onClick: () => handleMoveUp(index) }, /* @__PURE__ */ _react2.default.createElement(_icons.ArrowUpIcon, null)), /* @__PURE__ */ _react2.default.createElement("button", { className: "manualButton manualButtonDown", style: { fontSize: "15px", height: "50%" }, onClick: () => handleMoveDown(index) }, /* @__PURE__ */ _react2.default.createElement(_icons.ArrowDownIcon, null))), /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { gap: 2, align: "flex-start" }, /* @__PURE__ */ _react2.default.createElement(_ui.Box, { flex: 1 }, /* @__PURE__ */ _react2.default.createElement(
|
|
2815
|
+
_ui.TextInput,
|
|
3833
2816
|
{
|
|
3834
2817
|
value: pair.key,
|
|
3835
2818
|
onChange: (e) => handlePairChange(index, "key", e.target.value),
|
|
3836
2819
|
placeholder: keyPlaceholder
|
|
3837
2820
|
}
|
|
3838
|
-
)), /* @__PURE__ */
|
|
3839
|
-
|
|
2821
|
+
)), /* @__PURE__ */ _react2.default.createElement(_ui.Box, { flex: 1, style: { minHeight: "100%" } }, ((_a2 = pair.value) == null ? void 0 : _a2._ref) ? /* @__PURE__ */ _react2.default.createElement(_ui.Card, { className: "referenceCard", radius: 2, tone: "primary", style: { paddingLeft: "1rem", height: "fit-content" } }, /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { align: "center", justify: "space-between" }, /* @__PURE__ */ _react2.default.createElement(
|
|
2822
|
+
_ui.Text,
|
|
3840
2823
|
{
|
|
3841
2824
|
size: 2,
|
|
3842
2825
|
style: { whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", maxWidth: "90%" }
|
|
3843
2826
|
},
|
|
3844
2827
|
referenceData[pair.value._ref] || "Loading..."
|
|
3845
|
-
), /* @__PURE__ */
|
|
3846
|
-
|
|
2828
|
+
), /* @__PURE__ */ _react2.default.createElement(
|
|
2829
|
+
_ui.MenuButton,
|
|
3847
2830
|
{
|
|
3848
|
-
button: /* @__PURE__ */
|
|
2831
|
+
button: /* @__PURE__ */ _react2.default.createElement(_ui.Button, { icon: _icons.EllipsisHorizontalIcon, mode: "bleed", title: "Options" }),
|
|
3849
2832
|
id: `ref-options-${index}`,
|
|
3850
|
-
menu: /* @__PURE__ */
|
|
2833
|
+
menu: /* @__PURE__ */ _react2.default.createElement(_ui.Menu, null, /* @__PURE__ */ _react2.default.createElement(_ui.MenuItem, { tone: "critical", icon: _icons.TrashIcon, text: "Remove", onClick: () => handlePairChange(index, "value", null) }), /* @__PURE__ */ _react2.default.createElement(_ui.MenuItem, { icon: _icons.SyncIcon, text: "Replace", onClick: () => openReferenceSelector(index) })),
|
|
3851
2834
|
popover: { portal: true, tone: "default", placement: "left" }
|
|
3852
2835
|
}
|
|
3853
|
-
))) : /* @__PURE__ */
|
|
3854
|
-
|
|
2836
|
+
))) : /* @__PURE__ */ _react2.default.createElement(
|
|
2837
|
+
_ui.Box,
|
|
3855
2838
|
{
|
|
3856
2839
|
padding: 2,
|
|
3857
2840
|
style: { minHeight: "100%", border: "1px dashed #ccc", borderRadius: "4px", display: "flex", alignItems: "center", justifyContent: "center", cursor: "pointer" },
|
|
3858
2841
|
onClick: () => openReferenceSelector(index)
|
|
3859
2842
|
},
|
|
3860
|
-
/* @__PURE__ */
|
|
3861
|
-
))), /* @__PURE__ */
|
|
2843
|
+
/* @__PURE__ */ _react2.default.createElement(_ui.Text, { muted: true, size: 2 }, "Click to select a ", pickerLabel)
|
|
2844
|
+
))), /* @__PURE__ */ _react2.default.createElement(
|
|
3862
2845
|
"button",
|
|
3863
2846
|
{
|
|
3864
2847
|
className: "manualButton",
|
|
3865
2848
|
onClick: () => handleRemovePair(index),
|
|
3866
2849
|
style: { position: "absolute", top: "0", right: "-7px", transform: "translate(100%, 0%)" }
|
|
3867
2850
|
},
|
|
3868
|
-
/* @__PURE__ */
|
|
2851
|
+
/* @__PURE__ */ _react2.default.createElement(_icons.TrashIcon, null)
|
|
3869
2852
|
));
|
|
3870
|
-
}))), /* @__PURE__ */
|
|
3871
|
-
|
|
2853
|
+
}))), /* @__PURE__ */ _react2.default.createElement(_ui.Button, { tone: "primary", mode: "ghost", onClick: handleAddPair, icon: _icons.AddIcon, text: `Add ${keyTitle}` }), isDialogOpen && /* @__PURE__ */ _react2.default.createElement(
|
|
2854
|
+
_ui.Dialog,
|
|
3872
2855
|
{
|
|
3873
2856
|
header: `Select a ${pickerLabel}`,
|
|
3874
2857
|
id: "reference-selector-dialog",
|
|
3875
2858
|
onClose: closeDialog,
|
|
3876
2859
|
width: 1
|
|
3877
2860
|
},
|
|
3878
|
-
/* @__PURE__ */
|
|
3879
|
-
|
|
2861
|
+
/* @__PURE__ */ _react2.default.createElement(_ui.Box, { padding: 4 }, /* @__PURE__ */ _react2.default.createElement(
|
|
2862
|
+
_ui.Autocomplete,
|
|
3880
2863
|
{
|
|
3881
2864
|
id: "reference-autocomplete",
|
|
3882
2865
|
options: referenceOptions,
|
|
3883
2866
|
placeholder: `Search ${pickerLabel}s...`,
|
|
3884
|
-
renderOption: (option) => /* @__PURE__ */
|
|
2867
|
+
renderOption: (option) => /* @__PURE__ */ _react2.default.createElement(_ui.Card, { key: option.value, padding: 3, radius: 2, tone: "default", style: { cursor: "pointer" } }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 2 }, option.title)),
|
|
3885
2868
|
renderValue: (val) => {
|
|
3886
2869
|
var _a2;
|
|
3887
2870
|
return ((_a2 = referenceOptions.find((o) => o.value === val)) == null ? void 0 : _a2.title) || "";
|
|
@@ -3898,19 +2881,19 @@ function KeyValueReferenceInput(props) {
|
|
|
3898
2881
|
}
|
|
3899
2882
|
|
|
3900
2883
|
// src/components/VariableInstanceReferencesInput.jsx
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
2884
|
+
|
|
2885
|
+
|
|
2886
|
+
|
|
2887
|
+
|
|
2888
|
+
|
|
3906
2889
|
function VariableInstanceReferencesInput(props) {
|
|
3907
2890
|
const { value = [], onChange } = props;
|
|
3908
|
-
const [isAutofilling, setIsAutofilling] = (0,
|
|
3909
|
-
const [showConfirmDialog, setShowConfirmDialog] = (0,
|
|
3910
|
-
const [pendingAction, setPendingAction] = (0,
|
|
3911
|
-
const formDocument = (0,
|
|
2891
|
+
const [isAutofilling, setIsAutofilling] = _react.useState.call(void 0, false);
|
|
2892
|
+
const [showConfirmDialog, setShowConfirmDialog] = _react.useState.call(void 0, false);
|
|
2893
|
+
const [pendingAction, setPendingAction] = _react.useState.call(void 0, null);
|
|
2894
|
+
const formDocument = _sanity.useFormValue.call(void 0, []);
|
|
3912
2895
|
const sanityClient = useSanityClient();
|
|
3913
|
-
const fetchReferences = (0,
|
|
2896
|
+
const fetchReferences = _react.useCallback.call(void 0, async (client, doc) => {
|
|
3914
2897
|
const typefaceName = doc == null ? void 0 : doc.typefaceName;
|
|
3915
2898
|
if (!typefaceName) {
|
|
3916
2899
|
return client.fetch(`*[_type == 'font' && variableFont != true]{_id, title}`, {});
|
|
@@ -3920,27 +2903,27 @@ function VariableInstanceReferencesInput(props) {
|
|
|
3920
2903
|
{ typefaceName }
|
|
3921
2904
|
);
|
|
3922
2905
|
}, []);
|
|
3923
|
-
const performAutofillWithMatching = (0,
|
|
2906
|
+
const performAutofillWithMatching = _react.useCallback.call(void 0, async (mode) => {
|
|
3924
2907
|
setIsAutofilling(true);
|
|
3925
2908
|
try {
|
|
3926
2909
|
if (!(formDocument == null ? void 0 : formDocument.variableInstances)) {
|
|
3927
2910
|
console.warn("Cannot autofill: no variableInstances data on this document");
|
|
3928
2911
|
return;
|
|
3929
2912
|
}
|
|
3930
|
-
const mappings = await parseVariableFontInstances(formDocument, sanityClient);
|
|
2913
|
+
const mappings = await _chunkJCDZ7SWZjs.parseVariableFontInstances.call(void 0, formDocument, sanityClient);
|
|
3931
2914
|
if (mappings.length === 0) {
|
|
3932
2915
|
console.warn("No variable instances could be parsed from this font");
|
|
3933
2916
|
return;
|
|
3934
2917
|
}
|
|
3935
2918
|
const updatedPairs = mode === "replace" ? mappings : [...value, ...mappings.filter((m) => !value.some((p) => p.key === m.key))];
|
|
3936
|
-
onChange((0,
|
|
2919
|
+
onChange(_sanity.set.call(void 0, updatedPairs));
|
|
3937
2920
|
} catch (err) {
|
|
3938
2921
|
console.error("Error during autofill with matching:", err);
|
|
3939
2922
|
} finally {
|
|
3940
2923
|
setIsAutofilling(false);
|
|
3941
2924
|
}
|
|
3942
2925
|
}, [formDocument, sanityClient, value, onChange]);
|
|
3943
|
-
const performAutofillKeysOnly = (0,
|
|
2926
|
+
const performAutofillKeysOnly = _react.useCallback.call(void 0, async (mode) => {
|
|
3944
2927
|
setIsAutofilling(true);
|
|
3945
2928
|
try {
|
|
3946
2929
|
if (!(formDocument == null ? void 0 : formDocument.variableInstances)) {
|
|
@@ -3950,7 +2933,7 @@ function VariableInstanceReferencesInput(props) {
|
|
|
3950
2933
|
let instances;
|
|
3951
2934
|
try {
|
|
3952
2935
|
instances = JSON.parse(formDocument.variableInstances);
|
|
3953
|
-
} catch {
|
|
2936
|
+
} catch (e2) {
|
|
3954
2937
|
console.error("Invalid variableInstances JSON on this document");
|
|
3955
2938
|
return;
|
|
3956
2939
|
}
|
|
@@ -3959,16 +2942,16 @@ function VariableInstanceReferencesInput(props) {
|
|
|
3959
2942
|
console.warn("No variable instances found in JSON");
|
|
3960
2943
|
return;
|
|
3961
2944
|
}
|
|
3962
|
-
const keyOnlyPairs = keys.map((key) => ({ key, value: null, _key: (0,
|
|
2945
|
+
const keyOnlyPairs = keys.map((key) => ({ key, value: null, _key: _nanoid.nanoid.call(void 0, ) }));
|
|
3963
2946
|
const updatedPairs = mode === "replace" ? keyOnlyPairs : [...value, ...keyOnlyPairs.filter((p) => !value.some((existing) => existing.key === p.key))];
|
|
3964
|
-
onChange((0,
|
|
2947
|
+
onChange(_sanity.set.call(void 0, updatedPairs));
|
|
3965
2948
|
} catch (err) {
|
|
3966
2949
|
console.error("Error during keys-only autofill:", err);
|
|
3967
2950
|
} finally {
|
|
3968
2951
|
setIsAutofilling(false);
|
|
3969
2952
|
}
|
|
3970
2953
|
}, [formDocument, value, onChange]);
|
|
3971
|
-
const handleAutofillWithMatching = (0,
|
|
2954
|
+
const handleAutofillWithMatching = _react.useCallback.call(void 0, () => {
|
|
3972
2955
|
if (value.length > 0) {
|
|
3973
2956
|
setPendingAction("matching");
|
|
3974
2957
|
setShowConfirmDialog(true);
|
|
@@ -3976,7 +2959,7 @@ function VariableInstanceReferencesInput(props) {
|
|
|
3976
2959
|
}
|
|
3977
2960
|
performAutofillWithMatching("replace");
|
|
3978
2961
|
}, [value, performAutofillWithMatching]);
|
|
3979
|
-
const handleAutofillKeysOnly = (0,
|
|
2962
|
+
const handleAutofillKeysOnly = _react.useCallback.call(void 0, () => {
|
|
3980
2963
|
if (value.length > 0) {
|
|
3981
2964
|
setPendingAction("keysOnly");
|
|
3982
2965
|
setShowConfirmDialog(true);
|
|
@@ -3984,41 +2967,41 @@ function VariableInstanceReferencesInput(props) {
|
|
|
3984
2967
|
}
|
|
3985
2968
|
performAutofillKeysOnly("replace");
|
|
3986
2969
|
}, [value, performAutofillKeysOnly]);
|
|
3987
|
-
const handleConfirmChoice = (0,
|
|
2970
|
+
const handleConfirmChoice = _react.useCallback.call(void 0, async (choice) => {
|
|
3988
2971
|
setShowConfirmDialog(false);
|
|
3989
2972
|
if (pendingAction === "matching") await performAutofillWithMatching(choice);
|
|
3990
2973
|
else if (pendingAction === "keysOnly") await performAutofillKeysOnly(choice);
|
|
3991
2974
|
setPendingAction(null);
|
|
3992
2975
|
}, [pendingAction, performAutofillWithMatching, performAutofillKeysOnly]);
|
|
3993
|
-
const handleConfirmCancel = (0,
|
|
2976
|
+
const handleConfirmCancel = _react.useCallback.call(void 0, () => {
|
|
3994
2977
|
setShowConfirmDialog(false);
|
|
3995
2978
|
setPendingAction(null);
|
|
3996
2979
|
}, []);
|
|
3997
2980
|
const showAutofill = !!((formDocument == null ? void 0 : formDocument.variableFont) && (formDocument == null ? void 0 : formDocument.variableInstances));
|
|
3998
|
-
const topActions = showAutofill ? /* @__PURE__ */
|
|
3999
|
-
|
|
2981
|
+
const topActions = showAutofill ? /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { gap: 2 }, /* @__PURE__ */ _react2.default.createElement(
|
|
2982
|
+
_ui.Button,
|
|
4000
2983
|
{
|
|
4001
2984
|
tone: "primary",
|
|
4002
2985
|
mode: "ghost",
|
|
4003
2986
|
onClick: handleAutofillWithMatching,
|
|
4004
|
-
icon:
|
|
2987
|
+
icon: _icons.SyncIcon,
|
|
4005
2988
|
text: "Autofill with Matching",
|
|
4006
2989
|
disabled: isAutofilling,
|
|
4007
2990
|
loading: isAutofilling
|
|
4008
2991
|
}
|
|
4009
|
-
), /* @__PURE__ */
|
|
4010
|
-
|
|
2992
|
+
), /* @__PURE__ */ _react2.default.createElement(
|
|
2993
|
+
_ui.Button,
|
|
4011
2994
|
{
|
|
4012
2995
|
tone: "default",
|
|
4013
2996
|
mode: "ghost",
|
|
4014
2997
|
onClick: handleAutofillKeysOnly,
|
|
4015
|
-
icon:
|
|
2998
|
+
icon: _icons.DocumentTextIcon,
|
|
4016
2999
|
text: "Autofill Keys Only",
|
|
4017
3000
|
disabled: isAutofilling,
|
|
4018
3001
|
loading: isAutofilling
|
|
4019
3002
|
}
|
|
4020
3003
|
)) : null;
|
|
4021
|
-
return /* @__PURE__ */
|
|
3004
|
+
return /* @__PURE__ */ _react2.default.createElement(_react2.default.Fragment, null, /* @__PURE__ */ _react2.default.createElement(
|
|
4022
3005
|
KeyValueReferenceInput,
|
|
4023
3006
|
{
|
|
4024
3007
|
...props,
|
|
@@ -4026,43 +3009,43 @@ function VariableInstanceReferencesInput(props) {
|
|
|
4026
3009
|
fetchReferences,
|
|
4027
3010
|
topActions
|
|
4028
3011
|
}
|
|
4029
|
-
), showConfirmDialog && /* @__PURE__ */
|
|
4030
|
-
|
|
3012
|
+
), showConfirmDialog && /* @__PURE__ */ _react2.default.createElement(
|
|
3013
|
+
_ui.Dialog,
|
|
4031
3014
|
{
|
|
4032
3015
|
header: "Existing entries found",
|
|
4033
3016
|
id: "autofill-confirm-dialog",
|
|
4034
3017
|
onClose: handleConfirmCancel,
|
|
4035
3018
|
width: 1
|
|
4036
3019
|
},
|
|
4037
|
-
/* @__PURE__ */
|
|
3020
|
+
/* @__PURE__ */ _react2.default.createElement(_ui.Box, { padding: 4 }, /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 4 }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, null, "You already have ", value.length, " ", value.length === 1 ? "entry" : "entries", ". How would you like to proceed?"), /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { gap: 2, justify: "flex-end" }, /* @__PURE__ */ _react2.default.createElement(_ui.Button, { text: "Cancel", mode: "ghost", onClick: handleConfirmCancel }), /* @__PURE__ */ _react2.default.createElement(_ui.Button, { text: "Merge (Add New)", tone: "primary", mode: "ghost", onClick: () => handleConfirmChoice("merge") }), /* @__PURE__ */ _react2.default.createElement(_ui.Button, { text: "Replace All", tone: "critical", onClick: () => handleConfirmChoice("replace") }))))
|
|
4038
3021
|
));
|
|
4039
3022
|
}
|
|
4040
3023
|
|
|
4041
3024
|
// src/components/PrimaryCollectionGeneratorTypeface.jsx
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
3025
|
+
|
|
3026
|
+
|
|
3027
|
+
|
|
3028
|
+
|
|
4046
3029
|
var PrimaryCollectionGeneratorTypeface = () => {
|
|
4047
3030
|
const client = useSanityClient();
|
|
4048
|
-
const [status, setStatus] = (0,
|
|
4049
|
-
const [ready, setReady] = (0,
|
|
4050
|
-
const [price, setPrice] = (0,
|
|
3031
|
+
const [status, setStatus] = _react.useState.call(void 0, "ready");
|
|
3032
|
+
const [ready, setReady] = _react.useState.call(void 0, true);
|
|
3033
|
+
const [price, setPrice] = _react.useState.call(void 0,
|
|
4051
3034
|
process.env.SANITY_STUDIO_DEFAULT_COLLECTION_PRICE || 100
|
|
4052
3035
|
);
|
|
4053
|
-
const fonts = (0,
|
|
4054
|
-
const title = (0,
|
|
4055
|
-
const preferredStyle = (0,
|
|
4056
|
-
const docId = (0,
|
|
4057
|
-
const styles = (0,
|
|
4058
|
-
const generateCollection = (0,
|
|
3036
|
+
const fonts = _sanity.useFormValue.call(void 0, ["styles", "fonts"]);
|
|
3037
|
+
const title = _sanity.useFormValue.call(void 0, ["title"]);
|
|
3038
|
+
const preferredStyle = _sanity.useFormValue.call(void 0, ["preferredStyle"]);
|
|
3039
|
+
const docId = _sanity.useFormValue.call(void 0, ["_id"]);
|
|
3040
|
+
const styles = _sanity.useFormValue.call(void 0, ["styles"]);
|
|
3041
|
+
const generateCollection = _react.useCallback.call(void 0, async () => {
|
|
4059
3042
|
setStatus("Generating collection...");
|
|
4060
3043
|
setReady(false);
|
|
4061
3044
|
let id = title.toLowerCase().replace(/\s+/g, "-").slice(0, 200);
|
|
4062
3045
|
if (!id.includes("collection")) id += "-collection";
|
|
4063
3046
|
const colTitle = id.replace(/-/g, " ").replace(/\b\w/g, (l) => l.toUpperCase());
|
|
4064
3047
|
const collectionDoc = {
|
|
4065
|
-
_key: (0,
|
|
3048
|
+
_key: _nanoid.nanoid.call(void 0, ),
|
|
4066
3049
|
_id: id,
|
|
4067
3050
|
title: colTitle,
|
|
4068
3051
|
slug: { _type: "slug", current: id },
|
|
@@ -4080,7 +3063,7 @@ var PrimaryCollectionGeneratorTypeface = () => {
|
|
|
4080
3063
|
...styles,
|
|
4081
3064
|
collections: [{
|
|
4082
3065
|
_type: "reference",
|
|
4083
|
-
_key: (0,
|
|
3066
|
+
_key: _nanoid.nanoid.call(void 0, ),
|
|
4084
3067
|
_ref: sanityCollection._id,
|
|
4085
3068
|
_weak: true
|
|
4086
3069
|
}, ...collections]
|
|
@@ -4094,7 +3077,7 @@ var PrimaryCollectionGeneratorTypeface = () => {
|
|
|
4094
3077
|
setReady(true);
|
|
4095
3078
|
}, [docId, fonts, price, preferredStyle, styles, title, client]);
|
|
4096
3079
|
if (!title || !fonts) return null;
|
|
4097
|
-
return /* @__PURE__ */
|
|
3080
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 2 }, /* @__PURE__ */ _react2.default.createElement(StatusDisplay_default, { status, error: false }), /* @__PURE__ */ _react2.default.createElement(_ui.Card, { border: true, padding: 2, shadow: 1, radius: 2 }, ready ? /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 3 }, /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { align: "center", gap: 2, marginTop: 1, marginBottom: 1 }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, muted: true }, "Price"), /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, muted: true }, "$"), /* @__PURE__ */ _react2.default.createElement(
|
|
4098
3081
|
"input",
|
|
4099
3082
|
{
|
|
4100
3083
|
value: price,
|
|
@@ -4102,8 +3085,8 @@ var PrimaryCollectionGeneratorTypeface = () => {
|
|
|
4102
3085
|
type: "number",
|
|
4103
3086
|
style: { textAlign: "end", padding: "5px", maxWidth: "75px" }
|
|
4104
3087
|
}
|
|
4105
|
-
), /* @__PURE__ */
|
|
4106
|
-
|
|
3088
|
+
), /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, muted: true }, "per full family")), /* @__PURE__ */ _react2.default.createElement(
|
|
3089
|
+
_ui.Button,
|
|
4107
3090
|
{
|
|
4108
3091
|
mode: "ghost",
|
|
4109
3092
|
tone: "primary",
|
|
@@ -4111,19 +3094,19 @@ var PrimaryCollectionGeneratorTypeface = () => {
|
|
|
4111
3094
|
onClick: generateCollection,
|
|
4112
3095
|
text: "Generate Full Family Collection"
|
|
4113
3096
|
}
|
|
4114
|
-
)) : /* @__PURE__ */
|
|
3097
|
+
)) : /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { align: "center", justify: "center", gap: 3, padding: 4 }, /* @__PURE__ */ _react2.default.createElement(_ui.Spinner, null), /* @__PURE__ */ _react2.default.createElement(_ui.Text, { muted: true, size: 1 }, status))));
|
|
4115
3098
|
};
|
|
4116
3099
|
|
|
4117
3100
|
// src/components/SetOTF.jsx
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
3101
|
+
|
|
3102
|
+
|
|
3103
|
+
|
|
4121
3104
|
var SetOTF = (props) => {
|
|
4122
3105
|
var _a, _b;
|
|
4123
3106
|
const { onChange, value = {} } = props;
|
|
4124
3107
|
const client = useSanityClient();
|
|
4125
|
-
const stylesObject = (0,
|
|
4126
|
-
const [message, setMessage] = (0,
|
|
3108
|
+
const stylesObject = _sanity.useFormValue.call(void 0, ["styles"]);
|
|
3109
|
+
const [message, setMessage] = _react.useState.call(void 0, "");
|
|
4127
3110
|
const detect = async () => {
|
|
4128
3111
|
var _a2, _b2, _c;
|
|
4129
3112
|
if (!((_a2 = stylesObject == null ? void 0 : stylesObject.fonts) == null ? void 0 : _a2.length)) {
|
|
@@ -4158,7 +3141,7 @@ var SetOTF = (props) => {
|
|
|
4158
3141
|
if (approved) features.push(key);
|
|
4159
3142
|
}
|
|
4160
3143
|
});
|
|
4161
|
-
onChange((0,
|
|
3144
|
+
onChange(_sanity.set.call(void 0, { ...value, features }));
|
|
4162
3145
|
setMessage(`Features detected: ${features.length ? features.join(", ") : "none"}.`);
|
|
4163
3146
|
setTimeout(() => setMessage(""), 5e3);
|
|
4164
3147
|
} catch (err) {
|
|
@@ -4166,35 +3149,35 @@ var SetOTF = (props) => {
|
|
|
4166
3149
|
console.error("SetOTF detect error:", err);
|
|
4167
3150
|
}
|
|
4168
3151
|
};
|
|
4169
|
-
return /* @__PURE__ */
|
|
4170
|
-
|
|
3152
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { className: "openType" }, ((_a = value == null ? void 0 : value.features) == null ? void 0 : _a.length) > 0 && /* @__PURE__ */ _react2.default.createElement(_ui.Text, { muted: true, size: 1, style: { marginBottom: "0.5rem" } }, "Number of features: ", value.features.length), !!((_b = stylesObject == null ? void 0 : stylesObject.fonts) == null ? void 0 : _b.length) && /* @__PURE__ */ _react2.default.createElement(
|
|
3153
|
+
_ui.Button,
|
|
4171
3154
|
{
|
|
4172
3155
|
text: "Detect OTF",
|
|
4173
3156
|
mode: "ghost",
|
|
4174
3157
|
onClick: detect,
|
|
4175
3158
|
style: { borderRadius: "0 3px 0 0", marginBottom: "1rem" }
|
|
4176
3159
|
}
|
|
4177
|
-
), !!message && /* @__PURE__ */
|
|
3160
|
+
), !!message && /* @__PURE__ */ _react2.default.createElement(_ui.Text, { muted: true, size: 1 }, /* @__PURE__ */ _react2.default.createElement("br", null), message, /* @__PURE__ */ _react2.default.createElement("br", null), /* @__PURE__ */ _react2.default.createElement("br", null)), props.renderDefault(props));
|
|
4178
3161
|
};
|
|
4179
3162
|
|
|
4180
3163
|
// src/components/StyleCountInput.jsx
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
3164
|
+
|
|
3165
|
+
|
|
3166
|
+
|
|
4184
3167
|
var StyleCountInput = (props) => {
|
|
4185
|
-
const styles = (0,
|
|
4186
|
-
const vfStyles = (0,
|
|
3168
|
+
const styles = _sanity.useFormValue.call(void 0, ["styles", "fonts"]) || [];
|
|
3169
|
+
const vfStyles = _sanity.useFormValue.call(void 0, ["styles", "variableFont"]) || [];
|
|
4187
3170
|
const count = styles.length + vfStyles.length;
|
|
4188
|
-
return /* @__PURE__ */
|
|
3171
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1 }, count);
|
|
4189
3172
|
};
|
|
4190
3173
|
|
|
4191
3174
|
// src/components/NestedObjectArraySelector.jsx
|
|
4192
|
-
|
|
4193
|
-
|
|
3175
|
+
|
|
3176
|
+
|
|
4194
3177
|
|
|
4195
3178
|
// src/hooks/useNestedObjects.js
|
|
4196
|
-
|
|
4197
|
-
|
|
3179
|
+
|
|
3180
|
+
|
|
4198
3181
|
function useNestedObjects({
|
|
4199
3182
|
sourceType,
|
|
4200
3183
|
nestedField,
|
|
@@ -4203,11 +3186,11 @@ function useNestedObjects({
|
|
|
4203
3186
|
filter = "",
|
|
4204
3187
|
sortBy = ""
|
|
4205
3188
|
}) {
|
|
4206
|
-
const client = (0,
|
|
4207
|
-
const [objects, setObjects] = (0,
|
|
4208
|
-
const [loading, setLoading] = (0,
|
|
4209
|
-
const [error, setError] = (0,
|
|
4210
|
-
(0,
|
|
3189
|
+
const client = _sanity.useClient.call(void 0, { apiVersion: "2023-01-01" });
|
|
3190
|
+
const [objects, setObjects] = _react.useState.call(void 0, []);
|
|
3191
|
+
const [loading, setLoading] = _react.useState.call(void 0, true);
|
|
3192
|
+
const [error, setError] = _react.useState.call(void 0, null);
|
|
3193
|
+
_react.useEffect.call(void 0, () => {
|
|
4211
3194
|
if (!sourceType || !nestedField || !titleField || !valueField) {
|
|
4212
3195
|
setError(new Error("Missing required configuration"));
|
|
4213
3196
|
setLoading(false);
|
|
@@ -4261,8 +3244,8 @@ function useNestedObjects({
|
|
|
4261
3244
|
}
|
|
4262
3245
|
|
|
4263
3246
|
// src/components/NestedObjectArraySelector.jsx
|
|
4264
|
-
|
|
4265
|
-
var NestedObjectArraySelector =
|
|
3247
|
+
|
|
3248
|
+
var NestedObjectArraySelector = _react2.default.forwardRef((props, ref) => {
|
|
4266
3249
|
const { value = [], onChange, schemaType } = props;
|
|
4267
3250
|
const options = (schemaType == null ? void 0 : schemaType.options) || {};
|
|
4268
3251
|
const {
|
|
@@ -4275,9 +3258,9 @@ var NestedObjectArraySelector = import_react20.default.forwardRef((props, ref) =
|
|
|
4275
3258
|
emptyMessage = "No options found",
|
|
4276
3259
|
searchPlaceholder = "Search..."
|
|
4277
3260
|
} = options;
|
|
4278
|
-
const [searchTerm, setSearchTerm] = (0,
|
|
3261
|
+
const [searchTerm, setSearchTerm] = _react.useState.call(void 0, "");
|
|
4279
3262
|
const { objects, loading, error } = useNestedObjects({ sourceType, nestedField, titleField, valueField, filter, sortBy });
|
|
4280
|
-
const filteredObjects = (0,
|
|
3263
|
+
const filteredObjects = _react.useMemo.call(void 0, () => {
|
|
4281
3264
|
if (!searchTerm) return objects;
|
|
4282
3265
|
const lower = searchTerm.toLowerCase();
|
|
4283
3266
|
return objects.filter((obj) => {
|
|
@@ -4290,24 +3273,24 @@ var NestedObjectArraySelector = import_react20.default.forwardRef((props, ref) =
|
|
|
4290
3273
|
const isSelected = currentValue.includes(itemValue);
|
|
4291
3274
|
if (isSelected) {
|
|
4292
3275
|
const newValue = currentValue.filter((v) => v !== itemValue);
|
|
4293
|
-
onChange(newValue.length > 0 ? (0,
|
|
3276
|
+
onChange(newValue.length > 0 ? _sanity.set.call(void 0, newValue) : _sanity.unset.call(void 0, ));
|
|
4294
3277
|
} else {
|
|
4295
|
-
onChange((0,
|
|
3278
|
+
onChange(_sanity.set.call(void 0, [...currentValue, itemValue]));
|
|
4296
3279
|
}
|
|
4297
3280
|
};
|
|
4298
3281
|
if (!sourceType || !nestedField || !titleField || !valueField) {
|
|
4299
|
-
return /* @__PURE__ */
|
|
3282
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Card, { padding: 3, tone: "critical", border: true }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1 }, "Configuration error: Missing required options (sourceType, nestedField, titleField, or valueField)"));
|
|
4300
3283
|
}
|
|
4301
3284
|
if (loading) {
|
|
4302
|
-
return /* @__PURE__ */
|
|
3285
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Card, { padding: 3, border: true }, /* @__PURE__ */ _react2.default.createElement(_ui.Flex, { align: "center", justify: "center", padding: 4 }, /* @__PURE__ */ _react2.default.createElement(_ui.Spinner, null), /* @__PURE__ */ _react2.default.createElement(_ui.Box, { marginLeft: 3 }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1 }, "Loading options..."))));
|
|
4303
3286
|
}
|
|
4304
3287
|
if (error) {
|
|
4305
|
-
return /* @__PURE__ */
|
|
3288
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Card, { padding: 3, tone: "critical", border: true }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1 }, "Error loading options: ", error.message));
|
|
4306
3289
|
}
|
|
4307
3290
|
if (objects.length === 0) {
|
|
4308
|
-
return /* @__PURE__ */
|
|
3291
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Card, { padding: 3, tone: "transparent", border: true }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, muted: true }, emptyMessage));
|
|
4309
3292
|
}
|
|
4310
|
-
return /* @__PURE__ */
|
|
3293
|
+
return /* @__PURE__ */ _react2.default.createElement(_ui.Card, { padding: 0, border: true, ref }, objects.length > 5 && /* @__PURE__ */ _react2.default.createElement(_ui.Box, { padding: 3, style: { borderBottom: "1px solid var(--card-border-color)" } }, /* @__PURE__ */ _react2.default.createElement(
|
|
4311
3294
|
"input",
|
|
4312
3295
|
{
|
|
4313
3296
|
type: "text",
|
|
@@ -4316,39 +3299,39 @@ var NestedObjectArraySelector = import_react20.default.forwardRef((props, ref) =
|
|
|
4316
3299
|
onChange: (e) => setSearchTerm(e.target.value),
|
|
4317
3300
|
style: { width: "100%", padding: "8px 12px", border: "1px solid var(--card-border-color)", borderRadius: "4px", fontSize: "13px", fontFamily: "inherit" }
|
|
4318
3301
|
}
|
|
4319
|
-
)), /* @__PURE__ */
|
|
3302
|
+
)), /* @__PURE__ */ _react2.default.createElement(_ui.Stack, { space: 0 }, filteredObjects.length === 0 ? /* @__PURE__ */ _react2.default.createElement(_ui.Box, { padding: 3 }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, muted: true }, 'No results found for "', searchTerm, '"')) : filteredObjects.map((obj, index) => {
|
|
4320
3303
|
const isSelected = value == null ? void 0 : value.includes(obj.value);
|
|
4321
3304
|
const isLast = index === filteredObjects.length - 1;
|
|
4322
|
-
return /* @__PURE__ */
|
|
4323
|
-
|
|
3305
|
+
return /* @__PURE__ */ _react2.default.createElement(
|
|
3306
|
+
_ui.Box,
|
|
4324
3307
|
{
|
|
4325
3308
|
key: obj.value,
|
|
4326
3309
|
padding: 3,
|
|
4327
3310
|
style: { borderBottom: isLast ? "none" : "1px solid var(--card-border-color)", cursor: "pointer", backgroundColor: isSelected ? "var(--card-muted-fg-color)" : "transparent", transition: "background-color 0.2s" },
|
|
4328
3311
|
onClick: () => handleToggle(obj.value)
|
|
4329
3312
|
},
|
|
4330
|
-
/* @__PURE__ */
|
|
3313
|
+
/* @__PURE__ */ _react2.default.createElement(_ui.Flex, { align: "center", gap: 3 }, /* @__PURE__ */ _react2.default.createElement(_ui.Checkbox, { checked: isSelected, readOnly: true, style: { pointerEvents: "none" } }), /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, weight: isSelected ? "semibold" : "regular" }, obj.title))
|
|
4331
3314
|
);
|
|
4332
|
-
})), (value == null ? void 0 : value.length) > 0 && /* @__PURE__ */
|
|
3315
|
+
})), (value == null ? void 0 : value.length) > 0 && /* @__PURE__ */ _react2.default.createElement(_ui.Box, { padding: 2, paddingX: 3, style: { borderTop: "1px solid var(--card-border-color)", backgroundColor: "var(--card-muted-fg-color)" } }, /* @__PURE__ */ _react2.default.createElement(_ui.Text, { size: 1, muted: true }, value.length, " selected")));
|
|
4333
3316
|
});
|
|
4334
3317
|
NestedObjectArraySelector.displayName = "NestedObjectArraySelector";
|
|
4335
3318
|
|
|
4336
3319
|
// src/utils/getEmptyFontKit.js
|
|
4337
|
-
|
|
4338
|
-
var import_slugify4 = __toESM(require("slugify"));
|
|
3320
|
+
|
|
4339
3321
|
async function getEmptyFontKit({ title, files, weightKeywordList, italicKeywordList }) {
|
|
4340
|
-
var _a, _b, _c, _d, _e, _f;
|
|
4341
3322
|
let fontNames = {};
|
|
4342
3323
|
let subfamilies = {};
|
|
4343
3324
|
for (var i = 0; i < files.length; i++) {
|
|
4344
3325
|
const file = files[i];
|
|
4345
3326
|
const fontBuffer = await readFontFile2(file);
|
|
4346
|
-
const font =
|
|
4347
|
-
let weightName =
|
|
4348
|
-
|
|
4349
|
-
let variableFont =
|
|
4350
|
-
|
|
4351
|
-
|
|
3327
|
+
const font = await _chunkJCDZ7SWZjs.parseFont.call(void 0, fontBuffer, file.name);
|
|
3328
|
+
let weightName = _chunkJCDZ7SWZjs.getNameString.call(void 0, font, 17) || _chunkJCDZ7SWZjs.getNameString.call(void 0, font, 2) || "";
|
|
3329
|
+
const axes = _chunkJCDZ7SWZjs.getVariationAxes.call(void 0, font);
|
|
3330
|
+
let variableFont = axes !== null;
|
|
3331
|
+
const familyName = _chunkJCDZ7SWZjs.getNameString.call(void 0, font, 1);
|
|
3332
|
+
const fullName = _chunkJCDZ7SWZjs.getNameString.call(void 0, font, 4);
|
|
3333
|
+
let subfamilyName = familyName.toLowerCase().trim().replace(title.toLowerCase().trim(), "").trim();
|
|
3334
|
+
let fontTitle = fullName.toLowerCase().trim();
|
|
4352
3335
|
weightKeywordList.forEach((keyword) => {
|
|
4353
3336
|
const kw = keyword.toLowerCase().trim();
|
|
4354
3337
|
if (fontTitle.includes(kw)) {
|
|
@@ -4370,7 +3353,7 @@ async function getEmptyFontKit({ title, files, weightKeywordList, italicKeywordL
|
|
|
4370
3353
|
fontTitle = fontTitle.trim().split(" ").map((word) => word[0].toUpperCase() + word.slice(1)).join(" ");
|
|
4371
3354
|
subfamilyName = subfamilyName.trim();
|
|
4372
3355
|
subfamilyName = subfamilyName == "" ? "Regular" : subfamilyName.split(" ").map((word) => word[0].toUpperCase() + word.slice(1)).join(" ");
|
|
4373
|
-
let id = (0,
|
|
3356
|
+
let id = _slugify2.default.call(void 0, fontTitle.toLowerCase().trim());
|
|
4374
3357
|
if (variableFont && !id.endsWith("-vf")) {
|
|
4375
3358
|
id = id + "-vf";
|
|
4376
3359
|
fontTitle = fontTitle + " VF";
|
|
@@ -4383,26 +3366,26 @@ async function getEmptyFontKit({ title, files, weightKeywordList, italicKeywordL
|
|
|
4383
3366
|
if (!fontNames[id]) {
|
|
4384
3367
|
fontNames[id] = [{
|
|
4385
3368
|
file: file.name,
|
|
4386
|
-
fullName
|
|
4387
|
-
familyName
|
|
3369
|
+
fullName,
|
|
3370
|
+
familyName,
|
|
4388
3371
|
subFamily: subfamilyName
|
|
4389
3372
|
}];
|
|
4390
3373
|
} else if (fontNames[id].indexOf(file.name) == -1) {
|
|
4391
3374
|
fontNames[id].push({
|
|
4392
3375
|
file: file.name,
|
|
4393
|
-
fullName
|
|
4394
|
-
familyName
|
|
3376
|
+
fullName,
|
|
3377
|
+
familyName,
|
|
4395
3378
|
subFamily: subfamilyName
|
|
4396
3379
|
});
|
|
4397
3380
|
}
|
|
4398
3381
|
}
|
|
4399
|
-
console.log("
|
|
3382
|
+
console.log("Font names:", fontNames);
|
|
4400
3383
|
}
|
|
4401
3384
|
var readFontFile2 = (file) => {
|
|
4402
3385
|
return new Promise((resolve, reject) => {
|
|
4403
3386
|
const reader = new FileReader();
|
|
4404
3387
|
reader.onload = (event) => {
|
|
4405
|
-
resolve(
|
|
3388
|
+
resolve(event.target.result);
|
|
4406
3389
|
};
|
|
4407
3390
|
reader.onerror = (error) => {
|
|
4408
3391
|
reject(error);
|
|
@@ -6565,7 +5548,7 @@ var styleCountField = {
|
|
|
6565
5548
|
};
|
|
6566
5549
|
|
|
6567
5550
|
// src/schema/stylisticSetField.js
|
|
6568
|
-
|
|
5551
|
+
|
|
6569
5552
|
var stylisticSetField = {
|
|
6570
5553
|
title: "Stylistic Features Section",
|
|
6571
5554
|
name: "stylisticSet",
|
|
@@ -6582,7 +5565,7 @@ var stylisticSetField = {
|
|
|
6582
5565
|
name: "featuredWord",
|
|
6583
5566
|
title: "Words or Phrase",
|
|
6584
5567
|
type: "object",
|
|
6585
|
-
icon:
|
|
5568
|
+
icon: _icons.StringIcon,
|
|
6586
5569
|
fields: [
|
|
6587
5570
|
{
|
|
6588
5571
|
type: "text",
|
|
@@ -6733,7 +5716,7 @@ var stylisticSetField = {
|
|
|
6733
5716
|
name: "set",
|
|
6734
5717
|
type: "object",
|
|
6735
5718
|
title: "Stylistic Feature",
|
|
6736
|
-
icon:
|
|
5719
|
+
icon: _icons.StringIcon,
|
|
6737
5720
|
fields: [
|
|
6738
5721
|
{
|
|
6739
5722
|
name: "title",
|
|
@@ -6865,15 +5848,15 @@ var stylisticSetField = {
|
|
|
6865
5848
|
};
|
|
6866
5849
|
|
|
6867
5850
|
// src/schema/stylesField.js
|
|
6868
|
-
|
|
6869
|
-
var
|
|
5851
|
+
|
|
5852
|
+
var _sanityadvancedreferencearray = require('@liiift-studio/sanity-advanced-reference-array');
|
|
6870
5853
|
var typefaceParams = (doc) => ({ typefaceName: (doc == null ? void 0 : doc.title) || "" });
|
|
6871
|
-
var FontsRefArray = (props) =>
|
|
5854
|
+
var FontsRefArray = (props) => _react2.default.createElement(_sanityadvancedreferencearray.AdvancedRefArray, {
|
|
6872
5855
|
...props,
|
|
6873
5856
|
filterGroq: "lower(typefaceName) == lower($typefaceName)",
|
|
6874
5857
|
filterParams: typefaceParams
|
|
6875
5858
|
});
|
|
6876
|
-
var VariableFontsRefArray = (props) =>
|
|
5859
|
+
var VariableFontsRefArray = (props) => _react2.default.createElement(_sanityadvancedreferencearray.AdvancedRefArray, {
|
|
6877
5860
|
...props,
|
|
6878
5861
|
filterGroq: "lower(typefaceName) == lower($typefaceName) && variableFont == true",
|
|
6879
5862
|
filterParams: typefaceParams
|
|
@@ -7073,7 +6056,7 @@ function createStylesField({
|
|
|
7073
6056
|
title: "Collections",
|
|
7074
6057
|
name: "collections",
|
|
7075
6058
|
type: "array",
|
|
7076
|
-
components: { input:
|
|
6059
|
+
components: { input: _sanityadvancedreferencearray.AdvancedRefArray },
|
|
7077
6060
|
of: [{ type: "reference", weak: true, to: [{ type: "collection" }] }],
|
|
7078
6061
|
options: { sortable: true },
|
|
7079
6062
|
validation: (Rule) => Rule.unique()
|
|
@@ -7082,7 +6065,7 @@ function createStylesField({
|
|
|
7082
6065
|
title: "Pairs",
|
|
7083
6066
|
name: "pairs",
|
|
7084
6067
|
type: "array",
|
|
7085
|
-
components: { input:
|
|
6068
|
+
components: { input: _sanityadvancedreferencearray.AdvancedRefArray },
|
|
7086
6069
|
of: [{ type: "reference", weak: true, to: [{ type: "pair" }] }],
|
|
7087
6070
|
options: { sortable: true },
|
|
7088
6071
|
validation: (Rule) => Rule.unique(),
|
|
@@ -7098,62 +6081,98 @@ function createStylesField({
|
|
|
7098
6081
|
options: { collapsible: true }
|
|
7099
6082
|
};
|
|
7100
6083
|
}
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
|
|
7104
|
-
|
|
7105
|
-
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
|
|
7118
|
-
|
|
7119
|
-
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
|
|
7129
|
-
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
6084
|
+
|
|
6085
|
+
|
|
6086
|
+
|
|
6087
|
+
|
|
6088
|
+
|
|
6089
|
+
|
|
6090
|
+
|
|
6091
|
+
|
|
6092
|
+
|
|
6093
|
+
|
|
6094
|
+
|
|
6095
|
+
|
|
6096
|
+
|
|
6097
|
+
|
|
6098
|
+
|
|
6099
|
+
|
|
6100
|
+
|
|
6101
|
+
|
|
6102
|
+
|
|
6103
|
+
|
|
6104
|
+
|
|
6105
|
+
|
|
6106
|
+
|
|
6107
|
+
|
|
6108
|
+
|
|
6109
|
+
|
|
6110
|
+
|
|
6111
|
+
|
|
6112
|
+
|
|
6113
|
+
|
|
6114
|
+
|
|
6115
|
+
|
|
6116
|
+
|
|
6117
|
+
|
|
6118
|
+
|
|
6119
|
+
|
|
6120
|
+
|
|
6121
|
+
|
|
6122
|
+
|
|
6123
|
+
|
|
6124
|
+
|
|
6125
|
+
|
|
6126
|
+
|
|
6127
|
+
|
|
6128
|
+
|
|
6129
|
+
|
|
6130
|
+
|
|
6131
|
+
|
|
6132
|
+
|
|
6133
|
+
|
|
6134
|
+
|
|
6135
|
+
|
|
6136
|
+
|
|
6137
|
+
|
|
6138
|
+
|
|
6139
|
+
|
|
6140
|
+
|
|
6141
|
+
|
|
6142
|
+
|
|
6143
|
+
|
|
6144
|
+
|
|
6145
|
+
|
|
6146
|
+
|
|
6147
|
+
|
|
6148
|
+
|
|
6149
|
+
|
|
6150
|
+
|
|
6151
|
+
|
|
6152
|
+
|
|
6153
|
+
|
|
6154
|
+
|
|
6155
|
+
|
|
6156
|
+
|
|
6157
|
+
|
|
6158
|
+
|
|
6159
|
+
|
|
6160
|
+
|
|
6161
|
+
|
|
6162
|
+
|
|
6163
|
+
|
|
6164
|
+
|
|
6165
|
+
|
|
6166
|
+
|
|
6167
|
+
|
|
6168
|
+
|
|
6169
|
+
|
|
6170
|
+
|
|
6171
|
+
|
|
6172
|
+
|
|
6173
|
+
|
|
6174
|
+
|
|
6175
|
+
|
|
6176
|
+
|
|
6177
|
+
|
|
6178
|
+
exports.BatchUploadFonts = BatchUploadFonts; exports.BulkActions = _chunkJCDZ7SWZjs.BulkActions; exports.DISCOUNT_REQUIREMENT_TYPES = DISCOUNT_REQUIREMENT_TYPES; exports.DISCOUNT_REQUIREMENT_TYPES_OBJECT = DISCOUNT_REQUIREMENT_TYPES_OBJECT; exports.EXECUTION_STATUS = _chunkJCDZ7SWZjs.EXECUTION_STATUS; exports.ExistingDocumentResolver = _chunkJCDZ7SWZjs.ExistingDocumentResolver; exports.FONT_STATUS = _chunkJCDZ7SWZjs.FONT_STATUS; exports.FontReviewCard = _chunkJCDZ7SWZjs.FontReviewCard_default; exports.FontScriptUploaderComponent = FontScriptUploaderComponent; exports.GenerateCollectionsPairsComponent = GenerateCollectionsPairsComponent; exports.HtmlDescription = HtmlDescription; exports.KeyValueInput = KeyValueInput; exports.KeyValueReferenceInput = KeyValueReferenceInput; exports.NestedObjectArraySelector = NestedObjectArraySelector; exports.PLAN_PHASE = _chunkJCDZ7SWZjs.PLAN_PHASE; exports.PLAN_VERSION = _chunkJCDZ7SWZjs.PLAN_VERSION; exports.PriceInput = _chunkJCDZ7SWZjs.PriceInput_default; exports.PrimaryCollectionGeneratorTypeface = PrimaryCollectionGeneratorTypeface; exports.RECOMMENDATION = _chunkJCDZ7SWZjs.RECOMMENDATION; exports.RegenerateSubfamiliesComponent = RegenerateSubfamiliesComponent; exports.SCRIPTS = SCRIPTS; exports.SCRIPTS_OBJECT = SCRIPTS_OBJECT; exports.SetOTF = SetOTF; exports.SingleUploaderTool = SingleUploaderTool; exports.StatusDisplay = StatusDisplay_default; exports.StyleCountInput = StyleCountInput; exports.UpdateScriptsComponent = UpdateScriptsComponent; exports.UploadButton = UploadButton_default; exports.UploadModal = _chunkJCDZ7SWZjs.UploadModal; exports.UploadScriptsComponent = UploadScriptsComponent; exports.UploadStep1Settings = _chunkJCDZ7SWZjs.UploadStep1Settings; exports.UploadStep2Review = _chunkJCDZ7SWZjs.UploadStep2Review; exports.UploadStep3Execute = _chunkJCDZ7SWZjs.UploadStep3Execute; exports.UploadStep3bInstances = _chunkJCDZ7SWZjs.UploadStep3bInstances; exports.UploadSummary = _chunkJCDZ7SWZjs.UploadSummary; exports.VariableInstanceReferencesInput = VariableInstanceReferencesInput; exports.addItalicToFontTitle = _chunkJCDZ7SWZjs.addItalicToFontTitle; exports.buildUploadPlan = _chunkJCDZ7SWZjs.buildUploadPlan; exports.createEmptyPlan = _chunkJCDZ7SWZjs.createEmptyPlan; exports.createFontDecisions = _chunkJCDZ7SWZjs.createFontDecisions; exports.createFontObject = _chunkJCDZ7SWZjs.createFontObject; exports.createInitialExecutionState = _chunkJCDZ7SWZjs.createInitialExecutionState; exports.createStylesField = createStylesField; exports.determineWeight = _chunkJCDZ7SWZjs.determineWeight; exports.escapeCssFontName = _chunkJCDZ7SWZjs.escapeCssFontName; exports.executeUploadPlan = _chunkJCDZ7SWZjs.executeUploadPlan; exports.executionReducer = _chunkJCDZ7SWZjs.executionReducer; exports.expandAbbreviations = _chunkJCDZ7SWZjs.expandAbbreviations; exports.extractFontMetadata = _chunkJCDZ7SWZjs.extractFontMetadata; exports.extractWeightFromFullName = _chunkJCDZ7SWZjs.extractWeightFromFullName; exports.extractWeightName = _chunkJCDZ7SWZjs.extractWeightName; exports.formatFontTitle = _chunkJCDZ7SWZjs.formatFontTitle; exports.generateCssFile = _chunkJCDZ7SWZjs.generateCssFile; exports.generateFontData = _chunkJCDZ7SWZjs.generateFontData; exports.generateFontFile = generateFontFile; exports.generateStyleKeywords = _chunkJCDZ7SWZjs.generateStyleKeywords; exports.generateSubset = generateSubset; exports.getAllFeatureTags = _chunkJCDZ7SWZjs.getAllFeatureTags; exports.getCharacterSet = _chunkJCDZ7SWZjs.getCharacterSet; exports.getEmptyFontKit = getEmptyFontKit; exports.getFamilyClass = _chunkJCDZ7SWZjs.getFamilyClass; exports.getFontMetadata = _chunkJCDZ7SWZjs.getFontMetadata; exports.getFontMetrics = _chunkJCDZ7SWZjs.getFontMetrics; exports.getFsSelection = _chunkJCDZ7SWZjs.getFsSelection; exports.getGlyphCount = _chunkJCDZ7SWZjs.getGlyphCount; exports.getItalicAngle = _chunkJCDZ7SWZjs.getItalicAngle; exports.getMacStyle = _chunkJCDZ7SWZjs.getMacStyle; exports.getNameString = _chunkJCDZ7SWZjs.getNameString; exports.getNamedInstances = _chunkJCDZ7SWZjs.getNamedInstances; exports.getVariationAxes = _chunkJCDZ7SWZjs.getVariationAxes; exports.getWeightClass = _chunkJCDZ7SWZjs.getWeightClass; exports.logFontInfo = _chunkJCDZ7SWZjs.logFontInfo; exports.openTypeField = openTypeField; exports.parseFont = _chunkJCDZ7SWZjs.parseFont; exports.parseVariableFontInstances = _chunkJCDZ7SWZjs.parseVariableFontInstances_default; exports.planReducer = _chunkJCDZ7SWZjs.planReducer; exports.processFontFiles = _chunkJCDZ7SWZjs.processFontFiles; exports.processItalicKeywords = _chunkJCDZ7SWZjs.processItalicKeywords; exports.processSubfamilyName = _chunkJCDZ7SWZjs.processSubfamilyName; exports.readFontFile = _chunkJCDZ7SWZjs.readFontFile; exports.removeWeightNames = _chunkJCDZ7SWZjs.removeWeightNames; exports.renameFontDocuments = renameFontDocuments; exports.resolveExistingFont = _chunkJCDZ7SWZjs.resolveExistingFont; exports.reverseSpellingLookup = _chunkJCDZ7SWZjs.reverseSpellingLookup; exports.sanitizeForSanityId = _chunkJCDZ7SWZjs.sanitizeForSanityId; exports.sortFontObjects = _chunkJCDZ7SWZjs.sortFontObjects; exports.styleCountField = styleCountField; exports.stylisticSetField = stylisticSetField; exports.updateFontPrices = updateFontPrices; exports.updateTypefaceDocument = _chunkJCDZ7SWZjs.updateTypefaceDocument; exports.uploadFontFiles = uploadFontFiles; exports.useNestedObjects = useNestedObjects; exports.useSanityClient = useSanityClient;
|