@mdigitalcn/utils 2.0.0
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/LICENSE +21 -0
- package/README.md +228 -0
- package/dist/esm/array/checkValueInArray.js +2 -0
- package/dist/esm/array/checkValueInArray.js.map +1 -0
- package/dist/esm/array/chunk.js +2 -0
- package/dist/esm/array/chunk.js.map +1 -0
- package/dist/esm/array/collectBy.js +2 -0
- package/dist/esm/array/collectBy.js.map +1 -0
- package/dist/esm/array/compact.js +2 -0
- package/dist/esm/array/compact.js.map +1 -0
- package/dist/esm/array/countBy.js +2 -0
- package/dist/esm/array/countBy.js.map +1 -0
- package/dist/esm/array/difference.js +2 -0
- package/dist/esm/array/difference.js.map +1 -0
- package/dist/esm/array/drop.js +2 -0
- package/dist/esm/array/drop.js.map +1 -0
- package/dist/esm/array/dropWhile.js +2 -0
- package/dist/esm/array/dropWhile.js.map +1 -0
- package/dist/esm/array/first.js +2 -0
- package/dist/esm/array/first.js.map +1 -0
- package/dist/esm/array/flatten.js +2 -0
- package/dist/esm/array/flatten.js.map +1 -0
- package/dist/esm/array/groupBy.js +2 -0
- package/dist/esm/array/groupBy.js.map +1 -0
- package/dist/esm/array/index.js +2 -0
- package/dist/esm/array/index.js.map +1 -0
- package/dist/esm/array/intersection.js +2 -0
- package/dist/esm/array/intersection.js.map +1 -0
- package/dist/esm/array/keyBy.js +2 -0
- package/dist/esm/array/keyBy.js.map +1 -0
- package/dist/esm/array/last.js +2 -0
- package/dist/esm/array/last.js.map +1 -0
- package/dist/esm/array/maxBy.js +2 -0
- package/dist/esm/array/maxBy.js.map +1 -0
- package/dist/esm/array/minBy.js +2 -0
- package/dist/esm/array/minBy.js.map +1 -0
- package/dist/esm/array/partition.js +2 -0
- package/dist/esm/array/partition.js.map +1 -0
- package/dist/esm/array/sameElementsInArrays.js +2 -0
- package/dist/esm/array/sameElementsInArrays.js.map +1 -0
- package/dist/esm/array/sample.js +2 -0
- package/dist/esm/array/sample.js.map +1 -0
- package/dist/esm/array/shuffle.js +2 -0
- package/dist/esm/array/shuffle.js.map +1 -0
- package/dist/esm/array/sortBy.js +2 -0
- package/dist/esm/array/sortBy.js.map +1 -0
- package/dist/esm/array/take.js +2 -0
- package/dist/esm/array/take.js.map +1 -0
- package/dist/esm/array/takeWhile.js +2 -0
- package/dist/esm/array/takeWhile.js.map +1 -0
- package/dist/esm/array/union.js +2 -0
- package/dist/esm/array/union.js.map +1 -0
- package/dist/esm/array/uniq.js +2 -0
- package/dist/esm/array/uniq.js.map +1 -0
- package/dist/esm/array/uniqBy.js +2 -0
- package/dist/esm/array/uniqBy.js.map +1 -0
- package/dist/esm/array/without.js +2 -0
- package/dist/esm/array/without.js.map +1 -0
- package/dist/esm/array/xor.js +2 -0
- package/dist/esm/array/xor.js.map +1 -0
- package/dist/esm/array/zip.js +2 -0
- package/dist/esm/array/zip.js.map +1 -0
- package/dist/esm/array/zipObject.js +2 -0
- package/dist/esm/array/zipObject.js.map +1 -0
- package/dist/esm/file/anyToString.js +2 -0
- package/dist/esm/file/anyToString.js.map +1 -0
- package/dist/esm/file/convertToFormData.js +2 -0
- package/dist/esm/file/convertToFormData.js.map +1 -0
- package/dist/esm/file/decodeURIValue.js +2 -0
- package/dist/esm/file/decodeURIValue.js.map +1 -0
- package/dist/esm/file/downloadFile.js +2 -0
- package/dist/esm/file/downloadFile.js.map +1 -0
- package/dist/esm/file/getBase64.js +2 -0
- package/dist/esm/file/getBase64.js.map +1 -0
- package/dist/esm/file/index.js +2 -0
- package/dist/esm/file/index.js.map +1 -0
- package/dist/esm/file/isFileArray.js +2 -0
- package/dist/esm/file/isFileArray.js.map +1 -0
- package/dist/esm/function/compose.js +2 -0
- package/dist/esm/function/compose.js.map +1 -0
- package/dist/esm/function/curry.js +2 -0
- package/dist/esm/function/curry.js.map +1 -0
- package/dist/esm/function/debounce.js +2 -0
- package/dist/esm/function/debounce.js.map +1 -0
- package/dist/esm/function/hexToRgba.js +2 -0
- package/dist/esm/function/hexToRgba.js.map +1 -0
- package/dist/esm/function/identity.js +2 -0
- package/dist/esm/function/identity.js.map +1 -0
- package/dist/esm/function/index.js +2 -0
- package/dist/esm/function/index.js.map +1 -0
- package/dist/esm/function/memoize.js +2 -0
- package/dist/esm/function/memoize.js.map +1 -0
- package/dist/esm/function/negate.js +2 -0
- package/dist/esm/function/negate.js.map +1 -0
- package/dist/esm/function/noop.js +2 -0
- package/dist/esm/function/noop.js.map +1 -0
- package/dist/esm/function/once.js +2 -0
- package/dist/esm/function/once.js.map +1 -0
- package/dist/esm/function/partial.js +2 -0
- package/dist/esm/function/partial.js.map +1 -0
- package/dist/esm/function/pipe.js +2 -0
- package/dist/esm/function/pipe.js.map +1 -0
- package/dist/esm/function/queryString.js +2 -0
- package/dist/esm/function/queryString.js.map +1 -0
- package/dist/esm/function/throttle.js +2 -0
- package/dist/esm/function/throttle.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/math/clamp.js +2 -0
- package/dist/esm/math/clamp.js.map +1 -0
- package/dist/esm/math/inRange.js +2 -0
- package/dist/esm/math/inRange.js.map +1 -0
- package/dist/esm/math/index.js +2 -0
- package/dist/esm/math/index.js.map +1 -0
- package/dist/esm/math/mean.js +2 -0
- package/dist/esm/math/mean.js.map +1 -0
- package/dist/esm/math/median.js +2 -0
- package/dist/esm/math/median.js.map +1 -0
- package/dist/esm/math/random.js +2 -0
- package/dist/esm/math/random.js.map +1 -0
- package/dist/esm/math/range.js +2 -0
- package/dist/esm/math/range.js.map +1 -0
- package/dist/esm/math/round.js +2 -0
- package/dist/esm/math/round.js.map +1 -0
- package/dist/esm/math/sum.js +2 -0
- package/dist/esm/math/sum.js.map +1 -0
- package/dist/esm/object/cloneDeep.js +2 -0
- package/dist/esm/object/cloneDeep.js.map +1 -0
- package/dist/esm/object/findKey.js +2 -0
- package/dist/esm/object/findKey.js.map +1 -0
- package/dist/esm/object/flattenObject.js +2 -0
- package/dist/esm/object/flattenObject.js.map +1 -0
- package/dist/esm/object/get.js +2 -0
- package/dist/esm/object/get.js.map +1 -0
- package/dist/esm/object/getTrue.js +2 -0
- package/dist/esm/object/getTrue.js.map +1 -0
- package/dist/esm/object/has.js +2 -0
- package/dist/esm/object/has.js.map +1 -0
- package/dist/esm/object/index.js +2 -0
- package/dist/esm/object/index.js.map +1 -0
- package/dist/esm/object/invert.js +2 -0
- package/dist/esm/object/invert.js.map +1 -0
- package/dist/esm/object/isEmpty.js +2 -0
- package/dist/esm/object/isEmpty.js.map +1 -0
- package/dist/esm/object/jsonParse.js +2 -0
- package/dist/esm/object/jsonParse.js.map +1 -0
- package/dist/esm/object/mapKeys.js +2 -0
- package/dist/esm/object/mapKeys.js.map +1 -0
- package/dist/esm/object/mapValues.js +2 -0
- package/dist/esm/object/mapValues.js.map +1 -0
- package/dist/esm/object/mergeDeep.js +2 -0
- package/dist/esm/object/mergeDeep.js.map +1 -0
- package/dist/esm/object/omit.js +2 -0
- package/dist/esm/object/omit.js.map +1 -0
- package/dist/esm/object/omitBy.js +2 -0
- package/dist/esm/object/omitBy.js.map +1 -0
- package/dist/esm/object/path.js +2 -0
- package/dist/esm/object/path.js.map +1 -0
- package/dist/esm/object/pathOr.js +2 -0
- package/dist/esm/object/pathOr.js.map +1 -0
- package/dist/esm/object/pick.js +2 -0
- package/dist/esm/object/pick.js.map +1 -0
- package/dist/esm/object/pickBy.js +2 -0
- package/dist/esm/object/pickBy.js.map +1 -0
- package/dist/esm/object/prop.js +2 -0
- package/dist/esm/object/prop.js.map +1 -0
- package/dist/esm/object/propOr.js +2 -0
- package/dist/esm/object/propOr.js.map +1 -0
- package/dist/esm/object/set.js +2 -0
- package/dist/esm/object/set.js.map +1 -0
- package/dist/esm/predicate/index.js +2 -0
- package/dist/esm/predicate/index.js.map +1 -0
- package/dist/esm/predicate/isArray.js +2 -0
- package/dist/esm/predicate/isArray.js.map +1 -0
- package/dist/esm/predicate/isBoolean.js +2 -0
- package/dist/esm/predicate/isBoolean.js.map +1 -0
- package/dist/esm/predicate/isDate.js +2 -0
- package/dist/esm/predicate/isDate.js.map +1 -0
- package/dist/esm/predicate/isEqual.js +2 -0
- package/dist/esm/predicate/isEqual.js.map +1 -0
- package/dist/esm/predicate/isError.js +2 -0
- package/dist/esm/predicate/isError.js.map +1 -0
- package/dist/esm/predicate/isFunction.js +2 -0
- package/dist/esm/predicate/isFunction.js.map +1 -0
- package/dist/esm/predicate/isNil.js +2 -0
- package/dist/esm/predicate/isNil.js.map +1 -0
- package/dist/esm/predicate/isNumber.js +2 -0
- package/dist/esm/predicate/isNumber.js.map +1 -0
- package/dist/esm/predicate/isPlainObject.js +2 -0
- package/dist/esm/predicate/isPlainObject.js.map +1 -0
- package/dist/esm/predicate/isPrimitive.js +2 -0
- package/dist/esm/predicate/isPrimitive.js.map +1 -0
- package/dist/esm/predicate/isPromise.js +2 -0
- package/dist/esm/predicate/isPromise.js.map +1 -0
- package/dist/esm/predicate/isString.js +2 -0
- package/dist/esm/predicate/isString.js.map +1 -0
- package/dist/esm/promise/attempt.js +2 -0
- package/dist/esm/promise/attempt.js.map +1 -0
- package/dist/esm/promise/delay.js +2 -0
- package/dist/esm/promise/delay.js.map +1 -0
- package/dist/esm/promise/index.js +2 -0
- package/dist/esm/promise/index.js.map +1 -0
- package/dist/esm/promise/invariant.js +2 -0
- package/dist/esm/promise/invariant.js.map +1 -0
- package/dist/esm/promise/retry.js +2 -0
- package/dist/esm/promise/retry.js.map +1 -0
- package/dist/esm/promise/timeout.js +2 -0
- package/dist/esm/promise/timeout.js.map +1 -0
- package/dist/esm/react/hooks/useClickOutside.js +3 -0
- package/dist/esm/react/hooks/useClickOutside.js.map +1 -0
- package/dist/esm/react/hooks/useCopyToClipboard.js +3 -0
- package/dist/esm/react/hooks/useCopyToClipboard.js.map +1 -0
- package/dist/esm/react/hooks/useDebounce.js +3 -0
- package/dist/esm/react/hooks/useDebounce.js.map +1 -0
- package/dist/esm/react/hooks/useIntersectionObserver.js +3 -0
- package/dist/esm/react/hooks/useIntersectionObserver.js.map +1 -0
- package/dist/esm/react/hooks/useIsMounted.js +3 -0
- package/dist/esm/react/hooks/useIsMounted.js.map +1 -0
- package/dist/esm/react/hooks/useLocalStorage.js +3 -0
- package/dist/esm/react/hooks/useLocalStorage.js.map +1 -0
- package/dist/esm/react/hooks/useMediaQuery.js +3 -0
- package/dist/esm/react/hooks/useMediaQuery.js.map +1 -0
- package/dist/esm/react/hooks/useMountEffect.js +3 -0
- package/dist/esm/react/hooks/useMountEffect.js.map +1 -0
- package/dist/esm/react/hooks/usePrevious.js +3 -0
- package/dist/esm/react/hooks/usePrevious.js.map +1 -0
- package/dist/esm/react/hooks/useScreenSize.js +3 -0
- package/dist/esm/react/hooks/useScreenSize.js.map +1 -0
- package/dist/esm/react/hooks/useSessionStorage.js +3 -0
- package/dist/esm/react/hooks/useSessionStorage.js.map +1 -0
- package/dist/esm/react/hooks/useThrottle.js +3 -0
- package/dist/esm/react/hooks/useThrottle.js.map +1 -0
- package/dist/esm/react/hooks/useToggle.js +3 -0
- package/dist/esm/react/hooks/useToggle.js.map +1 -0
- package/dist/esm/react/hooks/useUpdateEffect.js +3 -0
- package/dist/esm/react/hooks/useUpdateEffect.js.map +1 -0
- package/dist/esm/react/index.js +2 -0
- package/dist/esm/react/index.js.map +1 -0
- package/dist/esm/react/utils/clsx.js +2 -0
- package/dist/esm/react/utils/clsx.js.map +1 -0
- package/dist/esm/react/utils/createContext.js +3 -0
- package/dist/esm/react/utils/createContext.js.map +1 -0
- package/dist/esm/react/utils/displayField.js +2 -0
- package/dist/esm/react/utils/displayField.js.map +1 -0
- package/dist/esm/string/camelCase.js +2 -0
- package/dist/esm/string/camelCase.js.map +1 -0
- package/dist/esm/string/capitalize.js +2 -0
- package/dist/esm/string/capitalize.js.map +1 -0
- package/dist/esm/string/deburr.js +2 -0
- package/dist/esm/string/deburr.js.map +1 -0
- package/dist/esm/string/escapeHtml.js +2 -0
- package/dist/esm/string/escapeHtml.js.map +1 -0
- package/dist/esm/string/escapeRegExp.js +2 -0
- package/dist/esm/string/escapeRegExp.js.map +1 -0
- package/dist/esm/string/formatBytes.js +2 -0
- package/dist/esm/string/formatBytes.js.map +1 -0
- package/dist/esm/string/formatDuration.js +2 -0
- package/dist/esm/string/formatDuration.js.map +1 -0
- package/dist/esm/string/formatNumber.js +2 -0
- package/dist/esm/string/formatNumber.js.map +1 -0
- package/dist/esm/string/htmlToText.js +2 -0
- package/dist/esm/string/htmlToText.js.map +1 -0
- package/dist/esm/string/index.js +2 -0
- package/dist/esm/string/index.js.map +1 -0
- package/dist/esm/string/kebabCase.js +2 -0
- package/dist/esm/string/kebabCase.js.map +1 -0
- package/dist/esm/string/maskString.js +2 -0
- package/dist/esm/string/maskString.js.map +1 -0
- package/dist/esm/string/pascalCase.js +2 -0
- package/dist/esm/string/pascalCase.js.map +1 -0
- package/dist/esm/string/pluralize.js +2 -0
- package/dist/esm/string/pluralize.js.map +1 -0
- package/dist/esm/string/slugify.js +2 -0
- package/dist/esm/string/slugify.js.map +1 -0
- package/dist/esm/string/snakeCase.js +2 -0
- package/dist/esm/string/snakeCase.js.map +1 -0
- package/dist/esm/string/startCase.js +2 -0
- package/dist/esm/string/startCase.js.map +1 -0
- package/dist/esm/string/template.js +2 -0
- package/dist/esm/string/template.js.map +1 -0
- package/dist/esm/string/truncateString.js +2 -0
- package/dist/esm/string/truncateString.js.map +1 -0
- package/dist/esm/string/words.js +2 -0
- package/dist/esm/string/words.js.map +1 -0
- package/dist/esm/validation/index.js +2 -0
- package/dist/esm/validation/index.js.map +1 -0
- package/dist/esm/validation/validateFileSizeByType.js +2 -0
- package/dist/esm/validation/validateFileSizeByType.js.map +1 -0
- package/dist/types/array/checkValueInArray.d.ts +23 -0
- package/dist/types/array/checkValueInArray.d.ts.map +1 -0
- package/dist/types/array/chunk.d.ts +15 -0
- package/dist/types/array/chunk.d.ts.map +1 -0
- package/dist/types/array/collectBy.d.ts +21 -0
- package/dist/types/array/collectBy.d.ts.map +1 -0
- package/dist/types/array/compact.d.ts +19 -0
- package/dist/types/array/compact.d.ts.map +1 -0
- package/dist/types/array/countBy.d.ts +13 -0
- package/dist/types/array/countBy.d.ts.map +1 -0
- package/dist/types/array/difference.d.ts +14 -0
- package/dist/types/array/difference.d.ts.map +1 -0
- package/dist/types/array/drop.d.ts +14 -0
- package/dist/types/array/drop.d.ts.map +1 -0
- package/dist/types/array/dropWhile.d.ts +13 -0
- package/dist/types/array/dropWhile.d.ts.map +1 -0
- package/dist/types/array/first.d.ts +13 -0
- package/dist/types/array/first.d.ts.map +1 -0
- package/dist/types/array/flatten.d.ts +13 -0
- package/dist/types/array/flatten.d.ts.map +1 -0
- package/dist/types/array/groupBy.d.ts +17 -0
- package/dist/types/array/groupBy.d.ts.map +1 -0
- package/dist/types/array/index.d.ts +31 -0
- package/dist/types/array/index.d.ts.map +1 -0
- package/dist/types/array/intersection.d.ts +14 -0
- package/dist/types/array/intersection.d.ts.map +1 -0
- package/dist/types/array/keyBy.d.ts +15 -0
- package/dist/types/array/keyBy.d.ts.map +1 -0
- package/dist/types/array/last.d.ts +13 -0
- package/dist/types/array/last.d.ts.map +1 -0
- package/dist/types/array/maxBy.d.ts +13 -0
- package/dist/types/array/maxBy.d.ts.map +1 -0
- package/dist/types/array/minBy.d.ts +13 -0
- package/dist/types/array/minBy.d.ts.map +1 -0
- package/dist/types/array/partition.d.ts +13 -0
- package/dist/types/array/partition.d.ts.map +1 -0
- package/dist/types/array/sameElementsInArrays.d.ts +15 -0
- package/dist/types/array/sameElementsInArrays.d.ts.map +1 -0
- package/dist/types/array/sample.d.ts +12 -0
- package/dist/types/array/sample.d.ts.map +1 -0
- package/dist/types/array/shuffle.d.ts +12 -0
- package/dist/types/array/shuffle.d.ts.map +1 -0
- package/dist/types/array/sortBy.d.ts +20 -0
- package/dist/types/array/sortBy.d.ts.map +1 -0
- package/dist/types/array/take.d.ts +14 -0
- package/dist/types/array/take.d.ts.map +1 -0
- package/dist/types/array/takeWhile.d.ts +13 -0
- package/dist/types/array/takeWhile.d.ts.map +1 -0
- package/dist/types/array/union.d.ts +13 -0
- package/dist/types/array/union.d.ts.map +1 -0
- package/dist/types/array/uniq.d.ts +12 -0
- package/dist/types/array/uniq.d.ts.map +1 -0
- package/dist/types/array/uniqBy.d.ts +12 -0
- package/dist/types/array/uniqBy.d.ts.map +1 -0
- package/dist/types/array/without.d.ts +13 -0
- package/dist/types/array/without.d.ts.map +1 -0
- package/dist/types/array/xor.d.ts +13 -0
- package/dist/types/array/xor.d.ts.map +1 -0
- package/dist/types/array/zip.d.ts +15 -0
- package/dist/types/array/zip.d.ts.map +1 -0
- package/dist/types/array/zipObject.d.ts +13 -0
- package/dist/types/array/zipObject.d.ts.map +1 -0
- package/dist/types/file/anyToString.d.ts +24 -0
- package/dist/types/file/anyToString.d.ts.map +1 -0
- package/dist/types/file/convertToFormData.d.ts +19 -0
- package/dist/types/file/convertToFormData.d.ts.map +1 -0
- package/dist/types/file/decodeURIValue.d.ts +22 -0
- package/dist/types/file/decodeURIValue.d.ts.map +1 -0
- package/dist/types/file/downloadFile.d.ts +28 -0
- package/dist/types/file/downloadFile.d.ts.map +1 -0
- package/dist/types/file/getBase64.d.ts +20 -0
- package/dist/types/file/getBase64.d.ts.map +1 -0
- package/dist/types/file/index.d.ts +7 -0
- package/dist/types/file/index.d.ts.map +1 -0
- package/dist/types/file/isFileArray.d.ts +13 -0
- package/dist/types/file/isFileArray.d.ts.map +1 -0
- package/dist/types/function/compose.d.ts +24 -0
- package/dist/types/function/compose.d.ts.map +1 -0
- package/dist/types/function/curry.d.ts +39 -0
- package/dist/types/function/curry.d.ts.map +1 -0
- package/dist/types/function/debounce.d.ts +36 -0
- package/dist/types/function/debounce.d.ts.map +1 -0
- package/dist/types/function/hexToRgba.d.ts +19 -0
- package/dist/types/function/hexToRgba.d.ts.map +1 -0
- package/dist/types/function/identity.d.ts +24 -0
- package/dist/types/function/identity.d.ts.map +1 -0
- package/dist/types/function/index.d.ts +16 -0
- package/dist/types/function/index.d.ts.map +1 -0
- package/dist/types/function/memoize.d.ts +20 -0
- package/dist/types/function/memoize.d.ts.map +1 -0
- package/dist/types/function/negate.d.ts +12 -0
- package/dist/types/function/negate.d.ts.map +1 -0
- package/dist/types/function/noop.d.ts +27 -0
- package/dist/types/function/noop.d.ts.map +1 -0
- package/dist/types/function/once.d.ts +22 -0
- package/dist/types/function/once.d.ts.map +1 -0
- package/dist/types/function/partial.d.ts +17 -0
- package/dist/types/function/partial.d.ts.map +1 -0
- package/dist/types/function/pipe.d.ts +24 -0
- package/dist/types/function/pipe.d.ts.map +1 -0
- package/dist/types/function/queryString.d.ts +44 -0
- package/dist/types/function/queryString.d.ts.map +1 -0
- package/dist/types/function/throttle.d.ts +35 -0
- package/dist/types/function/throttle.d.ts.map +1 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/math/clamp.d.ts +15 -0
- package/dist/types/math/clamp.d.ts.map +1 -0
- package/dist/types/math/inRange.d.ts +18 -0
- package/dist/types/math/inRange.d.ts.map +1 -0
- package/dist/types/math/index.d.ts +9 -0
- package/dist/types/math/index.d.ts.map +1 -0
- package/dist/types/math/mean.d.ts +11 -0
- package/dist/types/math/mean.d.ts.map +1 -0
- package/dist/types/math/median.d.ts +15 -0
- package/dist/types/math/median.d.ts.map +1 -0
- package/dist/types/math/random.d.ts +27 -0
- package/dist/types/math/random.d.ts.map +1 -0
- package/dist/types/math/range.d.ts +18 -0
- package/dist/types/math/range.d.ts.map +1 -0
- package/dist/types/math/round.d.ts +16 -0
- package/dist/types/math/round.d.ts.map +1 -0
- package/dist/types/math/sum.d.ts +11 -0
- package/dist/types/math/sum.d.ts.map +1 -0
- package/dist/types/object/cloneDeep.d.ts +18 -0
- package/dist/types/object/cloneDeep.d.ts.map +1 -0
- package/dist/types/object/findKey.d.ts +14 -0
- package/dist/types/object/findKey.d.ts.map +1 -0
- package/dist/types/object/flattenObject.d.ts +16 -0
- package/dist/types/object/flattenObject.d.ts.map +1 -0
- package/dist/types/object/get.d.ts +22 -0
- package/dist/types/object/get.d.ts.map +1 -0
- package/dist/types/object/getTrue.d.ts +12 -0
- package/dist/types/object/getTrue.d.ts.map +1 -0
- package/dist/types/object/has.d.ts +15 -0
- package/dist/types/object/has.d.ts.map +1 -0
- package/dist/types/object/index.d.ts +22 -0
- package/dist/types/object/index.d.ts.map +1 -0
- package/dist/types/object/invert.d.ts +13 -0
- package/dist/types/object/invert.d.ts.map +1 -0
- package/dist/types/object/isEmpty.d.ts +23 -0
- package/dist/types/object/isEmpty.d.ts.map +1 -0
- package/dist/types/object/jsonParse.d.ts +21 -0
- package/dist/types/object/jsonParse.d.ts.map +1 -0
- package/dist/types/object/mapKeys.d.ts +17 -0
- package/dist/types/object/mapKeys.d.ts.map +1 -0
- package/dist/types/object/mapValues.d.ts +17 -0
- package/dist/types/object/mapValues.d.ts.map +1 -0
- package/dist/types/object/mergeDeep.d.ts +20 -0
- package/dist/types/object/mergeDeep.d.ts.map +1 -0
- package/dist/types/object/omit.d.ts +13 -0
- package/dist/types/object/omit.d.ts.map +1 -0
- package/dist/types/object/omitBy.d.ts +17 -0
- package/dist/types/object/omitBy.d.ts.map +1 -0
- package/dist/types/object/path.d.ts +13 -0
- package/dist/types/object/path.d.ts.map +1 -0
- package/dist/types/object/pathOr.d.ts +14 -0
- package/dist/types/object/pathOr.d.ts.map +1 -0
- package/dist/types/object/pick.d.ts +13 -0
- package/dist/types/object/pick.d.ts.map +1 -0
- package/dist/types/object/pickBy.d.ts +17 -0
- package/dist/types/object/pickBy.d.ts.map +1 -0
- package/dist/types/object/prop.d.ts +31 -0
- package/dist/types/object/prop.d.ts.map +1 -0
- package/dist/types/object/propOr.d.ts +39 -0
- package/dist/types/object/propOr.d.ts.map +1 -0
- package/dist/types/object/set.d.ts +16 -0
- package/dist/types/object/set.d.ts.map +1 -0
- package/dist/types/predicate/index.d.ts +16 -0
- package/dist/types/predicate/index.d.ts.map +1 -0
- package/dist/types/predicate/isArray.d.ts +14 -0
- package/dist/types/predicate/isArray.d.ts.map +1 -0
- package/dist/types/predicate/isBoolean.d.ts +14 -0
- package/dist/types/predicate/isBoolean.d.ts.map +1 -0
- package/dist/types/predicate/isDate.d.ts +16 -0
- package/dist/types/predicate/isDate.d.ts.map +1 -0
- package/dist/types/predicate/isEqual.d.ts +18 -0
- package/dist/types/predicate/isEqual.d.ts.map +1 -0
- package/dist/types/predicate/isError.d.ts +14 -0
- package/dist/types/predicate/isError.d.ts.map +1 -0
- package/dist/types/predicate/isFunction.d.ts +14 -0
- package/dist/types/predicate/isFunction.d.ts.map +1 -0
- package/dist/types/predicate/isNil.d.ts +33 -0
- package/dist/types/predicate/isNil.d.ts.map +1 -0
- package/dist/types/predicate/isNumber.d.ts +17 -0
- package/dist/types/predicate/isNumber.d.ts.map +1 -0
- package/dist/types/predicate/isPlainObject.d.ts +18 -0
- package/dist/types/predicate/isPlainObject.d.ts.map +1 -0
- package/dist/types/predicate/isPrimitive.d.ts +18 -0
- package/dist/types/predicate/isPrimitive.d.ts.map +1 -0
- package/dist/types/predicate/isPromise.d.ts +14 -0
- package/dist/types/predicate/isPromise.d.ts.map +1 -0
- package/dist/types/predicate/isString.d.ts +14 -0
- package/dist/types/predicate/isString.d.ts.map +1 -0
- package/dist/types/promise/attempt.d.ts +28 -0
- package/dist/types/promise/attempt.d.ts.map +1 -0
- package/dist/types/promise/delay.d.ts +26 -0
- package/dist/types/promise/delay.d.ts.map +1 -0
- package/dist/types/promise/index.d.ts +10 -0
- package/dist/types/promise/index.d.ts.map +1 -0
- package/dist/types/promise/invariant.d.ts +18 -0
- package/dist/types/promise/invariant.d.ts.map +1 -0
- package/dist/types/promise/retry.d.ts +36 -0
- package/dist/types/promise/retry.d.ts.map +1 -0
- package/dist/types/promise/timeout.d.ts +30 -0
- package/dist/types/promise/timeout.d.ts.map +1 -0
- package/dist/types/react/hooks/index.d.ts +21 -0
- package/dist/types/react/hooks/index.d.ts.map +1 -0
- package/dist/types/react/hooks/useClickOutside.d.ts +116 -0
- package/dist/types/react/hooks/useClickOutside.d.ts.map +1 -0
- package/dist/types/react/hooks/useCopyToClipboard.d.ts +22 -0
- package/dist/types/react/hooks/useCopyToClipboard.d.ts.map +1 -0
- package/dist/types/react/hooks/useDebounce.d.ts +57 -0
- package/dist/types/react/hooks/useDebounce.d.ts.map +1 -0
- package/dist/types/react/hooks/useIntersectionObserver.d.ts +118 -0
- package/dist/types/react/hooks/useIntersectionObserver.d.ts.map +1 -0
- package/dist/types/react/hooks/useIsMounted.d.ts +26 -0
- package/dist/types/react/hooks/useIsMounted.d.ts.map +1 -0
- package/dist/types/react/hooks/useLocalStorage.d.ts +78 -0
- package/dist/types/react/hooks/useLocalStorage.d.ts.map +1 -0
- package/dist/types/react/hooks/useMediaQuery.d.ts +85 -0
- package/dist/types/react/hooks/useMediaQuery.d.ts.map +1 -0
- package/dist/types/react/hooks/useMountEffect.d.ts +107 -0
- package/dist/types/react/hooks/useMountEffect.d.ts.map +1 -0
- package/dist/types/react/hooks/usePrevious.d.ts +88 -0
- package/dist/types/react/hooks/usePrevious.d.ts.map +1 -0
- package/dist/types/react/hooks/useScreenSize.d.ts +37 -0
- package/dist/types/react/hooks/useScreenSize.d.ts.map +1 -0
- package/dist/types/react/hooks/useSessionStorage.d.ts +49 -0
- package/dist/types/react/hooks/useSessionStorage.d.ts.map +1 -0
- package/dist/types/react/hooks/useThrottle.d.ts +62 -0
- package/dist/types/react/hooks/useThrottle.d.ts.map +1 -0
- package/dist/types/react/hooks/useToggle.d.ts +89 -0
- package/dist/types/react/hooks/useToggle.d.ts.map +1 -0
- package/dist/types/react/hooks/useUpdateEffect.d.ts +91 -0
- package/dist/types/react/hooks/useUpdateEffect.d.ts.map +1 -0
- package/dist/types/react/index.d.ts +9 -0
- package/dist/types/react/index.d.ts.map +1 -0
- package/dist/types/react/utils/clsx.d.ts +31 -0
- package/dist/types/react/utils/clsx.d.ts.map +1 -0
- package/dist/types/react/utils/createContext.d.ts +27 -0
- package/dist/types/react/utils/createContext.d.ts.map +1 -0
- package/dist/types/react/utils/displayField.d.ts +18 -0
- package/dist/types/react/utils/displayField.d.ts.map +1 -0
- package/dist/types/react/utils/index.d.ts +5 -0
- package/dist/types/react/utils/index.d.ts.map +1 -0
- package/dist/types/string/camelCase.d.ts +16 -0
- package/dist/types/string/camelCase.d.ts.map +1 -0
- package/dist/types/string/capitalize.d.ts +11 -0
- package/dist/types/string/capitalize.d.ts.map +1 -0
- package/dist/types/string/deburr.d.ts +14 -0
- package/dist/types/string/deburr.d.ts.map +1 -0
- package/dist/types/string/escapeHtml.d.ts +17 -0
- package/dist/types/string/escapeHtml.d.ts.map +1 -0
- package/dist/types/string/escapeRegExp.d.ts +13 -0
- package/dist/types/string/escapeRegExp.d.ts.map +1 -0
- package/dist/types/string/formatBytes.d.ts +16 -0
- package/dist/types/string/formatBytes.d.ts.map +1 -0
- package/dist/types/string/formatDuration.d.ts +15 -0
- package/dist/types/string/formatDuration.d.ts.map +1 -0
- package/dist/types/string/formatNumber.d.ts +20 -0
- package/dist/types/string/formatNumber.d.ts.map +1 -0
- package/dist/types/string/htmlToText.d.ts +29 -0
- package/dist/types/string/htmlToText.d.ts.map +1 -0
- package/dist/types/string/index.d.ts +20 -0
- package/dist/types/string/index.d.ts.map +1 -0
- package/dist/types/string/kebabCase.d.ts +16 -0
- package/dist/types/string/kebabCase.d.ts.map +1 -0
- package/dist/types/string/maskString.d.ts +18 -0
- package/dist/types/string/maskString.d.ts.map +1 -0
- package/dist/types/string/pascalCase.d.ts +14 -0
- package/dist/types/string/pascalCase.d.ts.map +1 -0
- package/dist/types/string/pluralize.d.ts +17 -0
- package/dist/types/string/pluralize.d.ts.map +1 -0
- package/dist/types/string/slugify.d.ts +15 -0
- package/dist/types/string/slugify.d.ts.map +1 -0
- package/dist/types/string/snakeCase.d.ts +16 -0
- package/dist/types/string/snakeCase.d.ts.map +1 -0
- package/dist/types/string/startCase.d.ts +14 -0
- package/dist/types/string/startCase.d.ts.map +1 -0
- package/dist/types/string/template.d.ts +15 -0
- package/dist/types/string/template.d.ts.map +1 -0
- package/dist/types/string/truncateString.d.ts +13 -0
- package/dist/types/string/truncateString.d.ts.map +1 -0
- package/dist/types/string/words.d.ts +16 -0
- package/dist/types/string/words.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +44 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/validation/index.d.ts +5 -0
- package/dist/types/validation/index.d.ts.map +1 -0
- package/dist/types/validation/validateFileSizeByType.d.ts +32 -0
- package/dist/types/validation/validateFileSizeByType.d.ts.map +1 -0
- package/package.json +109 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set.js","sources":["../../../src/object/set.ts"],"sourcesContent":["/**\n * Creates a shallow clone of an object with a value set at the given path.\n * Creates intermediate objects/arrays as needed. Does not mutate the original.\n *\n * @example\n * set({}, 'a.b.c', 42) // { a: { b: { c: 42 } } }\n * set({ a: { b: 1 } }, 'a.b', 2) // { a: { b: 2 } }\n * set({ x: 1 }, ['a', 'b'], 3) // { x: 1, a: { b: 3 } }\n *\n * @param obj - Source object\n * @param path - Dot-separated string or array of keys\n * @param value - Value to set\n * @returns New object with the value set at the path\n */\nexport function set<T extends Record<string, any>>(\n obj: T,\n path: string | string[],\n value: unknown\n): T {\n const keys = Array.isArray(path) ? path : path.split('.');\n if (keys.length === 0) return obj;\n\n const result = { ...obj } as any;\n let current = result;\n\n for (let i = 0; i < keys.length - 1; i++) {\n const key = keys[i];\n current[key] = current[key] != null && typeof current[key] === 'object'\n ? { ...current[key] }\n : {};\n current = current[key];\n }\n\n current[keys[keys.length - 1]] = value;\n return result;\n}\n"],"names":["set","obj","path","value","keys","Array","isArray","split","length","result","current","i","key"],"mappings":"SAcgBA,EACdC,EACAC,EACAC,GAEA,MAAMC,EAAOC,MAAMC,QAAQJ,GAAQA,EAAOA,EAAKK,MAAM,KACrD,GAAoB,IAAhBH,EAAKI,OAAc,OAAOP,EAE9B,MAAMQ,EAAS,IAAKR,GACpB,IAAIS,EAAUD,EAEd,IAAK,IAAIE,EAAI,EAAGA,EAAIP,EAAKI,OAAS,EAAGG,IAAK,CACxC,MAAMC,EAAMR,EAAKO,GACjBD,EAAQE,GAAuB,MAAhBF,EAAQE,IAAwC,iBAAjBF,EAAQE,GAClD,IAAKF,EAAQE,IACb,CAAA,EACJF,EAAUA,EAAQE,EACpB,CAGA,OADAF,EAAQN,EAAKA,EAAKI,OAAS,IAAML,EAC1BM,CACT"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export{isNil,isNotNil}from"./isNil.js";export{isString}from"./isString.js";export{isNumber}from"./isNumber.js";export{isBoolean}from"./isBoolean.js";export{isArray}from"./isArray.js";export{isFunction}from"./isFunction.js";export{isDate}from"./isDate.js";export{isError}from"./isError.js";export{isPrimitive}from"./isPrimitive.js";export{isPromise}from"./isPromise.js";export{isPlainObject}from"./isPlainObject.js";export{isEqual}from"./isEqual.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isArray.js","sources":["../../../src/predicate/isArray.ts"],"sourcesContent":["/**\n * Type guard that checks if a value is an array.\n *\n * @example\n * isArray([1, 2, 3]) // true\n * isArray([]) // true\n * isArray('hello') // false\n * isArray({ length: 0 }) // false\n *\n * @param value - Value to check\n * @returns true if value is an array\n */\nexport function isArray(value: unknown): value is unknown[] {\n return Array.isArray(value);\n}\n"],"names":["isArray","value","Array"],"mappings":"AAYM,SAAUA,EAAQC,GACtB,OAAOC,MAAMF,QAAQC,EACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isBoolean.js","sources":["../../../src/predicate/isBoolean.ts"],"sourcesContent":["/**\n * Type guard that checks if a value is a boolean.\n *\n * @example\n * isBoolean(true) // true\n * isBoolean(false) // true\n * isBoolean(0) // false\n * isBoolean('true') // false\n *\n * @param value - Value to check\n * @returns true if value is a boolean\n */\nexport function isBoolean(value: unknown): value is boolean {\n return typeof value === 'boolean';\n}\n"],"names":["isBoolean","value"],"mappings":"AAYM,SAAUA,EAAUC,GACxB,MAAwB,kBAAVA,CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isDate.js","sources":["../../../src/predicate/isDate.ts"],"sourcesContent":["/**\n * Type guard that checks if a value is a valid Date instance.\n * Returns false for invalid dates (e.g., `new Date('invalid')`).\n *\n * @example\n * isDate(new Date()) // true\n * isDate(new Date('2024-01-01')) // true\n * isDate(new Date('invalid')) // false\n * isDate('2024-01-01') // false\n * isDate(Date.now()) // false (number)\n *\n * @param value - Value to check\n * @returns true if value is a valid Date\n */\nexport function isDate(value: unknown): value is Date {\n return value instanceof Date && !Number.isNaN(value.getTime());\n}\n"],"names":["isDate","value","Date","Number","isNaN","getTime"],"mappings":"AAcM,SAAUA,EAAOC,GACrB,OAAOA,aAAiBC,OAASC,OAAOC,MAAMH,EAAMI,UACtD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function r(e,t){if(Object.is(e,t))return!0;if(typeof e!=typeof t)return!1;if(null===e||null===t)return!1;if("object"!=typeof e||"object"!=typeof t)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.source===t.source&&e.flags===t.flags;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[n,f]of e)if(!t.has(n)||!r(f,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;const n=Array.from(t);for(const t of e){if(!n.some(e=>r(t,e)))return!1}return!0}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!r(e[n],t[n]))return!1;return!0}if(Array.isArray(e)!==Array.isArray(t))return!1;const n=Object.keys(e),f=Object.keys(t);if(n.length!==f.length)return!1;for(const f of n){if(!Object.prototype.hasOwnProperty.call(t,f))return!1;if(!r(e[f],t[f]))return!1}return!0}export{r as isEqual};
|
|
2
|
+
//# sourceMappingURL=isEqual.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isEqual.js","sources":["../../../src/predicate/isEqual.ts"],"sourcesContent":["/**\n * Performs a deep equality check between two values.\n * Handles primitives, objects, arrays, Date, RegExp, Map, Set, and nested structures.\n *\n * @example\n * isEqual(1, 1) // true\n * isEqual({ a: 1, b: { c: 2 } }, { a: 1, b: { c: 2 } }) // true\n * isEqual([1, [2, 3]], [1, [2, 3]]) // true\n * isEqual({ a: 1 }, { a: 2 }) // false\n * isEqual(new Date('2024-01-01'), new Date('2024-01-01')) // true\n * isEqual(new Set([1, 2]), new Set([1, 2])) // true\n *\n * @param a - First value\n * @param b - Second value\n * @returns true if values are deeply equal\n */\nexport function isEqual(a: unknown, b: unknown): boolean {\n // Same reference or both primitives with same value\n if (Object.is(a, b)) return true;\n\n // Different types\n if (typeof a !== typeof b) return false;\n if (a === null || b === null) return false;\n if (typeof a !== 'object' || typeof b !== 'object') return false;\n\n // Date comparison\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n // RegExp comparison\n if (a instanceof RegExp && b instanceof RegExp) {\n return a.source === b.source && a.flags === b.flags;\n }\n\n // Map comparison\n if (a instanceof Map && b instanceof Map) {\n if (a.size !== b.size) return false;\n for (const [key, val] of a) {\n if (!b.has(key) || !isEqual(val, b.get(key))) return false;\n }\n return true;\n }\n\n // Set comparison (deep equality for members)\n if (a instanceof Set && b instanceof Set) {\n if (a.size !== b.size) return false;\n const bArr = Array.from(b);\n for (const val of a) {\n const found = bArr.some((bVal) => isEqual(val, bVal));\n if (!found) return false;\n }\n return true;\n }\n\n // Array comparison\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (!isEqual(a[i], b[i])) return false;\n }\n return true;\n }\n\n // One is array, other isn't\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n\n // Object comparison\n const keysA = Object.keys(a as object);\n const keysB = Object.keys(b as object);\n\n if (keysA.length !== keysB.length) return false;\n\n for (const key of keysA) {\n if (!Object.prototype.hasOwnProperty.call(b, key)) return false;\n if (!isEqual((a as any)[key], (b as any)[key])) return false;\n }\n\n return true;\n}\n"],"names":["isEqual","a","b","Object","is","Date","getTime","RegExp","source","flags","Map","size","key","val","has","get","Set","bArr","Array","from","some","bVal","isArray","length","i","keysA","keys","keysB","prototype","hasOwnProperty","call"],"mappings":"AAgBM,SAAUA,EAAQC,EAAYC,GAElC,GAAIC,OAAOC,GAAGH,EAAGC,GAAI,OAAO,EAG5B,UAAWD,UAAaC,EAAG,OAAO,EAClC,GAAU,OAAND,GAAoB,OAANC,EAAY,OAAO,EACrC,GAAiB,iBAAND,GAA+B,iBAANC,EAAgB,OAAO,EAG3D,GAAID,aAAaI,MAAQH,aAAaG,KACpC,OAAOJ,EAAEK,YAAcJ,EAAEI,UAI3B,GAAIL,aAAaM,QAAUL,aAAaK,OACtC,OAAON,EAAEO,SAAWN,EAAEM,QAAUP,EAAEQ,QAAUP,EAAEO,MAIhD,GAAIR,aAAaS,KAAOR,aAAaQ,IAAK,CACxC,GAAIT,EAAEU,OAAST,EAAES,KAAM,OAAO,EAC9B,IAAK,MAAOC,EAAKC,KAAQZ,EACvB,IAAKC,EAAEY,IAAIF,KAASZ,EAAQa,EAAKX,EAAEa,IAAIH,IAAO,OAAO,EAEvD,OAAO,CACT,CAGA,GAAIX,aAAae,KAAOd,aAAac,IAAK,CACxC,GAAIf,EAAEU,OAAST,EAAES,KAAM,OAAO,EAC9B,MAAMM,EAAOC,MAAMC,KAAKjB,GACxB,IAAK,MAAMW,KAAOZ,EAAG,CAEnB,IADcgB,EAAKG,KAAMC,GAASrB,EAAQa,EAAKQ,IACnC,OAAO,CACrB,CACA,OAAO,CACT,CAGA,GAAIH,MAAMI,QAAQrB,IAAMiB,MAAMI,QAAQpB,GAAI,CACxC,GAAID,EAAEsB,SAAWrB,EAAEqB,OAAQ,OAAO,EAClC,IAAK,IAAIC,EAAI,EAAGA,EAAIvB,EAAEsB,OAAQC,IAC5B,IAAKxB,EAAQC,EAAEuB,GAAItB,EAAEsB,IAAK,OAAO,EAEnC,OAAO,CACT,CAGA,GAAIN,MAAMI,QAAQrB,KAAOiB,MAAMI,QAAQpB,GAAI,OAAO,EAGlD,MAAMuB,EAAQtB,OAAOuB,KAAKzB,GACpB0B,EAAQxB,OAAOuB,KAAKxB,GAE1B,GAAIuB,EAAMF,SAAWI,EAAMJ,OAAQ,OAAO,EAE1C,IAAK,MAAMX,KAAOa,EAAO,CACvB,IAAKtB,OAAOyB,UAAUC,eAAeC,KAAK5B,EAAGU,GAAM,OAAO,EAC1D,IAAKZ,EAASC,EAAUW,GAAOV,EAAUU,IAAO,OAAO,CACzD,CAEA,OAAO,CACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isError.js","sources":["../../../src/predicate/isError.ts"],"sourcesContent":["/**\n * Type guard that checks if a value is an Error instance.\n *\n * @example\n * isError(new Error('fail')) // true\n * isError(new TypeError('bad')) // true\n * isError({ message: 'not an error' }) // false\n * isError('error string') // false\n *\n * @param value - Value to check\n * @returns true if value is an Error\n */\nexport function isError(value: unknown): value is Error {\n return value instanceof Error;\n}\n"],"names":["isError","value","Error"],"mappings":"AAYM,SAAUA,EAAQC,GACtB,OAAOA,aAAiBC,KAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isFunction.js","sources":["../../../src/predicate/isFunction.ts"],"sourcesContent":["/**\n * Type guard that checks if a value is a function.\n *\n * @example\n * isFunction(() => {}) // true\n * isFunction(Math.round) // true\n * isFunction(class Foo {}) // true\n * isFunction('hello') // false\n *\n * @param value - Value to check\n * @returns true if value is a function\n */\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport function isFunction(value: unknown): value is Function {\n return typeof value === 'function';\n}\n"],"names":["isFunction","value"],"mappings":"AAaM,SAAUA,EAAWC,GACzB,MAAwB,mBAAVA,CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isNil.js","sources":["../../../src/predicate/isNil.ts"],"sourcesContent":["/**\n * Type guard that checks if a value is null or undefined.\n *\n * @example\n * isNil(null) // true\n * isNil(undefined) // true\n * isNil(0) // false\n * isNil('') // false\n * isNil(false) // false\n *\n * @param value - Value to check\n * @returns true if value is null or undefined\n */\nexport function isNil(value: unknown): value is null | undefined {\n return value == null;\n}\n\n/**\n * Type guard that checks if a value is NOT null or undefined.\n * Narrows the type by excluding null and undefined.\n *\n * @example\n * isNotNil(0) // true\n * isNotNil('') // true\n * isNotNil(null) // false\n * isNotNil(undefined) // false\n *\n * @example\n * const items = [1, null, 2, undefined, 3];\n * items.filter(isNotNil) // [1, 2, 3] — type is number[]\n *\n * @param value - Value to check\n * @returns true if value is not null or undefined\n */\nexport function isNotNil<T>(value: T | null | undefined): value is T {\n return value != null;\n}\n"],"names":["isNil","value","isNotNil"],"mappings":"AAaM,SAAUA,EAAMC,GACpB,OAAgB,MAATA,CACT,CAmBM,SAAUC,EAAYD,GAC1B,OAAgB,MAATA,CACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isNumber.js","sources":["../../../src/predicate/isNumber.ts"],"sourcesContent":["/**\n * Type guard that checks if a value is a finite number.\n * Returns false for NaN and Infinity.\n *\n * @example\n * isNumber(42) // true\n * isNumber(3.14) // true\n * isNumber(NaN) // false\n * isNumber(Infinity) // false\n * isNumber('42') // false\n * isNumber(null) // false\n *\n * @param value - Value to check\n * @returns true if value is a finite number\n */\nexport function isNumber(value: unknown): value is number {\n return typeof value === 'number' && !Number.isNaN(value) && Number.isFinite(value);\n}\n"],"names":["isNumber","value","Number","isNaN","isFinite"],"mappings":"AAeM,SAAUA,EAASC,GACvB,MAAwB,iBAAVA,IAAuBC,OAAOC,MAAMF,IAAUC,OAAOE,SAASH,EAC9E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPlainObject.js","sources":["../../../src/predicate/isPlainObject.ts"],"sourcesContent":["/**\n * Checks if a value is a plain object (created by {} or Object.create(null)).\n * Returns false for arrays, class instances, Date, Map, Set, etc.\n *\n * @example\n * isPlainObject({}) // true\n * isPlainObject({ key: 'value' }) // true\n * isPlainObject(Object.create(null)) // true\n * isPlainObject([]) // false\n * isPlainObject(new Date()) // false\n * isPlainObject(new Map()) // false\n * isPlainObject(null) // false\n *\n * @param value - Value to check\n * @returns true if value is a plain object\n */\nexport function isPlainObject(value: unknown): value is Record<string, unknown> {\n if (value === null || typeof value !== 'object') return false;\n if (Array.isArray(value)) return false;\n\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n}\n"],"names":["isPlainObject","value","Array","isArray","proto","Object","getPrototypeOf","prototype"],"mappings":"AAgBM,SAAUA,EAAcC,GAC5B,GAAc,OAAVA,GAAmC,iBAAVA,EAAoB,OAAO,EACxD,GAAIC,MAAMC,QAAQF,GAAQ,OAAO,EAEjC,MAAMG,EAAQC,OAAOC,eAAeL,GACpC,OAAOG,IAAUC,OAAOE,WAAuB,OAAVH,CACvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPrimitive.js","sources":["../../../src/predicate/isPrimitive.ts"],"sourcesContent":["/**\n * Type guard that checks if a value is a primitive type.\n * Primitives: string, number, boolean, symbol, bigint, undefined, null.\n *\n * @example\n * isPrimitive('hello') // true\n * isPrimitive(42) // true\n * isPrimitive(null) // true\n * isPrimitive(undefined) // true\n * isPrimitive({}) // false\n * isPrimitive([]) // false\n * isPrimitive(new Date()) // false\n *\n * @param value - Value to check\n * @returns true if value is a primitive\n */\nexport function isPrimitive(value: unknown): value is string | number | boolean | symbol | bigint | undefined | null {\n return value === null || (typeof value !== 'object' && typeof value !== 'function');\n}\n"],"names":["isPrimitive","value"],"mappings":"AAgBM,SAAUA,EAAYC,GAC1B,OAAiB,OAAVA,GAAoC,iBAAVA,GAAuC,mBAAVA,CAChE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPromise.js","sources":["../../../src/predicate/isPromise.ts"],"sourcesContent":["/**\n * Type guard that checks if a value is a Promise (or thenable).\n *\n * @example\n * isPromise(Promise.resolve(1)) // true\n * isPromise(new Promise(() => {})) // true\n * isPromise({ then: () => {} }) // true (thenable)\n * isPromise(42) // false\n *\n * @param value - Value to check\n * @returns true if value is a Promise-like\n */\nexport function isPromise(value: unknown): value is Promise<unknown> {\n return (\n value != null &&\n typeof value === 'object' &&\n typeof (value as any).then === 'function'\n );\n}\n"],"names":["isPromise","value","then"],"mappings":"AAYM,SAAUA,EAAUC,GACxB,OACW,MAATA,GACiB,iBAAVA,GACwB,mBAAvBA,EAAcC,IAE1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isString.js","sources":["../../../src/predicate/isString.ts"],"sourcesContent":["/**\n * Type guard that checks if a value is a string.\n *\n * @example\n * isString('hello') // true\n * isString(123) // false\n * isString(null) // false\n * isString(new String('test')) // false — only primitives\n *\n * @param value - Value to check\n * @returns true if value is a string primitive\n */\nexport function isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n"],"names":["isString","value"],"mappings":"AAYM,SAAUA,EAASC,GACvB,MAAwB,iBAAVA,CAChB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function r(r){try{return[null,r()]}catch(r){return[r instanceof Error?r:new Error(String(r)),null]}}async function n(r){try{return[null,await r()]}catch(r){return[r instanceof Error?r:new Error(String(r)),null]}}export{r as attempt,n as attemptAsync};
|
|
2
|
+
//# sourceMappingURL=attempt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attempt.js","sources":["../../../src/promise/attempt.ts"],"sourcesContent":["/**\n * Executes a function and returns a `[error, result]` tuple.\n * Eliminates try/catch boilerplate (Go-style error handling).\n *\n * @example\n * const [err, result] = attempt(() => JSON.parse('{\"a\":1}'));\n * // [null, { a: 1 }]\n *\n * const [err, result] = attempt(() => JSON.parse('bad'));\n * // [SyntaxError, null]\n *\n * @param fn - Function to execute\n * @returns Tuple of [null, result] on success, or [error, null] on failure\n */\nexport function attempt<T>(fn: () => T): [null, T] | [Error, null] {\n try {\n return [null, fn()];\n } catch (error) {\n return [error instanceof Error ? error : new Error(String(error)), null];\n }\n}\n\n/**\n * Async version of `attempt`. Executes an async function and returns a `[error, result]` tuple.\n *\n * @example\n * const [err, data] = await attemptAsync(() => fetch('/api').then(r => r.json()));\n * if (err) console.error(err);\n * else console.log(data);\n *\n * @param fn - Async function to execute\n * @returns Promise of tuple [null, result] on success, or [error, null] on failure\n */\nexport async function attemptAsync<T>(fn: () => Promise<T>): Promise<[null, T] | [Error, null]> {\n try {\n return [null, await fn()];\n } catch (error) {\n return [error instanceof Error ? error : new Error(String(error)), null];\n }\n}\n"],"names":["attempt","fn","error","Error","String","async","attemptAsync"],"mappings":"AAcM,SAAUA,EAAWC,GACzB,IACE,MAAO,CAAC,KAAMA,IAChB,CAAE,MAAOC,GACP,MAAO,CAACA,aAAiBC,MAAQD,EAAQ,IAAIC,MAAMC,OAAOF,IAAS,KACrE,CACF,CAaOG,eAAeC,EAAgBL,GACpC,IACE,MAAO,CAAC,WAAYA,IACtB,CAAE,MAAOC,GACP,MAAO,CAACA,aAAiBC,MAAQD,EAAQ,IAAIC,MAAMC,OAAOF,IAAS,KACrE,CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delay.js","sources":["../../../src/promise/delay.ts"],"sourcesContent":["/**\n * Returns a promise that resolves after the specified number of milliseconds.\n * Useful for adding delays in async workflows, animations, or polling.\n *\n * @example\n * await delay(1000) // waits 1 second\n *\n * @example\n * // Delay with a value\n * const result = await delay(500).then(() => 'done')\n *\n * @example\n * // In async function\n * async function poll() {\n * while (true) {\n * const data = await fetchData();\n * if (data.ready) return data;\n * await delay(2000);\n * }\n * }\n *\n * @param ms - Milliseconds to wait\n * @returns Promise that resolves after the delay\n */\nexport function delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n"],"names":["delay","ms","Promise","resolve","setTimeout"],"mappings":"AAwBM,SAAUA,EAAMC,GACpB,OAAO,IAAIC,QAASC,GAAYC,WAAWD,EAASF,GACtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invariant.js","sources":["../../../src/promise/invariant.ts"],"sourcesContent":["/**\n * Asserts a condition is truthy, throws if not. Useful for type narrowing and runtime assertions.\n *\n * @example\n * const user: User | null = getUser();\n * invariant(user, 'User not found');\n * // TypeScript now knows `user` is `User` (not null)\n * console.log(user.name);\n *\n * @example\n * invariant(items.length > 0, 'Items array must not be empty');\n *\n * @param condition - Condition to assert\n * @param message - Error message if condition is falsy\n * @throws Error if condition is falsy\n */\nexport function invariant(condition: unknown, message: string): asserts condition {\n if (!condition) {\n throw new Error(message);\n }\n}\n"],"names":["invariant","condition","message","Error"],"mappings":"AAgBM,SAAUA,EAAUC,EAAoBC,GAC5C,IAAKD,EACH,MAAM,IAAIE,MAAMD,EAEpB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
async function e(e,t={}){const{retries:a=3,delay:o=1e3,backoff:r="exponential",shouldRetry:n}=t;let i;for(let t=0;t<=a;t++)try{return await e()}catch(e){if(i=e,t===a)break;if(n&&!n(e))break;const c="exponential"===r?o*Math.pow(2,t):o;await new Promise(e=>setTimeout(e,c))}throw i}export{e as retry};
|
|
2
|
+
//# sourceMappingURL=retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.js","sources":["../../../src/promise/retry.ts"],"sourcesContent":["/**\n * Retries an async function with exponential backoff.\n * Useful for unreliable network requests, flaky APIs, or transient errors.\n *\n * @example\n * const data = await retry(() => fetch('/api/data').then(r => r.json()), {\n * retries: 3,\n * delay: 1000,\n * })\n *\n * @example\n * // With custom backoff and error filter\n * const result = await retry(fetchUser, {\n * retries: 5,\n * delay: 500,\n * backoff: 'exponential',\n * shouldRetry: (error) => error.status !== 404,\n * })\n *\n * @param fn - Async function to retry\n * @param options - Retry configuration\n * @returns The resolved value from the function\n * @throws The last error if all retries fail\n */\nexport interface RetryOptions {\n /** Number of retry attempts (default: 3) */\n retries?: number;\n /** Initial delay between retries in ms (default: 1000) */\n delay?: number;\n /** Backoff strategy (default: 'exponential') */\n backoff?: 'fixed' | 'exponential';\n /** Optional filter — return false to stop retrying early */\n shouldRetry?: (error: unknown) => boolean;\n}\n\nexport async function retry<T>(\n fn: () => Promise<T>,\n options: RetryOptions = {}\n): Promise<T> {\n const {\n retries = 3,\n delay = 1000,\n backoff = 'exponential',\n shouldRetry,\n } = options;\n\n let lastError: unknown;\n\n for (let attempt = 0; attempt <= retries; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error;\n\n if (attempt === retries) break;\n if (shouldRetry && !shouldRetry(error)) break;\n\n const waitTime = backoff === 'exponential'\n ? delay * Math.pow(2, attempt)\n : delay;\n\n await new Promise((resolve) => setTimeout(resolve, waitTime));\n }\n }\n\n throw lastError;\n}\n"],"names":["async","retry","fn","options","retries","delay","backoff","shouldRetry","lastError","attempt","error","waitTime","Math","pow","Promise","resolve","setTimeout"],"mappings":"AAmCOA,eAAeC,EACpBC,EACAC,EAAwB,IAExB,MAAMC,QACJA,EAAU,EAACC,MACXA,EAAQ,IAAIC,QACZA,EAAU,cAAaC,YACvBA,GACEJ,EAEJ,IAAIK,EAEJ,IAAK,IAAIC,EAAU,EAAGA,GAAWL,EAASK,IACxC,IACE,aAAaP,GACf,CAAE,MAAOQ,GAGP,GAFAF,EAAYE,EAERD,IAAYL,EAAS,MACzB,GAAIG,IAAgBA,EAAYG,GAAQ,MAExC,MAAMC,EAAuB,gBAAZL,EACbD,EAAQO,KAAKC,IAAI,EAAGJ,GACpBJ,QAEE,IAAIS,QAASC,GAAYC,WAAWD,EAASJ,GACrD,CAGF,MAAMH,CACR"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
async function e(e,r,t){let o;const n=new Promise((e,n)=>{o=setTimeout(()=>{const e=new Error(t??`Operation timed out after ${r}ms`);e.name="TimeoutError",n(e)},r)});try{return await Promise.race([e,n])}finally{clearTimeout(o)}}export{e as timeout};
|
|
2
|
+
//# sourceMappingURL=timeout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeout.js","sources":["../../../src/promise/timeout.ts"],"sourcesContent":["/**\n * Wraps a promise with a timeout. If the promise doesn't resolve within\n * the specified time, it rejects with a TimeoutError.\n *\n * @example\n * // Timeout after 5 seconds\n * const data = await timeout(fetch('/api/slow'), 5000)\n *\n * @example\n * // With custom error message\n * const data = await timeout(fetchUser(id), 3000, 'User fetch timed out')\n *\n * @example\n * // Catch timeout specifically\n * try {\n * await timeout(longOperation(), 1000)\n * } catch (error) {\n * if (error instanceof Error && error.name === 'TimeoutError') {\n * console.log('Operation timed out');\n * }\n * }\n *\n * @param promise - Promise to wrap\n * @param ms - Timeout in milliseconds\n * @param message - Optional custom error message\n * @returns The resolved value from the promise\n * @throws TimeoutError if the promise doesn't resolve in time\n */\nexport async function timeout<T>(\n promise: Promise<T>,\n ms: number,\n message?: string\n): Promise<T> {\n let timeoutId: ReturnType<typeof setTimeout>;\n\n const timeoutPromise = new Promise<never>((_, reject) => {\n timeoutId = setTimeout(() => {\n const error = new Error(message ?? `Operation timed out after ${ms}ms`);\n error.name = 'TimeoutError';\n reject(error);\n }, ms);\n });\n\n try {\n return await Promise.race([promise, timeoutPromise]);\n } finally {\n clearTimeout(timeoutId!);\n }\n}\n"],"names":["async","timeout","promise","ms","message","timeoutId","timeoutPromise","Promise","_","reject","setTimeout","error","Error","name","race","clearTimeout"],"mappings":"AA4BOA,eAAeC,EACpBC,EACAC,EACAC,GAEA,IAAIC,EAEJ,MAAMC,EAAiB,IAAIC,QAAe,CAACC,EAAGC,KAC5CJ,EAAYK,WAAW,KACrB,MAAMC,EAAQ,IAAIC,MAAMR,GAAW,6BAA6BD,OAChEQ,EAAME,KAAO,eACbJ,EAAOE,IACNR,KAGL,IACE,aAAaI,QAAQO,KAAK,CAACZ,EAASI,GACtC,SACES,aAAaV,EACf,CACF"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useRef as t,useEffect as e}from"react";function n(n){const r=t(null),o=t(n);return e(()=>{o.current=n},[n]),e(()=>{const t=t=>{r.current&&!r.current.contains(t.target)&&o.current()};return document.addEventListener("mousedown",t),document.addEventListener("touchstart",t),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("touchstart",t)}},[]),r}export{n as useClickOutside};
|
|
3
|
+
//# sourceMappingURL=useClickOutside.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useClickOutside.js","sources":["../../../../src/react/hooks/useClickOutside.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef } from 'react';\n\n/**\n * Detects clicks outside of a specified element and triggers a callback.\n * Useful for dropdowns, modals, popovers, and menus that should close when clicking outside.\n * Uses React 19's ref pattern without forwardRef.\n *\n * @template T - The type of HTML element (extends HTMLElement)\n * @param {() => void} callback - Function to call when a click outside is detected\n * @returns {React.RefObject<T>} A ref object to attach to the target element\n *\n * @example\n * ```tsx\n * function Dropdown() {\n * const [isOpen, setIsOpen] = useState(false);\n * const dropdownRef = useClickOutside<HTMLDivElement>(() => {\n * setIsOpen(false);\n * });\n *\n * return (\n * <div ref={dropdownRef}>\n * <button onClick={() => setIsOpen(!isOpen)}>Toggle Menu</button>\n * {isOpen && (\n * <ul className=\"dropdown-menu\">\n * <li>Option 1</li>\n * <li>Option 2</li>\n * <li>Option 3</li>\n * </ul>\n * )}\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Modal that closes on outside click\n * function Modal({ onClose }: { onClose: () => void }) {\n * const modalRef = useClickOutside<HTMLDivElement>(onClose);\n *\n * return (\n * <div className=\"modal-overlay\">\n * <div ref={modalRef} className=\"modal-content\">\n * <h2>Modal Title</h2>\n * <p>Click outside to close</p>\n * <button onClick={onClose}>Close</button>\n * </div>\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Search suggestions that close on outside click\n * function SearchWithSuggestions() {\n * const [query, setQuery] = useState('');\n * const [showSuggestions, setShowSuggestions] = useState(false);\n * const searchRef = useClickOutside<HTMLDivElement>(() => {\n * setShowSuggestions(false);\n * });\n *\n * return (\n * <div ref={searchRef}>\n * <input\n * value={query}\n * onChange={(e) => {\n * setQuery(e.target.value);\n * setShowSuggestions(true);\n * }}\n * placeholder=\"Search...\"\n * />\n * {showSuggestions && query && (\n * <ul className=\"suggestions\">\n * <li>Suggestion 1</li>\n * <li>Suggestion 2</li>\n * </ul>\n * )}\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Context menu (right-click menu)\n * function ContextMenu() {\n * const [position, setPosition] = useState<{ x: number; y: number } | null>(null);\n * const menuRef = useClickOutside<HTMLDivElement>(() => {\n * setPosition(null);\n * });\n *\n * const handleContextMenu = (e: React.MouseEvent) => {\n * e.preventDefault();\n * setPosition({ x: e.clientX, y: e.clientY });\n * };\n *\n * return (\n * <div onContextMenu={handleContextMenu}>\n * Right-click me\n * {position && (\n * <div\n * ref={menuRef}\n * style={{ position: 'fixed', top: position.y, left: position.x }}\n * className=\"context-menu\"\n * >\n * <button>Copy</button>\n * <button>Paste</button>\n * <button>Delete</button>\n * </div>\n * )}\n * </div>\n * );\n * }\n * ```\n */\nexport function useClickOutside<T extends HTMLElement>(\n callback: () => void\n): React.RefObject<T | null> {\n const ref = useRef<T>(null);\n const callbackRef = useRef(callback);\n\n // Keep callback ref up to date\n useEffect(() => {\n callbackRef.current = callback;\n }, [callback]);\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent | TouchEvent) => {\n if (ref.current && !ref.current.contains(event.target as Node)) {\n callbackRef.current();\n }\n };\n\n // Add event listeners for both mouse and touch events\n document.addEventListener('mousedown', handleClickOutside);\n document.addEventListener('touchstart', handleClickOutside);\n\n return () => {\n document.removeEventListener('mousedown', handleClickOutside);\n document.removeEventListener('touchstart', handleClickOutside);\n };\n }, []); // Empty deps - event listeners only set up once\n\n return ref;\n}\n"],"names":["useClickOutside","callback","ref","useRef","callbackRef","useEffect","current","handleClickOutside","event","contains","target","document","addEventListener","removeEventListener"],"mappings":"8CAsHM,SAAUA,EACdC,GAEA,MAAMC,EAAMC,EAAU,MAChBC,EAAcD,EAAOF,GAwB3B,OArBAI,EAAU,KACRD,EAAYE,QAAUL,GACrB,CAACA,IAEJI,EAAU,KACR,MAAME,EAAsBC,IACtBN,EAAII,UAAYJ,EAAII,QAAQG,SAASD,EAAME,SAC7CN,EAAYE,WAQhB,OAHAK,SAASC,iBAAiB,YAAaL,GACvCI,SAASC,iBAAiB,aAAcL,GAEjC,KACLI,SAASE,oBAAoB,YAAaN,GAC1CI,SAASE,oBAAoB,aAAcN,KAE5C,IAEIL,CACT"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useState as r,useCallback as t}from"react";function a(a=2e3){const[o,n]=r(null);return[o,t(async r=>{if(!navigator?.clipboard)return console.warn("Clipboard API not available"),!1;try{return await navigator.clipboard.writeText(r),n(r),a>0&&setTimeout(()=>n(null),a),!0}catch(r){return console.warn("Copy to clipboard failed:",r),n(null),!1}},[a])]}export{a as useCopyToClipboard};
|
|
3
|
+
//# sourceMappingURL=useCopyToClipboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCopyToClipboard.js","sources":["../../../../src/react/hooks/useCopyToClipboard.ts"],"sourcesContent":["'use client';\n\nimport { useCallback, useState } from 'react';\n\n/**\n * Copies text to the clipboard and tracks the copied state.\n * Resets the copied state after the specified timeout.\n *\n * @example\n * ```tsx\n * function CopyButton({ text }: { text: string }) {\n * const [copiedText, copy] = useCopyToClipboard();\n *\n * return (\n * <button onClick={() => copy(text)}>\n * {copiedText ? 'Copied!' : 'Copy'}\n * </button>\n * );\n * }\n * ```\n *\n * @param resetDelay - Time in ms before the copied state resets (default: 2000)\n * @returns Tuple of [copiedText, copyFn]\n */\nexport function useCopyToClipboard(\n resetDelay = 2000\n): [string | null, (text: string) => Promise<boolean>] {\n const [copiedText, setCopiedText] = useState<string | null>(null);\n\n const copy = useCallback(\n async (text: string): Promise<boolean> => {\n if (!navigator?.clipboard) {\n console.warn('Clipboard API not available');\n return false;\n }\n\n try {\n await navigator.clipboard.writeText(text);\n setCopiedText(text);\n\n if (resetDelay > 0) {\n setTimeout(() => setCopiedText(null), resetDelay);\n }\n\n return true;\n } catch (error) {\n console.warn('Copy to clipboard failed:', error);\n setCopiedText(null);\n return false;\n }\n },\n [resetDelay]\n );\n\n return [copiedText, copy];\n}\n"],"names":["useCopyToClipboard","resetDelay","copiedText","setCopiedText","useState","useCallback","async","text","navigator","clipboard","console","warn","writeText","setTimeout","error"],"mappings":"kDAwBM,SAAUA,EACdC,EAAa,KAEb,MAAOC,EAAYC,GAAiBC,EAAwB,MA2B5D,MAAO,CAACF,EAzBKG,EACXC,MAAOC,IACL,IAAKC,WAAWC,UAEd,OADAC,QAAQC,KAAK,gCACN,EAGT,IAQE,aAPMH,UAAUC,UAAUG,UAAUL,GACpCJ,EAAcI,GAEVN,EAAa,GACfY,WAAW,IAAMV,EAAc,MAAOF,IAGjC,CACT,CAAE,MAAOa,GAGP,OAFAJ,QAAQC,KAAK,4BAA6BG,GAC1CX,EAAc,OACP,CACT,GAEF,CAACF,IAIL"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDebounce.js","sources":["../../../../src/react/hooks/useDebounce.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\n\n/**\n * Debounces a value, delaying updates until the specified delay has passed since the last change.\n * Useful for expensive operations like API calls, search filtering, or form validation.\n *\n * @template T - The type of the value to debounce\n * @param {T} value - The value to debounce\n * @param {number} delay - The debounce delay in milliseconds\n * @returns {T} The debounced value\n *\n * @example\n * ```tsx\n * function SearchInput() {\n * const [searchTerm, setSearchTerm] = useState('');\n * const debouncedSearchTerm = useDebounce(searchTerm, 500);\n *\n * useEffect(() => {\n * if (debouncedSearchTerm) {\n * // API call will only trigger 500ms after user stops typing\n * fetchSearchResults(debouncedSearchTerm);\n * }\n * }, [debouncedSearchTerm]);\n *\n * return (\n * <input\n * value={searchTerm}\n * onChange={(e) => setSearchTerm(e.target.value)}\n * placeholder=\"Search...\"\n * />\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Debouncing complex objects\n * function FilterPanel() {\n * const [filters, setFilters] = useState({ price: 0, category: '' });\n * const debouncedFilters = useDebounce(filters, 300);\n *\n * useEffect(() => {\n * applyFilters(debouncedFilters);\n * }, [debouncedFilters]);\n *\n * return (\n * <div>\n * <input\n * type=\"number\"\n * value={filters.price}\n * onChange={(e) => setFilters({ ...filters, price: Number(e.target.value) })}\n * />\n * </div>\n * );\n * }\n * ```\n */\nexport function useDebounce<T>(value: T, delay: number): T {\n const [debouncedValue, setDebouncedValue] = useState<T>(value);\n\n useEffect(() => {\n const handler = setTimeout(() => {\n setDebouncedValue(value);\n }, delay);\n\n return () => {\n clearTimeout(handler);\n };\n }, [value, delay]);\n\n return debouncedValue;\n}\n"],"names":["useDebounce","value","delay","debouncedValue","setDebouncedValue","useState","useEffect","handler","setTimeout","clearTimeout"],"mappings":"gDA2DM,SAAUA,EAAeC,EAAUC,GACvC,MAAOC,EAAgBC,GAAqBC,EAAYJ,GAYxD,OAVAK,EAAU,KACR,MAAMC,EAAUC,WAAW,KACzBJ,EAAkBH,IACjBC,GAEH,MAAO,KACLO,aAAaF,KAEd,CAACN,EAAOC,IAEJC,CACT"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useRef as r,useState as e,useEffect as n}from"react";function t(t){const o=r(null),[s,i]=e(!1),{threshold:c=0,root:u=null,rootMargin:d="0px"}=t||{};return n(()=>{const r=o.current;if(!r)return;if("undefined"==typeof IntersectionObserver)return console.warn("IntersectionObserver is not supported in this browser"),void i(!0);const e=new IntersectionObserver(([r])=>{i(r.isIntersecting)},{threshold:c,root:u,rootMargin:d});return e.observe(r),()=>{e.disconnect()}},[c,u,d]),[o,s]}export{t as useIntersectionObserver};
|
|
3
|
+
//# sourceMappingURL=useIntersectionObserver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIntersectionObserver.js","sources":["../../../../src/react/hooks/useIntersectionObserver.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef, useState } from 'react';\n\n/**\n * Observes when an element enters or leaves the viewport using the Intersection Observer API.\n * Useful for lazy loading, infinite scroll, animations on scroll, and tracking element visibility.\n * Uses React 19's ref pattern without forwardRef.\n *\n * @template T - The type of HTML element (extends HTMLElement)\n * @param {IntersectionObserverInit} [options] - Configuration options for the IntersectionObserver\n * @returns {[React.RefObject<T>, boolean]} A tuple containing the ref to attach and the visibility state\n *\n * @example\n * ```tsx\n * function LazyImage({ src, alt }: { src: string; alt: string }) {\n * const [ref, isVisible] = useIntersectionObserver<HTMLImageElement>({\n * threshold: 0.1,\n * rootMargin: '50px',\n * });\n *\n * return (\n * <img\n * ref={ref}\n * src={isVisible ? src : 'placeholder.jpg'}\n * alt={alt}\n * style={{ opacity: isVisible ? 1 : 0.5 }}\n * />\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Fade in animation when element enters viewport\n * function FadeInSection({ children }: { children: React.ReactNode }) {\n * const [ref, isVisible] = useIntersectionObserver<HTMLDivElement>({\n * threshold: 0.5,\n * triggerOnce: true,\n * });\n *\n * return (\n * <div\n * ref={ref}\n * className={`fade-in ${isVisible ? 'visible' : ''}`}\n * >\n * {children}\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Infinite scroll implementation\n * function InfiniteList() {\n * const [items, setItems] = useState<string[]>(initialItems);\n * const [sentinelRef, isVisible] = useIntersectionObserver<HTMLDivElement>({\n * threshold: 1.0,\n * });\n *\n * useEffect(() => {\n * if (isVisible) {\n * // Load more items when sentinel becomes visible\n * loadMoreItems().then(newItems => {\n * setItems(prev => [...prev, ...newItems]);\n * });\n * }\n * }, [isVisible]);\n *\n * return (\n * <div>\n * {items.map(item => <div key={item}>{item}</div>)}\n * <div ref={sentinelRef}>Loading more...</div>\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Analytics tracking for viewport visibility\n * function TrackableSection({ id, children }: { id: string; children: React.ReactNode }) {\n * const [ref, isVisible] = useIntersectionObserver<HTMLElement>({\n * threshold: 0.75,\n * });\n *\n * useEffect(() => {\n * if (isVisible) {\n * analytics.track('section_viewed', { sectionId: id });\n * }\n * }, [isVisible, id]);\n *\n * return (\n * <section ref={ref}>\n * {children}\n * </section>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Sticky header that changes on scroll\n * function Header() {\n * const [triggerRef, hasScrolled] = useIntersectionObserver<HTMLDivElement>({\n * threshold: 1.0,\n * });\n *\n * return (\n * <>\n * <div ref={triggerRef} style={{ height: 1 }} />\n * <header className={hasScrolled ? 'sticky' : 'normal'}>\n * Navigation\n * </header>\n * </>\n * );\n * }\n * ```\n */\nexport function useIntersectionObserver<T extends HTMLElement>(\n options?: IntersectionObserverInit\n): [React.RefObject<T | null>, boolean] {\n const ref = useRef<T>(null);\n const [isIntersecting, setIsIntersecting] = useState(false);\n\n // Destructure options for proper dependency tracking\n const { threshold = 0, root = null, rootMargin = '0px' } = options || {};\n\n useEffect(() => {\n const element = ref.current;\n if (!element) return;\n\n // Check if IntersectionObserver is supported\n if (typeof IntersectionObserver === 'undefined') {\n console.warn('IntersectionObserver is not supported in this browser');\n // Default to visible if not supported\n setIsIntersecting(true);\n return;\n }\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n setIsIntersecting(entry.isIntersecting);\n },\n {\n threshold,\n root,\n rootMargin,\n }\n );\n\n observer.observe(element);\n\n return () => {\n observer.disconnect();\n };\n }, [threshold, root, rootMargin]);\n\n return [ref, isIntersecting];\n}\n"],"names":["useIntersectionObserver","options","ref","useRef","isIntersecting","setIsIntersecting","useState","threshold","root","rootMargin","useEffect","element","current","IntersectionObserver","console","warn","observer","entry","observe","disconnect"],"mappings":"4DAwHM,SAAUA,EACdC,GAEA,MAAMC,EAAMC,EAAU,OACfC,EAAgBC,GAAqBC,GAAS,IAG/CC,UAAEA,EAAY,EAACC,KAAEA,EAAO,KAAIC,WAAEA,EAAa,OAAUR,GAAW,CAAA,EAgCtE,OA9BAS,EAAU,KACR,MAAMC,EAAUT,EAAIU,QACpB,IAAKD,EAAS,OAGd,GAAoC,oBAAzBE,qBAIT,OAHAC,QAAQC,KAAK,8DAEbV,GAAkB,GAIpB,MAAMW,EAAW,IAAIH,qBACnB,EAAEI,MACAZ,EAAkBY,EAAMb,iBAE1B,CACEG,YACAC,OACAC,eAMJ,OAFAO,EAASE,QAAQP,GAEV,KACLK,EAASG,eAEV,CAACZ,EAAWC,EAAMC,IAEd,CAACP,EAAKE,EACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsMounted.js","sources":["../../../../src/react/hooks/useIsMounted.ts"],"sourcesContent":["'use client';\n\nimport { useCallback, useEffect, useRef } from 'react';\n\n/**\n * Returns a function that reports whether the component is still mounted.\n * Useful for avoiding state updates on unmounted components in async operations.\n *\n * @example\n * ```tsx\n * function AsyncComponent() {\n * const isMounted = useIsMounted();\n * const [data, setData] = useState(null);\n *\n * useEffect(() => {\n * fetchData().then((result) => {\n * if (isMounted()) {\n * setData(result);\n * }\n * });\n * }, []);\n *\n * return <div>{data}</div>;\n * }\n * ```\n *\n * @returns A function that returns true if the component is mounted\n */\nexport function useIsMounted(): () => boolean {\n const mountedRef = useRef(false);\n\n useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n };\n }, []);\n\n return useCallback(() => mountedRef.current, []);\n}\n"],"names":["useIsMounted","mountedRef","useRef","useEffect","current","useCallback"],"mappings":"wEA4BgBA,IACd,MAAMC,EAAaC,GAAO,GAS1B,OAPAC,EAAU,KACRF,EAAWG,SAAU,EACd,KACLH,EAAWG,SAAU,IAEtB,IAEIC,EAAY,IAAMJ,EAAWG,QAAS,GAC/C"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useState as e,useCallback as n,useEffect as r}from"react";function t(t,o){const[a,i]=e(()=>{if("undefined"==typeof window)return o;try{const e=window.localStorage.getItem(t);return e?JSON.parse(e):o}catch(e){return console.warn(`Error reading localStorage key "${t}":`,e),o}}),c=n(e=>{try{i(n=>{const r=e instanceof Function?e(n):e;return"undefined"!=typeof window&&(window.localStorage.setItem(t,JSON.stringify(r)),window.dispatchEvent(new StorageEvent("storage",{key:t,newValue:JSON.stringify(r),storageArea:window.localStorage}))),r})}catch(e){console.warn(`Error setting localStorage key "${t}":`,e)}},[t]);return r(()=>{if("undefined"==typeof window)return;const e=e=>{if(e.key===t)if(null!==e.newValue)try{i(JSON.parse(e.newValue))}catch(e){console.warn(`Error parsing localStorage change for key "${t}":`,e)}else i(o)};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[t,o]),[a,c]}export{t as useLocalStorage};
|
|
3
|
+
//# sourceMappingURL=useLocalStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLocalStorage.js","sources":["../../../../src/react/hooks/useLocalStorage.ts"],"sourcesContent":["'use client';\n\nimport { useCallback, useEffect, useState } from 'react';\n\n/**\n * Manages state that persists to localStorage with automatic synchronization across tabs.\n * Handles SSR safely and provides type-safe storage operations with JSON serialization.\n *\n * @template T - The type of the stored value\n * @param {string} key - The localStorage key to store the value under\n * @param {T} initialValue - The default value if no stored value exists\n * @returns {[T, (value: T | ((prev: T) => T)) => void]} A stateful value and setter function\n *\n * @example\n * ```tsx\n * function ThemeSelector() {\n * const [theme, setTheme] = useLocalStorage('theme', 'light');\n *\n * return (\n * <div>\n * <p>Current theme: {theme}</p>\n * <button onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}>\n * Toggle Theme\n * </button>\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Storing complex objects\n * interface UserPreferences {\n * notifications: boolean;\n * language: string;\n * fontSize: number;\n * }\n *\n * function UserSettings() {\n * const [preferences, setPreferences] = useLocalStorage<UserPreferences>(\n * 'user-preferences',\n * { notifications: true, language: 'en', fontSize: 16 }\n * );\n *\n * return (\n * <div>\n * <label>\n * <input\n * type=\"checkbox\"\n * checked={preferences.notifications}\n * onChange={(e) =>\n * setPreferences({ ...preferences, notifications: e.target.checked })\n * }\n * />\n * Enable notifications\n * </label>\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Using functional updates\n * function ShoppingCart() {\n * const [cart, setCart] = useLocalStorage<string[]>('cart', []);\n *\n * const addItem = (item: string) => {\n * setCart((prev) => [...prev, item]);\n * };\n *\n * return (\n * <div>\n * <p>Items in cart: {cart.length}</p>\n * <button onClick={() => addItem('Product')}>Add Item</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useLocalStorage<T>(\n key: string,\n initialValue: T\n): [T, (value: T | ((prev: T) => T)) => void] {\n // State to store our value\n // Pass initial state function to useState so logic is only executed once\n const [storedValue, setStoredValue] = useState<T>(() => {\n if (typeof window === 'undefined') {\n return initialValue;\n }\n\n try {\n const item = window.localStorage.getItem(key);\n return item ? (JSON.parse(item) as T) : initialValue;\n } catch (error) {\n console.warn(`Error reading localStorage key \"${key}\":`, error);\n return initialValue;\n }\n });\n\n // Return a wrapped version of useState's setter function that persists the new value to localStorage\n const setValue = useCallback(\n (value: T | ((prev: T) => T)) => {\n try {\n setStoredValue((prevValue) => {\n // Allow value to be a function so we have same API as useState\n const valueToStore = value instanceof Function ? value(prevValue) : value;\n\n // Save to localStorage\n if (typeof window !== 'undefined') {\n window.localStorage.setItem(key, JSON.stringify(valueToStore));\n // Dispatch storage event for cross-tab synchronization\n window.dispatchEvent(\n new StorageEvent('storage', {\n key,\n newValue: JSON.stringify(valueToStore),\n storageArea: window.localStorage,\n })\n );\n }\n\n return valueToStore;\n });\n } catch (error) {\n console.warn(`Error setting localStorage key \"${key}\":`, error);\n }\n },\n [key]\n );\n\n // Listen for changes in other tabs/windows\n useEffect(() => {\n if (typeof window === 'undefined') {\n return;\n }\n\n const handleStorageChange = (e: StorageEvent) => {\n if (e.key === key) {\n if (e.newValue !== null) {\n try {\n setStoredValue(JSON.parse(e.newValue) as T);\n } catch (error) {\n console.warn(`Error parsing localStorage change for key \"${key}\":`, error);\n }\n } else {\n // Key was removed or storage was cleared\n setStoredValue(initialValue);\n }\n }\n };\n\n window.addEventListener('storage', handleStorageChange);\n return () => window.removeEventListener('storage', handleStorageChange);\n }, [key, initialValue]);\n\n return [storedValue, setValue];\n}\n"],"names":["useLocalStorage","key","initialValue","storedValue","setStoredValue","useState","window","item","localStorage","getItem","JSON","parse","error","console","warn","setValue","useCallback","value","prevValue","valueToStore","Function","setItem","stringify","dispatchEvent","StorageEvent","newValue","storageArea","useEffect","handleStorageChange","e","addEventListener","removeEventListener"],"mappings":"iEAgFM,SAAUA,EACdC,EACAC,GAIA,MAAOC,EAAaC,GAAkBC,EAAY,KAChD,GAAsB,oBAAXC,OACT,OAAOJ,EAGT,IACE,MAAMK,EAAOD,OAAOE,aAAaC,QAAQR,GACzC,OAAOM,EAAQG,KAAKC,MAAMJ,GAAcL,CAC1C,CAAE,MAAOU,GAEP,OADAC,QAAQC,KAAK,mCAAmCb,MAASW,GAClDV,CACT,IAIIa,EAAWC,EACdC,IACC,IACEb,EAAgBc,IAEd,MAAMC,EAAeF,aAAiBG,SAAWH,EAAMC,GAAaD,EAepE,MAZsB,oBAAXX,SACTA,OAAOE,aAAaa,QAAQpB,EAAKS,KAAKY,UAAUH,IAEhDb,OAAOiB,cACL,IAAIC,aAAa,UAAW,CAC1BvB,MACAwB,SAAUf,KAAKY,UAAUH,GACzBO,YAAapB,OAAOE,iBAKnBW,GAEX,CAAE,MAAOP,GACPC,QAAQC,KAAK,mCAAmCb,MAASW,EAC3D,GAEF,CAACX,IA4BH,OAxBA0B,EAAU,KACR,GAAsB,oBAAXrB,OACT,OAGF,MAAMsB,EAAuBC,IAC3B,GAAIA,EAAE5B,MAAQA,EACZ,GAAmB,OAAf4B,EAAEJ,SACJ,IACErB,EAAeM,KAAKC,MAAMkB,EAAEJ,UAC9B,CAAE,MAAOb,GACPC,QAAQC,KAAK,8CAA8Cb,MAASW,EACtE,MAGAR,EAAeF,IAMrB,OADAI,OAAOwB,iBAAiB,UAAWF,GAC5B,IAAMtB,OAAOyB,oBAAoB,UAAWH,IAClD,CAAC3B,EAAKC,IAEF,CAACC,EAAaY,EACvB"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useState as e,useEffect as n}from"react";function t(t){const[o,i]=e(()=>(e=>"undefined"!=typeof window&&window.matchMedia(e).matches)(t));return n(()=>{if("undefined"==typeof window)return;const e=window.matchMedia(t);i(e.matches);const n=e=>{i(e.matches)};return e.addEventListener("change",n),()=>e.removeEventListener("change",n)},[t]),o}export{t as useMediaQuery};
|
|
3
|
+
//# sourceMappingURL=useMediaQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMediaQuery.js","sources":["../../../../src/react/hooks/useMediaQuery.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\n\n/**\n * Tracks whether a CSS media query matches the current viewport.\n * Automatically updates when the viewport changes. Handles SSR safely.\n *\n * @param {string} query - The media query string to evaluate (e.g., '(min-width: 768px)')\n * @returns {boolean} True if the media query matches, false otherwise\n *\n * @example\n * ```tsx\n * function ResponsiveLayout() {\n * const isMobile = useMediaQuery('(max-width: 768px)');\n * const isTablet = useMediaQuery('(min-width: 769px) and (max-width: 1024px)');\n * const isDesktop = useMediaQuery('(min-width: 1025px)');\n *\n * return (\n * <div>\n * {isMobile && <MobileNav />}\n * {isTablet && <TabletNav />}\n * {isDesktop && <DesktopNav />}\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Dark mode detection\n * function ThemeAwareComponent() {\n * const prefersDark = useMediaQuery('(prefers-color-scheme: dark)');\n *\n * return (\n * <div className={prefersDark ? 'dark-theme' : 'light-theme'}>\n * System theme: {prefersDark ? 'Dark' : 'Light'}\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Reduced motion preference\n * function AnimatedComponent() {\n * const prefersReducedMotion = useMediaQuery('(prefers-reduced-motion: reduce)');\n *\n * return (\n * <div\n * className={prefersReducedMotion ? 'no-animation' : 'with-animation'}\n * >\n * Content\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Portrait/landscape detection\n * function OrientationAwareComponent() {\n * const isPortrait = useMediaQuery('(orientation: portrait)');\n *\n * return (\n * <div>\n * <p>Device orientation: {isPortrait ? 'Portrait' : 'Landscape'}</p>\n * {isPortrait ? <PortraitLayout /> : <LandscapeLayout />}\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Conditional rendering based on screen size\n * function DataTable() {\n * const isLargeScreen = useMediaQuery('(min-width: 1200px)');\n *\n * return isLargeScreen ? (\n * <DetailedTable columns={allColumns} />\n * ) : (\n * <CompactTable columns={essentialColumns} />\n * );\n * }\n * ```\n */\nexport function useMediaQuery(query: string): boolean {\n const getMatches = (query: string): boolean => {\n // Prevent SSR issues\n if (typeof window === 'undefined') {\n return false;\n }\n return window.matchMedia(query).matches;\n };\n\n const [matches, setMatches] = useState<boolean>(() => getMatches(query));\n\n useEffect(() => {\n if (typeof window === 'undefined') {\n return;\n }\n\n const mediaQuery = window.matchMedia(query);\n\n // Update state with current value\n setMatches(mediaQuery.matches);\n\n // Define the event handler\n const handleChange = (event: MediaQueryListEvent) => {\n setMatches(event.matches);\n };\n\n // Modern browsers support addEventListener\n mediaQuery.addEventListener('change', handleChange);\n return () => mediaQuery.removeEventListener('change', handleChange);\n }, [query]);\n\n return matches;\n}\n"],"names":["useMediaQuery","query","matches","setMatches","useState","window","matchMedia","getMatches","useEffect","mediaQuery","handleChange","event","addEventListener","removeEventListener"],"mappings":"gDAuFM,SAAUA,EAAcC,GAC5B,MAQOC,EAASC,GAAcC,EAAkB,IAR7B,CAACH,GAEI,oBAAXI,QAGJA,OAAOC,WAAWL,GAAOC,QAGoBK,CAAWN,IAsBjE,OApBAO,EAAU,KACR,GAAsB,oBAAXH,OACT,OAGF,MAAMI,EAAaJ,OAAOC,WAAWL,GAGrCE,EAAWM,EAAWP,SAGtB,MAAMQ,EAAgBC,IACpBR,EAAWQ,EAAMT,UAKnB,OADAO,EAAWG,iBAAiB,SAAUF,GAC/B,IAAMD,EAAWI,oBAAoB,SAAUH,IACrD,CAACT,IAEGC,CACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMountEffect.js","sources":["../../../../src/react/hooks/useMountEffect.ts"],"sourcesContent":["'use client';\n\nimport { useEffect } from 'react';\n\n/**\n * Runs an effect only once when the component mounts, similar to componentDidMount.\n * This is a semantic wrapper around useEffect with an empty dependency array.\n * Supports cleanup functions that run on unmount.\n *\n * @param {() => void | (() => void)} effect - The effect function to run on mount. Can return a cleanup function.\n *\n * @example\n * ```tsx\n * function DataFetcher() {\n * const [data, setData] = useState(null);\n *\n * useMountEffect(() => {\n * fetchData().then(setData);\n * });\n *\n * return <div>{data ? JSON.stringify(data) : 'Loading...'}</div>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With cleanup function\n * function WebSocketConnection() {\n * const [messages, setMessages] = useState<string[]>([]);\n *\n * useMountEffect(() => {\n * const ws = new WebSocket('ws://localhost:8080');\n *\n * ws.onmessage = (event) => {\n * setMessages(prev => [...prev, event.data]);\n * };\n *\n * // Cleanup: close connection on unmount\n * return () => {\n * ws.close();\n * };\n * });\n *\n * return (\n * <ul>\n * {messages.map((msg, i) => <li key={i}>{msg}</li>)}\n * </ul>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Analytics tracking\n * function PageView({ pageName }: { pageName: string }) {\n * useMountEffect(() => {\n * analytics.track('page_view', { page: pageName });\n * });\n *\n * return <div>Page content</div>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Event listener setup\n * function KeyboardShortcuts() {\n * useMountEffect(() => {\n * const handleKeyPress = (e: KeyboardEvent) => {\n * if (e.ctrlKey && e.key === 's') {\n * e.preventDefault();\n * save();\n * }\n * };\n *\n * window.addEventListener('keydown', handleKeyPress);\n *\n * return () => {\n * window.removeEventListener('keydown', handleKeyPress);\n * };\n * });\n *\n * return <div>Press Ctrl+S to save</div>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Third-party library initialization\n * function ChartComponent() {\n * const chartRef = useRef<HTMLDivElement>(null);\n *\n * useMountEffect(() => {\n * if (!chartRef.current) return;\n *\n * const chart = new Chart(chartRef.current, {\n * type: 'bar',\n * data: chartData,\n * });\n *\n * return () => {\n * chart.destroy();\n * };\n * });\n *\n * return <div ref={chartRef} />;\n * }\n * ```\n */\nexport function useMountEffect(effect: () => void | (() => void)): void {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useEffect(effect, []);\n}\n"],"names":["useMountEffect","effect","useEffect"],"mappings":"kCA6GM,SAAUA,EAAeC,GAE7BC,EAAUD,EAAQ,GACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePrevious.js","sources":["../../../../src/react/hooks/usePrevious.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef } from 'react';\n\n/**\n * Tracks the previous value of a variable across renders.\n * Useful for comparing current and previous values, animations, or detecting changes.\n *\n * @template T - The type of the value to track\n * @param {T} value - The current value to track\n * @returns {T | undefined} The previous value (undefined on first render)\n *\n * @example\n * ```tsx\n * function Counter() {\n * const [count, setCount] = useState(0);\n * const previousCount = usePrevious(count);\n *\n * return (\n * <div>\n * <p>Current: {count}</p>\n * <p>Previous: {previousCount ?? 'N/A'}</p>\n * <button onClick={() => setCount(count + 1)}>Increment</button>\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Detecting changes for animations\n * function AnimatedValue({ value }: { value: number }) {\n * const previousValue = usePrevious(value);\n * const isIncreasing = previousValue !== undefined && value > previousValue;\n *\n * return (\n * <div className={isIncreasing ? 'animate-increase' : 'animate-decrease'}>\n * {value}\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Tracking user input changes\n * function SearchInput() {\n * const [query, setQuery] = useState('');\n * const previousQuery = usePrevious(query);\n *\n * useEffect(() => {\n * if (previousQuery !== undefined && query !== previousQuery) {\n * console.log(`Search changed from \"${previousQuery}\" to \"${query}\"`);\n * // Trigger search only on actual changes\n * performSearch(query);\n * }\n * }, [query, previousQuery]);\n *\n * return (\n * <input\n * value={query}\n * onChange={(e) => setQuery(e.target.value)}\n * placeholder=\"Search...\"\n * />\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Comparing object changes\n * interface User {\n * id: string;\n * name: string;\n * }\n *\n * function UserProfile({ user }: { user: User }) {\n * const previousUser = usePrevious(user);\n *\n * useEffect(() => {\n * if (previousUser && previousUser.id !== user.id) {\n * console.log('User changed!');\n * fetchUserData(user.id);\n * }\n * }, [user, previousUser]);\n *\n * return <div>{user.name}</div>;\n * }\n * ```\n */\nexport function usePrevious<T>(value: T): T | undefined {\n const ref = useRef<T | undefined>(undefined);\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n"],"names":["usePrevious","value","ref","useRef","undefined","useEffect","current"],"mappings":"8CA0FM,SAAUA,EAAeC,GAC7B,MAAMC,EAAMC,OAAsBC,GAMlC,OAJAC,EAAU,KACRH,EAAII,QAAUL,GACb,CAACA,IAEGC,EAAII,OACb"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{useState as i,useEffect as e}from"react";function n(n=768){const[t,d]=i({width:void 0,height:void 0});return e(()=>{if("undefined"!=typeof window)return window.addEventListener("resize",i),i(),()=>window.removeEventListener("resize",i);function i(){d({width:window.innerWidth,height:window.innerHeight})}},[]),(t.width??0)<=n}export{n as useScreenSize};
|
|
3
|
+
//# sourceMappingURL=useScreenSize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useScreenSize.js","sources":["../../../../src/react/hooks/useScreenSize.ts"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useState } from \"react\";\n\ninterface WindowSize {\n width: number | undefined;\n height: number | undefined;\n}\n\n/**\n * React hook to track the current window size and determine\n * if the width is less than or equal to a given threshold (e.g., 768px).\n *\n * Useful for responsive rendering or logic that depends on device width.\n *\n * @param {number} [threshold=768] - Width threshold in pixels.\n * @returns {boolean} `true` if the window width is less than or equal to `threshold`, otherwise `false`.\n *\n * @example\n * ```tsx\n * function ResponsiveComponent() {\n * const isMobile = useScreenSize(768);\n *\n * return (\n * <div>\n * {isMobile ? <MobileMenu /> : <DesktopNavigation />}\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * function Layout() {\n * const isTablet = useScreenSize(1024);\n *\n * return (\n * <div className={isTablet ? 'compact-layout' : 'wide-layout'}>\n * <MainContent />\n * </div>\n * );\n * }\n * ```\n */\nexport function useScreenSize(threshold: number = 768): boolean {\n const [windowSize, setWindowSize] = useState<WindowSize>({\n width: undefined,\n height: undefined,\n });\n\n useEffect(() => {\n // Prevent SSR issues\n if (typeof window === 'undefined') {\n return;\n }\n\n function handleResize() {\n setWindowSize({\n width: window.innerWidth,\n height: window.innerHeight,\n });\n }\n\n window.addEventListener(\"resize\", handleResize);\n handleResize(); // set initial size\n\n return () => window.removeEventListener(\"resize\", handleResize);\n }, []);\n\n return (windowSize.width ?? 0) <= threshold;\n}\n"],"names":["useScreenSize","threshold","windowSize","setWindowSize","useState","width","undefined","height","useEffect","window","addEventListener","handleResize","removeEventListener","innerWidth","innerHeight"],"mappings":"gDA4CM,SAAUA,EAAcC,EAAoB,KAChD,MAAOC,EAAYC,GAAiBC,EAAqB,CACvDC,WAAOC,EACPC,YAAQD,IAsBV,OAnBAE,EAAU,KAER,GAAsB,oBAAXC,OAcX,OAHAA,OAAOC,iBAAiB,SAAUC,GAClCA,IAEO,IAAMF,OAAOG,oBAAoB,SAAUD,GAVlD,SAASA,IACPR,EAAc,CACZE,MAAOI,OAAOI,WACdN,OAAQE,OAAOK,aAEnB,GAMC,KAEKZ,EAAWG,OAAS,IAAMJ,CACpC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useState as e,useCallback as n}from"react";function r(r,t){const[o,s]=e(()=>{if("undefined"==typeof window)return t;try{const e=window.sessionStorage.getItem(r);return e?JSON.parse(e):t}catch(e){return console.warn(`Error reading sessionStorage key "${r}":`,e),t}});return[o,n(e=>{try{s(n=>{const t=e instanceof Function?e(n):e;return"undefined"!=typeof window&&window.sessionStorage.setItem(r,JSON.stringify(t)),t})}catch(e){console.warn(`Error setting sessionStorage key "${r}":`,e)}},[r])]}export{r as useSessionStorage};
|
|
3
|
+
//# sourceMappingURL=useSessionStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSessionStorage.js","sources":["../../../../src/react/hooks/useSessionStorage.ts"],"sourcesContent":["'use client';\n\nimport { useCallback, useEffect, useState } from 'react';\n\n/**\n * Manages state that persists to sessionStorage with automatic synchronization.\n * Similar to useLocalStorage but data is cleared when the page session ends (tab/window closes).\n * Handles SSR safely and provides type-safe storage operations with JSON serialization.\n *\n * @template T - The type of the stored value\n * @param {string} key - The sessionStorage key to store the value under\n * @param {T} initialValue - The default value if no stored value exists\n * @returns {[T, (value: T | ((prev: T) => T)) => void]} A stateful value and setter function\n *\n * @example\n * function WizardForm() {\n * const [step, setStep] = useSessionStorage('wizard-step', 1);\n * const [formData, setFormData] = useSessionStorage('wizard-data', {});\n *\n * return (\n * <div>\n * <p>Step {step} of 3</p>\n * <button onClick={() => setStep(step + 1)}>Next</button>\n * </div>\n * );\n * }\n *\n * @example\n * interface FilterState {\n * search: string;\n * category: string;\n * sortBy: string;\n * }\n *\n * function ProductList() {\n * const [filters, setFilters] = useSessionStorage<FilterState>(\n * 'product-filters',\n * { search: '', category: 'all', sortBy: 'name' }\n * );\n *\n * return (\n * <div>\n * <input\n * value={filters.search}\n * onChange={(e) => setFilters({ ...filters, search: e.target.value })}\n * placeholder=\"Search products...\"\n * />\n * </div>\n * );\n * }\n */\nexport function useSessionStorage<T>(\n key: string,\n initialValue: T\n): [T, (value: T | ((prev: T) => T)) => void] {\n const [storedValue, setStoredValue] = useState<T>(() => {\n if (typeof window === 'undefined') {\n return initialValue;\n }\n\n try {\n const item = window.sessionStorage.getItem(key);\n return item ? (JSON.parse(item) as T) : initialValue;\n } catch (error) {\n console.warn(`Error reading sessionStorage key \"${key}\":`, error);\n return initialValue;\n }\n });\n\n const setValue = useCallback(\n (value: T | ((prev: T) => T)) => {\n try {\n setStoredValue((prevValue) => {\n const valueToStore = value instanceof Function ? value(prevValue) : value;\n\n if (typeof window !== 'undefined') {\n window.sessionStorage.setItem(key, JSON.stringify(valueToStore));\n // Note: Storage events don't fire for sessionStorage in other tabs\n // since sessionStorage is tab-specific. This event dispatch is removed\n // as it serves no practical purpose for sessionStorage.\n }\n\n return valueToStore;\n });\n } catch (error) {\n console.warn(`Error setting sessionStorage key \"${key}\":`, error);\n }\n },\n [key]\n );\n\n // Note: Storage event listener removed for sessionStorage\n // SessionStorage is tab-specific and doesn't sync across tabs like localStorage\n\n return [storedValue, setValue];\n}\n"],"names":["useSessionStorage","key","initialValue","storedValue","setStoredValue","useState","window","item","sessionStorage","getItem","JSON","parse","error","console","warn","useCallback","value","prevValue","valueToStore","Function","setItem","stringify"],"mappings":"kDAmDM,SAAUA,EACdC,EACAC,GAEA,MAAOC,EAAaC,GAAkBC,EAAY,KAChD,GAAsB,oBAAXC,OACT,OAAOJ,EAGT,IACE,MAAMK,EAAOD,OAAOE,eAAeC,QAAQR,GAC3C,OAAOM,EAAQG,KAAKC,MAAMJ,GAAcL,CAC1C,CAAE,MAAOU,GAEP,OADAC,QAAQC,KAAK,qCAAqCb,MAASW,GACpDV,CACT,IA4BF,MAAO,CAACC,EAzBSY,EACdC,IACC,IACEZ,EAAgBa,IACd,MAAMC,EAAeF,aAAiBG,SAAWH,EAAMC,GAAaD,EASpE,MAPsB,oBAAXV,QACTA,OAAOE,eAAeY,QAAQnB,EAAKS,KAAKW,UAAUH,IAM7CA,GAEX,CAAE,MAAON,GACPC,QAAQC,KAAK,qCAAqCb,MAASW,EAC7D,GAEF,CAACX,IAOL"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useRef as r,useEffect as t,useCallback as e}from"react";function n(n,c){const u=r(0),o=r(null),a=r(n);return t(()=>{a.current=n},[n]),t(()=>()=>{o.current&&clearTimeout(o.current)},[]),e((...r)=>{const t=Date.now(),e=t-u.current;e>=c?(a.current(...r),u.current=t):(o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{a.current(...r),u.current=Date.now()},c-e))},[c])}export{n as useThrottle};
|
|
3
|
+
//# sourceMappingURL=useThrottle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThrottle.js","sources":["../../../../src/react/hooks/useThrottle.ts"],"sourcesContent":["'use client';\n\nimport { useCallback, useEffect, useRef } from 'react';\n\n/**\n * Creates a throttled version of a callback function that only executes at most once per specified delay period.\n * Useful for rate-limiting expensive operations like scroll handlers, resize handlers, or API calls.\n *\n * @template T - The type of arguments passed to the callback\n * @param {(...args: T[]) => void} callback - The function to throttle\n * @param {number} delay - The minimum time between executions in milliseconds\n * @returns {(...args: T[]) => void} A throttled version of the callback\n *\n * @example\n * ```tsx\n * function ScrollTracker() {\n * const [scrollPosition, setScrollPosition] = useState(0);\n *\n * const handleScroll = useThrottle(() => {\n * setScrollPosition(window.scrollY);\n * console.log('Scroll position updated:', window.scrollY);\n * }, 200);\n *\n * useEffect(() => {\n * window.addEventListener('scroll', handleScroll);\n * return () => window.removeEventListener('scroll', handleScroll);\n * }, [handleScroll]);\n *\n * return <div>Current scroll: {scrollPosition}px</div>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Throttling with arguments\n * function ResizeHandler() {\n * const handleResize = useThrottle((width: number, height: number) => {\n * console.log('Window resized to:', width, height);\n * // Expensive layout calculations here\n * }, 500);\n *\n * useEffect(() => {\n * const listener = () => handleResize(window.innerWidth, window.innerHeight);\n * window.addEventListener('resize', listener);\n * return () => window.removeEventListener('resize', listener);\n * }, [handleResize]);\n *\n * return <div>Resize the window</div>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Throttling button clicks\n * function SaveButton() {\n * const handleSave = useThrottle(() => {\n * saveData();\n * console.log('Data saved');\n * }, 1000);\n *\n * return <button onClick={handleSave}>Save (max once per second)</button>;\n * }\n * ```\n */\nexport function useThrottle<T extends unknown[]>(\n callback: (...args: T) => void,\n delay: number\n): (...args: T) => void {\n const lastRan = useRef<number>(0);\n const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const callbackRef = useRef(callback);\n\n // Keep callback ref up to date\n useEffect(() => {\n callbackRef.current = callback;\n }, [callback]);\n\n // Cleanup timeout on unmount\n useEffect(() => {\n return () => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n };\n }, []);\n\n return useCallback(\n (...args: T) => {\n const now = Date.now();\n const timeSinceLastRan = now - lastRan.current;\n\n if (timeSinceLastRan >= delay) {\n callbackRef.current(...args);\n lastRan.current = now;\n } else {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n\n timeoutRef.current = setTimeout(\n () => {\n callbackRef.current(...args);\n lastRan.current = Date.now();\n },\n delay - timeSinceLastRan\n );\n }\n },\n [delay]\n );\n}\n"],"names":["useThrottle","callback","delay","lastRan","useRef","timeoutRef","callbackRef","useEffect","current","clearTimeout","useCallback","args","now","Date","timeSinceLastRan","setTimeout"],"mappings":"+DAgEM,SAAUA,EACdC,EACAC,GAEA,MAAMC,EAAUC,EAAe,GACzBC,EAAaD,EAA6C,MAC1DE,EAAcF,EAAOH,GAgB3B,OAbAM,EAAU,KACRD,EAAYE,QAAUP,GACrB,CAACA,IAGJM,EAAU,IACD,KACDF,EAAWG,SACbC,aAAaJ,EAAWG,UAG3B,IAEIE,EACL,IAAIC,KACF,MAAMC,EAAMC,KAAKD,MACXE,EAAmBF,EAAMT,EAAQK,QAEnCM,GAAoBZ,GACtBI,EAAYE,WAAWG,GACvBR,EAAQK,QAAUI,IAEdP,EAAWG,SACbC,aAAaJ,EAAWG,SAG1BH,EAAWG,QAAUO,WACnB,KACET,EAAYE,WAAWG,GACvBR,EAAQK,QAAUK,KAAKD,OAEzBV,EAAQY,KAId,CAACZ,GAEL"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useToggle.js","sources":["../../../../src/react/hooks/useToggle.ts"],"sourcesContent":["'use client';\n\nimport { useCallback, useState } from 'react';\n\n/**\n * Manages a boolean state with a toggle function for convenient on/off switching.\n * Useful for modals, menus, visibility states, and any binary UI states.\n *\n * @param {boolean} [initialValue=false] - The initial boolean state\n * @returns {[boolean, () => void, (value: boolean) => void]} A tuple containing the current state, toggle function, and setter function\n *\n * @example\n * ```tsx\n * function Modal() {\n * const [isOpen, toggle, setIsOpen] = useToggle(false);\n *\n * return (\n * <div>\n * <button onClick={toggle}>Toggle Modal</button>\n * <button onClick={() => setIsOpen(true)}>Open Modal</button>\n * <button onClick={() => setIsOpen(false)}>Close Modal</button>\n * {isOpen && (\n * <div className=\"modal\">\n * <h2>Modal Content</h2>\n * <button onClick={toggle}>Close</button>\n * </div>\n * )}\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Sidebar menu toggle\n * function Layout() {\n * const [isSidebarOpen, toggleSidebar] = useToggle(true);\n *\n * return (\n * <div>\n * <button onClick={toggleSidebar}>\n * {isSidebarOpen ? 'Hide' : 'Show'} Sidebar\n * </button>\n * <aside className={isSidebarOpen ? 'visible' : 'hidden'}>\n * Sidebar content\n * </aside>\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Dark mode toggle\n * function ThemeToggle() {\n * const [isDark, toggleTheme] = useToggle(false);\n *\n * useEffect(() => {\n * document.body.classList.toggle('dark-mode', isDark);\n * }, [isDark]);\n *\n * return (\n * <button onClick={toggleTheme}>\n * {isDark ? '🌙' : '☀️'} {isDark ? 'Dark' : 'Light'} Mode\n * </button>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Password visibility toggle\n * function PasswordInput() {\n * const [showPassword, toggleShowPassword] = useToggle(false);\n * const [password, setPassword] = useState('');\n *\n * return (\n * <div>\n * <input\n * type={showPassword ? 'text' : 'password'}\n * value={password}\n * onChange={(e) => setPassword(e.target.value)}\n * />\n * <button onClick={toggleShowPassword}>\n * {showPassword ? 'Hide' : 'Show'} Password\n * </button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useToggle(\n initialValue: boolean = false\n): [boolean, () => void, (value: boolean) => void] {\n const [state, setState] = useState<boolean>(initialValue);\n\n const toggle = useCallback(() => {\n setState((prev) => !prev);\n }, []);\n\n return [state, toggle, setState];\n}\n"],"names":["useToggle","initialValue","state","setState","useState","useCallback","prev"],"mappings":"kDA2FM,SAAUA,EACdC,GAAwB,GAExB,MAAOC,EAAOC,GAAYC,EAAkBH,GAM5C,MAAO,CAACC,EAJOG,EAAY,KACzBF,EAAUG,IAAUA,IACnB,IAEoBH,EACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUpdateEffect.js","sources":["../../../../src/react/hooks/useUpdateEffect.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef } from 'react';\n\n/**\n * Runs an effect only on updates (skips the initial mount), similar to componentDidUpdate.\n * Useful when you want to react to prop or state changes but not on the initial render.\n *\n * @param {() => void | (() => void)} effect - The effect function to run on updates. Can return a cleanup function.\n * @param {any[]} deps - Dependency array, same as useEffect\n *\n * @example\n * ```tsx\n * function AutoSaveForm({ formData }: { formData: FormData }) {\n * useUpdateEffect(() => {\n * // Only auto-save when formData changes, not on initial load\n * saveToServer(formData);\n * }, [formData]);\n *\n * return <form>...</form>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Notification on prop change\n * function UserProfile({ userId }: { userId: string }) {\n * const [user, setUser] = useState(null);\n *\n * useEffect(() => {\n * fetchUser(userId).then(setUser);\n * }, [userId]);\n *\n * useUpdateEffect(() => {\n * // Show notification only when userId changes, not on mount\n * toast.info('Loading new user profile...');\n * }, [userId]);\n *\n * return <div>{user?.name}</div>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Scroll to top on page change (but not initial load)\n * function PageContent({ pageId }: { pageId: number }) {\n * useUpdateEffect(() => {\n * window.scrollTo(0, 0);\n * }, [pageId]);\n *\n * return <div>Page {pageId} content</div>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Analytics tracking for filter changes (excluding initial state)\n * function ProductList() {\n * const [filters, setFilters] = useState({ category: 'all', price: 'any' });\n *\n * useUpdateEffect(() => {\n * // Track filter changes but not the initial default filters\n * analytics.track('filters_changed', filters);\n * }, [filters]);\n *\n * return <div>...</div>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Debounced search that doesn't trigger on mount\n * function SearchResults() {\n * const [query, setQuery] = useState('');\n * const debouncedQuery = useDebounce(query, 500);\n *\n * useUpdateEffect(() => {\n * // Only search when user types, not on initial empty query\n * if (debouncedQuery) {\n * performSearch(debouncedQuery);\n * }\n * }, [debouncedQuery]);\n *\n * return (\n * <input\n * value={query}\n * onChange={(e) => setQuery(e.target.value)}\n * placeholder=\"Search...\"\n * />\n * );\n * }\n * ```\n */\nexport function useUpdateEffect(\n effect: () => void | (() => void),\n deps: React.DependencyList\n): void {\n const isFirstMount = useRef(true);\n\n useEffect(() => {\n if (isFirstMount.current) {\n isFirstMount.current = false;\n return;\n }\n\n return effect();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n}\n"],"names":["useUpdateEffect","effect","deps","isFirstMount","useRef","useEffect","current"],"mappings":"8CA6FM,SAAUA,EACdC,EACAC,GAEA,MAAMC,EAAeC,GAAO,GAE5BC,EAAU,KACR,IAAIF,EAAaG,QAKjB,OAAOL,IAJLE,EAAaG,SAAU,GAMxBJ,EACL"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export{useDebounce}from"./hooks/useDebounce.js";export{useThrottle}from"./hooks/useThrottle.js";export{useLocalStorage}from"./hooks/useLocalStorage.js";export{useSessionStorage}from"./hooks/useSessionStorage.js";export{usePrevious}from"./hooks/usePrevious.js";export{useToggle}from"./hooks/useToggle.js";export{useClickOutside}from"./hooks/useClickOutside.js";export{useMediaQuery}from"./hooks/useMediaQuery.js";export{useIntersectionObserver}from"./hooks/useIntersectionObserver.js";export{useMountEffect}from"./hooks/useMountEffect.js";export{useUpdateEffect}from"./hooks/useUpdateEffect.js";export{useScreenSize}from"./hooks/useScreenSize.js";export{useIsMounted}from"./hooks/useIsMounted.js";export{useCopyToClipboard}from"./hooks/useCopyToClipboard.js";export{clsx}from"./utils/clsx.js";export{createContext}from"./utils/createContext.js";export{displayField}from"./utils/displayField.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function t(...t){let e="";for(const f of t){const t=o(f);t&&(e&&(e+=" "),e+=t)}return e}function o(t){let e="";if("string"==typeof t||"number"==typeof t)e+=t;else if("object"==typeof t&&t)if(Array.isArray(t))for(const f of t){const t=o(f);t&&(e&&(e+=" "),e+=t)}else for(const o in t)t[o]&&(e&&(e+=" "),e+=o);return e}export{t as clsx,t as default};
|
|
2
|
+
//# sourceMappingURL=clsx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clsx.js","sources":["../../../../src/react/utils/clsx.ts"],"sourcesContent":["/**\n * Combines class names into a single string.\n *\n * Accepts strings, numbers, arrays, objects, booleans, null, or undefined.\n * - Strings and numbers are included as-is.\n * - Arrays are recursively flattened.\n * - Objects include keys whose values are truthy.\n *\n * This is useful for dynamically constructing class names in React or any JS/TS project.\n *\n * @example\n * clsx('btn', 'btn-primary')\n * // Returns: \"btn btn-primary\"\n *\n * @example\n * clsx('btn', { 'btn-disabled': false, 'btn-active': true })\n * // Returns: \"btn btn-active\"\n *\n * @example\n * clsx(['btn', ['btn-large', { 'btn-disabled': false }]])\n * // Returns: \"btn btn-large\"\n *\n * @param {...ClassValue[]} args - List of class values to combine\n * @returns {string} A single string of class names, separated by spaces\n */\n\nexport type ClassValue =\n | string\n | number\n | boolean\n | undefined\n | null\n | ClassDictionary\n | ClassArray;\nexport type ClassDictionary = Record<string, boolean | undefined | null>;\nexport type ClassArray = ClassValue[];\n\nexport function clsx(...args: ClassValue[]): string {\n let str = \"\";\n\n for (const arg of args) {\n const val = toVal(arg);\n if (val) {\n str && (str += \" \");\n str += val;\n }\n }\n\n return str;\n}\n\n/**\n * Internal helper function that converts a ClassValue to string.\n *\n * @param {ClassValue} mix - Value to convert\n * @returns {string} The string representation of the value\n */\nfunction toVal(mix: ClassValue): string {\n let str = \"\";\n\n if (typeof mix === \"string\" || typeof mix === \"number\") {\n str += mix;\n } else if (typeof mix === \"object\" && mix) {\n if (Array.isArray(mix)) {\n for (const item of mix) {\n const val = toVal(item);\n if (val) {\n str && (str += \" \");\n str += val;\n }\n }\n } else {\n for (const key in mix) {\n if (mix[key]) {\n str && (str += \" \");\n str += key;\n }\n }\n }\n }\n\n return str;\n}\n\nexport default clsx;\n"],"names":["clsx","args","str","arg","val","toVal","mix","Array","isArray","item","key"],"mappings":"AAqCM,SAAUA,KAAQC,GACtB,IAAIC,EAAM,GAEV,IAAK,MAAMC,KAAOF,EAAM,CACtB,MAAMG,EAAMC,EAAMF,GACdC,IACFF,IAAQA,GAAO,KACfA,GAAOE,EAEX,CAEA,OAAOF,CACT,CAQA,SAASG,EAAMC,GACb,IAAIJ,EAAM,GAEV,GAAmB,iBAARI,GAAmC,iBAARA,EACpCJ,GAAOI,OACF,GAAmB,iBAARA,GAAoBA,EACpC,GAAIC,MAAMC,QAAQF,GAChB,IAAK,MAAMG,KAAQH,EAAK,CACtB,MAAMF,EAAMC,EAAMI,GACdL,IACFF,IAAQA,GAAO,KACfA,GAAOE,EAEX,MAEA,IAAK,MAAMM,KAAOJ,EACZA,EAAII,KACNR,IAAQA,GAAO,KACfA,GAAOQ,GAMf,OAAOR,CACT"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{createContext as r,useContext as t}from"react";function e(e){const o=r(void 0);return o.displayName=e,[o.Provider,function(){const r=t(o);if(void 0===r)throw new Error(`use${e} must be used within a ${e}Provider`);return r}]}export{e as createContext};
|
|
3
|
+
//# sourceMappingURL=createContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createContext.js","sources":["../../../../src/react/utils/createContext.ts"],"sourcesContent":["'use client';\n\nimport { createContext as reactCreateContext, useContext } from 'react';\n\n/**\n * Creates a type-safe React context with a custom hook.\n *\n * @example\n * const [ThemeProvider, useTheme] = createContext<{ theme: string }>('Theme');\n *\n * function App() {\n * return (\n * <ThemeProvider value={{ theme: 'dark' }}>\n * <Child />\n * </ThemeProvider>\n * );\n * }\n *\n * function Child() {\n * const { theme } = useTheme(); // Type-safe!\n * return <div>{theme}</div>;\n * }\n *\n * @param displayName - Display name for debugging\n * @returns Tuple of [Provider, useContext hook]\n */\nexport function createContext<T>(\n displayName: string\n): [\n React.Provider<T | undefined>,\n () => T\n] {\n const Context = reactCreateContext<T | undefined>(undefined);\n Context.displayName = displayName;\n\n function useContextHook(): T {\n const context = useContext(Context);\n if (context === undefined) {\n throw new Error(\n `use${displayName} must be used within a ${displayName}Provider`\n );\n }\n return context;\n }\n\n return [Context.Provider, useContextHook];\n}\n"],"names":["createContext","displayName","Context","reactCreateContext","undefined","Provider","context","useContext","Error"],"mappings":"sDA0BM,SAAUA,EACdC,GAKA,MAAMC,EAAUC,OAAkCC,GAalD,OAZAF,EAAQD,YAAcA,EAYf,CAACC,EAAQG,SAVhB,WACE,MAAMC,EAAUC,EAAWL,GAC3B,QAAgBE,IAAZE,EACF,MAAM,IAAIE,MACR,MAAMP,2BAAqCA,aAG/C,OAAOK,CACT,EAGF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"displayField.js","sources":["../../../../src/react/utils/displayField.ts"],"sourcesContent":["import { ReactNode } from \"react\";\n\n/**\n * Returns a display-safe value for UI rendering, substituting a placeholder\n * for empty, null, or undefined fields. Numbers are always shown as-is.\n *\n * @example\n * displayField(42) // 42\n * displayField(null) // '-'\n * displayField(undefined, 'N/A') // 'N/A'\n * displayField('Hello') // 'Hello'\n * displayField('') // '-'\n *\n * @param {string | number | ReactNode | null | undefined} field - The value to display\n * @param {string | number} [placeholder='-'] - Fallback shown when field is empty/null/undefined\n * @returns {string | number | ReactNode} The field value or the placeholder\n */\nexport const displayField = (\n field: string | number | ReactNode | null | undefined,\n placeholder: string | number = \"-\"\n): string | number | ReactNode => {\n if (typeof field === \"number\") {\n return field;\n }\n\n if (!field) {\n return placeholder;\n }\n\n return field;\n};\n"],"names":["displayField","field","placeholder"],"mappings":"AAiBO,MAAMA,EAAe,CAC1BC,EACAC,EAA+B,MAEV,iBAAVD,EACFA,EAGJA,GACIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camelCase.js","sources":["../../../src/string/camelCase.ts"],"sourcesContent":["import { words } from './words.js';\n\n/**\n * Converts a string to camelCase.\n * Handles spaces, hyphens, underscores, and mixed casing.\n *\n * @example\n * camelCase('hello world') // 'helloWorld'\n * camelCase('foo-bar-baz') // 'fooBarBaz'\n * camelCase('FOO_BAR') // 'fooBar'\n * camelCase('some-Mixed_string') // 'someMixedString'\n * camelCase('') // ''\n *\n * @param str - String to convert\n * @returns camelCase string\n */\nexport function camelCase(str: string): string {\n const w = words(str);\n if (w.length === 0) return '';\n\n return w\n .map((word, i) =>\n i === 0 ? word : word.charAt(0).toUpperCase() + word.slice(1)\n )\n .join('');\n}\n"],"names":["camelCase","str","w","words","length","map","word","i","charAt","toUpperCase","slice","join"],"mappings":"mCAgBM,SAAUA,EAAUC,GACxB,MAAMC,EAAIC,EAAMF,GAChB,OAAiB,IAAbC,EAAEE,OAAqB,GAEpBF,EACJG,IAAI,CAACC,EAAMC,IACJ,IAANA,EAAUD,EAAOA,EAAKE,OAAO,GAAGC,cAAgBH,EAAKI,MAAM,IAE5DC,KAAK,GACV"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capitalize.js","sources":["../../../src/string/capitalize.ts"],"sourcesContent":["/**\n * Capitalizes the first letter of a string.\n *\n * @example\n * capitalize('hello') // 'Hello'\n *\n * @param str - String to capitalize\n * @returns Capitalized string\n */\nexport function capitalize(str: string): string {\n if (str.length === 0) return str;\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n"],"names":["capitalize","str","length","charAt","toUpperCase","slice"],"mappings":"AASM,SAAUA,EAAWC,GACzB,OAAmB,IAAfA,EAAIC,OAAqBD,EACtBA,EAAIE,OAAO,GAAGC,cAAgBH,EAAII,MAAM,EACjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deburr.js","sources":["../../../src/string/deburr.ts"],"sourcesContent":["/**\n * Removes diacritical marks (accents) from a string by converting to ASCII equivalents.\n *\n * @example\n * deburr('café') // 'cafe'\n * deburr('Crème brûlée') // 'Creme brulee'\n * deburr('München') // 'Munchen'\n * deburr('hello') // 'hello'\n *\n * @param str - String to deburr\n * @returns ASCII-safe string\n */\nexport function deburr(str: string): string {\n return str\n .normalize('NFD')\n .replace(/[\\u0300-\\u036f]/g, '');\n}\n"],"names":["deburr","str","normalize","replace"],"mappings":"AAYM,SAAUA,EAAOC,GACrB,OAAOA,EACJC,UAAU,OACVC,QAAQ,mBAAoB,GACjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escapeHtml.js","sources":["../../../src/string/escapeHtml.ts"],"sourcesContent":["/**\n * Escapes HTML special characters to prevent XSS attacks.\n * Converts &, <, >, \", ' to their HTML entity equivalents.\n *\n * @example\n * escapeHtml('<script>alert(\"xss\")</script>')\n * // '<script>alert("xss")</script>'\n *\n * @example\n * escapeHtml(\"it's a <b>test</b> & more\")\n * // \"it's a <b>test</b> & more\"\n *\n * @param str - String to escape\n * @returns Escaped string safe for HTML insertion\n */\nexport function escapeHtml(str: string): string {\n if (!str) return '';\n\n const escapeMap: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": ''',\n };\n\n return str.replace(/[&<>\"']/g, (char) => escapeMap[char]);\n}\n"],"names":["escapeHtml","str","escapeMap","replace","char"],"mappings":"AAeM,SAAUA,EAAWC,GACzB,IAAKA,EAAK,MAAO,GAEjB,MAAMC,EAAoC,CACxC,IAAK,QACL,IAAK,OACL,IAAK,OACL,IAAK,SACL,IAAK,SAGP,OAAOD,EAAIE,QAAQ,WAAaC,GAASF,EAAUE,GACrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escapeRegExp.js","sources":["../../../src/string/escapeRegExp.ts"],"sourcesContent":["/**\n * Escapes special regex characters in a string so it can be used in `new RegExp()`.\n *\n * @example\n * escapeRegExp('hello.world') // 'hello\\\\.world'\n * escapeRegExp('$100 (USD)') // '\\\\$100 \\\\(USD\\\\)'\n * new RegExp(escapeRegExp(userInput)) // safe to use\n *\n * @param str - String to escape\n * @returns Escaped string safe for RegExp construction\n */\nexport function escapeRegExp(str: string): string {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n"],"names":["escapeRegExp","str","replace"],"mappings":"AAWM,SAAUA,EAAaC,GAC3B,OAAOA,EAAIC,QAAQ,sBAAuB,OAC5C"}
|