1544 lines
85 KiB
JavaScript
1544 lines
85 KiB
JavaScript
|
"use strict";
|
||
|
(self["webpackChunk_woocommerce_storybook"] = self["webpackChunk_woocommerce_storybook"] || []).push([[6],{
|
||
|
|
||
|
/***/ "../../packages/js/components/src/flag/index.js":
|
||
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||
|
|
||
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||
|
/* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
|
||
|
/* harmony export */ });
|
||
|
/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../../node_modules/.pnpm/classnames@2.3.2/node_modules/classnames/index.js");
|
||
|
/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_0__);
|
||
|
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("../../node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js");
|
||
|
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_4__);
|
||
|
/* harmony import */ var emoji_flags__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../../node_modules/.pnpm/emoji-flags@1.3.0/node_modules/emoji-flags/index.js");
|
||
|
/* harmony import */ var emoji_flags__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(emoji_flags__WEBPACK_IMPORTED_MODULE_1__);
|
||
|
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js");
|
||
|
/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_2__);
|
||
|
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js");
|
||
|
/**
|
||
|
* External dependencies
|
||
|
*/
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Use the `Flag` component to display a country's flag using the operating system's emojis.
|
||
|
*
|
||
|
* @param {Object} props
|
||
|
* @param {string} props.code
|
||
|
* @param {Object} props.order
|
||
|
* @param {string} props.className
|
||
|
* @param {string} props.size
|
||
|
* @param {boolean} props.hideFromScreenReader
|
||
|
* @return {Object} - React component.
|
||
|
*/
|
||
|
var Flag = function Flag(_ref) {
|
||
|
var code = _ref.code,
|
||
|
order = _ref.order,
|
||
|
className = _ref.className,
|
||
|
size = _ref.size,
|
||
|
hideFromScreenReader = _ref.hideFromScreenReader;
|
||
|
var classes = classnames__WEBPACK_IMPORTED_MODULE_0___default()('woocommerce-flag', className);
|
||
|
var _code = code || 'unknown';
|
||
|
if (order && order.shipping && order.shipping.country) {
|
||
|
_code = order.shipping.country;
|
||
|
} else if (order && order.billing && order.billing.country) {
|
||
|
_code = order.billing.country;
|
||
|
}
|
||
|
var inlineStyles = {
|
||
|
fontSize: size
|
||
|
};
|
||
|
var emoji = (0,lodash__WEBPACK_IMPORTED_MODULE_2__.get)(emoji_flags__WEBPACK_IMPORTED_MODULE_1___default().countryCode(_code), 'emoji');
|
||
|
return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_3__.createElement)("div", {
|
||
|
className: classes,
|
||
|
style: inlineStyles,
|
||
|
"aria-hidden": hideFromScreenReader
|
||
|
}, emoji && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_3__.createElement)("span", null, emoji), !emoji && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_3__.createElement)("span", {
|
||
|
className: "woocommerce-flag__fallback"
|
||
|
}, "Invalid country flag"));
|
||
|
};
|
||
|
Flag.propTypes = {
|
||
|
/**
|
||
|
* Two letter, three letter or three digit country code.
|
||
|
*/
|
||
|
code: (prop_types__WEBPACK_IMPORTED_MODULE_4___default().string),
|
||
|
/**
|
||
|
* An order can be passed instead of `code` and the code will automatically be pulled from the billing or shipping data.
|
||
|
*/
|
||
|
order: (prop_types__WEBPACK_IMPORTED_MODULE_4___default().object),
|
||
|
/**
|
||
|
* Additional CSS classes.
|
||
|
*/
|
||
|
className: (prop_types__WEBPACK_IMPORTED_MODULE_4___default().string),
|
||
|
/**
|
||
|
* Supply a font size to be applied to the emoji flag.
|
||
|
*/
|
||
|
size: (prop_types__WEBPACK_IMPORTED_MODULE_4___default().number)
|
||
|
};
|
||
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Flag);
|
||
|
|
||
|
/***/ }),
|
||
|
|
||
|
/***/ "../../packages/js/components/src/product-image/index.tsx":
|
||
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||
|
|
||
|
|
||
|
// EXPORTS
|
||
|
__webpack_require__.d(__webpack_exports__, {
|
||
|
A: () => (/* binding */ product_image)
|
||
|
});
|
||
|
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/extends.js
|
||
|
var esm_extends = __webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/extends.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js + 1 modules
|
||
|
var objectWithoutProperties = __webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js
|
||
|
var react = __webpack_require__("../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/classnames@2.3.2/node_modules/classnames/index.js
|
||
|
var classnames = __webpack_require__("../../node_modules/.pnpm/classnames@2.3.2/node_modules/classnames/index.js");
|
||
|
var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js
|
||
|
var lodash = __webpack_require__("../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js");
|
||
|
;// CONCATENATED MODULE: ../../packages/js/components/src/product-image/placeholder.tsx
|
||
|
// eslint-disable-next-line max-len
|
||
|
var placeholderWhiteBackground = "data:image/svg+xml;utf8,%3Csvg width='421' height='421' xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg'%3E%3Cstyle type='text/css'%3E.st0%7Bfill:url(%23SVGID_1_);stroke:%23717275;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10%7D .st1%7Bfill:%23FFFFFF;%7D .st2%7Bfill:%23717275;%7D .st3%7Bfill:%23DCDDE0;stroke:%23717275;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;%7D%3C/style%3E%3CradialGradient cx='105.8248' cy='287.7805' gradientUnits='userSpaceOnUse' id='SVGID_1_' r='372.6935'%3E%3Cstop offset='0.2613' stop-color='%23DCDDE0'/%3E%3Cstop offset='0.633' stop-color='%23D8DADD'/%3E%3Cstop offset='0.9665' stop-color='%23CECFD3'/%3E%3Cstop offset='1' stop-color='%23CCCED2'/%3E%3C/radialGradient%3E%3Cg class='layer' display='inline'%3E%3Ctitle%3ELayer 2%3C/title%3E%3Crect fill='%23ffffff' height='417.99996' id='svg_7' stroke-dasharray='null' stroke-linecap='null' stroke-linejoin='null' stroke-width='null' width='417.99996' x='1.50002' y='1.5'/%3E%3C/g%3E%3Cg class='layer' display='inline'%3E%3Ctitle%3ELayer 1%3C/title%3E%3Cg id='svg_2'/%3E%3Cg id='svg_6'%3E%3Cpath class='st0' d='m330.44409,336.12693c-0.12194,0.36582 0,0.67068 0.30485,0.79262c1.40232,-0.79262 3.17047,-1.0365 4.63377,-0.48776c0.67068,-1.46329 0.12194,-2.43882 0.06097,-3.90212c-0.91456,-15.66945 -0.73165,-31.9486 -0.73165,-47.73998c0,-16.34012 -0.30485,-32.74121 0.54874,-48.9594c0.79262,-15.9743 1.89009,-31.5218 1.28038,-47.55707c-0.60971,-15.79139 -0.06097,-31.70471 0.73165,-47.37416c0.36582,-8.04812 0.79262,-15.66945 0.36582,-23.77854c-0.48776,-9.08462 -0.36582,-21.88845 -0.36582,-30.97307c0,-1.0365 0.18291,-1.82912 -0.79262,-2.43882c-0.79262,-0.48776 -1.52427,-0.42679 -2.43882,-0.42679c-2.49979,0 -4.87765,-0.36582 -7.37744,-0.36582c-1.52427,0 -2.86562,0 -4.32891,0.30485c-0.79262,0.12194 -1.52427,0.06097 -2.31688,0.06097c-0.85359,0 -1.52427,0.18291 -2.31688,0.36582c-6.88968,1.15844 -15.73042,2.49979 -22.62009,1.76815c-6.88968,-0.73165 -13.71839,-0.67068 -20.54709,-2.01203c-6.46288,-1.28038 -12.92577,-0.42679 -19.38865,-0.42679c-4.146,0 -8.23103,0 -12.37703,0c-3.96309,0 -7.80424,-0.73165 -11.8283,-0.73165c-6.52385,0.06097 -13.10868,0.12194 -19.63253,0.36582c-4.51182,0.18291 -8.84074,0 -13.35256,0.42679c-6.82871,0.60971 -13.77936,1.09747 -20.66903,1.0365c-3.59727,0 -7.07259,0.24388 -10.60889,-0.42679c-3.17047,-0.60971 -6.58483,-0.12194 -9.7553,0.18291c-3.96309,0.36582 -7.86521,1.0365 -11.8283,1.0365c-3.84115,-0.06097 -7.74327,-0.85359 -11.58441,-0.85359c-4.38988,-0.12194 -8.59686,0.42679 -12.98674,0.12194c-5.36541,-0.36582 -10.60889,-0.06097 -15.91333,-0.12194c-0.91456,0 -1.34135,0.24388 -2.13397,0.36582c-0.79262,0.12194 -1.40232,0.36582 -2.19494,0.36582c-0.85359,0 -1.34135,-0.30485 -2.13397,-0.36582c-1.64621,-0.18291 -5.91415,-0.06097 -7.49938,-0.48776c-1.70718,-0.42679 -3.41435,-0.91456 -5.12153,-1.34135c-1.40232,1.34135 -1.52427,3.5363 -1.64621,5.48735c-0.85359,21.58359 -0.73165,43.16719 -0.60971,64.75078c0,4.99959 0.06097,9.99918 0.60971,14.9378c0.42679,3.84115 1.15844,7.6823 1.46329,11.52344c0.48776,6.219 -0.06097,12.49897 -0.36582,18.71798c-0.36582,7.31647 -0.36582,14.63295 0.06097,21.94942c0.97553,18.90089 -0.48776,40.30157 -0.79262,59.20246c-0.36582,18.41312 -0.67068,37.1311 3.90212,54.99549c4.63377,-1.82912 17.13274,1.15844 22.55912,1.40232c5.85318,0.24388 11.8283,0.30485 17.74245,0.30485c6.76774,0 13.59644,-0.36582 20.30321,0c8.47491,0.42679 16.09624,2.31688 24.63212,1.82912c4.146,-0.24388 8.65783,0.36582 12.68189,0.36582c3.29241,0 9.87724,-1.09747 12.25509,0.73165c8.77977,0 20.18127,0.12194 28.90007,-0.73165c9.08462,-0.85359 19.38865,-1.21941 28.47327,-0.36582c7.37744,0.73165 14.45003,1.34135 21.82748,0.36582c4.63377,-0.60971 9.14559,-1.09747 13.9013,-1.09747c4.32891,0 8.292,-1.58524 12.49897,-1.46329c4.63377,0.12194 9.38947,1.40232 14.02324,1.89009c3.04853,0.30485 9.63336,-2.49979 12.49897,-1.21941l-0.00003,-0.00001z' fill='black' id='svg_1'/%3E%3Cpath class='st1' d='m313.79912,275.40021c-1.09747,0 -3.90212,-4.20697 -4.99959,-
|
||
|
// eslint-disable-next-line max-len
|
||
|
var placeholderTransparentBackground = "data:image/svg+xml;utf8,%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 421 421' style='enable-background:new 0 0 421 421;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E .st0%7Bfill:url(%23SVGID_1_);stroke:%23717275;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;%7D .st1%7Bfill:%23FFFFFF;%7D .st2%7Bfill:%23717275;%7D .st3%7Bfill:%23DCDDE0;stroke:%23717275;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;%7D%0A%3C/style%3E%3CradialGradient id='SVGID_1_' cx='105.8248' cy='287.7805' r='372.6935' gradientUnits='userSpaceOnUse'%3E%3Cstop offset='0.2613' style='stop-color:%23DCDDE0'/%3E%3Cstop offset='0.633' style='stop-color:%23D8DADD'/%3E%3Cstop offset='0.9665' style='stop-color:%23CECFD3'/%3E%3Cstop offset='1' style='stop-color:%23CCCED2'/%3E%3C/radialGradient%3E%3Cpath class='st0' d='M407.2,416.7c-0.2,0.6,0,1.1,0.5,1.3c2.3-1.3,5.2-1.7,7.6-0.8c1.1-2.4,0.2-4,0.1-6.4 c-1.5-25.7-1.2-52.4-1.2-78.3c0-26.8-0.5-53.7,0.9-80.3c1.3-26.2,3.1-51.7,2.1-78c-1-25.9-0.1-52,1.2-77.7c0.6-13.2,1.3-25.7,0.6-39 c-0.8-14.9-0.6-35.9-0.6-50.8c0-1.7,0.3-3-1.3-4c-1.3-0.8-2.5-0.7-4-0.7c-4.1,0-8-0.6-12.1-0.6c-2.5,0-4.7,0-7.1,0.5 c-1.3,0.2-2.5,0.1-3.8,0.1c-1.4,0-2.5,0.3-3.8,0.6c-11.3,1.9-25.8,4.1-37.1,2.9c-11.3-1.2-22.5-1.1-33.7-3.3 c-10.6-2.1-21.2-0.7-31.8-0.7c-6.8,0-13.5,0-20.3,0c-6.5,0-12.8-1.2-19.4-1.2c-10.7,0.1-21.5,0.2-32.2,0.6c-7.4,0.3-14.5,0-21.9,0.7 c-11.2,1-22.6,1.8-33.9,1.7c-5.9,0-11.6,0.4-17.4-0.7c-5.2-1-10.8-0.2-16,0.3c-6.5,0.6-12.9,1.7-19.4,1.7c-6.3-0.1-12.7-1.4-19-1.4 C77,3,70.1,3.9,62.9,3.4c-8.8-0.6-17.4-0.1-26.1-0.2c-1.5,0-2.2,0.4-3.5,0.6C32,4,31,4.4,29.7,4.4c-1.4,0-2.2-0.5-3.5-0.6 C23.5,3.5,16.5,3.7,13.9,3c-2.8-0.7-5.6-1.5-8.4-2.2C3.2,3,3,6.6,2.8,9.8C1.4,45.2,1.6,80.6,1.8,116c0,8.2,0.1,16.4,1,24.5 c0.7,6.3,1.9,12.6,2.4,18.9c0.8,10.2-0.1,20.5-0.6,30.7c-0.6,12-0.6,24,0.1,36c1.6,31-0.8,66.1-1.3,97.1 c-0.6,30.2-1.1,60.9,6.4,90.2c7.6-3,28.1,1.9,37,2.3c9.6,0.4,19.4,0.5,29.1,0.5c11.1,0,22.3-0.6,33.3,0c13.9,0.7,26.4,3.8,40.4,3 c6.8-0.4,14.2,0.6,20.8,0.6c5.4,0,16.2-1.8,20.1,1.2c14.4,0,33.1,0.2,47.4-1.2c14.9-1.4,31.8-2,46.7-0.6c12.1,1.2,23.7,2.2,35.8,0.6 c7.6-1,15-1.8,22.8-1.8c7.1,0,13.6-2.6,20.5-2.4c7.6,0.2,15.4,2.3,23,3.1C391.7,419.2,402.5,414.6,407.2,416.7z'/%3E%3Cg%3E%3Cpath class='st1' d='M379.9,317.1c-1.8,0-6.4-6.9-8.2-9.6c-0.7-1.1-1.3-2-1.7-2.5c-2.9-3.7-6.6-7.4-10.2-10.9 c-1.1-1.1-2.3-2.3-3.4-3.4c-5.8-5.9-14.8-13.1-21.6-15.6c-2.3-0.8-4.2-2-6.1-3c-3.6-2.1-6.9-4-12.3-4.1c-0.5,0-1.1,0-1.6,0 c-6.2,0-12.3,0.8-18.6,1.8c-11.8,1.8-27.6,12.3-35.3,23.5c-1.2,1.8-1.9,3.8-2,5.8c-3.8-0.9-9.2-5.2-12.5-7.8 c-0.5-0.4-1-0.8-1.4-1.1c-4.5-3.5-7.8-7.5-11.4-11.9c-2.1-2.5-4.3-5.1-6.7-7.6c-13-13.4-27.7-25.4-41.9-37 c-7.4-6-15-12.2-22.3-18.5c-9.5-8.2-17-16.1-23.7-24.8c-0.7-0.9-1.4-1.8-2-2.7c-2.6-3.5-5.3-7-8.4-10.1c-1.1-1.1-3.8-3.1-6.9-5.3 c-4.9-3.6-12.4-9-13-11c-0.7-2.3-5.8-5.8-5.9-5.8c-1.4-0.8-2.9-2.3-3-4.3l-0.1-1.4l-1.3,0.6c-4.7,2.2-8.1,5.6-11.6,9.2 c-0.6,0.6-1.1,1.2-1.7,1.7c-9.3,9.4-18.3,19.1-26.7,28.7c-4.1,4.7-8.4,9.9-12,15.4c-1,1.5-1.9,3.3-2.8,5.2c-1.5,3.1-3.1,6.3-5,8.2 c-0.6-0.9-1.2-2.7-1.5-3.5c-0.1-0.3-0.2-0.7-0.3-0.9c-2.1-5.2-1.3-10.7-0.5-16.5c0.6-4.1,1.2-8.2,0.8-12.5c-0.2-1.6-0.5-3.3-0.8-5 c-1-5.7-2-11.5-1.2-16.8c2-15.8,4-32,5-48.1c1.6-15.9,0.7-30.9-0.3-46.8c-0.2-4-0.5-8.2-0.7-12.3c0-1.7-0.1-3.5-0.1-5.2 c-0.2-5.2-0.4-10.2,1-15.1c0.3-0.2,0.8-0.5,1.4-0.6l3.9,1.7c3.7,1.5,8.5,2.3,14.6,2.3c5.6,0,11.5-0.6,17.3-1.2 c5.3-0.5,10.4-1,14.8-1c1.1,0,2.1,0,3.1,0.1c2.5,0.2,5,0.5,7.4,0.8c3.5,0.4,7.2,0.9,10.8,0.9c0.9,0,1.8,0,2.6,0 c6.4,0,13-0.3,19.3-0.6c5.2-0.2,10.6-0.5,15.9-0.6c9-0.1,18.2-0.6,27-1c3.7-0.2,7.3-0.4,11-0.5c7.2-0.3,14.6-0.3,21.7-0.3 c5.1,0,10.4,0,15.7-0.1c10.9-0.3,21.9-0.9,32.5-1.6c11.3-0.7,23.1-1.4,34.6-1.6c2.9-0.1,5.8-0.1,8.6-0.1c6.3-0.1,12.8-0.1,19.3-0.5 c3.7-0.2,7.5-0.6,11.2-0.9c6.2-0.6,12.7-1.1,19-1.1c2.3,0,4.5,0.1,6.6,0.2c3.1,0.2,6.2,0.8,9.5,1.4c4.3,0.8,8.7,1.5,13,1.5 c1.1,0,2.2-0.1,3.2-0.2c-1.2,2.3-1.2,5.2-1.1,6.7c0.2,3.8,0.2,7.9,0.2,11.8c0,15.4-1.6,30
|
||
|
|
||
|
;// CONCATENATED MODULE: ../../packages/js/components/src/product-image/index.tsx
|
||
|
|
||
|
|
||
|
var _excluded = ["product", "width", "height", "className", "alt"];
|
||
|
|
||
|
/**
|
||
|
* External dependencies
|
||
|
*/
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Internal dependencies
|
||
|
*/
|
||
|
|
||
|
/**
|
||
|
* Use `ProductImage` to display a product's or variation's featured image.
|
||
|
* If no image can be found, a placeholder matching the front-end image
|
||
|
* placeholder will be displayed.
|
||
|
*/
|
||
|
|
||
|
var ProductImage = function ProductImage(_ref) {
|
||
|
var product = _ref.product,
|
||
|
_ref$width = _ref.width,
|
||
|
width = _ref$width === void 0 ? 33 : _ref$width,
|
||
|
_ref$height = _ref.height,
|
||
|
height = _ref$height === void 0 ? 33 : _ref$height,
|
||
|
_ref$className = _ref.className,
|
||
|
className = _ref$className === void 0 ? '' : _ref$className,
|
||
|
alt = _ref.alt,
|
||
|
props = (0,objectWithoutProperties/* default */.A)(_ref, _excluded);
|
||
|
// The first returned image from the API is the featured/product image.
|
||
|
var productImage = (0,lodash.get)(product, ['images', 0]) || (0,lodash.get)(product, ['image']);
|
||
|
var src = productImage && productImage.src || false;
|
||
|
var altText = alt || productImage && productImage.alt || '';
|
||
|
var classes = classnames_default()('woocommerce-product-image', className, {
|
||
|
'is-placeholder': !src
|
||
|
});
|
||
|
return (0,react.createElement)("img", (0,esm_extends/* default */.A)({
|
||
|
className: classes,
|
||
|
src: src || placeholderWhiteBackground,
|
||
|
width: width,
|
||
|
height: height,
|
||
|
alt: altText
|
||
|
}, props));
|
||
|
};
|
||
|
/* harmony default export */ const product_image = (ProductImage);
|
||
|
|
||
|
/***/ }),
|
||
|
|
||
|
/***/ "../../packages/js/components/src/search/index.tsx":
|
||
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||
|
|
||
|
|
||
|
// EXPORTS
|
||
|
__webpack_require__.d(__webpack_exports__, {
|
||
|
A: () => (/* binding */ search)
|
||
|
});
|
||
|
|
||
|
// UNUSED EXPORTS: Search
|
||
|
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.reflect.construct.js
|
||
|
var es_reflect_construct = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.reflect.construct.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules
|
||
|
var toConsumableArray = __webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js
|
||
|
var asyncToGenerator = __webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/typeof.js
|
||
|
var esm_typeof = __webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/typeof.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/classCallCheck.js
|
||
|
var classCallCheck = __webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/classCallCheck.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/createClass.js
|
||
|
var createClass = __webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/createClass.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
|
||
|
var assertThisInitialized = __webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/inherits.js
|
||
|
var inherits = __webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/inherits.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js
|
||
|
var possibleConstructorReturn = __webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js
|
||
|
var getPrototypeOf = __webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
||
|
var defineProperty = __webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/helpers/esm/defineProperty.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js
|
||
|
var react = __webpack_require__("../../node_modules/.pnpm/react@18.3.1/node_modules/react/index.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/regenerator/index.js
|
||
|
var regenerator = __webpack_require__("../../node_modules/.pnpm/@babel+runtime@7.23.5/node_modules/@babel/runtime/regenerator/index.js");
|
||
|
var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator);
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/regenerator-runtime@0.13.11/node_modules/regenerator-runtime/runtime.js
|
||
|
var runtime = __webpack_require__("../../node_modules/.pnpm/regenerator-runtime@0.13.11/node_modules/regenerator-runtime/runtime.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.function.bind.js
|
||
|
var es_function_bind = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.function.bind.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.for-each.js
|
||
|
var es_array_for_each = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.for-each.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.to-string.js
|
||
|
var es_object_to_string = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.to-string.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/web.dom-collections.for-each.js
|
||
|
var web_dom_collections_for_each = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/web.dom-collections.for-each.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.filter.js
|
||
|
var es_array_filter = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.filter.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.promise.js
|
||
|
var es_promise = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.promise.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.map.js
|
||
|
var es_array_map = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.map.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.concat.js
|
||
|
var es_array_concat = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.concat.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js
|
||
|
var lodash = __webpack_require__("../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js
|
||
|
var prop_types = __webpack_require__("../../node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js");
|
||
|
var prop_types_default = /*#__PURE__*/__webpack_require__.n(prop_types);
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/classnames@2.3.2/node_modules/classnames/index.js
|
||
|
var classnames = __webpack_require__("../../node_modules/.pnpm/classnames@2.3.2/node_modules/classnames/index.js");
|
||
|
var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
|
||
|
// EXTERNAL MODULE: ../../packages/js/components/src/select-control/index.tsx + 3 modules
|
||
|
var select_control = __webpack_require__("../../packages/js/components/src/select-control/index.tsx");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.function.name.js
|
||
|
var es_function_name = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.function.name.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@wordpress+i18n@4.6.1/node_modules/@wordpress/i18n/build-module/index.js + 3 modules
|
||
|
var build_module = __webpack_require__("../../node_modules/.pnpm/@wordpress+i18n@4.6.1/node_modules/@wordpress/i18n/build-module/index.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@wordpress+url@3.7.1/node_modules/@wordpress/url/build-module/add-query-args.js + 3 modules
|
||
|
var add_query_args = __webpack_require__("../../node_modules/.pnpm/@wordpress+url@3.7.1/node_modules/@wordpress/url/build-module/add-query-args.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@wordpress+api-fetch@6.3.1/node_modules/@wordpress/api-fetch/build-module/index.js + 12 modules
|
||
|
var api_fetch_build_module = __webpack_require__("../../node_modules/.pnpm/@wordpress+api-fetch@6.3.1/node_modules/@wordpress/api-fetch/build-module/index.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@automattic+interpolate-components@1.2.1_@types+react@17.0.71_react@17.0.2/node_modules/@automattic/interpolate-components/dist/esm/index.js + 1 modules
|
||
|
var esm = __webpack_require__("../../node_modules/.pnpm/@automattic+interpolate-components@1.2.1_@types+react@17.0.71_react@17.0.2/node_modules/@automattic/interpolate-components/dist/esm/index.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.index-of.js
|
||
|
var es_array_index_of = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.index-of.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.join.js
|
||
|
var es_array_join = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.join.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.string.trim.js
|
||
|
var es_string_trim = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.string.trim.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.date.to-string.js
|
||
|
var es_date_to_string = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.date.to-string.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.regexp.to-string.js
|
||
|
var es_regexp_to_string = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.regexp.to-string.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/@wordpress+html-entities@3.6.1/node_modules/@wordpress/html-entities/build-module/index.js
|
||
|
var html_entities_build_module = __webpack_require__("../../node_modules/.pnpm/@wordpress+html-entities@3.6.1/node_modules/@wordpress/html-entities/build-module/index.js");
|
||
|
;// CONCATENATED MODULE: ../../packages/js/components/src/search/autocompleters/utils.ts
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* External dependencies
|
||
|
*/
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Parse a string suggestion, split apart by where the first matching query is.
|
||
|
* Used to display matched partial in bold.
|
||
|
*
|
||
|
* @param {string} suggestion The item's label as returned from the API.
|
||
|
* @param {string} query The search term to match in the string.
|
||
|
* @return {Object} A list in three parts: before, match, and after.
|
||
|
*/
|
||
|
function computeSuggestionMatch(suggestion, query) {
|
||
|
if (!query) {
|
||
|
return null;
|
||
|
}
|
||
|
var indexOfMatch = suggestion.toLocaleLowerCase().indexOf(query.toLocaleLowerCase());
|
||
|
return {
|
||
|
suggestionBeforeMatch: (0,html_entities_build_module/* decodeEntities */.S)(suggestion.substring(0, indexOfMatch)),
|
||
|
suggestionMatch: (0,html_entities_build_module/* decodeEntities */.S)(suggestion.substring(indexOfMatch, indexOfMatch + query.length)),
|
||
|
suggestionAfterMatch: (0,html_entities_build_module/* decodeEntities */.S)(suggestion.substring(indexOfMatch + query.length))
|
||
|
};
|
||
|
}
|
||
|
function getTaxCode(tax) {
|
||
|
return [tax.country, tax.state, tax.name || (0,build_module.__)('TAX', 'woocommerce'), tax.priority].filter(Boolean).map(function (item) {
|
||
|
return item === null || item === void 0 ? void 0 : item.toString().toUpperCase().trim();
|
||
|
}).join('-');
|
||
|
}
|
||
|
;// CONCATENATED MODULE: ../../packages/js/components/src/search/autocompleters/attributes.tsx
|
||
|
|
||
|
|
||
|
/**
|
||
|
* External dependencies
|
||
|
*/
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Internal dependencies
|
||
|
*/
|
||
|
|
||
|
var completer = {
|
||
|
name: 'attributes',
|
||
|
className: 'woocommerce-search__product-result',
|
||
|
options: function options(search) {
|
||
|
var query = search ? {
|
||
|
search: search,
|
||
|
per_page: 10,
|
||
|
orderby: 'count'
|
||
|
} : {};
|
||
|
return (0,api_fetch_build_module/* default */.A)({
|
||
|
path: (0,add_query_args/* addQueryArgs */.F)('/wc-analytics/products/attributes', query)
|
||
|
});
|
||
|
},
|
||
|
isDebounced: true,
|
||
|
getOptionIdentifier: function getOptionIdentifier(attribute) {
|
||
|
return attribute.id;
|
||
|
},
|
||
|
getOptionKeywords: function getOptionKeywords(attribute) {
|
||
|
return [attribute.name];
|
||
|
},
|
||
|
getFreeTextOptions: function getFreeTextOptions(query) {
|
||
|
var label = (0,react.createElement)("span", {
|
||
|
key: "name",
|
||
|
className: "woocommerce-search__result-name"
|
||
|
}, (0,esm/* default */.A)({
|
||
|
mixedString: (0,build_module.__)('All attributes with names that include {{query /}}', 'woocommerce'),
|
||
|
components: {
|
||
|
query: (0,react.createElement)("strong", {
|
||
|
className: "components-form-token-field__suggestion-match"
|
||
|
}, query)
|
||
|
}
|
||
|
}));
|
||
|
var nameOption = {
|
||
|
key: 'name',
|
||
|
label: label,
|
||
|
value: {
|
||
|
id: query,
|
||
|
name: query
|
||
|
}
|
||
|
};
|
||
|
return [nameOption];
|
||
|
},
|
||
|
getOptionLabel: function getOptionLabel(attribute, query) {
|
||
|
var match = computeSuggestionMatch(attribute.name, query);
|
||
|
return (0,react.createElement)("span", {
|
||
|
key: "name",
|
||
|
className: "woocommerce-search__result-name",
|
||
|
"aria-label": attribute.name
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionBeforeMatch, (0,react.createElement)("strong", {
|
||
|
className: "components-form-token-field__suggestion-match"
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionMatch), match === null || match === void 0 ? void 0 : match.suggestionAfterMatch);
|
||
|
},
|
||
|
// This is slightly different than gutenberg/Autocomplete, we don't support different methods
|
||
|
// of replace/insertion, so we can just return the value.
|
||
|
getOptionCompletion: function getOptionCompletion(attribute) {
|
||
|
var value = {
|
||
|
key: attribute.id,
|
||
|
label: attribute.name
|
||
|
};
|
||
|
return value;
|
||
|
}
|
||
|
};
|
||
|
/* harmony default export */ const attributes = (completer);
|
||
|
;// CONCATENATED MODULE: ../../packages/js/components/src/search/autocompleters/categories.tsx
|
||
|
|
||
|
|
||
|
/**
|
||
|
* External dependencies
|
||
|
*/
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Internal dependencies
|
||
|
*/
|
||
|
|
||
|
var categories_completer = {
|
||
|
name: 'categories',
|
||
|
className: 'woocommerce-search__product-result',
|
||
|
options: function options(search) {
|
||
|
var query = search ? {
|
||
|
search: search,
|
||
|
per_page: 10,
|
||
|
orderby: 'count'
|
||
|
} : {};
|
||
|
return (0,api_fetch_build_module/* default */.A)({
|
||
|
path: (0,add_query_args/* addQueryArgs */.F)('/wc-analytics/products/categories', query)
|
||
|
});
|
||
|
},
|
||
|
isDebounced: true,
|
||
|
getOptionIdentifier: function getOptionIdentifier(category) {
|
||
|
return category.id;
|
||
|
},
|
||
|
getOptionKeywords: function getOptionKeywords(cat) {
|
||
|
return [cat.name];
|
||
|
},
|
||
|
getFreeTextOptions: function getFreeTextOptions(query) {
|
||
|
var label = (0,react.createElement)("span", {
|
||
|
key: "name",
|
||
|
className: "woocommerce-search__result-name"
|
||
|
}, (0,esm/* default */.A)({
|
||
|
mixedString: (0,build_module.__)('All categories with titles that include {{query /}}', 'woocommerce'),
|
||
|
components: {
|
||
|
query: (0,react.createElement)("strong", {
|
||
|
className: "components-form-token-field__suggestion-match"
|
||
|
}, query)
|
||
|
}
|
||
|
}));
|
||
|
var titleOption = {
|
||
|
key: 'title',
|
||
|
label: label,
|
||
|
value: {
|
||
|
id: query,
|
||
|
name: query
|
||
|
}
|
||
|
};
|
||
|
return [titleOption];
|
||
|
},
|
||
|
getOptionLabel: function getOptionLabel(cat, query) {
|
||
|
var match = computeSuggestionMatch(cat.name, query);
|
||
|
// @todo Bring back ProductImage, but allow for product category image
|
||
|
return (0,react.createElement)("span", {
|
||
|
key: "name",
|
||
|
className: "woocommerce-search__result-name",
|
||
|
"aria-label": cat.name
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionBeforeMatch, (0,react.createElement)("strong", {
|
||
|
className: "components-form-token-field__suggestion-match"
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionMatch), match === null || match === void 0 ? void 0 : match.suggestionAfterMatch);
|
||
|
},
|
||
|
// This is slightly different than gutenberg/Autocomplete, we don't support different methods
|
||
|
// of replace/insertion, so we can just return the value.
|
||
|
getOptionCompletion: function getOptionCompletion(cat) {
|
||
|
var value = {
|
||
|
key: cat.id,
|
||
|
label: cat.name
|
||
|
};
|
||
|
return value;
|
||
|
}
|
||
|
};
|
||
|
/* harmony default export */ const categories = (categories_completer);
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.is-array.js
|
||
|
var es_array_is_array = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.is-array.js");
|
||
|
// EXTERNAL MODULE: ../../packages/js/components/src/flag/index.js
|
||
|
var flag = __webpack_require__("../../packages/js/components/src/flag/index.js");
|
||
|
;// CONCATENATED MODULE: ../../packages/js/components/src/search/autocompleters/countries.tsx
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* External dependencies
|
||
|
*/
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Internal dependencies
|
||
|
*/
|
||
|
|
||
|
|
||
|
// Cache countries to avoid repeated requests.
|
||
|
var allCountries = null;
|
||
|
var isCountries = function isCountries(value) {
|
||
|
return Array.isArray(value) && value.length > 0 && (0,esm_typeof/* default */.A)(value[0]) === 'object' && typeof value[0].code === 'string' && typeof value[0].name === 'string';
|
||
|
};
|
||
|
var countries_completer = {
|
||
|
name: 'countries',
|
||
|
className: 'woocommerce-search__country-result',
|
||
|
isDebounced: true,
|
||
|
options: function options() {
|
||
|
// Returned cached countries if we've already received them.
|
||
|
if (allCountries) {
|
||
|
return Promise.resolve(allCountries);
|
||
|
}
|
||
|
// Make the request for country data.
|
||
|
return (0,api_fetch_build_module/* default */.A)({
|
||
|
path: '/wc-analytics/data/countries'
|
||
|
}).then(function (result) {
|
||
|
if (isCountries(result)) {
|
||
|
// Cache the response.
|
||
|
allCountries = result;
|
||
|
return allCountries;
|
||
|
}
|
||
|
|
||
|
// If the response is not valid, return an empty array.
|
||
|
// eslint-disable-next-line no-console
|
||
|
console.warn('Invalid countries response', result);
|
||
|
return [];
|
||
|
});
|
||
|
},
|
||
|
getOptionIdentifier: function getOptionIdentifier(country) {
|
||
|
return country.code;
|
||
|
},
|
||
|
getSearchExpression: function getSearchExpression(query) {
|
||
|
return '^' + query;
|
||
|
},
|
||
|
getOptionKeywords: function getOptionKeywords(country) {
|
||
|
return [country.code, (0,html_entities_build_module/* decodeEntities */.S)(country.name)];
|
||
|
},
|
||
|
getOptionLabel: function getOptionLabel(country, query) {
|
||
|
var name = (0,html_entities_build_module/* decodeEntities */.S)(country.name);
|
||
|
var match = computeSuggestionMatch(name, query);
|
||
|
return (0,react.createElement)(react.Fragment, null, (0,react.createElement)(flag/* default */.A, {
|
||
|
key: "thumbnail",
|
||
|
className: "woocommerce-search__result-thumbnail",
|
||
|
code: country.code
|
||
|
// @ts-expect-error TODO: migrate Flag component.
|
||
|
,
|
||
|
|
||
|
size: 18,
|
||
|
hideFromScreenReader: true
|
||
|
}), (0,react.createElement)("span", {
|
||
|
key: "name",
|
||
|
className: "woocommerce-search__result-name",
|
||
|
"aria-label": name
|
||
|
}, query ? (0,react.createElement)(react.Fragment, null, match === null || match === void 0 ? void 0 : match.suggestionBeforeMatch, (0,react.createElement)("strong", {
|
||
|
className: "components-form-token-field__suggestion-match"
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionMatch), match === null || match === void 0 ? void 0 : match.suggestionAfterMatch) : name));
|
||
|
},
|
||
|
// This is slightly different than gutenberg/Autocomplete, we don't support different methods
|
||
|
// of replace/insertion, so we can just return the value.
|
||
|
getOptionCompletion: function getOptionCompletion(country) {
|
||
|
var value = {
|
||
|
key: country.code,
|
||
|
label: (0,html_entities_build_module/* decodeEntities */.S)(country.name)
|
||
|
};
|
||
|
return value;
|
||
|
}
|
||
|
};
|
||
|
/* harmony default export */ const countries = (countries_completer);
|
||
|
;// CONCATENATED MODULE: ../../packages/js/components/src/search/autocompleters/coupons.tsx
|
||
|
|
||
|
/**
|
||
|
* External dependencies
|
||
|
*/
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Internal dependencies
|
||
|
*/
|
||
|
|
||
|
var coupons_completer = {
|
||
|
name: 'coupons',
|
||
|
className: 'woocommerce-search__coupon-result',
|
||
|
options: function options(search) {
|
||
|
var query = search ? {
|
||
|
search: search,
|
||
|
per_page: 10
|
||
|
} : {};
|
||
|
return (0,api_fetch_build_module/* default */.A)({
|
||
|
path: (0,add_query_args/* addQueryArgs */.F)('/wc-analytics/coupons', query)
|
||
|
});
|
||
|
},
|
||
|
isDebounced: true,
|
||
|
getOptionIdentifier: function getOptionIdentifier(coupon) {
|
||
|
return coupon.id;
|
||
|
},
|
||
|
getOptionKeywords: function getOptionKeywords(coupon) {
|
||
|
return [coupon.code];
|
||
|
},
|
||
|
getFreeTextOptions: function getFreeTextOptions(query) {
|
||
|
var label = (0,react.createElement)("span", {
|
||
|
key: "name",
|
||
|
className: "woocommerce-search__result-name"
|
||
|
}, (0,esm/* default */.A)({
|
||
|
mixedString: (0,build_module.__)('All coupons with codes that include {{query /}}', 'woocommerce'),
|
||
|
components: {
|
||
|
query: (0,react.createElement)("strong", {
|
||
|
className: "components-form-token-field__suggestion-match"
|
||
|
}, query)
|
||
|
}
|
||
|
}));
|
||
|
var codeOption = {
|
||
|
key: 'code',
|
||
|
label: label,
|
||
|
value: {
|
||
|
id: query,
|
||
|
code: query
|
||
|
}
|
||
|
};
|
||
|
return [codeOption];
|
||
|
},
|
||
|
getOptionLabel: function getOptionLabel(coupon, query) {
|
||
|
var match = computeSuggestionMatch(coupon.code, query);
|
||
|
return (0,react.createElement)("span", {
|
||
|
key: "name",
|
||
|
className: "woocommerce-search__result-name",
|
||
|
"aria-label": coupon.code
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionBeforeMatch, (0,react.createElement)("strong", {
|
||
|
className: "components-form-token-field__suggestion-match"
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionMatch), match === null || match === void 0 ? void 0 : match.suggestionAfterMatch);
|
||
|
},
|
||
|
// This is slightly different than gutenberg/Autocomplete, we don't support different methods
|
||
|
// of replace/insertion, so we can just return the value.
|
||
|
getOptionCompletion: function getOptionCompletion(coupon) {
|
||
|
var value = {
|
||
|
key: coupon.id,
|
||
|
label: coupon.code
|
||
|
};
|
||
|
return value;
|
||
|
}
|
||
|
};
|
||
|
/* harmony default export */ const coupons = (coupons_completer);
|
||
|
;// CONCATENATED MODULE: ../../packages/js/components/src/search/autocompleters/customers.tsx
|
||
|
|
||
|
|
||
|
/**
|
||
|
* External dependencies
|
||
|
*/
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Internal dependencies
|
||
|
*/
|
||
|
|
||
|
var customers_completer = {
|
||
|
name: 'customers',
|
||
|
className: 'woocommerce-search__customers-result',
|
||
|
options: function options(name) {
|
||
|
var query = name ? {
|
||
|
search: name,
|
||
|
searchby: 'name',
|
||
|
per_page: 10
|
||
|
} : {};
|
||
|
return (0,api_fetch_build_module/* default */.A)({
|
||
|
path: (0,add_query_args/* addQueryArgs */.F)('/wc-analytics/customers', query)
|
||
|
});
|
||
|
},
|
||
|
isDebounced: true,
|
||
|
getOptionIdentifier: function getOptionIdentifier(customer) {
|
||
|
return customer.id;
|
||
|
},
|
||
|
getOptionKeywords: function getOptionKeywords(customer) {
|
||
|
return [customer.name];
|
||
|
},
|
||
|
getFreeTextOptions: function getFreeTextOptions(query) {
|
||
|
var label = (0,react.createElement)("span", {
|
||
|
key: "name",
|
||
|
className: "woocommerce-search__result-name"
|
||
|
}, (0,esm/* default */.A)({
|
||
|
mixedString: (0,build_module.__)('All customers with names that include {{query /}}', 'woocommerce'),
|
||
|
components: {
|
||
|
query: (0,react.createElement)("strong", {
|
||
|
className: "components-form-token-field__suggestion-match"
|
||
|
}, query)
|
||
|
}
|
||
|
}));
|
||
|
var nameOption = {
|
||
|
key: 'name',
|
||
|
label: label,
|
||
|
value: {
|
||
|
id: query,
|
||
|
name: query
|
||
|
}
|
||
|
};
|
||
|
return [nameOption];
|
||
|
},
|
||
|
getOptionLabel: function getOptionLabel(customer, query) {
|
||
|
var match = computeSuggestionMatch(customer.name, query);
|
||
|
return (0,react.createElement)("span", {
|
||
|
key: "name",
|
||
|
className: "woocommerce-search__result-name",
|
||
|
"aria-label": customer.name
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionBeforeMatch, (0,react.createElement)("strong", {
|
||
|
className: "components-form-token-field__suggestion-match"
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionMatch), match === null || match === void 0 ? void 0 : match.suggestionAfterMatch);
|
||
|
},
|
||
|
// This is slightly different than gutenberg/Autocomplete, we don't support different methods
|
||
|
// of replace/insertion, so we can just return the value.
|
||
|
getOptionCompletion: function getOptionCompletion(customer) {
|
||
|
return {
|
||
|
key: customer.id,
|
||
|
label: customer.name
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
/* harmony default export */ const customers = (customers_completer);
|
||
|
;// CONCATENATED MODULE: ../../packages/js/components/src/search/autocompleters/download-ips.tsx
|
||
|
|
||
|
/**
|
||
|
* External dependencies
|
||
|
*/
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Internal dependencies
|
||
|
*/
|
||
|
|
||
|
var download_ips_completer = {
|
||
|
name: 'download-ips',
|
||
|
className: 'woocommerce-search__download-ip-result',
|
||
|
options: function options(match) {
|
||
|
var query = match ? {
|
||
|
match: match
|
||
|
} : {};
|
||
|
return (0,api_fetch_build_module/* default */.A)({
|
||
|
path: (0,add_query_args/* addQueryArgs */.F)('/wc-analytics/data/download-ips', query)
|
||
|
});
|
||
|
},
|
||
|
isDebounced: true,
|
||
|
getOptionIdentifier: function getOptionIdentifier(download) {
|
||
|
return download.user_ip_address;
|
||
|
},
|
||
|
getOptionKeywords: function getOptionKeywords(download) {
|
||
|
return [download.user_ip_address];
|
||
|
},
|
||
|
getOptionLabel: function getOptionLabel(download, query) {
|
||
|
var match = computeSuggestionMatch(download.user_ip_address, query);
|
||
|
return (0,react.createElement)("span", {
|
||
|
key: "name",
|
||
|
className: "woocommerce-search__result-name",
|
||
|
"aria-label": download.user_ip_address
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionBeforeMatch, (0,react.createElement)("strong", {
|
||
|
className: "components-form-token-field__suggestion-match"
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionMatch), match === null || match === void 0 ? void 0 : match.suggestionAfterMatch);
|
||
|
},
|
||
|
getOptionCompletion: function getOptionCompletion(download) {
|
||
|
return {
|
||
|
key: download.user_ip_address,
|
||
|
label: download.user_ip_address
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
/* harmony default export */ const download_ips = (download_ips_completer);
|
||
|
;// CONCATENATED MODULE: ../../packages/js/components/src/search/autocompleters/emails.tsx
|
||
|
|
||
|
/**
|
||
|
* External dependencies
|
||
|
*/
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Internal dependencies
|
||
|
*/
|
||
|
|
||
|
var emails_completer = {
|
||
|
name: 'emails',
|
||
|
className: 'woocommerce-search__emails-result',
|
||
|
options: function options(search) {
|
||
|
var query = search ? {
|
||
|
search: search,
|
||
|
searchby: 'email',
|
||
|
per_page: 10
|
||
|
} : {};
|
||
|
return (0,api_fetch_build_module/* default */.A)({
|
||
|
path: (0,add_query_args/* addQueryArgs */.F)('/wc-analytics/customers', query)
|
||
|
});
|
||
|
},
|
||
|
isDebounced: true,
|
||
|
getOptionIdentifier: function getOptionIdentifier(customer) {
|
||
|
return customer.id;
|
||
|
},
|
||
|
getOptionKeywords: function getOptionKeywords(customer) {
|
||
|
return [customer.email];
|
||
|
},
|
||
|
getOptionLabel: function getOptionLabel(customer, query) {
|
||
|
var match = computeSuggestionMatch(customer.email, query);
|
||
|
return (0,react.createElement)("span", {
|
||
|
key: "name",
|
||
|
className: "woocommerce-search__result-name",
|
||
|
"aria-label": customer.email
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionBeforeMatch, (0,react.createElement)("strong", {
|
||
|
className: "components-form-token-field__suggestion-match"
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionMatch), match === null || match === void 0 ? void 0 : match.suggestionAfterMatch);
|
||
|
},
|
||
|
// This is slightly different than gutenberg/Autocomplete, we don't support different methods
|
||
|
// of replace/insertion, so we can just return the value.
|
||
|
getOptionCompletion: function getOptionCompletion(customer) {
|
||
|
return {
|
||
|
key: customer.id,
|
||
|
label: customer.email
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
/* harmony default export */ const emails = (emails_completer);
|
||
|
;// CONCATENATED MODULE: ../../packages/js/components/src/search/autocompleters/orders.tsx
|
||
|
|
||
|
/**
|
||
|
* External dependencies
|
||
|
*/
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Internal dependencies
|
||
|
*/
|
||
|
|
||
|
var orders_completer = {
|
||
|
name: 'orders',
|
||
|
className: 'woocommerce-search__order-result',
|
||
|
options: function options(search) {
|
||
|
var query = search ? {
|
||
|
number: search,
|
||
|
per_page: 10
|
||
|
} : {};
|
||
|
return (0,api_fetch_build_module/* default */.A)({
|
||
|
path: (0,add_query_args/* addQueryArgs */.F)('/wc-analytics/orders', query)
|
||
|
});
|
||
|
},
|
||
|
isDebounced: true,
|
||
|
getOptionIdentifier: function getOptionIdentifier(order) {
|
||
|
return order.id;
|
||
|
},
|
||
|
getOptionKeywords: function getOptionKeywords(order) {
|
||
|
return ['#' + order.number];
|
||
|
},
|
||
|
getOptionLabel: function getOptionLabel(order, query) {
|
||
|
var match = computeSuggestionMatch('#' + order.number, query);
|
||
|
return (0,react.createElement)("span", {
|
||
|
key: "name",
|
||
|
className: "woocommerce-search__result-name",
|
||
|
"aria-label": '#' + order.number
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionBeforeMatch, (0,react.createElement)("strong", {
|
||
|
className: "components-form-token-field__suggestion-match"
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionMatch), match === null || match === void 0 ? void 0 : match.suggestionAfterMatch);
|
||
|
},
|
||
|
getOptionCompletion: function getOptionCompletion(order) {
|
||
|
return {
|
||
|
key: order.id,
|
||
|
label: '#' + order.number
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
/* harmony default export */ const orders = (orders_completer);
|
||
|
// EXTERNAL MODULE: ../../packages/js/components/src/product-image/index.tsx + 1 modules
|
||
|
var product_image = __webpack_require__("../../packages/js/components/src/product-image/index.tsx");
|
||
|
;// CONCATENATED MODULE: ../../packages/js/components/src/search/autocompleters/product.tsx
|
||
|
|
||
|
|
||
|
/**
|
||
|
* External dependencies
|
||
|
*/
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Internal dependencies
|
||
|
*/
|
||
|
|
||
|
|
||
|
var product_completer = {
|
||
|
name: 'products',
|
||
|
className: 'woocommerce-search__product-result',
|
||
|
options: function options(search) {
|
||
|
var query = search ? {
|
||
|
search: search,
|
||
|
per_page: 10,
|
||
|
orderby: 'popularity'
|
||
|
} : {};
|
||
|
return (0,api_fetch_build_module/* default */.A)({
|
||
|
path: (0,add_query_args/* addQueryArgs */.F)('/wc-analytics/products', query)
|
||
|
});
|
||
|
},
|
||
|
isDebounced: true,
|
||
|
getOptionIdentifier: function getOptionIdentifier(product) {
|
||
|
return product.id;
|
||
|
},
|
||
|
getOptionKeywords: function getOptionKeywords(product) {
|
||
|
return [product.name, product.sku];
|
||
|
},
|
||
|
getFreeTextOptions: function getFreeTextOptions(query) {
|
||
|
var label = (0,react.createElement)("span", {
|
||
|
key: "name",
|
||
|
className: "woocommerce-search__result-name"
|
||
|
}, (0,esm/* default */.A)({
|
||
|
mixedString: (0,build_module.__)('All products with titles that include {{query /}}', 'woocommerce'),
|
||
|
components: {
|
||
|
query: (0,react.createElement)("strong", {
|
||
|
className: "components-form-token-field__suggestion-match"
|
||
|
}, query)
|
||
|
}
|
||
|
}));
|
||
|
var titleOption = {
|
||
|
key: 'title',
|
||
|
label: label,
|
||
|
value: {
|
||
|
id: query,
|
||
|
name: query
|
||
|
}
|
||
|
};
|
||
|
return [titleOption];
|
||
|
},
|
||
|
getOptionLabel: function getOptionLabel(product, query) {
|
||
|
var match = computeSuggestionMatch(product.name, query);
|
||
|
return (0,react.createElement)(react.Fragment, null, (0,react.createElement)(product_image/* default */.A, {
|
||
|
key: "thumbnail",
|
||
|
className: "woocommerce-search__result-thumbnail",
|
||
|
product: product,
|
||
|
width: 18,
|
||
|
height: 18,
|
||
|
alt: ""
|
||
|
}), (0,react.createElement)("span", {
|
||
|
key: "name",
|
||
|
className: "woocommerce-search__result-name",
|
||
|
"aria-label": product.name
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionBeforeMatch, (0,react.createElement)("strong", {
|
||
|
className: "components-form-token-field__suggestion-match"
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionMatch), match === null || match === void 0 ? void 0 : match.suggestionAfterMatch));
|
||
|
},
|
||
|
// This is slightly different than gutenberg/Autocomplete, we don't support different methods
|
||
|
// of replace/insertion, so we can just return the value.
|
||
|
getOptionCompletion: function getOptionCompletion(product) {
|
||
|
var value = {
|
||
|
key: product.id,
|
||
|
label: product.name
|
||
|
};
|
||
|
return value;
|
||
|
}
|
||
|
};
|
||
|
/* harmony default export */ const product = (product_completer);
|
||
|
;// CONCATENATED MODULE: ../../packages/js/components/src/search/autocompleters/taxes.tsx
|
||
|
|
||
|
/**
|
||
|
* External dependencies
|
||
|
*/
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Internal dependencies
|
||
|
*/
|
||
|
|
||
|
var taxes_completer = {
|
||
|
name: 'taxes',
|
||
|
className: 'woocommerce-search__tax-result',
|
||
|
options: function options(search) {
|
||
|
var query = search ? {
|
||
|
code: search,
|
||
|
per_page: 10
|
||
|
} : {};
|
||
|
return (0,api_fetch_build_module/* default */.A)({
|
||
|
path: (0,add_query_args/* addQueryArgs */.F)('/wc-analytics/taxes', query)
|
||
|
});
|
||
|
},
|
||
|
isDebounced: true,
|
||
|
getOptionIdentifier: function getOptionIdentifier(tax) {
|
||
|
return tax.id;
|
||
|
},
|
||
|
getOptionKeywords: function getOptionKeywords(tax) {
|
||
|
return [tax.id, getTaxCode(tax)];
|
||
|
},
|
||
|
getFreeTextOptions: function getFreeTextOptions(query) {
|
||
|
var label = (0,react.createElement)("span", {
|
||
|
key: "name",
|
||
|
className: "woocommerce-search__result-name"
|
||
|
}, (0,esm/* default */.A)({
|
||
|
mixedString: (0,build_module.__)('All taxes with codes that include {{query /}}', 'woocommerce'),
|
||
|
components: {
|
||
|
query: (0,react.createElement)("strong", {
|
||
|
className: "components-form-token-field__suggestion-match"
|
||
|
}, query)
|
||
|
}
|
||
|
}));
|
||
|
var codeOption = {
|
||
|
key: 'code',
|
||
|
label: label,
|
||
|
value: {
|
||
|
id: query,
|
||
|
name: query
|
||
|
}
|
||
|
};
|
||
|
return [codeOption];
|
||
|
},
|
||
|
getOptionLabel: function getOptionLabel(tax, query) {
|
||
|
var match = computeSuggestionMatch(getTaxCode(tax), query);
|
||
|
return (0,react.createElement)("span", {
|
||
|
key: "name",
|
||
|
className: "woocommerce-search__result-name",
|
||
|
"aria-label": tax.code
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionBeforeMatch, (0,react.createElement)("strong", {
|
||
|
className: "components-form-token-field__suggestion-match"
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionMatch), match === null || match === void 0 ? void 0 : match.suggestionAfterMatch);
|
||
|
},
|
||
|
// This is slightly different than gutenberg/Autocomplete, we don't support different methods
|
||
|
// of replace/insertion, so we can just return the value.
|
||
|
getOptionCompletion: function getOptionCompletion(tax) {
|
||
|
var value = {
|
||
|
key: tax.id,
|
||
|
label: getTaxCode(tax)
|
||
|
};
|
||
|
return value;
|
||
|
}
|
||
|
};
|
||
|
/* harmony default export */ const taxes = (taxes_completer);
|
||
|
;// CONCATENATED MODULE: ../../packages/js/components/src/search/autocompleters/usernames.tsx
|
||
|
|
||
|
/**
|
||
|
* External dependencies
|
||
|
*/
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Internal dependencies
|
||
|
*/
|
||
|
|
||
|
var usernames_completer = {
|
||
|
name: 'usernames',
|
||
|
className: 'woocommerce-search__usernames-result',
|
||
|
options: function options(search) {
|
||
|
var query = search ? {
|
||
|
search: search,
|
||
|
searchby: 'username',
|
||
|
per_page: 10
|
||
|
} : {};
|
||
|
return (0,api_fetch_build_module/* default */.A)({
|
||
|
path: (0,add_query_args/* addQueryArgs */.F)('/wc-analytics/customers', query)
|
||
|
});
|
||
|
},
|
||
|
isDebounced: true,
|
||
|
getOptionIdentifier: function getOptionIdentifier(customer) {
|
||
|
return customer.id;
|
||
|
},
|
||
|
getOptionKeywords: function getOptionKeywords(customer) {
|
||
|
return [customer.username];
|
||
|
},
|
||
|
getOptionLabel: function getOptionLabel(customer, query) {
|
||
|
var match = computeSuggestionMatch(customer.username, query);
|
||
|
return (0,react.createElement)("span", {
|
||
|
key: "name",
|
||
|
className: "woocommerce-search__result-name",
|
||
|
"aria-label": customer.username
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionBeforeMatch, (0,react.createElement)("strong", {
|
||
|
className: "components-form-token-field__suggestion-match"
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionMatch), match === null || match === void 0 ? void 0 : match.suggestionAfterMatch);
|
||
|
},
|
||
|
// This is slightly different than gutenberg/Autocomplete, we don't support different methods
|
||
|
// of replace/insertion, so we can just return the value.
|
||
|
getOptionCompletion: function getOptionCompletion(customer) {
|
||
|
return {
|
||
|
key: customer.id,
|
||
|
label: customer.username
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
/* harmony default export */ const usernames = (usernames_completer);
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.keys.js
|
||
|
var es_object_keys = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.keys.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.symbol.js
|
||
|
var es_symbol = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.symbol.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.get-own-property-descriptor.js
|
||
|
var es_object_get_own_property_descriptor = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.get-own-property-descriptor.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.get-own-property-descriptors.js
|
||
|
var es_object_get_own_property_descriptors = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.get-own-property-descriptors.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.define-properties.js
|
||
|
var es_object_define_properties = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.define-properties.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.define-property.js
|
||
|
var es_object_define_property = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.object.define-property.js");
|
||
|
;// CONCATENATED MODULE: ../../packages/js/components/src/search/autocompleters/variable-product.tsx
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
function ownKeys(e, r) {
|
||
|
var t = Object.keys(e);
|
||
|
if (Object.getOwnPropertySymbols) {
|
||
|
var o = Object.getOwnPropertySymbols(e);
|
||
|
r && (o = o.filter(function (r) {
|
||
|
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
||
|
})), t.push.apply(t, o);
|
||
|
}
|
||
|
return t;
|
||
|
}
|
||
|
function _objectSpread(e) {
|
||
|
for (var r = 1; r < arguments.length; r++) {
|
||
|
var t = null != arguments[r] ? arguments[r] : {};
|
||
|
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
||
|
(0,defineProperty/* default */.A)(e, r, t[r]);
|
||
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
||
|
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
||
|
});
|
||
|
}
|
||
|
return e;
|
||
|
}
|
||
|
/**
|
||
|
* External dependencies
|
||
|
*/
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Internal dependencies
|
||
|
*/
|
||
|
|
||
|
var variable_product_completer = _objectSpread(_objectSpread({}, product), {}, {
|
||
|
name: 'products',
|
||
|
options: function options(search) {
|
||
|
var query = search ? {
|
||
|
search: search,
|
||
|
per_page: 10,
|
||
|
orderby: 'popularity',
|
||
|
type: 'variable'
|
||
|
} : {};
|
||
|
return (0,api_fetch_build_module/* default */.A)({
|
||
|
path: (0,add_query_args/* addQueryArgs */.F)('/wc-analytics/products', query)
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
/* harmony default export */ const variable_product = (variable_product_completer);
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.includes.js
|
||
|
var es_array_includes = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.array.includes.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.string.includes.js
|
||
|
var es_string_includes = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.string.includes.js");
|
||
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.symbol.description.js
|
||
|
var es_symbol_description = __webpack_require__("../../node_modules/.pnpm/core-js@3.34.0/node_modules/core-js/modules/es.symbol.description.js");
|
||
|
// EXTERNAL MODULE: ../../packages/js/navigation/src/index.js + 3 modules
|
||
|
var src = __webpack_require__("../../packages/js/navigation/src/index.js");
|
||
|
;// CONCATENATED MODULE: ../../packages/js/components/src/search/autocompleters/variations.tsx
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* External dependencies
|
||
|
*/
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Internal dependencies
|
||
|
*/
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Create a variation name by concatenating each of the variation's
|
||
|
* attribute option strings.
|
||
|
*
|
||
|
* @param {Object} variation - variation returned by the api
|
||
|
* @param {Array} variation.attributes - attribute objects, with option property.
|
||
|
* @param {string} variation.name - name of variation.
|
||
|
* @return {string} - formatted variation name
|
||
|
*/
|
||
|
function getVariationName(_ref) {
|
||
|
var attributes = _ref.attributes,
|
||
|
name = _ref.name;
|
||
|
var separator = window.wcSettings.variationTitleAttributesSeparator || ' - ';
|
||
|
if (name.indexOf(separator) > -1) {
|
||
|
return name;
|
||
|
}
|
||
|
var attributeList = attributes.map(function (_ref2) {
|
||
|
var option = _ref2.option;
|
||
|
return option;
|
||
|
}).join(', ');
|
||
|
return attributeList ? name + separator + attributeList : name;
|
||
|
}
|
||
|
var variations_completer = {
|
||
|
name: 'variations',
|
||
|
className: 'woocommerce-search__product-result',
|
||
|
options: function options(search) {
|
||
|
var query = search ? {
|
||
|
search: search,
|
||
|
per_page: 30,
|
||
|
_fields: ['attributes', 'description', 'id', 'name', 'sku']
|
||
|
} : {};
|
||
|
var product = (0,src/* getQuery */.$Z)().products;
|
||
|
|
||
|
// Product was specified, search only its variations.
|
||
|
if (product) {
|
||
|
if (product.includes(',')) {
|
||
|
// eslint-disable-next-line no-console
|
||
|
console.warn('Invalid product id supplied to Variations autocompleter');
|
||
|
}
|
||
|
return (0,api_fetch_build_module/* default */.A)({
|
||
|
path: (0,add_query_args/* addQueryArgs */.F)("/wc-analytics/products/".concat(product, "/variations"), query)
|
||
|
});
|
||
|
}
|
||
|
|
||
|
// Product was not specified, search all variations.
|
||
|
return (0,api_fetch_build_module/* default */.A)({
|
||
|
path: (0,add_query_args/* addQueryArgs */.F)('/wc-analytics/variations', query)
|
||
|
});
|
||
|
},
|
||
|
isDebounced: true,
|
||
|
getOptionIdentifier: function getOptionIdentifier(variation) {
|
||
|
return variation.id;
|
||
|
},
|
||
|
getOptionKeywords: function getOptionKeywords(variation) {
|
||
|
return [getVariationName(variation), variation.sku];
|
||
|
},
|
||
|
getOptionLabel: function getOptionLabel(variation, query) {
|
||
|
var match = computeSuggestionMatch(getVariationName(variation), query);
|
||
|
return (0,react.createElement)(react.Fragment, null, (0,react.createElement)(product_image/* default */.A, {
|
||
|
key: "thumbnail",
|
||
|
className: "woocommerce-search__result-thumbnail",
|
||
|
product: variation,
|
||
|
width: 18,
|
||
|
height: 18,
|
||
|
alt: ""
|
||
|
}), (0,react.createElement)("span", {
|
||
|
key: "name",
|
||
|
className: "woocommerce-search__result-name",
|
||
|
"aria-label": variation.description
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionBeforeMatch, (0,react.createElement)("strong", {
|
||
|
className: "components-form-token-field__suggestion-match"
|
||
|
}, match === null || match === void 0 ? void 0 : match.suggestionMatch), match === null || match === void 0 ? void 0 : match.suggestionAfterMatch));
|
||
|
},
|
||
|
// This is slightly different than gutenberg/Autocomplete, we don't support different methods
|
||
|
// of replace/insertion, so we can just return the value.
|
||
|
getOptionCompletion: function getOptionCompletion(variation) {
|
||
|
return {
|
||
|
key: variation.id,
|
||
|
label: getVariationName(variation)
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
/* harmony default export */ const variations = (variations_completer);
|
||
|
;// CONCATENATED MODULE: ../../packages/js/components/src/search/index.tsx
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
function _createSuper(Derived) {
|
||
|
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
||
|
return function _createSuperInternal() {
|
||
|
var Super = (0,getPrototypeOf/* default */.A)(Derived),
|
||
|
result;
|
||
|
if (hasNativeReflectConstruct) {
|
||
|
var NewTarget = (0,getPrototypeOf/* default */.A)(this).constructor;
|
||
|
result = Reflect.construct(Super, arguments, NewTarget);
|
||
|
} else {
|
||
|
result = Super.apply(this, arguments);
|
||
|
}
|
||
|
return (0,possibleConstructorReturn/* default */.A)(this, result);
|
||
|
};
|
||
|
}
|
||
|
function _isNativeReflectConstruct() {
|
||
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
||
|
if (Reflect.construct.sham) return false;
|
||
|
if (typeof Proxy === "function") return true;
|
||
|
try {
|
||
|
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
||
|
return true;
|
||
|
} catch (e) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
/**
|
||
|
* External dependencies
|
||
|
*/
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Internal dependencies
|
||
|
*/
|
||
|
|
||
|
|
||
|
/**
|
||
|
* A search box which autocompletes results while typing, allowing for the user to select an existing object
|
||
|
* (product, order, customer, etc). Currently only products are supported.
|
||
|
*/
|
||
|
var Search = /*#__PURE__*/function (_Component) {
|
||
|
(0,inherits/* default */.A)(Search, _Component);
|
||
|
var _super = _createSuper(Search);
|
||
|
function Search(props) {
|
||
|
var _this;
|
||
|
(0,classCallCheck/* default */.A)(this, Search);
|
||
|
_this = _super.call(this, props);
|
||
|
_this.state = {
|
||
|
options: []
|
||
|
};
|
||
|
_this.appendFreeTextSearch = _this.appendFreeTextSearch.bind((0,assertThisInitialized/* default */.A)(_this));
|
||
|
_this.fetchOptions = _this.fetchOptions.bind((0,assertThisInitialized/* default */.A)(_this));
|
||
|
_this.updateSelected = _this.updateSelected.bind((0,assertThisInitialized/* default */.A)(_this));
|
||
|
return _this;
|
||
|
}
|
||
|
(0,createClass/* default */.A)(Search, [{
|
||
|
key: "getAutocompleter",
|
||
|
value: function getAutocompleter() {
|
||
|
switch (this.props.type) {
|
||
|
case 'attributes':
|
||
|
return attributes;
|
||
|
case 'categories':
|
||
|
return categories;
|
||
|
case 'countries':
|
||
|
return countries;
|
||
|
case 'coupons':
|
||
|
return coupons;
|
||
|
case 'customers':
|
||
|
return customers;
|
||
|
case 'downloadIps':
|
||
|
return download_ips;
|
||
|
case 'emails':
|
||
|
return emails;
|
||
|
case 'orders':
|
||
|
return orders;
|
||
|
case 'products':
|
||
|
return product;
|
||
|
case 'taxes':
|
||
|
return taxes;
|
||
|
case 'usernames':
|
||
|
return usernames;
|
||
|
case 'variableProducts':
|
||
|
return variable_product;
|
||
|
case 'variations':
|
||
|
return variations;
|
||
|
case 'custom':
|
||
|
if (!this.props.autocompleter || (0,esm_typeof/* default */.A)(this.props.autocompleter) !== 'object') {
|
||
|
throw new Error("Invalid autocompleter provided to Search component, it requires a completer object when using 'custom' type.");
|
||
|
}
|
||
|
return this.props.autocompleter;
|
||
|
default:
|
||
|
throw new Error("No autocompleter found for type: ".concat(this.props.type));
|
||
|
}
|
||
|
}
|
||
|
}, {
|
||
|
key: "getFormattedOptions",
|
||
|
value: function getFormattedOptions(options, query) {
|
||
|
var autocompleter = this.getAutocompleter();
|
||
|
var formattedOptions = [];
|
||
|
options.forEach(function (option) {
|
||
|
var formattedOption = {
|
||
|
key: autocompleter.getOptionIdentifier(option),
|
||
|
label: autocompleter.getOptionLabel(option, query),
|
||
|
keywords: autocompleter.getOptionKeywords(option).filter(Boolean),
|
||
|
value: option
|
||
|
};
|
||
|
formattedOptions.push(formattedOption);
|
||
|
});
|
||
|
return formattedOptions;
|
||
|
}
|
||
|
}, {
|
||
|
key: "fetchOptions",
|
||
|
value: function fetchOptions(previousOptions, query) {
|
||
|
var _this2 = this;
|
||
|
if (!query) {
|
||
|
return [];
|
||
|
}
|
||
|
var autocompleterOptions = this.getAutocompleter().options;
|
||
|
|
||
|
// Support arrays, sync- & async functions that returns an array.
|
||
|
var resolvedOptions = Promise.resolve(typeof autocompleterOptions === 'function' ? autocompleterOptions(query) : autocompleterOptions || []);
|
||
|
return resolvedOptions.then( /*#__PURE__*/function () {
|
||
|
var _ref = (0,asyncToGenerator/* default */.A)( /*#__PURE__*/regenerator_default().mark(function _callee(response) {
|
||
|
var options;
|
||
|
return regenerator_default().wrap(function _callee$(_context) {
|
||
|
while (1) switch (_context.prev = _context.next) {
|
||
|
case 0:
|
||
|
options = _this2.getFormattedOptions(response, query);
|
||
|
_this2.setState({
|
||
|
options: options
|
||
|
});
|
||
|
return _context.abrupt("return", options);
|
||
|
case 3:
|
||
|
case "end":
|
||
|
return _context.stop();
|
||
|
}
|
||
|
}, _callee);
|
||
|
}));
|
||
|
return function (_x) {
|
||
|
return _ref.apply(this, arguments);
|
||
|
};
|
||
|
}());
|
||
|
}
|
||
|
}, {
|
||
|
key: "updateSelected",
|
||
|
value: function updateSelected(selected) {
|
||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||
|
var _this$props$onChange = this.props.onChange,
|
||
|
onChange = _this$props$onChange === void 0 ? function (_option) {} : _this$props$onChange;
|
||
|
var autocompleter = this.getAutocompleter();
|
||
|
var formattedSelections = selected.map(function (option) {
|
||
|
return option.value ? autocompleter.getOptionCompletion(option.value) : option;
|
||
|
});
|
||
|
onChange(formattedSelections);
|
||
|
}
|
||
|
}, {
|
||
|
key: "appendFreeTextSearch",
|
||
|
value: function appendFreeTextSearch(options, query) {
|
||
|
var allowFreeTextSearch = this.props.allowFreeTextSearch;
|
||
|
if (!query || !query.length) {
|
||
|
return [];
|
||
|
}
|
||
|
var autocompleter = this.getAutocompleter();
|
||
|
if (!allowFreeTextSearch || typeof autocompleter.getFreeTextOptions !== 'function') {
|
||
|
return options;
|
||
|
}
|
||
|
return [].concat((0,toConsumableArray/* default */.A)(autocompleter.getFreeTextOptions(query)), (0,toConsumableArray/* default */.A)(options));
|
||
|
}
|
||
|
}, {
|
||
|
key: "render",
|
||
|
value: function render() {
|
||
|
var autocompleter = this.getAutocompleter();
|
||
|
var _this$props = this.props,
|
||
|
className = _this$props.className,
|
||
|
inlineTags = _this$props.inlineTags,
|
||
|
placeholder = _this$props.placeholder,
|
||
|
selected = _this$props.selected,
|
||
|
showClearButton = _this$props.showClearButton,
|
||
|
staticResults = _this$props.staticResults,
|
||
|
disabled = _this$props.disabled,
|
||
|
multiple = _this$props.multiple;
|
||
|
var options = this.state.options;
|
||
|
var inputType = autocompleter.inputType ? autocompleter.inputType : 'text';
|
||
|
return (0,react.createElement)("div", null, (0,react.createElement)(select_control/* default */.A, {
|
||
|
className: classnames_default()('woocommerce-search', className, {
|
||
|
'is-static-results': staticResults
|
||
|
}),
|
||
|
disabled: disabled,
|
||
|
hideBeforeSearch: true,
|
||
|
inlineTags: inlineTags,
|
||
|
isSearchable: true,
|
||
|
getSearchExpression: autocompleter.getSearchExpression,
|
||
|
multiple: multiple,
|
||
|
placeholder: placeholder,
|
||
|
onChange: this.updateSelected,
|
||
|
onFilter: this.appendFreeTextSearch,
|
||
|
onSearch: this.fetchOptions,
|
||
|
options: options,
|
||
|
searchDebounceTime: 500,
|
||
|
searchInputType: inputType,
|
||
|
selected: selected,
|
||
|
showClearButton: showClearButton
|
||
|
}));
|
||
|
}
|
||
|
}]);
|
||
|
return Search;
|
||
|
}(react.Component);
|
||
|
(0,defineProperty/* default */.A)(Search, "propTypes", {
|
||
|
/**
|
||
|
* Render additional options in the autocompleter to allow free text entering depending on the type.
|
||
|
*/
|
||
|
allowFreeTextSearch: (prop_types_default()).bool,
|
||
|
/**
|
||
|
* Class name applied to parent div.
|
||
|
*/
|
||
|
className: (prop_types_default()).string,
|
||
|
/**
|
||
|
* Function called when selected results change, passed result list.
|
||
|
*/
|
||
|
onChange: (prop_types_default()).func,
|
||
|
/**
|
||
|
* The object type to be used in searching.
|
||
|
*/
|
||
|
type: prop_types_default().oneOf(['attributes', 'categories', 'countries', 'coupons', 'customers', 'downloadIps', 'emails', 'orders', 'products', 'taxes', 'usernames', 'variableProducts', 'variations', 'custom']).isRequired,
|
||
|
/**
|
||
|
* The custom autocompleter to be used in searching when type is 'custom'
|
||
|
*/
|
||
|
autocompleter: (prop_types_default()).object,
|
||
|
/**
|
||
|
* A placeholder for the search input.
|
||
|
*/
|
||
|
placeholder: (prop_types_default()).string,
|
||
|
/**
|
||
|
* An array of objects describing selected values or optionally a string for a single value.
|
||
|
* If the label of the selected value is omitted, the Tag of that value will not
|
||
|
* be rendered inside the search box.
|
||
|
*/
|
||
|
selected: prop_types_default().oneOfType([(prop_types_default()).string, prop_types_default().arrayOf(prop_types_default().shape({
|
||
|
key: prop_types_default().oneOfType([(prop_types_default()).number, (prop_types_default()).string]).isRequired,
|
||
|
label: (prop_types_default()).string
|
||
|
}))]),
|
||
|
/**
|
||
|
* Render tags inside input, otherwise render below input.
|
||
|
*/
|
||
|
inlineTags: (prop_types_default()).bool,
|
||
|
/**
|
||
|
* Render a 'Clear' button next to the input box to remove its contents.
|
||
|
*/
|
||
|
showClearButton: (prop_types_default()).bool,
|
||
|
/**
|
||
|
* Render results list positioned statically instead of absolutely.
|
||
|
*/
|
||
|
staticResults: (prop_types_default()).bool,
|
||
|
/**
|
||
|
* Whether the control is disabled or not.
|
||
|
*/
|
||
|
disabled: (prop_types_default()).bool,
|
||
|
/**
|
||
|
* Allow multiple option selections.
|
||
|
*/
|
||
|
multiple: (prop_types_default()).bool
|
||
|
});
|
||
|
(0,defineProperty/* default */.A)(Search, "defaultProps", {
|
||
|
allowFreeTextSearch: false,
|
||
|
onChange: lodash.noop,
|
||
|
selected: [],
|
||
|
inlineTags: false,
|
||
|
showClearButton: false,
|
||
|
staticResults: false,
|
||
|
disabled: false,
|
||
|
multiple: true
|
||
|
});
|
||
|
/* harmony default export */ const search = (Search);
|
||
|
try {
|
||
|
// @ts-ignore
|
||
|
Search.displayName = "Search";
|
||
|
// @ts-ignore
|
||
|
Search.__docgenInfo = { "description": "A search box which autocompletes results while typing, allowing for the user to select an existing object\n(product, order, customer, etc). Currently only products are supported.", "displayName": "Search", "props": { "type": { "defaultValue": null, "description": "", "name": "type", "required": true, "type": { "name": "enum", "value": [{ "value": "\"products\"" }, { "value": "\"countries\"" }, { "value": "\"categories\"" }, { "value": "\"custom\"" }, { "value": "\"attributes\"" }, { "value": "\"coupons\"" }, { "value": "\"customers\"" }, { "value": "\"downloadIps\"" }, { "value": "\"emails\"" }, { "value": "\"orders\"" }, { "value": "\"taxes\"" }, { "value": "\"usernames\"" }, { "value": "\"variableProducts\"" }, { "value": "\"variations\"" }] } }, "allowFreeTextSearch": { "defaultValue": { value: "false" }, "description": "", "name": "allowFreeTextSearch", "required": false, "type": { "name": "boolean" } }, "className": { "defaultValue": null, "description": "", "name": "className", "required": false, "type": { "name": "string" } }, "onChange": { "defaultValue": null, "description": "", "name": "onChange", "required": false, "type": { "name": "((value: Option | OptionCompletionValue[]) => void)" } }, "autocompleter": { "defaultValue": null, "description": "", "name": "autocompleter", "required": false, "type": { "name": "AutoCompleter" } }, "placeholder": { "defaultValue": null, "description": "", "name": "placeholder", "required": false, "type": { "name": "string" } }, "selected": { "defaultValue": { value: "[]" }, "description": "", "name": "selected", "required": false, "type": { "name": "string | { key: string | number; label?: string; }[]" } }, "inlineTags": { "defaultValue": { value: "false" }, "description": "", "name": "inlineTags", "required": false, "type": { "name": "boolean" } }, "showClearButton": { "defaultValue": { value: "false" }, "description": "", "name": "showClearButton", "required": false, "type": { "name": "boolean" } }, "staticResults": { "defaultValue": { value: "false" }, "description": "", "name": "staticResults", "required": false, "type": { "name": "boolean" } }, "disabled": { "defaultValue": { value: "false" }, "description": "", "name": "disabled", "required": false, "type": { "name": "boolean" } }, "multiple": { "defaultValue": { value: "true" }, "description": "", "name": "multiple", "required": false, "type": { "name": "boolean" } } } };
|
||
|
// @ts-ignore
|
||
|
if (typeof STORYBOOK_REACT_CLASSES !== "undefined")
|
||
|
// @ts-ignore
|
||
|
STORYBOOK_REACT_CLASSES["../../packages/js/components/src/search/index.tsx#Search"] = { docgenInfo: Search.__docgenInfo, name: "Search", path: "../../packages/js/components/src/search/index.tsx#Search" };
|
||
|
}
|
||
|
catch (__react_docgen_typescript_loader_error) { }
|
||
|
|
||
|
/***/ })
|
||
|
|
||
|
}]);
|