@snack-uikit/utils 3.4.0 → 3.4.1-preview-d96c83e8.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/dist/cjs/components/ThemeProvider/ThemeProvider.js +28 -0
- package/dist/cjs/components/ThemeProvider/contexts.js +14 -0
- package/dist/cjs/components/ThemeProvider/index.js +33 -0
- package/dist/cjs/components/index.js +25 -0
- package/dist/cjs/hooks/index.js +29 -0
- package/dist/cjs/hooks/useDebounce.js +23 -0
- package/dist/cjs/hooks/useEventHandler.js +21 -0
- package/dist/cjs/hooks/useIsomorphicLayoutEffect.js +10 -0
- package/dist/cjs/hooks/useThemeConfig.js +18 -0
- package/dist/cjs/hooks/useValueControl.js +18 -0
- package/dist/cjs/index.js +28 -0
- package/dist/cjs/types/index.js +5 -0
- package/dist/cjs/utils/componentPropsProcessors.js +30 -0
- package/dist/cjs/utils/index.js +26 -0
- package/dist/cjs/utils/isBrowser.js +10 -0
- package/dist/esm/components/ThemeProvider/ThemeProvider.d.ts +13 -0
- package/dist/esm/components/ThemeProvider/contexts.d.ts +7 -0
- package/dist/esm/components/ThemeProvider/index.js +3 -0
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/hooks/index.js +5 -0
- package/dist/esm/hooks/useDebounce.d.ts +1 -0
- package/dist/esm/hooks/useEventHandler.d.ts +1 -0
- package/dist/esm/hooks/useIsomorphicLayoutEffect.d.ts +2 -0
- package/dist/esm/hooks/useThemeConfig.d.ts +18 -0
- package/dist/esm/hooks/useValueControl.d.ts +7 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/esm/utils/componentPropsProcessors.d.ts +7 -0
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/utils/isBrowser.d.ts +1 -0
- package/package.json +7 -5
- /package/dist/{components → cjs/components}/ThemeProvider/ThemeProvider.d.ts +0 -0
- /package/dist/{components → cjs/components}/ThemeProvider/contexts.d.ts +0 -0
- /package/dist/{components → cjs/components}/ThemeProvider/index.d.ts +0 -0
- /package/dist/{components → cjs/components}/index.d.ts +0 -0
- /package/dist/{hooks → cjs/hooks}/index.d.ts +0 -0
- /package/dist/{hooks → cjs/hooks}/useDebounce.d.ts +0 -0
- /package/dist/{hooks → cjs/hooks}/useEventHandler.d.ts +0 -0
- /package/dist/{hooks → cjs/hooks}/useIsomorphicLayoutEffect.d.ts +0 -0
- /package/dist/{hooks → cjs/hooks}/useThemeConfig.d.ts +0 -0
- /package/dist/{hooks → cjs/hooks}/useValueControl.d.ts +0 -0
- /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/dist/{types → cjs/types}/index.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/componentPropsProcessors.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/index.d.ts +0 -0
- /package/dist/{utils → cjs/utils}/isBrowser.d.ts +0 -0
- /package/dist/{components → esm/components}/ThemeProvider/ThemeProvider.js +0 -0
- /package/dist/{components → esm/components}/ThemeProvider/contexts.js +0 -0
- /package/dist/{components/ThemeProvider/index.js → esm/components/ThemeProvider/index.d.ts} +0 -0
- /package/dist/{components/index.js → esm/components/index.d.ts} +0 -0
- /package/dist/{hooks/index.js → esm/hooks/index.d.ts} +0 -0
- /package/dist/{hooks → esm/hooks}/useDebounce.js +0 -0
- /package/dist/{hooks → esm/hooks}/useEventHandler.js +0 -0
- /package/dist/{hooks → esm/hooks}/useIsomorphicLayoutEffect.js +0 -0
- /package/dist/{hooks → esm/hooks}/useThemeConfig.js +0 -0
- /package/dist/{hooks → esm/hooks}/useValueControl.js +0 -0
- /package/dist/{index.js → esm/index.d.ts} +0 -0
- /package/dist/{types → esm/types}/index.js +0 -0
- /package/dist/{utils → esm/utils}/componentPropsProcessors.js +0 -0
- /package/dist/{utils/index.js → esm/utils/index.d.ts} +0 -0
- /package/dist/{utils → esm/utils}/isBrowser.js +0 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
4
|
+
var t = {};
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", {
|
|
12
|
+
value: true
|
|
13
|
+
});
|
|
14
|
+
exports.ThemeProvider = ThemeProvider;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
const hooks_1 = require("../../hooks");
|
|
17
|
+
const contexts_1 = require("./contexts");
|
|
18
|
+
function ThemeProvider(_a) {
|
|
19
|
+
var {
|
|
20
|
+
children
|
|
21
|
+
} = _a,
|
|
22
|
+
props = __rest(_a, ["children"]);
|
|
23
|
+
const themeConfig = (0, hooks_1.useThemeConfig)(props);
|
|
24
|
+
return (0, jsx_runtime_1.jsx)(contexts_1.ThemeContext.Provider, {
|
|
25
|
+
value: themeConfig,
|
|
26
|
+
children: children
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useThemeContext = exports.ThemeContext = void 0;
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
exports.ThemeContext = (0, react_1.createContext)({
|
|
9
|
+
theme: undefined,
|
|
10
|
+
themeClassName: undefined,
|
|
11
|
+
changeTheme: undefined
|
|
12
|
+
});
|
|
13
|
+
const useThemeContext = () => (0, react_1.useContext)(exports.ThemeContext);
|
|
14
|
+
exports.useThemeContext = useThemeContext;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return m[k];
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
} : function (o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
});
|
|
19
|
+
var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
exports.useThemeContext = void 0;
|
|
26
|
+
const contexts_1 = require("./contexts");
|
|
27
|
+
Object.defineProperty(exports, "useThemeContext", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () {
|
|
30
|
+
return contexts_1.useThemeContext;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
__exportStar(require("./ThemeProvider"), exports);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return m[k];
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
} : function (o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
});
|
|
19
|
+
var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
__exportStar(require("./ThemeProvider"), exports);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return m[k];
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
} : function (o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
});
|
|
19
|
+
var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
__exportStar(require("./useDebounce"), exports);
|
|
26
|
+
__exportStar(require("./useEventHandler"), exports);
|
|
27
|
+
__exportStar(require("./useIsomorphicLayoutEffect"), exports);
|
|
28
|
+
__exportStar(require("./useThemeConfig"), exports);
|
|
29
|
+
__exportStar(require("./useValueControl"), exports);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useDebounce = useDebounce;
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
|
+
const useEventHandler_1 = require("./useEventHandler");
|
|
10
|
+
function useDebounce(callback) {
|
|
11
|
+
let timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
12
|
+
const timeStampRef = (0, react_1.useRef)(0);
|
|
13
|
+
let timerId = -1;
|
|
14
|
+
return (0, useEventHandler_1.useEventHandler)(() => {
|
|
15
|
+
(0, utils_1.isBrowser)() && requestAnimationFrame(timestamp => {
|
|
16
|
+
if (timestamp < timeStampRef.current) {
|
|
17
|
+
clearTimeout(timerId);
|
|
18
|
+
}
|
|
19
|
+
timerId = setTimeout(callback, timeout);
|
|
20
|
+
timeStampRef.current = timestamp + timeout;
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useEventHandler = useEventHandler;
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const useIsomorphicLayoutEffect_1 = require("./useIsomorphicLayoutEffect");
|
|
9
|
+
function useEventHandler(handler) {
|
|
10
|
+
const handlerRef = (0, react_1.useRef)(null);
|
|
11
|
+
(0, useIsomorphicLayoutEffect_1.useLayoutEffect)(() => {
|
|
12
|
+
handlerRef.current = handler;
|
|
13
|
+
});
|
|
14
|
+
return (0, react_1.useCallback)(function () {
|
|
15
|
+
const handler = handlerRef.current;
|
|
16
|
+
if (handler === null) {
|
|
17
|
+
console.warn('The event handler cannot be called during render');
|
|
18
|
+
}
|
|
19
|
+
return handler === null || handler === void 0 ? void 0 : handler(...arguments);
|
|
20
|
+
}, []);
|
|
21
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useLayoutEffect = void 0;
|
|
7
|
+
// eslint-disable-next-line no-restricted-imports
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
10
|
+
exports.useLayoutEffect = (0, utils_1.isBrowser)() ? react_1.useLayoutEffect : react_1.useEffect;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useThemeConfig = useThemeConfig;
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
function hasDefaultTheme(props) {
|
|
9
|
+
return Boolean(props.defaultTheme);
|
|
10
|
+
}
|
|
11
|
+
function useThemeConfig(props) {
|
|
12
|
+
const [theme, setTheme] = (0, react_1.useState)(hasDefaultTheme(props) ? props.defaultTheme : undefined);
|
|
13
|
+
return {
|
|
14
|
+
theme,
|
|
15
|
+
themeClassName: theme ? props.themeMap[theme] : undefined,
|
|
16
|
+
changeTheme: setTheme
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useValueControl = useValueControl;
|
|
7
|
+
const uncontrollable_1 = require("uncontrollable");
|
|
8
|
+
function useValueControl(_ref) {
|
|
9
|
+
let {
|
|
10
|
+
value,
|
|
11
|
+
onChange,
|
|
12
|
+
defaultValue
|
|
13
|
+
} = _ref;
|
|
14
|
+
return (0, uncontrollable_1.useUncontrolledProp)(value, defaultValue, newValue => {
|
|
15
|
+
const newState = typeof newValue === 'function' ? newValue(value) : newValue;
|
|
16
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newState);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return m[k];
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
} : function (o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
});
|
|
19
|
+
var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
__exportStar(require("./hooks"), exports);
|
|
26
|
+
__exportStar(require("./utils"), exports);
|
|
27
|
+
__exportStar(require("./components"), exports);
|
|
28
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.excludeSupportProps = excludeSupportProps;
|
|
7
|
+
exports.extractDataTestProps = extractDataTestProps;
|
|
8
|
+
exports.extractSupportProps = extractSupportProps;
|
|
9
|
+
const DATA_TEST_REGEXP = /^data-test-/;
|
|
10
|
+
const DATA_AND_ARIA_REGEXP = /^(data|aria)-/;
|
|
11
|
+
function excludeProps(props, regexp) {
|
|
12
|
+
return Object.keys(props).filter(prop => !prop.match(regexp)).reduce((nextProps, prop) => Object.assign(Object.assign({}, nextProps), {
|
|
13
|
+
[prop]: props[prop]
|
|
14
|
+
}), {});
|
|
15
|
+
}
|
|
16
|
+
function extractProps(props, regex) {
|
|
17
|
+
return Object.keys(props).reduce((nextProps, prop) => {
|
|
18
|
+
if (prop.match(regex)) nextProps[prop] = props[prop];
|
|
19
|
+
return nextProps;
|
|
20
|
+
}, {});
|
|
21
|
+
}
|
|
22
|
+
function excludeSupportProps(props) {
|
|
23
|
+
return excludeProps(props, DATA_AND_ARIA_REGEXP);
|
|
24
|
+
}
|
|
25
|
+
function extractDataTestProps(props) {
|
|
26
|
+
return extractProps(props, DATA_TEST_REGEXP);
|
|
27
|
+
}
|
|
28
|
+
function extractSupportProps(props) {
|
|
29
|
+
return extractProps(props, DATA_AND_ARIA_REGEXP);
|
|
30
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return m[k];
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
} : function (o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
});
|
|
19
|
+
var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
__exportStar(require("./componentPropsProcessors"), exports);
|
|
26
|
+
__exportStar(require("./isBrowser"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isBrowser = isBrowser;
|
|
7
|
+
function isBrowser() {
|
|
8
|
+
// eslint-disable-next-line @cloud-ru/ssr-safe-react/domApi
|
|
9
|
+
return Boolean(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
type UseThemePropsWithDefaultTheme = {
|
|
3
|
+
themeMap: Record<string, string>;
|
|
4
|
+
defaultTheme: string;
|
|
5
|
+
};
|
|
6
|
+
type UseThemeProps = {
|
|
7
|
+
themeMap: Record<string, string>;
|
|
8
|
+
};
|
|
9
|
+
export type ThemeProviderProps = {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
} & (UseThemePropsWithDefaultTheme | UseThemeProps);
|
|
12
|
+
export declare function ThemeProvider({ children, ...props }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type ThemeContextType = {
|
|
2
|
+
theme: string | undefined;
|
|
3
|
+
themeClassName: string | undefined;
|
|
4
|
+
changeTheme: ((theme: string) => void) | undefined;
|
|
5
|
+
};
|
|
6
|
+
export declare const ThemeContext: import("react").Context<ThemeContextType>;
|
|
7
|
+
export declare const useThemeContext: () => ThemeContextType;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ThemeProvider';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useDebounce(callback: () => void, timeout?: number): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useEventHandler<T extends (...args: never[]) => unknown>(handler: T): T;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type UseThemePropsWithDefaultTheme<T extends string> = {
|
|
2
|
+
themeMap: Record<T, string>;
|
|
3
|
+
defaultTheme: T;
|
|
4
|
+
};
|
|
5
|
+
type UseThemeProps<T extends string> = {
|
|
6
|
+
themeMap: Record<T, string>;
|
|
7
|
+
};
|
|
8
|
+
export declare function useThemeConfig<T extends string>(props: UseThemeProps<T>): {
|
|
9
|
+
theme: T | undefined;
|
|
10
|
+
themeClassName: string | undefined;
|
|
11
|
+
changeTheme(theme: T): void;
|
|
12
|
+
};
|
|
13
|
+
export declare function useThemeConfig<T extends string>(props: UseThemePropsWithDefaultTheme<T>): {
|
|
14
|
+
theme: T;
|
|
15
|
+
themeClassName: string;
|
|
16
|
+
changeTheme(theme: T): void;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type UseValueControl<TValue> = {
|
|
2
|
+
value?: TValue;
|
|
3
|
+
onChange?(value: TValue): void;
|
|
4
|
+
defaultValue?: TValue;
|
|
5
|
+
};
|
|
6
|
+
export declare function useValueControl<TValue>({ value, onChange, defaultValue }: UseValueControl<TValue>): readonly [TValue | undefined, (value: any, ...args: any[]) => ReturnType<import("uncontrollable").Handler> | void];
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ValueOf<T> = T[keyof T];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AriaAttributes } from 'react';
|
|
2
|
+
export type WithSupportProps<T> = {
|
|
3
|
+
'data-test-id'?: string;
|
|
4
|
+
} & AriaAttributes & T;
|
|
5
|
+
export declare function excludeSupportProps<T extends Record<string, unknown>>(props: T): {};
|
|
6
|
+
export declare function extractDataTestProps<T extends Record<string, unknown>>(props: T): Record<string, unknown>;
|
|
7
|
+
export declare function extractSupportProps<T extends Record<string, unknown>>(props: T): Record<string, unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isBrowser(): boolean;
|
package/package.json
CHANGED
|
@@ -4,15 +4,16 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Utils",
|
|
7
|
-
"version": "3.4.0",
|
|
7
|
+
"version": "3.4.1-preview-d96c83e8.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
11
11
|
"*.woff2"
|
|
12
12
|
],
|
|
13
13
|
"description": "Пакет с вспомогательными функциями",
|
|
14
|
-
"
|
|
15
|
-
"
|
|
14
|
+
"types": "./dist/esm/index.d.ts",
|
|
15
|
+
"main": "./dist/cjs/index.js",
|
|
16
|
+
"module": "./dist/esm/index.js",
|
|
16
17
|
"homepage": "https://github.com/cloud-ru-tech/snack-uikit/tree/master/packages/utils",
|
|
17
18
|
"repository": {
|
|
18
19
|
"type": "git",
|
|
@@ -24,7 +25,8 @@
|
|
|
24
25
|
"Anna Kozlova <apkozlova@cloud.ru>"
|
|
25
26
|
],
|
|
26
27
|
"files": [
|
|
27
|
-
"dist",
|
|
28
|
+
"dist/cjs",
|
|
29
|
+
"dist/esm",
|
|
28
30
|
"src",
|
|
29
31
|
"./CHANGELOG.md",
|
|
30
32
|
"./LICENSE"
|
|
@@ -34,5 +36,5 @@
|
|
|
34
36
|
"dependencies": {
|
|
35
37
|
"uncontrollable": "8.0.4"
|
|
36
38
|
},
|
|
37
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "7ad2685e79ccef7528ade40fe4e2a5d4e609a22f"
|
|
38
40
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|