Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
experimental: migrate transitions to style object model (#4084)
Bogdan Chadkin51d2e3e3e955
diff --git a/apps/builder/app/builder/features/style-panel/sections/transitions/transition-content.tsx b/apps/builder/app/builder/features/style-panel/sections/transitions/transition-content.tsxindex 0ebb026cde..f9d4524fcb 100644--- a/apps/builder/app/builder/features/style-panel/sections/transitions/transition-content.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/transitions/transition-content.tsx@@ -21,31 +21,22 @@ import {Text,Grid,} from "@webstudio-is/design-system";+import { InfoCircleIcon } from "@webstudio-is/icons";import {parseCssValue,properties,propertyDescriptions,type ExtractedTransitionProperties,} from "@webstudio-is/css-data";-import type {- CreateBatchUpdate,- StyleUpdateOptions,-} from "../../shared/use-style-data";+import type { StyleUpdateOptions } from "../../shared/use-style-data";import { type IntermediateStyleValue } from "../../shared/css-value-input";-import { TransitionProperty } from "./transition-property";-import { TransitionTiming } from "./transition-timing";import { CssValueInputContainer } from "../../shared/css-value-input";-import { deleteTransitionLayer, editTransitionLayer } from "./transition-utils";-import type { StyleInfo } from "../../shared/style-info";import { parseCssFragment } from "../../shared/parse-css-fragment";-import { InfoCircleIcon } from "@webstudio-is/icons";import { PropertyInlineLabel } from "../../property-label";--type TransitionContentProps = {- index: number;- currentStyle: StyleInfo;- createBatchUpdate: CreateBatchUpdate;-};+import { TransitionProperty } from "./transition-property";+import { TransitionTiming } from "./transition-timing";+import { editTransitionLayer } from "./transition-utils";+import { useComputedStyles } from "../../shared/model";// We are allowing users to add/edit layers as shorthand from the style-panel// So, we need to use the shorthand property to validate the layer too.@@ -55,33 +46,30 @@ const shortHandTransitionProperty = "transition" as StyleProperty;const getLayer = (value: undefined | StyleValue, index: number) =>value?.type === "layers" ? value.value[index] : undefined;-export const TransitionContent = ({- index,- createBatchUpdate,- currentStyle,-}: TransitionContentProps) => {- const onEditLayer = (- index: number,- layers: LayersValue,- options: StyleUpdateOptions- ) => {- editTransitionLayer({- index,- layers,- options,- createBatchUpdate,- currentStyle,- });- };+export const TransitionContent = ({ index }: { index: number }) => {+ const styles = useComputedStyles([+ "transitionProperty",+ "transitionDuration",+ "transitionTimingFunction",+ "transitionDelay",+ "transitionBehavior",+ ]);+ const [+ transitionProperty,+ transitionDuration,+ transitionTimingFunction,+ transitionDelay,+ transitionBehavior,+ ] = styles;- const property = getLayer(currentStyle.transitionProperty?.value, index);- const duration = getLayer(currentStyle.transitionDuration?.value, index);+ const property = getLayer(transitionProperty.cascadedValue, index);+ const duration = getLayer(transitionDuration.cascadedValue, index);const timingFunction = getLayer(- currentStyle.transitionTimingFunction?.value,+ transitionTimingFunction.cascadedValue,index);- const delay = getLayer(currentStyle.transitionDelay?.value, index);- const behavior = getLayer(currentStyle.transitionBehavior?.value, index);+ const delay = getLayer(transitionDelay.cascadedValue, index);+ const behavior = getLayer(transitionBehavior.cascadedValue, index);const [intermediateValue, setIntermediateValue] = useState<IntermediateStyleValue | InvalidValue | undefined@@ -102,7 +90,7 @@ export const TransitionContent = ({});};- const handleComplete = (options: StyleUpdateOptions) => {+ const handleComplete = () => {if (intermediateValue === undefined) {return;}@@ -129,7 +117,12 @@ export const TransitionContent = ({value: [tuple],};- onEditLayer(index, layers, options);+ editTransitionLayer({+ index,+ layers,+ options: { isEphemeral: false },+ styles,+ });};const handlePropertyUpdate = (@@ -161,7 +154,12 @@ export const TransitionContent = ({value: toValue(layerTuple),});- onEditLayer(index, { type: "layers", value: [layerTuple] }, options);+ editTransitionLayer({+ index,+ layers: { type: "layers", value: [layerTuple] },+ options,+ styles,+ });};return (@@ -175,10 +173,14 @@ export const TransitionContent = ({gridTemplateRows: theme.spacing[13],}}>+ <PropertyInlineLabel+ label="Property"+ description={propertyDescriptions.transitionProperty}+ properties={["transitionProperty"]}+ /><TransitionProperty- currentStyle={currentStyle}- property={property ?? properties.transitionProperty.initial}- onPropertySelection={handlePropertyUpdate}+ value={property ?? properties.transitionProperty.initial}+ onChange={(property) => handlePropertyUpdate({ property })}/><PropertyInlineLabel@@ -279,27 +281,12 @@ export const TransitionContent = ({color={intermediateValue?.type === "invalid" ? "error" : undefined}value={intermediateValue?.value ?? ""}onChange={handleChange}- onBlur={() => handleComplete({ isEphemeral: true })}+ onBlur={handleComplete}onKeyDown={(event) => {event.stopPropagation();if (event.key === "Enter") {- handleComplete({ isEphemeral: false });- event.preventDefault();- }-- if (event.key === "Escape") {- if (intermediateValue === undefined) {- return;- }-- deleteTransitionLayer({- currentStyle,- createBatchUpdate,- index,- options: { isEphemeral: true },- });- setIntermediateValue(undefined);+ handleComplete();event.preventDefault();}}}diff --git a/apps/builder/app/builder/features/style-panel/sections/transitions/transition-property.tsx b/apps/builder/app/builder/features/style-panel/sections/transitions/transition-property.tsxindex f73d3a6e78..34e10cda51 100644--- a/apps/builder/app/builder/features/style-panel/sections/transitions/transition-property.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/transitions/transition-property.tsx@@ -1,9 +1,11 @@-import { useState, useEffect, useMemo } from "react";+import { useState, useEffect } from "react";+import { computed } from "nanostores";+import { useStore } from "@nanostores/react";+import { matchSorter } from "match-sorter";import {animatableProperties,commonTransitionProperties,isAnimatableProperty,- propertyDescriptions,} from "@webstudio-is/css-data";import {InputField,@@ -19,45 +21,73 @@ import {ComboboxScrollArea,} from "@webstudio-is/design-system";import {+ hyphenateProperty,toValue,type KeywordValue,type StyleValue,type UnparsedValue,} from "@webstudio-is/css-engine";-import { matchSorter } from "match-sorter";import { setUnion } from "~/shared/shim";-import { type StyleInfo } from "../../shared/style-info";-import { getAnimatablePropertiesOnInstance } from "./transition-utils";-import { PropertyInlineLabel } from "../../property-label";+import {+ $selectedInstanceSelector,+ $selectedOrLastStyleSourceSelector,+} from "~/shared/nano-states";+import { getComputedStyleDecl } from "~/shared/style-object-model";+import { $definedProperties, $model } from "../../shared/model";type AnimatableProperties = (typeof animatableProperties)[number];type NameAndLabel = { name: string; label?: string };type TransitionPropertyProps = {- property: StyleValue;- currentStyle: StyleInfo;- onPropertySelection: (params: {- property: KeywordValue | UnparsedValue;- }) => void;+ value: StyleValue;+ onChange: (value: KeywordValue | UnparsedValue) => void;};const commonPropertiesSet = new Set(commonTransitionProperties);+const $animatableDefinedProperties = computed(+ [+ $definedProperties,+ $model,+ $selectedInstanceSelector,+ $selectedOrLastStyleSourceSelector,+ ],+ (definedProperties, model, instanceSelector, styleSourceSelector) => {+ const animatableProperties = new Set<string>();+ for (const property of definedProperties) {+ const hyphenatedProperty = hyphenateProperty(property);+ if (isAnimatableProperty(hyphenatedProperty)) {+ const styleDecl = getComputedStyleDecl({+ model,+ instanceSelector,+ styleSourceId: styleSourceSelector?.styleSourceId,+ state: styleSourceSelector?.state,+ property,+ });+ if (+ styleDecl.source.name === "remote" ||+ styleDecl.source.name === "local" ||+ styleDecl.source.name === "overwritten"+ ) {+ animatableProperties.add(hyphenatedProperty);+ }+ }+ }+ return animatableProperties;+ }+);+export const TransitionProperty = ({- property,- currentStyle,- onPropertySelection,+ value,+ onChange,}: TransitionPropertyProps) => {- const valueString = toValue(property);+ const animatableDefinedProperties = useStore($animatableDefinedProperties);+ const valueString = toValue(value);const [inputValue, setInputValue] = useState<string>(valueString);useEffect(() => setInputValue(valueString), [valueString]);- const propertiesDefinedOnInstanceSet = useMemo(- () => getAnimatablePropertiesOnInstance(currentStyle),- [currentStyle]- );const properties = Array.from(setUnion(- setUnion(propertiesDefinedOnInstanceSet, commonPropertiesSet),+ setUnion(animatableDefinedProperties, commonPropertiesSet),new Set(animatableProperties)));@@ -105,10 +135,10 @@ export const TransitionProperty = ({}// Keep the proeprties on instance at the top- if (propertiesDefinedOnInstanceSet.has(a.item.name)) {+ if (animatableDefinedProperties.has(a.item.name)) {return -1;}- if (propertiesDefinedOnInstanceSet.has(b.item.name)) {+ if (animatableDefinedProperties.has(b.item.name)) {return 1;}@@ -132,15 +162,15 @@ export const TransitionProperty = ({const commonProperties = items.filter((item) =>commonPropertiesSet.has(item.name) === true &&- propertiesDefinedOnInstanceSet.has(item.name) === false+ animatableDefinedProperties.has(item.name) === false);const filteredProperties = items.filter((item) =>commonPropertiesSet.has(item.name) === false &&- propertiesDefinedOnInstanceSet.has(item.name) === false+ animatableDefinedProperties.has(item.name) === false);const propertiesDefinedOnInstance: Array<NameAndLabel> = items.filter(- (item) => propertiesDefinedOnInstanceSet.has(item.name)+ (item) => animatableDefinedProperties.has(item.name));const saveAnimatableProperty = (propertyName: string) => {@@ -148,9 +178,7 @@ export const TransitionProperty = ({return;}setInputValue(propertyName);- onPropertySelection({- property: { type: "unparsed", value: propertyName },- });+ onChange({ type: "unparsed", value: propertyName });};const renderItem = (item: NameAndLabel, index: number) => {@@ -169,68 +197,61 @@ export const TransitionProperty = ({};return (- <>- <PropertyInlineLabel- label="Property"- description={propertyDescriptions.transitionProperty}- properties={["transitionProperty"]}- />- <ComboboxRoot open={isOpen}>- <div {...getComboboxProps()}>- <ComboboxAnchor>- <InputField- autoFocus- {...getInputProps({- onKeyDown: (event) => {- if (event.key === "Enter") {- saveAnimatableProperty(inputValue);- }- event.stopPropagation();- },- })}- placeholder="all"- suffix={<NestedInputButton {...getToggleButtonProps()} />}- />- </ComboboxAnchor>- <ComboboxContent align="end" sideOffset={5}>- <ComboboxListbox {...getMenuProps()}>- <ComboboxScrollArea>- {isOpen && (- <>- {propertiesDefinedOnInstance.length > 0 && (- <>- <ComboboxLabel>Defined</ComboboxLabel>- {propertiesDefinedOnInstance.map((property, index) =>- renderItem(property, index)- )}- <ComboboxSeparator />- </>- )}-- <ComboboxLabel>Common</ComboboxLabel>- {commonProperties.map((property, index) =>- renderItem(- property,- propertiesDefinedOnInstance.length + index- )- )}- <ComboboxSeparator />-- {filteredProperties.map((property, index) =>- renderItem(- property,- propertiesDefinedOnInstance.length +- commonProperties.length +- index- )- )}- </>- )}- </ComboboxScrollArea>- </ComboboxListbox>- </ComboboxContent>- </div>- </ComboboxRoot>- </>+ <ComboboxRoot open={isOpen}>+ <div {...getComboboxProps()}>+ <ComboboxAnchor>+ <InputField+ autoFocus+ {...getInputProps({+ onKeyDown: (event) => {+ if (event.key === "Enter") {+ saveAnimatableProperty(inputValue);+ }+ event.stopPropagation();+ },+ })}+ placeholder="all"+ suffix={<NestedInputButton {...getToggleButtonProps()} />}+ />+ </ComboboxAnchor>+ <ComboboxContent align="end" sideOffset={5}>+ <ComboboxListbox {...getMenuProps()}>+ <ComboboxScrollArea>+ {isOpen && (+ <>+ {propertiesDefinedOnInstance.length > 0 && (+ <>+ <ComboboxLabel>Defined</ComboboxLabel>+ {propertiesDefinedOnInstance.map((property, index) =>+ renderItem(property, index)+ )}+ <ComboboxSeparator />+ </>+ )}++ <ComboboxLabel>Common</ComboboxLabel>+ {commonProperties.map((property, index) =>+ renderItem(+ property,+ propertiesDefinedOnInstance.length + index+ )+ )}+ <ComboboxSeparator />++ {filteredProperties.map((property, index) =>+ renderItem(+ property,+ propertiesDefinedOnInstance.length ++ commonProperties.length ++ index+ )+ )}+ </>+ )}+ </ComboboxScrollArea>+ </ComboboxListbox>+ </ComboboxContent>+ </div>+ </ComboboxRoot>);};diff --git a/apps/builder/app/builder/features/style-panel/sections/transitions/transition-utils.ts b/apps/builder/app/builder/features/style-panel/sections/transitions/transition-utils.tsindex 93317d3f7e..b8ae72ac58 100644--- a/apps/builder/app/builder/features/style-panel/sections/transitions/transition-utils.ts+++ b/apps/builder/app/builder/features/style-panel/sections/transitions/transition-utils.ts@@ -4,20 +4,17 @@ import {type KeywordValue,type LayersValue,type UnitValue,- type StyleProperty,- hyphenateProperty,} from "@webstudio-is/css-engine";-import type { StyleInfo } from "../../shared/style-info";-import type {- CreateBatchUpdate,- StyleUpdateOptions,-} from "../../shared/use-style-data";import {extractTransitionProperties,- isAnimatableProperty,properties,transitionLongHandProperties,} from "@webstudio-is/css-data";+import {+ createBatchUpdate,+ type StyleUpdateOptions,+} from "../../shared/use-style-data";+import type { ComputedStyleDecl } from "~/shared/style-object-model";export type TransitionProperty = (typeof transitionLongHandProperties)[number];@@ -89,32 +86,8 @@ export const findTimingFunctionFromValue = ();};-export const getAnimatablePropertiesOnInstance = (- currentStyle: StyleInfo-): Set<string> => {- const properties: Set<string> = new Set();- let property: StyleProperty;- for (property in currentStyle) {- const value = currentStyle[property];- const prop = hyphenateProperty(property);-- if (isAnimatableProperty(prop) === false) {- continue;- }-- if (value?.local !== undefined) {- properties.add(prop);- }-- if (value?.nextSource || value?.previousSource) {- properties.add(prop);- }- }- return properties;-};--export const getTransitionProperties = (- currentyStyle: StyleInfo+const getTransitionProperties = (+ styles: ComputedStyleDecl[]): Record<TransitionProperty, LayersValue> => {const properties: Record<TransitionProperty, LayersValue> = {transitionProperty: { type: "layers", value: [] },@@ -123,51 +96,24 @@ export const getTransitionProperties = (transitionDuration: { type: "layers", value: [] },transitionBehavior: { type: "layers", value: [] },};- for (const property of transitionLongHandProperties) {- const value = currentyStyle[property];-- if (value !== undefined && value.value.type === "layers") {- properties[property] = value.value;+ for (const styleDecl of styles) {+ if (styleDecl.cascadedValue.type === "layers") {+ properties[styleDecl.property as TransitionProperty] =+ styleDecl.cascadedValue;}}return properties;};-export const deleteTransitionLayer = (props: {- index: number;- createBatchUpdate: CreateBatchUpdate;- currentStyle: StyleInfo;- options?: StyleUpdateOptions;-}) => {- const {- index,- createBatchUpdate,- currentStyle,- options = { isEphemeral: false },- } = props;-- const properties = getTransitionProperties(currentStyle);- const batch = createBatchUpdate();- transitionLongHandProperties.forEach((property) => {- const value = properties[property].value;- batch.setProperty(property)({- type: "layers",- value: value.filter((_, i) => i !== index),- });- });- batch.publish(options);-};-// @todo support editing transition-behaviorexport const editTransitionLayer = (props: {index: number;layers: LayersValue;options: StyleUpdateOptions;- currentStyle: StyleInfo;- createBatchUpdate: CreateBatchUpdate;+ styles: ComputedStyleDecl[];}) => {- const { index, layers, createBatchUpdate, options, currentStyle } = props;+ const { index, layers, options } = props;const batch = createBatchUpdate();const newTransitionProperties: Array<KeywordValue | UnparsedValue> = [];@@ -198,7 +144,7 @@ export const editTransitionLayer = (props: {newTransitionTimingFunctions.push(timing);}- const existingTransitionProperties = getTransitionProperties(currentStyle);+ const existingTransitionProperties = getTransitionProperties(props.styles);const {transitionProperty,transitionDelay,diff --git a/apps/builder/app/builder/features/style-panel/sections/transitions/transitions.stories.tsx b/apps/builder/app/builder/features/style-panel/sections/transitions/transitions.stories.tsxindex 8709a108d3..2afdc3747d 100644--- a/apps/builder/app/builder/features/style-panel/sections/transitions/transitions.stories.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/transitions/transitions.stories.tsx@@ -1,11 +1,14 @@import { styled, theme } from "@webstudio-is/design-system";-import { useRef, useState } from "react";-import type { StyleInfo } from "../../shared/style-info";-import type {- CreateBatchUpdate,- DeleteProperty,- SetProperty,-} from "../../shared/use-style-data";+import { getStyleDeclKey, StyleDecl } from "@webstudio-is/sdk";+import {+ $breakpoints,+ $selectedBreakpointId,+ $selectedInstanceSelector,+ $styles,+ $styleSources,+ $styleSourceSelections,+} from "~/shared/nano-states";+import { registerContainers } from "~/shared/sync";import { Section } from "./transitions";const Panel = styled("div", {@@ -13,88 +16,46 @@ const Panel = styled("div", {boxShadow: theme.shadows.panelSectionDropShadow,});-const useStyleInfo = (styleInfoInitial: StyleInfo) => {- const [styleInfo, setStyleInfo] = useState(() => styleInfoInitial);-- const setProperty: SetProperty = (name) => (value, options) => {- if (options?.isEphemeral) {- return;- }-- setStyleInfo((styleInfo) => ({- ...styleInfo,- [name]: {- ...styleInfo[name],- value: value,- local: value,- },- }));- };-- const deleteProperty: DeleteProperty = (name, options) => {- if (options?.isEphemeral) {- return;- }-- setStyleInfo((styleInfo) => {- const { [name]: _, ...rest } = styleInfo;- return rest;- });- };-- const execCommands = useRef<(() => void)[]>([]);-- const createBatchUpdate: CreateBatchUpdate = () => ({- deleteProperty: (property) => {- execCommands.current.push(() => {- deleteProperty(property);- });- },- setProperty: (property) => (style) => {- execCommands.current.push(() => {- setProperty(property)(style);- });- },- publish: (options) => {- if (options?.isEphemeral) {- execCommands.current = [];- return;- }-- for (const command of execCommands.current) {- command();- }-- execCommands.current = [];- },- });-- return { styleInfo, setProperty, deleteProperty, createBatchUpdate };+const transitionProperty: StyleDecl = {+ breakpointId: "base",+ styleSourceId: "local",+ property: "transitionProperty",+ value: {+ type: "layers",+ value: [+ { type: "unparsed", value: "opacity" },+ { type: "unparsed", value: "transform" },+ { type: "keyword", value: "all" },+ ],+ },};-export const Transitions = () => {- const { styleInfo, setProperty, deleteProperty, createBatchUpdate } =- useStyleInfo({- transitionProperty: {- value: {- type: "layers",- value: [- { type: "unparsed", value: "opacity" },- { type: "unparsed", value: "transform" },- { type: "keyword", value: "all" },- ],- },+registerContainers();+$breakpoints.set(new Map([["base", { id: "base", label: "" }]]));+$selectedBreakpointId.set("base");+$styleSources.set(+ new Map([+ [+ "local",+ {+ id: "local",+ type: "local",},- });+ ],+ ])+);+$styles.set(+ new Map([[getStyleDeclKey(transitionProperty), transitionProperty]])+);+$styleSourceSelections.set(+ new Map([["box", { instanceId: "box", values: ["local"] }]])+);+$selectedInstanceSelector.set(["box"]);+export const Transitions = () => {return (<Panel>- <Section- currentStyle={styleInfo}- setProperty={setProperty}- deleteProperty={deleteProperty}- createBatchUpdate={createBatchUpdate}- />+ <Section /></Panel>);};diff --git a/apps/builder/app/builder/features/style-panel/sections/transitions/transitions.tsx b/apps/builder/app/builder/features/style-panel/sections/transitions/transitions.tsxindex 5f193cf6d7..d77bcf619f 100644--- a/apps/builder/app/builder/features/style-panel/sections/transitions/transitions.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/transitions/transitions.tsx@@ -10,68 +10,71 @@ import {properties,transitionLongHandProperties,} from "@webstudio-is/css-data";+import { toValue, type LayerValueItem } from "@webstudio-is/css-engine";import { CollapsibleSectionRoot } from "~/builder/shared/collapsible-section";-import type { SectionProps } from "../shared/section";-import { getDots } from "../../shared/style-section";import { $selectedOrLastStyleSourceSelector } from "~/shared/nano-states";-import { TransitionContent } from "./transition-content";-import {- findTimingFunctionFromValue,- type TransitionProperty,-} from "./transition-utils";-import { toValue, type LayerValueItem } from "@webstudio-is/css-engine";import { humanizeString } from "~/shared/string-utils";-import { RepeatedStyle } from "../../shared/repeated-style";-import type { StyleInfo } from "../../shared/style-info";import { repeatUntil } from "~/shared/array-utils";+import type { ComputedStyleDecl } from "~/shared/style-object-model";+import { getDots } from "../../shared/style-section";+import { RepeatedStyle } from "../../shared/repeated-style";import { PropertySectionLabel } from "../../property-label";import { useComputedStyles } from "../../shared/model";+import { createBatchUpdate } from "../../shared/use-style-data";+import {+ findTimingFunctionFromValue,+ type TransitionProperty,+} from "./transition-utils";+import { TransitionContent } from "./transition-content";export { transitionLongHandProperties as properties };const label = "Transitions";const getTransitionLayers = (- style: StyleInfo,+ styles: ComputedStyleDecl[],property: TransitionProperty) => {+ const transitionPropertyValue = styles.find(+ (styleDecl) => styleDecl.property === "transitionProperty"+ )?.cascadedValue;+ const currentPropertyValue = styles.find(+ (styleDecl) => styleDecl.property === property+ )?.cascadedValue;const transitionPropertiesCount =- style.transitionProperty?.value?.type === "layers"- ? style.transitionProperty.value.value.length+ transitionPropertyValue?.type === "layers"+ ? transitionPropertyValue.value.length: 0;const definedLayers: LayerValueItem[] =- style[property]?.value.type === "layers"- ? style[property].value.value+ currentPropertyValue?.type === "layers"+ ? currentPropertyValue.value: [properties[property].initial];return repeatUntil(definedLayers, transitionPropertiesCount);};const getLayerLabel = ({- style,+ styles,index,}: {- style: StyleInfo;+ styles: ComputedStyleDecl[];index: number;}) => {// show label without hidden replacement- const propertyLayer =- getTransitionLayers(style, "transitionProperty")[index] ??- properties.transitionProperty.initial;+ const propertyLayer = getTransitionLayers(styles, "transitionProperty")[+ index+ ];const property = humanizeString(toValue({ ...propertyLayer, hidden: false }));const duration = toValue(- getTransitionLayers(style, "transitionDuration")[index] ??- properties.transitionDuration.initial+ getTransitionLayers(styles, "transitionDuration")[index]);- const timingFunctionLayer =- getTransitionLayers(style, "transitionTimingFunction")[index] ??- properties.transitionTimingFunction.initial;+ const timingFunctionLayer = getTransitionLayers(+ styles,+ "transitionTimingFunction"+ )[index];const timingFunction = toValue({ ...timingFunctionLayer, hidden: false });const humanizedTimingFunction =findTimingFunctionFromValue(timingFunction) ?? timingFunction;- const delay = toValue(- getTransitionLayers(style, "transitionDelay")[index] ??- properties.transitionDelay.initial- );+ const delay = toValue(getTransitionLayers(styles, "transitionDelay")[index]);return `${property}: ${duration} ${humanizedTimingFunction} ${delay}`;};@@ -84,8 +87,7 @@ const defaultTransitionLayers: Record<TransitionProperty, LayerValueItem> = {transitionBehavior: { type: "keyword", value: "normal" },};-export const Section = (props: SectionProps) => {- const { currentStyle, createBatchUpdate } = props;+export const Section = () => {const [isOpen, setIsOpen] = useState(true);const selectedOrLastStyleSourceSelector = useStore(@@ -124,7 +126,7 @@ export const Section = (props: SectionProps) => {batch.setProperty(property)({type: "layers",value: [- ...getTransitionLayers(currentStyle, property),+ ...getTransitionLayers(styles, property),defaultTransitionLayers[property],],});@@ -145,25 +147,11 @@ export const Section = (props: SectionProps) => {><RepeatedStylelabel={label}- properties={[- "transitionProperty",- "transitionDuration",- "transitionTimingFunction",- "transitionDelay",- "transitionBehavior",- ]}- style={currentStyle}- createBatchUpdate={createBatchUpdate}+ styles={styles}getItemProps={(index) => ({- label: getLayerLabel({ style: currentStyle, index }),+ label: getLayerLabel({ styles, index }),})}- renderItemContent={(index) => (- <TransitionContent- index={index}- currentStyle={currentStyle}- createBatchUpdate={createBatchUpdate}- />- )}+ renderItemContent={(index) => <TransitionContent index={index} />}/></CollapsibleSectionRoot>);diff --git a/apps/builder/app/builder/features/style-panel/shared/model.tsx b/apps/builder/app/builder/features/style-panel/shared/model.tsxindex 62693b47ed..5e3949aa6e 100644--- a/apps/builder/app/builder/features/style-panel/shared/model.tsx+++ b/apps/builder/app/builder/features/style-panel/shared/model.tsx@@ -79,7 +79,50 @@ const $matchingBreakpoints = computed(});-const $model = computed(+export const $definedProperties = computed(+ [+ $selectedInstanceSelector,+ $styleSourceSelections,+ $matchingBreakpoints,+ $styles,+ ],+ (+ instanceSelector,+ styleSourceSelections,+ matchingBreakpointsArray,+ styles+ ) => {+ const definedProperties = new Set<StyleProperty>();+ if (instanceSelector === undefined) {+ return definedProperties;+ }+ const matchingStyleSources = new Set();+ const matchingBreakpoints = new Set(matchingBreakpointsArray);+ for (const instanceId of instanceSelector) {+ const styleSources = styleSourceSelections.get(instanceId)?.values;+ if (styleSources) {+ for (const styleSourceId of styleSources) {+ matchingStyleSources.add(styleSourceId);+ }+ }+ }+ for (const styleDecl of styles.values()) {+ if (+ matchingBreakpoints.has(styleDecl.breakpointId) &&+ matchingStyleSources.has(styleDecl.styleSourceId)+ ) {+ definedProperties.add(styleDecl.property);+ }+ }+ return definedProperties;+ }+);++/**+ * Do not use directly+ * only transition property is permitted+ */+export const $model = computed([$styles,$styleSourceSelections,diff --git a/apps/builder/app/builder/features/style-panel/shared/repeated-style.tsx b/apps/builder/app/builder/features/style-panel/shared/repeated-style.tsxindex 211a1df2f4..404994fb2a 100644--- a/apps/builder/app/builder/features/style-panel/shared/repeated-style.tsx+++ b/apps/builder/app/builder/features/style-panel/shared/repeated-style.tsx@@ -20,28 +20,20 @@ import {useSortable,} from "@webstudio-is/design-system";import { FloatingPanel } from "~/builder/shared/floating-panel";-import type { StyleInfo } from "./style-info";-import type { CreateBatchUpdate } from "./use-style-data";-import { ColorThumb } from "./color-thumb";import { repeatUntil } from "~/shared/array-utils";+import type { ComputedStyleDecl } from "~/shared/style-object-model";+import { createBatchUpdate } from "./use-style-data";+import { ColorThumb } from "./color-thumb";const createLayersTransformer =- ({- properties,- style,- createBatchUpdate,- }: {- properties: StyleProperty[];- style: StyleInfo;- createBatchUpdate: CreateBatchUpdate;- }) =>+ (styles: ComputedStyleDecl[]) =>(transform: (value: LayersValue) => Partial<LayersValue>) => {const batch = createBatchUpdate();- const primaryValue = style[properties[0]]?.value;+ const primaryValue = styles[0].cascadedValue;const primaryLayersCount =primaryValue?.type === "layers" ? primaryValue.value.length : 0;- for (const property of properties) {- const value = style[property]?.value;+ for (const styleDecl of styles) {+ const value = styleDecl.cascadedValue;if (value?.type === "layers") {const normalizedLayers: LayersValue = {type: "layers",@@ -53,9 +45,9 @@ const createLayersTransformer =};// delete empty layersif (newLayers.value.length === 0) {- batch.deleteProperty(property);+ batch.deleteProperty(styleDecl.property as StyleProperty);} else {- batch.setProperty(property)(newLayers);+ batch.setProperty(styleDecl.property as StyleProperty)(newLayers);}}}@@ -90,19 +82,17 @@ const swapLayers = (value: LayersValue, oldIndex: number, newIndex: number) => {export const RepeatedStyle = (props: {label: string;- properties: StyleProperty[];- style: StyleInfo;- createBatchUpdate: CreateBatchUpdate;+ styles: ComputedStyleDecl[];getItemProps: (index: number,primaryValue: StyleValue) => { label: string; color?: RgbaColor };renderItemContent: (index: number) => JSX.Element;}) => {- const transformLayers = createLayersTransformer(props);- const { label, properties, style, getItemProps, renderItemContent } = props;+ const transformLayers = createLayersTransformer(props.styles);+ const { label, styles, getItemProps, renderItemContent } = props;// first property should describe the amount of layers- const layers = style[properties[0]]?.value;+ const layers = styles[0].cascadedValue;const primaryValues = layers?.type === "layers" ? layers.value : [];const sortableItems = useMemo(