PromoCursed/node_modules/.cache/babel-loader/23eb47fc5c3471a080a6123f1e172dd1365993021bee0f2db56352fea3216a72.json

1 line
29 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport { useEvent, useMergedState } from 'rc-util';\nimport * as React from 'react';\nimport useSyncState from \"../../hooks/useSyncState\";\nimport { formatValue, isSame, isSameTimestamp } from \"../../utils/dateUtil\";\nimport { fillIndex } from \"../../utils/miscUtil\";\nimport useLockEffect from \"./useLockEffect\";\nvar EMPTY_VALUE = [];\n\n// Submit Logic:\n// * ✅ Value:\n// * merged value using controlled value, if not, use stateValue\n// * When merged value change, [1] resync calendar value and submit value\n// * ✅ Calender Value:\n// * 💻 When user typing is validate, change the calendar value\n// * 🌅 When user click on the panel, change the calendar value\n// * Submit Value:\n// * 💻 When user blur the input, flush calendar value to submit value\n// * 🌅 When user click on the panel is no needConfirm, flush calendar value to submit value\n// * 🌅 When user click on the panel is needConfirm and click OK, flush calendar value to submit value\n// * Blur logic & close logic:\n// * ✅ For value, always try flush submit\n// * ✅ If `needConfirm`, reset as [1]\n// * Else (`!needConfirm`)\n// * If has another index field, active another index\n// * ✅ Flush submit:\n// * If all the start & end field is confirmed or all blur or panel closed\n// * Update `needSubmit` mark to true\n// * trigger onChange by `needSubmit` and update stateValue\n\nfunction useUtil(generateConfig, locale, formatList) {\n var getDateTexts = function getDateTexts(dates) {\n return dates.map(function (date) {\n return formatValue(date, {\n generateConfig: generateConfig,\n locale: locale,\n format: formatList[0]\n });\n });\n };\n var isSameDates = function isSameDates(source, target) {\n var maxLen = Math.max(source.length, target.length);\n var diffIndex = -1;\n for (var i = 0; i < maxLen; i += 1) {\n var prev = source[i] || null;\n var next = target[i] || null;\n if (prev !== next && !isSameTimestamp(generateConfig, prev, next)) {\n diffIndex = i;\n break;\n }\n }\n return [diffIndex < 0, diffIndex !== 0];\n };\n return [getDateTexts, isSameDates];\n}\nfunction orderDates(dates, generateConfig) {\n return _toConsumableArray(dates).sort(function (a, b) {\n return generateConfig.isAfter(a, b) ? 1 : -1;\n });\n}\n\n/**\n * Used for internal value management.\n * It should always use `mergedValue` in render logic\n */\nexport function useCalendarValue(mergedValue) {\n var _useSyncState = useSyncState(mergedValue),\n _useSyncState2 = _slicedToArray(_useSyncState, 2),\n calendarValue = _useSyncState2[0],\n setCalendarValue = _useSyncState2[1];\n\n /** Sync calendarValue & submitValue back with value */\n var syncWithValue = useEvent(function () {\n setCalendarValue(mergedValue);\n });\n React.useEffect(function () {\n syncWithValue();\n }, [mergedValue]);\n return [calendarValue, setCalendarValue];\n}\n\n/**\n * Control the internal `value` align with prop `value` and provide a temp `calendarValue` for ui.\n * `calendarValue` will be reset when blur & focus & open.\n */\nexport function useInnerValue(generateConfig, locale, formatList, /** Used for RangePicker. `true` means [DateType, DateType] or will be DateType[] */\nrangeValue,\n/**\n * Trigger order when trigger calendar value change.\n * This should only used in SinglePicker with `multiple` mode.\n * So when `rangeValue` is `true`, order will be ignored.\n */\norder, defaultValue, value, onCalendarChange, onOk) {\n // This is the root value which will sync with controlled or uncontrolled value\n var _useMergedState = useMergedState(defaultValue, {\n value: value\n }),\n _useMergedState2 = _slicedToArray(_useMergedState, 2),\n innerValue = _useMergedState2[0],\n setInnerValue = _useMergedState2[1];\n var mergedValue = innerV