key: "onSuggestionSelected",
value: function onSuggestionSelected(suggestion) {
this.addNewToken(suggestion);
value: function onInputChange(event) {
var separator = this.props.tokenizeOnSpace ? /[ ,\t]+/ : /[,\t]+/;
var items = text.split(separator);
var tokenValue = Object(external_lodash_["last"])(items) || '';
this.addNewTokens(items.slice(0, -1));
incompleteTokenValue: tokenValue
}, this.updateSuggestions);
this.props.onInputChange(tokenValue);
value: function handleDeleteKey(deleteToken) {
var preventDefault = false;
if (this.input.hasFocus() && this.isInputEmpty()) {
key: "handleLeftArrowKey",
value: function handleLeftArrowKey() {
var preventDefault = false;
if (this.isInputEmpty()) {
this.moveInputBeforePreviousToken();
key: "handleRightArrowKey",
value: function handleRightArrowKey() {
var preventDefault = false;
if (this.isInputEmpty()) {
this.moveInputAfterNextToken();
value: function handleUpArrowKey() {
this.setState(function (state, props) {
selectedSuggestionIndex: (state.selectedSuggestionIndex === 0 ? _this2.getMatchingSuggestions(state.incompleteTokenValue, props.suggestions, props.value, props.maxSuggestions, props.saveTransform).length : state.selectedSuggestionIndex) - 1,
selectedSuggestionScroll: true
return true; // preventDefault
key: "handleDownArrowKey",
value: function handleDownArrowKey() {
this.setState(function (state, props) {
selectedSuggestionIndex: (state.selectedSuggestionIndex + 1) % _this3.getMatchingSuggestions(state.incompleteTokenValue, props.suggestions, props.value, props.maxSuggestions, props.saveTransform).length,
selectedSuggestionScroll: true
return true; // preventDefault
value: function handleEscapeKey(event) {
incompleteTokenValue: event.target.value,
selectedSuggestionIndex: -1,
selectedSuggestionScroll: false
return true; // preventDefault
value: function handleCommaKey() {
if (this.inputHasValidValue()) {
this.addNewToken(this.state.incompleteTokenValue);
return true; // preventDefault
value: function moveInputToIndex(index) {
this.setState(function (state, props) {
inputOffsetFromEnd: props.value.length - Math.max(index, -1) - 1
key: "moveInputBeforePreviousToken",
value: function moveInputBeforePreviousToken() {
this.setState(function (state, props) {
inputOffsetFromEnd: Math.min(state.inputOffsetFromEnd + 1, props.value.length)
key: "moveInputAfterNextToken",
value: function moveInputAfterNextToken() {
this.setState(function (state) {
inputOffsetFromEnd: Math.max(state.inputOffsetFromEnd - 1, 0)
key: "deleteTokenBeforeInput",
value: function deleteTokenBeforeInput() {
var index = this.getIndexOfInput() - 1;
this.deleteToken(this.props.value[index]);
key: "deleteTokenAfterInput",
value: function deleteTokenAfterInput() {
var index = this.getIndexOfInput();
if (index < this.props.value.length) {
this.deleteToken(this.props.value[index]); // update input offset since it's the offset from the last token
this.moveInputToIndex(index);
value: function addCurrentToken() {
var preventDefault = false;
var selectedSuggestion = this.getSelectedSuggestion();
if (selectedSuggestion) {
this.addNewToken(selectedSuggestion);
} else if (this.inputHasValidValue()) {
this.addNewToken(this.state.incompleteTokenValue);
value: function addNewTokens(tokens) {
var tokensToAdd = Object(external_lodash_["uniq"])(tokens.map(this.props.saveTransform).filter(Boolean).filter(function (token) {
return !_this4.valueContainsToken(token);
if (tokensToAdd.length > 0) {
var newValue = Object(external_lodash_["clone"])(this.props.value);
newValue.splice.apply(newValue, [this.getIndexOfInput(), 0].concat(tokensToAdd));
this.props.onChange(newValue);
value: function addNewToken(token) {
this.addNewTokens([token]);
this.props.speak(this.props.messages.added, 'assertive');
incompleteTokenValue: '',
selectedSuggestionIndex: -1,
selectedSuggestionScroll: false,
if (this.state.isActive) {
value: function deleteToken(token) {
var newTokens = this.props.value.filter(function (item) {
return _this5.getTokenValue(item) !== _this5.getTokenValue(token);
this.props.onChange(newTokens);
this.props.speak(this.props.messages.removed, 'assertive');
value: function getTokenValue(token) {
if ('object' === Object(esm_typeof["a" /* default */])(token)) {
key: "getMatchingSuggestions",
value: function getMatchingSuggestions() {
var searchValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.state.incompleteTokenValue;
var suggestions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.props.suggestions;
var value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.props.value;
var maxSuggestions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : this.props.maxSuggestions;
var saveTransform = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.props.saveTransform;
var match = saveTransform(searchValue);
var startsWithMatch = [];
if (match.length === 0) {
suggestions = Object(external_lodash_["difference"])(suggestions, value);
match = match.toLocaleLowerCase();
Object(external_lodash_["each"])(suggestions, function (suggestion) {
var index = suggestion.toLocaleLowerCase().indexOf(match);
if (value.indexOf(suggestion) === -1) {
startsWithMatch.push(suggestion);
containsMatch.push(suggestion);
suggestions = startsWithMatch.concat(containsMatch);
return Object(external_lodash_["take"])(suggestions, maxSuggestions);
key: "getSelectedSuggestion",
value: function getSelectedSuggestion() {
if (this.state.selectedSuggestionIndex !== -1) {
return this.getMatchingSuggestions()[this.state.selectedSuggestionIndex];
key: "valueContainsToken",
value: function valueContainsToken(token) {
return Object(external_lodash_["some"])(this.props.value, function (item) {
return _this6.getTokenValue(token) === _this6.getTokenValue(item);
value: function getIndexOfInput() {
return this.props.value.length - this.state.inputOffsetFromEnd;
value: function isInputEmpty() {
return this.state.incompleteTokenValue.length === 0;
key: "inputHasValidValue",
value: function inputHasValidValue() {
return this.props.saveTransform(this.state.incompleteTokenValue).length > 0;
key: "updateSuggestions",
value: function updateSuggestions() {
var resetSelectedSuggestion = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
var incompleteTokenValue = this.state.incompleteTokenValue;
var inputHasMinimumChars = incompleteTokenValue.trim().length > 1;
var matchingSuggestions = this.getMatchingSuggestions(incompleteTokenValue);
var hasMatchingSuggestions = matchingSuggestions.length > 0;
isExpanded: inputHasMinimumChars && hasMatchingSuggestions
if (resetSelectedSuggestion) {
newState.selectedSuggestionIndex = -1;
newState.selectedSuggestionScroll = false;
if (inputHasMinimumChars) {
var debouncedSpeak = this.props.debouncedSpeak;
var message = hasMatchingSuggestions ? Object(external_wp_i18n_["sprintf"])(
/* translators: %d: number of results. */
Object(external_wp_i18n_["_n"])('%d result found, use up and down arrow keys to navigate.', '%d results found, use up and down arrow keys to navigate.', matchingSuggestions.length), matchingSuggestions.length) : Object(external_wp_i18n_["__"])('No results.');
debouncedSpeak(message, 'assertive');
key: "renderTokensAndInput",
value: function renderTokensAndInput() {
var components = Object(external_lodash_["map"])(this.props.value, this.renderToken);
components.splice(this.getIndexOfInput(), 0, this.renderInput());
value: function renderToken(token, index, tokens) {
var value = this.getTokenValue(token);
var status = token.status ? token.status : undefined;
var termPosition = index + 1;
var termsCount = tokens.length;
return Object(external_wp_element_["createElement"])(Token, {
displayTransform: this.props.displayTransform,
onClickRemove: this.onTokenClickRemove,
isBorderless: token.isBorderless || this.props.isBorderless,
onMouseEnter: token.onMouseEnter,
onMouseLeave: token.onMouseLeave,
disabled: 'error' !== status && this.props.disabled,
messages: this.props.messages,
termPosition: termPosition
value: function renderInput() {
var _this$props2 = this.props,
autoCapitalize = _this$props2.autoCapitalize,
autoComplete = _this$props2.autoComplete,
maxLength = _this$props2.maxLength,
value = _this$props2.value,
instanceId = _this$props2.instanceId;
autoCapitalize: autoCapitalize,
autoComplete: autoComplete,
disabled: this.props.disabled,
value: this.state.incompleteTokenValue,
isExpanded: this.state.isExpanded,
selectedSuggestionIndex: this.state.selectedSuggestionIndex
if (!(maxLength && value.length >= maxLength)) {
props = form_token_field_objectSpread(form_token_field_objectSpread({}, props), {}, {
onChange: this.onInputChange
return Object(external_wp_element_["createElement"])(token_input, props);
value: function render() {
var _this$props3 = this.props,
disabled = _this$props3.disabled,
_this$props3$label = _this$props3.label,
label = _this$props3$label === void 0 ? Object(external_wp_i18n_["__"])('Add item') : _this$props3$label,
instanceId = _this$props3.instanceId,
className = _this$props3.className;
var isExpanded = this.state.isExpanded;
var classes = classnames_default()(className, 'components-form-token-field__input-container', {
'is-active': this.state.isActive,
className: 'components-form-token-field',
var matchingSuggestions = this.getMatchingSuggestions();
tokenFieldProps = Object.assign({}, tokenFieldProps, {
onKeyDown: this.onKeyDown,
onKeyPress: this.onKeyPress,
} // Disable reason: There is no appropriate role which describes the
// input container intended accessible usability.
// TODO: Refactor click detection to use blur to stop propagation.
/* eslint-disable jsx-a11y/no-static-element-interactions */
return Object(external_wp_element_["createElement"])("div", tokenFieldProps, Object(external_wp_element_["createElement"])("label", {
htmlFor: "components-form-token-input-".concat(instanceId),
className: "components-form-token-field__label"
}, label), Object(external_wp_element_["createElement"])("div", {
ref: this.bindTokensAndInput,
onMouseDown: this.onContainerTouched,
onTouchStart: this.onContainerTouched
}, this.renderTokensAndInput(), isExpanded && Object(external_wp_element_["createElement"])(suggestions_list, {
match: this.props.saveTransform(this.state.incompleteTokenValue),
displayTransform: this.props.displayTransform,
suggestions: matchingSuggestions,
selectedIndex: this.state.selectedSuggestionIndex,
scrollIntoView: this.state.selectedSuggestionScroll,
onHover: this.onSuggestionHovered,
onSelect: this.onSuggestionSelected
})), Object(external_wp_element_["createElement"])("p", {
id: "components-form-token-suggestions-howto-".concat(instanceId),
className: "components-form-token-field__help"
}, this.props.tokenizeOnSpace ? Object(external_wp_i18n_["__"])('Separate with commas, spaces, or the Enter key.') : Object(external_wp_i18n_["__"])('Separate with commas or the Enter key.')));
/* eslint-enable jsx-a11y/no-static-element-interactions */
key: "getDerivedStateFromProps",
value: function getDerivedStateFromProps(props, state) {
if (!props.disabled || !state.isActive) {
}(external_wp_element_["Component"]);
form_token_field_FormTokenField.defaultProps = {
suggestions: Object.freeze([]),
value: Object.freeze([]),
displayTransform: external_lodash_["identity"],
saveTransform: function saveTransform(token) {
onChange: function onChange() {},
onInputChange: function onInputChange() {},
added: Object(external_wp_i18n_["__"])('Item added.'),
removed: Object(external_wp_i18n_["__"])('Item removed.'),
remove: Object(external_wp_i18n_["__"])('Remove item')
/* harmony default export */ var form_token_field = (with_spoken_messages(Object(external_wp_compose_["withInstanceId"])(form_token_field_FormTokenField)));
// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/custom-gradient-bar/constants.js
var COLOR_POPOVER_PROPS = {
className: 'components-custom-gradient-picker__color-picker-popover',
var GRADIENT_MARKERS_WIDTH = 18;
var INSERT_POINT_WIDTH = 23;
var MINIMUM_ABSOLUTE_LEFT_POSITION = 5;
var MINIMUM_DISTANCE_BETWEEN_INSERTER_AND_POINT = 10;
var MINIMUM_DISTANCE_BETWEEN_POINTS = 0;
var MINIMUM_SIGNIFICANT_MOVE = 5;
var KEYBOARD_CONTROL_POINT_VARIATION = MINIMUM_DISTANCE_BETWEEN_INSERTER_AND_POINT;
var MINIMUM_DISTANCE_BETWEEN_INSERTER_AND_MARKER = (INSERT_POINT_WIDTH + GRADIENT_MARKERS_WIDTH) / 2;
// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/custom-gradient-bar/utils.js
function utils_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function utils_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { utils_ownKeys(Object(source), true).forEach(function (key) { Object(esm_defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { utils_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
* Control point for the gradient bar.
* @typedef {Object} ControlPoint
* @property {string} color Color of the control point.
* @property {number} position Integer position of the control point as a percentage.
* Color as parsed from the gradient by gradient-parser.
* @typedef {Object} Color
* @property {string} r Red component.