- }
-
- }
-
+
+ {children}
+
);
};
diff --git a/scripts/components/base-control/base-control.js b/scripts/components/base-control/base-control.js
index 990b85c45..0a4f75aa0 100644
--- a/scripts/components/base-control/base-control.js
+++ b/scripts/components/base-control/base-control.js
@@ -1,25 +1,23 @@
import React from 'react';
-import { IconLabel } from '@eightshift/frontend-libs/scripts';
-import { clsx } from '@eightshift/ui-components/utilities';
+import { BaseControl } from '@eightshift/ui-components';
/**
* @since 8.0.0
*
* A base component to optionally encase a component with a label and help.
*
- * @param {object} props - Control options.
- * @param {React.Component?} [props.icon] - Icon to show next to the label
- * @param {React.Component?} [props.label] - Label to show above component.
- * @param {React.Component?} [props.subtitle] - Subtitle below the label.
- * @param {React.Component?} [props.actions] - Actions to show to the right of the label.
- * @param {React.Component?} [props.help] - Help to show below the control.
- * @param {React.Component?} [props.children] - Content to show.
- * @param {string?} [props.additionalClasses] - Classes to add to the control base.
- * @param {string?} [props.additionalLabelClasses] - Classes to add to the control label.
- * @param {boolean?} [props.inlineLabel=false] - If `true`, the label is displayed inline with the control. In that case `actions` are shown below the control.
- * @param {boolean?} [props.noBottomSpacing=false] - If `true`, space below the control is removed.
- * @param {boolean?} [props.reducedBottomSpacing=false] - If `true`, space below the control is reduced.
- * @param {function?} [props.wrapChildren] - If passed (function `(children) => React.Component`), the children are wrapped in the provided element.
+ * @deprecated Use `BaseControl` from `@eightshift/ui-components` instead.
+ *
+ * @param {object} props - Control options.
+ * @param {React.Component?} [props.icon] - Icon to show next to the label
+ * @param {React.Component?} [props.label] - Label to show above component.
+ * @param {React.Component?} [props.subtitle] - Subtitle below the label.
+ * @param {React.Component?} [props.actions] - Actions to show to the right of the label.
+ * @param {React.Component?} [props.help] - Help to show below the control.
+ * @param {React.Component?} [props.children] - Content to show.
+ * @param {string?} [props.additionalClasses] - Classes to add to the control base.
+ * @param {string?} [props.additionalLabelClasses] - Classes to add to the control label.
+ * @param {boolean?} [props.inlineLabel=false] - If `true`, the label is displayed inline with the control. In that case `actions` are shown below the control.
*/
export const Control = (props) => {
const {
@@ -37,67 +35,20 @@ export const Control = (props) => {
additionalClasses,
additionalLabelClasses,
-
- noBottomSpacing = false,
- reducedBottomSpacing = false,
-
- wrapChildren,
} = props;
- if (!children) {
- return null;
- }
-
- const bottomSpacingClass = reducedBottomSpacing ? 'es-mb-2' : 'es-mb-5';
-
- if (inlineLabel) {
- return (
-
- }
+ className={additionalClasses}
+ actions={actions}
+ keepActionsOnExpand={keepActionsOnExpand}
+ disabled={disabled}
>
-
- {children}
-
-
+ {children}
+
);
};
diff --git a/scripts/components/color-palette-custom/color-palette-custom.js b/scripts/components/color-palette-custom/color-palette-custom.js
index d40432166..025597dae 100644
--- a/scripts/components/color-palette-custom/color-palette-custom.js
+++ b/scripts/components/color-palette-custom/color-palette-custom.js
@@ -1,35 +1,31 @@
-import React, { useState } from 'react';
+import React from 'react';
import { __ } from '@wordpress/i18n';
-import { Button, TextControl, Tooltip } from '@wordpress/components';
-import { icons } from '@eightshift/ui-components/icons';
import { select } from '@wordpress/data';
import { STORE_NAME } from './../../editor/store';
-import { Control } from '../base-control/base-control';
-import { ColorSwatch } from '../color-swatch/color-swatch';
-import { clsx } from '@eightshift/ui-components/utilities';
+import { ColorPicker } from '@eightshift/ui-components';
/**
* Modified version of WordPress's `ColorPalette` which saves values as color names/slugs instead of hex codes.
*
- * @typedef {'tiles'|'list'|'listTwoCol'} ColorPaletteLayout
+ * @deprecated Use `ColorPicker` from `@eightshift/ui-components` instead.
*
- * @param {object} props - ColorPalette options.
- * @param {array} props.colors - Colors to display.
- * @param {object} props.value - Current value.
- * @param {function} props.onChange - Function called when the value is modified.
- * @param {boolean} [props.clearable=false] - If `true`, the color palette will have a *Clear* button.
- * @param {string?} [props.label] - Label displayed above the picker.
- * @param {string?} [props.help] - Help text displayed below the picker.
- * @param {React.Component?} [props.icon] - Icon to show next to the label
- * @param {boolean?} [props.noBottomSpacing] - If `true`, space below the control is removed.
- * @param {boolean?} [props.reducedBottomSpacing] - If `true`, space below the control is reduced.
- * @param {boolean?} [props.inlineLabel] - If `true`, the label is displayed inline with the control. In that case `actions` are shown below the control.
+ * @param {object} props - ColorPalette options.
+ * @param {array} props.colors - Colors to display.
+ * @param {object} props.value - Current value.
+ * @param {function} props.onChange - Function called when the value is modified.
+ * @param {boolean} [props.clearable=false] - If `true`, the color palette will have a *Clear* button.
+ * @param {string?} [props.label] - Label displayed above the picker.
+ * @param {string?} [props.help] - Help text displayed below the picker.
+ * @param {React.Component?} [props.icon] - Icon to show next to the label
+ * @param {boolean?} [props.noBottomSpacing] - If `true`, space below the control is removed.
+ * @param {boolean?} [props.reducedBottomSpacing] - If `true`, space below the control is reduced.
+ * @param {boolean?} [props.inlineLabel] - If `true`, the label is displayed inline with the control. In that case `actions` are shown below the control.
* @param {ColorPaletteLayout} [props.layout='tiles'] - Determines the layout of the control.
- * @param {boolean} [props.searchable=false] - If `true`, the list of color can be searched through.
- * @param {boolean} [props.disabled] - If `true`, the component can't be interacted with.
- * @param {boolean} [props.noShadeGrouping=false] - If `false`, color swatches will be grouped if there are 2 or more colors with the same beginning of the name, but different ending (-50, -100, ..., -900 or -10, -20, ..., -90).
- * @param {React.Component?} [props.subtitle] - Subtitle below the label.
- * @param {React.Component?} [props.actions] - Actions to show to the right of the label.
+ * @param {boolean} [props.searchable=false] - If `true`, the list of color can be searched through.
+ * @param {boolean} [props.disabled] - If `true`, the component can't be interacted with.
+ * @param {boolean} [props.noShadeGrouping=false] - If `false`, color swatches will be grouped if there are 2 or more colors with the same beginning of the name, but different ending (-50, -100, ..., -900 or -10, -20, ..., -90).
+ * @param {React.Component?} [props.subtitle] - Subtitle below the label.
+ * @param {React.Component?} [props.actions] - Actions to show to the right of the label.
*/
export const ColorPalette = (props) => {
const {
@@ -40,216 +36,24 @@ export const ColorPalette = (props) => {
label,
help,
icon,
- reducedBottomSpacing,
- noBottomSpacing,
- inlineLabel,
- layout = 'tiles',
- searchable = false,
disabled,
noShadeGrouping = false,
subtitle,
- actions,
} = props;
- const colorSuffixRegex = /(?!^.+)(-?(?:50|100|200|300|400|500|600|700|800|900|10|20|30|40|50|60|70|80|90){1})$/gi;
-
- let groupedColors = { generic: colors };
-
- if (!noShadeGrouping) {
- groupedColors = colors.reduce((output, current) => {
- // Bailout if a color is invalid.
- if (current === undefined || current?.name === undefined || current?.slug === undefined) {
- return output;
- }
-
- if (current.slug.match(colorSuffixRegex)?.length) {
- const newSlug = current.name.replace(colorSuffixRegex, '').trim();
-
- if (!output[newSlug]) {
- output[newSlug] = [];
- }
-
- output[newSlug] = [
- ...output[newSlug],
- {
- ...current,
- shade: current.slug.match(colorSuffixRegex)[0].replace('-', ''),
- },
- ];
- } else {
- output.generic = [
- ...output.generic,
- current,
- ];
- }
-
- return output;
- }, { generic: [] });
-
- // Don't show color groups if only one color would end up in the group.
- for (let [colorName, colors] of Object.entries(groupedColors)) {
- if (colors.length === 1 && colorName !== 'generic') {
- groupedColors.generic.push(colors[0]);
-
- delete groupedColors[colorName];
- }
- }
- }
-
- const [filteredColors, setFilteredColors] = useState(groupedColors);
- const [searchTerm, setSearchTerm] = useState('');
-
- const detailView = layout === 'list' || layout === 'listTwoCol';
-
- const searchEmptyIcon = React.cloneElement(icons.searchEmpty, { className: 'es-w-8 es-h-8 es-has-wp-admin-theme-color' });
-
- let layoutClasses = 'es-h-spaced-wrap es-gap-0!';
-
- if (layout === 'list') {
- layoutClasses = 'es-v-spaced es-gap-0!';
- }
-
- if (layout === 'listTwoCol') {
- layoutClasses = 'es-fifty-fifty-h-wrap es-gap-0!';
- }
-
return (
-
- {searchable &&
- {
- setSearchTerm(v);
-
- if (v.trim().length === 0) {
- setFilteredColors(groupedColors);
- return;
- }
-
- const filtered = Object.entries(groupedColors).reduce((output, [groupName, groupColors]) => {
- const filteredColors = groupColors.filter(({ name }) => name.trim().toLowerCase().includes(v.toLowerCase()));
-
- if (filteredColors.length > 0) {
- output[groupName] = filteredColors;
- }
-
- return output;
- }, {});
-
- setFilteredColors(filtered);
- }}
- />
- }
-
- {Object.values(filteredColors).every((colors) => colors.length < 1) && searchTerm?.length > 0 &&
-
- );
- };
-};
-
-export const getMultiValueRemove = (ComponentToRender) => {
- return (props) => (
- e.stopPropagation(),
- ...props.innerProps,
- }}
- />
- );
-};
diff --git a/scripts/components/custom-select/multi-select.js b/scripts/components/custom-select/multi-select.js
index 44741891b..ac508f309 100644
--- a/scripts/components/custom-select/multi-select.js
+++ b/scripts/components/custom-select/multi-select.js
@@ -1,48 +1,35 @@
import React from 'react';
-import Select, { components } from 'react-select';
-import { DndContext } from '@dnd-kit/core';
-import { restrictToParentElement } from '@dnd-kit/modifiers';
-import { SortableContext } from '@dnd-kit/sortable';
-import { defaultEightshiftColorScheme, defaultEightshiftStyles } from './custom-select-style';
-import {
- CustomSelectDefaultClearIndicator,
- CustomSelectDefaultDropdownIndicator,
- CustomSelectDefaultMultiValueRemove,
-} from './custom-select-default-components';
-import { getDragEndHandler, getMultiValue, getMultiValueContainer, getMultiValueRemove } from './multi-select-components';
-import { customOnChange, getValue } from './shared';
-import { Control } from '../base-control/base-control';
+import { MultiSelect as EsUicMultiSelect } from '@eightshift/ui-components';
/**
* Multi-select, re-orderable select menu.
*
- * @param {object} props - MultiSelect options.
- * @param {string?} [props.label] - Label displayed above the control.
- * @param {string?} [props.help] - Help text displayed below the control.
- * @param {React.Component?} [props.icon] - Icon to show next to the label
- * @param {React.Component?} [props.subtitle] - Subtitle below the label.
- * @param {React.Component?} [props.actions] - Actions to show to the right of the label.
- * @param {boolean?} [props.inlineLabel] - If `true`, the label is displayed inline with the control. In that case `actions` are shown below the control.
- * @param {array<{string, string}>?} props.options - Options to choose from. Option should be in `{label: '', value: ''}` format.
- * @param {object} props.value - Current value
- * @param {function} props.onChange - Function called when the selection is changed.
- * @param {boolean} [props.simpleValue=false] - If `true`, instead of passing (and getting) a `{label: '', value: ''}` object from the component, only the value is returned.
- * @param {boolean} [props.clearable=false] - If `true`, a button to remove all items is shown.
- * @param {boolean} [props.noSearch=false] - If `true`, the search functionality is disabled.
- * @param {boolean} [props.disabled=false] - If set `true`, the component is disabled.
- * @param {boolean} [props.keepMenuOpenAfterSelect=false] - If set `true`, the dropdown is not closed immediately after selecting an option.
- * @param {string?} [props.placeholder] - Placeholder text when nothing is selected.
+ * @deprecated Use `MultiSelect` from `@eightshift/ui-components` instead.
+ *
+ * @param {object} props - MultiSelect options.
+ * @param {string?} [props.label] - Label displayed above the control.
+ * @param {string?} [props.help] - Help text displayed below the control.
+ * @param {React.Component?} [props.icon] - Icon to show next to the label
+ * @param {React.Component?} [props.subtitle] - Subtitle below the label.
+ * @param {React.Component?} [props.actions] - Actions to show to the right of the label.
+ * @param {boolean?} [props.inlineLabel] - If `true`, the label is displayed inline with the control. In that case `actions` are shown below the control.
+ * @param {array<{string, string}>?} props.options - Options to choose from. Option should be in `{label: '', value: ''}` format.
+ * @param {object} props.value - Current value
+ * @param {function} props.onChange - Function called when the selection is changed.
+ * @param {boolean} [props.simpleValue=false] - If `true`, instead of passing (and getting) a `{label: '', value: ''}` object from the component, only the value is returned.
+ * @param {boolean} [props.clearable=false] - If `true`, a button to remove all items is shown.
+ * @param {boolean} [props.noSearch=false] - If `true`, the search functionality is disabled.
+ * @param {boolean} [props.disabled=false] - If set `true`, the component is disabled.
+ * @param {boolean} [props.keepMenuOpenAfterSelect=false] - If set `true`, the dropdown is not closed immediately after selecting an option.
+ * @param {string?} [props.placeholder] - Placeholder text when nothing is selected.
* @param {React.Component?} [props.customDropdownIndicator] - If provided, replaces the default dropdown arrow indicator.
- * @param {React.Component?} [props.customClearIndicator] - If provided and `noClear` is `false`, replaces the default 'Clear all' button.
- * @param {React.Component?} [props.customMenuOption] - If provided, replaces the default item in the dropdown menu (react-select's `components.Option`).
- * @param {React.Component?} [props.customValueDisplay] - If provided, replaces the default current value display of each selected item (react-select's `components.MultiValue`).
- * @param {React.Component?} [props.customValueContainer] - If provided, replaces the default items container component (react-select's `components.MultiValueContainer`).
- * @param {React.Component?} [props.customValueRemove] - If provided, replaces the default item remove button (react-select's `components.MultiValueRemove`.
- * @param {boolean} [props.noBottomSpacing] - If `true`, the default bottom spacing is removed.
- * @param {boolean?} [props.reducedBottomSpacing] - If `true`, space below the control is reduced.
- * @param {string?} [props.additionalClasses=''] - If provided, the classes are added to the component container.
- * @param {string?} [props.additionalSelectClasses=''] - If provided, the classes are added to the Select element itself.
- * @param {object?} [props.additionalProps={}] - If provided, the provided props will be passed to the Select control.
+ * @param {React.Component?} [props.customClearIndicator] - If provided and `noClear` is `false`, replaces the default 'Clear all' button.
+ * @param {React.Component?} [props.customMenuOption] - If provided, replaces the default item in the dropdown menu (react-select's `components.Option`).
+ * @param {React.Component?} [props.customValueDisplay] - If provided, replaces the default current value display of each selected item (react-select's `components.MultiValue`).
+ * @param {React.Component?} [props.customValueContainer] - If provided, replaces the default items container component (react-select's `components.MultiValueContainer`).
+ * @param {React.Component?} [props.customValueRemove] - If provided, replaces the default item remove button (react-select's `components.MultiValueRemove`.
+ * @param {string?} [props.additionalSelectClasses=''] - If provided, the classes are added to the Select element itself.
+ * @param {object?} [props.additionalProps={}] - If provided, the provided props will be passed to the Select control.
*/
export const MultiSelect = (props) => {
const {
@@ -77,58 +64,35 @@ export const MultiSelect = (props) => {
customValueRemove,
customValueContainer,
- noBottomSpacing,
- reducedBottomSpacing,
-
- additionalClasses,
additionalSelectClasses,
additionalProps,
} = props;
return (
-
-
- id)}>
-
-
-
+ inline={inlineLabel}
+ options={options}
+ value={value}
+ simpleValue={simpleValue}
+ onChange={onChange}
+ clearable={clearable}
+ noSearch={noSearch}
+ disabled={disabled}
+ keepMenuOpenAfterSelect={keepMenuOpenAfterSelect}
+ placeholder={placeholder}
+ customClearIndicator={customClearIndicator}
+ customDropdownArrow={customDropdownArrow}
+ customMenuOption={customMenuOption}
+ customValueDisplay={customValueDisplay}
+ customValueRemove={customValueRemove}
+ customValueContainer={customValueContainer}
+ className={additionalSelectClasses}
+ {...additionalProps}
+ />
);
};
diff --git a/scripts/components/custom-select/react-select-component-wrappers.js b/scripts/components/custom-select/react-select-component-wrappers.js
deleted file mode 100644
index ab2775e34..000000000
--- a/scripts/components/custom-select/react-select-component-wrappers.js
+++ /dev/null
@@ -1,94 +0,0 @@
-import React from 'react';
-import { components } from 'react-select';
-
-/**
- * Wrappers for react-select components if you are having trouble importing directly from react-select.
-*/
-
-/**
- * Custom dropdown indicator for CustomSelect.
- *
- * (a wrapper for `components.DropdownIndicator` from `react-select`)
- *
- * @param {object} props - components.DropdownIndicator props.
-*/
-export const RSDropdownIndicator = (props) => (
-
-);
-
-/**
- * Custom value display for CustomSelect.
- *
- * (a wrapper for `components.SingleValue` from `react-select`)
- *
- * @param {object} props - components.SingleValue props.
-*/
-export const RSSingleValue = (props) => (
-
-);
-
-/**
- * Custom value display for multi item select.
- *
- * (a wrapper for `components.MultiValue` from `react-select`)
- *
- * @param {object} props - components.SingleValue props.
-*/
-export const RSMultiValue = (props) => (
-
-);
-
-/**
- * Custom option for CustomSelect.
- *
- * (a wrapper for `components.Option` from `react-select`)
- *
- * @param {object} props - components.Option props.
-*/
-export const RSOption = (props) => (
-
-);
-
-
-/**
- * Custom multiple value remove button for CustomSelect.
- *
- * (a wrapper for `components.MultiValueRemove` from `react-select`)
- *
- * @param {object} props - components.MultiValueRemove props.
-*/
-export const RSMultiValueRemove = (props) => (
-
-);
-
-
-/**
- * Custom multiple value display container for CustomSelect.
- *
- * (a wrapper for `components.MultiValueContainer` from `react-select`)
- *
- * @param {object} props - components.MultiValueContainer props.
-*/
-export const RSMultiValueContainer = (props) => (
-
-);
-
-/**
- * Custom multiple value display for CustomSelect.
- *
- * (a wrapper for `components.MultiValueLabel` from `react-select`)
- *
- * @param {object} props - components.MultiValueLabel props.
-*/
-export const RSMultiValueLabel = (props) => (
-
-);
-
-/**
- * Default clear indicator for CustomSelect.
- *
- * @param {object} props - components.ClearIndicator props.
-*/
-export const RSClearIndicator = (props) => (
-
-);
diff --git a/scripts/components/custom-select/shared.js b/scripts/components/custom-select/shared.js
deleted file mode 100644
index b1e728187..000000000
--- a/scripts/components/custom-select/shared.js
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Utils for `simpleValue`-capable components.
-*/
-
-/**
- * Handles getting the current value.
- *
- * @param {boolean} simpleValue If `simpleValue` is selected.
- * @param {any} value Current value.
- * @param {array} options Options passed to the component.
- *
- * @returns Appropriate output for the given input combination.
- */
-export const getValue = (simpleValue, value, options) => {
- if (!simpleValue) {
- return value;
- }
-
- if (Array.isArray(value)) {
- return value.map((value) => options?.find(({value: itemValue}) => itemValue === value));
- }
-
- return options?.find(({value: itemValue}) => itemValue === value);
-};
-
-/**
- * Handles the `onChange` callback.
- *
- * @param {*} simpleValue If `simpleValue` is selected.
- * @param {*} newValue The new value to be set.
- * @param {callback} onChange The `onChange` callback passed to the component.
- * @returns
- */
-export const customOnChange = (simpleValue, newValue, onChange) => {
- if (!simpleValue) {
- onChange(newValue);
- return;
- }
-
- if (Array.isArray(newValue)) {
- onChange(newValue.map((item) => item?.value));
- return;
- }
-
- onChange(newValue?.value);
-};
diff --git a/scripts/components/custom-select/single-select.js b/scripts/components/custom-select/single-select.js
index e6ad8b36c..0408bfcba 100644
--- a/scripts/components/custom-select/single-select.js
+++ b/scripts/components/custom-select/single-select.js
@@ -1,38 +1,33 @@
import React from 'react';
-import RSSelect, { components } from 'react-select';
-import { defaultEightshiftColorScheme, defaultEightshiftStyles } from './custom-select-style';
-import { CustomSelectDefaultClearIndicator, CustomSelectDefaultDropdownIndicator } from './custom-select-default-components';
-import { customOnChange, getValue } from './shared';
-import { Control } from '../base-control/base-control';
+import { Select as EsUicSelect } from '@eightshift/ui-components';
/**
* A simple, customizable select menu.
*
- * @param {object} props - Select options.
- * @param {string?} [props.label] - Label displayed above the control.
- * @param {string?} [props.help] - Help text displayed below the control.
- * @param {React.Component?} [props.icon] - Icon to show next to the label
- * @param {React.Component?} [props.subtitle] - Subtitle below the label.
- * @param {React.Component?} [props.actions] - Actions to show to the right of the label.
- * @param {boolean?} [props.inlineLabel] - If `true`, the label is displayed inline with the control. In that case `actions` are shown below the control.
- * @param {array<{string, string}>?} props.options - Options to choose from. Option should be in `{label: '', value: ''}` format.
- * @param {object} props.value - Current value
- * @param {boolean} [props.simpleValue=false] - If `true`, instead of passing (and getting) a `{label: '', value: ''}` object from the component, only the value is returned.
- * @param {function} props.onChange - Function called when the selection is changed.
- * @param {boolean} [props.clearable=false] - If `true`, a button to remove the value is shown.
- * @param {boolean} [props.noSearch=false] - If `true`, the search functionality is disabled.
- * @param {boolean} [props.disabled=false] - If set `true`, the component is disabled.
- * @param {boolean} [props.closeMenuAfterSelect=false] - If set `true`, the dropdown is closed immediately after selecting an option.
- * @param {string?} [props.placeholder] - Placeholder text when nothing is selected.
+ * @deprecated Use `Select` from `@eightshift/ui-components` instead.
+ *
+ * @param {object} props - Select options.
+ * @param {string?} [props.label] - Label displayed above the control.
+ * @param {string?} [props.help] - Help text displayed below the control.
+ * @param {React.Component?} [props.icon] - Icon to show next to the label
+ * @param {React.Component?} [props.subtitle] - Subtitle below the label.
+ * @param {React.Component?} [props.actions] - Actions to show to the right of the label.
+ * @param {boolean?} [props.inlineLabel] - If `true`, the label is displayed inline with the control. In that case `actions` are shown below the control.
+ * @param {array<{string, string}>?} props.options - Options to choose from. Option should be in `{label: '', value: ''}` format.
+ * @param {object} props.value - Current value
+ * @param {boolean} [props.simpleValue=false] - If `true`, instead of passing (and getting) a `{label: '', value: ''}` object from the component, only the value is returned.
+ * @param {function} props.onChange - Function called when the selection is changed.
+ * @param {boolean} [props.clearable=false] - If `true`, a button to remove the value is shown.
+ * @param {boolean} [props.noSearch=false] - If `true`, the search functionality is disabled.
+ * @param {boolean} [props.disabled=false] - If set `true`, the component is disabled.
+ * @param {boolean} [props.closeMenuAfterSelect=false] - If set `true`, the dropdown is closed immediately after selecting an option.
+ * @param {string?} [props.placeholder] - Placeholder text when nothing is selected.
* @param {React.Component?} [props.customDropdownIndicator] - If provided, replaces the default dropdown arrow indicator.
- * @param {React.Component?} [props.customClearIndicator] - If provided and `noClear` is `false`, replaces the default 'Clear all' button.
- * @param {React.Component?} [props.customMenuOption] - If provided, replaces the default item in the dropdown menu (react-select's `components.Option`).
- * @param {React.Component?} [props.customValueDisplay] - If provided, replaces the default current value display of each selected item (react-select's `components.SingleValue`).
- * @param {boolean} [props.noBottomSpacing] - If `true`, the default bottom spacing is removed.
- * @param {boolean?} [props.reducedBottomSpacing] - If `true`, space below the control is reduced.
- * @param {string?} [props.additionalClasses=''] - If provided, the classes are added to the component container.
- * @param {string?} [props.additionalSelectClasses=''] - If provided, the classes are added to the Select element itself.
- * @param {object?} [props.additionalProps={}] - If provided, the provided props will be passed to the Select control.
+ * @param {React.Component?} [props.customClearIndicator] - If provided and `noClear` is `false`, replaces the default 'Clear all' button.
+ * @param {React.Component?} [props.customMenuOption] - If provided, replaces the default item in the dropdown menu (react-select's `components.Option`).
+ * @param {React.Component?} [props.customValueDisplay] - If provided, replaces the default current value display of each selected item (react-select's `components.SingleValue`).
+ * @param {string?} [props.additionalSelectClasses=''] - If provided, the classes are added to the Select element itself.
+ * @param {object?} [props.additionalProps={}] - If provided, the provided props will be passed to the Select control.
*/
export const Select = (props) => {
const {
@@ -64,49 +59,33 @@ export const Select = (props) => {
customMenuOption,
customValueDisplay,
- noBottomSpacing,
- reducedBottomSpacing,
-
- additionalClasses,
additionalSelectClasses,
additionalProps,
} = props;
return (
-
- customOnChange(simpleValue, v, onChange)}
- closeMenuOnSelect={closeMenuAfterSelect}
- isClearable={clearable}
- isSearchable={!noSearch}
- isDisabled={disabled}
- className={additionalSelectClasses}
- placeholder={placeholder}
- theme={defaultEightshiftColorScheme}
- styles={defaultEightshiftStyles}
- components={{
- Option: customMenuOption ?? components.Option,
- SingleValue: customValueDisplay ?? components.SingleValue,
- IndicatorSeparator: null,
- DropdownIndicator: customDropdownArrow ?? CustomSelectDefaultDropdownIndicator,
- ClearIndicator: customClearIndicator ?? CustomSelectDefaultClearIndicator,
- }}
- menuPortalTarget={document.body}
- menuPosition='fixed'
- {...additionalProps}
- />
-
+ inline={inlineLabel}
+ options={options}
+ value={value}
+ simpleValue={simpleValue}
+ onChange={onChange}
+ clearable={clearable}
+ noSearch={noSearch}
+ disabled={disabled}
+ keepMenuOpenAfterSelect={!closeMenuAfterSelect}
+ placeholder={placeholder}
+ customClearIndicator={customClearIndicator}
+ customDropdownArrow={customDropdownArrow}
+ customMenuOption={customMenuOption}
+ customValueDisplay={customValueDisplay}
+ className={additionalSelectClasses}
+ {...additionalProps}
+ />
);
};
diff --git a/scripts/components/custom-slider/column-config-slider.js b/scripts/components/custom-slider/column-config-slider.js
index 37052a63e..ad059302e 100644
--- a/scripts/components/custom-slider/column-config-slider.js
+++ b/scripts/components/custom-slider/column-config-slider.js
@@ -1,10 +1,9 @@
-import React, { useRef, useLayoutEffect, useState } from 'react';
-import { Control } from '../base-control/base-control';
-import { renderColumnConfigSliderHandle } from './tooltip-handle';
-import { clamp, columnConfigStyleProps } from './shared';
-import Slider from 'rc-slider';
+import React from 'react';
+import { ColumnConfigSlider as EsUicColumnConfigSlider } from '@eightshift/ui-components';
/**
+ * @deprecated Use `ColumnConfigSlider` from `@eightshift/ui-components` instead.
+ *
* A custom range slider for configuring column width & offset.
*
* @param {object} props - ColumnConfigSlider options.
@@ -16,15 +15,11 @@ import Slider from 'rc-slider';
* @param {React.Component?} [props.label] - Label to show above component.
* @param {React.Component?} [props.subtitle] - Subtitle below the label.
* @param {React.Component[]?} [props.actions] - Actions to show to the right of the label.
- * @param {boolean?} [props.noBottomSpacing] - If `true`, space below the control is removed.
- * @param {boolean?} [props.reducedBottomSpacing] - If `true`, space below the control is reduced.
* @param {boolean} [props.disabled=false] - If `true`, the component is disabled.
* @param {boolean} [props.noWidthHandle=false] - If `true`, the width handle is not shown.
* @param {boolean} [props.noOffsetHandle=false] - If `true`, the offset handle is not shown.
- * @param {string?} [props.additionalClass] - If passed, the classes are appended to the slider.
* @param {React.Component} [props.additionalControlsAbove] - If passed, the controls are shown above the slider.
* @param {React.Component} [props.additionalControlsBelow] - If passed, the controls are shown below the slider.
- * @param {function} [props.onBeforeChange] - Function to trigger when the value of the slider starts changing.
* @param {function} [props.onAfterChange] - Function to trigger when the value of the slider is changed.
*/
export const ColumnConfigSlider = (props) => {
@@ -41,156 +36,37 @@ export const ColumnConfigSlider = (props) => {
label,
actions,
subtitle,
- noBottomSpacing,
- reducedBottomSpacing,
// Behavior
disabled,
noWidthHandle = false,
noOffsetHandle = false,
- // Classes
- additionalClass,
-
// Additions.
additionalControlsAbove,
additionalControlsBelow,
- onBeforeChange,
onAfterChange,
} = props;
- const max = numOfColumns + 1;
-
- // Custom focus state capture to ensure proper focus visuals on the handle.
- const [hasFocus, setHasFocus] = useState(false);
-
- // Re-calculate height to take markers and other possible customizations into account (to prevent overlaps with other content).
- // The
-
+ <>
+ {additionalControlsAbove}
+
+ {additionalControlsBelow}
+ >
);
};
diff --git a/scripts/components/custom-slider/custom-range-slider.js b/scripts/components/custom-slider/custom-range-slider.js
index 0f4a36f08..5efa7e178 100644
--- a/scripts/components/custom-slider/custom-range-slider.js
+++ b/scripts/components/custom-slider/custom-range-slider.js
@@ -1,26 +1,17 @@
-import React, { useRef, useLayoutEffect, useState } from 'react';
-import { __ } from '@wordpress/i18n';
-import { Button } from '@wordpress/components';
-import { Control } from '../base-control/base-control';
-import { renderHandle } from './tooltip-handle';
-import { generateMarkers, styleProps } from './shared';
-import { icons } from '@eightshift/ui-components/icons';
-import { AnimatedContentVisibility } from '../animated-content-visibility/animated-content-visibility';
-import Slider from 'rc-slider';
-import { NumberPicker } from '../number-picker/number-picker';
-import { clsx } from '@eightshift/ui-components/utilities';
+import React from 'react';
+import { Slider as EsUicSlider } from '@eightshift/ui-components';
/**
* A modern and customizable custom range slider.
*
+ * @deprecated Use `Slider` from `@eightshift/ui-components` instead.
+ *
* @typedef {null | 'dots' | true | {Number: string} | {Number: {style, label}}} DotStyle
- * @typedef {'top'|'bottom'|'hidden'} TooltipPosition
*
* @param {object} props - RangeSlider options.
* @param {Number} [props.min] - Minimum value of the slider.
* @param {Number} [props.max] - Maximum value of the slider.
* @param {Number|null} [props.step=1] - Value between slider steps. Must be greater than zero, `max` - `min` should be evenly divisible by the step value. If `marks` are set, you can set `step` to `null` to use `marks` as only steps.
- * @param {boolean} [props.discrete=false] - If `true`, the value interval is discrete (independent value), otherwise it's continuous.
* @param {Number[]} [props.value] - Current value of the slider.
* @param {function} [props.onChange] - Function to trigger when the value of the slider is changing.
* @param {React.Component?} [props.icon] - Icon to show next to the label
@@ -28,15 +19,11 @@ import { clsx } from '@eightshift/ui-components/utilities';
* @param {React.Component?} [props.label] - Label to show above component.
* @param {React.Component[]?} [props.actions] - Actions to show to the right of the label.
* @param {React.Component?} [props.subtitle] - Subtitle below the label.
- * @param {boolean?} [props.noBottomSpacing] - If `true`, space below the control is removed.
- * @param {boolean?} [props.reducedBottomSpacing] - If `true`, space below the control is reduced.
- * @param {boolean} [props.reverse=false] - If `true`, the slider is displayed in reverse.
* @param {boolean} [props.disabled=false] - If `true`, the component is disabled.
* @param {DotStyle} [props.marks=null] - Marks on the slider. Key represents the value of the slider, value determines what is shown. You can also use an object {label, value} for the displayed value to customize certain marks. Won't have any effect if `dots` are enabled.
* @param {boolean|number} [props.pushable=false] - If `true`, the handles can push surrounding handles. If set to a number, the number defines the minimum distance between handles.
* @param {boolean} [props.noCross=false] - If `true`, the handles of the ranges are not allowed to cross.
* @param {boolean} [props.draggableTrack=false] - If `true`, the track can be dragged to move all of the values together.
- * @param {function} [props.onBeforeChange] - Function to trigger when the value of the slider starts changing.
* @param {function} [props.onAfterChange] - Function to trigger when the value of the slider is changed.
* @param {string} [props.railColor] - Custom rail color. Should be a valid value of the CSS `background` property.
* @param {string} [props.trackColor] - Custom track color. Should be a valid value of the CSS `background` property.
@@ -60,7 +47,6 @@ export const RangeSlider = (props) => {
min,
max,
step = 1,
- discrete = false,
value,
onChange,
@@ -71,211 +57,38 @@ export const RangeSlider = (props) => {
label,
actions,
subtitle,
- noBottomSpacing,
- reducedBottomSpacing,
// Behavior
- reverse,
disabled,
marks = null,
- pushable = false,
- noCross = false,
- draggableTrack = false,
-
- onBeforeChange,
onAfterChange,
- // Visual customization.
- handleColor,
-
- // Classes
- additionalClass,
- additionalSliderClass,
-
- // Tooltip
- noTooltip = false,
- tooltipPlacement = 'top',
- tooltipFormat = (value) => value,
-
// Additions.
leftAddition,
rightAddition,
inputField = false,
- valueDisplay = false,
- // eslint-disable-next-line max-len
- valueDisplayElement = ((v) => {v}),
} = props;
- const [inputFieldsVisible, setInputFieldsVisible] = useState(false);
-
- // Custom focus state capture to ensure proper focus visuals on the handle.
- const [hasFocus, setHasFocus] = useState(false);
-
- // Re-calculate height to take markers and other possible customizations into account (to prevent overlaps with other content).
- // The
-
- {inputField &&
-
- {value.map((v, i) => (
- {
- let currentValue = [...value];
- currentValue[i] = v;
-
- onChange(currentValue);
- }}
- disabled={disabled}
- fixedWidth={`${max}`.length}
- noBottomSpacing
- />
- ))}
-
- }
-
+ disabled={disabled}
+ markers={marks}
+ onChangeEnd={onAfterChange}
+ inputField={inputField}
+ before={leftAddition}
+ after={rightAddition}
+ />
);
};
diff --git a/scripts/components/custom-slider/custom-slider.js b/scripts/components/custom-slider/custom-slider.js
index 65721f49e..a33668238 100644
--- a/scripts/components/custom-slider/custom-slider.js
+++ b/scripts/components/custom-slider/custom-slider.js
@@ -1,23 +1,18 @@
-import React, { useRef, useLayoutEffect, useState } from 'react';
-import { Control } from '../base-control/base-control';
-import { renderHandle } from './tooltip-handle';
-import { generateMarkers, styleProps } from './shared';
-import { NumberPicker } from '../number-picker/number-picker';
-import RcSlider from 'rc-slider';
-import { clsx } from '@eightshift/ui-components/utilities';
+import React from 'react';
+import { Slider as EsUicSlider } from '@eightshift/ui-components';
/**
* A modern and customizable custom slider.
*
+ * @deprecated Use `Slider` from `@eightshift/ui-components` instead.
+ *
* @typedef {null | 'dots' | true | {Number: string} | {Number: {style, label}}} DotStyle
- * @typedef {'top'|'bottom'|'hidden'} TooltipPosition
*
* @param {object} props - Slider options.
* @param {Number} [props.min=0] - Minimum value of the slider.
* @param {Number} props.max - Maximum value of the slider.
* @param {Number|null} [props.step=1] - Value between slider steps. Must be greater than zero, `max` - `min` should be evenly divisible by the step value. If `marks` are set, you can set `step` to `null` to use `marks` as only steps.
* @param {Number} [props.startPoint=undefined] - Determines starting point of the slider track. If `undefined`, value of `min` is used.
- * @param {boolean} [props.discrete=false] - If `true`, the value interval is discrete (independent value), otherwise it's continuous.
* @param {Number} [props.value] - Current value of the slider.
* @param {function} [props.onChange] - Function to trigger when the value of the slider is changing.
* @param {React.Component?} [props.icon] - Icon to show next to the label
@@ -25,8 +20,6 @@ import { clsx } from '@eightshift/ui-components/utilities';
* @param {React.Component?} [props.label] - Label to show above component.
* @param {React.Component[]?} [props.actions] - Actions to show to the right of the label.
* @param {React.Component?} [props.subtitle] - Subtitle below the label.
- * @param {boolean?} [props.noBottomSpacing] - If `true`, space below the control is removed.
- * @param {boolean?} [props.reducedBottomSpacing] - If `true`, space below the control is reduced.
* @param {boolean} [props.reverse=false] - If `true`, the slider is displayed in reverse.
* @param {boolean} [props.disabled=false] - If `true`, the component is disabled.
* @param {DotStyle} [props.marks=null] - Marks on the slider. Key represents the value of the slider, value determines what is shown. You can also use an object {label, value} for the displayed value to customize certain marks. Won't have any effect if `dots` are enabled.
@@ -36,17 +29,9 @@ import { clsx } from '@eightshift/ui-components/utilities';
* @param {string} [props.trackColor] - Custom track color. Should be a valid value of the CSS `background` property.
* @param {string} [props.activeMarkColor] - Custom active mark color. Should be a valid value of the CSS `background` property.
* @param {string} [props.inactiveMarkColor] - Custom inactive mark color. Should be a valid value of the CSS `background` property.
- * @param {string} [props.handleColor] - Custom slider handle color. Should be a valid value of the CSS `background` property.
- * @param {string?} [props.additionalClass] - If passed, the classes are appended to the base control.
- * @param {string?} [props.additionalSliderClass] - If passed, the classes are appended to the slider.
- * @param {boolean} [props.noTooltip=false] - If `true`, the tooltips are not shown when changing value.
- * @param {TooltipPosition} [props.tooltipPlacement='top'] - Defines where the tooltip is placed. If set to `hidden` no tooltip is shown.
- * @param {string} [props.tooltipFormat=(value)=>value] - Defines how the tooltips are formatted. Should be in format `(value) => string` or `(value, isDragging) => string`.
* @param {React.Component} [props.leftAddition] - Component to display on the left of the slider.
* @param {React.Component} [props.rightAddition] - Component to display on the right of the slider.
* @param {boolean} [props.inputField=false] - If `true`, an input field is shown next to the slider. Can't be used with `valueDisplay`.
- * @param {boolean} [props.valueDisplay=false] - If `true`, the current value is shown next to the slider. Can't be used with `hasInputField`.
- * @param {React.Component} [props.valueDisplayElement] - If set and `valueDisplay` is enabled, sets the value display element that is used.
*/
export const Slider = (props) => {
const {
@@ -55,7 +40,6 @@ export const Slider = (props) => {
max,
step = 1,
startPoint,
- discrete = false,
value,
onChange,
@@ -66,170 +50,38 @@ export const Slider = (props) => {
label,
actions,
subtitle,
- noBottomSpacing,
- reducedBottomSpacing,
// Behavior
- reverse,
disabled,
marks = null,
- onBeforeChange,
onAfterChange,
- // Visual customization.
- handleColor,
-
- // Classes
- additionalClass,
- additionalSliderClass,
-
- // Tooltip
- noTooltip = false,
- tooltipPlacement = 'top',
- tooltipFormat = (value) => value,
-
// Additions.
leftAddition,
rightAddition,
inputField = false,
-
- valueDisplay = false,
- // eslint-disable-next-line max-len
- valueDisplayElement = ({value}),
} = props;
- // Custom focus state capture to ensure proper focus visuals on the handle.
- const [hasFocus, setHasFocus] = useState(false);
-
- // Re-calculate height to take markers and other possible customizations into account (to prevent overlaps with other content).
- // The
- }
-
- }
+ )}
>
);
};
diff --git a/scripts/components/matrix-align-control/matrix-align-control.js b/scripts/components/matrix-align-control/matrix-align-control.js
index 934e01697..45030005c 100644
--- a/scripts/components/matrix-align-control/matrix-align-control.js
+++ b/scripts/components/matrix-align-control/matrix-align-control.js
@@ -1,165 +1,46 @@
-import React, { useState } from 'react';
-import { __ } from '@wordpress/i18n';
-import { Button } from '@wordpress/components';
-import { Control, OptionSelector, PopoverWithTrigger, TileButton } from '../../../scripts';
-import { icons } from '@eightshift/ui-components/icons';
-import { camelCase, upperFirst } from '@eightshift/ui-components/utilities';
+import React from 'react';
+import { MatrixAlign } from '@eightshift/ui-components';
/**
+ * @deprecated Use `MatrixAlign` from `@eightshift/ui-components` instead.
+ *
* A component that can provide a 3x3 or a 2x2 grid of positions to pick from.
* Replaces the default Gutenberg `AlignmentMatrixControl`/`BlockAlignmentMatrixControl`/`BlockAlignmentMatrixToolbar`.
*
- * @typedef {'wp'|'tileButton'|'inline'} MatrixAlignControlType
* @typedef {'top' | 'top left' | 'top right' | 'middle' | 'middle left' | 'middle right' | 'bottom' | 'bottom left' | 'bottom right'} AppearOrigin
*
* @param {object} props - MatrixAlignControl options.
- * @param {MatrixAlignControlType} [props.type='wp'] - Style of the option trigger. `wp` replicates the default Gutenberg control, `tileButton` shows a regular button that fits with a `tileButton` IconToggle well.
* @param {'3x3'|'2x2'} [props.size='3x3'] - Defines the matrix size to show. Can be either `3x3` or `2x2`.
* @param {React.Component?} [props.label] - Label displayed on the trigger button. (tooltip when style is `wp`, text label below icon when style is `tileButton`)
* @param {string} props.value - Current value.
* @param {function} [props.onChange] - Function that is called on every value change.
- * @param {string?} [props.additionalTriggerClasses] - If provided, the classes are appended to the trigger button.
* @param {React.Component?} [props.icon] - Icon to show next to the label
* @param {React.Component?} [props.subtitle] - Subtitle below the label.
- * @param {boolean?} [props.noBottomSpacing] - If `true`, space below the control is removed.
- * @param {boolean?} [props.reducedBottomSpacing] - If `true`, space below the control is reduced.
* @param {AppearOrigin} [props.popoverPosition='top center'] - Position where the popover appears.
*/
export const MatrixAlignControl = (props) => {
const {
- type = 'wp',
size = '3x3',
label = __('Position', 'eightshift-frontend-libs'),
value,
onChange,
- additionalTriggerClasses,
icon,
subtitle,
- noBottomSpacing,
- reducedBottomSpacing,
popoverPosition,
} = props;
- const [currentValue, setCurrentValue] = useState(value);
-
- const allSizeOptions = [
- {
- value: 'top left',
- label: __('Top-left', 'eightshift-frontend-libs'),
- availableOn: ['3x3', '2x2']
- },
- {
- value: 'top center',
- label: __('Top-center', 'eightshift-frontend-libs'),
- availableOn: ['3x3']
- },
- {
- value: 'top right',
- label: __('Top-right', 'eightshift-frontend-libs'),
- availableOn: ['3x3', '2x2']
- },
- {
- value: 'center left',
- label: __('Center-left', 'eightshift-frontend-libs'),
- availableOn: ['3x3']
- },
- {
- value: 'center center',
- label: __('Center', 'eightshift-frontend-libs'),
- availableOn: ['3x3']
- },
- {
- value: 'center right',
- label: __('Center-right', 'eightshift-frontend-libs'),
- availableOn: ['3x3']
- },
- {
- value: 'bottom left',
- label: __('Bottom-left', 'eightshift-frontend-libs'),
- availableOn: ['3x3', '2x2']
- },
- {
- value: 'bottom center',
- label: __('Bottom-center', 'eightshift-frontend-libs'),
- availableOn: ['3x3']
- },
- {
- value: 'bottom right',
- label: __('Bottom-right', 'eightshift-frontend-libs'),
- availableOn: ['3x3', '2x2']
- },
- ];
-
- // Set icons for (in)active options.
- const sizeOptions = allSizeOptions.filter(({ availableOn }) => availableOn.includes(size)).map((item) => ({
- ...item,
- icon: item.value === currentValue ? icons.matrixAlignControlDotActive : icons.matrixAlignControlDotInactive,
- }));
- const mainControl = (
- onChange(currentValue)}
- contentClass='es-p-1'
- position={popoverPosition ?? (type === 'inline' ? 'middle right' : 'bottom right')}
- trigger={
- ({ ref, setIsOpen, isOpen }) => {
- if (type === 'wp' || type === 'inline') {
- return (
- setIsOpen(!isOpen)}
- ref={ref}
- label={label}
- icon={icons[`position${size}${upperFirst(camelCase(currentValue))}`]}
- />
- );
- }
-
- return (
- setIsOpen(!isOpen)}
- icon={icons[`position${size}${upperFirst(camelCase(currentValue))}`]}
- additionalClasses={additionalTriggerClasses}
- />
- );
- }
- }
- >
- {
- setCurrentValue(value);
- onChange(value);
- }}
- value={currentValue ?? (size === '3x3' ? 'center center' : 'top left')}
- border='none'
- alignment='center'
- additionalClass={size === '3x3' ? 'es-w-28!' : 'es-w-19!'}
- additionalButtonClass='es-rounded-1!'
- noBottomSpacing
- iconOnly
- />
-
+ return (
+
);
-
- if (type === 'inline') {
- return (
-
- {mainControl}
-
- );
- }
-
- return mainControl;
};
diff --git a/scripts/components/menu/es-menu.scss b/scripts/components/menu/es-menu.scss
deleted file mode 100644
index da6042ea2..000000000
--- a/scripts/components/menu/es-menu.scss
+++ /dev/null
@@ -1,3 +0,0 @@
-.es-submenu-popover {
- translate: calc(100% - 0.5rem) 0;
-}
diff --git a/scripts/components/menu/menu-item.js b/scripts/components/menu/menu-item.js
index 0a98b285c..479e60356 100644
--- a/scripts/components/menu/menu-item.js
+++ b/scripts/components/menu/menu-item.js
@@ -1,19 +1,20 @@
import React from 'react';
-import { Button } from '@wordpress/components';
-import { clsx } from '@eightshift/ui-components/utilities';
+import { MenuItem as EsUicMenuItem } from '@eightshift/ui-components';
/**
* @since 8.5.0
*
+ * @deprecated Use `MenuItem` from `@eightshift/ui-components` instead.
+ *
* A simple menu item.
*
- * @param {object} props - MenuItem options.
- * @param {React.Component?} [props.icon] - Icon to show within the menu item.
+ * @param {object} props - MenuItem options.
+ * @param {React.Component?} [props.icon] - Icon to show within the menu item.
* @param {(string|React.Component)?} [props.label] - Label to show inside the menu item.
- * @param {function?} [props.onClick] - Button click action.
- * @param {boolean?} [props.disabled=false] - If `true`, the menu item is disabled.
- * @param {string?} [props.additionalClass] - Pass custom class(es) to the menu item.
- * @param {object?} [props.customProps] - Pass custom props to the menu item.
+ * @param {function?} [props.onClick] - Button click action.
+ * @param {boolean?} [props.disabled=false] - If `true`, the menu item is disabled.
+ * @param {string?} [props.additionalClass] - Pass custom class(es) to the menu item.
+ * @param {object?} [props.customProps] - Pass custom props to the menu item.
*/
export const MenuItem = (props) => {
const {
@@ -28,19 +29,14 @@ export const MenuItem = (props) => {
} = props;
return (
-
{label}
-
+
);
};
diff --git a/scripts/components/menu/menu-separator.js b/scripts/components/menu/menu-separator.js
index a3dbd5f10..1e96f0d70 100644
--- a/scripts/components/menu/menu-separator.js
+++ b/scripts/components/menu/menu-separator.js
@@ -1,10 +1,13 @@
import React from 'react';
+import { MenuSeparator as EsUicMenuSeparator } from '@eightshift/ui-components';
/**
* @since 8.5.0
*
+ * @deprecated Use `MenuSeparator` from `@eightshift/ui-components` instead.
+ *
* A simple menu separator.
*/
export const MenuSeparator = () => (
-
+
);
diff --git a/scripts/components/menu/menu.js b/scripts/components/menu/menu.js
index 52cda8a3e..a58e7c8c5 100644
--- a/scripts/components/menu/menu.js
+++ b/scripts/components/menu/menu.js
@@ -1,25 +1,22 @@
import React from 'react';
-import { Button } from '@wordpress/components';
-import { PopoverWithTrigger } from '../../../scripts';
-import { clsx } from '@eightshift/ui-components/utilities';
-import { icons } from '@eightshift/ui-components/icons';
+import { Menu as EsUicMenu } from '@eightshift/ui-components';
/**
* @since 8.5.0
*
+ * @deprecated Use `Menu` from `@eightshift/ui-components` instead.
+ *
* A simple dropdown menu.
*
- * @param {object} props - Menu options.
- * @param {React.Component?} [props.icon] - Icon to show within the menu open button.
- * @param {(string|React.Component)?} [props.label] - Label to show inside the menu open button.
+ * @param {object} props - Menu options.
+ * @param {React.Component?} [props.icon] - Icon to show within the menu open button.
+ * @param {(string|React.Component)?} [props.label] - Label to show inside the menu open button.
* @param {(string|React.Component)?} [props.tooltip] - Tooltip to show on the menu open button.
- * @param {boolean?} [props.disabled=false] - If `true`, the menu open button is disabled.
- * @param {string?} [props.buttonClass] - Replace the menu open default class.
- * @param {string?} [props.additionalClass] - Pass custom class(es) to the menu open button.
- * @param {object?} [props.buttonProps] - Pass custom props to the menu open button.
- * @param {boolean?} [props.isSubmenu=false] - If `true`, the styling of the menu toggle matches the styling of `MenuItem`s.
- * @param {object?} [props.popoverProps] - Pass custom props to the popover that contains the menu items.
- * @param {string?} [props.popoverAdditionalClass] - Pass custom class(es) to the popover that contains the menu items.
+ * @param {boolean?} [props.disabled=false] - If `true`, the menu open button is disabled.
+ * @param {string?} [props.buttonClass] - Replace the menu open default class.
+ * @param {string?} [props.additionalClass] - Pass custom class(es) to the menu open button.
+ * @param {object?} [props.buttonProps] - Pass custom props to the menu open button.
+ * @param {object?} [props.popoverProps] - Pass custom props to the popover that contains the menu items.
*/
export const Menu = (props) => {
const {
@@ -30,72 +27,27 @@ export const Menu = (props) => {
disabled = false,
buttonClass,
- additionalClass,
buttonProps,
- isSubmenu = false,
-
popoverProps,
- popoverAdditionalClass,
children,
} = props;
- let buttonClassname = clsx(
- // eslint-disable-next-line max-len
- 'es-slight-button-border-cool-gray-400 es-hover-slight-button-border-admin-accent es-active-slight-button-border-admin-accent es-focus-slight-button-border-admin-accent es-nested-size-5',
- // eslint-disable-next-line max-len
- 'es-nested-m-0! es-gap-1.25! es-bg-pure-white es-text-3.25! es-color-cool-gray-650 es-rounded-1.5! es-flex-shrink-0 es-min-w-auto!',
- !label && 'es-size-9',
- label && 'es-px-2.5!',
- additionalClass,
- );
-
- if (isSubmenu) {
- buttonClassname = clsx(
- 'es-rounded-1.5 es-gap-1.5! es-transition-colors es-min-w-max! es-nested-m-0!',
- !disabled && 'es-hover-color-current! es-hover-bg-cool-gray-50 es-nested-color-cool-gray-450',
- disabled && 'es-nested-color-cool-gray-200',
- additionalClass
- );
- }
-
- let innerContent = label;
-
- if (isSubmenu) {
- innerContent = (
-
- {label}
-
- {icons.chevronRight}
-
- );
- }
-
return (
- (
- setIsOpen(!isOpen)}
- className={buttonClass ?? buttonClassname}
- label={tooltip}
- disabled={disabled}
- {...buttonProps}
- >
- {innerContent}
-
- )}
- contentClass={clsx('es-p-1 es-v-spaced es-gap-2px! es-min-w-48', popoverAdditionalClass)}
- position='bottom right'
- noArrow
- additionalPopoverProps={isSubmenu && { offset: { mainAxis: -36 } }}
- {...popoverProps}
+
{children}
-
+
);
};
diff --git a/scripts/components/number-picker/number-picker.js b/scripts/components/number-picker/number-picker.js
index 8f7b7a9f7..521e4e30d 100644
--- a/scripts/components/number-picker/number-picker.js
+++ b/scripts/components/number-picker/number-picker.js
@@ -1,15 +1,11 @@
import React from 'react';
import { __ } from '@wordpress/i18n';
-import { Button, __experimentalNumberControl as NumberControl } from '@wordpress/components';
-import { Control } from '../base-control/base-control';
-import { icons } from '@eightshift/ui-components/icons';
-import { clsx } from '@eightshift/ui-components/utilities';
+import { NumberPicker as EsUicNumberPicker } from '@eightshift/ui-components';
-const round = (value, decimals) => {
- return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals);
-};
/**
+ * @deprecated Use `NumberControl` from `@eightshift/ui-components` instead.
+ *
* A simple number picker, built on the Gutenberg `NumberControl`.
*
* @param {object} props - `NumberPicker` options.
@@ -19,27 +15,18 @@ const round = (value, decimals) => {
* @param {Number} props.value - Current value.
* @param {function} [props.onChange] - Function called when the value changes.
* @param {boolean} [props.disabled=false] - If `true`, the component is disabled.
- * @param {boolean} [props.noDragToChange=false] - If `true`, the up/down drag to change value is disabled.
* @param {React.Component?} [props.icon] - Icon to show next to the label
* @param {React.Component?} [props.label] - Label to show above component.
* @param {React.Component?} [props.subtitle] - Subtitle below the label.
- * @param {React.Component?} [props.actions] - Actions to show to the right of the label.
* @param {React.Component?} [props.help] - Help to show below the control.
* @param {React.Component?} [props.children] - Content to show.
- * @param {string?} [props.additionalClasses] - Classes to add to the control base.
* @param {boolean?} [props.inlineLabel] - If `true`, the label is displayed inline with the control. In that case `actions` are shown below the control.
- * @param {boolean?} [props.noBottomSpacing] - If `true`, space below the control is removed.
- * @param {boolean?} [props.reducedBottomSpacing] - If `true`, space below the control is reduced.
- * @param {object?} [props.inputField] - Allows passing raw config data to the `NumberPicker`, e.g. `shiftStep`.
* @param {string?} [props.placeholder] - Placeholder to show inside the NumberPicker.
* @param {Number?} [props.fixedWidth] - If passed, sets the width of the input field to the provided number of characters. Useful if you have e.g. value from 1 to 1000, but you don't want the input field to change size when on lower values.
* @param {string|React.Component} [props.prefix] - If passed, displayed before input field.
* @param {string|React.Component} [props.suffix] - If passed, displayed after the input field.
- * @param {string} [props.prefixClass] - If passed, replaces the prefix default class.
- * @param {string} [props.suffixClass] - If passed, replaces the suffix default class.
* @param {React.Component?} [props.extraButton] - If passed, the control is displayed to the right of the spinner buttons.
* @param {boolean?} [props.noExtraButtonSeparator=false] - If passed, and the `extraButton` is added, the separator between the spinner buttons and the extra button is hidden.
- * @param {int?} [props.roundToDecimals=2] - If passed the number of decimals numbers are rounded to is changed.
*/
export const NumberPicker = (props) => {
const {
@@ -50,20 +37,11 @@ export const NumberPicker = (props) => {
onChange,
disabled = false,
- noDragToChange = false,
-
icon,
help,
label,
- actions,
subtitle,
inlineLabel,
- noBottomSpacing,
- reducedBottomSpacing,
-
- additionalClasses,
-
- inputField,
placeholder,
@@ -72,102 +50,28 @@ export const NumberPicker = (props) => {
prefix,
suffix,
- prefixClass,
- suffixClass,
-
extraButton,
- noExtraButtonSeparator = false,
-
- roundToDecimals = 2,
} = props;
- const spinnerButtonClass = 'es-w-4! es-h-3! es-min-w-4! es-rounded-1! es-button-icon-12 es-p-0! es-hover-bg-cool-gray-100! es-transition';
- const prefixSuffixDefaultClass = 'es-user-select-none es-color-cool-gray-450';
-
return (
-
-
-
+ {extraButton}
+
);
};
diff --git a/scripts/components/number-picker/number-picker.scss b/scripts/components/number-picker/number-picker.scss
deleted file mode 100644
index 697858135..000000000
--- a/scripts/components/number-picker/number-picker.scss
+++ /dev/null
@@ -1,44 +0,0 @@
-// stylelint-disable declaration-no-important
-.es-number-picker {
- .es-number-picker-container {
- &:has(.components-input-control__input:focus-visible) {
- box-shadow: 0 0 0 2px var(--wp-admin-theme-color, var(--es-admin-accent-color-default)) !important;
- }
- }
-
- .es-number-picker-input {
- .components-input-control {
- &__backdrop {
- display: none !important;
- }
-
- &__container {
- border: none !important;
- box-shadow: none !important;
- background: none !important;
-
- min-height: auto !important;
- }
-
- &__input {
- appearance: none;
-
- margin: 0 !important;
- padding: 0 !important;
- min-height: auto !important;
-
- border: none !important;
- box-shadow: none !important;
-
- width: var(--es-number-input-width) !important;
-
- // Special case for Firefox, as it keeps ignoring appearance none on input[type=number]
- // stylelint-disable-next-line max-nesting-depth
- @supports (-moz-appearance: textfield) {
- // stylelint-disable-next-line property-no-vendor-prefix
- -moz-appearance: textfield;
- }
- }
- }
- }
-}
diff --git a/scripts/index.js b/scripts/index.js
index 24031704e..ca0042c52 100644
--- a/scripts/index.js
+++ b/scripts/index.js
@@ -11,16 +11,6 @@ export { ColorPalette } from './components/color-palette-custom/color-palette-cu
export { ColorPicker } from './components/color-picker-component/color-picker-component';
export { Collapsable } from './components/collapsable/collapsable';
export { Control } from './components/base-control/base-control';
-export {
- RSOption,
- RSDropdownIndicator,
- RSSingleValue,
- RSMultiValueRemove,
- RSMultiValueContainer,
- RSMultiValueLabel,
- RSClearIndicator,
- RSMultiValue,
-} from './components/custom-select/react-select-component-wrappers';
export { ColumnConfigSlider } from './components/custom-slider/column-config-slider';
export { Slider } from './components/custom-slider/custom-slider';
export { RangeSlider } from './components/custom-slider/custom-range-slider';
From ea1990c1575a9c9a5eb2f248c9174d9f07dc20cb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Goran=20Alkovi=C4=87?=
<77000136+goranalkovic-infinum@users.noreply.github.com>
Date: Fri, 19 Jul 2024 17:09:33 +0200
Subject: [PATCH 34/74] replace more components
---
.../option-selector/option-selector.js | 207 +++---------------
.../popover-with-trigger.js | 118 ++--------
2 files changed, 49 insertions(+), 276 deletions(-)
diff --git a/scripts/components/option-selector/option-selector.js b/scripts/components/option-selector/option-selector.js
index 9434f6f0a..624d30b51 100644
--- a/scripts/components/option-selector/option-selector.js
+++ b/scripts/components/option-selector/option-selector.js
@@ -1,36 +1,28 @@
import React from 'react';
-import { Control, IconLabel } from '@eightshift/frontend-libs/scripts';
-import { Button } from '@wordpress/components';
-import { icons } from '@eightshift/ui-components/icons';
-import { clsx } from '@eightshift/ui-components/utilities';
+import { OptionSelect } from '@eightshift/ui-components';
/**
+ * @deprecated Use `OptionSelect` from `@eightshift/ui-components` instead.
+ *
* Button-based option selector, inspired by WP 5.9.
*
- * @param {object} props - OptionSelector options.
- * @param {React.Component?} [props.icon] - Icon to show next to the label
- * @param {React.Component?} [props.help] - Help text displayed below the control.
- * @param {React.Component?} [props.label] - Label displayed above the control.
- * @param {boolean?} [props.inlineLabel] - Label displayed inline with the control.
- * @param {React.Component?} [props.actions] - Actions to show to the right of the label.
- * @param {React.Component?} [props.subtitle] - Subtitle below the label.
- * @param {any} [props.value] - Current value.
- * @param {function} [props.onChange] - Function that is called on every value change.
- * @param {boolean} [props.disabled=false] - If `true`, the component will be disabled.
- * @param {array} [props.options] - Options to show, either values or objects with {label?, value, icon?, subtitle?}
- * @param {array<{label, value}>?} [props.optionLabels] - If passed, these labels/icons will be used instead the ones provided with `options`. Must be passed when `options` contain just values.
- * @param {'none'|'offset'} [props.border='offset'] - Sets the appearance of a border around the buttons.
- * @param {boolean} [props.noWrap=false] - If `false` and there is more options then can fit, the buttons will wrap to the row below.
- * @param {'default'|'stretch'|'left'|'center'|'right'|'vertical'} [props.alignment='default'] - If `true` and there is more options then can fit, the buttons will wrap to the row below.
- * @param {boolean} [props.iconOnly=false] - If `true`, the buttons will only contain icons. If a label is also passed, it will be used for the button tooltip.
- * @param {boolean} [props.largerIcons=false] - If `true`, the icons inside of buttons are rendered larger.
- * @param {boolean} [props.compactButtons=false] - If `true`, the buttons are rendered smaller
- * @param {boolean} [props.labelOnlyOnActive=false] - If `true`, the label is shown only on the active item.
- * @param {boolean} [props.noBottomSpacing] - If `true`, the default bottom spacing is removed.
- * @param {boolean?} [props.reducedBottomSpacing] - If `true`, space below the control is reduced.
- * @param {string?} [props.additionalClass] - If provided, the classes are appended to the button container.
- * @param {string?} [props.additionalButtonClass] - If provided, the classes are appended to the selection buttons.
- * @param {string?} [props.additionalContainerClass] - If provided, the classes are appended to the container.
+ * @param {object} props - OptionSelector options.
+ * @param {React.Component?} [props.icon] - Icon to show next to the label
+ * @param {React.Component?} [props.help] - Help text displayed below the control.
+ * @param {React.Component?} [props.label] - Label displayed above the control.
+ * @param {boolean?} [props.inlineLabel] - Label displayed inline with the control.
+ * @param {React.Component?} [props.actions] - Actions to show to the right of the label.
+ * @param {React.Component?} [props.subtitle] - Subtitle below the label.
+ * @param {any} [props.value] - Current value.
+ * @param {function} [props.onChange] - Function that is called on every value change.
+ * @param {boolean} [props.disabled=false] - If `true`, the component will be disabled.
+ * @param {array} [props.options] - Options to show, either values or objects with {label?, value, icon?, subtitle?}
+ * @param {'default'|'stretch'|'left'|'center'|'right'|'vertical'} [props.alignment='default'] - Option alignment.
+ * @param {boolean} [props.iconOnly=false] - If `true`, the buttons will only contain icons. If a label is also passed, it will be used for the button tooltip.
+ * @param {boolean} [props.compactButtons=false] - If `true`, the buttons are rendered smaller
+ * @param {string?} [props.additionalClass] - If provided, the classes are appended to the button container.
+ * @param {string?} [props.additionalButtonClass] - If provided, the classes are appended to the selection buttons.
+ * @param {string?} [props.additionalContainerClass] - If provided, the classes are appended to the container.
*/
export const OptionSelector = (props) => {
const {
@@ -47,166 +39,33 @@ export const OptionSelector = (props) => {
disabled = false,
options,
- optionLabels,
- border = 'offset',
- noWrap = false,
alignment = 'default',
iconOnly = false,
- largerIcons = false,
compactButtons = false,
- labelOnlyOnActive = false,
-
- noBottomSpacing,
- reducedBottomSpacing,
- additionalClass,
additionalButtonClass,
additionalContainerClass,
} = props;
- const buttonClasses = clsx(
- iconOnly && 'es-button-square-36',
- largerIcons && 'es-button-icon-24',
- border === 'offset' && 'es-rounded-0.75! es-p-1.5!',
- additionalButtonClass
- );
-
- const getSpacingConfig = (alignment) => {
- switch (alignment) {
- case 'left':
- return 'es-mr-auto es-content-start es-w-max';
- case 'center':
- return 'es-mx-auto es-content-center es-w-max';
- case 'right':
- return 'es-ml-auto es-content-center es-w-max';
- case 'stretch':
- return 'es-content-between es-w-full';
- case 'vertical':
- return 'es-flex-col es-w-full';
- default:
- return 'es-w-max';
- }
- };
-
- const control = (
-
);
};
From 78a51c7d122478af2e45165c4bb9b696592feda1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Goran=20Alkovi=C4=87?=
<77000136+goranalkovic-infinum@users.noreply.github.com>
Date: Tue, 23 Jul 2024 16:33:57 +0200
Subject: [PATCH 52/74] tweak responsive
---
scripts/components/responsive/responsive.js | 219 +++++++++++---------
1 file changed, 123 insertions(+), 96 deletions(-)
diff --git a/scripts/components/responsive/responsive.js b/scripts/components/responsive/responsive.js
index 0200ea123..6986a510d 100644
--- a/scripts/components/responsive/responsive.js
+++ b/scripts/components/responsive/responsive.js
@@ -1,12 +1,15 @@
import React, { useState, Fragment } from 'react';
import { __, sprintf } from '@wordpress/i18n';
-import { Button } from '@wordpress/components';
import { getDefaultBreakpointNames } from '../../helpers';
-import { IconLabel } from '../icon-label/icon-label';
-import { Control } from '../base-control/base-control';
-import { AnimatedContentVisibility } from '../animated-content-visibility/animated-content-visibility';
import { icons } from '@eightshift/ui-components/icons';
import { clsx, upperFirst } from '@eightshift/ui-components/utilities';
+import {
+ AnimatedVisibility,
+ BaseControl,
+ Button,
+ RichLabel,
+ ToggleButton,
+} from '@eightshift/ui-components';
/**
* A component that displays options adjustable across screen sizes.
@@ -21,8 +24,6 @@ import { clsx, upperFirst } from '@eightshift/ui-components/utilities';
* @param {array} [props.breakpointLabels] - If provided, labels for breakpoints will use the provided names instead of using the breakpoint name itself.
* @param {string?} [props.additionalClasses] - If provided, passes additional classes through to the component.
* @param {boolean} [props.inline=false] - If `true`, the control is rendered inline and the options are more compact. Having label, subtitle, icon or help on the child component is not advised.
- * @param {boolean} [props.noBottomSpacing] - If `true`, the default bottom spacing is removed.
- * @param {boolean?} [props.reducedBottomSpacing] - If `true`, space below the control is reduced.
* @param {array<{callback: function, isActive: boolean}>} [props.inheritButton] - If provided, an 'Inherit' button is shown on each breakpoint except the first one. For each breakpoint a `callback` function (function that sets/unsets the "inherit" value, usually `undefined`) and a `isActive` flag (`true` if inheriting from parent) need to be provided.
*/
export const Responsive = (props) => {
@@ -41,9 +42,6 @@ export const Responsive = (props) => {
additionalClasses,
inline = false,
-
- noBottomSpacing,
- reducedBottomSpacing,
} = props;
const fallbackBreakpointLabels = breakpoints.map((v) => upperFirst(v));
@@ -51,46 +49,45 @@ export const Responsive = (props) => {
const [isOpen, setIsOpen] = useState(false);
return (
-
- {inline &&
-