@pixerate/editor-react 0.106.0 → 0.108.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/README.md +1 -1
- package/dist/animation-editor/index.cjs +2 -1
- package/dist/animation-editor/index.js +1 -1
- package/dist/canvas/index.cjs +2 -1
- package/dist/canvas/index.js +1 -1
- package/dist/chart/ChartDataGrid.d.cts +5 -0
- package/dist/chart/ChartDataGrid.d.ts +5 -0
- package/dist/chart/ChartInspector.d.cts +1 -1
- package/dist/chart/ChartInspector.d.ts +1 -1
- package/dist/chart/index.cjs +136 -3
- package/dist/chart/index.js +3 -1
- package/dist/{chunk-CEV4OEOY.js → chunk-6XI62THS.js} +1 -1
- package/dist/{chunk-FUR7LCDM.js → chunk-GJ3IMZQW.js} +152 -5
- package/dist/{chunk-Q7LAFHGP.js → chunk-ZQ6H2C7N.js} +2 -1
- package/dist/effects/EffectParameters.d.cts +4 -2
- package/dist/effects/EffectParameters.d.ts +4 -2
- package/dist/effects/index.cjs +2 -1
- package/dist/effects/index.js +1 -1
- package/dist/image-editor/index.cjs +2 -1
- package/dist/image-editor/index.js +2 -2
- package/dist/index.cjs +136 -4
- package/dist/index.js +3 -3
- package/dist/paint-editor/index.cjs +2 -1
- package/dist/paint-editor/index.js +1 -1
- package/dist/typography/FontPicker.d.cts +48 -0
- package/dist/typography/FontPicker.d.ts +48 -0
- package/dist/typography/TypographyControl.d.cts +11 -0
- package/dist/typography/TypographyControl.d.ts +11 -0
- package/dist/typography/index.cjs +328 -0
- package/dist/typography/index.d.cts +7 -0
- package/dist/typography/index.d.ts +7 -0
- package/dist/typography/index.js +299 -0
- package/dist/typography/useFontPicker.d.cts +17 -0
- package/dist/typography/useFontPicker.d.ts +17 -0
- package/dist/vector/index.cjs +2 -1
- package/dist/vector/index.js +1 -1
- package/dist/video-editor/index.cjs +2 -1
- package/dist/video-editor/index.js +1 -1
- package/package.json +16 -3
|
@@ -2987,10 +2987,11 @@ function EffectParameters({
|
|
|
2987
2987
|
onPreset,
|
|
2988
2988
|
onPresetName,
|
|
2989
2989
|
renderControlAddon,
|
|
2990
|
+
fonts,
|
|
2990
2991
|
disabled = false,
|
|
2991
2992
|
className = ""
|
|
2992
2993
|
}) {
|
|
2993
|
-
const fields = (0, import_react21.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
|
|
2994
|
+
const fields = (0, import_react21.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
|
|
2994
2995
|
const idBase = (0, import_react21.useId)();
|
|
2995
2996
|
const gesture = import_react21.default.useRef(null);
|
|
2996
2997
|
const count = import_react21.default.useRef(0);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type FontPickerModel, type FontProvider, type FontSpec, type FontSummary } from "@pixerate/editor/typography";
|
|
3
|
+
export interface FontPickerProps {
|
|
4
|
+
/** The selected font (controlled). */
|
|
5
|
+
value?: Partial<FontSpec>;
|
|
6
|
+
/** Called when the user (or an agent through the model's tools) picks a different font, weight or style. */
|
|
7
|
+
onChange?: (value: FontSpec) => void;
|
|
8
|
+
/** An existing model; when given, `provider`, `fonts` and `previewText` are ignored. */
|
|
9
|
+
model?: FontPickerModel;
|
|
10
|
+
/** Where fonts come from (fetched on mount). */
|
|
11
|
+
provider?: FontProvider;
|
|
12
|
+
/** A fixed list of fonts. */
|
|
13
|
+
fonts?: readonly FontSummary[];
|
|
14
|
+
/** Text for the live preview. */
|
|
15
|
+
previewText?: string;
|
|
16
|
+
/** Show the live preview (default true). */
|
|
17
|
+
showPreview?: boolean;
|
|
18
|
+
/** Show the category filter (default true). */
|
|
19
|
+
showCategories?: boolean;
|
|
20
|
+
/** Show the weight and style selects (default true). */
|
|
21
|
+
showWeight?: boolean;
|
|
22
|
+
/** Most options rendered at once (default 200); search to reach the rest. */
|
|
23
|
+
maxResults?: number;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
className?: string;
|
|
26
|
+
id?: string;
|
|
27
|
+
/** Accessible label for the group (default "Font picker"). */
|
|
28
|
+
"aria-label"?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Body of the picker, driven by a model (shared with {@link TypographyControl}). */
|
|
31
|
+
export declare function FontPickerView({ model, showPreview, showCategories, showWeight, maxResults, disabled, className, id, "aria-label": ariaLabel, children, }: {
|
|
32
|
+
model: FontPickerModel;
|
|
33
|
+
showPreview?: boolean;
|
|
34
|
+
showCategories?: boolean;
|
|
35
|
+
showWeight?: boolean;
|
|
36
|
+
maxResults?: number;
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
className?: string;
|
|
39
|
+
id?: string;
|
|
40
|
+
"aria-label"?: string;
|
|
41
|
+
children?: React.ReactNode;
|
|
42
|
+
}): React.JSX.Element;
|
|
43
|
+
/**
|
|
44
|
+
* Searchable font picker: a combobox over a listbox of families rendered in their own face, a
|
|
45
|
+
* category filter, weight and style selects, and a live preview. Arrow keys, Home, End, Enter and
|
|
46
|
+
* Escape work in the search field.
|
|
47
|
+
*/
|
|
48
|
+
export declare function FontPicker({ value, onChange, model, provider, fonts, previewText, ...view }: FontPickerProps): React.JSX.Element;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type FontPickerModel, type FontProvider, type FontSpec, type FontSummary } from "@pixerate/editor/typography";
|
|
3
|
+
export interface FontPickerProps {
|
|
4
|
+
/** The selected font (controlled). */
|
|
5
|
+
value?: Partial<FontSpec>;
|
|
6
|
+
/** Called when the user (or an agent through the model's tools) picks a different font, weight or style. */
|
|
7
|
+
onChange?: (value: FontSpec) => void;
|
|
8
|
+
/** An existing model; when given, `provider`, `fonts` and `previewText` are ignored. */
|
|
9
|
+
model?: FontPickerModel;
|
|
10
|
+
/** Where fonts come from (fetched on mount). */
|
|
11
|
+
provider?: FontProvider;
|
|
12
|
+
/** A fixed list of fonts. */
|
|
13
|
+
fonts?: readonly FontSummary[];
|
|
14
|
+
/** Text for the live preview. */
|
|
15
|
+
previewText?: string;
|
|
16
|
+
/** Show the live preview (default true). */
|
|
17
|
+
showPreview?: boolean;
|
|
18
|
+
/** Show the category filter (default true). */
|
|
19
|
+
showCategories?: boolean;
|
|
20
|
+
/** Show the weight and style selects (default true). */
|
|
21
|
+
showWeight?: boolean;
|
|
22
|
+
/** Most options rendered at once (default 200); search to reach the rest. */
|
|
23
|
+
maxResults?: number;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
className?: string;
|
|
26
|
+
id?: string;
|
|
27
|
+
/** Accessible label for the group (default "Font picker"). */
|
|
28
|
+
"aria-label"?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Body of the picker, driven by a model (shared with {@link TypographyControl}). */
|
|
31
|
+
export declare function FontPickerView({ model, showPreview, showCategories, showWeight, maxResults, disabled, className, id, "aria-label": ariaLabel, children, }: {
|
|
32
|
+
model: FontPickerModel;
|
|
33
|
+
showPreview?: boolean;
|
|
34
|
+
showCategories?: boolean;
|
|
35
|
+
showWeight?: boolean;
|
|
36
|
+
maxResults?: number;
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
className?: string;
|
|
39
|
+
id?: string;
|
|
40
|
+
"aria-label"?: string;
|
|
41
|
+
children?: React.ReactNode;
|
|
42
|
+
}): React.JSX.Element;
|
|
43
|
+
/**
|
|
44
|
+
* Searchable font picker: a combobox over a listbox of families rendered in their own face, a
|
|
45
|
+
* category filter, weight and style selects, and a live preview. Arrow keys, Home, End, Enter and
|
|
46
|
+
* Escape work in the search field.
|
|
47
|
+
*/
|
|
48
|
+
export declare function FontPicker({ value, onChange, model, provider, fonts, previewText, ...view }: FontPickerProps): React.JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type FontPickerProps } from "./FontPicker.cjs";
|
|
3
|
+
export interface TypographyControlProps extends FontPickerProps {
|
|
4
|
+
/** Accessible label for the group (default "Typography"). */
|
|
5
|
+
"aria-label"?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Composite inspector control: the {@link FontPicker} plus size (px), line height and letter
|
|
9
|
+
* spacing (em). Emits the whole {@link FontSpec} through `onChange`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function TypographyControl({ value, onChange, model, provider, fonts, previewText, disabled, "aria-label": ariaLabel, ...view }: TypographyControlProps): React.JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type FontPickerProps } from "./FontPicker.js";
|
|
3
|
+
export interface TypographyControlProps extends FontPickerProps {
|
|
4
|
+
/** Accessible label for the group (default "Typography"). */
|
|
5
|
+
"aria-label"?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Composite inspector control: the {@link FontPicker} plus size (px), line height and letter
|
|
9
|
+
* spacing (em). Emits the whole {@link FontSpec} through `onChange`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function TypographyControl({ value, onChange, model, provider, fonts, previewText, disabled, "aria-label": ariaLabel, ...view }: TypographyControlProps): React.JSX.Element;
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/typography/index.ts
|
|
22
|
+
var typography_exports = {};
|
|
23
|
+
__export(typography_exports, {
|
|
24
|
+
FontPicker: () => FontPicker,
|
|
25
|
+
FontPickerView: () => FontPickerView,
|
|
26
|
+
TypographyControl: () => TypographyControl,
|
|
27
|
+
useFontPicker: () => useFontPicker
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(typography_exports);
|
|
30
|
+
|
|
31
|
+
// src/typography/FontPicker.tsx
|
|
32
|
+
var import_react2 = require("react");
|
|
33
|
+
var import_typography2 = require("@pixerate/editor/typography");
|
|
34
|
+
|
|
35
|
+
// src/typography/useFontPicker.ts
|
|
36
|
+
var import_react = require("react");
|
|
37
|
+
var import_typography = require("@pixerate/editor/typography");
|
|
38
|
+
function useFontPicker(options = {}) {
|
|
39
|
+
const onChangeRef = (0, import_react.useRef)(options.onChange);
|
|
40
|
+
onChangeRef.current = options.onChange;
|
|
41
|
+
const [model] = (0, import_react.useState)(() => options.model ?? new import_typography.FontPickerModel({ ...options, onChange: void 0 }));
|
|
42
|
+
const state = (0, import_react.useSyncExternalStore)(model.subscribe, model.getState, model.getState);
|
|
43
|
+
(0, import_react.useEffect)(() => model.onValueChange((value) => onChangeRef.current?.(value)), [model]);
|
|
44
|
+
const valueKey = options.value ? JSON.stringify(options.value) : "";
|
|
45
|
+
(0, import_react.useEffect)(() => {
|
|
46
|
+
if (options.value) model.setValue(options.value);
|
|
47
|
+
}, [model, valueKey]);
|
|
48
|
+
(0, import_react.useEffect)(() => {
|
|
49
|
+
if (!options.model && options.provider) void model.refresh();
|
|
50
|
+
}, [model]);
|
|
51
|
+
return { model, state };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/typography/FontPicker.tsx
|
|
55
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
56
|
+
var FIELD = {
|
|
57
|
+
boxSizing: "border-box",
|
|
58
|
+
width: "100%",
|
|
59
|
+
padding: "5px 8px",
|
|
60
|
+
borderRadius: "6px",
|
|
61
|
+
border: "1px solid var(--pixerate-font-picker-border, #3a4152)",
|
|
62
|
+
background: "var(--pixerate-font-picker-field-bg, #151922)",
|
|
63
|
+
color: "inherit",
|
|
64
|
+
font: "inherit"
|
|
65
|
+
};
|
|
66
|
+
function FontPickerView({
|
|
67
|
+
model,
|
|
68
|
+
showPreview = true,
|
|
69
|
+
showCategories = true,
|
|
70
|
+
showWeight = true,
|
|
71
|
+
maxResults = 200,
|
|
72
|
+
disabled = false,
|
|
73
|
+
className,
|
|
74
|
+
id,
|
|
75
|
+
"aria-label": ariaLabel = "Font picker",
|
|
76
|
+
children
|
|
77
|
+
}) {
|
|
78
|
+
const { state } = useFontPicker({ model });
|
|
79
|
+
const baseId = (0, import_react2.useId)();
|
|
80
|
+
const listId = `${baseId}-list`;
|
|
81
|
+
const optionId = (i) => `${baseId}-opt-${i}`;
|
|
82
|
+
const listRef = (0, import_react2.useRef)(null);
|
|
83
|
+
const shown = state.results.slice(0, maxResults);
|
|
84
|
+
const css = model.css;
|
|
85
|
+
(0, import_react2.useEffect)(() => {
|
|
86
|
+
if (state.highlighted < 0) return;
|
|
87
|
+
const el = listRef.current?.ownerDocument.getElementById(optionId(state.highlighted));
|
|
88
|
+
el?.scrollIntoView?.({ block: "nearest" });
|
|
89
|
+
}, [state.highlighted]);
|
|
90
|
+
const status = state.loading ? "Loading fonts\u2026" : state.error ? `Could not load fonts: ${state.error}` : state.loadStatus[state.value.family.toLowerCase()] === "failed" ? `${state.value.family} could not be loaded; a fallback is shown.` : "";
|
|
91
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
92
|
+
"div",
|
|
93
|
+
{
|
|
94
|
+
id,
|
|
95
|
+
role: "group",
|
|
96
|
+
"aria-label": ariaLabel,
|
|
97
|
+
"aria-disabled": disabled || void 0,
|
|
98
|
+
className,
|
|
99
|
+
style: {
|
|
100
|
+
boxSizing: "border-box",
|
|
101
|
+
width: "var(--pixerate-font-picker-width, 280px)",
|
|
102
|
+
borderRadius: "var(--pixerate-font-picker-radius, 8px)",
|
|
103
|
+
background: "var(--pixerate-font-picker-bg, #1f2430)",
|
|
104
|
+
color: "var(--pixerate-font-picker-fg, #f0f2f5)",
|
|
105
|
+
padding: "12px",
|
|
106
|
+
display: "flex",
|
|
107
|
+
flexDirection: "column",
|
|
108
|
+
gap: "8px",
|
|
109
|
+
fontFamily: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
|
|
110
|
+
fontSize: "12px",
|
|
111
|
+
opacity: disabled ? 0.6 : 1,
|
|
112
|
+
pointerEvents: disabled ? "none" : "auto"
|
|
113
|
+
},
|
|
114
|
+
children: [
|
|
115
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", gap: "6px" }, children: [
|
|
116
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
117
|
+
"input",
|
|
118
|
+
{
|
|
119
|
+
type: "text",
|
|
120
|
+
role: "combobox",
|
|
121
|
+
"aria-label": "Search fonts",
|
|
122
|
+
"aria-expanded": "true",
|
|
123
|
+
"aria-controls": listId,
|
|
124
|
+
"aria-autocomplete": "list",
|
|
125
|
+
"aria-activedescendant": state.highlighted >= 0 && state.highlighted < shown.length ? optionId(state.highlighted) : void 0,
|
|
126
|
+
placeholder: "Search fonts",
|
|
127
|
+
value: state.query,
|
|
128
|
+
disabled,
|
|
129
|
+
onChange: (e) => model.setQuery(e.target.value),
|
|
130
|
+
onKeyDown: (e) => {
|
|
131
|
+
if (model.handleKey(e.key)) e.preventDefault();
|
|
132
|
+
},
|
|
133
|
+
style: FIELD
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
showCategories && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
137
|
+
"select",
|
|
138
|
+
{
|
|
139
|
+
"aria-label": "Font category",
|
|
140
|
+
value: state.category,
|
|
141
|
+
disabled,
|
|
142
|
+
onChange: (e) => model.setCategory(e.target.value),
|
|
143
|
+
style: { ...FIELD, width: "auto" },
|
|
144
|
+
children: ["all", ...import_typography2.FONT_CATEGORIES].map((c) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: c, children: import_typography2.FONT_CATEGORY_LABELS[c] }, c))
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
] }),
|
|
148
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
149
|
+
"ul",
|
|
150
|
+
{
|
|
151
|
+
ref: listRef,
|
|
152
|
+
id: listId,
|
|
153
|
+
role: "listbox",
|
|
154
|
+
"aria-label": "Fonts",
|
|
155
|
+
style: {
|
|
156
|
+
listStyle: "none",
|
|
157
|
+
margin: 0,
|
|
158
|
+
padding: "2px",
|
|
159
|
+
maxHeight: "var(--pixerate-font-picker-list-height, 180px)",
|
|
160
|
+
overflowY: "auto",
|
|
161
|
+
borderRadius: "6px",
|
|
162
|
+
border: "1px solid var(--pixerate-font-picker-border, #3a4152)"
|
|
163
|
+
},
|
|
164
|
+
children: [
|
|
165
|
+
shown.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { role: "presentation", style: { padding: "6px 8px", opacity: 0.7 }, children: state.loading ? "Loading\u2026" : "No fonts match" }),
|
|
166
|
+
shown.map((font, i) => {
|
|
167
|
+
const selected = font.family.toLowerCase() === state.value.family.toLowerCase();
|
|
168
|
+
const highlighted = i === state.highlighted;
|
|
169
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
170
|
+
"li",
|
|
171
|
+
{
|
|
172
|
+
id: optionId(i),
|
|
173
|
+
role: "option",
|
|
174
|
+
"aria-selected": selected,
|
|
175
|
+
"data-highlighted": highlighted || void 0,
|
|
176
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
177
|
+
onMouseEnter: () => model.setHighlight(i),
|
|
178
|
+
onClick: () => model.selectFamily(font.family),
|
|
179
|
+
style: {
|
|
180
|
+
display: "flex",
|
|
181
|
+
justifyContent: "space-between",
|
|
182
|
+
alignItems: "baseline",
|
|
183
|
+
gap: "8px",
|
|
184
|
+
padding: "5px 8px",
|
|
185
|
+
borderRadius: "4px",
|
|
186
|
+
cursor: "pointer",
|
|
187
|
+
background: selected ? "var(--pixerate-font-picker-selected, #2f3b57)" : highlighted ? "var(--pixerate-font-picker-hover, #2a3040)" : "transparent"
|
|
188
|
+
},
|
|
189
|
+
children: [
|
|
190
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { fontFamily: model.familyCss(font), fontSize: "14px" }, children: font.family }),
|
|
191
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { opacity: 0.6, fontSize: "10px" }, children: import_typography2.FONT_CATEGORY_LABELS[font.category] })
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
font.family
|
|
195
|
+
);
|
|
196
|
+
})
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
),
|
|
200
|
+
showWeight && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", gap: "6px" }, children: [
|
|
201
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
202
|
+
"select",
|
|
203
|
+
{
|
|
204
|
+
"aria-label": "Font weight",
|
|
205
|
+
value: state.value.weight,
|
|
206
|
+
disabled,
|
|
207
|
+
onChange: (e) => model.setWeight(Number(e.target.value)),
|
|
208
|
+
style: FIELD,
|
|
209
|
+
children: model.availableWeights.map((w) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: w, children: w }, w))
|
|
210
|
+
}
|
|
211
|
+
),
|
|
212
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
213
|
+
"select",
|
|
214
|
+
{
|
|
215
|
+
"aria-label": "Font style",
|
|
216
|
+
value: state.value.style,
|
|
217
|
+
disabled,
|
|
218
|
+
onChange: (e) => model.setStyle(e.target.value),
|
|
219
|
+
style: FIELD,
|
|
220
|
+
children: model.availableStyles.map((s) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: s, children: s }, s))
|
|
221
|
+
}
|
|
222
|
+
)
|
|
223
|
+
] }),
|
|
224
|
+
children,
|
|
225
|
+
showPreview && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
226
|
+
"div",
|
|
227
|
+
{
|
|
228
|
+
"aria-label": "Font preview",
|
|
229
|
+
style: {
|
|
230
|
+
fontFamily: css.fontFamily,
|
|
231
|
+
fontWeight: css.fontWeight,
|
|
232
|
+
fontStyle: css.fontStyle,
|
|
233
|
+
fontSize: `${Math.min(state.value.size, 48)}px`,
|
|
234
|
+
lineHeight: css.lineHeight,
|
|
235
|
+
letterSpacing: css.letterSpacing,
|
|
236
|
+
padding: "6px 4px",
|
|
237
|
+
overflowWrap: "anywhere"
|
|
238
|
+
},
|
|
239
|
+
children: state.previewText
|
|
240
|
+
}
|
|
241
|
+
),
|
|
242
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { role: "status", "aria-live": "polite", style: { minHeight: status ? void 0 : 0, opacity: 0.75 }, children: status })
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
function FontPicker({ value, onChange, model, provider, fonts, previewText, ...view }) {
|
|
248
|
+
const picker = useFontPicker({ model, provider, fonts, previewText, value, onChange });
|
|
249
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FontPickerView, { model: picker.model, ...view });
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// src/typography/TypographyControl.tsx
|
|
253
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
254
|
+
var NUMBER = {
|
|
255
|
+
boxSizing: "border-box",
|
|
256
|
+
width: "100%",
|
|
257
|
+
padding: "5px 6px",
|
|
258
|
+
borderRadius: "6px",
|
|
259
|
+
border: "1px solid var(--pixerate-font-picker-border, #3a4152)",
|
|
260
|
+
background: "var(--pixerate-font-picker-field-bg, #151922)",
|
|
261
|
+
color: "inherit",
|
|
262
|
+
font: "inherit"
|
|
263
|
+
};
|
|
264
|
+
function NumberField({
|
|
265
|
+
label,
|
|
266
|
+
unit,
|
|
267
|
+
value,
|
|
268
|
+
step,
|
|
269
|
+
min,
|
|
270
|
+
max,
|
|
271
|
+
disabled,
|
|
272
|
+
onCommit
|
|
273
|
+
}) {
|
|
274
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { style: { display: "flex", flexDirection: "column", gap: "2px", flex: 1, minWidth: 0 }, children: [
|
|
275
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: { opacity: 0.75 }, children: [
|
|
276
|
+
label,
|
|
277
|
+
" ",
|
|
278
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { opacity: 0.6 }, children: unit })
|
|
279
|
+
] }),
|
|
280
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
281
|
+
"input",
|
|
282
|
+
{
|
|
283
|
+
type: "number",
|
|
284
|
+
"aria-label": label,
|
|
285
|
+
value,
|
|
286
|
+
step,
|
|
287
|
+
min,
|
|
288
|
+
max,
|
|
289
|
+
disabled,
|
|
290
|
+
onChange: (e) => {
|
|
291
|
+
const n = e.target.valueAsNumber;
|
|
292
|
+
if (Number.isFinite(n)) onCommit(n);
|
|
293
|
+
},
|
|
294
|
+
style: NUMBER
|
|
295
|
+
}
|
|
296
|
+
)
|
|
297
|
+
] });
|
|
298
|
+
}
|
|
299
|
+
function TypographyControl({
|
|
300
|
+
value,
|
|
301
|
+
onChange,
|
|
302
|
+
model,
|
|
303
|
+
provider,
|
|
304
|
+
fonts,
|
|
305
|
+
previewText,
|
|
306
|
+
disabled = false,
|
|
307
|
+
"aria-label": ariaLabel = "Typography",
|
|
308
|
+
...view
|
|
309
|
+
}) {
|
|
310
|
+
const { model: m, state } = useFontPicker({ model, provider, fonts, previewText, value, onChange });
|
|
311
|
+
const v = state.value;
|
|
312
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(FontPickerView, { model: m, disabled, "aria-label": ariaLabel, ...view, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", gap: "6px" }, children: [
|
|
313
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NumberField, { label: "Font size", unit: "px", value: v.size, step: 1, min: 1, max: 1e3, disabled, onCommit: (n) => m.setSize(n) }),
|
|
314
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NumberField, { label: "Line height", unit: "\xD7", value: v.lineHeight ?? 1.5, step: 0.05, min: 0.5, max: 4, disabled, onCommit: (n) => m.setLineHeight(n) }),
|
|
315
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NumberField, { label: "Letter spacing", unit: "em", value: v.letterSpacing ?? 0, step: 0.01, min: -0.5, max: 1, disabled, onCommit: (n) => m.setLetterSpacing(n) })
|
|
316
|
+
] }) });
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// src/typography/index.ts
|
|
320
|
+
__reExport(typography_exports, require("@pixerate/editor/typography"), module.exports);
|
|
321
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
322
|
+
0 && (module.exports = {
|
|
323
|
+
FontPicker,
|
|
324
|
+
FontPickerView,
|
|
325
|
+
TypographyControl,
|
|
326
|
+
useFontPicker,
|
|
327
|
+
...require("@pixerate/editor/typography")
|
|
328
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { FontPicker, FontPickerView } from "./FontPicker.cjs";
|
|
2
|
+
export type { FontPickerProps } from "./FontPicker.cjs";
|
|
3
|
+
export { TypographyControl } from "./TypographyControl.cjs";
|
|
4
|
+
export type { TypographyControlProps } from "./TypographyControl.cjs";
|
|
5
|
+
export { useFontPicker } from "./useFontPicker.cjs";
|
|
6
|
+
export type { UseFontPickerOptions, UseFontPickerResult } from "./useFontPicker.cjs";
|
|
7
|
+
export * from "@pixerate/editor/typography";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { FontPicker, FontPickerView } from "./FontPicker.js";
|
|
2
|
+
export type { FontPickerProps } from "./FontPicker.js";
|
|
3
|
+
export { TypographyControl } from "./TypographyControl.js";
|
|
4
|
+
export type { TypographyControlProps } from "./TypographyControl.js";
|
|
5
|
+
export { useFontPicker } from "./useFontPicker.js";
|
|
6
|
+
export type { UseFontPickerOptions, UseFontPickerResult } from "./useFontPicker.js";
|
|
7
|
+
export * from "@pixerate/editor/typography";
|