@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.
Files changed (71) hide show
  1. package/dist/context-selector/createContext.d.ts +26 -0
  2. package/dist/context-selector/createContext.js +83 -0
  3. package/dist/context-selector/index.d.ts +4 -0
  4. package/dist/context-selector/index.js +33 -0
  5. package/dist/context-selector/types.d.ts +24 -0
  6. package/dist/context-selector/types.js +15 -0
  7. package/dist/context-selector/useContextSelector.d.ts +29 -0
  8. package/dist/context-selector/useContextSelector.js +92 -0
  9. package/dist/context-selector/useHasParentContext.d.ts +26 -0
  10. package/dist/context-selector/useHasParentContext.js +46 -0
  11. package/dist/directionLocationUtil.d.ts +1 -0
  12. package/dist/getBoundingClientRect/index.js +1 -11
  13. package/dist/hooks/useDomReady/index.js +2 -2
  14. package/dist/hooks/useEventCallback.d.ts +12 -3
  15. package/dist/hooks/useEventCallback.js +14 -5
  16. package/dist/hooks/useIsomorphicLayoutEffect.d.ts +11 -0
  17. package/dist/hooks/useIsomorphicLayoutEffect.js +39 -0
  18. package/dist/hooks/useMemoizedFn.js +1 -1
  19. package/dist/hooks/useSize.js +2 -2
  20. package/dist/hooks/useTouchEmulator.js +3 -3
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.js +3 -1
  23. package/dist/isMini.js +1 -1
  24. package/dist/render.d.ts +2 -2
  25. package/dist/setRef.d.ts +1 -1
  26. package/dist/ssr/canUseDOM.d.ts +4 -0
  27. package/dist/ssr/canUseDOM.js +29 -0
  28. package/dist/ssr/index.d.ts +1 -0
  29. package/dist/ssr/index.js +27 -0
  30. package/dist/themeCreator/cssVarToValue.d.ts +16 -0
  31. package/dist/themeCreator/cssVarToValue.js +32 -4
  32. package/dist/toArray.d.ts +1 -1
  33. package/dist/toArray.js +3 -3
  34. package/dist/transitions.d.ts +1 -1
  35. package/dist/transitions.js +1 -1
  36. package/es/context-selector/createContext.d.ts +26 -0
  37. package/es/context-selector/createContext.js +53 -0
  38. package/es/context-selector/index.d.ts +4 -0
  39. package/es/context-selector/index.js +8 -0
  40. package/es/context-selector/types.d.ts +24 -0
  41. package/es/context-selector/types.js +0 -0
  42. package/es/context-selector/useContextSelector.d.ts +29 -0
  43. package/es/context-selector/useContextSelector.js +59 -0
  44. package/es/context-selector/useHasParentContext.d.ts +26 -0
  45. package/es/context-selector/useHasParentContext.js +13 -0
  46. package/es/directionLocationUtil.d.ts +1 -0
  47. package/es/getBoundingClientRect/index.js +1 -11
  48. package/es/hooks/useDomReady/index.js +1 -1
  49. package/es/hooks/useEventCallback.d.ts +12 -3
  50. package/es/hooks/useEventCallback.js +14 -5
  51. package/es/hooks/useIsomorphicLayoutEffect.d.ts +11 -0
  52. package/es/hooks/useIsomorphicLayoutEffect.js +6 -0
  53. package/es/hooks/useMemoizedFn.js +1 -1
  54. package/es/hooks/useSize.js +1 -1
  55. package/es/hooks/useTouchEmulator.js +3 -3
  56. package/es/index.d.ts +1 -0
  57. package/es/index.js +1 -0
  58. package/es/isMini.js +1 -1
  59. package/es/render.d.ts +2 -2
  60. package/es/setRef.d.ts +1 -1
  61. package/es/ssr/canUseDOM.d.ts +4 -0
  62. package/es/ssr/canUseDOM.js +6 -0
  63. package/es/ssr/index.d.ts +1 -0
  64. package/es/ssr/index.js +4 -0
  65. package/es/themeCreator/cssVarToValue.d.ts +16 -0
  66. package/es/themeCreator/cssVarToValue.js +31 -3
  67. package/es/toArray.d.ts +1 -1
  68. package/es/toArray.js +2 -2
  69. package/es/transitions.d.ts +1 -1
  70. package/es/transitions.js +1 -1
  71. 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 = (_a = defaultLight) == null ? void 0 : _a.cssVars,
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
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import * as React from 'react';
2
2
  interface Option {
3
3
  keepEmpty?: boolean;
4
4
  }
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.props) {
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);
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import * as React from 'react';
2
2
  interface IEasing {
3
3
  easeInOut: string;
4
4
  easeIn: string;
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.2",
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.2"
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": "echo \"Error: run tests from root\" && exit 1"
36
+ "test": "cd ../.. && vitest run --project bui-utils"
36
37
  }
37
38
  }