🐛 Fix variants events (#7320)

* 🐛 Add missing event add-component-to-variant

* 🐛 Fix event apply-tokens, param applied-to-variant

* 🐛 Fix missing case on event "add new variant"

* 🐛 Fix event combine-as-variants

* 🐛 Fix event variant-edit-property-name

* 🐛 On variants events, change trigger for origin

* 🐛 Split combine-as-variants to not have an optional first parameter
This commit is contained in:
Pablo Alba 2025-09-16 13:09:23 +02:00 committed by GitHub
parent c62fadac47
commit 18d5b84b00
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 169 additions and 137 deletions

View File

@ -887,6 +887,12 @@
(pcb/update-shapes [parent-id]
#(ctl/add-children-to-cell % selected all-objects drop-cell)))
add-component-to-variant? (and
;; Any of the shapes is a head
(some ctc/instance-head? orig-shapes)
;; Any ancestor of the destination parent is a variant
(->> (cfh/get-parents-with-self page-objects parent-id)
(some ctc/is-variant?)))
undo-id (js/Symbol)]
(rx/concat
@ -895,10 +901,7 @@
(let [parent-type (cfh/get-shape-type all-objects (:parent-id shape))
external-lib? (not= file-id (:component-file shape))
component (ctn/get-component-from-shape shape libraries)
origin "workspace:paste"
any-parent-is-variant (->> (cfh/get-parents-with-self all-objects (:parent-id shape))
(some ctc/is-variant?)
boolean)]
origin "workspace:paste"]
;; NOTE: we don't emit the create-shape event all the time for
;; avoid send a lot of events (that are not necessary); this
@ -909,8 +912,7 @@
:is-external-library external-lib?
:type (get shape :type)
:parent-type parent-type
:is-variant (ctc/is-variant? component)
:any-parent-is-variant any-parent-is-variant})
:is-variant (ctc/is-variant? component)})
(if (cfh/has-layout? objects (:parent-id shape))
(ev/event {::ev/name "layout-add-element"
::ev/origin origin
@ -925,7 +927,9 @@
(dch/commit-changes changes)
(dws/select-shapes selected)
(ptk/data-event :layout/update {:ids [frame-id]})
(dwu/commit-undo-transaction undo-id))))))))
(dwu/commit-undo-transaction undo-id)
(when add-component-to-variant?
(ptk/event ::ev/event {::ev/name "add-component-to-variant"})))))))))
(defn- as-content [text]
(let [paragraphs (->> (str/lines text)

View File

@ -592,9 +592,6 @@
page
libraries)
component (ctn/get-component-from-shape new-shape libraries)
any-parent-is-variant (->> (cfh/get-parents-with-self objects (:parent-id new-shape))
(some ctk/is-variant?)
boolean)
undo-id (js/Symbol)]
@ -605,8 +602,7 @@
{::ev/name "use-library-component"
::ev/origin origin
:external-library (not= file-id current-file-id)
:is-variant (ctk/is-variant? component)
:any-parent-is-variant any-parent-is-variant})
:is-variant (ctk/is-variant? component)})
(dwu/start-undo-transaction undo-id)
(dch/commit-changes changes)
(ptk/data-event :layout/update {:ids [(:id new-shape)]})

View File

@ -486,11 +486,7 @@
parent-type (cfh/get-shape-type objects (:parent-id shape))
external-lib? (not= file-id (:component-file shape))
component (ctn/get-component-from-shape shape libraries)
origin "workspace:duplicate-shapes"
any-parent-is-variant (->> (cfh/get-parents-with-self objects (:parent-id shape))
(some ctk/is-variant?)
boolean)]
origin "workspace:duplicate-shapes"]
;; NOTE: we don't emit the create-shape event all the time for
;; avoid send a lot of events (that are not necessary); this
@ -501,8 +497,7 @@
:is-external-library external-lib?
:type (get shape :type)
:parent-type parent-type
:is-variant (ctk/is-variant? component)
:any-parent-is-variant any-parent-is-variant})
:is-variant (ctk/is-variant? component)})
(if (cfh/has-layout? objects (:parent-id shape))
(ev/event {::ev/name "layout-add-element"
::ev/origin origin

View File

@ -235,7 +235,6 @@
parent-id (:id (ctn/get-first-valid-parent objects parent-id)) ;; We don't want to change the structure of component copies
frame-id (:id (ctn/get-first-valid-parent objects frame-id))
shape (cts/setup-shape
(-> attrs
(assoc :type type)
@ -312,7 +311,6 @@
(get objects)
(ctc/is-variant?))))]
(rx/of (create-artboard-from-shapes selected id parent-id index name delta)))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -362,6 +360,7 @@
;; FIXME: this need to be refactored
(defn toggle-file-thumbnail-selected
[]
(ptk/reify ::toggle-file-thumbnail-selected
@ -397,6 +396,7 @@
;; --- Change Shape Order (D&D Ordering)
(defn relocate-shapes
[ids parent-id to-index & [ignore-parents?]]
(dm/assert! (every? uuid? ids))
@ -428,10 +428,28 @@
to-index
ids
:ignore-parents? ignore-parents?))
add-component-to-variant? (and
;; Any of the shapes is a head
(some (comp ctc/instance-head? objects) ids)
;; Any ancestor of the destination parent is a variant
(->> (cfh/get-parents-with-self objects parent-id)
(some ctc/is-variant?)))
add-new-variant? (and
;; The parent is a variant container
(-> parent-id objects ctc/is-variant-container?)
;; Any of the shapes is a main instance
(some (comp ctc/main-instance? objects) ids))
undo-id (js/Symbol)]
(rx/of (dwu/start-undo-transaction undo-id)
(dch/commit-changes changes)
(dwco/expand-collapse parent-id)
(ptk/data-event :layout/update {:ids (concat all-parents ids)})
(dwu/commit-undo-transaction undo-id))))))
(dwu/commit-undo-transaction undo-id)
(when add-component-to-variant?
(ev/event {::ev/name "add-component-to-variant"}))
(when add-new-variant?
(ev/event {::ev/name "add-new-variant" ::ev/origin "workspace:move-shapes-in-layers-tab"})))))))

View File

@ -489,7 +489,7 @@
(some ctt/spacing-margin-keys attributes))
(ctt/any-appliable-attr? attributes (:type shape))))))
shape-ids (d/nilv (keys shapes) [])
any-variant? (->> shapes (some ctk/is-variant?) boolean)
any-variant? (->> shapes vals (some ctk/is-variant?) boolean)
resolved-value (get-in resolved-tokens [(cft/token-identifier token) :resolved-value])
tokenized-attributes (cft/attributes-map attributes token)

View File

@ -295,7 +295,6 @@
(rx/map #(resize shape initial-position layout %))
(rx/share))
modifiers-stream
(if (features/active-feature? state "render-wasm/v1")
(rx/merge
@ -1024,7 +1023,6 @@
delta (calculate-delta position bbox frame)
modifiers (dwm/create-modif-tree [id] (ctm/move-modifiers delta))]
(if (features/active-feature? state "render-wasm/v1")
(rx/of (dwm/apply-wasm-modifiers modifiers
{:ignore-constraints false
@ -1105,7 +1103,19 @@
frame-id
drop-index
ids
:cell cell))]
:cell cell))
add-component-to-variant? (and
;; Any of the shapes is a head
(some (comp ctk/instance-head? objects) ids)
;; Any ancestor of the destination parent is a variant
(->> (cfh/get-parents-with-self objects frame-id)
(some ctk/is-variant?)))
add-new-variant? (and
;; The parent is a variant container
(-> frame-id objects ctk/is-variant-container?)
;; Any of the shapes is a main instance
(some (comp ctk/main-instance? objects) ids))]
(rx/concat
(let [shapes (mapv #(get objects %) ids)
@ -1120,7 +1130,11 @@
(when (and (some? frame-id) (d/not-empty? changes))
(rx/of (dch/commit-changes changes)
(dwc/expand-collapse frame-id))))))))
(dwc/expand-collapse frame-id)))
(when add-component-to-variant?
(rx/of (ev/event {::ev/name "add-component-to-variant"})))
(when add-new-variant?
(rx/of (ev/event {::ev/name "add-new-variant" ::ev/origin "workspace:move-shapes-to-frame"}))))))))
(defn- get-displacement
"Retrieve the correct displacement delta point for the
@ -1135,6 +1149,7 @@
;; -- Flip ----------------------------------------------------------
(defn flip-horizontal-selected
([]
(flip-horizontal-selected nil))
@ -1152,7 +1167,6 @@
center (grc/rect->center selrect)
modifiers (dwm/create-modif-tree selected (ctm/resize-modifiers (gpt/point -1.0 1.0) center))]
(if (features/active-feature? state "render-wasm/v1")
(rx/of (dwm/apply-wasm-modifiers modifiers {:ignore-snap-pixel true}))
(rx/of (dwm/apply-modifiers {:modifiers modifiers :ignore-snap-pixel true}))))))))

View File

@ -87,9 +87,9 @@
(rx/of
(when (or (seq properties-to-remove) (seq properties-to-update))
(ptk/event ::ev/event {::ev/name "variant-edit-property-value" :trigger "rename-in-layers"}))
(ev/event {::ev/name "variant-edit-property-value" ::ev/origin "workspace:rename-in-layers"}))
(when (seq properties-to-add)
(ptk/event ::ev/event {::ev/name "variant-add-property" :trigger "rename-in-layers"}))
(ev/event {::ev/name "variant-add-property" ::ev/origin "workspace:rename-in-layers"}))
(dwu/start-undo-transaction undo-id)
(dch/commit-changes changes)
(dwu/commit-undo-transaction undo-id))))))
@ -97,7 +97,7 @@
(defn update-property-name
"Update the variant property name on the position pos
in all the components with this variant-id"
[variant-id pos new-name]
[variant-id pos new-name {:keys [trigger]}]
(ptk/reify ::update-property-name
ptk/WatchEvent
(watch [it state _]
@ -106,15 +106,22 @@
objects (-> (dsh/get-page data page-id)
(get :objects))
related-components (cfv/find-variant-components data objects variant-id)
props (-> related-components last :variant-properties)
prop-name (-> props (nth pos) :name)
changes (-> (pcb/empty-changes it page-id)
(pcb/with-objects objects)
(pcb/with-library-data data)
(clvp/generate-update-property-name variant-id pos new-name))
undo-id (js/Symbol)]
(rx/of
(dwu/start-undo-transaction undo-id)
(dch/commit-changes changes)
(dwu/commit-undo-transaction undo-id))))))
(when (not= prop-name new-name)
(rx/of
(dwu/start-undo-transaction undo-id)
(dch/commit-changes changes)
(dwu/commit-undo-transaction undo-id)
(ev/event {::ev/name "variant-edit-property-name" ::ev/origin trigger})))))))
(defn update-property-value
"Updates the variant property value on the position pos in a component"
@ -225,7 +232,7 @@
(when (seq (:redo-changes changes))
(rx/of
(ptk/event ::ev/event {::ev/name "variant-remove-property" :trigger "rename-in-layers"})
(ev/event {::ev/name "variant-remove-property" ::ev/origin "workspace:rename-in-layers"})
(dwu/start-undo-transaction undo-id)
(dch/commit-changes changes)
(dwu/commit-undo-transaction undo-id)))))))
@ -466,13 +473,13 @@
(cond
transform-in-variant?
(rx/of
(ptk/event ::ev/event {::ev/name "transform-in-variant" :trigger "shortcut"})
(ev/event {::ev/name "transform-in-variant" ::ev/origin "workspace:shortcut"})
(transform-in-variant (:id first-shape)))
add-new-variant?
(rx/concat
(rx/of
(ptk/event ::ev/event {::ev/name "add-new-variant" :trigger "shortcut-create-component"})
(ev/event {::ev/name "add-new-variant" ::ev/origin "workspace:shortcut-create-component"})
(dwu/start-undo-transaction undo-id))
(rx/from (map add-new-variant selected-ids))
(rx/of (dwu/commit-undo-transaction undo-id)))
@ -494,7 +501,7 @@
(if add-new-variant?
(rx/concat
(rx/of
(ptk/event ::ev/event {::ev/name "add-new-variant" :trigger "shortcut-duplicate"})
(ev/event {::ev/name "add-new-variant" ::ev/origin "workspace:shortcut-duplicate"})
(dwu/start-undo-transaction undo-id)
(add-new-variant (first selected-ids) false))
(rx/from (map #(add-new-variant % true) (rest selected-ids)))
@ -563,79 +570,86 @@
vec))
(defn combine-as-variants
([]
(combine-as-variants nil {}))
([selected {:keys [page-id]}]
(ptk/reify ::combine-as-variants
ptk/WatchEvent
(watch [_ state stream]
(let [current-page (:current-page-id state)
[ids {:keys [page-id trigger]}]
(ptk/reify ::combine-as-variants
ptk/WatchEvent
(watch [_ state stream]
(let [current-page (:current-page-id state)
combine
(fn [current-page]
(let [objects (dsh/lookup-page-objects state current-page)
selected (->> (or selected (dsh/lookup-selected state))
(cfh/clean-loops objects)
(remove (fn [id]
(let [shape (get objects id)]
(or (not (ctc/main-instance? shape))
(ctc/is-variant? shape))))))]
(when (> (count selected) 1)
(let [shapes (mapv #(get objects %) selected)
rect (bounding-rect shapes)
prefix (->> shapes
(mapv #(cfh/split-path (:name %)))
(common-prefix))
combine
(fn [current-page]
(let [objects (dsh/lookup-page-objects state current-page)
ids (->> ids
(cfh/clean-loops objects)
(remove (fn [id]
(let [shape (get objects id)]
(or (not (ctc/main-instance? shape))
(ctc/is-variant? shape))))))]
(when (> (count ids) 1)
(let [shapes (mapv #(get objects %) ids)
rect (bounding-rect shapes)
prefix (->> shapes
(mapv #(cfh/split-path (:name %)))
(common-prefix))
;; When the common parent is root, add a wrapper
add-wrapper? (empty? prefix)
first-shape (first shapes)
delta (gpt/point (- (:x rect) (:x first-shape) 30)
(- (:y rect) (:y first-shape) 30))
common-parent (->> selected
(mapv #(-> (cfh/get-parent-ids objects %) reverse))
common-prefix
last)
index (-> (get objects common-parent)
:shapes
count
inc)
variant-id (uuid/next)
undo-id (js/Symbol)]
add-wrapper? (empty? prefix)
first-shape (first shapes)
delta (gpt/point (- (:x rect) (:x first-shape) 30)
(- (:y rect) (:y first-shape) 30))
common-parent (->> ids
(mapv #(-> (cfh/get-parent-ids objects %) reverse))
common-prefix
last)
index (-> (get objects common-parent)
:shapes
count
inc)
variant-id (uuid/next)
undo-id (js/Symbol)]
(rx/concat
(if (and page-id (not= current-page page-id))
(rx/of (dcm/go-to-workspace :page-id page-id))
(rx/empty))
(rx/concat
(if (and page-id (not= current-page page-id))
(rx/of (dcm/go-to-workspace :page-id page-id))
(rx/empty))
(rx/of (dwu/start-undo-transaction undo-id)
(transform-in-variant (first selected) variant-id delta prefix add-wrapper? false false)
(dwsh/relocate-shapes (into #{} (-> selected rest reverse)) variant-id 0)
(dwsh/update-shapes selected #(-> %
(assoc :constraints-h :left)
(assoc :constraints-v :top)
(assoc :fixed-scroll false)))
(dwsh/relocate-shapes #{variant-id} common-parent index)
(dwt/update-dimensions [variant-id] :width (+ (:width rect) 60))
(dwt/update-dimensions [variant-id] :height (+ (:height rect) 60)))
(rx/of (dwu/start-undo-transaction undo-id)
(transform-in-variant (first ids) variant-id delta prefix add-wrapper? false false)
(dwsh/relocate-shapes (into #{} (-> ids rest reverse)) variant-id 0)
(dwsh/update-shapes ids #(-> %
(assoc :constraints-h :left)
(assoc :constraints-v :top)
(assoc :fixed-scroll false)))
(dwsh/relocate-shapes #{variant-id} common-parent index)
(dwt/update-dimensions [variant-id] :width (+ (:width rect) 60))
(dwt/update-dimensions [variant-id] :height (+ (:height rect) 60))
(ev/event {::ev/name "combine-as-variants" ::ev/origin trigger :number-of-combined (count ids)}))
;; NOTE: we need to schedule a commit into a
;; microtask for ensure that all the scheduled
;; microtask of previous events execute before the
;; commit
(->> (rx/of (dwu/commit-undo-transaction undo-id))
(rx/observe-on :async)))))))
(->> (rx/of (dwu/commit-undo-transaction undo-id))
(rx/observe-on :async)))))))
redirect-to-page
(fn [page-id]
(rx/merge
(->> stream
(rx/filter (ptk/type? ::dwpg/initialize-page))
(rx/take 1)
(rx/observe-on :async)
(rx/mapcat (fn [_] (combine page-id))))
(rx/of (dcm/go-to-workspace :page-id page-id))))]
redirect-to-page
(fn [page-id]
(rx/merge
(->> stream
(rx/filter (ptk/type? ::dwpg/initialize-page))
(rx/take 1)
(rx/observe-on :async)
(rx/mapcat (fn [_] (combine page-id))))
(rx/of (dcm/go-to-workspace :page-id page-id))))]
(if (and page-id (not= page-id current-page))
(redirect-to-page page-id)
(combine current-page)))))))
(if (and page-id (not= page-id current-page))
(redirect-to-page page-id)
(combine current-page))))))
(defn combine-selected-as-variants
[options]
(ptk/reify ::combine-selected-as-variants
ptk/WatchEvent
(watch [_ state _]
(let [selected (dsh/lookup-selected state)]
(rx/of (combine-as-variants selected options))))))

View File

@ -576,12 +576,11 @@
do-add-component (mf/use-fn #(st/emit! (dwl/add-component)))
do-add-multiple-components (mf/use-fn #(st/emit! (dwl/add-multiple-components)))
do-combine-as-variants (mf/use-fn #(st/emit!
(ptk/event ::ev/event {::ev/name "combine-as-variants" :trigger "context-menu-component"})
(dwv/combine-as-variants)))
(dwv/combine-selected-as-variants {:trigger "workspace:context-menu-component"})))
do-add-variant (mf/use-fn
(mf/deps shapes)
#(st/emit!
(ptk/event ::ev/event {::ev/name "add-new-variant" :trigger "context-menu-component"})
(ev/event {::ev/name "add-new-variant" ::ev/origin "workspace:context-menu-component"})
(dwv/add-new-variant (:id (first shapes)))))]
[:*
(when can-make-component ;; We don't want to change the structure of component copies
@ -802,6 +801,7 @@
;; FIXME: optimize because it is rendered always
(mf/defc context-menu*
[]
(let [mdata (mf/deref menu-ref)

View File

@ -39,7 +39,6 @@
[app.util.timers :as ts]
[cljs.spec.alpha :as s]
[cuerdas.core :as str]
[potok.v2.core :as ptk]
[rumext.v2 :as mf]))
(def assets-filters (mf/create-context nil))
@ -357,6 +356,8 @@
;; For when it's only one shape
shape (first shapes)
shape-id (:id shape)
@ -442,17 +443,17 @@
do-add-variant
#(if (ctk/is-variant? shape)
(st/emit!
(ptk/event ::ev/event {::ev/name "add-new-variant"
:trigger (if for-design-tab? "design-tab-menu-variant" "context-menu-variant")})
(ev/event {::ev/name "add-new-variant"
::ev/origin (if for-design-tab? "workspace:design-tab-menu-variant" "workspace:context-menu-variant")})
(dwv/add-new-variant shape-id))
(st/emit!
(ptk/event ::ev/event {::ev/name "transform-in-variant"
:trigger (if for-design-tab? "design-tab-menu" "context-menu")})
(ev/event {::ev/name "transform-in-variant"
::ev/origin (if for-design-tab? "workspace:design-tab-menu" "workspace:context-menu")})
(dwv/transform-in-variant shape-id)))
do-add-new-property
#(st/emit!
(ptk/event ::ev/event {::ev/name "add-new-property" :trigger "design-tab-menu-variant"})
(ev/event {::ev/name "add-new-property" ::ev/origin "workspace:design-tab-menu-variant"})
(dwv/add-new-property variant-id {:property-value "Value 1" :editing? true}))
do-show-local-component

View File

@ -176,7 +176,6 @@
:title (tr "workspace.assets.components.num-variants" num-variants)}
[:> icon* {:icon-id i/variant :size "s"}]])])]))
(defn- count-leaves
"Counts the total number of leaf elements in a nested map structure.
A leaf element is considered any element inside a vector."
@ -202,7 +201,6 @@
dragging* (mf/use-state false)
dragging? (deref dragging*)
selected-paths (mf/with-memo [selected-full]
(into #{}
(comp (map :path) (d/nilv ""))
@ -262,7 +260,6 @@
(when ^boolean dragging?
[:div {:class (stl/css :grid-placeholder)} "\u00A0"])
(when (and (empty? components)
(some? groups)
is-local)
@ -506,9 +503,7 @@
page-id (->> comps first :main-instance-page)]
(st/emit!
(ptk/event ::ev/event {::ev/name "combine-as-variants" :trigger "context-menu-assets-group"})
(dwv/combine-as-variants ids {:page-id page-id})))))
(dwv/combine-as-variants ids {:page-id page-id :trigger "workspace:context-menu-assets-group"})))))
on-drag-start
(mf/use-fn
@ -557,8 +552,7 @@
ids (into #{} (map :main-instance-id selected-full))]
(st/emit!
(ptk/event ::ev/event {::ev/name "combine-as-variants" :trigger "context-menu-assets"})
(dwv/combine-as-variants ids {:page-id page-id})))))]
(dwv/combine-as-variants ids {:page-id page-id :trigger "workspace:context-menu-assets"})))))]
[:& cmm/asset-section {:file-id file-id
:title (tr "workspace.assets.components")

View File

@ -47,7 +47,6 @@
[app.util.timers :as tm]
[cuerdas.core :as str]
[okulary.core :as l]
[potok.v2.core :as ptk]
[rumext.v2 :as mf]))
(def ref:annotations-state
@ -342,7 +341,7 @@
(let [value (d/nilv (str/trim value) "")]
(doseq [id component-ids]
(st/emit!
(ptk/event ::ev/event {::ev/name "variant-edit-property-value" :trigger "combo-design-tab"})
(ev/event {::ev/name "variant-edit-property-value" ::ev/origin "workspace:combo-design-tab"})
(dwv/update-property-value id pos value))
(st/emit! (dwv/update-error id))))))
@ -356,8 +355,7 @@
int)]
(when (seq value)
(st/emit!
(ptk/event ::ev/event {::ev/name "variant-edit-property-name" :trigger "design-tab-variant"})
(dwv/update-property-name variant-id pos value))))))]
(dwv/update-property-name variant-id pos value {:trigger "workspace:design-tab-variant"}))))))]
[:*
[:div {:class (stl/css :variant-property-list)}
@ -895,22 +893,21 @@
(mf/use-fn
(mf/deps id)
#(st/emit!
(ptk/event ::ev/event {::ev/name "add-new-variant" :trigger "button-design-tab-variant"})
(ev/event {::ev/name "add-new-variant" ::ev/origin "workspace:button-design-tab-variant"})
(dwv/add-new-variant id)))
add-new-property
(mf/use-fn
(mf/deps shape)
#(st/emit!
(ptk/event ::ev/event {::ev/name "add-new-property" :trigger "button-design-tab-variant"})
(ev/event {::ev/name "add-new-property" ::ev/origin "workspace:button-design-tab-variant"})
(dwv/add-new-property (:variant-id shape) {:property-value "Value 1"
:editing? true})))
on-combine-as-variants
(mf/use-fn
#(st/emit!
(ptk/event ::ev/event {::ev/name "combine-as-variants" :trigger "button-design-tab"})
(dwv/combine-as-variants)))
(dwv/combine-selected-as-variants {:trigger "workspace:button-design-tab"})))
;; NOTE: function needed for force rerender from the bottom
;; components. This is because `component-annotation`
@ -1097,7 +1094,7 @@
(mf/use-fn
(mf/deps shape)
(fn [trigger]
(st/emit! (ptk/event ::ev/event {::ev/name "add-new-variant" :trigger trigger})
(st/emit! (ev/event {::ev/name "add-new-variant" ::ev/origin trigger})
(dwv/add-new-variant (:id shape)))))
add-new-property
@ -1105,16 +1102,16 @@
(mf/deps variant-id)
(fn [trigger]
(st/emit!
(ptk/event ::ev/event {::ev/name "add-new-property" :trigger trigger})
(ev/event {::ev/name "add-new-property" ::ev/origin trigger})
(dwv/add-new-property variant-id {:property-value "Value 1"
:editing? true}))))
menu-entries [{:title (tr "workspace.shape.menu.show-in-assets")
:action show-in-assets-panel}
{:title (tr "workspace.shape.menu.add-variant")
:action (partial create-variant "design-tab-menu-component")}
:action (partial create-variant "workspace:design-tab-menu-component")}
{:title (tr "workspace.shape.menu.add-variant-property")
:action (partial add-new-property "design-tab-menu-component")}]
:action (partial add-new-property "workspace:design-tab-menu-component")}]
toggle-content
(mf/use-fn
@ -1149,8 +1146,7 @@
int)]
(when (seq value)
(st/emit!
(ptk/event ::ev/event {::ev/name "variant-edit-property-name" :trigger "design-tab-component"})
(dwv/update-property-name variant-id pos value))))))
(dwv/update-property-name variant-id pos value {:trigger "workspace:design-tab-component"}))))))
remove-property
(mf/use-fn
@ -1161,7 +1157,7 @@
int)]
(when (> (count properties) 1)
(st/emit!
(ptk/event ::ev/event {::ev/name "variant-remove-property" :trigger "button-design-tab"})
(ev/event {::ev/name "variant-remove-property" ::ev/origin "workspace:button-design-tab"})
(dwv/remove-property variant-id pos))))))
select-shapes-with-malformed
@ -1195,7 +1191,7 @@
:icon i/help}]
[:> icon-button* {:variant "ghost"
:aria-label (tr "workspace.shape.menu.add-variant")
:on-click (partial create-variant "button-design-tab-component")
:on-click (partial create-variant "workspace:button-design-tab-component")
:icon i/variant}]]]]
(when open?
@ -1233,7 +1229,7 @@
[:> icon-button* {:variant "ghost"
:aria-label (tr "workspace.shape.menu.add-variant-property")
:on-click (partial add-new-property "button-design-tab-component")
:on-click (partial add-new-property "workspace:button-design-tab-component")
:icon i/add}]]
(when-not multi?