@elementor/editor-editing-panel 4.4.0-1120 → 4.4.0-1122

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/index.js CHANGED
@@ -5975,7 +5975,7 @@ var getNextItemNumber = (existingTitles) => {
5975
5975
  }
5976
5976
  return next;
5977
5977
  };
5978
- var buildItemModel = (position, showIcon) => {
5978
+ var buildItemModel = (position, showIcon, differentOpenIcon) => {
5979
5979
  const numberedTitle = getItemTitle(position);
5980
5980
  return {
5981
5981
  elType: ACCORDION_ITEM_ELEMENT_TYPE,
@@ -5990,7 +5990,10 @@ var buildItemModel = (position, showIcon) => {
5990
5990
  // has already turned Show Icon off, a newly added item must start with its icon hidden
5991
5991
  // too, not re-show one just because the item itself is brand new. See the comment on
5992
5992
  // the mirrored prop in `Atomic_Accordion_Item_Header` for why this duplication exists.
5993
- settings: { show_icon: import_editor_props18.booleanPropTypeUtil.create(showIcon) },
5993
+ settings: {
5994
+ show_icon: import_editor_props18.booleanPropTypeUtil.create(showIcon),
5995
+ different_open_icon: import_editor_props18.booleanPropTypeUtil.create(differentOpenIcon)
5996
+ },
5994
5997
  elements: [
5995
5998
  {
5996
5999
  elType: ACCORDION_ITEM_TITLE_ELEMENT_TYPE,
@@ -6036,7 +6039,8 @@ var useActions = () => {
6036
6039
  accordionId,
6037
6040
  existingTitles,
6038
6041
  items: items3,
6039
- showIcon
6042
+ showIcon,
6043
+ differentOpenIcon = false
6040
6044
  }) => {
6041
6045
  const accordion = (0, import_editor_elements17.getContainer)(accordionId);
6042
6046
  if (!accordion) {
@@ -6058,7 +6062,11 @@ var useActions = () => {
6058
6062
  // *existing* element out of the document, not for describing one to create. A single
6059
6063
  // cast is enough (the two types overlap enough for TS to allow it directly); no
6060
6064
  // `unknown` escape hatch needed.
6061
- model: buildItemModel(position, showIcon)
6065
+ model: buildItemModel(
6066
+ position,
6067
+ showIcon,
6068
+ differentOpenIcon
6069
+ )
6062
6070
  }
6063
6071
  ]
6064
6072
  });
@@ -6173,6 +6181,56 @@ function getAccordionHeaderIds(accordionId) {
6173
6181
  ).filter((header) => Boolean(header));
6174
6182
  return headerContainers.map((header) => header.id);
6175
6183
  }
6184
+ var cascadeDifferentOpenIconToHeaders = (0, import_editor_v1_adapters9.undoable)(
6185
+ {
6186
+ do: ({ accordionId, differentOpenIcon }) => {
6187
+ const headerIds = getAccordionHeaderIds(accordionId);
6188
+ const previous = Object.fromEntries(
6189
+ headerIds.map(
6190
+ (headerId) => [
6191
+ headerId,
6192
+ (0, import_editor_elements18.getElementSettings)(headerId, [
6193
+ "different_open_icon"
6194
+ ]).different_open_icon
6195
+ ]
6196
+ )
6197
+ );
6198
+ headerIds.forEach((headerId) => {
6199
+ (0, import_editor_elements18.updateElementSettings)({
6200
+ id: headerId,
6201
+ props: { different_open_icon: import_editor_props19.booleanPropTypeUtil.create(differentOpenIcon) },
6202
+ withHistory: false
6203
+ });
6204
+ });
6205
+ return { previous };
6206
+ },
6207
+ undo: (_payload, { previous }) => {
6208
+ Object.entries(previous).forEach(([headerId, previousValue]) => {
6209
+ (0, import_editor_elements18.updateElementSettings)({
6210
+ id: headerId,
6211
+ props: { different_open_icon: previousValue ?? null },
6212
+ withHistory: false
6213
+ });
6214
+ });
6215
+ }
6216
+ },
6217
+ {
6218
+ title: (0, import_i18n70.__)("Accordion", "elementor"),
6219
+ subtitle: (0, import_i18n70.__)("Different icon when open", "elementor"),
6220
+ debounce: { wait: HISTORY_DEBOUNCE_WAIT }
6221
+ }
6222
+ );
6223
+ function useDifferentOpenIconWriteThrough(accordionId, differentOpenIcon) {
6224
+ const previousRef = (0, import_react41.useRef)(null);
6225
+ (0, import_react41.useEffect)(() => {
6226
+ const previous = previousRef.current;
6227
+ previousRef.current = { accordionId, differentOpenIcon };
6228
+ if (!previous || previous.accordionId !== accordionId || previous.differentOpenIcon === differentOpenIcon) {
6229
+ return;
6230
+ }
6231
+ cascadeDifferentOpenIconToHeaders({ accordionId, differentOpenIcon });
6232
+ }, [accordionId, differentOpenIcon]);
6233
+ }
6176
6234
  function useShowIconWriteThrough(accordionId, showIcon) {
6177
6235
  const previousRef = (0, import_react41.useRef)(null);
6178
6236
  (0, import_react41.useEffect)(() => {
@@ -6195,7 +6253,9 @@ var AccordionItemsControl = ({ label }) => {
6195
6253
  { includeSelfAsParent: true }
6196
6254
  );
6197
6255
  const showIcon = import_editor_props20.booleanPropTypeUtil.extract(settings.show_icon) ?? true;
6256
+ const differentOpenIcon = import_editor_props20.booleanPropTypeUtil.extract(settings.different_open_icon) ?? false;
6198
6257
  useShowIconWriteThrough(element.id, showIcon);
6258
+ useDifferentOpenIconWriteThrough(element.id, differentOpenIcon);
6199
6259
  const repeaterValues = items3.map((item, index) => {
6200
6260
  return {
6201
6261
  id: item.id,
@@ -6211,7 +6271,8 @@ var AccordionItemsControl = ({ label }) => {
6211
6271
  // see `getNextItemNumber`.
6212
6272
  existingTitles: repeaterValues.map(({ title }) => title),
6213
6273
  items: meta.action.payload,
6214
- showIcon
6274
+ showIcon,
6275
+ differentOpenIcon
6215
6276
  });
6216
6277
  }
6217
6278
  if (meta?.action?.type === "remove") {