@liiift-studio/sanity-font-manager 2.5.7 → 2.6.0

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/index.js CHANGED
@@ -18497,14 +18497,16 @@ var SingleUploaderTool = (props) => {
18497
18497
  if (!(ttfAsset == null ? void 0 : ttfAsset.url)) throw new Error("Could not fetch TTF file URL");
18498
18498
  const arrayBuffer = await (await fetch(ttfAsset.url)).arrayBuffer();
18499
18499
  const font2 = await parseFont(arrayBuffer, `${doc_id}.ttf`);
18500
- const { weightName, subfamilyName, style, variableFont } = extractFontMetadata(
18500
+ const { weightName, subfamilyName, fontTitle, style, variableFont } = extractFontMetadata(
18501
18501
  font2,
18502
18502
  doc_typefaceName,
18503
18503
  weightKeywordList,
18504
- italicKeywordList
18504
+ italicKeywordList,
18505
+ false,
18506
+ null
18505
18507
  );
18506
18508
  const weight = determineWeight(font2, weightName);
18507
- await client.patch(doc_id).set({ weightName, subfamily: subfamilyName, style, variableFont, weight }).commit();
18509
+ await client.patch(doc_id).set({ title: fontTitle, weightName, subfamily: subfamilyName, style, variableFont, weight }).commit();
18508
18510
  const fontData = await generateFontData({
18509
18511
  url: ttfAsset.url,
18510
18512
  fontKit: font2,
@@ -18654,15 +18656,17 @@ var SingleUploaderTool = (props) => {
18654
18656
  if (code === "ttf") {
18655
18657
  const fontBuffer = await readFontFile(file);
18656
18658
  const font2 = await parseFont(fontBuffer, file.name);
18657
- const { weightName, subfamilyName, style, variableFont } = extractFontMetadata(
18659
+ const { weightName, subfamilyName, fontTitle, style, variableFont } = extractFontMetadata(
18658
18660
  font2,
18659
18661
  doc_typefaceName,
18660
18662
  weightKeywordList,
18661
- italicKeywordList
18663
+ italicKeywordList,
18664
+ false,
18665
+ null
18662
18666
  );
18663
18667
  const weight = determineWeight(font2, weightName);
18664
18668
  const normalizedId = doc_id.startsWith("drafts.") ? doc_id.replace("drafts.", "") : doc_id;
18665
- await client.patch(normalizedId).set({ weightName, subfamily: subfamilyName, style, variableFont, weight }).commit();
18669
+ await client.patch(normalizedId).set({ title: fontTitle, weightName, subfamily: subfamilyName, style, variableFont, weight }).commit();
18666
18670
  }
18667
18671
  onChange((0, import_sanity6.set)(newFileInput));
18668
18672
  setTimeout(() => {
@@ -19584,6 +19588,9 @@ function KeyValueReferenceInput(props) {
19584
19588
  const [availableReferences, setAvailableReferences] = (0, import_react23.useState)([]);
19585
19589
  const sanityClient = useSanityClient();
19586
19590
  const formDocument = (0, import_sanity10.useFormValue)([]);
19591
+ (0, import_react23.useEffect)(() => {
19592
+ setPairs(value);
19593
+ }, [value]);
19587
19594
  (0, import_react23.useEffect)(() => {
19588
19595
  const refIds = pairs.filter((p2) => {
19589
19596
  var _a2;
@@ -22798,6 +22805,14 @@ var stylisticSetField = {
22798
22805
  // src/schema/stylesField.js
22799
22806
  var import_react30 = __toESM(require("react"));
22800
22807
  var import_sanity_advanced_reference_array = require("@liiift-studio/sanity-advanced-reference-array");
22808
+ var inlineStyleCountField = {
22809
+ name: "styleCount",
22810
+ type: "number",
22811
+ components: {
22812
+ input: StyleCountInput
22813
+ },
22814
+ readOnly: true
22815
+ };
22801
22816
  var typefaceParams = (doc) => ({ typefaceName: (doc == null ? void 0 : doc.title) || "" });
22802
22817
  var FontsRefArray = (props) => import_react30.default.createElement(import_sanity_advanced_reference_array.AdvancedRefArray, {
22803
22818
  ...props,
@@ -22858,7 +22873,8 @@ function createStylesField({
22858
22873
  subfamilyPreview = false,
22859
22874
  pairs = true,
22860
22875
  generateCollections = false,
22861
- generateFullFamilyCollection = false
22876
+ generateFullFamilyCollection = false,
22877
+ styleCount = false
22862
22878
  } = {}) {
22863
22879
  const subfamilyFields = [
22864
22880
  {
@@ -22958,6 +22974,7 @@ function createStylesField({
22958
22974
  initialValue: false,
22959
22975
  description: "Check if this typeface includes serif letterforms. Used for typeface overview serif/sans filters. Frontend automatically treats non-serif typefaces as sans serif."
22960
22976
  }),
22977
+ ...field(styleCount, inlineStyleCountField),
22961
22978
  {
22962
22979
  title: "Fonts",
22963
22980
  name: "fonts",
package/dist/index.mjs CHANGED
@@ -18396,14 +18396,16 @@ var SingleUploaderTool = (props) => {
18396
18396
  if (!(ttfAsset == null ? void 0 : ttfAsset.url)) throw new Error("Could not fetch TTF file URL");
18397
18397
  const arrayBuffer = await (await fetch(ttfAsset.url)).arrayBuffer();
18398
18398
  const font2 = await parseFont(arrayBuffer, `${doc_id}.ttf`);
18399
- const { weightName, subfamilyName, style, variableFont } = extractFontMetadata(
18399
+ const { weightName, subfamilyName, fontTitle, style, variableFont } = extractFontMetadata(
18400
18400
  font2,
18401
18401
  doc_typefaceName,
18402
18402
  weightKeywordList,
18403
- italicKeywordList
18403
+ italicKeywordList,
18404
+ false,
18405
+ null
18404
18406
  );
18405
18407
  const weight = determineWeight(font2, weightName);
18406
- await client.patch(doc_id).set({ weightName, subfamily: subfamilyName, style, variableFont, weight }).commit();
18408
+ await client.patch(doc_id).set({ title: fontTitle, weightName, subfamily: subfamilyName, style, variableFont, weight }).commit();
18407
18409
  const fontData = await generateFontData({
18408
18410
  url: ttfAsset.url,
18409
18411
  fontKit: font2,
@@ -18553,15 +18555,17 @@ var SingleUploaderTool = (props) => {
18553
18555
  if (code === "ttf") {
18554
18556
  const fontBuffer = await readFontFile(file);
18555
18557
  const font2 = await parseFont(fontBuffer, file.name);
18556
- const { weightName, subfamilyName, style, variableFont } = extractFontMetadata(
18558
+ const { weightName, subfamilyName, fontTitle, style, variableFont } = extractFontMetadata(
18557
18559
  font2,
18558
18560
  doc_typefaceName,
18559
18561
  weightKeywordList,
18560
- italicKeywordList
18562
+ italicKeywordList,
18563
+ false,
18564
+ null
18561
18565
  );
18562
18566
  const weight = determineWeight(font2, weightName);
18563
18567
  const normalizedId = doc_id.startsWith("drafts.") ? doc_id.replace("drafts.", "") : doc_id;
18564
- await client.patch(normalizedId).set({ weightName, subfamily: subfamilyName, style, variableFont, weight }).commit();
18568
+ await client.patch(normalizedId).set({ title: fontTitle, weightName, subfamily: subfamilyName, style, variableFont, weight }).commit();
18565
18569
  }
18566
18570
  onChange(set2(newFileInput));
18567
18571
  setTimeout(() => {
@@ -19483,6 +19487,9 @@ function KeyValueReferenceInput(props) {
19483
19487
  const [availableReferences, setAvailableReferences] = useState16([]);
19484
19488
  const sanityClient = useSanityClient();
19485
19489
  const formDocument = useFormValue8([]);
19490
+ useEffect11(() => {
19491
+ setPairs(value);
19492
+ }, [value]);
19486
19493
  useEffect11(() => {
19487
19494
  const refIds = pairs.filter((p2) => {
19488
19495
  var _a2;
@@ -22697,6 +22704,14 @@ var stylisticSetField = {
22697
22704
  // src/schema/stylesField.js
22698
22705
  import React28 from "react";
22699
22706
  import { AdvancedRefArray } from "@liiift-studio/sanity-advanced-reference-array";
22707
+ var inlineStyleCountField = {
22708
+ name: "styleCount",
22709
+ type: "number",
22710
+ components: {
22711
+ input: StyleCountInput
22712
+ },
22713
+ readOnly: true
22714
+ };
22700
22715
  var typefaceParams = (doc) => ({ typefaceName: (doc == null ? void 0 : doc.title) || "" });
22701
22716
  var FontsRefArray = (props) => React28.createElement(AdvancedRefArray, {
22702
22717
  ...props,
@@ -22757,7 +22772,8 @@ function createStylesField({
22757
22772
  subfamilyPreview = false,
22758
22773
  pairs = true,
22759
22774
  generateCollections = false,
22760
- generateFullFamilyCollection = false
22775
+ generateFullFamilyCollection = false,
22776
+ styleCount = false
22761
22777
  } = {}) {
22762
22778
  const subfamilyFields = [
22763
22779
  {
@@ -22857,6 +22873,7 @@ function createStylesField({
22857
22873
  initialValue: false,
22858
22874
  description: "Check if this typeface includes serif letterforms. Used for typeface overview serif/sans filters. Frontend automatically treats non-serif typefaces as sans serif."
22859
22875
  }),
22876
+ ...field(styleCount, inlineStyleCountField),
22860
22877
  {
22861
22878
  title: "Fonts",
22862
22879
  name: "fonts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liiift-studio/sanity-font-manager",
3
- "version": "2.5.7",
3
+ "version": "2.6.0",
4
4
  "description": "Sanity Studio plugin — full font management suite with batch upload, format conversion, metadata extraction, CSS generation, collection/pair generation, and script variant support. Supports Sanity v3, v4, and v5.",
5
5
  "license": "MIT",
6
6
  "author": "Liiift Studio",
@@ -29,6 +29,11 @@ export function KeyValueReferenceInput(props) {
29
29
  const sanityClient = useSanityClient();
30
30
  const formDocument = useFormValue([]);
31
31
 
32
+ /** Syncs local pairs state when the value prop changes externally (e.g. autofill from parent) */
33
+ useEffect(() => {
34
+ setPairs(value);
35
+ }, [value]);
36
+
32
37
  /** Fetches and caches display titles for all referenced documents whenever pairs change */
33
38
  useEffect(() => {
34
39
  const refIds = pairs.filter(p => p.value?._ref).map(p => p.value._ref);
@@ -194,15 +194,17 @@ export const SingleUploaderTool = (props) => {
194
194
  const arrayBuffer = await (await fetch(ttfAsset.url)).arrayBuffer();
195
195
  const font = await parseFont(arrayBuffer, `${doc_id}.ttf`);
196
196
 
197
- const { weightName, subfamilyName, style, variableFont } = extractFontMetadata(
197
+ const { weightName, subfamilyName, fontTitle, style, variableFont } = extractFontMetadata(
198
198
  font,
199
199
  doc_typefaceName,
200
200
  weightKeywordList,
201
201
  italicKeywordList,
202
+ false,
203
+ null,
202
204
  );
203
205
  const weight = determineWeight(font, weightName);
204
206
 
205
- await client.patch(doc_id).set({ weightName, subfamily: subfamilyName, style, variableFont, weight }).commit();
207
+ await client.patch(doc_id).set({ title: fontTitle, weightName, subfamily: subfamilyName, style, variableFont, weight }).commit();
206
208
 
207
209
  const fontData = await generateFontData({
208
210
  url: ttfAsset.url,
@@ -349,12 +351,12 @@ export const SingleUploaderTool = (props) => {
349
351
  if (code === 'ttf') {
350
352
  const fontBuffer = await readFontFile(file);
351
353
  const font = await parseFont(fontBuffer, file.name);
352
- const { weightName, subfamilyName, style, variableFont } = extractFontMetadata(
353
- font, doc_typefaceName, weightKeywordList, italicKeywordList
354
+ const { weightName, subfamilyName, fontTitle, style, variableFont } = extractFontMetadata(
355
+ font, doc_typefaceName, weightKeywordList, italicKeywordList, false, null
354
356
  );
355
357
  const weight = determineWeight(font, weightName);
356
358
  const normalizedId = doc_id.startsWith('drafts.') ? doc_id.replace('drafts.', '') : doc_id;
357
- await client.patch(normalizedId).set({ weightName, subfamily: subfamilyName, style, variableFont, weight }).commit();
359
+ await client.patch(normalizedId).set({ title: fontTitle, weightName, subfamily: subfamilyName, style, variableFont, weight }).commit();
358
360
  }
359
361
 
360
362
  onChange(set(newFileInput));
@@ -4,6 +4,17 @@ import { AdvancedRefArray } from '@liiift-studio/sanity-advanced-reference-array
4
4
  import { RegenerateSubfamiliesComponent } from '../components/RegenerateSubfamiliesComponent.jsx';
5
5
  import { GenerateCollectionsPairsComponent } from '../components/GenerateCollectionsPairsComponent.jsx';
6
6
  import { PrimaryCollectionGeneratorTypeface } from '../components/PrimaryCollectionGeneratorTypeface.jsx';
7
+ import { StyleCountInput } from '../components/StyleCountInput.jsx';
8
+
9
+ // Inline style count field — injected into the styles object when styleCount option is true
10
+ const inlineStyleCountField = {
11
+ name: 'styleCount',
12
+ type: 'number',
13
+ components: {
14
+ input: StyleCountInput,
15
+ },
16
+ readOnly: true,
17
+ };
7
18
 
8
19
  // Returns extra GROQ params scoped to the current typeface document
9
20
  const typefaceParams = (doc) => ({ typefaceName: doc?.title || '' });
@@ -80,6 +91,7 @@ const subfamilyPreferredStyleFilter = async ({ getClient, document, parent }) =>
80
91
  * @param {boolean} [options.subfamilyFontFilter=false] - Filter subfamily font picker to typeface fonts only
81
92
  * @param {boolean} [options.subfamilyPreview=false] - Include preview on subfamily array items
82
93
  * @param {boolean} [options.pairs=true] - Show pairs array to editors
94
+ * @param {boolean} [options.styleCount=false] - Include style count display above fonts array
83
95
  */
84
96
  export function createStylesField({
85
97
  free = false,
@@ -97,6 +109,7 @@ export function createStylesField({
97
109
  pairs = true,
98
110
  generateCollections = false,
99
111
  generateFullFamilyCollection = false,
112
+ styleCount = false,
100
113
  } = {}) {
101
114
 
102
115
  const subfamilyFields = [
@@ -199,6 +212,7 @@ export function createStylesField({
199
212
  initialValue: false,
200
213
  description: 'Check if this typeface includes serif letterforms. Used for typeface overview serif/sans filters. Frontend automatically treats non-serif typefaces as sans serif.',
201
214
  }),
215
+ ...field(styleCount, inlineStyleCountField),
202
216
  {
203
217
  title: 'Fonts',
204
218
  name: 'fonts',