1 |
|
2 | import React from "react";
|
3 |
|
4 |
|
5 | export * from "@chakra-ui/accordion";
|
6 | export * from "@chakra-ui/alert";
|
7 | export * from "@chakra-ui/avatar";
|
8 | export * from "@chakra-ui/breadcrumb";
|
9 | export * from "@chakra-ui/button";
|
10 | export * from "@chakra-ui/checkbox";
|
11 | export * from "@chakra-ui/close-button";
|
12 | export * from "@chakra-ui/control-box";
|
13 | export * from "@chakra-ui/counter";
|
14 | export * from "@chakra-ui/css-reset";
|
15 | export * from "@chakra-ui/editable";
|
16 | export * from "@chakra-ui/form-control";
|
17 | export * from "@chakra-ui/hooks";
|
18 | export * from "@chakra-ui/icon";
|
19 | export * from "@chakra-ui/image";
|
20 | export * from "@chakra-ui/input";
|
21 | export * from "@chakra-ui/layout";
|
22 | export * from "@chakra-ui/media-query";
|
23 | export * from "@chakra-ui/menu";
|
24 | export * from "@chakra-ui/modal";
|
25 | export * from "@chakra-ui/number-input";
|
26 | export * from "@chakra-ui/pin-input";
|
27 | export * from "@chakra-ui/popover";
|
28 | export * from "@chakra-ui/popper";
|
29 | export * from "@chakra-ui/portal";
|
30 | export * from "@chakra-ui/progress";
|
31 | export * from "@chakra-ui/radio";
|
32 | export * from "@chakra-ui/react-env";
|
33 | export * from "@chakra-ui/select";
|
34 | export * from "@chakra-ui/skeleton";
|
35 | export * from "@chakra-ui/slider";
|
36 | export * from "@chakra-ui/spinner";
|
37 | export * from "@chakra-ui/stat";
|
38 | export * from "@chakra-ui/switch";
|
39 | export * from "@chakra-ui/system";
|
40 | export * from "@chakra-ui/table";
|
41 | export * from "@chakra-ui/tabs";
|
42 | export * from "@chakra-ui/tag";
|
43 | export * from "@chakra-ui/textarea";
|
44 | export * from "@chakra-ui/theme";
|
45 | export * from "@chakra-ui/toast";
|
46 | export * from "@chakra-ui/tooltip";
|
47 | export * from "@chakra-ui/transition";
|
48 | export * from "@chakra-ui/visually-hidden";
|
49 |
|
50 |
|
51 | import {
|
52 | ChakraProvider as BaseChakraProvider
|
53 | } from "@chakra-ui/provider";
|
54 | import { theme as defaultTheme } from "@chakra-ui/theme";
|
55 | import { ToastProvider } from "@chakra-ui/toast";
|
56 | function ChakraProvider({
|
57 | children,
|
58 | theme: theme2 = defaultTheme,
|
59 | toastOptions,
|
60 | ...restProps
|
61 | }) {
|
62 | return React.createElement(BaseChakraProvider, {
|
63 | theme: theme2,
|
64 | ...restProps
|
65 | }, children, React.createElement(ToastProvider, {
|
66 | ...toastOptions
|
67 | }));
|
68 | }
|
69 |
|
70 |
|
71 | import { theme, isChakraTheme } from "@chakra-ui/theme";
|
72 | import {
|
73 | isFunction,
|
74 | mergeWith,
|
75 | pipe
|
76 | } from "@chakra-ui/utils";
|
77 | function extendTheme(...extensions) {
|
78 | let overrides = [...extensions];
|
79 | let baseTheme = extensions[extensions.length - 1];
|
80 | if (isChakraTheme(baseTheme) && overrides.length > 1) {
|
81 | overrides = overrides.slice(0, overrides.length - 1);
|
82 | } else {
|
83 | baseTheme = theme;
|
84 | }
|
85 | return pipe(...overrides.map((extension) => (prevTheme) => isFunction(extension) ? extension(prevTheme) : mergeThemeOverride(prevTheme, extension)))(baseTheme);
|
86 | }
|
87 | function mergeThemeOverride(...overrides) {
|
88 | return mergeWith({}, ...overrides, mergeThemeCustomizer);
|
89 | }
|
90 | function mergeThemeCustomizer(source, override, key, object) {
|
91 | if ((isFunction(source) || isFunction(override)) && Object.prototype.hasOwnProperty.call(object, key)) {
|
92 | return (...args) => {
|
93 | const sourceValue = isFunction(source) ? source(...args) : source;
|
94 | const overrideValue = isFunction(override) ? override(...args) : override;
|
95 | return mergeWith({}, sourceValue, overrideValue, mergeThemeCustomizer);
|
96 | };
|
97 | }
|
98 | return void 0;
|
99 | }
|
100 |
|
101 |
|
102 | import { isObject, fromEntries } from "@chakra-ui/utils";
|
103 | function withDefaultColorScheme({
|
104 | colorScheme,
|
105 | components
|
106 | }) {
|
107 | return (theme2) => {
|
108 | let names = Object.keys(theme2.components || {});
|
109 | if (Array.isArray(components)) {
|
110 | names = components;
|
111 | } else if (isObject(components)) {
|
112 | names = Object.keys(components);
|
113 | }
|
114 | return mergeThemeOverride(theme2, {
|
115 | components: fromEntries(names.map((componentName) => {
|
116 | const withColorScheme = {
|
117 | defaultProps: {
|
118 | colorScheme
|
119 | }
|
120 | };
|
121 | return [componentName, withColorScheme];
|
122 | }))
|
123 | });
|
124 | };
|
125 | }
|
126 |
|
127 |
|
128 | import { isObject as isObject2, fromEntries as fromEntries2 } from "@chakra-ui/utils";
|
129 | function withDefaultSize({
|
130 | size,
|
131 | components
|
132 | }) {
|
133 | return (theme2) => {
|
134 | let names = Object.keys(theme2.components || {});
|
135 | if (Array.isArray(components)) {
|
136 | names = components;
|
137 | } else if (isObject2(components)) {
|
138 | names = Object.keys(components);
|
139 | }
|
140 | return mergeThemeOverride(theme2, {
|
141 | components: fromEntries2(names.map((componentName) => {
|
142 | const withSize = {
|
143 | defaultProps: {
|
144 | size
|
145 | }
|
146 | };
|
147 | return [componentName, withSize];
|
148 | }))
|
149 | });
|
150 | };
|
151 | }
|
152 |
|
153 |
|
154 | import { isObject as isObject3, fromEntries as fromEntries3 } from "@chakra-ui/utils";
|
155 | function withDefaultVariant({
|
156 | variant,
|
157 | components
|
158 | }) {
|
159 | return (theme2) => {
|
160 | let names = Object.keys(theme2.components || {});
|
161 | if (Array.isArray(components)) {
|
162 | names = components;
|
163 | } else if (isObject3(components)) {
|
164 | names = Object.keys(components);
|
165 | }
|
166 | return mergeThemeOverride(theme2, {
|
167 | components: fromEntries3(names.map((componentName) => {
|
168 | const withVariant = {
|
169 | defaultProps: {
|
170 | variant
|
171 | }
|
172 | };
|
173 | return [componentName, withVariant];
|
174 | }))
|
175 | });
|
176 | };
|
177 | }
|
178 |
|
179 |
|
180 | import { pipe as pipe2 } from "@chakra-ui/utils";
|
181 | function withDefaultProps({
|
182 | defaultProps: { colorScheme, variant, size },
|
183 | components
|
184 | }) {
|
185 | const identity = (t) => t;
|
186 | const fns = [
|
187 | colorScheme ? withDefaultColorScheme({ colorScheme, components }) : identity,
|
188 | size ? withDefaultSize({ size, components }) : identity,
|
189 | variant ? withDefaultVariant({ variant, components }) : identity
|
190 | ];
|
191 | return (theme2) => mergeThemeOverride(pipe2(...fns)(theme2));
|
192 | }
|
193 | export {
|
194 | ChakraProvider,
|
195 | extendTheme,
|
196 | mergeThemeOverride,
|
197 | withDefaultColorScheme,
|
198 | withDefaultProps,
|
199 | withDefaultSize,
|
200 | withDefaultVariant
|
201 | };
|