@pairdraw/design-jsx 0.17.0 → 0.18.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/chunks/component-properties.js +2 -2
- package/dist/chunks/effects.js +6 -1
- package/dist/chunks/effects.js.map +1 -1
- package/dist/chunks/export/index.js +4 -4
- package/dist/chunks/export/index.js.map +1 -1
- package/dist/chunks/fields.js +80 -8
- package/dist/chunks/fields.js.map +1 -1
- package/dist/chunks/index.js +1 -1
- package/dist/chunks/index.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/tree.d.ts +1 -1
- package/package.json +3 -3
- package/src/effects.ts +10 -2
- package/src/overrides/effects.ts +101 -12
- package/src/reference/authoring.md +1 -1
|
@@ -2,10 +2,10 @@ import { DESIGN_JSX_SUPPORTED_PROPERTIES, designJSXProp } from "./behaviours/ren
|
|
|
2
2
|
import { applyComponentPropertyValue, componentPropertyDefinitions, createComponentPropertyId, exposableInstances, exposedInstances, instanceExposureIssue } from "@pairdraw/scene-graph/components";
|
|
3
3
|
import { colorToFill, parseColor, tryParseColor } from "@pairdraw/scene-graph/color";
|
|
4
4
|
import * as v from "valibot";
|
|
5
|
+
import { SHAPE_WITH_TEXT_TYPES } from "@pairdraw/scene-graph/shape-with-text";
|
|
5
6
|
import { paintTransformSchema } from "@pairdraw/scene-graph/paints";
|
|
6
7
|
import { mapValues } from "es-toolkit/object";
|
|
7
8
|
import { STICKY_COLORS } from "@pairdraw/scene-graph/generated";
|
|
8
|
-
import { SHAPE_WITH_TEXT_TYPES } from "@pairdraw/scene-graph/shape-with-text";
|
|
9
9
|
import { isPlainObject } from "es-toolkit/predicate";
|
|
10
10
|
import { compact } from "es-toolkit/array";
|
|
11
11
|
import { instanceMainComponent } from "@pairdraw/scene-graph/instances";
|
|
@@ -804,6 +804,6 @@ function inferComponentSetProperties(graph, componentSetId) {
|
|
|
804
804
|
graph.updateNode(componentSetId, { componentPropertyDefinitions: [...existingDefinitions, ...definitions] });
|
|
805
805
|
}
|
|
806
806
|
//#endregion
|
|
807
|
-
export { BLEND_MODE, CONNECTOR_LINE, CONNECTOR_SIDE, CONSTRAINT, DEFAULT_MODE_NAME, ENUM_PROPS, FIGJAM_TEXT_SIZE, FIGJAM_TYPEFACE, LayerRefs, MASK_TYPE, SHAPE_KIND, STROKE_ALIGN, STROKE_CAP, STROKE_JOIN, TEXT_ALIGN, TEXT_ALIGN_VERTICAL, TEXT_AUTO_RESIZE, TEXT_CASE, TEXT_DECORATION, TEXT_DECORATION_STYLE, TEXT_DIRECTION, applyStrokeOverrides, assignComponentProperties, assignNamedProperties, bindProperties, componentPropNames, connectorPropsSchema, defineMode, defineVars, designMode, designVar, elementPropWarnings, exposeInstance, fillFromValue, inferComponentSetProperties, isColor$1 as isColor, isComponentProperty, isFillValue, isLayerRef, isMode, isVariable, isVariableInput, ownLayerPropsSchema, parseScriptInput, placedOwnLayerPropsSchema, property, readElementProps, ref, shapeLayerPropsSchema, shapePropsSchema, stickyPropsSchema };
|
|
807
|
+
export { BLEND_MODE, CONNECTOR_LINE, CONNECTOR_SIDE, CONSTRAINT, DEFAULT_MODE_NAME, ENUM_PROPS, FIGJAM_TEXT_SIZE, FIGJAM_TYPEFACE, LayerRefs, MASK_TYPE, SHAPE_KIND, STROKE_ALIGN, STROKE_CAP, STROKE_JOIN, TEXT_ALIGN, TEXT_ALIGN_VERTICAL, TEXT_AUTO_RESIZE, TEXT_CASE, TEXT_DECORATION, TEXT_DECORATION_STYLE, TEXT_DIRECTION, applyStrokeOverrides, assignComponentProperties, assignNamedProperties, bindProperties, componentPropNames, connectorPropsSchema, defineMode, defineVars, designMode, designVar, elementPropWarnings, enumProp, exposeInstance, fillFromValue, inferComponentSetProperties, isColor$1 as isColor, isComponentProperty, isFillValue, isLayerRef, isMode, isVariable, isVariableInput, ownLayerPropsSchema, parseScriptInput, placedOwnLayerPropsSchema, property, readElementProps, ref, shapeLayerPropsSchema, shapePropsSchema, stickyPropsSchema };
|
|
808
808
|
|
|
809
809
|
//# sourceMappingURL=component-properties.js.map
|
package/dist/chunks/effects.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BLEND_MODE } from "./component-properties.js";
|
|
1
2
|
import { parseColor } from "@pairdraw/scene-graph/color";
|
|
2
3
|
import { TRANSPARENT } from "@pairdraw/scene-graph/constants";
|
|
3
4
|
//#region src/effects.ts
|
|
@@ -7,6 +8,10 @@ function toColor(color) {
|
|
|
7
8
|
if (color === void 0) return { ...TRANSPARENT };
|
|
8
9
|
return typeof color === "string" ? parseColor(color) : color;
|
|
9
10
|
}
|
|
11
|
+
/** A layer's `blendMode` spelling, or undefined when the helper omits it or names none. */
|
|
12
|
+
function parsedBlendMode(blendMode) {
|
|
13
|
+
return blendMode === void 0 ? void 0 : BLEND_MODE.parse(blendMode);
|
|
14
|
+
}
|
|
10
15
|
function shadowEffect(type, options) {
|
|
11
16
|
return {
|
|
12
17
|
type,
|
|
@@ -18,7 +23,7 @@ function shadowEffect(type, options) {
|
|
|
18
23
|
radius: options.radius ?? DEFAULT_EFFECT_RADIUS,
|
|
19
24
|
spread: options.spread ?? 0,
|
|
20
25
|
visible: options.visible ?? true,
|
|
21
|
-
blendMode: options.blendMode,
|
|
26
|
+
blendMode: parsedBlendMode(options.blendMode),
|
|
22
27
|
showShadowBehindNode: options.showShadowBehindNode
|
|
23
28
|
};
|
|
24
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effects.js","names":[],"sources":["../../src/effects.ts"],"sourcesContent":["import type { BlendMode, Effect } from '@pairdraw/scene-graph'\nimport { parseColor } from '@pairdraw/scene-graph/color'\nimport { TRANSPARENT } from '@pairdraw/scene-graph/constants'\nimport type { Color, Vector } from '@pairdraw/scene-graph/primitives'\n\nexport type EffectColor = string | Color\n\nexport interface ShadowEffectOptions {\n color?: EffectColor\n x?: number\n y?: number\n offset?: Vector\n radius?: number\n spread?: number\n visible?: boolean\n blendMode?:
|
|
1
|
+
{"version":3,"file":"effects.js","names":[],"sources":["../../src/effects.ts"],"sourcesContent":["import type { BlendMode, Effect } from '@pairdraw/scene-graph'\nimport { parseColor } from '@pairdraw/scene-graph/color'\nimport { TRANSPARENT } from '@pairdraw/scene-graph/constants'\nimport type { Color, Vector } from '@pairdraw/scene-graph/primitives'\n\nimport { BLEND_MODE } from './enums'\n\nexport type EffectColor = string | Color\n\nexport interface ShadowEffectOptions {\n color?: EffectColor\n x?: number\n y?: number\n offset?: Vector\n radius?: number\n spread?: number\n visible?: boolean\n /** Same spellings as a layer's `blendMode`, read case-insensitively. */\n blendMode?: string\n showShadowBehindNode?: boolean\n}\n\nexport interface BlurEffectOptions {\n radius?: number\n visible?: boolean\n}\n\n/** Radius of a shadow or blur that does not set one. */\nconst DEFAULT_EFFECT_RADIUS = 8\n\nfunction toColor(color: EffectColor | undefined): Color {\n if (color === undefined) return { ...TRANSPARENT }\n return typeof color === 'string' ? parseColor(color) : color\n}\n\n/** A layer's `blendMode` spelling, or undefined when the helper omits it or names none. */\nfunction parsedBlendMode(blendMode: string | undefined): BlendMode | undefined {\n return blendMode === undefined ? undefined : BLEND_MODE.parse(blendMode)\n}\n\nfunction shadowEffect(type: 'DROP_SHADOW' | 'INNER_SHADOW', options: ShadowEffectOptions): Effect {\n return {\n type,\n color: toColor(options.color ?? 'rgba(0, 0, 0, 0.25)'),\n offset: options.offset ?? { x: options.x ?? 0, y: options.y ?? 4 },\n radius: options.radius ?? DEFAULT_EFFECT_RADIUS,\n spread: options.spread ?? 0,\n visible: options.visible ?? true,\n blendMode: parsedBlendMode(options.blendMode),\n showShadowBehindNode: options.showShadowBehindNode\n }\n}\n\nfunction blurEffect(\n type: 'LAYER_BLUR' | 'BACKGROUND_BLUR' | 'FOREGROUND_BLUR',\n radiusOrOptions: number | BlurEffectOptions = {}\n): Effect {\n const options =\n typeof radiusOrOptions === 'number' ? { radius: radiusOrOptions } : radiusOrOptions\n return {\n type,\n color: { ...TRANSPARENT },\n offset: { x: 0, y: 0 },\n radius: options.radius ?? DEFAULT_EFFECT_RADIUS,\n spread: 0,\n visible: options.visible ?? true\n }\n}\n\nexport function dropShadow(options: ShadowEffectOptions = {}): Effect {\n return shadowEffect('DROP_SHADOW', options)\n}\n\nexport function innerShadow(options: ShadowEffectOptions = {}): Effect {\n return shadowEffect('INNER_SHADOW', options)\n}\n\nexport function layerBlur(radiusOrOptions?: number | BlurEffectOptions): Effect {\n return blurEffect('LAYER_BLUR', radiusOrOptions)\n}\n\nexport function backgroundBlur(radiusOrOptions?: number | BlurEffectOptions): Effect {\n return blurEffect('BACKGROUND_BLUR', radiusOrOptions)\n}\n\nexport function foregroundBlur(radiusOrOptions?: number | BlurEffectOptions): Effect {\n return blurEffect('FOREGROUND_BLUR', radiusOrOptions)\n}\n"],"mappings":";;;;;AA4BA,MAAM,wBAAwB;AAE9B,SAAS,QAAQ,OAAuC;CACtD,IAAI,UAAU,KAAA,GAAW,OAAO,EAAE,GAAG,YAAY;CACjD,OAAO,OAAO,UAAU,WAAW,WAAW,KAAK,IAAI;AACzD;;AAGA,SAAS,gBAAgB,WAAsD;CAC7E,OAAO,cAAc,KAAA,IAAY,KAAA,IAAY,WAAW,MAAM,SAAS;AACzE;AAEA,SAAS,aAAa,MAAsC,SAAsC;CAChG,OAAO;EACL;EACA,OAAO,QAAQ,QAAQ,SAAS,qBAAqB;EACrD,QAAQ,QAAQ,UAAU;GAAE,GAAG,QAAQ,KAAK;GAAG,GAAG,QAAQ,KAAK;EAAE;EACjE,QAAQ,QAAQ,UAAU;EAC1B,QAAQ,QAAQ,UAAU;EAC1B,SAAS,QAAQ,WAAW;EAC5B,WAAW,gBAAgB,QAAQ,SAAS;EAC5C,sBAAsB,QAAQ;CAChC;AACF;AAEA,SAAS,WACP,MACA,kBAA8C,CAAC,GACvC;CACR,MAAM,UACJ,OAAO,oBAAoB,WAAW,EAAE,QAAQ,gBAAgB,IAAI;CACtE,OAAO;EACL;EACA,OAAO,EAAE,GAAG,YAAY;EACxB,QAAQ;GAAE,GAAG;GAAG,GAAG;EAAE;EACrB,QAAQ,QAAQ,UAAU;EAC1B,QAAQ;EACR,SAAS,QAAQ,WAAW;CAC9B;AACF;AAEA,SAAgB,WAAW,UAA+B,CAAC,GAAW;CACpE,OAAO,aAAa,eAAe,OAAO;AAC5C;AAEA,SAAgB,YAAY,UAA+B,CAAC,GAAW;CACrE,OAAO,aAAa,gBAAgB,OAAO;AAC7C;AAEA,SAAgB,UAAU,iBAAsD;CAC9E,OAAO,WAAW,cAAc,eAAe;AACjD;AAEA,SAAgB,eAAe,iBAAsD;CACnF,OAAO,WAAW,mBAAmB,eAAe;AACtD;AAEA,SAAgB,eAAe,iBAAsD;CACnF,OAAO,WAAW,mBAAmB,eAAe;AACtD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isTreeNode } from "../behaviours/elements.js";
|
|
2
|
-
import { backgroundBlur, dropShadow, foregroundBlur, innerShadow, layerBlur } from "../effects.js";
|
|
3
2
|
import { BLEND_MODE, CONSTRAINT, MASK_TYPE, TEXT_ALIGN, TEXT_ALIGN_VERTICAL, TEXT_CASE, TEXT_DECORATION, defineMode, defineVars, designMode, designVar, isMode, isVariable, parseScriptInput, property, ref } from "../component-properties.js";
|
|
3
|
+
import { backgroundBlur, dropShadow, foregroundBlur, innerShadow, layerBlur } from "../effects.js";
|
|
4
4
|
import { Reference, connectorExportScope, connectorLabel, connectorProps, connectorRefDeclarations, helperCall, layersUnder, plainValue, propAttribute, valueSyntax } from "../connectors.js";
|
|
5
5
|
import { DESIGN_JSX_ELEMENTS, collectCornerRadii, collectEffectProps, collectFillProps, collectPadding, collectStrokeProps, elementTag, emitPadding, formatColor, formatTracks, getNodeContext, shapeWithTextLabelText, shapeWithTextProps, stickyBody, stickyProps } from "../elements.js";
|
|
6
6
|
import { AUTO, collectDecorationProps, textLengthJSX } from "./decoration.js";
|
|
@@ -27,14 +27,14 @@ import { getNodeVariableModeId, modesDefaultFirst, resolveVariableInModes } from
|
|
|
27
27
|
import { createDefaultNode } from "@pairdraw/scene-graph/node-defaults";
|
|
28
28
|
import { resolveNodeTextDirection } from "@pairdraw/scene-graph/text/direction";
|
|
29
29
|
//#region src/paints.ts
|
|
30
|
-
const colorSchema = v.union([v.string(), v.object({
|
|
30
|
+
const colorSchema$1 = v.union([v.string(), v.object({
|
|
31
31
|
r: v.number(),
|
|
32
32
|
g: v.number(),
|
|
33
33
|
b: v.number(),
|
|
34
34
|
a: v.number()
|
|
35
35
|
})]);
|
|
36
|
-
const stopsSchema = v.array(v.union([v.tuple([colorSchema, v.number()]), v.object({
|
|
37
|
-
color: colorSchema,
|
|
36
|
+
const stopsSchema = v.array(v.union([v.tuple([colorSchema$1, v.number()]), v.object({
|
|
37
|
+
color: colorSchema$1,
|
|
38
38
|
position: v.number()
|
|
39
39
|
})], (issue) => `Expected [color, position] or { color, position } but received ${issue.received}`));
|
|
40
40
|
const GRADIENT_HELPERS = {
|