@wordpress/block-library
Version:
Block library for the WordPress editor.
155 lines (152 loc) • 5.22 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _i18n = require("@wordpress/i18n");
var _blockEditor = require("@wordpress/block-editor");
var _components = require("@wordpress/components");
var _element = require("@wordpress/element");
var _hooks = require("../utils/hooks");
var _jsxRuntime = require("react/jsx-runtime");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
const LIST_STYLE_OPTIONS = [{
label: (0, _i18n.__)('Numbers'),
value: 'decimal'
}, {
label: (0, _i18n.__)('Uppercase letters'),
value: 'upper-alpha'
}, {
label: (0, _i18n.__)('Lowercase letters'),
value: 'lower-alpha'
}, {
label: (0, _i18n.__)('Uppercase Roman numerals'),
value: 'upper-roman'
}, {
label: (0, _i18n.__)('Lowercase Roman numerals'),
value: 'lower-roman'
}];
const OrderedListSettings = ({
setAttributes,
reversed,
start,
type
}) => {
const dropdownMenuProps = (0, _hooks.useToolsPanelDropdownMenuProps)();
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.InspectorControls, {
children: _element.Platform.isNative ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.PanelBody, {
title: (0, _i18n.__)('Settings'),
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.SelectControl, {
__next40pxDefaultSize: true,
__nextHasNoMarginBottom: true,
label: (0, _i18n.__)('List style'),
options: LIST_STYLE_OPTIONS,
value: type,
onChange: newValue => setAttributes({
type: newValue
})
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.TextControl, {
__next40pxDefaultSize: true,
__nextHasNoMarginBottom: true,
label: (0, _i18n.__)('Start value'),
type: "number",
onChange: value => {
const int = parseInt(value, 10);
setAttributes({
// It should be possible to unset the value,
// e.g. with an empty string.
start: isNaN(int) ? undefined : int
});
},
value: Number.isInteger(start) ? start.toString(10) : '',
step: "1"
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToggleControl, {
__nextHasNoMarginBottom: true,
label: (0, _i18n.__)('Reverse order'),
checked: reversed || false,
onChange: value => {
setAttributes({
// Unset the attribute if not reversed.
reversed: value || undefined
});
}
})]
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalToolsPanel, {
label: (0, _i18n.__)('Settings'),
resetAll: () => {
setAttributes({
type: undefined,
start: undefined,
reversed: undefined
});
},
dropdownMenuProps: dropdownMenuProps,
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToolsPanelItem, {
label: (0, _i18n.__)('List style'),
isShownByDefault: true,
hasValue: () => !!type,
onDeselect: () => setAttributes({
type: undefined
}),
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.SelectControl, {
__next40pxDefaultSize: true,
__nextHasNoMarginBottom: true,
label: (0, _i18n.__)('List style'),
options: LIST_STYLE_OPTIONS,
value: type || 'decimal',
onChange: newValue => setAttributes({
type: newValue
})
})
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToolsPanelItem, {
label: (0, _i18n.__)('Start value'),
isShownByDefault: true,
hasValue: () => !!start,
onDeselect: () => setAttributes({
start: undefined
}),
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.TextControl, {
__next40pxDefaultSize: true,
__nextHasNoMarginBottom: true,
label: (0, _i18n.__)('Start value'),
type: "number",
onChange: value => {
const int = parseInt(value, 10);
setAttributes({
// It should be possible to unset the value,
// e.g. with an empty string.
start: isNaN(int) ? undefined : int
});
},
value: Number.isInteger(start) ? start.toString(10) : '',
step: "1"
})
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToolsPanelItem, {
label: (0, _i18n.__)('Reverse order'),
isShownByDefault: true,
hasValue: () => !!reversed,
onDeselect: () => setAttributes({
reversed: undefined
}),
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToggleControl, {
__nextHasNoMarginBottom: true,
label: (0, _i18n.__)('Reverse order'),
checked: reversed || false,
onChange: value => {
setAttributes({
// Unset the attribute if not reversed.
reversed: value || undefined
});
}
})
})]
})
});
};
var _default = exports.default = OrderedListSettings;
//# sourceMappingURL=ordered-list-settings.js.map
;