UNPKG

akvo-react-form-editor

Version:
1,686 lines (1,522 loc) 446 kB
import React__default, { createContext, useContext, useEffect, forwardRef, createElement, useMemo, useState, useCallback } from 'react'; import 'antd/dist/antd.min.css'; import { Form, Row, Col, Button, Space, Tag, Typography, Modal, Input, Card, Select, Divider, Checkbox, InputNumber, Radio, DatePicker, AutoComplete, Alert, Tooltip, Tabs, notification } from 'antd'; import { Store } from 'pullstate'; import { all } from 'locale-codes'; import uniqBy from 'lodash/uniqBy'; import snakeCase$1 from 'lodash/snakeCase'; import { TbEditOff, TbEdit } from 'react-icons/tb'; import { RiDeleteBin2Line, RiSave3Fill, RiSettings5Fill, RiSettings5Line } from 'react-icons/ri'; import { BiMove, BiCopy } from 'react-icons/bi'; import { MdOutlineAddCircleOutline, MdOutlineRemoveCircleOutline, MdOutlineArrowCircleUp, MdOutlineArrowCircleDown, MdOutlineLanguage } from 'react-icons/md'; import { AiOutlineEyeInvisible, AiOutlineEye, AiOutlineCopy, AiOutlineQuestionCircle } from 'react-icons/ai'; import { isEmpty, mapKeys, orderBy, findIndex, intersection, uniq, difference, takeRight, snakeCase as snakeCase$2, map, groupBy, maxBy, minBy } from 'lodash'; import orderBy$1 from 'lodash/orderBy'; import 'akvo-react-form/dist/index.css'; import { Webform } from 'akvo-react-form'; import { SketchPicker } from 'react-color'; import isEmpty$1 from 'lodash/isEmpty'; import { VscPreview } from 'react-icons/vsc'; function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } var styles = {"container":"arfe-container","form-definition":"arfe-form-definition","form-item-no-bottom-margin":"arfe-form-item-no-bottom-margin","input-checkbox-wrapper":"arfe-input-checkbox-wrapper","button-icon":"arfe-button-icon","reorder-wrapper":"arfe-reorder-wrapper","reorder-button":"arfe-reorder-button","select-dropdown":"arfe-select-dropdown","tabs-wrapper":"arfe-tabs-wrapper","tabs-wrapper-sticky":"arfe-tabs-wrapper-sticky","right-tabs":"arfe-right-tabs","tab-pane-name-icon":"arfe-tab-pane-name-icon","question-group-title":"arfe-question-group-title","space-align-right":"arfe-space-align-right","space-align-left":"arfe-space-align-left","space-vertical-align-left":"arfe-space-vertical-align-left","space-vertical-align-right":"arfe-space-vertical-align-right","more-question-setting-text":"arfe-more-question-setting-text","dependant-list-box":"arfe-dependant-list-box","tags":"arfe-tags","tags-active":"arfe-tags-active","translation-form-item":"arfe-translation-form-item","translation-form-item-card":"arfe-translation-form-item-card","field-error-wrapper":"arfe-field-error-wrapper"}; var FormWrapper = function FormWrapper(_ref) { var children = _ref.children; var _Form$useForm = Form.useForm(), form = _Form$useForm[0]; var handleOnValuesChange = function handleOnValuesChange() {}; var handleOnFinish = function handleOnFinish() {}; var handleOnFinishFailed = function handleOnFinishFailed() {}; return /*#__PURE__*/React__default.createElement(Form, { form: form, key: "akvo-react-form-editor", name: "akvo-react-form-editor", layout: "vertical", onValuesChange: handleOnValuesChange, onFinish: handleOnFinish, onFinishFailed: handleOnFinishFailed }, children); }; var UIStaticText = { en: { inputFormNameLabel: 'Form Name', inputFormDescriptionLabel: 'Form Description', inputFormTranslationLabel: 'Add New Translation', inputFormExistingTranslationsLabel: 'Existing Translations', inputFormDefaultLanguageLabel: 'Default Language', formTabPane: 'Edit Form', formTranslationPane: 'Translations', previewTabPane: 'Preview', questionCount: 'Questions', questionGroupCount: 'Question Groups', mandatoryQuestionCount: 'Mandatory Questions', version: 'Version', inputQuestionGroupNameLabel: 'Question Group Name', inputQuestionGroupLabelLabel: 'Question Group Label', inputQuestionGroupDescriptionLabel: 'Question Group Description', inputRepeatThisGroupCheckbox: 'Repeat this group', inputRepeatTextLabel: 'Repeat Text', buttonShowQuestionsText: 'Show Questions', buttonHideQuestionsText: 'Hide Questions', buttonEditGroupText: 'Edit Group', buttonCancelEditGroupText: 'Cancel Edit Group', buttonDeleteText: 'Delete', buttonCancelText: 'Cancel', buttonAddNewQuestionGroupText: 'Insert group here', buttonCopyQuestionGroupText: 'Copy group here', buttonMoveQuestionGroupText: 'Move group here', buttonAddNewQuestionText: 'Add new question', buttonCopyQuestionText: 'Copy question here', buttonMoveQuestionText: 'Move question here', inputQuestionLabelLabel: 'Question Label', inputQuestionNameLabel: 'Question Name', inputQuestionTypeLabel: 'Question Type', inputQuestionVariableNameLabel: 'Variable Name', inputQuestionTooltipLabel: 'Question Tooltip', inputQuestionRequiredCheckbox: 'Required', inputQuestionMetaCheckbox: 'Data point name', inputQuestionMetaCheckboxHint: 'A string value that represents the name of the data point', buttonSaveText: 'Save', questionSettingTabPane: 'Setting', questionSkipLogicTabPane: 'Skip Logic', questionCustomParamsTabPane: 'Custom Params', questionExtraTabPane: 'Extra', inputQuestionDependentToLabel: 'Dependent to Question', inputQuestionDependentLogicLabel: 'Logic', inputQuestionDependentAnswerLabel: 'Value', questionMoreInputTypeSettingText: 'More Input Question Setting', inputQuestionRequireDoubleEntryCheckbox: 'Require double entry of answer', inputQuestionHiddenStringCheckbox: 'Hidden String/Password', questionMoreInputNumberSettingText: 'More Number Question Setting', inputQuestionAllowDecimalCheckbox: 'Allow Decimal', inputQuestionMinimumValueLabel: 'Minimum Value', inputQuestionMaximumValueLabel: 'Maximum Value', inputQuestionMinimumValidationText: 'Min value must be less than', inputQuestionMaximumValidationText: 'Max value must be greater than', inputQuestionEqualValueLabel: 'Equal Value', questionMoreOptionTypeSettingText: 'More Option Question Setting', questionMoreOptionTranslationText: 'Option Translations', inputQuestionAllowOtherCheckbox: 'Allow Other', inputQuestionAllowOtherTextLabel: 'Allow Other Text', inputQuestionOptionNameLabel: 'Option', questionMoreTreeSettingText: 'More Nested List Question Setting', inputSelectTreeDropdownValueLabel: 'Select Nested List Value', deleteQuestionGroupError: 'Unable to delete question group', deleteQuestionError: 'Unable to delete question', infoNoDependentQuestionText: 'No dependent questions', questionMoreCascadeSettingText: 'More Cascade Question Setting', inputQuestionEndpointLabel: 'Cascade Endpoint', inputQuestionEndpointValidationText: 'Invalid URL', inputQuestionInitialValueLabel: 'Initial Value', inputQuestionListCheckbox: 'Use Specific Object Name', inputQuestionListLabel: 'Object Name', questionMoreInputDateSettingText: 'More Date Question Setting', inputQuestionAfterDateValueLabel: 'After Date', inputQuestionBeforeDateValueLabel: 'Before Date', alertDeleteQuestionTitle: 'Delete Question', alertDeleteQuestion: 'Do you want to delete this question?', alertDeleteQuestionGroupTitle: 'Delete Question Group', alertDeleteQuestionGroup: 'Do you want to delete this question group and all the questions?', questionMoreTableTypeSettingText: 'More Table Question Setting', inputColumnNameLabel: 'Column Name', inputColumnTypeLabel: 'Column Type', inputColumnOptionsLabel: 'Column Options', questionTableTypeDefineOptionsText: 'Define Options', questionHintSettingText: 'Hint Setting', inputQuestionStaticValueLabel: 'Static Value', inputSelectHintEndpointLabel: 'Hint Endpoint', inputSelectHintPathLabel: 'Hint Path', inputQuestionHintButtonTextLabel: 'Hint Button Text', questionMoreImageTypeSettingText: 'More Image Question Setting', inputQuestionImageLimitValidationText: 'Limit / Max file size', questionMoreAutofieldTypeSettingText: 'More Autofield Question Setting', inputQuestionAutofieldMultiline: 'Support Multiline Function', inputQuestionAutofieldFnString: 'Add Function (String) Here', inputQuestionAutofieldFnColor: 'Add Function Color Here', questionStatsSettingTest: 'Stats Setting', inputStatsUrlText: 'Add Stats Endpoint Here', inpuStatsUrlValidationText: 'Invalid URL format', questionIdText: 'Question ID', copyQuestionIdToClipboardText: 'Copy Question ID', copiedText: 'Copied', validationErrorTitle: 'Validation Error', validationErrorDescription: 'Please fix all validation before save the form.', inputQuestionShortLabelLabel: 'Short Label', inputQuestionShortLabelTooltip: 'The value entered in the Sort Label field will be used as a replacement for the question label in the Excel export.', inputQuestionDisplayOnlyCheckbox: 'Display Only', inputQuestionDisplayOnlyCheckboxTooltip: 'If you check "Display Only", the answer value for this question will not be submitted.', evaluatefnStringButton: 'Evaluate Function', evaluatefnStringError: 'Error evaluating function string', evaluatefnStringSuccess: 'Function string evaluated correctly!', prefilledQuestionTitle: 'Would you like to add a prefill to this question?', prefilledYesText: 'Yes', prefilledNoText: 'No', prefilledSourceQuestion: 'Source Question', prefilledSQPlaceholder: 'Select source question', prefilledSourceAnswer: 'Source Answer', prefilledSAPlaceholder: 'Select source answer', prefilledDefaultValue: 'Default Value', prefilledDVPlaceholder: 'Select default value', addonBefore: 'AddonBefore', addonBeforePlaceholder: 'e.g., +62 or other required prefixes', addonAfter: 'AddonAfter', addonAfterPlaceholder: 'e.g., Kilogram, Unit, or any other necessary suffix.' } }; var fake = [ "Lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit", "Sed", "aliquet", "quis", "neque", "quis", "ultrices", "Nullam", "at", "ante", "lorem", "Fusce", "id", "mauris", "sed", "augue", "porta", "ultrices", "eu", "vitae", "mauris", "Fusce", "sed", "nisl", "eget", "augue", "commodo", "ullamcorper", "Phasellus", "lectus", "augue", "eleifend", "sit", "amet", "sapien", "sit", "amet", "tincidunt", "pretium", "nisl", "Donec", "tristique", "eleifend", "sapien", "blandit", "suscipit", "eros", "dapibus", "ac", "Aliquam", "facilisis", "ornare", "lorem", "at", "iaculis", "Duis", "consequat", "magna", "at", "tincidunt", "sodales", "Nam", "eu", "interdum", "augue" ]; var titleCase = function titleCase(str) { return str.replace(/\w\S*/g, function (txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); }); }; var getWords = function getWords() { return fake[Math.floor(Math.random() * fake.length)]; }; var dummyName = function dummyName(len) { if (len === void 0) { len = 2; } return Array.from('x'.repeat(len)).reduce(function (curr) { return curr + ' ' + getWords(); }, titleCase(getWords())); }; var localeDropdownValue = uniqBy(all.filter(function (x) { return x.location; }).map(function (x) { return { label: x.name, value: x['iso639-1'] }; }).filter(function (x) { return x.value; }), 'value'); var generateId = function generateId() { return new Date().getTime(); }; var questionType = { input: 'input', number: 'number', cascade: 'cascade', geo: 'geo', text: 'text', date: 'date', option: 'option', multiple_option: 'multiple_option', tree: 'tree', table: 'table', image: 'image', autofield: 'autofield' }; var defaultForm = function defaultForm() { return { id: generateId(), name: 'New Form', version: 1, description: 'New Form Description' }; }; var defaultQuestion = function defaultQuestion(_ref) { var questionGroup = _ref.questionGroup, label = _ref.label, name = _ref.name, _ref$prevOrder = _ref.prevOrder, prevOrder = _ref$prevOrder === void 0 ? 0 : _ref$prevOrder, _ref$type = _ref.type, type = _ref$type === void 0 ? questionType.input : _ref$type, _ref$required = _ref.required, required = _ref$required === void 0 ? false : _ref$required, _ref$params = _ref.params, params = _ref$params === void 0 ? {} : _ref$params; var labelTemp = label ? label : dummyName(5); var q = { id: generateId() + 2, order: prevOrder + 1, questionGroupId: questionGroup.id, label: labelTemp, name: name ? name : snakeCase$1(labelTemp), short_label: null, type: type, required: required, meta: false, tooltip: null, displayOnly: false, pre: {} }; if (type === questionType.option || type === questionType.multiple_option) { return _extends({}, q, { options: [], allowOther: false }); } if (type === questionType.cascade) { return _extends({}, q, { api: { endpoint: null, initial: 0, list: false } }); } return _extends({}, q, params); }; var defaultQuestionGroup = function defaultQuestionGroup(_ref2) { var _ref2$label = _ref2.label, label = _ref2$label === void 0 ? dummyName() : _ref2$label, name = _ref2.name, _ref2$prevOrder = _ref2.prevOrder, prevOrder = _ref2$prevOrder === void 0 ? 0 : _ref2$prevOrder, _ref2$defaultQuestion = _ref2.defaultQuestionParam, defaultQuestionParam = _ref2$defaultQuestion === void 0 ? {} : _ref2$defaultQuestion; var qg = { id: generateId() + 1, label: label, name: name ? name : snakeCase$1(label), order: prevOrder + 1, description: null, repeatable: false }; return _extends({}, qg, { questions: [defaultQuestion(_extends({ questionGroup: qg }, defaultQuestionParam))] }); }; var UIStore = new Store({ current: { tab: 'edit-form', formId: null, questionGroupId: null, questionId: null }, activeEditFormSetting: true, activeQuestionGroups: [], activeEditQuestionGroups: [], activeMoveQuestionGroup: null, isCopyingQuestionGroup: false, activeEditQuestions: [], activeMoveQuestion: null, isCopyingQuestion: false, UIText: UIStaticText.en, localeDropdownValue: localeDropdownValue, existingTranslation: null, activeTranslationQuestionGroups: [], activeEditTranslationQuestionGroups: [], activeEditTranslationQuestions: [], hostParams: {} }); var ErrorStore = new Store({ questionGroupErrors: [], questionErrors: [] }); var FormStore = new Store(_extends({}, defaultForm())); var QuestionGroupStore = new Store({ questionGroups: [defaultQuestionGroup({})] }); var formFn = { add: defaultForm, store: FormStore }; var questionGroupFn = { add: defaultQuestionGroup, store: QuestionGroupStore }; var questionFn = { add: defaultQuestion, update: function update(_ref3) { var id = _ref3.id, type = _ref3.type, questionGroup = _ref3.questionGroup, params = _ref3.params; return defaultQuestion(_extends({ id: id, type: type, questionGroup: questionGroup }, params)); } }; var IconContext = /*#__PURE__*/createContext({}); function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function _objectSpread2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; } function commonjsRequire () { throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs'); } var classnames = createCommonjsModule(function (module) { /*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames */ /* global define */ (function () { var hasOwn = {}.hasOwnProperty; function classNames() { var classes = []; for (var i = 0; i < arguments.length; i++) { var arg = arguments[i]; if (!arg) continue; var argType = typeof arg; if (argType === 'string' || argType === 'number') { classes.push(arg); } else if (Array.isArray(arg)) { if (arg.length) { var inner = classNames.apply(null, arg); if (inner) { classes.push(inner); } } } else if (argType === 'object') { if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) { classes.push(arg.toString()); continue; } for (var key in arg) { if (hasOwn.call(arg, key) && arg[key]) { classes.push(key); } } } } return classes.join(' '); } if ( module.exports) { classNames.default = classNames; module.exports = classNames; } else { window.classNames = classNames; } }()); }); function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } /** * Take input from [0, n] and return it as [0, 1] * @hidden */ function bound01(n, max) { if (isOnePointZero(n)) { n = '100%'; } var isPercent = isPercentage(n); n = max === 360 ? n : Math.min(max, Math.max(0, parseFloat(n))); // Automatically convert percentage into number if (isPercent) { n = parseInt(String(n * max), 10) / 100; } // Handle floating point rounding errors if (Math.abs(n - max) < 0.000001) { return 1; } // Convert into [0, 1] range if it isn't already if (max === 360) { // If n is a hue given in degrees, // wrap around out-of-range values into [0, 360] range // then convert into [0, 1]. n = (n < 0 ? (n % max) + max : n % max) / parseFloat(String(max)); } else { // If n not a hue given in degrees // Convert into [0, 1] range if it isn't already. n = (n % max) / parseFloat(String(max)); } return n; } /** * Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1 * <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0> * @hidden */ function isOnePointZero(n) { return typeof n === 'string' && n.indexOf('.') !== -1 && parseFloat(n) === 1; } /** * Check to see if string passed in is a percentage * @hidden */ function isPercentage(n) { return typeof n === 'string' && n.indexOf('%') !== -1; } /** * Return a valid alpha value [0,1] with all invalid values being set to 1 * @hidden */ function boundAlpha(a) { a = parseFloat(a); if (isNaN(a) || a < 0 || a > 1) { a = 1; } return a; } /** * Replace a decimal with it's percentage value * @hidden */ function convertToPercentage(n) { if (n <= 1) { return "".concat(Number(n) * 100, "%"); } return n; } /** * Force a hex value to have 2 characters * @hidden */ function pad2(c) { return c.length === 1 ? '0' + c : String(c); } // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from: // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript> /** * Handle bounds / percentage checking to conform to CSS color spec * <http://www.w3.org/TR/css3-color/> * *Assumes:* r, g, b in [0, 255] or [0, 1] * *Returns:* { r, g, b } in [0, 255] */ function rgbToRgb(r, g, b) { return { r: bound01(r, 255) * 255, g: bound01(g, 255) * 255, b: bound01(b, 255) * 255, }; } function hue2rgb(p, q, t) { if (t < 0) { t += 1; } if (t > 1) { t -= 1; } if (t < 1 / 6) { return p + (q - p) * (6 * t); } if (t < 1 / 2) { return q; } if (t < 2 / 3) { return p + (q - p) * (2 / 3 - t) * 6; } return p; } /** * Converts an HSL color value to RGB. * * *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100] * *Returns:* { r, g, b } in the set [0, 255] */ function hslToRgb(h, s, l) { var r; var g; var b; h = bound01(h, 360); s = bound01(s, 100); l = bound01(l, 100); if (s === 0) { // achromatic g = l; b = l; r = l; } else { var q = l < 0.5 ? l * (1 + s) : l + s - l * s; var p = 2 * l - q; r = hue2rgb(p, q, h + 1 / 3); g = hue2rgb(p, q, h); b = hue2rgb(p, q, h - 1 / 3); } return { r: r * 255, g: g * 255, b: b * 255 }; } /** * Converts an RGB color value to HSV * * *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1] * *Returns:* { h, s, v } in [0,1] */ function rgbToHsv(r, g, b) { r = bound01(r, 255); g = bound01(g, 255); b = bound01(b, 255); var max = Math.max(r, g, b); var min = Math.min(r, g, b); var h = 0; var v = max; var d = max - min; var s = max === 0 ? 0 : d / max; if (max === min) { h = 0; // achromatic } else { switch (max) { case r: h = (g - b) / d + (g < b ? 6 : 0); break; case g: h = (b - r) / d + 2; break; case b: h = (r - g) / d + 4; break; } h /= 6; } return { h: h, s: s, v: v }; } /** * Converts an HSV color value to RGB. * * *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100] * *Returns:* { r, g, b } in the set [0, 255] */ function hsvToRgb(h, s, v) { h = bound01(h, 360) * 6; s = bound01(s, 100); v = bound01(v, 100); var i = Math.floor(h); var f = h - i; var p = v * (1 - s); var q = v * (1 - f * s); var t = v * (1 - (1 - f) * s); var mod = i % 6; var r = [v, q, p, p, t, v][mod]; var g = [t, v, v, q, p, p][mod]; var b = [p, p, t, v, v, q][mod]; return { r: r * 255, g: g * 255, b: b * 255 }; } /** * Converts an RGB color to hex * * Assumes r, g, and b are contained in the set [0, 255] * Returns a 3 or 6 character hex */ function rgbToHex(r, g, b, allow3Char) { var hex = [ pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16)), ]; // Return a 3 character hex if possible if (allow3Char && hex[0].startsWith(hex[0].charAt(1)) && hex[1].startsWith(hex[1].charAt(1)) && hex[2].startsWith(hex[2].charAt(1))) { return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0); } return hex.join(''); } /** Converts a hex value to a decimal */ function convertHexToDecimal(h) { return parseIntFromHex(h) / 255; } /** Parse a base-16 hex value into a base-10 integer */ function parseIntFromHex(val) { return parseInt(val, 16); } // https://github.com/bahamas10/css-color-names/blob/master/css-color-names.json /** * @hidden */ var names = { aliceblue: '#f0f8ff', antiquewhite: '#faebd7', aqua: '#00ffff', aquamarine: '#7fffd4', azure: '#f0ffff', beige: '#f5f5dc', bisque: '#ffe4c4', black: '#000000', blanchedalmond: '#ffebcd', blue: '#0000ff', blueviolet: '#8a2be2', brown: '#a52a2a', burlywood: '#deb887', cadetblue: '#5f9ea0', chartreuse: '#7fff00', chocolate: '#d2691e', coral: '#ff7f50', cornflowerblue: '#6495ed', cornsilk: '#fff8dc', crimson: '#dc143c', cyan: '#00ffff', darkblue: '#00008b', darkcyan: '#008b8b', darkgoldenrod: '#b8860b', darkgray: '#a9a9a9', darkgreen: '#006400', darkgrey: '#a9a9a9', darkkhaki: '#bdb76b', darkmagenta: '#8b008b', darkolivegreen: '#556b2f', darkorange: '#ff8c00', darkorchid: '#9932cc', darkred: '#8b0000', darksalmon: '#e9967a', darkseagreen: '#8fbc8f', darkslateblue: '#483d8b', darkslategray: '#2f4f4f', darkslategrey: '#2f4f4f', darkturquoise: '#00ced1', darkviolet: '#9400d3', deeppink: '#ff1493', deepskyblue: '#00bfff', dimgray: '#696969', dimgrey: '#696969', dodgerblue: '#1e90ff', firebrick: '#b22222', floralwhite: '#fffaf0', forestgreen: '#228b22', fuchsia: '#ff00ff', gainsboro: '#dcdcdc', ghostwhite: '#f8f8ff', goldenrod: '#daa520', gold: '#ffd700', gray: '#808080', green: '#008000', greenyellow: '#adff2f', grey: '#808080', honeydew: '#f0fff0', hotpink: '#ff69b4', indianred: '#cd5c5c', indigo: '#4b0082', ivory: '#fffff0', khaki: '#f0e68c', lavenderblush: '#fff0f5', lavender: '#e6e6fa', lawngreen: '#7cfc00', lemonchiffon: '#fffacd', lightblue: '#add8e6', lightcoral: '#f08080', lightcyan: '#e0ffff', lightgoldenrodyellow: '#fafad2', lightgray: '#d3d3d3', lightgreen: '#90ee90', lightgrey: '#d3d3d3', lightpink: '#ffb6c1', lightsalmon: '#ffa07a', lightseagreen: '#20b2aa', lightskyblue: '#87cefa', lightslategray: '#778899', lightslategrey: '#778899', lightsteelblue: '#b0c4de', lightyellow: '#ffffe0', lime: '#00ff00', limegreen: '#32cd32', linen: '#faf0e6', magenta: '#ff00ff', maroon: '#800000', mediumaquamarine: '#66cdaa', mediumblue: '#0000cd', mediumorchid: '#ba55d3', mediumpurple: '#9370db', mediumseagreen: '#3cb371', mediumslateblue: '#7b68ee', mediumspringgreen: '#00fa9a', mediumturquoise: '#48d1cc', mediumvioletred: '#c71585', midnightblue: '#191970', mintcream: '#f5fffa', mistyrose: '#ffe4e1', moccasin: '#ffe4b5', navajowhite: '#ffdead', navy: '#000080', oldlace: '#fdf5e6', olive: '#808000', olivedrab: '#6b8e23', orange: '#ffa500', orangered: '#ff4500', orchid: '#da70d6', palegoldenrod: '#eee8aa', palegreen: '#98fb98', paleturquoise: '#afeeee', palevioletred: '#db7093', papayawhip: '#ffefd5', peachpuff: '#ffdab9', peru: '#cd853f', pink: '#ffc0cb', plum: '#dda0dd', powderblue: '#b0e0e6', purple: '#800080', rebeccapurple: '#663399', red: '#ff0000', rosybrown: '#bc8f8f', royalblue: '#4169e1', saddlebrown: '#8b4513', salmon: '#fa8072', sandybrown: '#f4a460', seagreen: '#2e8b57', seashell: '#fff5ee', sienna: '#a0522d', silver: '#c0c0c0', skyblue: '#87ceeb', slateblue: '#6a5acd', slategray: '#708090', slategrey: '#708090', snow: '#fffafa', springgreen: '#00ff7f', steelblue: '#4682b4', tan: '#d2b48c', teal: '#008080', thistle: '#d8bfd8', tomato: '#ff6347', turquoise: '#40e0d0', violet: '#ee82ee', wheat: '#f5deb3', white: '#ffffff', whitesmoke: '#f5f5f5', yellow: '#ffff00', yellowgreen: '#9acd32', }; /** * Given a string or object, convert that input to RGB * * Possible string inputs: * ``` * "red" * "#f00" or "f00" * "#ff0000" or "ff0000" * "#ff000000" or "ff000000" * "rgb 255 0 0" or "rgb (255, 0, 0)" * "rgb 1.0 0 0" or "rgb (1, 0, 0)" * "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1" * "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1" * "hsl(0, 100%, 50%)" or "hsl 0 100% 50%" * "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1" * "hsv(0, 100%, 100%)" or "hsv 0 100% 100%" * ``` */ function inputToRGB(color) { var rgb = { r: 0, g: 0, b: 0 }; var a = 1; var s = null; var v = null; var l = null; var ok = false; var format = false; if (typeof color === 'string') { color = stringInputToObject(color); } if (typeof color === 'object') { if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) { rgb = rgbToRgb(color.r, color.g, color.b); ok = true; format = String(color.r).substr(-1) === '%' ? 'prgb' : 'rgb'; } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) { s = convertToPercentage(color.s); v = convertToPercentage(color.v); rgb = hsvToRgb(color.h, s, v); ok = true; format = 'hsv'; } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) { s = convertToPercentage(color.s); l = convertToPercentage(color.l); rgb = hslToRgb(color.h, s, l); ok = true; format = 'hsl'; } if (Object.prototype.hasOwnProperty.call(color, 'a')) { a = color.a; } } a = boundAlpha(a); return { ok: ok, format: color.format || format, r: Math.min(255, Math.max(rgb.r, 0)), g: Math.min(255, Math.max(rgb.g, 0)), b: Math.min(255, Math.max(rgb.b, 0)), a: a, }; } // <http://www.w3.org/TR/css3-values/#integers> var CSS_INTEGER = '[-\\+]?\\d+%?'; // <http://www.w3.org/TR/css3-values/#number-value> var CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?'; // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome. var CSS_UNIT = "(?:".concat(CSS_NUMBER, ")|(?:").concat(CSS_INTEGER, ")"); // Actual matching. // Parentheses and commas are optional, but not required. // Whitespace can take the place of commas or opening paren var PERMISSIVE_MATCH3 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?"); var PERMISSIVE_MATCH4 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?"); var matchers = { CSS_UNIT: new RegExp(CSS_UNIT), rgb: new RegExp('rgb' + PERMISSIVE_MATCH3), rgba: new RegExp('rgba' + PERMISSIVE_MATCH4), hsl: new RegExp('hsl' + PERMISSIVE_MATCH3), hsla: new RegExp('hsla' + PERMISSIVE_MATCH4), hsv: new RegExp('hsv' + PERMISSIVE_MATCH3), hsva: new RegExp('hsva' + PERMISSIVE_MATCH4), hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/, hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/, }; /** * Permissive string parsing. Take in a number of formats, and output an object * based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` */ function stringInputToObject(color) { color = color.trim().toLowerCase(); if (color.length === 0) { return false; } var named = false; if (names[color]) { color = names[color]; named = true; } else if (color === 'transparent') { return { r: 0, g: 0, b: 0, a: 0, format: 'name' }; } // Try to match string input using regular expressions. // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360] // Just return an object and let the conversion functions handle that. // This way the result will be the same whether the tinycolor is initialized with string or object. var match = matchers.rgb.exec(color); if (match) { return { r: match[1], g: match[2], b: match[3] }; } match = matchers.rgba.exec(color); if (match) { return { r: match[1], g: match[2], b: match[3], a: match[4] }; } match = matchers.hsl.exec(color); if (match) { return { h: match[1], s: match[2], l: match[3] }; } match = matchers.hsla.exec(color); if (match) { return { h: match[1], s: match[2], l: match[3], a: match[4] }; } match = matchers.hsv.exec(color); if (match) { return { h: match[1], s: match[2], v: match[3] }; } match = matchers.hsva.exec(color); if (match) { return { h: match[1], s: match[2], v: match[3], a: match[4] }; } match = matchers.hex8.exec(color); if (match) { return { r: parseIntFromHex(match[1]), g: parseIntFromHex(match[2]), b: parseIntFromHex(match[3]), a: convertHexToDecimal(match[4]), format: named ? 'name' : 'hex8', }; } match = matchers.hex6.exec(color); if (match) { return { r: parseIntFromHex(match[1]), g: parseIntFromHex(match[2]), b: parseIntFromHex(match[3]), format: named ? 'name' : 'hex', }; } match = matchers.hex4.exec(color); if (match) { return { r: parseIntFromHex(match[1] + match[1]), g: parseIntFromHex(match[2] + match[2]), b: parseIntFromHex(match[3] + match[3]), a: convertHexToDecimal(match[4] + match[4]), format: named ? 'name' : 'hex8', }; } match = matchers.hex3.exec(color); if (match) { return { r: parseIntFromHex(match[1] + match[1]), g: parseIntFromHex(match[2] + match[2]), b: parseIntFromHex(match[3] + match[3]), format: named ? 'name' : 'hex', }; } return false; } /** * Check to see if it looks like a CSS unit * (see `matchers` above for definition). */ function isValidCSSUnit(color) { return Boolean(matchers.CSS_UNIT.exec(String(color))); } var hueStep = 2; // 色相阶梯 var saturationStep = 0.16; // 饱和度阶梯,浅色部分 var saturationStep2 = 0.05; // 饱和度阶梯,深色部分 var brightnessStep1 = 0.05; // 亮度阶梯,浅色部分 var brightnessStep2 = 0.15; // 亮度阶梯,深色部分 var lightColorCount = 5; // 浅色数量,主色上 var darkColorCount = 4; // 深色数量,主色下 // 暗色主题颜色映射关系表 var darkColorMap = [{ index: 7, opacity: 0.15 }, { index: 6, opacity: 0.25 }, { index: 5, opacity: 0.3 }, { index: 5, opacity: 0.45 }, { index: 5, opacity: 0.65 }, { index: 5, opacity: 0.85 }, { index: 4, opacity: 0.9 }, { index: 3, opacity: 0.95 }, { index: 2, opacity: 0.97 }, { index: 1, opacity: 0.98 }]; // Wrapper function ported from TinyColor.prototype.toHsv // Keep it here because of `hsv.h * 360` function toHsv(_ref) { var r = _ref.r, g = _ref.g, b = _ref.b; var hsv = rgbToHsv(r, g, b); return { h: hsv.h * 360, s: hsv.s, v: hsv.v }; } // Wrapper function ported from TinyColor.prototype.toHexString // Keep it here because of the prefix `#` function toHex(_ref2) { var r = _ref2.r, g = _ref2.g, b = _ref2.b; return "#".concat(rgbToHex(r, g, b, false)); } // Wrapper function ported from TinyColor.prototype.mix, not treeshakable. // Amount in range [0, 1] // Assume color1 & color2 has no alpha, since the following src code did so. function mix(rgb1, rgb2, amount) { var p = amount / 100; var rgb = { r: (rgb2.r - rgb1.r) * p + rgb1.r, g: (rgb2.g - rgb1.g) * p + rgb1.g, b: (rgb2.b - rgb1.b) * p + rgb1.b }; return rgb; } function getHue(hsv, i, light) { var hue; // 根据色相不同,色相转向不同 if (Math.round(hsv.h) >= 60 && Math.round(hsv.h) <= 240) { hue = light ? Math.round(hsv.h) - hueStep * i : Math.round(hsv.h) + hueStep * i; } else { hue = light ? Math.round(hsv.h) + hueStep * i : Math.round(hsv.h) - hueStep * i; } if (hue < 0) { hue += 360; } else if (hue >= 360) { hue -= 360; } return hue; } function getSaturation(hsv, i, light) { // grey color don't change saturation if (hsv.h === 0 && hsv.s === 0) { return hsv.s; } var saturation; if (light) { saturation = hsv.s - saturationStep * i; } else if (i === darkColorCount) { saturation = hsv.s + saturationStep; } else { saturation = hsv.s + saturationStep2 * i; } // 边界值修正 if (saturation > 1) { saturation = 1; } // 第一格的 s 限制在 0.06-0.1 之间 if (light && i === lightColorCount && saturation > 0.1) { saturation = 0.1; } if (saturation < 0.06) { saturation = 0.06; } return Number(saturation.toFixed(2)); } function getValue(hsv, i, light) { var value; if (light) { value = hsv.v + brightnessStep1 * i; } else { value = hsv.v - brightnessStep2 * i; } if (value > 1) { value = 1; } return Number(value.toFixed(2)); } function generate(color) { var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var patterns = []; var pColor = inputToRGB(color); for (var i = lightColorCount; i > 0; i -= 1) { var hsv = toHsv(pColor); var colorString = toHex(inputToRGB({ h: getHue(hsv, i, true), s: getSaturation(hsv, i, true), v: getValue(hsv, i, true) })); patterns.push(colorString); } patterns.push(toHex(pColor)); for (var _i = 1; _i <= darkColorCount; _i += 1) { var _hsv = toHsv(pColor); var _colorString = toHex(inputToRGB({ h: getHue(_hsv, _i), s: getSaturation(_hsv, _i), v: getValue(_hsv, _i) })); patterns.push(_colorString); } // dark theme patterns if (opts.theme === 'dark') { return darkColorMap.map(function (_ref3) { var index = _ref3.index, opacity = _ref3.opacity; var darkColorString = toHex(mix(inputToRGB(opts.backgroundColor || '#141414'), inputToRGB(patterns[index]), opacity * 100)); return darkColorString; }); } return patterns; } var presetPrimaryColors = { red: '#F5222D', volcano: '#FA541C', orange: '#FA8C16', gold: '#FAAD14', yellow: '#FADB14', lime: '#A0D911', green: '#52C41A', cyan: '#13C2C2', blue: '#1890FF', geekblue: '#2F54EB', purple: '#722ED1', magenta: '#EB2F96', grey: '#666666' }; var presetPalettes = {}; var presetDarkPalettes = {}; Object.keys(presetPrimaryColors).forEach(function (key) { presetPalettes[key] = generate(presetPrimaryColors[key]); presetPalettes[key].primary = presetPalettes[key][5]; // dark presetPalettes presetDarkPalettes[key] = generate(presetPrimaryColors[key], { theme: 'dark', backgroundColor: '#141414' }); presetDarkPalettes[key].primary = presetDarkPalettes[key][5]; }); /* eslint-disable no-console */ var warned = {}; function warning(valid, message) { // Support uglify if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) { console.error("Warning: ".concat(message)); } } function call(method, valid, message) { if (!valid && !warned[message]) { method(false, message); warned[message] = true; } } function warningOnce(valid, message) { call(warning, valid, message); } /* eslint-enable */ function canUseDom() { return !!(typeof window !== 'undefined' && window.document && window.document.createElement); } function contains(root, n) { if (!root) { return false; } // Use native if support if (root.contains) { return root.contains(n); } // `document.contains` not support with IE11 var node = n; while (node) { if (node === root) { return true; } node = node.parentNode; } return false; } var APPEND_ORDER = 'data-rc-order'; var MARK_KEY = "rc-util-key"; var containerCache = new Map(); function getMark() { var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, mark = _ref.mark; if (mark) { return mark.startsWith('data-') ? mark : "data-".concat(mark); } return MARK_KEY; } function getContainer(option) { if (option.attachTo) { return option.attachTo; } var head = document.querySelector('head'); return head || document.body; } function getOrder(prepend) { if (prepend === 'queue') { return 'prependQueue'; } return prepend ? 'prepend' : 'append'; } /** * Find style which inject by rc-util */ function findStyles(container) { return Array.from((containerCache.get(container) || container).children).filter(function (node) { return node.tagName === 'STYLE'; }); } function injectCSS(css) { var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; if (!canUseDom()) { return null; } var csp = option.csp, prepend = option.prepend; var styleNode = document.createElement('style'); styleNode.setAttribute(APPEND_ORDER, getOrder(prepend)); if (csp === null || csp === void 0 ? void 0 : csp.nonce) { styleNode.nonce = csp === null || csp === void 0 ? void 0 : csp.nonce; } styleNode.innerHTML = css; var container = getContainer(option); var firstChild = container.firstChild; if (prepend) { // If is queue `prepend`, it will prepend first style and then append rest style if (prepend === 'queue') { var existStyle = findStyles(container).filter(function (node) { return ['prepend', 'prependQueue'].includes(node.getAttribute(APPEND_ORDER)); }); if (existStyle.length) { container.insertBefore(styleNode, existStyle[existStyle.length - 1].nextSibling); return styleNode; } } // Use `insertBefore` as `prepend` container.insertBefore(styleNode, firstChild); } else { container.appendChild(styleNode); } return styleNode; } function findExistNode(key) { var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var container = getContainer(option); return findStyles(container).find(function (node) { return node.getAttribute(getMark(option)) === key; }); } /** * qiankun will inject `appendChild` to insert into other */ function syncRealContainer(container, option) { var cachedRealContainer = containerCache.get(container); // Find real container when not cached or cached container removed if (!cachedRealContainer || !contains(document, cachedRealContainer)) { var placeholderStyle = injectCSS('', option); var parentNode = placeholderStyle.parentNode; containerCache.set(container, parentNode); parentNode.removeChild(placeholderStyle); } } function updateCSS(css, key) { var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; var container = getContainer(option); // Sync real parent syncRealContainer(container, option); var existNode = findExistNode(key, option); if (existNode) { var _option$csp, _option$csp2; if (((_option$csp = option.csp) === null || _option$csp === void 0 ? void 0 : _option$csp.nonce) && existNode.nonce !== ((_option$csp2 = option.csp) === null || _option$csp2 === void 0 ? void 0 : _option$csp2.nonce)) { var _option$csp3; existNode.nonce = (_option$csp3 = option.csp) === null || _option$csp3 === void 0 ? void 0 : _option$csp3.nonce; } if (existNode.innerHTML !== css) { existNode.innerHTML = css; } return existNode; } var newNode = injectCSS(css, option); newNode.setAttribute(getMark(option), key); return newNode; } function warning$1(valid, message) { warningOnce(valid, "[@ant-design/icons] ".concat(message)); } function isIconDefinition(target) { return _typeof(target) === 'object' && typeof target.name === 'string' && typeof target.theme === 'string' && (_typeof(target.icon) === 'object' || typeof target.icon === 'function'); } function normalizeAttrs() { var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return Object.keys(attrs).reduce(function (acc, key) { var val = attrs[key]; switch (key) { case 'class': acc.className = val; delete acc.class; break; default: acc[key] = val; } return acc; }, {}); } function generate$1(node, key, rootProps) { if (!rootProps) { return /*#__PURE__*/React__default.createElement(node.tag, _objectSpread2({ key: key }, normalizeAttrs(node.attrs)), (node.children || []).map(function (child, index) { return generate$1(child, "".concat(key, "-").concat(node.tag, "-").concat(index)); })); } return /*#__PURE__*/React__default.createElement(node.tag, _objectSpread2(_objectSpread2({ key: key }, normalizeAttrs(node.attrs)), rootProps), (node.children || []).map(function (child, index) { return generate$1(child, "".concat(key, "-").concat(node.tag, "-").concat(index)); })); } function getSecondaryColor(primaryColor) { // choose the second color return generate(primaryColor)[0]; } function normalizeTwoToneColors(twoToneColor) { if (!twoToneColor) { return []; } return Array.isArray(twoToneColor) ? twoToneColor : [twoToneColor]; } // These props make sure that the SVG behaviours like general text. var iconStyles = "\n.anticon {\n display: inline-block;\n color: inherit;\n font-style: normal;\n line-height: 0;\n text-align: center;\n text-transform: none;\n vertical-align: -0.125em;\n text-rendering: optimizeLegibility;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n.anticon > * {\n line-height: 1;\n}\n\n.anticon svg {\n display: inline-block;\n}\n\n.anticon::before {\n display: none;\n}\n\n.anticon .anticon-icon {\n display: block;\n}\n\n.anticon[tabindex] {\n cursor: pointer;\n}\n\n.anticon-spin::before,\n.anticon-spin {\n display: inline-block;\n -webkit-animation: loadingCircle 1s infinite linear;\n animation: loadingCircle 1s infinite linear;\n}\n\n@-webkit-keyframes loadingCircle {\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n\n@keyframes loadingCircle {\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n"; var useInsertStyles = function useInsertStyles() { var styleStr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : iconStyles; var _useContext = useContext(IconContext), csp = _useContext.csp; useEffect(function () { updateCSS(styleStr, '@ant-design-icons', { prepend: true, csp: csp }); }, []); }; var _excluded = ["icon", "className"