@contember/react-utils 1.2.0-beta.3 → 1.2.0-rc.1
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/development/context/createOptionalContextFactory.js +13 -0
- package/dist/development/context/createOptionalContextFactory.js.map +1 -0
- package/dist/development/debug-context/Context.js +3 -3
- package/dist/development/debug-context/Context.js.map +1 -1
- package/dist/development/hooks/useAddClassNameDuringResize.js +3 -0
- package/dist/development/hooks/useAddClassNameDuringResize.js.map +1 -1
- package/dist/development/hooks/useContainerWidth.js +14 -0
- package/dist/development/hooks/useContainerWidth.js.map +1 -0
- package/dist/development/hooks/useDocumentTitle.js +22 -0
- package/dist/development/hooks/useDocumentTitle.js.map +1 -0
- package/dist/development/hooks/useExpectSameValueReference.js +7 -4
- package/dist/development/hooks/useExpectSameValueReference.js.map +1 -1
- package/dist/development/index.js +23 -0
- package/dist/development/index.js.map +1 -1
- package/dist/development/theming/ColorSchemeProvider.js +18 -0
- package/dist/development/theming/ColorSchemeProvider.js.map +1 -0
- package/dist/development/theming/GlobalClassNamePrefixContext.js +6 -0
- package/dist/development/theming/GlobalClassNamePrefixContext.js.map +1 -0
- package/dist/development/theming/contexts.js +12 -0
- package/dist/development/theming/contexts.js.map +1 -0
- package/dist/development/theming/useClassName.js +17 -0
- package/dist/development/theming/useClassName.js.map +1 -0
- package/dist/development/theming/useClassNameFactory.js +20 -0
- package/dist/development/theming/useClassNameFactory.js.map +1 -0
- package/dist/development/theming/useThemedClassName.js +17 -0
- package/dist/development/theming/useThemedClassName.js.map +1 -0
- package/dist/development/theming/useThemedClassNameFactory.js +27 -0
- package/dist/development/theming/useThemedClassNameFactory.js.map +1 -0
- package/dist/production/context/createOptionalContextFactory.js +13 -0
- package/dist/production/context/createOptionalContextFactory.js.map +1 -0
- package/dist/production/debug-context/Context.js +3 -3
- package/dist/production/debug-context/Context.js.map +1 -1
- package/dist/production/hooks/useAddClassNameDuringResize.js +3 -0
- package/dist/production/hooks/useAddClassNameDuringResize.js.map +1 -1
- package/dist/production/hooks/useContainerWidth.js +14 -0
- package/dist/production/hooks/useContainerWidth.js.map +1 -0
- package/dist/production/hooks/useDocumentTitle.js +22 -0
- package/dist/production/hooks/useDocumentTitle.js.map +1 -0
- package/dist/production/hooks/useExpectSameValueReference.js.map +1 -1
- package/dist/production/index.js +23 -0
- package/dist/production/index.js.map +1 -1
- package/dist/production/theming/ColorSchemeProvider.js +14 -0
- package/dist/production/theming/ColorSchemeProvider.js.map +1 -0
- package/dist/production/theming/GlobalClassNamePrefixContext.js +6 -0
- package/dist/production/theming/GlobalClassNamePrefixContext.js.map +1 -0
- package/dist/production/theming/contexts.js +12 -0
- package/dist/production/theming/contexts.js.map +1 -0
- package/dist/production/theming/useClassName.js +17 -0
- package/dist/production/theming/useClassName.js.map +1 -0
- package/dist/production/theming/useClassNameFactory.js +20 -0
- package/dist/production/theming/useClassNameFactory.js.map +1 -0
- package/dist/production/theming/useThemedClassName.js +17 -0
- package/dist/production/theming/useThemedClassName.js.map +1 -0
- package/dist/production/theming/useThemedClassNameFactory.js +27 -0
- package/dist/production/theming/useThemedClassNameFactory.js.map +1 -0
- package/dist/types/context/createOptionalContextFactory.d.ts +3 -0
- package/dist/types/context/createOptionalContextFactory.d.ts.map +1 -0
- package/dist/types/context/index.d.ts +1 -0
- package/dist/types/context/index.d.ts.map +1 -1
- package/dist/types/debug-context/Context.d.ts +2 -2
- package/dist/types/debug-context/Context.d.ts.map +1 -1
- package/dist/types/hooks/index.d.ts +2 -0
- package/dist/types/hooks/index.d.ts.map +1 -1
- package/dist/types/hooks/useAddClassNameDuringResize.d.ts.map +1 -1
- package/dist/types/hooks/useContainerWidth.d.ts +4 -0
- package/dist/types/hooks/useContainerWidth.d.ts.map +1 -0
- package/dist/types/hooks/useDocumentTitle.d.ts +2 -0
- package/dist/types/hooks/useDocumentTitle.d.ts.map +1 -0
- package/dist/types/hooks/useExpectSameValueReference.d.ts +22 -0
- package/dist/types/hooks/useExpectSameValueReference.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/theming/ColorSchemeProvider.d.ts +7 -0
- package/dist/types/theming/ColorSchemeProvider.d.ts.map +1 -0
- package/dist/types/theming/GlobalClassNamePrefixContext.d.ts +2 -0
- package/dist/types/theming/GlobalClassNamePrefixContext.d.ts.map +1 -0
- package/dist/types/theming/contexts.d.ts +12 -0
- package/dist/types/theming/contexts.d.ts.map +1 -0
- package/dist/types/theming/index.d.ts +8 -0
- package/dist/types/theming/index.d.ts.map +1 -0
- package/dist/types/theming/useClassName.d.ts +11 -0
- package/dist/types/theming/useClassName.d.ts.map +1 -0
- package/dist/types/theming/useClassNameFactory.d.ts +17 -0
- package/dist/types/theming/useClassNameFactory.d.ts.map +1 -0
- package/dist/types/theming/useThemedClassName.d.ts +39 -0
- package/dist/types/theming/useThemedClassName.d.ts.map +1 -0
- package/dist/types/theming/useThemedClassNameFactory.d.ts +3 -0
- package/dist/types/theming/useThemedClassNameFactory.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/context/createOptionalContextFactory.ts +13 -0
- package/src/context/index.ts +1 -0
- package/src/debug-context/Context.tsx +5 -5
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useAddClassNameDuringResize.ts +4 -0
- package/src/hooks/useContainerWidth.ts +13 -0
- package/src/hooks/useDocumentTitle.ts +21 -0
- package/src/hooks/useExpectSameValueReference.ts +27 -2
- package/src/index.ts +1 -0
- package/src/theming/ColorSchemeProvider.tsx +19 -0
- package/src/theming/GlobalClassNamePrefixContext.ts +3 -0
- package/src/theming/contexts.ts +18 -0
- package/src/theming/index.ts +7 -0
- package/src/theming/useClassName.ts +28 -0
- package/src/theming/useClassNameFactory.ts +47 -0
- package/src/theming/useThemedClassName.ts +54 -0
- package/src/theming/useThemedClassNameFactory.ts +41 -0
package/dist/production/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createNonNullableContextFactory } from "./context/createNonNullableContextFactory.js";
|
|
2
|
+
import { createOptionalContextFactory } from "./context/createOptionalContextFactory.js";
|
|
2
3
|
import { isNoopScopedConsole, noopLog, noopLogged, noopScopedConsole } from "./debug-context/Constants.js";
|
|
3
4
|
import { DebugChildren, ScopedConsoleContext, useScopedConsoleRef } from "./debug-context/Context.js";
|
|
4
5
|
import { unwrapRefValue } from "./hooks/unwrapRefValue.js";
|
|
@@ -8,8 +9,10 @@ import { useArrayMapMemo } from "./hooks/useArrayMapMemo.js";
|
|
|
8
9
|
import { useComposeRef } from "./hooks/useComposeRef.js";
|
|
9
10
|
import { useConstantLengthInvariant } from "./hooks/useConstantLengthInvariant.js";
|
|
10
11
|
import { useConstantValueInvariant } from "./hooks/useConstantValueInvariant.js";
|
|
12
|
+
import { ContainerWidthContext, useContainerWidth } from "./hooks/useContainerWidth.js";
|
|
11
13
|
import { useDebounce } from "./hooks/useDebounce.js";
|
|
12
14
|
import { useDebounceCallback } from "./hooks/useDebounceCallback.js";
|
|
15
|
+
import { useDocumentTitle } from "./hooks/useDocumentTitle.js";
|
|
13
16
|
import { useElementSize } from "./hooks/useElementSize.js";
|
|
14
17
|
import { useEventHandler } from "./hooks/useEventHandler.js";
|
|
15
18
|
import { useExpectSameValueReference } from "./hooks/useExpectSameValueReference.js";
|
|
@@ -31,10 +34,23 @@ import { noop } from "./referentiallyStable/noop.js";
|
|
|
31
34
|
import { returnFalse } from "./referentiallyStable/returnFalse.js";
|
|
32
35
|
import { returnTrue } from "./referentiallyStable/returnTrue.js";
|
|
33
36
|
import { useReferentiallyStableCallback } from "./referentiallyStable/useReferentiallyStableCallback.js";
|
|
37
|
+
import { ColorSchemeProvider } from "./theming/ColorSchemeProvider.js";
|
|
38
|
+
import { GlobalClassNamePrefixContext } from "./theming/GlobalClassNamePrefixContext.js";
|
|
39
|
+
import { ColorSchemeContext, DEFAULT_COLOR_SCHEME, useColorScheme } from "./theming/contexts.js";
|
|
40
|
+
import { useClassName } from "./theming/useClassName.js";
|
|
41
|
+
import { useClassNameFactory } from "./theming/useClassNameFactory.js";
|
|
42
|
+
import { useThemedClassName } from "./theming/useThemedClassName.js";
|
|
43
|
+
import { useThemedClassNameFactory } from "./theming/useThemedClassNameFactory.js";
|
|
34
44
|
export {
|
|
45
|
+
ColorSchemeContext,
|
|
46
|
+
ColorSchemeProvider,
|
|
47
|
+
ContainerWidthContext,
|
|
48
|
+
DEFAULT_COLOR_SCHEME,
|
|
35
49
|
DebugChildren,
|
|
50
|
+
GlobalClassNamePrefixContext,
|
|
36
51
|
ScopedConsoleContext,
|
|
37
52
|
createNonNullableContextFactory,
|
|
53
|
+
createOptionalContextFactory,
|
|
38
54
|
emptyArray,
|
|
39
55
|
emptyObject,
|
|
40
56
|
identityFunction,
|
|
@@ -49,11 +65,16 @@ export {
|
|
|
49
65
|
useAbortController,
|
|
50
66
|
useAddClassNameDuringResize,
|
|
51
67
|
useArrayMapMemo,
|
|
68
|
+
useClassName,
|
|
69
|
+
useClassNameFactory,
|
|
70
|
+
useColorScheme,
|
|
52
71
|
useComposeRef,
|
|
53
72
|
useConstantLengthInvariant,
|
|
54
73
|
useConstantValueInvariant,
|
|
74
|
+
useContainerWidth,
|
|
55
75
|
useDebounce,
|
|
56
76
|
useDebounceCallback,
|
|
77
|
+
useDocumentTitle,
|
|
57
78
|
useElementSize,
|
|
58
79
|
useEventHandler,
|
|
59
80
|
useExpectSameValueReference,
|
|
@@ -68,6 +89,8 @@ export {
|
|
|
68
89
|
useScopedConsoleRef,
|
|
69
90
|
useScrollOffsets,
|
|
70
91
|
useSessionStorageState,
|
|
92
|
+
useThemedClassName,
|
|
93
|
+
useThemedClassNameFactory,
|
|
71
94
|
useUpdatedRef,
|
|
72
95
|
useWindowSize
|
|
73
96
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { useColorScheme, ColorSchemeContext } from "./contexts.js";
|
|
4
|
+
const ColorSchemeProvider = memo(
|
|
5
|
+
({ children, scheme }) => {
|
|
6
|
+
const inheritedColorScheme = useColorScheme();
|
|
7
|
+
return /* @__PURE__ */ jsx(ColorSchemeContext.Provider, { value: scheme ?? inheritedColorScheme, children });
|
|
8
|
+
}
|
|
9
|
+
);
|
|
10
|
+
ColorSchemeProvider.displayName = "Interface.ColorSchemeProvider";
|
|
11
|
+
export {
|
|
12
|
+
ColorSchemeProvider
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=ColorSchemeProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorSchemeProvider.js","sources":["../../../src/theming/ColorSchemeProvider.tsx"],"sourcesContent":["import { KebabCase } from '@contember/utilities'\nimport { memo } from 'react'\nimport { ColorSchemeContext, useColorScheme } from './contexts'\n\nexport type ColorSchemeProviderProps<T extends KebabCase<string>> = {\n\tchildren: React.ReactNode\n\tscheme?: T\n}\n\nexport const ColorSchemeProvider = memo(\n\t<T extends KebabCase<string>>({ children, scheme }: ColorSchemeProviderProps<T>) => {\n\t\tconst inheritedColorScheme = useColorScheme()\n\n\t\treturn (\n\t\t\t<ColorSchemeContext.Provider value={scheme ?? inheritedColorScheme}>{children}</ColorSchemeContext.Provider>\n\t\t)\n\t},\n)\nColorSchemeProvider.displayName = 'Interface.ColorSchemeProvider'\n"],"names":[],"mappings":";;;AASO,MAAM,sBAAsB;AAAA,EAClC,CAA8B,EAAE,UAAU,aAA0C;AACnF,UAAM,uBAAuB;AAE7B,+BACE,mBAAmB,UAAnB,EAA4B,OAAO,UAAU,sBAAuB,SAAS,CAAA;AAAA,EAEhF;AACD;AACA,oBAAoB,cAAc;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GlobalClassNamePrefixContext.js","sources":["../../../src/theming/GlobalClassNamePrefixContext.ts"],"sourcesContent":["import { createContext } from 'react'\n\nexport const GlobalClassNamePrefixContext = createContext<string>('cui-')\n"],"names":[],"mappings":";AAEa,MAAA,+BAA+B,cAAsB,MAAM;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createOptionalContextFactory } from "../context/createOptionalContextFactory.js";
|
|
2
|
+
const DEFAULT_COLOR_SCHEME = "system";
|
|
3
|
+
const [ColorSchemeContext, useColorScheme] = createOptionalContextFactory(
|
|
4
|
+
"Interface.ColorScheme",
|
|
5
|
+
DEFAULT_COLOR_SCHEME
|
|
6
|
+
);
|
|
7
|
+
export {
|
|
8
|
+
ColorSchemeContext,
|
|
9
|
+
DEFAULT_COLOR_SCHEME,
|
|
10
|
+
useColorScheme
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=contexts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contexts.js","sources":["../../../src/theming/contexts.ts"],"sourcesContent":["import { createOptionalContextFactory } from '../context'\n\nexport const DEFAULT_COLOR_SCHEME = 'system'\n\n\n/**\n * @group UI\n *\n * @description\n * Provides the current color scheme, possible values are `'light'`, `'dark'` or `'system'`.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme\n *\n */\nexport const [ColorSchemeContext, useColorScheme] = createOptionalContextFactory<string>(\n\t'Interface.ColorScheme',\n\tDEFAULT_COLOR_SCHEME,\n)\n"],"names":[],"mappings":";AAEO,MAAM,uBAAuB;AAYvB,MAAA,CAAC,oBAAoB,cAAc,IAAI;AAAA,EACnD;AAAA,EACA;AACD;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { flatClassNameList, deduplicateClassName } from "@contember/utilities";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { GlobalClassNamePrefixContext } from "./GlobalClassNamePrefixContext.js";
|
|
4
|
+
function useClassName(componentClassName, additionalClassName = null, prefixOverride) {
|
|
5
|
+
const contextPrefix = useContext(GlobalClassNamePrefixContext);
|
|
6
|
+
const classNamePrefix = prefixOverride === null || prefixOverride === "" ? "" : prefixOverride || contextPrefix;
|
|
7
|
+
const componentClassNameList = flatClassNameList(componentClassName).map(
|
|
8
|
+
(componentClassName2) => `${classNamePrefix}${componentClassName2}`
|
|
9
|
+
);
|
|
10
|
+
return deduplicateClassName(componentClassNameList.concat(
|
|
11
|
+
flatClassNameList(additionalClassName)
|
|
12
|
+
)).join(" ");
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
useClassName
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=useClassName.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useClassName.js","sources":["../../../src/theming/useClassName.ts"],"sourcesContent":["import { NestedClassName, deduplicateClassName, flatClassNameList } from '@contember/utilities'\nimport { useContext } from 'react'\nimport { GlobalClassNamePrefixContext } from './GlobalClassNamePrefixContext'\n\n/**\n * Hook for component class name accepting outer class name\n *\n * @param componentClassName - Component class name\n * @param additionalClassName - Additional class name\n * @param prefixOverride - Context component prefix override\n * @returns Prefixed component class name.\n */\nexport function useClassName (\n\tcomponentClassName: NestedClassName,\n\tadditionalClassName: NestedClassName = null,\n\tprefixOverride?: string | null | undefined,\n) {\n\tconst contextPrefix = useContext(GlobalClassNamePrefixContext)\n\tconst classNamePrefix: string = prefixOverride === null || prefixOverride === '' ? '' : prefixOverride || contextPrefix\n\n\tconst componentClassNameList: string[] = flatClassNameList(componentClassName).map(\n\t\tcomponentClassName => `${classNamePrefix}${componentClassName}`,\n\t)\n\n\treturn deduplicateClassName(componentClassNameList.concat(\n\t\tflatClassNameList(additionalClassName),\n\t)).join(' ')\n}\n"],"names":["componentClassName"],"mappings":";;;AAYO,SAAS,aACf,oBACA,sBAAuC,MACvC,gBACC;AACK,QAAA,gBAAgB,WAAW,4BAA4B;AAC7D,QAAM,kBAA0B,mBAAmB,QAAQ,mBAAmB,KAAK,KAAK,kBAAkB;AAEpG,QAAA,yBAAmC,kBAAkB,kBAAkB,EAAE;AAAA,IAC9E,CAAAA,wBAAsB,GAAG,kBAAkBA;AAAAA,EAAA;AAG5C,SAAO,qBAAqB,uBAAuB;AAAA,IAClD,kBAAkB,mBAAmB;AAAA,EAAA,CACrC,EAAE,KAAK,GAAG;AACZ;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { flatClassNameList, deduplicateClassName } from "@contember/utilities";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { GlobalClassNamePrefixContext } from "./GlobalClassNamePrefixContext.js";
|
|
4
|
+
function useClassNameFactory(componentClassName, glue = "-", prefixOverride) {
|
|
5
|
+
const contextPrefix = useContext(GlobalClassNamePrefixContext);
|
|
6
|
+
const classNamePrefix = prefixOverride === null || prefixOverride === "" ? "" : prefixOverride || contextPrefix;
|
|
7
|
+
const componentClassNameList = flatClassNameList(componentClassName).map(
|
|
8
|
+
(componentClassName2) => `${classNamePrefix}${componentClassName2}`
|
|
9
|
+
);
|
|
10
|
+
return function componentClassNameFor(suffix = null, additionalClassName = null) {
|
|
11
|
+
const classNameSuffix = suffix ?? "";
|
|
12
|
+
return deduplicateClassName((classNameSuffix ? classNameSuffix.match(/^[a-zA-Z0-9]/) ? componentClassNameList.map((componentClassName2) => `${componentClassName2}${glue}${classNameSuffix}`) : componentClassNameList.map((componentClassName2) => `${componentClassName2}${classNameSuffix}`) : componentClassNameList).concat(
|
|
13
|
+
flatClassNameList(additionalClassName)
|
|
14
|
+
)).join(" ");
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
useClassNameFactory
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=useClassNameFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useClassNameFactory.js","sources":["../../../src/theming/useClassNameFactory.ts"],"sourcesContent":["import { NestedClassName, deduplicateClassName, flatClassNameList } from '@contember/utilities'\nimport { useContext } from 'react'\nimport { GlobalClassNamePrefixContext } from './GlobalClassNamePrefixContext'\n\n/**\n * Hook for component class name accepting outer class name\n *\n * Returns a reusable function almost that is handy for components\n * with many sub-component parts that should inherit the root component\n * name.\n *\n * Also, product of the factory is a function that can be used outside of rules of hooks.\n *\n * @param componentClassName - Component class name\n * @param glue - String to use to glue component and sub-component suffix\n * @param prefixOverride - Context component prefix override\n * @returns\n */\nexport function useClassNameFactory(\n\tcomponentClassName: NestedClassName,\n\tglue: string | null = '-',\n\tprefixOverride?: string | null | undefined,\n) {\n\tconst contextPrefix = useContext(GlobalClassNamePrefixContext)\n\tconst classNamePrefix: string = prefixOverride === null || prefixOverride === '' ? '' : prefixOverride || contextPrefix\n\n\tconst componentClassNameList: string[] = flatClassNameList(componentClassName).map(\n\t\tcomponentClassName => `${classNamePrefix}${componentClassName}`,\n\t)\n\n\treturn function componentClassNameFor(\n\t\tsuffix: string | null | undefined = null,\n\t\tadditionalClassName: NestedClassName = null,\n\t): string {\n\t\tconst classNameSuffix: string = suffix ?? ''\n\n\t\treturn deduplicateClassName((classNameSuffix\n\t\t\t? (classNameSuffix.match(/^[a-zA-Z0-9]/)\n\t\t\t\t? componentClassNameList.map(componentClassName => `${componentClassName}${glue}${classNameSuffix}`)\n\t\t\t\t: componentClassNameList.map(componentClassName => `${componentClassName}${classNameSuffix}`)\n\t\t\t)\n\t\t\t: componentClassNameList\n\t\t).concat(\n\t\t\tflatClassNameList(additionalClassName),\n\t\t)).join(' ')\n\t}\n}\n"],"names":["componentClassName"],"mappings":";;;AAkBO,SAAS,oBACf,oBACA,OAAsB,KACtB,gBACC;AACK,QAAA,gBAAgB,WAAW,4BAA4B;AAC7D,QAAM,kBAA0B,mBAAmB,QAAQ,mBAAmB,KAAK,KAAK,kBAAkB;AAEpG,QAAA,yBAAmC,kBAAkB,kBAAkB,EAAE;AAAA,IAC9E,CAAAA,wBAAsB,GAAG,kBAAkBA;AAAAA,EAAA;AAG5C,SAAO,SAAS,sBACf,SAAoC,MACpC,sBAAuC,MAC9B;AACT,UAAM,kBAA0B,UAAU;AAEnC,WAAA,sBAAsB,kBACzB,gBAAgB,MAAM,cAAc,IACpC,uBAAuB,IAAI,CAAAA,wBAAsB,GAAGA,sBAAqB,OAAO,iBAAiB,IACjG,uBAAuB,IAAI,CAAAA,wBAAsB,GAAGA,sBAAqB,iBAAiB,IAE3F,wBACD;AAAA,MACD,kBAAkB,mBAAmB;AAAA,IAAA,CACrC,EAAE,KAAK,GAAG;AAAA,EAAA;AAEb;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { filterThemedClassName, colorSchemeClassName } from "@contember/utilities";
|
|
2
|
+
import { useColorScheme } from "./contexts.js";
|
|
3
|
+
import { useClassName } from "./useClassName.js";
|
|
4
|
+
function useThemedClassName(componentClassName, additionalClassName, prefixOverride) {
|
|
5
|
+
return useClassName(
|
|
6
|
+
componentClassName,
|
|
7
|
+
filterThemedClassName(
|
|
8
|
+
additionalClassName,
|
|
9
|
+
colorSchemeClassName(useColorScheme())
|
|
10
|
+
),
|
|
11
|
+
prefixOverride
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
useThemedClassName
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=useThemedClassName.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThemedClassName.js","sources":["../../../src/theming/useThemedClassName.ts"],"sourcesContent":["import { NestedClassName, colorSchemeClassName, filterThemedClassName } from '@contember/utilities'\nimport { useColorScheme } from './contexts'\nimport { useClassName } from './useClassName'\n\n/**\n * Hook for component class name accepting outer class name with theme-* and scheme-* class manes\n *\n * It looks for theme CSS classes in the given class name, deduplicates them and returns final theme class name with scheme CSS class set\n * @internal\n *\n * @param componentClassName - Component class name\n * @param additionalClassName - Additional class name\n * @param prefixOverride - Context component prefix override\n * @returns string\n * @see useColorScheme\n *\n * @example\n * ```tsx\n * function Button({ className }: { className?: string | string[] }) {\n * \t const [contentThemeClassName, controlsThemeClassName] = useThemedClassName(className)\n *\n * \t return (\n * \t\t <div className={contentThemeClassName}>\n * \t\t\t <button className={controlsThemeClassName}>Click me</button>\n * \t\t </div>\n * \t )\n * }\n *\n * function App() {\n * \t return (\n * \t\t <Button className=\"theme-default theme-danger:hover\" />\n * \t )\n * }\n *\n * // renders:\n * // <div class=\"scheme-system theme-default-content theme-danger-content:hover\">\n * // \t<button class=\"scheme-system theme-default-controls theme-danger-controls:hover\">Click me</button>\n * // </div>\n * ```\n */\nexport function useThemedClassName(\n\tcomponentClassName: NestedClassName,\n\tadditionalClassName: NestedClassName,\n\tprefixOverride?: string | null | undefined,\n): string {\n\treturn useClassName(\n\t\tcomponentClassName,\n\t\tfilterThemedClassName(\n\t\t\tadditionalClassName,\n\t\t\tcolorSchemeClassName(useColorScheme()),\n\t\t),\n\t\tprefixOverride,\n\t)\n}\n"],"names":[],"mappings":";;;AAwCgB,SAAA,mBACf,oBACA,qBACA,gBACS;AACF,SAAA;AAAA,IACN;AAAA,IACA;AAAA,MACC;AAAA,MACA,qBAAqB,gBAAgB;AAAA,IACtC;AAAA,IACA;AAAA,EAAA;AAEF;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { flatClassNameList, colorSchemeClassName, deduplicateClassName, filterThemedClassName } from "@contember/utilities";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { GlobalClassNamePrefixContext } from "./GlobalClassNamePrefixContext.js";
|
|
4
|
+
import { useColorScheme } from "./contexts.js";
|
|
5
|
+
function useThemedClassNameFactory(componentClassName, glue = "-", prefixOverride) {
|
|
6
|
+
const contextPrefix = useContext(GlobalClassNamePrefixContext);
|
|
7
|
+
const classNamePrefix = prefixOverride === null || prefixOverride === "" ? "" : prefixOverride || contextPrefix;
|
|
8
|
+
const componentClassNameList = flatClassNameList(componentClassName).map(
|
|
9
|
+
(componentClassName2) => `${classNamePrefix}${componentClassName2}`
|
|
10
|
+
);
|
|
11
|
+
const colorScheme = colorSchemeClassName(useColorScheme());
|
|
12
|
+
return function componentClassNameFor(suffix = null, additionalClassName = null) {
|
|
13
|
+
const classNameSuffix = suffix ?? "";
|
|
14
|
+
return deduplicateClassName((classNameSuffix ? classNameSuffix.match(/^[a-zA-Z0-9]/) ? componentClassNameList.map((componentClassName2) => `${componentClassName2}${glue}${classNameSuffix}`) : componentClassNameList.map((componentClassName2) => `${componentClassName2}${classNameSuffix}`) : componentClassNameList).concat(
|
|
15
|
+
flatClassNameList(
|
|
16
|
+
filterThemedClassName(
|
|
17
|
+
additionalClassName,
|
|
18
|
+
colorScheme
|
|
19
|
+
)
|
|
20
|
+
)
|
|
21
|
+
)).join(" ");
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
useThemedClassNameFactory
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=useThemedClassNameFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThemedClassNameFactory.js","sources":["../../../src/theming/useThemedClassNameFactory.ts"],"sourcesContent":["import { NestedClassName, colorSchemeClassName, deduplicateClassName, filterThemedClassName, flatClassNameList } from '@contember/utilities'\nimport { useContext } from 'react'\nimport { GlobalClassNamePrefixContext } from './GlobalClassNamePrefixContext'\nimport { useColorScheme } from './contexts'\n\nexport function useThemedClassNameFactory(\n\tcomponentClassName: NestedClassName,\n\tglue: string | null = '-',\n\tprefixOverride?: string | null | undefined,\n) {\n\tconst contextPrefix = useContext(GlobalClassNamePrefixContext)\n\tconst classNamePrefix: string = prefixOverride === null || prefixOverride === '' ? '' : prefixOverride || contextPrefix\n\n\tconst componentClassNameList: string[] = flatClassNameList(componentClassName).map(\n\t\tcomponentClassName => `${classNamePrefix}${componentClassName}`,\n\t)\n\n\tconst colorScheme = colorSchemeClassName(useColorScheme())\n\n\treturn function componentClassNameFor(\n\t\tsuffix: string | null | undefined = null,\n\t\tadditionalClassName: NestedClassName = null,\n\t): string {\n\t\tconst classNameSuffix: string = suffix ?? ''\n\n\t\treturn deduplicateClassName((classNameSuffix\n\t\t\t? (classNameSuffix.match(/^[a-zA-Z0-9]/)\n\t\t\t\t? componentClassNameList.map(componentClassName => `${componentClassName}${glue}${classNameSuffix}`)\n\t\t\t\t: componentClassNameList.map(componentClassName => `${componentClassName}${classNameSuffix}`)\n\t\t\t)\n\t\t\t: componentClassNameList\n\t\t).concat(\n\t\t\tflatClassNameList(\n\t\t\t\tfilterThemedClassName(\n\t\t\t\t\tadditionalClassName,\n\t\t\t\t\tcolorScheme,\n\t\t\t\t),\n\t\t\t),\n\t\t)).join(' ')\n\t}\n}\n"],"names":["componentClassName"],"mappings":";;;;AAKO,SAAS,0BACf,oBACA,OAAsB,KACtB,gBACC;AACK,QAAA,gBAAgB,WAAW,4BAA4B;AAC7D,QAAM,kBAA0B,mBAAmB,QAAQ,mBAAmB,KAAK,KAAK,kBAAkB;AAEpG,QAAA,yBAAmC,kBAAkB,kBAAkB,EAAE;AAAA,IAC9E,CAAAA,wBAAsB,GAAG,kBAAkBA;AAAAA,EAAA;AAGtC,QAAA,cAAc,qBAAqB,eAAA,CAAgB;AAEzD,SAAO,SAAS,sBACf,SAAoC,MACpC,sBAAuC,MAC9B;AACT,UAAM,kBAA0B,UAAU;AAEnC,WAAA,sBAAsB,kBACzB,gBAAgB,MAAM,cAAc,IACpC,uBAAuB,IAAI,CAAAA,wBAAsB,GAAGA,sBAAqB,OAAO,iBAAiB,IACjG,uBAAuB,IAAI,CAAAA,wBAAsB,GAAGA,sBAAqB,iBAAiB,IAE3F,wBACD;AAAA,MACD;AAAA,QACC;AAAA,UACC;AAAA,UACA;AAAA,QACD;AAAA,MACD;AAAA,IAAA,CACA,EAAE,KAAK,GAAG;AAAA,EAAA;AAEb;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createOptionalContextFactory.d.ts","sourceRoot":"","sources":["../../../src/context/createOptionalContextFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAGpC,wBAAgB,4BAA4B,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CASpG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAA;AACjD,cAAc,gCAAgC,CAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { ScopedConsoleContextType } from './Types';
|
|
3
3
|
export declare const ScopedConsoleContext: import("react").Context<ScopedConsoleContextType>;
|
|
4
|
-
export declare const useScopedConsoleRef: (prefix: string) => import("react").MutableRefObject<ScopedConsoleContextType>;
|
|
4
|
+
export declare const useScopedConsoleRef: (prefix: string, override?: boolean) => import("react").MutableRefObject<ScopedConsoleContextType>;
|
|
5
5
|
export type DebugChildrenProps = {
|
|
6
|
-
active
|
|
6
|
+
active?: true;
|
|
7
7
|
children: ReactNode;
|
|
8
8
|
id: string;
|
|
9
9
|
} | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/debug-context/Context.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAoD,MAAM,OAAO,CAAA;AAEnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAmClD,eAAO,MAAM,oBAAoB,mDAAiD,CAAA;AAOlF,eAAO,MAAM,mBAAmB,WAAY,MAAM,+
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/debug-context/Context.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAoD,MAAM,OAAO,CAAA;AAEnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAmClD,eAAO,MAAM,oBAAoB,mDAAiD,CAAA;AAOlF,eAAO,MAAM,mBAAmB,WAAY,MAAM,aAAa,OAAO,+DAiBrE,CAAA;AAED,MAAM,MAAM,kBAAkB,GAC3B;IAAE,MAAM,CAAC,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,MAAM,CAAC,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvD,eAAO,MAAM,aAAa,0DAYxB,CAAA"}
|
|
@@ -5,8 +5,10 @@ export * from './useArrayMapMemo';
|
|
|
5
5
|
export * from './useComposeRef';
|
|
6
6
|
export * from './useConstantLengthInvariant';
|
|
7
7
|
export * from './useConstantValueInvariant';
|
|
8
|
+
export * from './useContainerWidth';
|
|
8
9
|
export * from './useDebounce';
|
|
9
10
|
export * from './useDebounceCallback';
|
|
11
|
+
export * from './useDocumentTitle';
|
|
10
12
|
export * from './useElementSize';
|
|
11
13
|
export * from './useEventHandler';
|
|
12
14
|
export * from './useExpectSameValueReference';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,8BAA8B,CAAA;AAC5C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,8BAA8B,CAAA;AAC5C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAddClassNameDuringResize.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAddClassNameDuringResize.ts"],"names":[],"mappings":"AA4BA;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CAC1C,SAAS,EAAE,MAAM,EACjB,gBAAgB,GAAE,MAAY,EAC9B,OAAO,CAAC,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"useAddClassNameDuringResize.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAddClassNameDuringResize.ts"],"names":[],"mappings":"AA4BA;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CAC1C,SAAS,EAAE,MAAM,EACjB,gBAAgB,GAAE,MAAY,EAC9B,OAAO,CAAC,EAAE,WAAW,QAmBrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useContainerWidth.d.ts","sourceRoot":"","sources":["../../../src/hooks/useContainerWidth.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,yBAAyB,GAAG,MAAM,CAAA;AAC9C,eAAO,MAAM,qBAAqB,wCAAwD,CAAA;AAG1F,wBAAgB,iBAAiB,IAAI,MAAM,CAK1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDocumentTitle.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDocumentTitle.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,MAAM,QAkB7H"}
|
|
@@ -1,2 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether the next value is the same reference as the previous one
|
|
3
|
+
*
|
|
4
|
+
* If not, it checks whether the values are deeply equal. If not, it logs an error.
|
|
5
|
+
*
|
|
6
|
+
* @param next - Value to be checked.
|
|
7
|
+
* @param shouldThrow - If true, it throws an error instead of logging it. Defaults to false.
|
|
8
|
+
* @returns void
|
|
9
|
+
* -
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* useExpectSameValueReference(style)
|
|
13
|
+
* ```
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* useExpectSameValueReference(style, true)
|
|
17
|
+
* ```
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* useExpectSameValueReference(style, import.meta.env.DEV)
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
1
23
|
export declare function useExpectSameValueReference<T>(next: T, shouldThrow?: boolean): void;
|
|
2
24
|
//# sourceMappingURL=useExpectSameValueReference.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useExpectSameValueReference.d.ts","sourceRoot":"","sources":["../../../src/hooks/useExpectSameValueReference.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useExpectSameValueReference.d.ts","sourceRoot":"","sources":["../../../src/hooks/useExpectSameValueReference.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,WAAW,GAAE,OAAe,QAyBnF"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,SAAS,CAAA;AACvB,cAAc,uBAAuB,CAAA;AACrC,cAAc,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,SAAS,CAAA;AACvB,cAAc,uBAAuB,CAAA;AACrC,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { KebabCase } from '@contember/utilities';
|
|
2
|
+
export type ColorSchemeProviderProps<T extends KebabCase<string>> = {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
scheme?: T;
|
|
5
|
+
};
|
|
6
|
+
export declare const ColorSchemeProvider: import("react").MemoExoticComponent<(<T extends string>({ children, scheme }: ColorSchemeProviderProps<T>) => JSX.Element)>;
|
|
7
|
+
//# sourceMappingURL=ColorSchemeProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorSchemeProvider.d.ts","sourceRoot":"","sources":["../../../src/theming/ColorSchemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAIhD,MAAM,MAAM,wBAAwB,CAAC,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,IAAI;IACnE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,MAAM,CAAC,EAAE,CAAC,CAAA;CACV,CAAA;AAED,eAAO,MAAM,mBAAmB,6HAQ/B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GlobalClassNamePrefixContext.d.ts","sourceRoot":"","sources":["../../../src/theming/GlobalClassNamePrefixContext.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,4BAA4B,iCAAgC,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const DEFAULT_COLOR_SCHEME = "system";
|
|
2
|
+
/**
|
|
3
|
+
* @group UI
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* Provides the current color scheme, possible values are `'light'`, `'dark'` or `'system'`.
|
|
7
|
+
*
|
|
8
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export declare const ColorSchemeContext: import("react").Context<string>, useColorScheme: () => string;
|
|
12
|
+
//# sourceMappingURL=contexts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contexts.d.ts","sourceRoot":"","sources":["../../../src/theming/contexts.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,WAAW,CAAA;AAG5C;;;;;;;;GAQG;AACH,eAAO,MAAO,kBAAkB,mCAAE,cAAc,cAG/C,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './ColorSchemeProvider';
|
|
2
|
+
export * from './GlobalClassNamePrefixContext';
|
|
3
|
+
export * from './contexts';
|
|
4
|
+
export * from './useClassName';
|
|
5
|
+
export * from './useClassNameFactory';
|
|
6
|
+
export * from './useThemedClassName';
|
|
7
|
+
export * from './useThemedClassNameFactory';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/theming/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,6BAA6B,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NestedClassName } from '@contember/utilities';
|
|
2
|
+
/**
|
|
3
|
+
* Hook for component class name accepting outer class name
|
|
4
|
+
*
|
|
5
|
+
* @param componentClassName - Component class name
|
|
6
|
+
* @param additionalClassName - Additional class name
|
|
7
|
+
* @param prefixOverride - Context component prefix override
|
|
8
|
+
* @returns Prefixed component class name.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useClassName(componentClassName: NestedClassName, additionalClassName?: NestedClassName, prefixOverride?: string | null | undefined): string;
|
|
11
|
+
//# sourceMappingURL=useClassName.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useClassName.d.ts","sourceRoot":"","sources":["../../../src/theming/useClassName.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAA2C,MAAM,sBAAsB,CAAA;AAI/F;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC3B,kBAAkB,EAAE,eAAe,EACnC,mBAAmB,GAAE,eAAsB,EAC3C,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,UAY1C"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { NestedClassName } from '@contember/utilities';
|
|
2
|
+
/**
|
|
3
|
+
* Hook for component class name accepting outer class name
|
|
4
|
+
*
|
|
5
|
+
* Returns a reusable function almost that is handy for components
|
|
6
|
+
* with many sub-component parts that should inherit the root component
|
|
7
|
+
* name.
|
|
8
|
+
*
|
|
9
|
+
* Also, product of the factory is a function that can be used outside of rules of hooks.
|
|
10
|
+
*
|
|
11
|
+
* @param componentClassName - Component class name
|
|
12
|
+
* @param glue - String to use to glue component and sub-component suffix
|
|
13
|
+
* @param prefixOverride - Context component prefix override
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export declare function useClassNameFactory(componentClassName: NestedClassName, glue?: string | null, prefixOverride?: string | null | undefined): (suffix?: string | null | undefined, additionalClassName?: NestedClassName) => string;
|
|
17
|
+
//# sourceMappingURL=useClassNameFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useClassNameFactory.d.ts","sourceRoot":"","sources":["../../../src/theming/useClassNameFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAA2C,MAAM,sBAAsB,CAAA;AAI/F;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAClC,kBAAkB,EAAE,eAAe,EACnC,IAAI,GAAE,MAAM,GAAG,IAAU,EACzB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,aAUjC,MAAM,GAAG,IAAI,GAAG,SAAS,wBACZ,eAAe,KAClC,MAAM,CAaT"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { NestedClassName } from '@contember/utilities';
|
|
2
|
+
/**
|
|
3
|
+
* Hook for component class name accepting outer class name with theme-* and scheme-* class manes
|
|
4
|
+
*
|
|
5
|
+
* It looks for theme CSS classes in the given class name, deduplicates them and returns final theme class name with scheme CSS class set
|
|
6
|
+
* @internal
|
|
7
|
+
*
|
|
8
|
+
* @param componentClassName - Component class name
|
|
9
|
+
* @param additionalClassName - Additional class name
|
|
10
|
+
* @param prefixOverride - Context component prefix override
|
|
11
|
+
* @returns string
|
|
12
|
+
* @see useColorScheme
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* function Button({ className }: { className?: string | string[] }) {
|
|
17
|
+
* const [contentThemeClassName, controlsThemeClassName] = useThemedClassName(className)
|
|
18
|
+
*
|
|
19
|
+
* return (
|
|
20
|
+
* <div className={contentThemeClassName}>
|
|
21
|
+
* <button className={controlsThemeClassName}>Click me</button>
|
|
22
|
+
* </div>
|
|
23
|
+
* )
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* function App() {
|
|
27
|
+
* return (
|
|
28
|
+
* <Button className="theme-default theme-danger:hover" />
|
|
29
|
+
* )
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* // renders:
|
|
33
|
+
* // <div class="scheme-system theme-default-content theme-danger-content:hover">
|
|
34
|
+
* // <button class="scheme-system theme-default-controls theme-danger-controls:hover">Click me</button>
|
|
35
|
+
* // </div>
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function useThemedClassName(componentClassName: NestedClassName, additionalClassName: NestedClassName, prefixOverride?: string | null | undefined): string;
|
|
39
|
+
//# sourceMappingURL=useThemedClassName.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThemedClassName.d.ts","sourceRoot":"","sources":["../../../src/theming/useThemedClassName.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAA+C,MAAM,sBAAsB,CAAA;AAInG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,kBAAkB,CACjC,kBAAkB,EAAE,eAAe,EACnC,mBAAmB,EAAE,eAAe,EACpC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACxC,MAAM,CASR"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { NestedClassName } from '@contember/utilities';
|
|
2
|
+
export declare function useThemedClassNameFactory(componentClassName: NestedClassName, glue?: string | null, prefixOverride?: string | null | undefined): (suffix?: string | null | undefined, additionalClassName?: NestedClassName) => string;
|
|
3
|
+
//# sourceMappingURL=useThemedClassNameFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThemedClassNameFactory.d.ts","sourceRoot":"","sources":["../../../src/theming/useThemedClassNameFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAwF,MAAM,sBAAsB,CAAA;AAK5I,wBAAgB,yBAAyB,CACxC,kBAAkB,EAAE,eAAe,EACnC,IAAI,GAAE,MAAM,GAAG,IAAU,EACzB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,aAYjC,MAAM,GAAG,IAAI,GAAG,SAAS,wBACZ,eAAe,KAClC,MAAM,CAkBT"}
|