@elementor/editor-controls 3.33.0-286 → 3.33.0-288

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.d.mts CHANGED
@@ -136,7 +136,9 @@ type Props$5<TValue> = {
136
136
  value: ExclusiveValue<TValue>;
137
137
  onChange: (value: ExclusiveValue<TValue>) => void;
138
138
  });
139
- declare const ToggleButtonGroupUi: <TValue>({ justify, size, value, onChange, items, maxItems, exclusive, fullWidth, disabled, placeholder, }: Props$5<TValue>) => React$1.JSX.Element;
139
+ declare const ToggleButtonGroupUi: <TValue>(props: Props$5<TValue> & {
140
+ ref?: React$1.Ref<HTMLDivElement>;
141
+ }) => React$1.ReactElement;
140
142
  declare const ControlToggleButtonGroup: <TValue>(props: Props$5<TValue>) => React$1.JSX.Element;
141
143
 
142
144
  type ToggleControlProps<T extends PropValue> = {
package/dist/index.d.ts CHANGED
@@ -136,7 +136,9 @@ type Props$5<TValue> = {
136
136
  value: ExclusiveValue<TValue>;
137
137
  onChange: (value: ExclusiveValue<TValue>) => void;
138
138
  });
139
- declare const ToggleButtonGroupUi: <TValue>({ justify, size, value, onChange, items, maxItems, exclusive, fullWidth, disabled, placeholder, }: Props$5<TValue>) => React$1.JSX.Element;
139
+ declare const ToggleButtonGroupUi: <TValue>(props: Props$5<TValue> & {
140
+ ref?: React$1.Ref<HTMLDivElement>;
141
+ }) => React$1.ReactElement;
140
142
  declare const ControlToggleButtonGroup: <TValue>(props: Props$5<TValue>) => React$1.JSX.Element;
141
143
 
142
144
  type ToggleControlProps<T extends PropValue> = {
package/dist/index.js CHANGED
@@ -2341,99 +2341,102 @@ var StyledToggleButton = (0, import_ui38.styled)(import_ui38.ToggleButton, {
2341
2341
  }
2342
2342
  `}
2343
2343
  `;
2344
- var ToggleButtonGroupUi = ({
2345
- justify = "end",
2346
- size = "tiny",
2347
- value,
2348
- onChange,
2349
- items: items2,
2350
- maxItems,
2351
- exclusive = false,
2352
- fullWidth = false,
2353
- disabled,
2354
- placeholder
2355
- }) => {
2356
- const shouldSliceItems = exclusive && maxItems !== void 0 && items2.length > maxItems;
2357
- const menuItems = shouldSliceItems ? items2.slice(maxItems - 1) : [];
2358
- const fixedItems = shouldSliceItems ? items2.slice(0, maxItems - 1) : items2;
2359
- const theme = (0, import_ui38.useTheme)();
2360
- const isRtl = "rtl" === theme.direction;
2361
- const handleChange = (_, newValue) => {
2362
- onChange(newValue);
2363
- };
2364
- const getGridTemplateColumns = (0, import_react27.useMemo)(() => {
2365
- const isOffLimits = menuItems?.length;
2366
- const itemsCount = isOffLimits ? fixedItems.length + 1 : fixedItems.length;
2367
- const templateColumnsSuffix = isOffLimits ? "auto" : "";
2368
- return `repeat(${itemsCount}, minmax(0, 25%)) ${templateColumnsSuffix}`;
2369
- }, [menuItems?.length, fixedItems.length]);
2370
- const shouldShowExclusivePlaceholder = exclusive && (value === null || value === void 0 || value === "");
2371
- const nonExclusiveSelectedValues = !exclusive && Array.isArray(value) ? value.map((v) => typeof v === "string" ? v : "").join(" ").trim().split(/\s+/).filter(Boolean) : [];
2372
- const shouldShowNonExclusivePlaceholder = !exclusive && nonExclusiveSelectedValues.length === 0;
2373
- const getPlaceholderArray = (placeholderValue) => {
2374
- if (Array.isArray(placeholderValue)) {
2375
- return placeholderValue.flatMap((p) => {
2376
- if (typeof p === "string") {
2377
- return p.trim().split(/\s+/).filter(Boolean);
2378
- }
2379
- return [];
2380
- });
2381
- }
2382
- if (typeof placeholderValue === "string") {
2383
- return placeholderValue.trim().split(/\s+/).filter(Boolean);
2384
- }
2385
- return [];
2386
- };
2387
- const placeholderArray = getPlaceholderArray(placeholder);
2388
- return /* @__PURE__ */ React51.createElement(
2389
- StyledToggleButtonGroup,
2390
- {
2391
- justify,
2392
- value,
2393
- onChange: handleChange,
2394
- exclusive,
2395
- disabled,
2396
- sx: {
2397
- direction: isRtl ? "rtl /* @noflip */" : "ltr /* @noflip */",
2398
- display: "grid",
2399
- gridTemplateColumns: getGridTemplateColumns,
2400
- width: `100%`
2344
+ var ToggleButtonGroupUi = React51.forwardRef(
2345
+ ({
2346
+ justify = "end",
2347
+ size = "tiny",
2348
+ value,
2349
+ onChange,
2350
+ items: items2,
2351
+ maxItems,
2352
+ exclusive = false,
2353
+ fullWidth = false,
2354
+ disabled,
2355
+ placeholder
2356
+ }, ref) => {
2357
+ const shouldSliceItems = exclusive && maxItems !== void 0 && items2.length > maxItems;
2358
+ const menuItems = shouldSliceItems ? items2.slice(maxItems - 1) : [];
2359
+ const fixedItems = shouldSliceItems ? items2.slice(0, maxItems - 1) : items2;
2360
+ const theme = (0, import_ui38.useTheme)();
2361
+ const isRtl = "rtl" === theme.direction;
2362
+ const handleChange = (_, newValue) => {
2363
+ onChange(newValue);
2364
+ };
2365
+ const getGridTemplateColumns = (0, import_react27.useMemo)(() => {
2366
+ const isOffLimits = menuItems?.length;
2367
+ const itemsCount = isOffLimits ? fixedItems.length + 1 : fixedItems.length;
2368
+ const templateColumnsSuffix = isOffLimits ? "auto" : "";
2369
+ return `repeat(${itemsCount}, minmax(0, 25%)) ${templateColumnsSuffix}`;
2370
+ }, [menuItems?.length, fixedItems.length]);
2371
+ const shouldShowExclusivePlaceholder = exclusive && (value === null || value === void 0 || value === "");
2372
+ const nonExclusiveSelectedValues = !exclusive && Array.isArray(value) ? value.map((v) => typeof v === "string" ? v : "").join(" ").trim().split(/\s+/).filter(Boolean) : [];
2373
+ const shouldShowNonExclusivePlaceholder = !exclusive && nonExclusiveSelectedValues.length === 0;
2374
+ const getPlaceholderArray = (placeholderValue) => {
2375
+ if (Array.isArray(placeholderValue)) {
2376
+ return placeholderValue.flatMap((p) => {
2377
+ if (typeof p === "string") {
2378
+ return p.trim().split(/\s+/).filter(Boolean);
2379
+ }
2380
+ return [];
2381
+ });
2401
2382
  }
2402
- },
2403
- fixedItems.map(({ label, value: buttonValue, renderContent: Content3, showTooltip }) => {
2404
- const isPlaceholder = placeholderArray.length > 0 && placeholderArray.includes(buttonValue) && (shouldShowExclusivePlaceholder || shouldShowNonExclusivePlaceholder);
2405
- return /* @__PURE__ */ React51.createElement(
2406
- ConditionalTooltip,
2407
- {
2408
- key: buttonValue,
2409
- label,
2410
- showTooltip: showTooltip || false
2411
- },
2412
- /* @__PURE__ */ React51.createElement(
2413
- StyledToggleButton,
2383
+ if (typeof placeholderValue === "string") {
2384
+ return placeholderValue.trim().split(/\s+/).filter(Boolean);
2385
+ }
2386
+ return [];
2387
+ };
2388
+ const placeholderArray = getPlaceholderArray(placeholder);
2389
+ return /* @__PURE__ */ React51.createElement(
2390
+ StyledToggleButtonGroup,
2391
+ {
2392
+ ref,
2393
+ justify,
2394
+ value,
2395
+ onChange: handleChange,
2396
+ exclusive,
2397
+ disabled,
2398
+ sx: {
2399
+ direction: isRtl ? "rtl /* @noflip */" : "ltr /* @noflip */",
2400
+ display: "grid",
2401
+ gridTemplateColumns: getGridTemplateColumns,
2402
+ width: `100%`
2403
+ }
2404
+ },
2405
+ fixedItems.map(({ label, value: buttonValue, renderContent: Content3, showTooltip }) => {
2406
+ const isPlaceholder = placeholderArray.length > 0 && placeholderArray.includes(buttonValue) && (shouldShowExclusivePlaceholder || shouldShowNonExclusivePlaceholder);
2407
+ return /* @__PURE__ */ React51.createElement(
2408
+ ConditionalTooltip,
2414
2409
  {
2415
- value: buttonValue,
2416
- "aria-label": label,
2417
- size,
2418
- fullWidth,
2419
- isPlaceholder
2410
+ key: buttonValue,
2411
+ label,
2412
+ showTooltip: showTooltip || false
2420
2413
  },
2421
- /* @__PURE__ */ React51.createElement(Content3, { size })
2422
- )
2423
- );
2424
- }),
2425
- menuItems.length && exclusive && /* @__PURE__ */ React51.createElement(
2426
- SplitButtonGroup,
2427
- {
2428
- size,
2429
- value: value || null,
2430
- onChange,
2431
- items: menuItems,
2432
- fullWidth
2433
- }
2434
- )
2435
- );
2436
- };
2414
+ /* @__PURE__ */ React51.createElement(
2415
+ StyledToggleButton,
2416
+ {
2417
+ value: buttonValue,
2418
+ "aria-label": label,
2419
+ size,
2420
+ fullWidth,
2421
+ isPlaceholder
2422
+ },
2423
+ /* @__PURE__ */ React51.createElement(Content3, { size })
2424
+ )
2425
+ );
2426
+ }),
2427
+ menuItems.length && exclusive && /* @__PURE__ */ React51.createElement(
2428
+ SplitButtonGroup,
2429
+ {
2430
+ size,
2431
+ value: value || null,
2432
+ onChange,
2433
+ items: menuItems,
2434
+ fullWidth
2435
+ }
2436
+ )
2437
+ );
2438
+ }
2439
+ );
2437
2440
  var ControlToggleButtonGroup = (props) => {
2438
2441
  return /* @__PURE__ */ React51.createElement(ControlActions, null, /* @__PURE__ */ React51.createElement(ToggleButtonGroupUi, { ...props }));
2439
2442
  };
@@ -2469,8 +2472,7 @@ var SplitButtonGroup = ({
2469
2472
  onClick: (ev) => {
2470
2473
  ev.preventDefault();
2471
2474
  onMenuItemClick(previewButton.value);
2472
- },
2473
- ref: menuButtonRef
2475
+ }
2474
2476
  },
2475
2477
  previewButton.renderContent({ size })
2476
2478
  ), /* @__PURE__ */ React51.createElement(