ods-component-lib 1.22.2 → 1.22.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/index5.js +2 -3
- package/dist/_virtual/index5.js.map +1 -1
- package/dist/_virtual/index6.js +3 -2
- package/dist/_virtual/index6.js.map +1 -1
- package/dist/components/antd/currencyInput/CurrencySelect.js +15 -14
- package/dist/components/antd/currencyInput/CurrencySelect.js.map +1 -1
- package/dist/node_modules/@ant-design/cssinjs/es/StyleContext.js +6 -6
- package/dist/node_modules/@ant-design/cssinjs/es/StyleContext.js.map +1 -1
- package/dist/node_modules/@ant-design/cssinjs/es/hooks/useCacheToken.js +20 -20
- package/dist/node_modules/@ant-design/cssinjs/es/hooks/useCacheToken.js.map +1 -1
- package/dist/node_modules/@ant-design/cssinjs/es/hooks/useGlobalCache.js.map +1 -1
- package/dist/node_modules/@ant-design/cssinjs/es/hooks/useStyleRegister.js +101 -98
- package/dist/node_modules/@ant-design/cssinjs/es/hooks/useStyleRegister.js.map +1 -1
- package/dist/node_modules/@ant-design/cssinjs/es/util/index.js +29 -27
- package/dist/node_modules/@ant-design/cssinjs/es/util/index.js.map +1 -1
- package/dist/node_modules/@rc-component/async-validator/es/index.js +20 -20
- package/dist/node_modules/@rc-component/async-validator/es/index.js.map +1 -1
- package/dist/node_modules/@rc-component/async-validator/es/messages.js +1 -0
- package/dist/node_modules/@rc-component/async-validator/es/messages.js.map +1 -1
- package/dist/node_modules/@rc-component/async-validator/es/rule/type.js +18 -8
- package/dist/node_modules/@rc-component/async-validator/es/rule/type.js.map +1 -1
- package/dist/node_modules/@rc-component/async-validator/es/util.js +1 -1
- package/dist/node_modules/@rc-component/async-validator/es/util.js.map +1 -1
- package/dist/node_modules/@rc-component/async-validator/es/validator/index.js +1 -0
- package/dist/node_modules/@rc-component/async-validator/es/validator/index.js.map +1 -1
- package/dist/node_modules/@rc-component/collapse/es/hooks/useItems.js +88 -68
- package/dist/node_modules/@rc-component/collapse/es/hooks/useItems.js.map +1 -1
- package/dist/node_modules/@rc-component/dialog/es/Dialog/Content/Panel.js +75 -96
- package/dist/node_modules/@rc-component/dialog/es/Dialog/Content/Panel.js.map +1 -1
- package/dist/node_modules/@rc-component/dialog/es/Dialog/Content/index.js +22 -20
- package/dist/node_modules/@rc-component/dialog/es/Dialog/Content/index.js.map +1 -1
- package/dist/node_modules/@rc-component/dialog/es/Dialog/index.js +92 -100
- package/dist/node_modules/@rc-component/dialog/es/Dialog/index.js.map +1 -1
- package/dist/node_modules/@rc-component/dialog/es/DialogWrap.js +40 -29
- package/dist/node_modules/@rc-component/dialog/es/DialogWrap.js.map +1 -1
- package/dist/node_modules/@rc-component/form/es/hooks/useForm.js +115 -100
- package/dist/node_modules/@rc-component/form/es/hooks/useForm.js.map +1 -1
- package/dist/node_modules/@rc-component/form/es/utils/NameMap.js +28 -22
- package/dist/node_modules/@rc-component/form/es/utils/NameMap.js.map +1 -1
- package/dist/node_modules/@rc-component/form/es/utils/messages.js +1 -0
- package/dist/node_modules/@rc-component/form/es/utils/messages.js.map +1 -1
- package/dist/node_modules/@rc-component/image/es/Preview/index.js +111 -105
- package/dist/node_modules/@rc-component/image/es/Preview/index.js.map +1 -1
- package/dist/node_modules/@rc-component/portal/es/useEscKeyDown.js +42 -22
- package/dist/node_modules/@rc-component/portal/es/useEscKeyDown.js.map +1 -1
- package/dist/node_modules/@rc-component/resize-observer/es/SingleObserver/index.js +18 -54
- package/dist/node_modules/@rc-component/resize-observer/es/SingleObserver/index.js.map +1 -1
- package/dist/node_modules/@rc-component/resize-observer/es/index.js.map +1 -1
- package/dist/node_modules/@rc-component/resize-observer/es/useResizeObserver.js +50 -0
- package/dist/node_modules/@rc-component/resize-observer/es/useResizeObserver.js.map +1 -0
- package/dist/node_modules/@rc-component/select/es/SelectInput/Content/MultipleContent.js +50 -50
- package/dist/node_modules/@rc-component/select/es/SelectInput/Content/MultipleContent.js.map +1 -1
- package/dist/node_modules/@rc-component/select/es/SelectInput/index.js +85 -80
- package/dist/node_modules/@rc-component/select/es/SelectInput/index.js.map +1 -1
- package/dist/node_modules/@rc-component/table/es/VirtualTable/BodyGrid.js +85 -80
- package/dist/node_modules/@rc-component/table/es/VirtualTable/BodyGrid.js.map +1 -1
- package/dist/node_modules/@rc-component/trigger/es/Popup/index.js +74 -72
- package/dist/node_modules/@rc-component/trigger/es/Popup/index.js.map +1 -1
- package/dist/node_modules/@rc-component/trigger/es/UniqueProvider/index.js +10 -9
- package/dist/node_modules/@rc-component/trigger/es/UniqueProvider/index.js.map +1 -1
- package/dist/node_modules/@rc-component/trigger/es/hooks/useAlign.js +27 -27
- package/dist/node_modules/@rc-component/trigger/es/hooks/useAlign.js.map +1 -1
- package/dist/node_modules/@rc-component/trigger/es/index.js +150 -140
- package/dist/node_modules/@rc-component/trigger/es/index.js.map +1 -1
- package/dist/node_modules/@rc-component/util/es/Dom/focus.js +65 -20
- package/dist/node_modules/@rc-component/util/es/Dom/focus.js.map +1 -1
- package/dist/node_modules/@rc-component/util/es/ref.js +1 -1
- package/dist/node_modules/antd/es/_util/wave/WaveEffect.js +53 -48
- package/dist/node_modules/antd/es/_util/wave/WaveEffect.js.map +1 -1
- package/dist/node_modules/antd/es/_util/wave/style.js +8 -7
- package/dist/node_modules/antd/es/_util/wave/style.js.map +1 -1
- package/dist/node_modules/antd/es/alert/Alert.js +133 -128
- package/dist/node_modules/antd/es/alert/Alert.js.map +1 -1
- package/dist/node_modules/antd/es/badge/Badge.js +29 -28
- package/dist/node_modules/antd/es/badge/Badge.js.map +1 -1
- package/dist/node_modules/antd/es/badge/style/index.js +1 -1
- package/dist/node_modules/antd/es/badge/style/index.js.map +1 -1
- package/dist/node_modules/antd/es/button/buttonHelpers.js +47 -41
- package/dist/node_modules/antd/es/button/buttonHelpers.js.map +1 -1
- package/dist/node_modules/antd/es/button/style/variant.js +132 -132
- package/dist/node_modules/antd/es/button/style/variant.js.map +1 -1
- package/dist/node_modules/antd/es/calendar/generateCalendar.js +55 -57
- package/dist/node_modules/antd/es/calendar/generateCalendar.js.map +1 -1
- package/dist/node_modules/antd/es/calendar/style/index.js +18 -18
- package/dist/node_modules/antd/es/calendar/style/index.js.map +1 -1
- package/dist/node_modules/antd/es/card/CardGrid.js.map +1 -1
- package/dist/node_modules/antd/es/card/style/index.js +15 -7
- package/dist/node_modules/antd/es/card/style/index.js.map +1 -1
- package/dist/node_modules/antd/es/checkbox/Group.js +32 -30
- package/dist/node_modules/antd/es/checkbox/Group.js.map +1 -1
- package/dist/node_modules/antd/es/collapse/Collapse.js +61 -61
- package/dist/node_modules/antd/es/collapse/Collapse.js.map +1 -1
- package/dist/node_modules/antd/es/config-provider/index.js +76 -71
- package/dist/node_modules/antd/es/config-provider/index.js.map +1 -1
- package/dist/node_modules/antd/es/date-picker/generatePicker/generateRangePicker.js +29 -31
- package/dist/node_modules/antd/es/date-picker/generatePicker/generateRangePicker.js.map +1 -1
- package/dist/node_modules/antd/es/date-picker/generatePicker/generateSinglePicker.js +7 -9
- package/dist/node_modules/antd/es/date-picker/generatePicker/generateSinglePicker.js.map +1 -1
- package/dist/node_modules/antd/es/date-picker/generatePicker/{SuffixIcon.js → useSuffixIcon.js} +4 -4
- package/dist/node_modules/antd/es/date-picker/generatePicker/useSuffixIcon.js.map +1 -0
- package/dist/node_modules/antd/es/date-picker/style/panel.js +4 -4
- package/dist/node_modules/antd/es/date-picker/style/panel.js.map +1 -1
- package/dist/node_modules/antd/es/drawer/useFocusable.js +14 -0
- package/dist/node_modules/antd/es/drawer/useFocusable.js.map +1 -0
- package/dist/node_modules/antd/es/form/style/index.js +24 -24
- package/dist/node_modules/antd/es/form/style/index.js.map +1 -1
- package/dist/node_modules/antd/es/grid/col.js +56 -54
- package/dist/node_modules/antd/es/grid/col.js.map +1 -1
- package/dist/node_modules/antd/es/grid/style/index.js +50 -50
- package/dist/node_modules/antd/es/grid/style/index.js.map +1 -1
- package/dist/node_modules/antd/es/input/style/index.js +1 -0
- package/dist/node_modules/antd/es/input/style/index.js.map +1 -1
- package/dist/node_modules/antd/es/input-number/index.js +91 -91
- package/dist/node_modules/antd/es/input-number/index.js.map +1 -1
- package/dist/node_modules/antd/es/input-number/style/index.js +80 -79
- package/dist/node_modules/antd/es/input-number/style/index.js.map +1 -1
- package/dist/node_modules/antd/es/layout/style/sider.js +9 -9
- package/dist/node_modules/antd/es/layout/style/sider.js.map +1 -1
- package/dist/node_modules/antd/es/menu/MenuItem.js +6 -6
- package/dist/node_modules/antd/es/menu/MenuItem.js.map +1 -1
- package/dist/node_modules/antd/es/menu/SubMenu.js +8 -8
- package/dist/node_modules/antd/es/menu/SubMenu.js.map +1 -1
- package/dist/node_modules/antd/es/menu/style/horizontal.js +1 -1
- package/dist/node_modules/antd/es/menu/style/horizontal.js.map +1 -1
- package/dist/node_modules/antd/es/menu/style/index.js +58 -58
- package/dist/node_modules/antd/es/menu/style/index.js.map +1 -1
- package/dist/node_modules/antd/es/menu/style/vertical.js +1 -1
- package/dist/node_modules/antd/es/menu/style/vertical.js.map +1 -1
- package/dist/node_modules/antd/es/modal/ConfirmDialog.js +117 -112
- package/dist/node_modules/antd/es/modal/ConfirmDialog.js.map +1 -1
- package/dist/node_modules/antd/es/modal/Modal.js +115 -109
- package/dist/node_modules/antd/es/modal/Modal.js.map +1 -1
- package/dist/node_modules/antd/es/modal/style/index.js +83 -80
- package/dist/node_modules/antd/es/modal/style/index.js.map +1 -1
- package/dist/node_modules/antd/es/pagination/Pagination.js +85 -81
- package/dist/node_modules/antd/es/pagination/Pagination.js.map +1 -1
- package/dist/node_modules/antd/es/pagination/style/bordered.js +2 -2
- package/dist/node_modules/antd/es/pagination/style/bordered.js.map +1 -1
- package/dist/node_modules/antd/es/pagination/style/index.js +98 -132
- package/dist/node_modules/antd/es/pagination/style/index.js.map +1 -1
- package/dist/node_modules/antd/es/popover/index.js +77 -82
- package/dist/node_modules/antd/es/popover/index.js.map +1 -1
- package/dist/node_modules/antd/es/popover/style/index.js +65 -63
- package/dist/node_modules/antd/es/popover/style/index.js.map +1 -1
- package/dist/node_modules/antd/es/radio/context.js +3 -3
- package/dist/node_modules/antd/es/radio/context.js.map +1 -1
- package/dist/node_modules/antd/es/radio/group.js +31 -29
- package/dist/node_modules/antd/es/radio/group.js.map +1 -1
- package/dist/node_modules/antd/es/radio/style/index.js +1 -1
- package/dist/node_modules/antd/es/radio/style/index.js.map +1 -1
- package/dist/node_modules/antd/es/select/style/dropdown.js +1 -1
- package/dist/node_modules/antd/es/select/style/dropdown.js.map +1 -1
- package/dist/node_modules/antd/es/select/style/select-input-multiple.js +71 -69
- package/dist/node_modules/antd/es/select/style/select-input-multiple.js.map +1 -1
- package/dist/node_modules/antd/es/select/style/select-input.js +104 -98
- package/dist/node_modules/antd/es/select/style/select-input.js.map +1 -1
- package/dist/node_modules/antd/es/space/Item.js +2 -2
- package/dist/node_modules/antd/es/space/Item.js.map +1 -1
- package/dist/node_modules/antd/es/space/index.js +4 -4
- package/dist/node_modules/antd/es/space/index.js.map +1 -1
- package/dist/node_modules/antd/es/space/style/addon.js +47 -46
- package/dist/node_modules/antd/es/space/style/addon.js.map +1 -1
- package/dist/node_modules/antd/es/steps/PanelArrow.js +2 -2
- package/dist/node_modules/antd/es/steps/PanelArrow.js.map +1 -1
- package/dist/node_modules/antd/es/steps/ProgressIcon.js +12 -10
- package/dist/node_modules/antd/es/steps/ProgressIcon.js.map +1 -1
- package/dist/node_modules/antd/es/steps/index.js +108 -106
- package/dist/node_modules/antd/es/steps/index.js.map +1 -1
- package/dist/node_modules/antd/es/steps/style/horizontal.js +13 -11
- package/dist/node_modules/antd/es/steps/style/horizontal.js.map +1 -1
- package/dist/node_modules/antd/es/steps/style/icon.js +23 -18
- package/dist/node_modules/antd/es/steps/style/icon.js.map +1 -1
- package/dist/node_modules/antd/es/steps/style/index.js +41 -41
- package/dist/node_modules/antd/es/steps/style/index.js.map +1 -1
- package/dist/node_modules/antd/es/steps/style/inline.js +28 -23
- package/dist/node_modules/antd/es/steps/style/inline.js.map +1 -1
- package/dist/node_modules/antd/es/steps/style/label-placement.js +44 -39
- package/dist/node_modules/antd/es/steps/style/label-placement.js.map +1 -1
- package/dist/node_modules/antd/es/steps/style/nav.js +29 -27
- package/dist/node_modules/antd/es/steps/style/nav.js.map +1 -1
- package/dist/node_modules/antd/es/steps/style/panel.js +61 -56
- package/dist/node_modules/antd/es/steps/style/panel.js.map +1 -1
- package/dist/node_modules/antd/es/steps/style/progress-dot.js +28 -26
- package/dist/node_modules/antd/es/steps/style/progress-dot.js.map +1 -1
- package/dist/node_modules/antd/es/steps/style/progress.js +24 -57
- package/dist/node_modules/antd/es/steps/style/progress.js.map +1 -1
- package/dist/node_modules/antd/es/steps/style/rtl.js +10 -8
- package/dist/node_modules/antd/es/steps/style/rtl.js.map +1 -1
- package/dist/node_modules/antd/es/steps/style/small.js +21 -16
- package/dist/node_modules/antd/es/steps/style/small.js.map +1 -1
- package/dist/node_modules/antd/es/steps/style/status.js +187 -176
- package/dist/node_modules/antd/es/steps/style/status.js.map +1 -1
- package/dist/node_modules/antd/es/steps/style/util.js +18 -16
- package/dist/node_modules/antd/es/steps/style/util.js.map +1 -1
- package/dist/node_modules/antd/es/steps/style/vertical.js +21 -16
- package/dist/node_modules/antd/es/steps/style/vertical.js.map +1 -1
- package/dist/node_modules/antd/es/style/placementArrow.js +31 -29
- package/dist/node_modules/antd/es/style/placementArrow.js.map +1 -1
- package/dist/node_modules/antd/es/table/InternalTable.js +65 -62
- package/dist/node_modules/antd/es/table/InternalTable.js.map +1 -1
- package/dist/node_modules/antd/es/table/TableMeasureRowContext.js +6 -0
- package/dist/node_modules/antd/es/table/TableMeasureRowContext.js.map +1 -0
- package/dist/node_modules/antd/es/table/hooks/useFilter/FilterDropdown.js +145 -137
- package/dist/node_modules/antd/es/table/hooks/useFilter/FilterDropdown.js.map +1 -1
- package/dist/node_modules/antd/es/table/style/index.js +3 -3
- package/dist/node_modules/antd/es/table/style/index.js.map +1 -1
- package/dist/node_modules/antd/es/table/style/radius.js +10 -0
- package/dist/node_modules/antd/es/table/style/radius.js.map +1 -1
- package/dist/node_modules/antd/es/table/style/virtual.js +5 -5
- package/dist/node_modules/antd/es/table/style/virtual.js.map +1 -1
- package/dist/node_modules/antd/es/theme/util/genStyleUtils.js +29 -32
- package/dist/node_modules/antd/es/theme/util/genStyleUtils.js.map +1 -1
- package/dist/node_modules/antd/es/timeline/Timeline.js +76 -74
- package/dist/node_modules/antd/es/timeline/Timeline.js.map +1 -1
- package/dist/node_modules/antd/es/timeline/style/horizontal.js +21 -18
- package/dist/node_modules/antd/es/timeline/style/horizontal.js.map +1 -1
- package/dist/node_modules/antd/es/timeline/style/index.js +85 -70
- package/dist/node_modules/antd/es/timeline/style/index.js.map +1 -1
- package/dist/node_modules/antd/es/timeline/useItems.js +38 -37
- package/dist/node_modules/antd/es/timeline/useItems.js.map +1 -1
- package/dist/node_modules/antd/es/tooltip/PurePanel.js +27 -27
- package/dist/node_modules/antd/es/tooltip/PurePanel.js.map +1 -1
- package/dist/node_modules/antd/es/tooltip/UniqueProvider/MotionContent.js +17 -22
- package/dist/node_modules/antd/es/tooltip/UniqueProvider/MotionContent.js.map +1 -1
- package/dist/node_modules/antd/es/tooltip/UniqueProvider/index.js +27 -26
- package/dist/node_modules/antd/es/tooltip/UniqueProvider/index.js.map +1 -1
- package/dist/node_modules/antd/es/tooltip/index.js +50 -50
- package/dist/node_modules/antd/es/tooltip/index.js.map +1 -1
- package/dist/node_modules/antd/es/tooltip/style/index.js +55 -52
- package/dist/node_modules/antd/es/tooltip/style/index.js.map +1 -1
- package/dist/node_modules/antd/es/tooltip/util.js +13 -12
- package/dist/node_modules/antd/es/tooltip/util.js.map +1 -1
- package/dist/node_modules/antd/es/tree/DirectoryTree.js +42 -41
- package/dist/node_modules/antd/es/tree/DirectoryTree.js.map +1 -1
- package/dist/node_modules/antd/es/version/version.js +1 -1
- package/dist/node_modules/antd/es/version/version.js.map +1 -1
- package/dist/node_modules/canvg/lib/index.es.js +84 -84
- package/dist/node_modules/canvg/lib/index.es.js.map +1 -1
- package/dist/node_modules/compute-scroll-into-view/dist/index.js +17 -17
- package/dist/node_modules/compute-scroll-into-view/dist/index.js.map +1 -1
- package/dist/node_modules/dompurify/dist/purify.es.js +217 -223
- package/dist/node_modules/dompurify/dist/purify.es.js.map +1 -1
- package/dist/node_modules/fflate/esm/browser.js +295 -335
- package/dist/node_modules/fflate/esm/browser.js.map +1 -1
- package/dist/node_modules/jspdf/dist/jspdf.es.min.js +1771 -1781
- package/dist/node_modules/jspdf/dist/jspdf.es.min.js.map +1 -1
- package/dist/node_modules/raf/index.js +1 -1
- package/dist/node_modules/uuid/dist/esm-browser/regex.js +5 -0
- package/dist/node_modules/uuid/dist/esm-browser/regex.js.map +1 -0
- package/dist/node_modules/uuid/dist/esm-browser/rng.js +2 -3
- package/dist/node_modules/uuid/dist/esm-browser/rng.js.map +1 -1
- package/dist/node_modules/uuid/dist/esm-browser/stringify.js +10 -6
- package/dist/node_modules/uuid/dist/esm-browser/stringify.js.map +1 -1
- package/dist/node_modules/uuid/dist/esm-browser/v4.js +6 -9
- package/dist/node_modules/uuid/dist/esm-browser/v4.js.map +1 -1
- package/dist/node_modules/uuid/dist/esm-browser/validate.js +8 -0
- package/dist/node_modules/uuid/dist/esm-browser/validate.js.map +1 -0
- package/package.json +1 -1
- package/dist/node_modules/antd/es/date-picker/generatePicker/SuffixIcon.js.map +0 -1
- package/dist/node_modules/uuid/dist/esm-browser/native.js +0 -7
- package/dist/node_modules/uuid/dist/esm-browser/native.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStyleRegister.js","sources":["../../../../../../node_modules/@ant-design/cssinjs/es/hooks/useStyleRegister.js"],"sourcesContent":["import hash from '@emotion/hash';\nimport { removeCSS, updateCSS } from \"@rc-component/util/es/Dom/dynamicCSS\";\nimport * as React from 'react';\n// @ts-ignore\nimport unitless from '@emotion/unitless';\nimport { compile, middleware, prefixer, serialize, stringify } from 'stylis';\nimport { contentQuotesLinter, hashedAnimationLinter } from \"../linters\";\nimport StyleContext, { ATTR_CACHE_PATH, ATTR_MARK, CSS_IN_JS_INSTANCE } from \"../StyleContext\";\nimport { isClientSide, toStyleStr } from \"../util\";\nimport { CSS_FILE_STYLE, existPath, getStyleAndHash } from \"../util/cacheMapUtil\";\nimport useGlobalCache from \"./useGlobalCache\";\nconst SKIP_CHECK = '_skip_check_';\nconst MULTI_VALUE = '_multi_value_';\n// ============================================================================\n// == Parser ==\n// ============================================================================\n// Preprocessor style content to browser support one\nexport function normalizeStyle(styleStr, autoPrefix) {\n const serialized = autoPrefix ? serialize(compile(styleStr), middleware([prefixer, stringify])) : serialize(compile(styleStr), stringify);\n return serialized.replace(/\\{%%%\\:[^;];}/g, ';');\n}\nfunction isCompoundCSSProperty(value) {\n return typeof value === 'object' && value && (SKIP_CHECK in value || MULTI_VALUE in value);\n}\n\n// 注入 hash 值\nfunction injectSelectorHash(key, hashId, hashPriority) {\n if (!hashId) {\n return key;\n }\n const hashClassName = `.${hashId}`;\n const hashSelector = hashPriority === 'low' ? `:where(${hashClassName})` : hashClassName;\n\n // 注入 hashId\n const keys = key.split(',').map(k => {\n const fullPath = k.trim().split(/\\s+/);\n\n // 如果 Selector 第一个是 HTML Element,那我们就插到它的后面。反之,就插到最前面。\n let firstPath = fullPath[0] || '';\n const htmlElement = firstPath.match(/^\\w+/)?.[0] || '';\n firstPath = `${htmlElement}${hashSelector}${firstPath.slice(htmlElement.length)}`;\n return [firstPath, ...fullPath.slice(1)].join(' ');\n });\n return keys.join(',');\n}\n// Parse CSSObject to style content\nexport const parseStyle = (interpolation, config = {}, {\n root,\n injectHash,\n parentSelectors\n} = {\n root: true,\n parentSelectors: []\n}) => {\n const {\n hashId,\n layer,\n path,\n hashPriority,\n transformers = [],\n linters = []\n } = config;\n let styleStr = '';\n let effectStyle = {};\n function parseKeyframes(keyframes) {\n const animationName = keyframes.getName(hashId);\n if (!effectStyle[animationName]) {\n const [parsedStr] = parseStyle(keyframes.style, config, {\n root: false,\n parentSelectors\n });\n effectStyle[animationName] = `@keyframes ${keyframes.getName(hashId)}${parsedStr}`;\n }\n }\n function flattenList(list, fullList = []) {\n list.forEach(item => {\n if (Array.isArray(item)) {\n flattenList(item, fullList);\n } else if (item) {\n fullList.push(item);\n }\n });\n return fullList;\n }\n const flattenStyleList = flattenList(Array.isArray(interpolation) ? interpolation : [interpolation]);\n flattenStyleList.forEach(originStyle => {\n // Only root level can use raw string\n const style = typeof originStyle === 'string' && !root ? {} : originStyle;\n if (typeof style === 'string') {\n styleStr += `${style}\\n`;\n } else if (style._keyframe) {\n // Keyframe\n parseKeyframes(style);\n } else {\n const mergedStyle = transformers.reduce((prev, trans) => trans?.visit?.(prev) || prev, style);\n\n // Normal CSSObject\n Object.keys(mergedStyle).forEach(key => {\n const value = mergedStyle[key];\n if (typeof value === 'object' && value && (key !== 'animationName' || !value._keyframe) && !isCompoundCSSProperty(value)) {\n let subInjectHash = false;\n\n // 当成嵌套对象来处理\n let mergedKey = key.trim();\n // Whether treat child as root. In most case it is false.\n let nextRoot = false;\n\n // 拆分多个选择器\n if ((root || injectHash) && hashId) {\n if (mergedKey.startsWith('@')) {\n // 略过媒体查询,交给子节点继续插入 hashId\n subInjectHash = true;\n } else if (mergedKey === '&') {\n // 抹掉 root selector 上的单个 &\n mergedKey = injectSelectorHash('', hashId, hashPriority);\n } else {\n // 注入 hashId\n mergedKey = injectSelectorHash(key, hashId, hashPriority);\n }\n } else if (root && !hashId && (mergedKey === '&' || mergedKey === '')) {\n // In case of `{ '&': { a: { color: 'red' } } }` or `{ '': { a: { color: 'red' } } }` without hashId,\n // we will get `&{a:{color:red;}}` or `{a:{color:red;}}` string for stylis to compile.\n // But it does not conform to stylis syntax,\n // and finally we will get `{color:red;}` as css, which is wrong.\n // So we need to remove key in root, and treat child `{ a: { color: 'red' } }` as root.\n mergedKey = '';\n nextRoot = true;\n }\n const [parsedStr, childEffectStyle] = parseStyle(value, config, {\n root: nextRoot,\n injectHash: subInjectHash,\n parentSelectors: [...parentSelectors, mergedKey]\n });\n effectStyle = {\n ...effectStyle,\n ...childEffectStyle\n };\n styleStr += `${mergedKey}${parsedStr}`;\n } else {\n function appendStyle(cssKey, cssValue) {\n if (process.env.NODE_ENV !== 'production' && (typeof value !== 'object' || !value?.[SKIP_CHECK])) {\n [contentQuotesLinter, hashedAnimationLinter, ...linters].forEach(linter => linter(cssKey, cssValue, {\n path,\n hashId,\n parentSelectors\n }));\n }\n\n // 如果是样式则直接插入\n const styleName = cssKey.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`);\n\n // Auto suffix with px\n let formatValue = cssValue;\n if (!unitless[cssKey] && typeof formatValue === 'number' && formatValue !== 0) {\n formatValue = `${formatValue}px`;\n }\n\n // handle animationName & Keyframe value\n if (cssKey === 'animationName' && cssValue?._keyframe) {\n parseKeyframes(cssValue);\n formatValue = cssValue.getName(hashId);\n }\n styleStr += `${styleName}:${formatValue};`;\n }\n const actualValue = value?.value ?? value;\n if (typeof value === 'object' && value?.[MULTI_VALUE] && Array.isArray(actualValue)) {\n actualValue.forEach(item => {\n appendStyle(key, item);\n });\n } else {\n appendStyle(key, actualValue);\n }\n }\n });\n }\n });\n if (!root) {\n styleStr = `{${styleStr}}`;\n } else if (layer) {\n // fixme: https://github.com/thysultan/stylis/pull/339\n if (styleStr) {\n styleStr = `@layer ${layer.name} {${styleStr}}`;\n }\n if (layer.dependencies) {\n effectStyle[`@layer ${layer.name}`] = layer.dependencies.map(deps => `@layer ${deps}, ${layer.name};`).join('\\n');\n }\n }\n return [styleStr, effectStyle];\n};\n\n// ============================================================================\n// == Register ==\n// ============================================================================\nexport function uniqueHash(path, styleStr) {\n return hash(`${path.join('%')}${styleStr}`);\n}\nexport const STYLE_PREFIX = 'style';\n/**\n * Register a style to the global style sheet.\n */\nexport default function useStyleRegister(info, styleFn) {\n const {\n path,\n hashId,\n layer,\n nonce,\n clientOnly,\n order = 0\n } = info;\n const {\n mock,\n hashPriority,\n container,\n transformers,\n linters,\n cache,\n layer: enableLayer,\n autoPrefix\n } = React.useContext(StyleContext);\n const fullPath = [hashId || ''];\n if (enableLayer) {\n fullPath.push('layer');\n }\n fullPath.push(...path);\n\n // Check if need insert style\n let isMergedClientSide = isClientSide;\n if (process.env.NODE_ENV !== 'production' && mock !== undefined) {\n isMergedClientSide = mock === 'client';\n }\n useGlobalCache(STYLE_PREFIX, fullPath,\n // Create cache if needed\n () => {\n const cachePath = fullPath.join('|');\n\n // Get style from SSR inline style directly\n if (existPath(cachePath)) {\n const [inlineCacheStyleStr, styleHash] = getStyleAndHash(cachePath);\n if (inlineCacheStyleStr) {\n return [inlineCacheStyleStr, styleHash, {}, clientOnly, order];\n }\n }\n\n // Generate style\n const styleObj = styleFn();\n const [parsedStyle, effectStyle] = parseStyle(styleObj, {\n hashId,\n hashPriority,\n layer: enableLayer ? layer : undefined,\n path: path.join('-'),\n transformers,\n linters\n });\n const styleStr = normalizeStyle(parsedStyle, autoPrefix || false);\n const styleId = uniqueHash(fullPath, styleStr);\n return [styleStr, styleId, effectStyle, clientOnly, order];\n },\n // Remove cache if no need\n (cacheValue, fromHMR) => {\n const [, styleId] = cacheValue;\n if (fromHMR && isClientSide) {\n removeCSS(styleId, {\n mark: ATTR_MARK,\n attachTo: container\n });\n }\n },\n // Effect: Inject style here\n cacheValue => {\n const [styleStr, styleId, effectStyle,, priority] = cacheValue;\n if (isMergedClientSide && styleStr !== CSS_FILE_STYLE) {\n const mergedCSSConfig = {\n mark: ATTR_MARK,\n prepend: enableLayer ? false : 'queue',\n attachTo: container,\n priority\n };\n const nonceStr = typeof nonce === 'function' ? nonce() : nonce;\n if (nonceStr) {\n mergedCSSConfig.csp = {\n nonce: nonceStr\n };\n }\n\n // ================= Split Effect Style =================\n // We will split effectStyle here since @layer should be at the top level\n const effectLayerKeys = [];\n const effectRestKeys = [];\n Object.keys(effectStyle).forEach(key => {\n if (key.startsWith('@layer')) {\n effectLayerKeys.push(key);\n } else {\n effectRestKeys.push(key);\n }\n });\n\n // ================= Inject Layer Style =================\n // Inject layer style\n effectLayerKeys.forEach(effectKey => {\n updateCSS(normalizeStyle(effectStyle[effectKey], autoPrefix || false), `_layer-${effectKey}`, {\n ...mergedCSSConfig,\n prepend: true\n });\n });\n\n // ==================== Inject Style ====================\n // Inject style\n const style = updateCSS(styleStr, styleId, mergedCSSConfig);\n style[CSS_IN_JS_INSTANCE] = cache.instanceId;\n\n // Debug usage. Dev only\n if (process.env.NODE_ENV !== 'production') {\n style.setAttribute(ATTR_CACHE_PATH, fullPath.join('|'));\n }\n\n // ================ Inject Effect Style =================\n // Inject client side effect style\n effectRestKeys.forEach(effectKey => {\n updateCSS(normalizeStyle(effectStyle[effectKey], autoPrefix || false), `_effect-${effectKey}`, mergedCSSConfig);\n });\n }\n });\n}\nexport const extract = (cache, effectStyles, options) => {\n const [styleStr, styleId, effectStyle, clientOnly, order] = cache;\n const {\n plain,\n autoPrefix\n } = options || {};\n\n // Skip client only style\n if (clientOnly) {\n return null;\n }\n let keyStyleText = styleStr;\n\n // ====================== Share ======================\n // Used for @rc-component/util\n const sharedAttrs = {\n 'data-rc-order': 'prependQueue',\n 'data-rc-priority': `${order}`\n };\n\n // ====================== Style ======================\n keyStyleText = toStyleStr(styleStr, undefined, styleId, sharedAttrs, plain);\n\n // =============== Create effect style ===============\n if (effectStyle) {\n Object.keys(effectStyle).forEach(effectKey => {\n // Effect style can be reused\n if (!effectStyles[effectKey]) {\n effectStyles[effectKey] = true;\n const effectStyleStr = normalizeStyle(effectStyle[effectKey], autoPrefix || false);\n const effectStyleHTML = toStyleStr(effectStyleStr, undefined, `_effect-${effectKey}`, sharedAttrs, plain);\n if (effectKey.startsWith('@layer')) {\n keyStyleText = effectStyleHTML + keyStyleText;\n } else {\n keyStyleText += effectStyleHTML;\n }\n }\n });\n }\n return [order, styleId, keyStyleText];\n};"],"names":["SKIP_CHECK","MULTI_VALUE","normalizeStyle","styleStr","autoPrefix","serialize","compile","middleware","prefixer","stringify","isCompoundCSSProperty","value","injectSelectorHash","key","hashId","hashPriority","hashClassName","hashSelector","k","fullPath","firstPath","htmlElement","parseStyle","interpolation","config","root","injectHash","parentSelectors","layer","path","transformers","linters","effectStyle","parseKeyframes","keyframes","animationName","parsedStr","flattenList","list","fullList","item","originStyle","style","mergedStyle","prev","trans","subInjectHash","mergedKey","nextRoot","childEffectStyle","appendStyle","cssKey","cssValue","process","contentQuotesLinter","hashedAnimationLinter","linter","styleName","match","formatValue","unitless","actualValue","deps","uniqueHash","hash","STYLE_PREFIX","useStyleRegister","info","styleFn","nonce","clientOnly","order","mock","container","cache","enableLayer","React","StyleContext","isMergedClientSide","isClientSide","useGlobalCache","cachePath","existPath","inlineCacheStyleStr","styleHash","getStyleAndHash","styleObj","parsedStyle","styleId","cacheValue","fromHMR","removeCSS","ATTR_MARK","priority","CSS_FILE_STYLE","mergedCSSConfig","nonceStr","effectLayerKeys","effectRestKeys","effectKey","updateCSS","CSS_IN_JS_INSTANCE","ATTR_CACHE_PATH"],"mappings":";;;;;;;;;;;;;;AAWA,MAAMA,IAAa,gBACbC,IAAc;AAKb,SAASC,EAAeC,GAAUC,GAAY;AAEnD,UADmBA,IAAaC,EAAUC,EAAQH,CAAQ,GAAGI,EAAW,CAACC,GAAUC,CAAS,CAAC,CAAC,IAAIJ,EAAUC,EAAQH,CAAQ,GAAGM,CAAS,GACtH,QAAQ,kBAAkB,GAAG;AACjD;AACA,SAASC,GAAsBC,GAAO;AACpC,SAAO,OAAOA,KAAU,YAAYA,MAAUX,KAAcW,KAASV,KAAeU;AACtF;AAGA,SAASC,EAAmBC,GAAKC,GAAQC,GAAc;AACrD,MAAI,CAACD;AACH,WAAOD;AAET,QAAMG,IAAgB,IAAIF,CAAM,IAC1BG,IAAeF,MAAiB,QAAQ,UAAUC,CAAa,MAAMA;AAY3E,SATaH,EAAI,MAAM,GAAG,EAAE,IAAI,CAAAK,MAAK;AACnC,UAAMC,IAAWD,EAAE,KAAI,EAAG,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KxD+E,EAAe,QAAQ,CAAAC,MAAa;AAClC,UAAAC,EAAUlG,EAAe8B,EAAYmE,CAAS,GAAG/F,KAAc,EAAK,GAAG,WAAW+F,CAAS,IAAIJ,CAAe;AAAA,QAChH,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EAAC;AACH;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"useStyleRegister.js","sources":["../../../../../../node_modules/@ant-design/cssinjs/es/hooks/useStyleRegister.js"],"sourcesContent":["import hash from '@emotion/hash';\nimport { removeCSS, updateCSS } from \"@rc-component/util/es/Dom/dynamicCSS\";\nimport * as React from 'react';\n// @ts-ignore\nimport unitless from '@emotion/unitless';\nimport { compile, middleware, prefixer, serialize, stringify } from 'stylis';\nimport { contentQuotesLinter, hashedAnimationLinter } from \"../linters\";\nimport StyleContext, { ATTR_CACHE_PATH, ATTR_MARK, CSS_IN_JS_INSTANCE } from \"../StyleContext\";\nimport { isClientSide, isNonNullable, toStyleStr, where } from \"../util\";\nimport { CSS_FILE_STYLE, existPath, getStyleAndHash } from \"../util/cacheMapUtil\";\nimport useGlobalCache from \"./useGlobalCache\";\nconst SKIP_CHECK = '_skip_check_';\nconst MULTI_VALUE = '_multi_value_';\n// ============================================================================\n// == Parser ==\n// ============================================================================\n// Preprocessor style content to browser support one\nexport function normalizeStyle(styleStr, autoPrefix) {\n const serialized = autoPrefix ? serialize(compile(styleStr), middleware([prefixer, stringify])) : serialize(compile(styleStr), stringify);\n return serialized.replace(/\\{%%%\\:[^;];}/g, ';');\n}\nfunction isCompoundCSSProperty(value) {\n return typeof value === 'object' && value && (SKIP_CHECK in value || MULTI_VALUE in value);\n}\n\n// 注入 hash 值\nfunction injectSelectorHash(key, hashId, hashPriority = 'high') {\n if (!hashId) {\n return key;\n }\n const hashSelector = where({\n hashCls: hashId,\n hashPriority\n });\n\n // 注入 hashId\n const keys = key.split(',').map(k => {\n const fullPath = k.trim().split(/\\s+/);\n\n // 如果 Selector 第一个是 HTML Element,那我们就插到它的后面。反之,就插到最前面。\n let firstPath = fullPath[0] || '';\n const htmlElement = firstPath.match(/^\\w+/)?.[0] || '';\n firstPath = `${htmlElement}${hashSelector}${firstPath.slice(htmlElement.length)}`;\n return [firstPath, ...fullPath.slice(1)].join(' ');\n });\n return keys.join(',');\n}\n// Parse CSSObject to style content\nexport const parseStyle = (interpolation, config = {}, {\n root,\n injectHash,\n parentSelectors\n} = {\n root: true,\n parentSelectors: []\n}) => {\n const {\n hashId,\n layer,\n path,\n hashPriority,\n transformers = [],\n linters = []\n } = config;\n let styleStr = '';\n let effectStyle = {};\n function parseKeyframes(keyframes) {\n const animationName = keyframes.getName(hashId);\n if (!effectStyle[animationName]) {\n const [parsedStr] = parseStyle(keyframes.style, config, {\n root: false,\n parentSelectors\n });\n effectStyle[animationName] = `@keyframes ${keyframes.getName(hashId)}${parsedStr}`;\n }\n }\n function flattenList(list, fullList = []) {\n list.forEach(item => {\n if (Array.isArray(item)) {\n flattenList(item, fullList);\n } else if (item) {\n fullList.push(item);\n }\n });\n return fullList;\n }\n const flattenStyleList = flattenList(Array.isArray(interpolation) ? interpolation : [interpolation]);\n flattenStyleList.forEach(originStyle => {\n // Only root level can use raw string\n const style = typeof originStyle === 'string' && !root ? {} : originStyle;\n if (typeof style === 'string') {\n styleStr += `${style}\\n`;\n } else if (style._keyframe) {\n // Keyframe\n parseKeyframes(style);\n } else {\n const mergedStyle = transformers.reduce((prev, trans) => trans?.visit?.(prev) || prev, style);\n\n // Normal CSSObject\n Object.keys(mergedStyle).forEach(key => {\n const value = mergedStyle[key];\n if (typeof value === 'object' && value && (key !== 'animationName' || !value._keyframe) && !isCompoundCSSProperty(value)) {\n let subInjectHash = false;\n\n // 当成嵌套对象来处理\n let mergedKey = key.trim();\n // Whether treat child as root. In most case it is false.\n let nextRoot = false;\n\n // 拆分多个选择器\n if ((root || injectHash) && hashId) {\n if (mergedKey.startsWith('@')) {\n // 略过媒体查询,交给子节点继续插入 hashId\n subInjectHash = true;\n } else if (mergedKey === '&') {\n // 抹掉 root selector 上的单个 &\n mergedKey = injectSelectorHash('', hashId, hashPriority);\n } else {\n // 注入 hashId\n mergedKey = injectSelectorHash(key, hashId, hashPriority);\n }\n } else if (root && !hashId && (mergedKey === '&' || mergedKey === '')) {\n // In case of `{ '&': { a: { color: 'red' } } }` or `{ '': { a: { color: 'red' } } }` without hashId,\n // we will get `&{a:{color:red;}}` or `{a:{color:red;}}` string for stylis to compile.\n // But it does not conform to stylis syntax,\n // and finally we will get `{color:red;}` as css, which is wrong.\n // So we need to remove key in root, and treat child `{ a: { color: 'red' } }` as root.\n mergedKey = '';\n nextRoot = true;\n }\n const [parsedStr, childEffectStyle] = parseStyle(value, config, {\n root: nextRoot,\n injectHash: subInjectHash,\n parentSelectors: [...parentSelectors, mergedKey]\n });\n effectStyle = {\n ...effectStyle,\n ...childEffectStyle\n };\n styleStr += `${mergedKey}${parsedStr}`;\n } else {\n function appendStyle(cssKey, cssValue) {\n if (process.env.NODE_ENV !== 'production' && (typeof value !== 'object' || !value?.[SKIP_CHECK])) {\n [contentQuotesLinter, hashedAnimationLinter, ...linters].forEach(linter => linter(cssKey, cssValue, {\n path,\n hashId,\n parentSelectors\n }));\n }\n\n // 如果是样式则直接插入\n const styleName = cssKey.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`);\n\n // Auto suffix with px\n let formatValue = cssValue;\n if (!unitless[cssKey] && typeof formatValue === 'number' && formatValue !== 0) {\n formatValue = `${formatValue}px`;\n }\n\n // handle animationName & Keyframe value\n if (cssKey === 'animationName' && cssValue?._keyframe) {\n parseKeyframes(cssValue);\n formatValue = cssValue.getName(hashId);\n }\n styleStr += `${styleName}:${formatValue};`;\n }\n const actualValue = value?.value ?? value;\n if (typeof value === 'object' && value?.[MULTI_VALUE] && Array.isArray(actualValue)) {\n actualValue.forEach(item => {\n appendStyle(key, item);\n });\n } else {\n if (isNonNullable(actualValue)) {\n appendStyle(key, actualValue);\n }\n }\n }\n });\n }\n });\n if (!root) {\n styleStr = `{${styleStr}}`;\n } else if (layer) {\n // fixme: https://github.com/thysultan/stylis/pull/339\n if (styleStr) {\n styleStr = `@layer ${layer.name} {${styleStr}}`;\n }\n if (layer.dependencies) {\n effectStyle[`@layer ${layer.name}`] = layer.dependencies.map(deps => `@layer ${deps}, ${layer.name};`).join('\\n');\n }\n }\n return [styleStr, effectStyle];\n};\n\n// ============================================================================\n// == Register ==\n// ============================================================================\nexport function uniqueHash(path, styleStr) {\n return hash(`${path.join('%')}${styleStr}`);\n}\nexport const STYLE_PREFIX = 'style';\n/**\n * Register a style to the global style sheet.\n */\nexport default function useStyleRegister(info, styleFn) {\n const {\n path,\n hashId,\n layer,\n nonce,\n clientOnly,\n order = 0\n } = info;\n const {\n mock,\n hashPriority,\n container,\n transformers,\n linters,\n cache,\n layer: enableLayer,\n autoPrefix\n } = React.useContext(StyleContext);\n const fullPath = [hashId || ''];\n if (enableLayer) {\n fullPath.push('layer');\n }\n fullPath.push(...path);\n\n // Check if need insert style\n let isMergedClientSide = isClientSide;\n if (process.env.NODE_ENV !== 'production' && mock !== undefined) {\n isMergedClientSide = mock === 'client';\n }\n useGlobalCache(STYLE_PREFIX, fullPath,\n // Create cache if needed\n () => {\n const cachePath = fullPath.join('|');\n\n // Get style from SSR inline style directly\n if (existPath(cachePath)) {\n const [inlineCacheStyleStr, styleHash] = getStyleAndHash(cachePath);\n if (inlineCacheStyleStr) {\n return [inlineCacheStyleStr, styleHash, {}, clientOnly, order];\n }\n }\n\n // Generate style\n const styleObj = styleFn();\n const [parsedStyle, effectStyle] = parseStyle(styleObj, {\n hashId,\n hashPriority,\n layer: enableLayer ? layer : undefined,\n path: path.join('-'),\n transformers,\n linters\n });\n const styleStr = normalizeStyle(parsedStyle, autoPrefix || false);\n const styleId = uniqueHash(fullPath, styleStr);\n return [styleStr, styleId, effectStyle, clientOnly, order];\n },\n // Remove cache if no need\n (cacheValue, fromHMR) => {\n const [, styleId] = cacheValue;\n if (fromHMR && isClientSide) {\n removeCSS(styleId, {\n mark: ATTR_MARK,\n attachTo: container\n });\n }\n },\n // Effect: Inject style here\n cacheValue => {\n const [styleStr, styleId, effectStyle,, priority] = cacheValue;\n if (isMergedClientSide && styleStr !== CSS_FILE_STYLE) {\n const mergedCSSConfig = {\n mark: ATTR_MARK,\n prepend: enableLayer ? false : 'queue',\n attachTo: container,\n priority\n };\n const nonceStr = typeof nonce === 'function' ? nonce() : nonce;\n if (nonceStr) {\n mergedCSSConfig.csp = {\n nonce: nonceStr\n };\n }\n\n // ================= Split Effect Style =================\n // We will split effectStyle here since @layer should be at the top level\n const effectLayerKeys = [];\n const effectRestKeys = [];\n Object.keys(effectStyle).forEach(key => {\n if (key.startsWith('@layer')) {\n effectLayerKeys.push(key);\n } else {\n effectRestKeys.push(key);\n }\n });\n\n // ================= Inject Layer Style =================\n // Inject layer style\n effectLayerKeys.forEach(effectKey => {\n updateCSS(normalizeStyle(effectStyle[effectKey], autoPrefix || false), `_layer-${effectKey}`, {\n ...mergedCSSConfig,\n prepend: true\n });\n });\n\n // ==================== Inject Style ====================\n // Inject style\n const style = updateCSS(styleStr, styleId, mergedCSSConfig);\n style[CSS_IN_JS_INSTANCE] = cache.instanceId;\n\n // Debug usage. Dev only\n if (process.env.NODE_ENV !== 'production') {\n style.setAttribute(ATTR_CACHE_PATH, fullPath.join('|'));\n }\n\n // ================ Inject Effect Style =================\n // Inject client side effect style\n effectRestKeys.forEach(effectKey => {\n updateCSS(normalizeStyle(effectStyle[effectKey], autoPrefix || false), `_effect-${effectKey}`, mergedCSSConfig);\n });\n }\n });\n}\nexport const extract = (cache, effectStyles, options) => {\n const [styleStr, styleId, effectStyle, clientOnly, order] = cache;\n const {\n plain,\n autoPrefix\n } = options || {};\n\n // Skip client only style\n if (clientOnly) {\n return null;\n }\n let keyStyleText = styleStr;\n\n // ====================== Share ======================\n // Used for @rc-component/util\n const sharedAttrs = {\n 'data-rc-order': 'prependQueue',\n 'data-rc-priority': `${order}`\n };\n\n // ====================== Style ======================\n keyStyleText = toStyleStr(styleStr, undefined, styleId, sharedAttrs, plain);\n\n // =============== Create effect style ===============\n if (effectStyle) {\n Object.keys(effectStyle).forEach(effectKey => {\n // Effect style can be reused\n if (!effectStyles[effectKey]) {\n effectStyles[effectKey] = true;\n const effectStyleStr = normalizeStyle(effectStyle[effectKey], autoPrefix || false);\n const effectStyleHTML = toStyleStr(effectStyleStr, undefined, `_effect-${effectKey}`, sharedAttrs, plain);\n if (effectKey.startsWith('@layer')) {\n keyStyleText = effectStyleHTML + keyStyleText;\n } else {\n keyStyleText += effectStyleHTML;\n }\n }\n });\n }\n return [order, styleId, keyStyleText];\n};"],"names":["SKIP_CHECK","MULTI_VALUE","normalizeStyle","styleStr","autoPrefix","serialize","compile","middleware","prefixer","stringify","isCompoundCSSProperty","value","injectSelectorHash","key","hashId","hashPriority","hashSelector","where","k","fullPath","firstPath","htmlElement","parseStyle","interpolation","config","root","injectHash","parentSelectors","layer","path","transformers","linters","effectStyle","parseKeyframes","keyframes","animationName","parsedStr","flattenList","list","fullList","item","originStyle","style","mergedStyle","prev","trans","subInjectHash","mergedKey","nextRoot","childEffectStyle","appendStyle","cssKey","cssValue","process","contentQuotesLinter","hashedAnimationLinter","linter","styleName","match","formatValue","unitless","actualValue","isNonNullable","deps","uniqueHash","hash","STYLE_PREFIX","useStyleRegister","info","styleFn","nonce","clientOnly","order","mock","container","cache","enableLayer","React","StyleContext","isMergedClientSide","isClientSide","useGlobalCache","cachePath","existPath","inlineCacheStyleStr","styleHash","getStyleAndHash","styleObj","parsedStyle","styleId","cacheValue","fromHMR","removeCSS","ATTR_MARK","priority","CSS_FILE_STYLE","mergedCSSConfig","nonceStr","effectLayerKeys","effectRestKeys","effectKey","updateCSS","CSS_IN_JS_INSTANCE","ATTR_CACHE_PATH"],"mappings":";;;;;;;;;;;;;;AAWA,MAAMA,IAAa,gBACbC,IAAc;AAKb,SAASC,EAAeC,GAAUC,GAAY;AAEnD,UADmBA,IAAaC,EAAUC,EAAQH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C,UAAIA,EAAI,WAAW,QAAQ,IACzBqF,EAAgB,KAAKrF,CAAG,IAExBsF,EAAe,KAAKtF,CAAG;AAAA,QAE3B,CAAC,GAIDqF,EAAgB,QAAQ,CAAAE,MAAa;AACnC,UAAAC,EAAUnG,EAAe8B,EAAYoE,CAAS,GAAGhG,KAAc,EAAK,GAAG,UAAUgG,CAAS,IAAI;AAAA,YAC5F,GAAGJ;AAAA,YACH,SAAS;AAAA,UACnB,CAAS;AAAA,QACH,CAAC;AAID,cAAMtD,IAAQ2D,EAAUlG,GAAUsF,GAASO,CAAe;AAC1D,QAAAtD,EAAM4D,CAAkB,IAAI3B,EAAM,YAG9BtB,EAAQ,IAAI,aAAa,gBAC3BX,EAAM,aAAa6D,GAAiBpF,EAAS,KAAK,GAAG,CAAC,GAKxDgF,EAAe,QAAQ,CAAAC,MAAa;AAClC,UAAAC,EAAUnG,EAAe8B,EAAYoE,CAAS,GAAGhG,KAAc,EAAK,GAAG,WAAWgG,CAAS,IAAIJ,CAAe;AAAA,QAChH,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EAAC;AACH;","x_google_ignoreList":[0]}
|
|
@@ -1,46 +1,48 @@
|
|
|
1
1
|
import c from "../../../../@emotion/hash/dist/hash.browser.esm.js";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
function w(
|
|
6
|
-
let r =
|
|
7
|
-
for (let n = 0; n <
|
|
8
|
-
const o =
|
|
2
|
+
import u from "../../../../@rc-component/util/es/Dom/canUseDom.js";
|
|
3
|
+
import l from "../theme/Theme.js";
|
|
4
|
+
const a = /* @__PURE__ */ new WeakMap(), s = {};
|
|
5
|
+
function w(e, t) {
|
|
6
|
+
let r = a;
|
|
7
|
+
for (let n = 0; n < t.length; n += 1) {
|
|
8
|
+
const o = t[n];
|
|
9
9
|
r.has(o) || r.set(o, /* @__PURE__ */ new WeakMap()), r = r.get(o);
|
|
10
10
|
}
|
|
11
|
-
return r.has(s) || r.set(s,
|
|
11
|
+
return r.has(s) || r.set(s, e()), r.get(s);
|
|
12
12
|
}
|
|
13
13
|
const i = /* @__PURE__ */ new WeakMap();
|
|
14
|
-
function f(
|
|
15
|
-
let
|
|
16
|
-
return
|
|
17
|
-
const n =
|
|
18
|
-
|
|
19
|
-
}),
|
|
14
|
+
function f(e) {
|
|
15
|
+
let t = i.get(e) || "";
|
|
16
|
+
return t || (Object.keys(e).forEach((r) => {
|
|
17
|
+
const n = e[r];
|
|
18
|
+
t += r, n instanceof l ? t += n.id : n && typeof n == "object" ? t += f(n) : t += n;
|
|
19
|
+
}), t = c(t), i.set(e, t)), t;
|
|
20
20
|
}
|
|
21
|
-
function $(
|
|
22
|
-
return c(`${
|
|
21
|
+
function $(e, t) {
|
|
22
|
+
return c(`${t}_${f(e)}`);
|
|
23
23
|
}
|
|
24
|
-
const
|
|
25
|
-
function
|
|
26
|
-
return typeof
|
|
24
|
+
const b = u();
|
|
25
|
+
function d(e) {
|
|
26
|
+
return typeof e == "number" ? `${e}px` : e;
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function g(e) {
|
|
29
29
|
const {
|
|
30
|
-
hashCls:
|
|
30
|
+
hashCls: t,
|
|
31
31
|
hashPriority: r = "low"
|
|
32
|
-
} =
|
|
33
|
-
if (!
|
|
32
|
+
} = e || {};
|
|
33
|
+
if (!t)
|
|
34
34
|
return "";
|
|
35
|
-
const n = `.${
|
|
35
|
+
const n = `.${t}`;
|
|
36
36
|
return r === "low" ? `:where(${n})` : n;
|
|
37
37
|
}
|
|
38
|
+
const k = (e) => e != null;
|
|
38
39
|
export {
|
|
39
40
|
f as flattenToken,
|
|
40
|
-
|
|
41
|
+
b as isClientSide,
|
|
42
|
+
k as isNonNullable,
|
|
41
43
|
w as memoResult,
|
|
42
44
|
$ as token2key,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
d as unit,
|
|
46
|
+
g as where
|
|
45
47
|
};
|
|
46
48
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../node_modules/@ant-design/cssinjs/es/util/index.js"],"sourcesContent":["import hash from '@emotion/hash';\nimport canUseDom from \"@rc-component/util/es/Dom/canUseDom\";\nimport { removeCSS, updateCSS } from \"@rc-component/util/es/Dom/dynamicCSS\";\nimport { ATTR_MARK, ATTR_TOKEN } from \"../StyleContext\";\nimport { Theme } from \"../theme\";\n\n// Create a cache for memo concat\n\nconst resultCache = new WeakMap();\nconst RESULT_VALUE = {};\nexport function memoResult(callback, deps) {\n let current = resultCache;\n for (let i = 0; i < deps.length; i += 1) {\n const dep = deps[i];\n if (!current.has(dep)) {\n current.set(dep, new WeakMap());\n }\n current = current.get(dep);\n }\n if (!current.has(RESULT_VALUE)) {\n current.set(RESULT_VALUE, callback());\n }\n return current.get(RESULT_VALUE);\n}\n\n// Create a cache here to avoid always loop generate\nconst flattenTokenCache = new WeakMap();\n\n/**\n * Flatten token to string, this will auto cache the result when token not change\n */\nexport function flattenToken(token) {\n let str = flattenTokenCache.get(token) || '';\n if (!str) {\n Object.keys(token).forEach(key => {\n const value = token[key];\n str += key;\n if (value instanceof Theme) {\n str += value.id;\n } else if (value && typeof value === 'object') {\n str += flattenToken(value);\n } else {\n str += value;\n }\n });\n\n // https://github.com/ant-design/ant-design/issues/48386\n // Should hash the string to avoid style tag name too long\n str = hash(str);\n\n // Put in cache\n flattenTokenCache.set(token, str);\n }\n return str;\n}\n\n/**\n * Convert derivative token to key string\n */\nexport function token2key(token, salt) {\n return hash(`${salt}_${flattenToken(token)}`);\n}\nconst randomSelectorKey = `random-${Date.now()}-${Math.random()}`.replace(/\\./g, '');\n\n// Magic `content` for detect selector support\nconst checkContent = '_bAmBoO_';\nfunction supportSelector(styleStr, handleElement, supportCheck) {\n if (canUseDom()) {\n updateCSS(styleStr, randomSelectorKey);\n const ele = document.createElement('div');\n ele.style.position = 'fixed';\n ele.style.left = '0';\n ele.style.top = '0';\n handleElement?.(ele);\n document.body.appendChild(ele);\n if (process.env.NODE_ENV !== 'production') {\n ele.innerHTML = 'Test';\n ele.style.zIndex = '9999999';\n }\n const support = supportCheck ? supportCheck(ele) : getComputedStyle(ele).content?.includes(checkContent);\n ele.parentNode?.removeChild(ele);\n removeCSS(randomSelectorKey);\n return support;\n }\n return false;\n}\nlet canLayer = undefined;\nexport function supportLayer() {\n if (canLayer === undefined) {\n canLayer = supportSelector(`@layer ${randomSelectorKey} { .${randomSelectorKey} { content: \"${checkContent}\"!important; } }`, ele => {\n ele.className = randomSelectorKey;\n });\n }\n return canLayer;\n}\nlet canWhere = undefined;\nexport function supportWhere() {\n if (canWhere === undefined) {\n canWhere = supportSelector(`:where(.${randomSelectorKey}) { content: \"${checkContent}\"!important; }`, ele => {\n ele.className = randomSelectorKey;\n });\n }\n return canWhere;\n}\nlet canLogic = undefined;\nexport function supportLogicProps() {\n if (canLogic === undefined) {\n canLogic = supportSelector(`.${randomSelectorKey} { inset-block: 93px !important; }`, ele => {\n ele.className = randomSelectorKey;\n }, ele => getComputedStyle(ele).bottom === '93px');\n }\n return canLogic;\n}\nexport const isClientSide = canUseDom();\nexport function unit(num) {\n if (typeof num === 'number') {\n return `${num}px`;\n }\n return num;\n}\nexport function toStyleStr(style, tokenKey, styleId, customizeAttrs = {}, plain = false) {\n if (plain) {\n return style;\n }\n const attrs = {\n ...customizeAttrs,\n [ATTR_TOKEN]: tokenKey,\n [ATTR_MARK]: styleId\n };\n const attrStr = Object.keys(attrs).map(attr => {\n const val = attrs[attr];\n return val ? `${attr}=\"${val}\"` : null;\n }).filter(v => v).join(' ');\n return `<style ${attrStr}>${style}</style>`;\n}\nexport function where(options) {\n const {\n hashCls,\n hashPriority = 'low'\n } = options || {};\n if (!hashCls) {\n return '';\n }\n const hashSelector = `.${hashCls}`;\n return hashPriority === 'low' ? `:where(${hashSelector})` : hashSelector;\n}"],"names":["resultCache","RESULT_VALUE","memoResult","callback","deps","current","i","dep","flattenTokenCache","flattenToken","token","str","key","value","Theme","hash","token2key","salt","isClientSide","canUseDom","unit","num","where","options","hashCls","hashPriority","hashSelector"],"mappings":";;;AAQA,MAAMA,IAAc,oBAAI,QAAO,GACzBC,IAAe,CAAA;AACd,SAASC,EAAWC,GAAUC,GAAM;AACzC,MAAIC,IAAUL;AACd,WAASM,IAAI,GAAGA,IAAIF,EAAK,QAAQE,KAAK,GAAG;AACvC,UAAMC,IAAMH,EAAKE,CAAC;AAClB,IAAKD,EAAQ,IAAIE,CAAG,KAClBF,EAAQ,IAAIE,GAAK,oBAAI,QAAO,CAAE,GAEhCF,IAAUA,EAAQ,IAAIE,CAAG;AAAA,EAC3B;AACA,SAAKF,EAAQ,IAAIJ,CAAY,KAC3BI,EAAQ,IAAIJ,GAAcE,GAAU,GAE/BE,EAAQ,IAAIJ,CAAY;AACjC;AAGA,MAAMO,IAAoB,oBAAI,QAAO;AAK9B,SAASC,EAAaC,GAAO;AAClC,MAAIC,IAAMH,EAAkB,IAAIE,CAAK,KAAK;AAC1C,SAAKC,MACH,OAAO,KAAKD,CAAK,EAAE,QAAQ,CAAAE,MAAO;AAChC,UAAMC,IAAQH,EAAME,CAAG;AACvB,IAAAD,KAAOC,GACHC,aAAiBC,IACnBH,KAAOE,EAAM,KACJA,KAAS,OAAOA,KAAU,WACnCF,KAAOF,EAAaI,CAAK,IAEzBF,KAAOE;AAAA,EAEX,CAAC,GAIDF,IAAMI,EAAKJ,CAAG,GAGdH,EAAkB,IAAIE,GAAOC,CAAG,IAE3BA;AACT;AAKO,SAASK,EAAUN,GAAOO,GAAM;AACrC,SAAOF,EAAK,GAAGE,CAAI,IAAIR,EAAaC,CAAK,CAAC,EAAE;AAC9C;AAoDY,MAACQ,IAAeC,EAAS;AAC9B,SAASC,EAAKC,GAAK;AACxB,SAAI,OAAOA,KAAQ,WACV,GAAGA,CAAG,OAERA;AACT;AAgBO,SAASC,EAAMC,GAAS;AAC7B,QAAM;AAAA,IACJ,SAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,EACnB,IAAMF,KAAW,CAAA;AACf,MAAI,CAACC;AACH,WAAO;AAET,QAAME,IAAe,IAAIF,CAAO;AAChC,SAAOC,MAAiB,QAAQ,UAAUC,CAAY,MAAMA;AAC9D;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../node_modules/@ant-design/cssinjs/es/util/index.js"],"sourcesContent":["import hash from '@emotion/hash';\nimport canUseDom from \"@rc-component/util/es/Dom/canUseDom\";\nimport { removeCSS, updateCSS } from \"@rc-component/util/es/Dom/dynamicCSS\";\nimport { ATTR_MARK, ATTR_TOKEN } from \"../StyleContext\";\nimport { Theme } from \"../theme\";\n\n// Create a cache for memo concat\n\nconst resultCache = new WeakMap();\nconst RESULT_VALUE = {};\nexport function memoResult(callback, deps) {\n let current = resultCache;\n for (let i = 0; i < deps.length; i += 1) {\n const dep = deps[i];\n if (!current.has(dep)) {\n current.set(dep, new WeakMap());\n }\n current = current.get(dep);\n }\n if (!current.has(RESULT_VALUE)) {\n current.set(RESULT_VALUE, callback());\n }\n return current.get(RESULT_VALUE);\n}\n\n// Create a cache here to avoid always loop generate\nconst flattenTokenCache = new WeakMap();\n\n/**\n * Flatten token to string, this will auto cache the result when token not change\n */\nexport function flattenToken(token) {\n let str = flattenTokenCache.get(token) || '';\n if (!str) {\n Object.keys(token).forEach(key => {\n const value = token[key];\n str += key;\n if (value instanceof Theme) {\n str += value.id;\n } else if (value && typeof value === 'object') {\n str += flattenToken(value);\n } else {\n str += value;\n }\n });\n\n // https://github.com/ant-design/ant-design/issues/48386\n // Should hash the string to avoid style tag name too long\n str = hash(str);\n\n // Put in cache\n flattenTokenCache.set(token, str);\n }\n return str;\n}\n\n/**\n * Convert derivative token to key string\n */\nexport function token2key(token, salt) {\n return hash(`${salt}_${flattenToken(token)}`);\n}\nconst randomSelectorKey = `random-${Date.now()}-${Math.random()}`.replace(/\\./g, '');\n\n// Magic `content` for detect selector support\nconst checkContent = '_bAmBoO_';\nfunction supportSelector(styleStr, handleElement, supportCheck) {\n if (canUseDom()) {\n updateCSS(styleStr, randomSelectorKey);\n const ele = document.createElement('div');\n ele.style.position = 'fixed';\n ele.style.left = '0';\n ele.style.top = '0';\n handleElement?.(ele);\n document.body.appendChild(ele);\n if (process.env.NODE_ENV !== 'production') {\n ele.innerHTML = 'Test';\n ele.style.zIndex = '9999999';\n }\n const support = supportCheck ? supportCheck(ele) : getComputedStyle(ele).content?.includes(checkContent);\n ele.parentNode?.removeChild(ele);\n removeCSS(randomSelectorKey);\n return support;\n }\n return false;\n}\nlet canLayer = undefined;\nexport function supportLayer() {\n if (canLayer === undefined) {\n canLayer = supportSelector(`@layer ${randomSelectorKey} { .${randomSelectorKey} { content: \"${checkContent}\"!important; } }`, ele => {\n ele.className = randomSelectorKey;\n });\n }\n return canLayer;\n}\nlet canWhere = undefined;\nexport function supportWhere() {\n if (canWhere === undefined) {\n canWhere = supportSelector(`:where(.${randomSelectorKey}) { content: \"${checkContent}\"!important; }`, ele => {\n ele.className = randomSelectorKey;\n });\n }\n return canWhere;\n}\nlet canLogic = undefined;\nexport function supportLogicProps() {\n if (canLogic === undefined) {\n canLogic = supportSelector(`.${randomSelectorKey} { inset-block: 93px !important; }`, ele => {\n ele.className = randomSelectorKey;\n }, ele => getComputedStyle(ele).bottom === '93px');\n }\n return canLogic;\n}\nexport const isClientSide = canUseDom();\nexport function unit(num) {\n if (typeof num === 'number') {\n return `${num}px`;\n }\n return num;\n}\nexport function toStyleStr(style, tokenKey, styleId, customizeAttrs = {}, plain = false) {\n if (plain) {\n return style;\n }\n const attrs = {\n ...customizeAttrs,\n [ATTR_TOKEN]: tokenKey,\n [ATTR_MARK]: styleId\n };\n const attrStr = Object.keys(attrs).map(attr => {\n const val = attrs[attr];\n return val ? `${attr}=\"${val}\"` : null;\n }).filter(v => v).join(' ');\n return `<style ${attrStr}>${style}</style>`;\n}\nexport function where(options) {\n const {\n hashCls,\n hashPriority = 'low'\n } = options || {};\n if (!hashCls) {\n return '';\n }\n const hashSelector = `.${hashCls}`;\n return hashPriority === 'low' ? `:where(${hashSelector})` : hashSelector;\n}\nexport const isNonNullable = val => {\n return val !== undefined && val !== null;\n};"],"names":["resultCache","RESULT_VALUE","memoResult","callback","deps","current","i","dep","flattenTokenCache","flattenToken","token","str","key","value","Theme","hash","token2key","salt","isClientSide","canUseDom","unit","num","where","options","hashCls","hashPriority","hashSelector","isNonNullable","val"],"mappings":";;;AAQA,MAAMA,IAAc,oBAAI,QAAO,GACzBC,IAAe,CAAA;AACd,SAASC,EAAWC,GAAUC,GAAM;AACzC,MAAIC,IAAUL;AACd,WAASM,IAAI,GAAGA,IAAIF,EAAK,QAAQE,KAAK,GAAG;AACvC,UAAMC,IAAMH,EAAKE,CAAC;AAClB,IAAKD,EAAQ,IAAIE,CAAG,KAClBF,EAAQ,IAAIE,GAAK,oBAAI,QAAO,CAAE,GAEhCF,IAAUA,EAAQ,IAAIE,CAAG;AAAA,EAC3B;AACA,SAAKF,EAAQ,IAAIJ,CAAY,KAC3BI,EAAQ,IAAIJ,GAAcE,GAAU,GAE/BE,EAAQ,IAAIJ,CAAY;AACjC;AAGA,MAAMO,IAAoB,oBAAI,QAAO;AAK9B,SAASC,EAAaC,GAAO;AAClC,MAAIC,IAAMH,EAAkB,IAAIE,CAAK,KAAK;AAC1C,SAAKC,MACH,OAAO,KAAKD,CAAK,EAAE,QAAQ,CAAAE,MAAO;AAChC,UAAMC,IAAQH,EAAME,CAAG;AACvB,IAAAD,KAAOC,GACHC,aAAiBC,IACnBH,KAAOE,EAAM,KACJA,KAAS,OAAOA,KAAU,WACnCF,KAAOF,EAAaI,CAAK,IAEzBF,KAAOE;AAAA,EAEX,CAAC,GAIDF,IAAMI,EAAKJ,CAAG,GAGdH,EAAkB,IAAIE,GAAOC,CAAG,IAE3BA;AACT;AAKO,SAASK,EAAUN,GAAOO,GAAM;AACrC,SAAOF,EAAK,GAAGE,CAAI,IAAIR,EAAaC,CAAK,CAAC,EAAE;AAC9C;AAoDY,MAACQ,IAAeC,EAAS;AAC9B,SAASC,EAAKC,GAAK;AACxB,SAAI,OAAOA,KAAQ,WACV,GAAGA,CAAG,OAERA;AACT;AAgBO,SAASC,EAAMC,GAAS;AAC7B,QAAM;AAAA,IACJ,SAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,EACnB,IAAMF,KAAW,CAAA;AACf,MAAI,CAACC;AACH,WAAO;AAET,QAAME,IAAe,IAAIF,CAAO;AAChC,SAAOC,MAAiB,QAAQ,UAAUC,CAAY,MAAMA;AAC9D;AACY,MAACC,IAAgB,CAAAC,MACCA,KAAQ;","x_google_ignoreList":[0]}
|
|
@@ -33,9 +33,9 @@ var M = /* @__PURE__ */ (function() {
|
|
|
33
33
|
key: "validate",
|
|
34
34
|
value: function(t) {
|
|
35
35
|
var u = this, m = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, k = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : function() {
|
|
36
|
-
},
|
|
36
|
+
}, f = t, n = m, E = k;
|
|
37
37
|
if (typeof n == "function" && (E = n, n = {}), !this.rules || Object.keys(this.rules).length === 0)
|
|
38
|
-
return E && E(null,
|
|
38
|
+
return E && E(null, f), Promise.resolve(f);
|
|
39
39
|
function B(r) {
|
|
40
40
|
var a = [], e = {};
|
|
41
41
|
function v(o) {
|
|
@@ -47,7 +47,7 @@ var M = /* @__PURE__ */ (function() {
|
|
|
47
47
|
}
|
|
48
48
|
for (var i = 0; i < r.length; i++)
|
|
49
49
|
v(r[i]);
|
|
50
|
-
a.length ? (e = N(a), E(a, e)) : E(null,
|
|
50
|
+
a.length ? (e = N(a), E(a, e)) : E(null, f);
|
|
51
51
|
}
|
|
52
52
|
if (n.messages) {
|
|
53
53
|
var j = this.messages();
|
|
@@ -56,38 +56,38 @@ var M = /* @__PURE__ */ (function() {
|
|
|
56
56
|
n.messages = this.messages();
|
|
57
57
|
var O = {}, D = n.keys || Object.keys(this.rules);
|
|
58
58
|
return D.forEach(function(r) {
|
|
59
|
-
var a = u.rules[r], e =
|
|
59
|
+
var a = u.rules[r], e = f[r];
|
|
60
60
|
a.forEach(function(v) {
|
|
61
61
|
var i = v;
|
|
62
|
-
typeof i.transform == "function" && (
|
|
62
|
+
typeof i.transform == "function" && (f === t && (f = b({}, f)), e = f[r] = i.transform(e), e != null && (i.type = i.type || (Array.isArray(e) ? "array" : C(e)))), typeof i == "function" ? i = {
|
|
63
63
|
validator: i
|
|
64
64
|
} : i = b({}, i), i.validator = u.getValidationMethod(i), i.validator && (i.field = r, i.fullField = i.fullField || r, i.type = u.getType(i), O[r] = O[r] || [], O[r].push({
|
|
65
65
|
rule: i,
|
|
66
66
|
value: e,
|
|
67
|
-
source:
|
|
67
|
+
source: f,
|
|
68
68
|
field: r
|
|
69
69
|
}));
|
|
70
70
|
});
|
|
71
71
|
}), K(O, n, function(r, a) {
|
|
72
72
|
var e = r.rule, v = (e.type === "object" || e.type === "array") && (C(e.fields) === "object" || C(e.defaultField) === "object");
|
|
73
73
|
v = v && (e.required || !e.required && r.value), e.field = r.field;
|
|
74
|
-
function i(
|
|
74
|
+
function i(l, y) {
|
|
75
75
|
return b(b({}, y), {}, {
|
|
76
|
-
fullField: "".concat(e.fullField, ".").concat(
|
|
77
|
-
fullFields: e.fullFields ? [].concat(q(e.fullFields), [
|
|
76
|
+
fullField: "".concat(e.fullField, ".").concat(l),
|
|
77
|
+
fullFields: e.fullFields ? [].concat(q(e.fullFields), [l]) : [l]
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
function o() {
|
|
81
|
-
var
|
|
82
|
-
!n.suppressWarning && y.length && h.warning("async-validator:", y), y.length && e.message !== void 0 && (y = [].concat(e.message));
|
|
83
|
-
var p = y.map(W(e,
|
|
81
|
+
var l = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], y = Array.isArray(l) ? l : [l];
|
|
82
|
+
!n.suppressWarning && y.length && h.warning("async-validator:", y), y.length && e.message !== void 0 && e.message !== null && (y = [].concat(e.message));
|
|
83
|
+
var p = y.map(W(e, f));
|
|
84
84
|
if (n.first && p.length)
|
|
85
85
|
return a(p);
|
|
86
86
|
if (!v)
|
|
87
87
|
a(p);
|
|
88
88
|
else {
|
|
89
89
|
if (e.required && !r.value)
|
|
90
|
-
return e.message !== void 0 ? p = [].concat(e.message).map(W(e,
|
|
90
|
+
return e.message !== void 0 ? p = [].concat(e.message).map(W(e, f)) : n.error && (p = [n.error(e, U(n.messages.required, e.field))]), a(p);
|
|
91
91
|
var A = {};
|
|
92
92
|
e.defaultField && Object.keys(r.value).map(function(d) {
|
|
93
93
|
A[d] = e.defaultField;
|
|
@@ -110,22 +110,22 @@ var M = /* @__PURE__ */ (function() {
|
|
|
110
110
|
else if (e.validator) {
|
|
111
111
|
try {
|
|
112
112
|
s = e.validator(e, r.value, o, r.source, n);
|
|
113
|
-
} catch (
|
|
113
|
+
} catch (l) {
|
|
114
114
|
var V, _;
|
|
115
|
-
(V = (_ = console).error) === null || V === void 0 || V.call(_,
|
|
116
|
-
throw
|
|
117
|
-
}, 0), o(
|
|
115
|
+
(V = (_ = console).error) === null || V === void 0 || V.call(_, l), n.suppressValidatorError || setTimeout(function() {
|
|
116
|
+
throw l;
|
|
117
|
+
}, 0), o(l.message);
|
|
118
118
|
}
|
|
119
119
|
s === !0 ? o() : s === !1 ? o(typeof e.message == "function" ? e.message(e.fullField || e.field) : e.message || "".concat(e.fullField || e.field, " fails")) : s instanceof Array ? o(s) : s instanceof Error && o(s.message);
|
|
120
120
|
}
|
|
121
121
|
s && s.then && s.then(function() {
|
|
122
122
|
return o();
|
|
123
|
-
}, function(
|
|
124
|
-
return o(
|
|
123
|
+
}, function(l) {
|
|
124
|
+
return o(l);
|
|
125
125
|
});
|
|
126
126
|
}, function(r) {
|
|
127
127
|
B(r);
|
|
128
|
-
},
|
|
128
|
+
}, f);
|
|
129
129
|
}
|
|
130
130
|
}, {
|
|
131
131
|
key: "getType",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../node_modules/@rc-component/async-validator/es/index.js"],"sourcesContent":["import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport { messages as defaultMessages, newMessages } from \"./messages\";\nimport { asyncMap, complementError, convertFieldsError, deepMerge, format, warning } from \"./util\";\nimport validators from \"./validator/index\";\nexport * from \"./interface\";\n\n/**\n * Encapsulates a validation schema.\n *\n * @param descriptor An object declaring validation rules\n * for this schema.\n */\nvar Schema = /*#__PURE__*/function () {\n function Schema(descriptor) {\n _classCallCheck(this, Schema);\n // ======================== Instance ========================\n _defineProperty(this, \"rules\", null);\n _defineProperty(this, \"_messages\", defaultMessages);\n this.define(descriptor);\n }\n _createClass(Schema, [{\n key: \"define\",\n value: function define(rules) {\n var _this = this;\n if (!rules) {\n throw new Error('Cannot configure a schema with no rules');\n }\n if (_typeof(rules) !== 'object' || Array.isArray(rules)) {\n throw new Error('Rules must be an object');\n }\n this.rules = {};\n Object.keys(rules).forEach(function (name) {\n var item = rules[name];\n _this.rules[name] = Array.isArray(item) ? item : [item];\n });\n }\n }, {\n key: \"messages\",\n value: function messages(_messages) {\n if (_messages) {\n this._messages = deepMerge(newMessages(), _messages);\n }\n return this._messages;\n }\n }, {\n key: \"validate\",\n value: function validate(source_) {\n var _this2 = this;\n var o = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var oc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};\n var source = source_;\n var options = o;\n var callback = oc;\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n if (!this.rules || Object.keys(this.rules).length === 0) {\n if (callback) {\n callback(null, source);\n }\n return Promise.resolve(source);\n }\n function complete(results) {\n var errors = [];\n var fields = {};\n function add(e) {\n if (Array.isArray(e)) {\n var _errors;\n errors = (_errors = errors).concat.apply(_errors, _toConsumableArray(e));\n } else {\n errors.push(e);\n }\n }\n for (var i = 0; i < results.length; i++) {\n add(results[i]);\n }\n if (!errors.length) {\n callback(null, source);\n } else {\n fields = convertFieldsError(errors);\n callback(errors, fields);\n }\n }\n if (options.messages) {\n var messages = this.messages();\n if (messages === defaultMessages) {\n messages = newMessages();\n }\n deepMerge(messages, options.messages);\n options.messages = messages;\n } else {\n options.messages = this.messages();\n }\n var series = {};\n var keys = options.keys || Object.keys(this.rules);\n keys.forEach(function (z) {\n var arr = _this2.rules[z];\n var value = source[z];\n arr.forEach(function (r) {\n var rule = r;\n if (typeof rule.transform === 'function') {\n if (source === source_) {\n source = _objectSpread({}, source);\n }\n value = source[z] = rule.transform(value);\n if (value !== undefined && value !== null) {\n rule.type = rule.type || (Array.isArray(value) ? 'array' : _typeof(value));\n }\n }\n if (typeof rule === 'function') {\n rule = {\n validator: rule\n };\n } else {\n rule = _objectSpread({}, rule);\n }\n\n // Fill validator. Skip if nothing need to validate\n rule.validator = _this2.getValidationMethod(rule);\n if (!rule.validator) {\n return;\n }\n rule.field = z;\n rule.fullField = rule.fullField || z;\n rule.type = _this2.getType(rule);\n series[z] = series[z] || [];\n series[z].push({\n rule: rule,\n value: value,\n source: source,\n field: z\n });\n });\n });\n var errorFields = {};\n return asyncMap(series, options, function (data, doIt) {\n var rule = data.rule;\n var deep = (rule.type === 'object' || rule.type === 'array') && (_typeof(rule.fields) === 'object' || _typeof(rule.defaultField) === 'object');\n deep = deep && (rule.required || !rule.required && data.value);\n rule.field = data.field;\n function addFullField(key, schema) {\n return _objectSpread(_objectSpread({}, schema), {}, {\n fullField: \"\".concat(rule.fullField, \".\").concat(key),\n fullFields: rule.fullFields ? [].concat(_toConsumableArray(rule.fullFields), [key]) : [key]\n });\n }\n function cb() {\n var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var errorList = Array.isArray(e) ? e : [e];\n if (!options.suppressWarning && errorList.length) {\n Schema.warning('async-validator:', errorList);\n }\n if (errorList.length && rule.message !== undefined) {\n errorList = [].concat(rule.message);\n }\n\n // Fill error info\n var filledErrors = errorList.map(complementError(rule, source));\n if (options.first && filledErrors.length) {\n errorFields[rule.field] = 1;\n return doIt(filledErrors);\n }\n if (!deep) {\n doIt(filledErrors);\n } else {\n // if rule is required but the target object\n // does not exist fail at the rule level and don't\n // go deeper\n if (rule.required && !data.value) {\n if (rule.message !== undefined) {\n filledErrors = [].concat(rule.message).map(complementError(rule, source));\n } else if (options.error) {\n filledErrors = [options.error(rule, format(options.messages.required, rule.field))];\n }\n return doIt(filledErrors);\n }\n var fieldsSchema = {};\n if (rule.defaultField) {\n Object.keys(data.value).map(function (key) {\n fieldsSchema[key] = rule.defaultField;\n });\n }\n fieldsSchema = _objectSpread(_objectSpread({}, fieldsSchema), data.rule.fields);\n var paredFieldsSchema = {};\n Object.keys(fieldsSchema).forEach(function (field) {\n var fieldSchema = fieldsSchema[field];\n var fieldSchemaList = Array.isArray(fieldSchema) ? fieldSchema : [fieldSchema];\n paredFieldsSchema[field] = fieldSchemaList.map(addFullField.bind(null, field));\n });\n var schema = new Schema(paredFieldsSchema);\n schema.messages(options.messages);\n if (data.rule.options) {\n data.rule.options.messages = options.messages;\n data.rule.options.error = options.error;\n }\n schema.validate(data.value, data.rule.options || options, function (errs) {\n var finalErrors = [];\n if (filledErrors && filledErrors.length) {\n finalErrors.push.apply(finalErrors, _toConsumableArray(filledErrors));\n }\n if (errs && errs.length) {\n finalErrors.push.apply(finalErrors, _toConsumableArray(errs));\n }\n doIt(finalErrors.length ? finalErrors : null);\n });\n }\n }\n var res;\n if (rule.asyncValidator) {\n res = rule.asyncValidator(rule, data.value, cb, data.source, options);\n } else if (rule.validator) {\n try {\n res = rule.validator(rule, data.value, cb, data.source, options);\n } catch (error) {\n var _console$error, _console;\n (_console$error = (_console = console).error) === null || _console$error === void 0 || _console$error.call(_console, error);\n // rethrow to report error\n if (!options.suppressValidatorError) {\n setTimeout(function () {\n throw error;\n }, 0);\n }\n cb(error.message);\n }\n if (res === true) {\n cb();\n } else if (res === false) {\n cb(typeof rule.message === 'function' ? rule.message(rule.fullField || rule.field) : rule.message || \"\".concat(rule.fullField || rule.field, \" fails\"));\n } else if (res instanceof Array) {\n cb(res);\n } else if (res instanceof Error) {\n cb(res.message);\n }\n }\n if (res && res.then) {\n res.then(function () {\n return cb();\n }, function (e) {\n return cb(e);\n });\n }\n }, function (results) {\n complete(results);\n }, source);\n }\n }, {\n key: \"getType\",\n value: function getType(rule) {\n if (rule.type === undefined && rule.pattern instanceof RegExp) {\n rule.type = 'pattern';\n }\n if (typeof rule.validator !== 'function' && rule.type && !validators.hasOwnProperty(rule.type)) {\n throw new Error(format('Unknown rule type %s', rule.type));\n }\n return rule.type || 'string';\n }\n }, {\n key: \"getValidationMethod\",\n value: function getValidationMethod(rule) {\n if (typeof rule.validator === 'function') {\n return rule.validator;\n }\n var keys = Object.keys(rule);\n var messageIndex = keys.indexOf('message');\n if (messageIndex !== -1) {\n keys.splice(messageIndex, 1);\n }\n if (keys.length === 1 && keys[0] === 'required') {\n return validators.required;\n }\n return validators[this.getType(rule)] || undefined;\n }\n }]);\n return Schema;\n}();\n// ========================= Static =========================\n_defineProperty(Schema, \"register\", function register(type, validator) {\n if (typeof validator !== 'function') {\n throw new Error('Cannot register a validator by type, validator is not a function');\n }\n validators[type] = validator;\n});\n_defineProperty(Schema, \"warning\", warning);\n_defineProperty(Schema, \"messages\", defaultMessages);\n_defineProperty(Schema, \"validators\", validators);\nexport default Schema;"],"names":["Schema","descriptor","_classCallCheck","_defineProperty","defaultMessages","_createClass","rules","_this","_typeof","name","item","_messages","deepMerge","newMessages","source_","_this2","o","oc","source","options","callback","complete","results","errors","fields","add","e","_errors","_toConsumableArray","convertFieldsError","messages","series","keys","z","arr","value","r","rule","_objectSpread","asyncMap","data","doIt","deep","addFullField","key","schema","cb","errorList","filledErrors","complementError","format","fieldsSchema","paredFieldsSchema","field","fieldSchema","fieldSchemaList","errs","finalErrors","res","error","_console$error","_console","validators","messageIndex","type","validator","warning"],"mappings":";;;;;;;;;AAiBG,IAACA,IAAsB,4BAAY;AACpC,WAASA,EAAOC,GAAY;AAC1B,IAAAC,EAAgB,MAAMF,CAAM,GAE5BG,EAAgB,MAAM,SAAS,IAAI,GACnCA,EAAgB,MAAM,aAAaC,CAAe,GAClD,KAAK,OAAOH,CAAU;AAAA,EACxB;AACA,SAAAI,EAAaL,GAAQ,CAAC;AAAA,IACpB,KAAK;AAAA,IACL,OAAO,SAAgBM,GAAO;AAC5B,UAAIC,IAAQ;AACZ,UAAI,CAACD;AACH,cAAM,IAAI,MAAM,yCAAyC;AAE3D,UAAIE,EAAQF,CAAK,MAAM,YAAY,MAAM,QAAQA,CAAK;AACpD,cAAM,IAAI,MAAM,yBAAyB;AAE3C,WAAK,QAAQ,CAAA,GACb,OAAO,KAAKA,CAAK,EAAE,QAAQ,SAAUG,GAAM;AACzC,YAAIC,IAAOJ,EAAMG,CAAI;AACrB,QAAAF,EAAM,MAAME,CAAI,IAAI,MAAM,QAAQC,CAAI,IAAIA,IAAO,CAACA,CAAI;AAAA,MACxD,CAAC;AAAA,IACH;AAAA,EACJ,GAAK;AAAA,IACD,KAAK;AAAA,IACL,OAAO,SAAkBC,GAAW;AAClC,aAAIA,MACF,KAAK,YAAYC,EAAUC,EAAW,GAAIF,CAAS,IAE9C,KAAK;AAAA,IACd;AAAA,EACJ,GAAK;AAAA,IACD,KAAK;AAAA,IACL,OAAO,SAAkBG,GAAS;AAChC,UAAIC,IAAS,MACTC,IAAI,UAAU,SAAS,KAAK,UAAU,CAAC,MAAM,SAAY,UAAU,CAAC,IAAI,CAAA,GACxEC,IAAK,UAAU,SAAS,KAAK,UAAU,CAAC,MAAM,SAAY,UAAU,CAAC,IAAI,WAAY;AAAA,MAAC,GACtFC,IAASJ,GACTK,IAAUH,G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CAAI,IAAIC;AACrB,CAAC;AACD9D,EAAgBH,GAAQ,WAAWkE,CAAO;AAC1C/D,EAAgBH,GAAQ,YAAYI,CAAe;AACnDD,EAAgBH,GAAQ,cAAc8D,CAAU;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../node_modules/@rc-component/async-validator/es/index.js"],"sourcesContent":["import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _classCallCheck from \"@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/esm/createClass\";\nimport _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport { messages as defaultMessages, newMessages } from \"./messages\";\nimport { asyncMap, complementError, convertFieldsError, deepMerge, format, warning } from \"./util\";\nimport validators from \"./validator/index\";\nexport * from \"./interface\";\n\n/**\n * Encapsulates a validation schema.\n *\n * @param descriptor An object declaring validation rules\n * for this schema.\n */\nvar Schema = /*#__PURE__*/function () {\n function Schema(descriptor) {\n _classCallCheck(this, Schema);\n // ======================== Instance ========================\n _defineProperty(this, \"rules\", null);\n _defineProperty(this, \"_messages\", defaultMessages);\n this.define(descriptor);\n }\n _createClass(Schema, [{\n key: \"define\",\n value: function define(rules) {\n var _this = this;\n if (!rules) {\n throw new Error('Cannot configure a schema with no rules');\n }\n if (_typeof(rules) !== 'object' || Array.isArray(rules)) {\n throw new Error('Rules must be an object');\n }\n this.rules = {};\n Object.keys(rules).forEach(function (name) {\n var item = rules[name];\n _this.rules[name] = Array.isArray(item) ? item : [item];\n });\n }\n }, {\n key: \"messages\",\n value: function messages(_messages) {\n if (_messages) {\n this._messages = deepMerge(newMessages(), _messages);\n }\n return this._messages;\n }\n }, {\n key: \"validate\",\n value: function validate(source_) {\n var _this2 = this;\n var o = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var oc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};\n var source = source_;\n var options = o;\n var callback = oc;\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n if (!this.rules || Object.keys(this.rules).length === 0) {\n if (callback) {\n callback(null, source);\n }\n return Promise.resolve(source);\n }\n function complete(results) {\n var errors = [];\n var fields = {};\n function add(e) {\n if (Array.isArray(e)) {\n var _errors;\n errors = (_errors = errors).concat.apply(_errors, _toConsumableArray(e));\n } else {\n errors.push(e);\n }\n }\n for (var i = 0; i < results.length; i++) {\n add(results[i]);\n }\n if (!errors.length) {\n callback(null, source);\n } else {\n fields = convertFieldsError(errors);\n callback(errors, fields);\n }\n }\n if (options.messages) {\n var messages = this.messages();\n if (messages === defaultMessages) {\n messages = newMessages();\n }\n deepMerge(messages, options.messages);\n options.messages = messages;\n } else {\n options.messages = this.messages();\n }\n var series = {};\n var keys = options.keys || Object.keys(this.rules);\n keys.forEach(function (z) {\n var arr = _this2.rules[z];\n var value = source[z];\n arr.forEach(function (r) {\n var rule = r;\n if (typeof rule.transform === 'function') {\n if (source === source_) {\n source = _objectSpread({}, source);\n }\n value = source[z] = rule.transform(value);\n if (value !== undefined && value !== null) {\n rule.type = rule.type || (Array.isArray(value) ? 'array' : _typeof(value));\n }\n }\n if (typeof rule === 'function') {\n rule = {\n validator: rule\n };\n } else {\n rule = _objectSpread({}, rule);\n }\n\n // Fill validator. Skip if nothing need to validate\n rule.validator = _this2.getValidationMethod(rule);\n if (!rule.validator) {\n return;\n }\n rule.field = z;\n rule.fullField = rule.fullField || z;\n rule.type = _this2.getType(rule);\n series[z] = series[z] || [];\n series[z].push({\n rule: rule,\n value: value,\n source: source,\n field: z\n });\n });\n });\n var errorFields = {};\n return asyncMap(series, options, function (data, doIt) {\n var rule = data.rule;\n var deep = (rule.type === 'object' || rule.type === 'array') && (_typeof(rule.fields) === 'object' || _typeof(rule.defaultField) === 'object');\n deep = deep && (rule.required || !rule.required && data.value);\n rule.field = data.field;\n function addFullField(key, schema) {\n return _objectSpread(_objectSpread({}, schema), {}, {\n fullField: \"\".concat(rule.fullField, \".\").concat(key),\n fullFields: rule.fullFields ? [].concat(_toConsumableArray(rule.fullFields), [key]) : [key]\n });\n }\n function cb() {\n var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var errorList = Array.isArray(e) ? e : [e];\n if (!options.suppressWarning && errorList.length) {\n Schema.warning('async-validator:', errorList);\n }\n if (errorList.length && rule.message !== undefined && rule.message !== null) {\n errorList = [].concat(rule.message);\n }\n\n // Fill error info\n var filledErrors = errorList.map(complementError(rule, source));\n if (options.first && filledErrors.length) {\n errorFields[rule.field] = 1;\n return doIt(filledErrors);\n }\n if (!deep) {\n doIt(filledErrors);\n } else {\n // if rule is required but the target object\n // does not exist fail at the rule level and don't\n // go deeper\n if (rule.required && !data.value) {\n if (rule.message !== undefined) {\n filledErrors = [].concat(rule.message).map(complementError(rule, source));\n } else if (options.error) {\n filledErrors = [options.error(rule, format(options.messages.required, rule.field))];\n }\n return doIt(filledErrors);\n }\n var fieldsSchema = {};\n if (rule.defaultField) {\n Object.keys(data.value).map(function (key) {\n fieldsSchema[key] = rule.defaultField;\n });\n }\n fieldsSchema = _objectSpread(_objectSpread({}, fieldsSchema), data.rule.fields);\n var paredFieldsSchema = {};\n Object.keys(fieldsSchema).forEach(function (field) {\n var fieldSchema = fieldsSchema[field];\n var fieldSchemaList = Array.isArray(fieldSchema) ? fieldSchema : [fieldSchema];\n paredFieldsSchema[field] = fieldSchemaList.map(addFullField.bind(null, field));\n });\n var schema = new Schema(paredFieldsSchema);\n schema.messages(options.messages);\n if (data.rule.options) {\n data.rule.options.messages = options.messages;\n data.rule.options.error = options.error;\n }\n schema.validate(data.value, data.rule.options || options, function (errs) {\n var finalErrors = [];\n if (filledErrors && filledErrors.length) {\n finalErrors.push.apply(finalErrors, _toConsumableArray(filledErrors));\n }\n if (errs && errs.length) {\n finalErrors.push.apply(finalErrors, _toConsumableArray(errs));\n }\n doIt(finalErrors.length ? finalErrors : null);\n });\n }\n }\n var res;\n if (rule.asyncValidator) {\n res = rule.asyncValidator(rule, data.value, cb, data.source, options);\n } else if (rule.validator) {\n try {\n res = rule.validator(rule, data.value, cb, data.source, options);\n } catch (error) {\n var _console$error, _console;\n (_console$error = (_console = console).error) === null || _console$error === void 0 || _console$error.call(_console, error);\n // rethrow to report error\n if (!options.suppressValidatorError) {\n setTimeout(function () {\n throw error;\n }, 0);\n }\n cb(error.message);\n }\n if (res === true) {\n cb();\n } else if (res === false) {\n cb(typeof rule.message === 'function' ? rule.message(rule.fullField || rule.field) : rule.message || \"\".concat(rule.fullField || rule.field, \" fails\"));\n } else if (res instanceof Array) {\n cb(res);\n } else if (res instanceof Error) {\n cb(res.message);\n }\n }\n if (res && res.then) {\n res.then(function () {\n return cb();\n }, function (e) {\n return cb(e);\n });\n }\n }, function (results) {\n complete(results);\n }, source);\n }\n }, {\n key: \"getType\",\n value: function getType(rule) {\n if (rule.type === undefined && rule.pattern instanceof RegExp) {\n rule.type = 'pattern';\n }\n if (typeof rule.validator !== 'function' && rule.type && !validators.hasOwnProperty(rule.type)) {\n throw new Error(format('Unknown rule type %s', rule.type));\n }\n return rule.type || 'string';\n }\n }, {\n key: \"getValidationMethod\",\n value: function getValidationMethod(rule) {\n if (typeof rule.validator === 'function') {\n return rule.validator;\n }\n var keys = Object.keys(rule);\n var messageIndex = keys.indexOf('message');\n if (messageIndex !== -1) {\n keys.splice(messageIndex, 1);\n }\n if (keys.length === 1 && keys[0] === 'required') {\n return validators.required;\n }\n return validators[this.getType(rule)] || undefined;\n }\n }]);\n return Schema;\n}();\n// ========================= Static =========================\n_defineProperty(Schema, \"register\", function register(type, validator) {\n if (typeof validator !== 'function') {\n throw new Error('Cannot register a validator by type, validator is not a function');\n }\n validators[type] = validator;\n});\n_defineProperty(Schema, \"warning\", warning);\n_defineProperty(Schema, \"messages\", defaultMessages);\n_defineProperty(Schema, \"validators\", validators);\nexport default Schema;"],"names":["Schema","descriptor","_classCallCheck","_defineProperty","defaultMessages","_createClass","rules","_this","_typeof","name","item","_messages","deepMerge","newMessages","source_","_this2","o","oc","source","options","callback","complete","results","errors","fields","add","e","_errors","_toConsumableArray","convertFieldsError","messages","series","keys","z","arr","value","r","rule","_objectSpread","asyncMap","data","doIt","deep","addFullField","key","schema","cb","errorList","filledErrors","complementError","format","fieldsSchema","paredFieldsSchema","field","fieldSchema","fieldSchemaList","errs","finalErrors","res","error","_console$error","_console","validators","messageIndex","type","validator","warning"],"mappings":";;;;;;;;;AAiBG,IAACA,IAAsB,4BAAY;AACpC,WAASA,EAAOC,GAAY;AAC1B,IAAAC,EAAgB,MAAMF,CAAM,GAE5BG,EAAgB,MAAM,SAAS,IAAI,GACnCA,EAAgB,MAAM,aAAaC,CAAe,GAClD,KAAK,OAAOH,CAAU;AAAA,EACxB;AACA,SAAAI,EAAaL,GAAQ,CAAC;AAAA,IACpB,KAAK;AAAA,IACL,OAAO,SAAgBM,GAAO;AAC5B,UAAIC,IAAQ;AACZ,UAAI,CAACD;AACH,cAAM,IAAI,MAAM,yCAAyC;AAE3D,UAAIE,EAAQF,CAAK,MAAM,YAAY,MAAM,QAAQA,CAAK;AACpD,cAAM,IAAI,MAAM,yBAAyB;AAE3C,WAAK,QAAQ,CAAA,GACb,OAAO,KAAKA,CAAK,EAAE,QAAQ,SAAUG,GAAM;AACzC,YAAIC,IAAOJ,EAAMG,CAAI;AACrB,QAAAF,EAAM,MAAME,CAAI,IAAI,MAAM,QAAQC,CAAI,IAAIA,IAAO,CAACA,CAAI;AAAA,MACxD,CAAC;AAAA,IACH;AAAA,EACJ,GAAK;AAAA,IACD,KAAK;AAAA,IACL,OAAO,SAAkBC,GAAW;AAClC,aAAIA,MACF,KAAK,YAAYC,EAAUC,EAAW,GAAIF,CAAS,IAE9C,KAAK;AAAA,IACd;AAAA,EACJ,GAAK;AAAA,IACD,KAAK;AAAA,IACL,OAAO,SAAkBG,GAAS;AAChC,UAAIC,IAAS,MACTC,IAA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zB,CAAI,CAAC,KAAK;AAAA,IAC3C;AAAA,EACJ,CAAG,CAAC,GACKrC;AACT,GAAC;AAEDG,EAAgBH,GAAQ,YAAY,SAAkBgE,GAAMC,GAAW;AACrE,MAAI,OAAOA,KAAc;AACvB,UAAM,IAAI,MAAM,kEAAkE;AAEpF,EAAAH,EAAWE,CAAI,IAAIC;AACrB,CAAC;AACD9D,EAAgBH,GAAQ,WAAWkE,CAAO;AAC1C/D,EAAgBH,GAAQ,YAAYI,CAAe;AACnDD,EAAgBH,GAAQ,cAAc8D,CAAU;","x_google_ignoreList":[0]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sources":["../../../../../node_modules/@rc-component/async-validator/es/messages.js"],"sourcesContent":["export function newMessages() {\n return {\n default: 'Validation error on field %s',\n required: '%s is required',\n enum: '%s must be one of %s',\n whitespace: '%s cannot be empty',\n date: {\n format: '%s date %s is invalid for format %s',\n parse: '%s date could not be parsed, %s is invalid ',\n invalid: '%s date %s is invalid'\n },\n types: {\n string: '%s is not a %s',\n method: '%s is not a %s (function)',\n array: '%s is not an %s',\n object: '%s is not an %s',\n number: '%s is not a %s',\n date: '%s is not a %s',\n boolean: '%s is not a %s',\n integer: '%s is not an %s',\n float: '%s is not a %s',\n regexp: '%s is not a valid %s',\n email: '%s is not a valid %s',\n url: '%s is not a valid %s',\n hex: '%s is not a valid %s'\n },\n string: {\n len: '%s must be exactly %s characters',\n min: '%s must be at least %s characters',\n max: '%s cannot be longer than %s characters',\n range: '%s must be between %s and %s characters'\n },\n number: {\n len: '%s must equal %s',\n min: '%s cannot be less than %s',\n max: '%s cannot be greater than %s',\n range: '%s must be between %s and %s'\n },\n array: {\n len: '%s must be exactly %s in length',\n min: '%s cannot be less than %s in length',\n max: '%s cannot be greater than %s in length',\n range: '%s must be between %s and %s in length'\n },\n pattern: {\n mismatch: '%s value %s does not match pattern %s'\n },\n clone: function clone() {\n var cloned = JSON.parse(JSON.stringify(this));\n cloned.clone = this.clone;\n return cloned;\n }\n };\n}\nexport var messages = newMessages();"],"names":["newMessages","cloned","messages"],"mappings":"AAAO,SAASA,IAAc;AAC5B,SAAO;AAAA,IACL,SAAS;AAAA,IACT,UAAU;AAAA,IACV,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,MAAM;AAAA,MACJ,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,SAAS;AAAA,IACf;AAAA,IACI,OAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS;AAAA,MACT,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,KAAK;AAAA,MACL,KAAK;AAAA,IACX;AAAA,IACI,QAAQ;AAAA,MACN,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,OAAO;AAAA,IACb;AAAA,IACI,QAAQ;AAAA,MACN,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,OAAO;AAAA,IACb;AAAA,IACI,OAAO;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,OAAO;AAAA,IACb;AAAA,IACI,SAAS;AAAA,MACP,UAAU;AAAA,IAChB;AAAA,IACI,OAAO,WAAiB;AACtB,UAAIC,IAAS,KAAK,MAAM,KAAK,UAAU,IAAI,CAAC;AAC5C,aAAAA,EAAO,QAAQ,KAAK,OACbA;AAAA,IACT;AAAA,EACJ;AACA;AACU,IAACC,IAAWF,EAAW;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"messages.js","sources":["../../../../../node_modules/@rc-component/async-validator/es/messages.js"],"sourcesContent":["export function newMessages() {\n return {\n default: 'Validation error on field %s',\n required: '%s is required',\n enum: '%s must be one of %s',\n whitespace: '%s cannot be empty',\n date: {\n format: '%s date %s is invalid for format %s',\n parse: '%s date could not be parsed, %s is invalid ',\n invalid: '%s date %s is invalid'\n },\n types: {\n string: '%s is not a %s',\n method: '%s is not a %s (function)',\n array: '%s is not an %s',\n object: '%s is not an %s',\n number: '%s is not a %s',\n date: '%s is not a %s',\n boolean: '%s is not a %s',\n integer: '%s is not an %s',\n float: '%s is not a %s',\n regexp: '%s is not a valid %s',\n email: '%s is not a valid %s',\n tel: '%s is not a valid %s',\n url: '%s is not a valid %s',\n hex: '%s is not a valid %s'\n },\n string: {\n len: '%s must be exactly %s characters',\n min: '%s must be at least %s characters',\n max: '%s cannot be longer than %s characters',\n range: '%s must be between %s and %s characters'\n },\n number: {\n len: '%s must equal %s',\n min: '%s cannot be less than %s',\n max: '%s cannot be greater than %s',\n range: '%s must be between %s and %s'\n },\n array: {\n len: '%s must be exactly %s in length',\n min: '%s cannot be less than %s in length',\n max: '%s cannot be greater than %s in length',\n range: '%s must be between %s and %s in length'\n },\n pattern: {\n mismatch: '%s value %s does not match pattern %s'\n },\n clone: function clone() {\n var cloned = JSON.parse(JSON.stringify(this));\n cloned.clone = this.clone;\n return cloned;\n }\n };\n}\nexport var messages = newMessages();"],"names":["newMessages","cloned","messages"],"mappings":"AAAO,SAASA,IAAc;AAC5B,SAAO;AAAA,IACL,SAAS;AAAA,IACT,UAAU;AAAA,IACV,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,MAAM;AAAA,MACJ,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,SAAS;AAAA,IACf;AAAA,IACI,OAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS;AAAA,MACT,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,IACX;AAAA,IACI,QAAQ;AAAA,MACN,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,OAAO;AAAA,IACb;AAAA,IACI,QAAQ;AAAA,MACN,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,OAAO;AAAA,IACb;AAAA,IACI,OAAO;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,OAAO;AAAA,IACb;AAAA,IACI,SAAS;AAAA,MACP,UAAU;AAAA,IAChB;AAAA,IACI,OAAO,WAAiB;AACtB,UAAIC,IAAS,KAAK,MAAM,KAAK,UAAU,IAAI,CAAC;AAC5C,aAAAA,EAAO,QAAQ,KAAK,OACbA;AAAA,IACT;AAAA,EACJ;AACA;AACU,IAACC,IAAWF,EAAW;","x_google_ignoreList":[0]}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import p from "../../../../@babel/runtime/helpers/esm/typeof.js";
|
|
2
|
-
import { format as
|
|
2
|
+
import { format as m } from "../util.js";
|
|
3
3
|
import y from "./required.js";
|
|
4
|
-
import
|
|
5
|
-
var
|
|
4
|
+
import s from "./url.js";
|
|
5
|
+
var u = {
|
|
6
6
|
// http://emailregex.com/
|
|
7
7
|
email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,
|
|
8
8
|
// url: new RegExp(
|
|
9
9
|
// '^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$',
|
|
10
10
|
// 'i',
|
|
11
11
|
// ),
|
|
12
|
+
/**
|
|
13
|
+
* Phone number regex, support country code, brackets, spaces, and dashes (or non-breaking hyphen \u2011).
|
|
14
|
+
* @see https://regexr.com/3c53v
|
|
15
|
+
* @see https://ihateregex.io/expr/phone/
|
|
16
|
+
* @see https://developers.google.com/style/phone-numbers using non-breaking hyphen \u2011
|
|
17
|
+
*/
|
|
18
|
+
tel: /^(\+[0-9]{1,3}[-\s\u2011]?)?(\([0-9]{1,4}\)[-\s\u2011]?)?([0-9]+[-\s\u2011]?)*[0-9]+$/,
|
|
12
19
|
hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i
|
|
13
20
|
}, f = {
|
|
14
21
|
integer: function(t) {
|
|
@@ -42,21 +49,24 @@ var m = {
|
|
|
42
49
|
return typeof t == "function";
|
|
43
50
|
},
|
|
44
51
|
email: function(t) {
|
|
45
|
-
return typeof t == "string" && t.length <= 320 && !!t.match(
|
|
52
|
+
return typeof t == "string" && t.length <= 320 && !!t.match(u.email);
|
|
53
|
+
},
|
|
54
|
+
tel: function(t) {
|
|
55
|
+
return typeof t == "string" && t.length <= 32 && !!t.match(u.tel);
|
|
46
56
|
},
|
|
47
57
|
url: function(t) {
|
|
48
|
-
return typeof t == "string" && t.length <= 2048 && !!t.match(
|
|
58
|
+
return typeof t == "string" && t.length <= 2048 && !!t.match(s());
|
|
49
59
|
},
|
|
50
60
|
hex: function(t) {
|
|
51
|
-
return typeof t == "string" && !!t.match(
|
|
61
|
+
return typeof t == "string" && !!t.match(u.hex);
|
|
52
62
|
}
|
|
53
63
|
}, x = function(t, r, a, i, o) {
|
|
54
64
|
if (t.required && r === void 0) {
|
|
55
65
|
y(t, r, a, i, o);
|
|
56
66
|
return;
|
|
57
67
|
}
|
|
58
|
-
var c = ["integer", "float", "array", "regexp", "object", "method", "email", "number", "date", "url", "hex"], n = t.type;
|
|
59
|
-
c.indexOf(n) > -1 ? f[n](r) || i.push(
|
|
68
|
+
var c = ["integer", "float", "array", "regexp", "object", "method", "email", "tel", "number", "date", "url", "hex"], n = t.type;
|
|
69
|
+
c.indexOf(n) > -1 ? f[n](r) || i.push(m(o.messages.types[n], t.fullField, t.type)) : n && p(r) !== t.type && i.push(m(o.messages.types[n], t.fullField, t.type));
|
|
60
70
|
};
|
|
61
71
|
export {
|
|
62
72
|
x as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.js","sources":["../../../../../../node_modules/@rc-component/async-validator/es/rule/type.js"],"sourcesContent":["import _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport { format } from \"../util\";\nimport required from \"./required\";\nimport getUrlRegex from \"./url\";\n/* eslint max-len:0 */\n\nvar pattern = {\n // http://emailregex.com/\n email: /^(([^<>()\\[\\]\\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]+\\.)+[a-zA-Z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]{2,}))$/,\n // url: new RegExp(\n // '^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\\\S+(?::\\\\S*)?@)?(?:(?:(?:[1-9]\\\\d?|1\\\\d\\\\d|2[01]\\\\d|22[0-3])(?:\\\\.(?:1?\\\\d{1,2}|2[0-4]\\\\d|25[0-5])){2}(?:\\\\.(?:[0-9]\\\\d?|1\\\\d\\\\d|2[0-4]\\\\d|25[0-4]))|(?:(?:[a-z\\\\u00a1-\\\\uffff0-9]+-*)*[a-z\\\\u00a1-\\\\uffff0-9]+)(?:\\\\.(?:[a-z\\\\u00a1-\\\\uffff0-9]+-*)*[a-z\\\\u00a1-\\\\uffff0-9]+)*(?:\\\\.(?:[a-z\\\\u00a1-\\\\uffff]{2,})))|localhost)(?::\\\\d{2,5})?(?:(/|\\\\?|#)[^\\\\s]*)?$',\n // 'i',\n // ),\n hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i\n};\nvar types = {\n integer: function integer(value) {\n return types.number(value) && parseInt(value, 10) === value;\n },\n float: function float(value) {\n return types.number(value) && !types.integer(value);\n },\n array: function array(value) {\n return Array.isArray(value);\n },\n regexp: function regexp(value) {\n if (value instanceof RegExp) {\n return true;\n }\n try {\n return !!new RegExp(value);\n } catch (e) {\n return false;\n }\n },\n date: function date(value) {\n return typeof value.getTime === 'function' && typeof value.getMonth === 'function' && typeof value.getYear === 'function' && !isNaN(value.getTime());\n },\n number: function number(value) {\n if (isNaN(value)) {\n return false;\n }\n return typeof value === 'number';\n },\n object: function object(value) {\n return _typeof(value) === 'object' && !types.array(value);\n },\n method: function method(value) {\n return typeof value === 'function';\n },\n email: function email(value) {\n return typeof value === 'string' && value.length <= 320 && !!value.match(pattern.email);\n },\n url: function url(value) {\n return typeof value === 'string' && value.length <= 2048 && !!value.match(getUrlRegex());\n },\n hex: function hex(value) {\n return typeof value === 'string' && !!value.match(pattern.hex);\n }\n};\nvar type = function type(rule, value, source, errors, options) {\n if (rule.required && value === undefined) {\n required(rule, value, source, errors, options);\n return;\n }\n var custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'number', 'date', 'url', 'hex'];\n var ruleType = rule.type;\n if (custom.indexOf(ruleType) > -1) {\n if (!types[ruleType](value)) {\n errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));\n }\n // straight typeof check\n } else if (ruleType && _typeof(value) !== rule.type) {\n errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));\n }\n};\nexport default type;"],"names":["pattern","types","value","_typeof","getUrlRegex","type","rule","source","errors","options","required","custom","ruleType","format"],"mappings":";;;;AAMA,IAAIA,IAAU;AAAA;AAAA,EAEZ,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"type.js","sources":["../../../../../../node_modules/@rc-component/async-validator/es/rule/type.js"],"sourcesContent":["import _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport { format } from \"../util\";\nimport required from \"./required\";\nimport getUrlRegex from \"./url\";\n/* eslint max-len:0 */\n\nvar pattern = {\n // http://emailregex.com/\n email: /^(([^<>()\\[\\]\\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]+\\.)+[a-zA-Z\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]{2,}))$/,\n // url: new RegExp(\n // '^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\\\S+(?::\\\\S*)?@)?(?:(?:(?:[1-9]\\\\d?|1\\\\d\\\\d|2[01]\\\\d|22[0-3])(?:\\\\.(?:1?\\\\d{1,2}|2[0-4]\\\\d|25[0-5])){2}(?:\\\\.(?:[0-9]\\\\d?|1\\\\d\\\\d|2[0-4]\\\\d|25[0-4]))|(?:(?:[a-z\\\\u00a1-\\\\uffff0-9]+-*)*[a-z\\\\u00a1-\\\\uffff0-9]+)(?:\\\\.(?:[a-z\\\\u00a1-\\\\uffff0-9]+-*)*[a-z\\\\u00a1-\\\\uffff0-9]+)*(?:\\\\.(?:[a-z\\\\u00a1-\\\\uffff]{2,})))|localhost)(?::\\\\d{2,5})?(?:(/|\\\\?|#)[^\\\\s]*)?$',\n // 'i',\n // ),\n /**\n * Phone number regex, support country code, brackets, spaces, and dashes (or non-breaking hyphen \\u2011).\n * @see https://regexr.com/3c53v\n * @see https://ihateregex.io/expr/phone/\n * @see https://developers.google.com/style/phone-numbers using non-breaking hyphen \\u2011\n */\n tel: /^(\\+[0-9]{1,3}[-\\s\\u2011]?)?(\\([0-9]{1,4}\\)[-\\s\\u2011]?)?([0-9]+[-\\s\\u2011]?)*[0-9]+$/,\n hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i\n};\nvar types = {\n integer: function integer(value) {\n return types.number(value) && parseInt(value, 10) === value;\n },\n float: function float(value) {\n return types.number(value) && !types.integer(value);\n },\n array: function array(value) {\n return Array.isArray(value);\n },\n regexp: function regexp(value) {\n if (value instanceof RegExp) {\n return true;\n }\n try {\n return !!new RegExp(value);\n } catch (e) {\n return false;\n }\n },\n date: function date(value) {\n return typeof value.getTime === 'function' && typeof value.getMonth === 'function' && typeof value.getYear === 'function' && !isNaN(value.getTime());\n },\n number: function number(value) {\n if (isNaN(value)) {\n return false;\n }\n return typeof value === 'number';\n },\n object: function object(value) {\n return _typeof(value) === 'object' && !types.array(value);\n },\n method: function method(value) {\n return typeof value === 'function';\n },\n email: function email(value) {\n return typeof value === 'string' && value.length <= 320 && !!value.match(pattern.email);\n },\n tel: function tel(value) {\n return typeof value === 'string' && value.length <= 32 && !!value.match(pattern.tel);\n },\n url: function url(value) {\n return typeof value === 'string' && value.length <= 2048 && !!value.match(getUrlRegex());\n },\n hex: function hex(value) {\n return typeof value === 'string' && !!value.match(pattern.hex);\n }\n};\nvar type = function type(rule, value, source, errors, options) {\n if (rule.required && value === undefined) {\n required(rule, value, source, errors, options);\n return;\n }\n var custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'tel', 'number', 'date', 'url', 'hex'];\n var ruleType = rule.type;\n if (custom.indexOf(ruleType) > -1) {\n if (!types[ruleType](value)) {\n errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));\n }\n // straight typeof check\n } else if (ruleType && _typeof(value) !== rule.type) {\n errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));\n }\n};\nexport default type;"],"names":["pattern","types","value","_typeof","getUrlRegex","type","rule","source","errors","options","required","custom","ruleType","format"],"mappings":";;;;AAMA,IAAIA,IAAU;AAAA;AAAA,EAEZ,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWP,KAAK;AAAA,EACL,KAAK;AACP,GACIC,IAAQ;AAAA,EACV,SAAS,SAAiBC,GAAO;AAC/B,WAAOD,EAAM,OAAOC,CAAK,KAAK,SAASA,GAAO,EAAE,MAAMA;AAAA,EACxD;AAAA,EACA,OAAO,SAAeA,GAAO;AAC3B,WAAOD,EAAM,OAAOC,CAAK,KAAK,CAACD,EAAM,QAAQC,CAAK;AAAA,EACpD;AAAA,EACA,OAAO,SAAeA,GAAO;AAC3B,WAAO,MAAM,QAAQA,CAAK;AAAA,EAC5B;AAAA,EACA,QAAQ,SAAgBA,GAAO;AAC7B,QAAIA,aAAiB;AACnB,aAAO;AAET,QAAI;AACF,aAAO,CAAC,CAAC,IAAI,OAAOA,CAAK;AAAA,IAC3B,QAAY;AACV,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EACA,MAAM,SAAcA,GAAO;AACzB,WAAO,OAAOA,EAAM,WAAY,cAAc,OAAOA,EAAM,YAAa,cAAc,OAAOA,EAAM,WAAY,cAAc,CAAC,MAAMA,EAAM,SAAS;AAAA,EACrJ;AAAA,EACA,QAAQ,SAAgBA,GAAO;AAC7B,WAAI,MAAMA,CAAK,IACN,KAEF,OAAOA,KAAU;AAAA,EAC1B;AAAA,EACA,QAAQ,SAAgBA,GAAO;AAC7B,WAAOC,EAAQD,CAAK,MAAM,YAAY,CAACD,EAAM,MAAMC,CAAK;AAAA,EAC1D;AAAA,EACA,QAAQ,SAAgBA,GAAO;AAC7B,WAAO,OAAOA,KAAU;AAAA,EAC1B;AAAA,EACA,OAAO,SAAeA,GAAO;A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date" || r === "pattern";
|
|
60
|
+
return r === "string" || r === "url" || r === "hex" || r === "email" || r === "date" || r === "pattern" || r === "tel";
|
|
61
61
|
}
|
|
62
62
|
function X(r, t) {
|
|
63
63
|
return !!(r == null || t === "array" && Array.isArray(r) && !r.length || I(t) && typeof r == "string" && !r);
|