@koine/utils 2.0.0-beta.72 → 2.0.0-beta.74
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/Defer.d.ts +1 -0
- package/Defer.js +11 -0
- package/Emitter.d.ts +1 -0
- package/Emitter.js +20 -0
- package/accentSets.d.ts +1 -0
- package/accentSets.js +30 -0
- package/addOrReplaceAtIdx.d.ts +1 -0
- package/addOrReplaceAtIdx.js +15 -0
- package/areEqual.d.ts +1 -1
- package/areEqual.js +46 -0
- package/arrayFilterFalsy.d.ts +1 -0
- package/arrayFilterFalsy.js +2 -0
- package/arrayFindLastIndex.d.ts +1 -0
- package/arrayFindLastIndex.js +9 -0
- package/arrayOfAll.d.ts +1 -0
- package/arrayOfAll.js +2 -0
- package/arraySum.d.ts +1 -0
- package/arraySum.js +2 -0
- package/arrayToLookup.d.ts +1 -0
- package/arrayToLookup.js +5 -0
- package/arrayUniqueByProperties.d.ts +1 -0
- package/arrayUniqueByProperties.js +2 -0
- package/buildUrlQueryString.d.ts +1 -0
- package/buildUrlQueryString.js +21 -0
- package/capitalize.d.ts +1 -0
- package/capitalize.js +3 -0
- package/changeCaseCamel.d.ts +1 -0
- package/changeCaseCamel.js +19 -0
- package/changeCaseCapital.d.ts +1 -0
- package/changeCaseCapital.js +12 -0
- package/changeCaseConstant.d.ts +1 -0
- package/changeCaseConstant.js +8 -0
- package/changeCaseDot.d.ts +1 -0
- package/changeCaseDot.js +3 -0
- package/changeCaseHelpers.d.ts +0 -5
- package/changeCaseHelpers.js +71 -0
- package/changeCaseKebab.d.ts +1 -0
- package/changeCaseKebab.js +3 -0
- package/changeCaseNone.d.ts +1 -0
- package/changeCaseNone.js +8 -0
- package/changeCasePascal.d.ts +1 -0
- package/changeCasePascal.js +11 -0
- package/changeCasePascalSnake.d.ts +1 -0
- package/changeCasePascalSnake.js +3 -0
- package/changeCasePath.d.ts +1 -0
- package/changeCasePath.js +3 -0
- package/changeCaseSentence.d.ts +1 -0
- package/changeCaseSentence.js +17 -0
- package/changeCaseSnake.d.ts +1 -0
- package/changeCaseSnake.js +3 -0
- package/changeCaseTrain.d.ts +1 -0
- package/changeCaseTrain.js +3 -0
- package/chunkByChunks.d.ts +1 -0
- package/chunkByChunks.js +32 -0
- package/chunkBySize.d.ts +1 -0
- package/chunkBySize.js +8 -0
- package/clamp.d.ts +1 -0
- package/clamp.js +2 -0
- package/clsx.d.ts +1 -1
- package/clsx.js +40 -0
- package/convertRange.d.ts +1 -0
- package/convertRange.js +2 -0
- package/cookie.d.ts +0 -3
- package/cookie.js +1 -0
- package/createPalette.d.ts +1 -1
- package/createPalette.js +12 -0
- package/debounce.d.ts +1 -0
- package/debounce.js +18 -0
- package/debouncePromise.d.ts +1 -0
- package/debouncePromise.js +52 -0
- package/debounceRaf.d.ts +1 -0
- package/debounceRaf.js +13 -0
- package/decode.d.ts +1 -0
- package/decode.js +2 -0
- package/encode.d.ts +1 -0
- package/encode.js +2 -0
- package/ensureInt.d.ts +1 -0
- package/ensureInt.js +2 -0
- package/env.js +1 -0
- package/errorToString.d.ts +1 -0
- package/errorToString.js +3 -0
- package/escapeRegExp.d.ts +1 -0
- package/escapeRegExp.js +2 -0
- package/findDuplicatedIndexes.d.ts +1 -0
- package/findDuplicatedIndexes.js +11 -0
- package/forin.d.ts +1 -0
- package/forin.js +6 -0
- package/gbToBytes.d.ts +1 -0
- package/gbToBytes.js +2 -0
- package/getEmptyArray.d.ts +1 -0
- package/getEmptyArray.js +5 -0
- package/getKeys.d.ts +1 -0
- package/getKeys.js +2 -0
- package/getMediaQueryWidthResolvers.d.ts +1 -0
- package/getMediaQueryWidthResolvers.js +42 -0
- package/getMediaQueryWidthTailwindScreens.d.ts +1 -0
- package/getMediaQueryWidthTailwindScreens.js +27 -0
- package/getNonce.d.ts +1 -0
- package/getNonce.js +3 -0
- package/getParamAmong.d.ts +1 -0
- package/getParamAmong.js +6 -0
- package/getParamAsInt.d.ts +1 -0
- package/getParamAsInt.js +9 -0
- package/getParamAsString.d.ts +1 -0
- package/getParamAsString.js +3 -0
- package/getType.d.ts +1 -0
- package/getType.js +2 -0
- package/getUrlHashParams.d.ts +1 -0
- package/getUrlHashParams.js +9 -0
- package/getUrlHashPathname.d.ts +1 -0
- package/getUrlHashPathname.js +2 -0
- package/getUrlPathnameParts.d.ts +1 -0
- package/getUrlPathnameParts.js +6 -0
- package/getUrlQueryParams.d.ts +1 -0
- package/getUrlQueryParams.js +22 -0
- package/imgEmptyPixel.d.ts +1 -0
- package/imgEmptyPixel.js +2 -0
- package/index.cjs.js +69 -69
- package/index.d.ts +1 -1
- package/index.esm.js +69 -69
- package/index.js +156 -0
- package/invariant.d.ts +1 -0
- package/invariant.js +17 -0
- package/isAbsoluteUrl.d.ts +1 -0
- package/isAbsoluteUrl.js +3 -0
- package/isAnyObject.d.ts +1 -0
- package/isAnyObject.js +3 -0
- package/isArray.d.ts +1 -0
- package/isArray.js +3 -0
- package/isBlob.d.ts +1 -0
- package/isBlob.js +3 -0
- package/isBoolean.d.ts +1 -0
- package/isBoolean.js +3 -0
- package/isBrowser.d.ts +1 -0
- package/isBrowser.js +2 -0
- package/isBrowserNow.d.ts +1 -0
- package/isBrowserNow.js +3 -0
- package/isDate.d.ts +1 -0
- package/isDate.js +3 -0
- package/isEmptyArray.d.ts +1 -0
- package/isEmptyArray.js +3 -0
- package/isEmptyObject.d.ts +1 -0
- package/isEmptyObject.js +3 -0
- package/isEmptyString.d.ts +1 -0
- package/isEmptyString.js +2 -0
- package/isError.d.ts +1 -0
- package/isError.js +3 -0
- package/isExternalUrl.d.ts +1 -0
- package/isExternalUrl.js +11 -0
- package/isFile.d.ts +1 -0
- package/isFile.js +3 -0
- package/isFloat.d.ts +1 -0
- package/isFloat.js +3 -0
- package/isFormData.d.ts +1 -0
- package/isFormData.js +3 -0
- package/isFullArray.d.ts +1 -0
- package/isFullArray.js +3 -0
- package/isFullObject.d.ts +1 -0
- package/isFullObject.js +3 -0
- package/isFullString.d.ts +1 -0
- package/isFullString.js +3 -0
- package/isFunction.d.ts +1 -0
- package/isFunction.js +2 -0
- package/isInt.d.ts +1 -0
- package/isInt.js +3 -0
- package/isMap.d.ts +1 -0
- package/isMap.js +3 -0
- package/isNaNValue.d.ts +1 -0
- package/isNaNValue.js +3 -0
- package/isNegativeNumber.d.ts +1 -0
- package/isNegativeNumber.js +3 -0
- package/isNull.d.ts +1 -0
- package/isNull.js +3 -0
- package/isNullOrUndefined.d.ts +1 -0
- package/isNullOrUndefined.js +5 -0
- package/isNumber.d.ts +1 -0
- package/isNumber.js +3 -0
- package/isNumericLiteral.d.ts +1 -0
- package/isNumericLiteral.js +2 -0
- package/isObject.d.ts +1 -0
- package/isObject.js +3 -0
- package/isObjectLike.d.ts +1 -0
- package/isObjectLike.js +3 -0
- package/isObjectStringKeyed.d.ts +1 -0
- package/isObjectStringKeyed.js +3 -0
- package/isOneOf.d.ts +1 -0
- package/isOneOf.js +8 -0
- package/isPlainObject.d.ts +1 -0
- package/isPlainObject.js +6 -0
- package/isPositiveNumber.d.ts +1 -0
- package/isPositiveNumber.js +3 -0
- package/isPrimitive.d.ts +1 -0
- package/isPrimitive.js +13 -0
- package/isPromise.d.ts +1 -0
- package/isPromise.js +3 -0
- package/isRegExp.d.ts +1 -0
- package/isRegExp.js +3 -0
- package/isServer.d.ts +1 -0
- package/isServer.js +3 -0
- package/isServerNow.d.ts +1 -0
- package/isServerNow.js +3 -0
- package/isSet.d.ts +1 -0
- package/isSet.js +3 -0
- package/isString.d.ts +1 -0
- package/isString.js +3 -0
- package/isSymbol.d.ts +1 -0
- package/isSymbol.js +3 -0
- package/isType.d.ts +1 -0
- package/isType.js +13 -0
- package/isUndefined.d.ts +1 -0
- package/isUndefined.js +3 -0
- package/isWeakMap.d.ts +1 -0
- package/isWeakMap.js +3 -0
- package/isWeakSet.d.ts +1 -0
- package/isWeakSet.js +3 -0
- package/kbToBytes.d.ts +1 -0
- package/kbToBytes.js +2 -0
- package/location.js +1 -0
- package/lowercase.d.ts +1 -0
- package/lowercase.js +2 -0
- package/mapListBy.d.ts +1 -0
- package/mapListBy.js +5 -0
- package/matchSorter.d.ts +1 -0
- package/matchSorter.js +239 -0
- package/mbToBytes.d.ts +1 -0
- package/mbToBytes.js +2 -0
- package/mergeObjects.d.ts +1 -0
- package/mergeObjects.js +29 -0
- package/mergeUrlQueryParams.d.ts +1 -0
- package/mergeUrlQueryParams.js +14 -0
- package/moveSortableArrayItemByKey.d.ts +1 -0
- package/moveSortableArrayItemByKey.js +9 -0
- package/noop.d.ts +1 -0
- package/noop.js +2 -0
- package/normaliseUrl.d.ts +1 -0
- package/normaliseUrl.js +3 -0
- package/normaliseUrlPathname.d.ts +1 -0
- package/normaliseUrlPathname.js +3 -0
- package/objectFlat.d.ts +1 -0
- package/objectFlat.js +17 -0
- package/objectFlip.d.ts +1 -0
- package/objectFlip.js +5 -0
- package/objectMergeWithDefaults.d.ts +1 -0
- package/objectMergeWithDefaults.js +21 -0
- package/objectOmit.d.ts +1 -0
- package/objectOmit.js +8 -0
- package/objectPick.d.ts +1 -0
- package/objectPick.js +9 -0
- package/objectSort.d.ts +1 -0
- package/objectSort.js +2 -0
- package/objectSortByKeysMatching.d.ts +1 -0
- package/objectSortByKeysMatching.js +3 -0
- package/objectToArray.d.ts +1 -0
- package/objectToArray.js +2 -0
- package/package.json +1 -1
- package/parseCookie.d.ts +1 -0
- package/parseCookie.js +33 -0
- package/parseURL.d.ts +1 -0
- package/parseURL.js +14 -0
- package/quaranteneProps.d.ts +1 -1
- package/quaranteneProps.js +16 -0
- package/randomInt.d.ts +1 -0
- package/randomInt.js +2 -0
- package/randomKey.d.ts +1 -0
- package/randomKey.js +5 -0
- package/readCookie.d.ts +1 -0
- package/readCookie.js +34 -0
- package/removeAccents.d.ts +1 -0
- package/removeAccents.js +10 -0
- package/removeCookie.d.ts +1 -0
- package/removeCookie.js +10 -0
- package/removeDuplicates.d.ts +2 -0
- package/removeDuplicates.js +2 -0
- package/removeDuplicatesByKey.d.ts +1 -0
- package/removeDuplicatesByKey.js +13 -0
- package/removeDuplicatesComparing.d.ts +1 -0
- package/removeDuplicatesComparing.js +7 -0
- package/removeIndexesFromArray.d.ts +1 -0
- package/removeIndexesFromArray.js +10 -0
- package/removeTrailingSlash.d.ts +2 -1
- package/removeTrailingSlash.js +2 -0
- package/removeUrlQueryParams.d.ts +1 -0
- package/removeUrlQueryParams.js +14 -0
- package/render.d.ts +1 -1
- package/render.js +113 -0
- package/round.d.ts +1 -0
- package/round.js +4 -0
- package/roundTo.d.ts +1 -0
- package/roundTo.js +11 -0
- package/serializeCookie.d.ts +1 -0
- package/serializeCookie.js +69 -0
- package/setCookie.d.ts +1 -0
- package/setCookie.js +45 -0
- package/shuffle.d.ts +1 -0
- package/shuffle.js +17 -0
- package/slugify.d.ts +1 -0
- package/slugify.js +11 -0
- package/split.d.ts +1 -0
- package/split.js +2 -0
- package/splitReverse.d.ts +1 -0
- package/splitReverse.js +2 -0
- package/swapMap.d.ts +1 -0
- package/swapMap.js +8 -0
- package/throttle.d.ts +1 -0
- package/throttle.js +15 -0
- package/titleCase.d.ts +1 -0
- package/titleCase.js +4 -0
- package/toNumber.d.ts +1 -0
- package/toNumber.js +3 -0
- package/toRgba.d.ts +1 -0
- package/toRgba.js +8 -0
- package/transformToUrlPathname.d.ts +1 -0
- package/transformToUrlPathname.js +5 -0
- package/truncate.d.ts +1 -0
- package/truncate.js +6 -0
- package/tryUntil.d.ts +1 -0
- package/tryUntil.js +15 -0
- package/types.js +1 -0
- package/uid.d.ts +1 -0
- package/uid.js +6 -0
- package/updateLinkParams.d.ts +1 -0
- package/updateLinkParams.js +7 -0
- package/updateUrlQueryParams.d.ts +1 -0
- package/updateUrlQueryParams.js +11 -0
- package/uppercase.d.ts +1 -0
- package/uppercase.js +2 -0
- package/uuid.d.ts +1 -0
- package/uuid.js +5 -0
- package/uuidNumeric.d.ts +1 -0
- package/uuidNumeric.js +2 -0
- package/wait.d.ts +1 -0
- package/wait.js +2 -0
- package/without.js +1 -0
package/cookie.d.ts
CHANGED
package/cookie.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export let defaultAttributesClient = { path: "/" };
|
package/createPalette.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ type PaletteMap<T extends PaletteShades> = {
|
|
|
7
7
|
[PS in T[number] as keyof PaletteMapPair<PS>]: PaletteMapPair<PS>[keyof PaletteMapPair<PS>];
|
|
8
8
|
};
|
|
9
9
|
export declare let createPalette: <TName extends string, TShades extends PaletteShades, TColor = TShades[number][1], TMap = PaletteMap<TShades>>(name: TName, shades: TShades) => readonly [TMap, Record<`${TName}-${TShades[number][0]}`, string>, TColor[]];
|
|
10
|
-
export
|
|
10
|
+
export default createPalette;
|
package/createPalette.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export let createPalette = (name, shades) => {
|
|
2
|
+
const map = shades.reduce((map, def) => {
|
|
3
|
+
map[def[0]] = def[1];
|
|
4
|
+
return map;
|
|
5
|
+
}, {});
|
|
6
|
+
const tailwindPalette = shades.reduce((map, def) => {
|
|
7
|
+
map[`${name}-${def[0]}`] = def[1];
|
|
8
|
+
return map;
|
|
9
|
+
}, {});
|
|
10
|
+
return [map, tailwindPalette, Object.values(map)];
|
|
11
|
+
};
|
|
12
|
+
export default createPalette;
|
package/debounce.d.ts
CHANGED
package/debounce.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export let debounce = (fn, wait, immediate) => {
|
|
2
|
+
let timeout;
|
|
3
|
+
return function (...args) {
|
|
4
|
+
const context = this;
|
|
5
|
+
const later = function () {
|
|
6
|
+
timeout = null;
|
|
7
|
+
if (!immediate)
|
|
8
|
+
fn.apply(context, args);
|
|
9
|
+
};
|
|
10
|
+
const callNow = immediate && !timeout;
|
|
11
|
+
if (timeout)
|
|
12
|
+
clearTimeout(timeout);
|
|
13
|
+
timeout = setTimeout(later, wait);
|
|
14
|
+
if (callNow)
|
|
15
|
+
fn.apply(context, args);
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export default debounce;
|
package/debouncePromise.d.ts
CHANGED
|
@@ -8,3 +8,4 @@ export interface DebouncedFunction<Args extends any[], F extends (...args: Args)
|
|
|
8
8
|
cancel: (reason?: any) => void;
|
|
9
9
|
}
|
|
10
10
|
export declare let debouncePromise: <Args extends any[], F extends (...args: Args) => any>(func: F, waitMilliseconds?: number, options?: DebounceOptions<ReturnType<F>>) => DebouncedFunction<Args, F>;
|
|
11
|
+
export default debouncePromise;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export let debouncePromise = (func, waitMilliseconds = 50, options = {}) => {
|
|
2
|
+
let timeoutId;
|
|
3
|
+
const isImmediate = options.isImmediate ?? false;
|
|
4
|
+
const callback = options.callback ?? false;
|
|
5
|
+
const maxWait = options.maxWait;
|
|
6
|
+
let lastInvokeTime = Date.now();
|
|
7
|
+
let promises = [];
|
|
8
|
+
function nextInvokeTimeout() {
|
|
9
|
+
if (maxWait !== undefined) {
|
|
10
|
+
const timeSinceLastInvocation = Date.now() - lastInvokeTime;
|
|
11
|
+
if (timeSinceLastInvocation + waitMilliseconds >= maxWait) {
|
|
12
|
+
return maxWait - timeSinceLastInvocation;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return waitMilliseconds;
|
|
16
|
+
}
|
|
17
|
+
const debouncedFunction = function (...args) {
|
|
18
|
+
const context = this;
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
const invokeFunction = function () {
|
|
21
|
+
timeoutId = undefined;
|
|
22
|
+
lastInvokeTime = Date.now();
|
|
23
|
+
if (!isImmediate) {
|
|
24
|
+
const result = func.apply(context, args);
|
|
25
|
+
callback && callback(result);
|
|
26
|
+
promises.forEach(({ resolve }) => resolve(result));
|
|
27
|
+
promises = [];
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const shouldCallNow = isImmediate && timeoutId === undefined;
|
|
31
|
+
if (timeoutId !== undefined) {
|
|
32
|
+
clearTimeout(timeoutId);
|
|
33
|
+
}
|
|
34
|
+
timeoutId = setTimeout(invokeFunction, nextInvokeTimeout());
|
|
35
|
+
if (shouldCallNow) {
|
|
36
|
+
const result = func.apply(context, args);
|
|
37
|
+
callback && callback(result);
|
|
38
|
+
return resolve(result);
|
|
39
|
+
}
|
|
40
|
+
promises.push({ resolve, reject });
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
debouncedFunction.cancel = function (reason) {
|
|
44
|
+
if (timeoutId !== undefined) {
|
|
45
|
+
clearTimeout(timeoutId);
|
|
46
|
+
}
|
|
47
|
+
promises.forEach(({ reject }) => reject(reason));
|
|
48
|
+
promises = [];
|
|
49
|
+
};
|
|
50
|
+
return debouncedFunction;
|
|
51
|
+
};
|
|
52
|
+
export default debouncePromise;
|
package/debounceRaf.d.ts
CHANGED
package/debounceRaf.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function debounceRaf(fn) {
|
|
2
|
+
let timeout;
|
|
3
|
+
return function (...args) {
|
|
4
|
+
const context = this;
|
|
5
|
+
if (timeout) {
|
|
6
|
+
window.cancelAnimationFrame(timeout);
|
|
7
|
+
}
|
|
8
|
+
timeout = window.requestAnimationFrame(function () {
|
|
9
|
+
fn.apply(context, args);
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export default debounceRaf;
|
package/decode.d.ts
CHANGED
package/decode.js
ADDED
package/encode.d.ts
CHANGED
package/encode.js
ADDED
package/ensureInt.d.ts
CHANGED
package/ensureInt.js
ADDED
package/env.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/errorToString.d.ts
CHANGED
package/errorToString.js
ADDED
package/escapeRegExp.d.ts
CHANGED
package/escapeRegExp.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export let findDuplicatedIndexes = (arr) => {
|
|
2
|
+
const indexes = {};
|
|
3
|
+
for (let i = 0; i < arr.length; i++) {
|
|
4
|
+
const idxInArray = arr.indexOf(arr[i]);
|
|
5
|
+
if (idxInArray !== i && idxInArray !== -1) {
|
|
6
|
+
indexes[i] = true;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return indexes;
|
|
10
|
+
};
|
|
11
|
+
export default findDuplicatedIndexes;
|
package/forin.d.ts
CHANGED
package/forin.js
ADDED
package/gbToBytes.d.ts
CHANGED
package/gbToBytes.js
ADDED
package/getEmptyArray.d.ts
CHANGED
package/getEmptyArray.js
ADDED
package/getKeys.d.ts
CHANGED
package/getKeys.js
ADDED
|
@@ -7,3 +7,4 @@ export declare let getMediaQueryWidthResolvers: <TBreakpointsConfig extends GetM
|
|
|
7
7
|
between: (br1: Extract<keyof TBreakpointsConfig, string>, br2?: Extract<keyof TBreakpointsConfig, string> | undefined) => string;
|
|
8
8
|
only: (br: Extract<keyof TBreakpointsConfig, string>) => string;
|
|
9
9
|
};
|
|
10
|
+
export default getMediaQueryWidthResolvers;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export let getMediaQueryWidthResolvers = (customBreakpoints) => {
|
|
2
|
+
const breakpoints = {
|
|
3
|
+
xs: 0,
|
|
4
|
+
...customBreakpoints,
|
|
5
|
+
};
|
|
6
|
+
const sortedBreakpointsNames = Object.keys(breakpoints).map((key) => {
|
|
7
|
+
const br = key;
|
|
8
|
+
return [br, breakpoints[br]];
|
|
9
|
+
})
|
|
10
|
+
.sort((a, b) => a[1] - b[1])
|
|
11
|
+
.map((item) => item[0]);
|
|
12
|
+
const getNextBreakpoint = (breakpoint) => {
|
|
13
|
+
const index = sortedBreakpointsNames.indexOf(breakpoint);
|
|
14
|
+
return sortedBreakpointsNames[index + 1];
|
|
15
|
+
};
|
|
16
|
+
const min = (br) => `(min-width: ${breakpoints[br]}px)`;
|
|
17
|
+
const max = (br) => `(max-width: ${breakpoints[br] - 0.02}px)`;
|
|
18
|
+
const up = min;
|
|
19
|
+
const down = (br) => {
|
|
20
|
+
const brNext = getNextBreakpoint(br);
|
|
21
|
+
return brNext && `(max-width: ${breakpoints[brNext] - 0.02}px)`;
|
|
22
|
+
};
|
|
23
|
+
const between = (br1, br2) => {
|
|
24
|
+
br2 = br2 || getNextBreakpoint(br1);
|
|
25
|
+
return br2
|
|
26
|
+
? `(min-width: ${breakpoints[br1]}px) and (max-width: ${breakpoints[br2] - 0.02}px)`
|
|
27
|
+
: min(br1);
|
|
28
|
+
};
|
|
29
|
+
const only = (br) => {
|
|
30
|
+
const brNext = getNextBreakpoint(br);
|
|
31
|
+
return brNext ? between(br, brNext) : min(br);
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
max,
|
|
35
|
+
min,
|
|
36
|
+
down,
|
|
37
|
+
up,
|
|
38
|
+
between,
|
|
39
|
+
only,
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export default getMediaQueryWidthResolvers;
|
|
@@ -2,3 +2,4 @@ import { type GetMediaQueryWidthResolversBreakpoints } from "./getMediaQueryWidt
|
|
|
2
2
|
export declare let getMediaQueryWidthTailwindScreens: (breakpoints: GetMediaQueryWidthResolversBreakpoints) => Record<string, {
|
|
3
3
|
raw: string;
|
|
4
4
|
}>;
|
|
5
|
+
export default getMediaQueryWidthTailwindScreens;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getMediaQueryWidthResolvers, } from "./getMediaQueryWidthResolvers";
|
|
2
|
+
export let getMediaQueryWidthTailwindScreens = (breakpoints) => {
|
|
3
|
+
const mqWidthResolvers = getMediaQueryWidthResolvers(breakpoints);
|
|
4
|
+
const screens = Object.keys(breakpoints).reduce((output, br, idx) => {
|
|
5
|
+
const brNext = Object.keys(breakpoints)[idx + 1];
|
|
6
|
+
for (const resolverName in mqWidthResolvers) {
|
|
7
|
+
const resolver = resolverName;
|
|
8
|
+
const resolverFn = mqWidthResolvers[resolver];
|
|
9
|
+
const raw = resolverFn(br);
|
|
10
|
+
if (raw) {
|
|
11
|
+
if (resolverName === "min") {
|
|
12
|
+
output[`@${br}`] = { raw };
|
|
13
|
+
}
|
|
14
|
+
if (resolverName === "between") {
|
|
15
|
+
if (brNext)
|
|
16
|
+
output[`@${resolverName}-${br}_${brNext}`] = { raw };
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
output[`@${resolverName}-${br}`] = { raw };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return output;
|
|
24
|
+
}, {});
|
|
25
|
+
return screens;
|
|
26
|
+
};
|
|
27
|
+
export default getMediaQueryWidthTailwindScreens;
|
package/getNonce.d.ts
CHANGED
package/getNonce.js
ADDED
package/getParamAmong.d.ts
CHANGED
package/getParamAmong.js
ADDED
package/getParamAsInt.d.ts
CHANGED
package/getParamAsInt.js
ADDED
package/getParamAsString.d.ts
CHANGED
package/getType.d.ts
CHANGED
package/getType.js
ADDED
package/getUrlHashParams.d.ts
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export let getUrlHashParams = (hash = "") => {
|
|
2
|
+
hash = hash || location.hash;
|
|
3
|
+
const hashParts = hash.split("?");
|
|
4
|
+
if (hashParts.length >= 1) {
|
|
5
|
+
return Object.fromEntries(new URLSearchParams(hashParts[1]));
|
|
6
|
+
}
|
|
7
|
+
return {};
|
|
8
|
+
};
|
|
9
|
+
export default getUrlHashParams;
|
package/getUrlHashPathname.d.ts
CHANGED
package/getUrlPathnameParts.d.ts
CHANGED
package/getUrlQueryParams.d.ts
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isBrowser } from "./isBrowser";
|
|
2
|
+
export let getUrlQueryParams = (url) => {
|
|
3
|
+
let params = {};
|
|
4
|
+
const search = url
|
|
5
|
+
? url.split("?")?.[1]
|
|
6
|
+
: isBrowser
|
|
7
|
+
? location.search.substring(1)
|
|
8
|
+
: "";
|
|
9
|
+
if (!search) {
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
const paramsAsObj = `{"${search
|
|
14
|
+
.replace(/&/g, '","')
|
|
15
|
+
.replace(/=/g, '":"')}"}`;
|
|
16
|
+
params = JSON.parse(paramsAsObj, (key, value) => key === "" ? value : decodeURIComponent(value));
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
}
|
|
20
|
+
return params;
|
|
21
|
+
};
|
|
22
|
+
export default getUrlQueryParams;
|
package/imgEmptyPixel.d.ts
CHANGED
package/imgEmptyPixel.js
ADDED