@bifrostui/utils 2.0.0-alpha.2 → 2.0.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/context-selector/createContext.d.ts +26 -0
- package/dist/context-selector/createContext.js +83 -0
- package/dist/context-selector/index.d.ts +4 -0
- package/dist/context-selector/index.js +33 -0
- package/dist/context-selector/types.d.ts +24 -0
- package/dist/context-selector/types.js +15 -0
- package/dist/context-selector/useContextSelector.d.ts +29 -0
- package/dist/context-selector/useContextSelector.js +92 -0
- package/dist/context-selector/useHasParentContext.d.ts +26 -0
- package/dist/context-selector/useHasParentContext.js +46 -0
- package/dist/directionLocationUtil.d.ts +1 -0
- package/dist/getBoundingClientRect/index.js +1 -11
- package/dist/hooks/useDomReady/index.js +2 -2
- package/dist/hooks/useEventCallback.d.ts +12 -3
- package/dist/hooks/useEventCallback.js +14 -5
- package/dist/hooks/useIsomorphicLayoutEffect.d.ts +11 -0
- package/dist/hooks/useIsomorphicLayoutEffect.js +39 -0
- package/dist/hooks/useMemoizedFn.js +1 -1
- package/dist/hooks/useSize.js +2 -2
- package/dist/hooks/useTouchEmulator.js +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/isMini.js +1 -1
- package/dist/render.d.ts +2 -2
- package/dist/setRef.d.ts +1 -1
- package/dist/ssr/canUseDOM.d.ts +4 -0
- package/dist/ssr/canUseDOM.js +29 -0
- package/dist/ssr/index.d.ts +1 -0
- package/dist/ssr/index.js +27 -0
- package/dist/themeCreator/cssVarToValue.d.ts +16 -0
- package/dist/themeCreator/cssVarToValue.js +32 -4
- package/dist/toArray.d.ts +1 -1
- package/dist/toArray.js +3 -3
- package/dist/transitions.d.ts +1 -1
- package/dist/transitions.js +1 -1
- package/es/context-selector/createContext.d.ts +26 -0
- package/es/context-selector/createContext.js +53 -0
- package/es/context-selector/index.d.ts +4 -0
- package/es/context-selector/index.js +8 -0
- package/es/context-selector/types.d.ts +24 -0
- package/es/context-selector/types.js +0 -0
- package/es/context-selector/useContextSelector.d.ts +29 -0
- package/es/context-selector/useContextSelector.js +59 -0
- package/es/context-selector/useHasParentContext.d.ts +26 -0
- package/es/context-selector/useHasParentContext.js +13 -0
- package/es/directionLocationUtil.d.ts +1 -0
- package/es/getBoundingClientRect/index.js +1 -11
- package/es/hooks/useDomReady/index.js +1 -1
- package/es/hooks/useEventCallback.d.ts +12 -3
- package/es/hooks/useEventCallback.js +14 -5
- package/es/hooks/useIsomorphicLayoutEffect.d.ts +11 -0
- package/es/hooks/useIsomorphicLayoutEffect.js +6 -0
- package/es/hooks/useMemoizedFn.js +1 -1
- package/es/hooks/useSize.js +1 -1
- package/es/hooks/useTouchEmulator.js +3 -3
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/isMini.js +1 -1
- package/es/render.d.ts +2 -2
- package/es/setRef.d.ts +1 -1
- package/es/ssr/canUseDOM.d.ts +4 -0
- package/es/ssr/canUseDOM.js +6 -0
- package/es/ssr/index.d.ts +1 -0
- package/es/ssr/index.js +4 -0
- package/es/themeCreator/cssVarToValue.d.ts +16 -0
- package/es/themeCreator/cssVarToValue.js +31 -3
- package/es/toArray.d.ts +1 -1
- package/es/toArray.js +2 -2
- package/es/transitions.d.ts +1 -1
- package/es/transitions.js +1 -1
- package/package.json +5 -4
|
@@ -1,9 +1,35 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
1
17
|
import { defaultLight } from "@bifrostui/styles/registry";
|
|
18
|
+
let globalDefaultThemeVars;
|
|
19
|
+
const setDefaultThemeVars = (themeVars) => {
|
|
20
|
+
globalDefaultThemeVars = themeVars;
|
|
21
|
+
};
|
|
22
|
+
const getDefaultThemeVars = () => {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
if (!globalDefaultThemeVars) {
|
|
25
|
+
return (_a = defaultLight) == null ? void 0 : _a.cssVars;
|
|
26
|
+
}
|
|
27
|
+
return __spreadValues(__spreadValues({}, (_b = defaultLight) == null ? void 0 : _b.cssVars), globalDefaultThemeVars);
|
|
28
|
+
};
|
|
2
29
|
const cssVarToValue = (options) => {
|
|
3
|
-
var _a;
|
|
4
30
|
const {
|
|
5
31
|
cssVar,
|
|
6
|
-
themeVars = (
|
|
32
|
+
themeVars = getDefaultThemeVars(),
|
|
7
33
|
_visitedKeys = /* @__PURE__ */ new Set()
|
|
8
34
|
} = options || {};
|
|
9
35
|
if (!cssVar)
|
|
@@ -25,5 +51,7 @@ const cssVarToValue = (options) => {
|
|
|
25
51
|
return variableValue;
|
|
26
52
|
};
|
|
27
53
|
export {
|
|
28
|
-
cssVarToValue
|
|
54
|
+
cssVarToValue,
|
|
55
|
+
getDefaultThemeVars,
|
|
56
|
+
setDefaultThemeVars
|
|
29
57
|
};
|
package/es/toArray.d.ts
CHANGED
package/es/toArray.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
import { isFragment } from "react-is";
|
|
3
3
|
function toArray(children, option = {}) {
|
|
4
4
|
let ret = [];
|
|
@@ -8,7 +8,7 @@ function toArray(children, option = {}) {
|
|
|
8
8
|
}
|
|
9
9
|
if (Array.isArray(child)) {
|
|
10
10
|
ret = ret.concat(toArray(child));
|
|
11
|
-
} else if (isFragment(child) && child
|
|
11
|
+
} else if (isFragment(child) && React.isValidElement(child)) {
|
|
12
12
|
ret = ret.concat(toArray(child.props.children, option));
|
|
13
13
|
} else {
|
|
14
14
|
ret.push(child);
|
package/es/transitions.d.ts
CHANGED
package/es/transitions.js
CHANGED
|
@@ -52,7 +52,7 @@ function formatMs(milliseconds) {
|
|
|
52
52
|
function createTransitions(inputTransitions = {}) {
|
|
53
53
|
const mergedEasing = __spreadValues(__spreadValues({}, easing), inputTransitions.easing);
|
|
54
54
|
const mergedDuration = __spreadValues(__spreadValues({}, duration), inputTransitions.duration);
|
|
55
|
-
const create = (props = ["all"], options) => {
|
|
55
|
+
const create = (props = ["all"], options = {}) => {
|
|
56
56
|
const {
|
|
57
57
|
duration: durationOption = mergedDuration.standard,
|
|
58
58
|
easing: easingOption = mergedEasing.easeInOut,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bifrostui/utils",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.20",
|
|
4
4
|
"description": "BUI React utilities for building components.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -17,13 +17,14 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"react-is": "^18.0.0",
|
|
20
|
-
"@bifrostui/styles": "2.0.0-alpha.
|
|
20
|
+
"@bifrostui/styles": "2.0.0-alpha.20"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"@tarojs/runtime": "^3.0.0",
|
|
24
24
|
"@tarojs/taro": "^3.0.0",
|
|
25
25
|
"react": "^17.0.0 || ^18.0.0",
|
|
26
|
-
"react-dom": "^17.0.0 || ^18.0.0"
|
|
26
|
+
"react-dom": "^17.0.0 || ^18.0.0",
|
|
27
|
+
"scheduler": ">=0.27.0"
|
|
27
28
|
},
|
|
28
29
|
"license": "MIT",
|
|
29
30
|
"publishConfig": {
|
|
@@ -32,6 +33,6 @@
|
|
|
32
33
|
},
|
|
33
34
|
"scripts": {
|
|
34
35
|
"build": "node esbuild.config.js",
|
|
35
|
-
"test": "
|
|
36
|
+
"test": "cd ../.. && vitest run --project bui-utils"
|
|
36
37
|
}
|
|
37
38
|
}
|