@liiift-studio/sanity-font-manager 2.3.0 → 2.3.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/README.md CHANGED
@@ -91,6 +91,78 @@ Updates and re-links existing script font variant references on font documents
91
91
 
92
92
  Recalculates and patches the `subfamily` field on all fonts linked to a typeface, based on the typeface's defined subfamily groups — without re-uploading any files.
93
93
 
94
+ ### `KeyValueInput`
95
+
96
+ Generic ordered key-value editor where both keys and values are plain strings. Supports add, remove, and reorder (up/down arrows). Values are stored as an array of `{ key, value }` objects.
97
+
98
+ ```jsx
99
+ import { KeyValueInput } from '@liiift-studio/sanity-font-manager';
100
+
101
+ {
102
+ name: 'aliases',
103
+ type: 'array',
104
+ of: [{ type: 'object', fields: [{ name: 'key', type: 'string' }, { name: 'value', type: 'string' }] }],
105
+ components: { input: KeyValueInput },
106
+ }
107
+ ```
108
+
109
+ ### `KeyValueReferenceInput`
110
+
111
+ Generic key-value editor where keys are plain strings and values are weak Sanity document references. Supports searching by title via a popover picker, add/remove/reorder, and an optional `topActions` slot for action buttons above the list.
112
+
113
+ | Prop | Type | Description |
114
+ |---|---|---|
115
+ | `fetchReferences` | `async (client, doc) => [{_id, title}]` | Async function that returns candidate references for the picker. Receives the Sanity client and the current document. |
116
+ | `topActions` | `ReactNode` | Optional content rendered above the key-value rows (e.g. autofill buttons). |
117
+ | `referenceType` | `string` | Document type for the created weak references (default: `'font'`). |
118
+
119
+ ```jsx
120
+ import { KeyValueReferenceInput } from '@liiift-studio/sanity-font-manager';
121
+
122
+ {
123
+ name: 'instanceMap',
124
+ type: 'array',
125
+ of: [{ type: 'object', fields: [{ name: 'key', type: 'string' }, { name: 'value', type: 'reference', weak: true, to: [{ type: 'font' }] }] }],
126
+ components: { input: KeyValueReferenceInput },
127
+ // Pass props via options or a wrapper component:
128
+ options: {
129
+ fetchReferences: async (client, doc) => client.fetch('*[_type == "font"]{_id, title}'),
130
+ referenceType: 'font',
131
+ },
132
+ }
133
+ ```
134
+
135
+ ### `VariableInstanceReferencesInput`
136
+
137
+ Font-specific wrapper around `KeyValueReferenceInput` for mapping variable font instance names to their matching static font documents. Provides:
138
+
139
+ - A picker filtered to fonts sharing the same `typefaceName`, excluding variable fonts
140
+ - **Autofill with Matching** — calls `parseVariableFontInstances` to match instance names to existing font documents by weight/style heuristics
141
+ - **Autofill Keys Only** — populates instance name keys from the font's `variableInstances` metadata without resolving references
142
+ - Autofill buttons are shown only when the document is a variable font with parsed instance data
143
+ - Replace/merge confirmation dialog when pairs already exist
144
+
145
+ ```jsx
146
+ import { VariableInstanceReferencesInput } from '@liiift-studio/sanity-font-manager';
147
+
148
+ {
149
+ name: 'variableInstanceReferences',
150
+ title: 'Variable Font Instances',
151
+ type: 'array',
152
+ hidden: ({ parent }) => !parent.variableFont,
153
+ of: [
154
+ {
155
+ type: 'object',
156
+ fields: [
157
+ { name: 'key', type: 'string', title: 'Instance Name' },
158
+ { name: 'value', type: 'reference', weak: true, to: [{ type: 'font' }], title: 'Matching Font' },
159
+ ],
160
+ },
161
+ ],
162
+ components: { input: VariableInstanceReferencesInput },
163
+ }
164
+ ```
165
+
94
166
  ### `StatusDisplay`
95
167
 
96
168
  Shared status bar used by all components. Shows `Status: [message]` in green on success and red on error, with an optional `action` element slot on the far right (used for the advanced toggle in `SingleUploaderTool`).
@@ -209,6 +281,7 @@ const client = useSanityClient();
209
281
  | `glyphCount` | `number` | Total number of glyphs |
210
282
  | `opentypeFeatures` | `object` | Available OpenType feature tags |
211
283
  | `characterSet` | `object` | Array of Unicode code points covered by the font |
284
+ | `variableInstanceReferences` | `array<object>` | Maps variable font instance names to static font document references — `[{ key: string, value: reference }]` |
212
285
 
213
286
  ### Typeface document (`typeface`)
214
287
 
package/dist/index.js CHANGED
@@ -2914,7 +2914,7 @@ var SingleUploaderTool = (props) => {
2914
2914
  }
2915
2915
  )
2916
2916
  }
2917
- ), renderFontSection("ttf"), status === "ready" && (fileInput == null ? void 0 : fileInput.ttf) && /* @__PURE__ */ import_react8.default.createElement(import_ui7.Grid, { columns: [2], gap: 2 }, /* @__PURE__ */ import_react8.default.createElement(
2917
+ ), renderFontSection("ttf"), status === "ready" && (fileInput == null ? void 0 : fileInput.ttf) && /* @__PURE__ */ import_react8.default.createElement(import_ui7.Grid, { columns: [1, 2], gap: 2 }, /* @__PURE__ */ import_react8.default.createElement(
2918
2918
  import_ui7.Button,
2919
2919
  {
2920
2920
  mode: "ghost",
package/dist/index.mjs CHANGED
@@ -2835,7 +2835,7 @@ var SingleUploaderTool = (props) => {
2835
2835
  }
2836
2836
  )
2837
2837
  }
2838
- ), renderFontSection("ttf"), status === "ready" && (fileInput == null ? void 0 : fileInput.ttf) && /* @__PURE__ */ React7.createElement(Grid3, { columns: [2], gap: 2 }, /* @__PURE__ */ React7.createElement(
2838
+ ), renderFontSection("ttf"), status === "ready" && (fileInput == null ? void 0 : fileInput.ttf) && /* @__PURE__ */ React7.createElement(Grid3, { columns: [1, 2], gap: 2 }, /* @__PURE__ */ React7.createElement(
2839
2839
  Button5,
2840
2840
  {
2841
2841
  mode: "ghost",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liiift-studio/sanity-font-manager",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
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",
@@ -627,7 +627,7 @@ export const SingleUploaderTool = (props) => {
627
627
  {renderFontSection('ttf')}
628
628
 
629
629
  {status === 'ready' && fileInput?.ttf && (
630
- <Grid columns={[2]} gap={2}>
630
+ <Grid columns={[1, 2]} gap={2}>
631
631
  <Button
632
632
  mode="ghost"
633
633
  tone="primary"