@helpdice/theme 1.0.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/LICENSE +20 -0
- package/README.md +37 -0
- package/dist/css-baseline/css-baseline.d.ts +9 -0
- package/dist/css-baseline/index.d.ts +1 -0
- package/dist/css-baseline/index.js +868 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +1516 -0
- package/dist/shared/css-transition.d.ts +13 -0
- package/dist/styled-jsx.cjs.js +748 -0
- package/dist/themes/index.d.ts +4 -0
- package/dist/themes/index.js +299 -0
- package/dist/themes/presets/dark.d.ts +8 -0
- package/dist/themes/presets/default.d.ts +8 -0
- package/dist/themes/presets/index.d.ts +90 -0
- package/dist/themes/presets/shared.d.ts +4 -0
- package/dist/themes/themes.d.ts +18 -0
- package/dist/ui-provider/index.d.ts +3 -0
- package/dist/ui-provider/index.js +1425 -0
- package/dist/ui-provider/theme-provider.d.ts +8 -0
- package/dist/ui-provider/ui-provider.d.ts +8 -0
- package/dist/use-all-themes/all-themes-context.d.ts +7 -0
- package/dist/use-all-themes/index.d.ts +3 -0
- package/dist/use-all-themes/index.js +311 -0
- package/dist/use-classes/index.d.ts +2 -0
- package/dist/use-classes/index.js +48 -0
- package/dist/use-classes/use-classes.d.ts +4 -0
- package/dist/use-current-state/index.d.ts +2 -0
- package/dist/use-current-state/index.js +72 -0
- package/dist/use-current-state/use-current-state.d.ts +4 -0
- package/dist/use-media-query/index.js +444 -0
- package/dist/use-theme/index.d.ts +2 -0
- package/dist/use-theme/index.js +309 -0
- package/dist/use-theme/theme-context.d.ts +4 -0
- package/dist/use-toasts/helpers.d.ts +18 -0
- package/dist/use-toasts/index.js +204 -0
- package/dist/use-toasts/toast-container.d.ts +3 -0
- package/dist/use-toasts/toast-item.d.ts +8 -0
- package/dist/use-toasts/use-toast.d.ts +40 -0
- package/dist/utils/collections.d.ts +15 -0
- package/dist/utils/layouts.d.ts +20 -0
- package/dist/utils/prop-types.d.ts +19 -0
- package/dist/utils/types.d.ts +3 -0
- package/dist/utils/use-current-state.d.ts +2 -0
- package/dist/utils/use-hd-ui-context.d.ts +16 -0
- package/dist/utils/use-portal.d.ts +2 -0
- package/dist/utils/use-ssr.d.ts +6 -0
- package/esm/css-baseline/css-baseline.d.ts +9 -0
- package/esm/css-baseline/css-baseline.js +23 -0
- package/esm/css-baseline/index.d.ts +1 -0
- package/esm/css-baseline/index.js +2 -0
- package/esm/index.d.ts +12 -0
- package/esm/index.js +11 -0
- package/esm/shared/backdrop.js +66 -0
- package/esm/shared/css-transition.d.ts +13 -0
- package/esm/shared/css-transition.js +65 -0
- package/esm/shared/dropdown.js +99 -0
- package/esm/shared/ellipsis.js +13 -0
- package/esm/shared/expand.js +86 -0
- package/esm/shared/highlight.js +46 -0
- package/esm/styled-jsx-server.es.js +5 -0
- package/esm/styled-jsx.es.js +737 -0
- package/esm/themes/index.d.ts +4 -0
- package/esm/themes/index.js +2 -0
- package/esm/themes/presets/dark.d.ts +8 -0
- package/esm/themes/presets/dark.js +64 -0
- package/esm/themes/presets/default.d.ts +8 -0
- package/esm/themes/presets/default.js +64 -0
- package/esm/themes/presets/index.d.ts +90 -0
- package/esm/themes/presets/index.js +1 -0
- package/esm/themes/presets/shared.d.ts +4 -0
- package/esm/themes/presets/shared.js +42 -0
- package/esm/themes/themes.d.ts +18 -0
- package/esm/themes/themes.js +77 -0
- package/esm/ui-provider/index.d.ts +3 -0
- package/esm/ui-provider/index.js +4 -0
- package/esm/ui-provider/theme-provider.d.ts +8 -0
- package/esm/ui-provider/theme-provider.js +45 -0
- package/esm/ui-provider/ui-provider.d.ts +8 -0
- package/esm/ui-provider/ui-provider.js +55 -0
- package/esm/use-all-themes/all-themes-context.d.ts +7 -0
- package/esm/use-all-themes/all-themes-context.js +11 -0
- package/esm/use-all-themes/index.d.ts +3 -0
- package/esm/use-all-themes/index.js +2 -0
- package/esm/use-classes/index.d.ts +2 -0
- package/esm/use-classes/index.js +2 -0
- package/esm/use-classes/use-classes.d.ts +4 -0
- package/esm/use-classes/use-classes.js +34 -0
- package/esm/use-current-state/index.d.ts +2 -0
- package/esm/use-current-state/index.js +2 -0
- package/esm/use-current-state/use-current-state.d.ts +4 -0
- package/esm/use-current-state/use-current-state.js +23 -0
- package/esm/use-media-query/index.js +2 -0
- package/esm/use-media-query/use-media-query.js +81 -0
- package/esm/use-theme/index.d.ts +2 -0
- package/esm/use-theme/index.js +2 -0
- package/esm/use-theme/theme-context.d.ts +4 -0
- package/esm/use-theme/theme-context.js +9 -0
- package/esm/use-toasts/helpers.d.ts +18 -0
- package/esm/use-toasts/helpers.js +66 -0
- package/esm/use-toasts/index.js +2 -0
- package/esm/use-toasts/toast-container.d.ts +3 -0
- package/esm/use-toasts/toast-container.js +120 -0
- package/esm/use-toasts/toast-item.d.ts +8 -0
- package/esm/use-toasts/toast-item.js +45 -0
- package/esm/use-toasts/use-toast.d.ts +40 -0
- package/esm/use-toasts/use-toast.js +103 -0
- package/esm/utils/calculations.js +29 -0
- package/esm/utils/collections.d.ts +15 -0
- package/esm/utils/collections.js +128 -0
- package/esm/utils/color.js +35 -0
- package/esm/utils/layouts.d.ts +20 -0
- package/esm/utils/layouts.js +73 -0
- package/esm/utils/prop-types.d.ts +19 -0
- package/esm/utils/prop-types.js +20 -0
- package/esm/utils/types.d.ts +3 -0
- package/esm/utils/types.js +1 -0
- package/esm/utils/use-click-anywhere.js +15 -0
- package/esm/utils/use-context-state/create-ui-context.js +50 -0
- package/esm/utils/use-context-state/use-context-state.js +40 -0
- package/esm/utils/use-current-state.d.ts +2 -0
- package/esm/utils/use-current-state.js +2 -0
- package/esm/utils/use-default-props.js +17 -0
- package/esm/utils/use-dom-observer.js +26 -0
- package/esm/utils/use-hd-ui-context.d.ts +16 -0
- package/esm/utils/use-hd-ui-context.js +27 -0
- package/esm/utils/use-portal.d.ts +2 -0
- package/esm/utils/use-portal.js +34 -0
- package/esm/utils/use-previous.js +11 -0
- package/esm/utils/use-real-shape.js +47 -0
- package/esm/utils/use-resize.js +19 -0
- package/esm/utils/use-ssr.d.ts +6 -0
- package/esm/utils/use-ssr.js +19 -0
- package/esm/utils/use-warning.js +13 -0
- package/package.json +111 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
import { HUIThemes } from '../themes/presets';
|
|
3
|
+
export interface Props {
|
|
4
|
+
themeType?: string;
|
|
5
|
+
themes?: Array<HUIThemes>;
|
|
6
|
+
}
|
|
7
|
+
declare const ThemeProvider: React.FC<PropsWithChildren<Props>>;
|
|
8
|
+
export default ThemeProvider;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
import { HUIThemes } from '../themes/presets';
|
|
3
|
+
export type UiProviderProps = {
|
|
4
|
+
themes?: Array<HUIThemes>;
|
|
5
|
+
themeType?: string | 'dark' | 'light';
|
|
6
|
+
};
|
|
7
|
+
declare const HuiProvider: React.FC<PropsWithChildren<UiProviderProps>>;
|
|
8
|
+
export default HuiProvider;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { HUIThemes } from '../themes/presets';
|
|
3
|
+
export type AllThemesConfig = {
|
|
4
|
+
themes: Array<HUIThemes>;
|
|
5
|
+
};
|
|
6
|
+
export declare const AllThemesContext: React.Context<AllThemesConfig>;
|
|
7
|
+
export declare const useAllThemes: () => AllThemesConfig;
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
function _defineProperty(e, r, t) {
|
|
8
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
9
|
+
value: t,
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
writable: true
|
|
13
|
+
}) : e[r] = t, e;
|
|
14
|
+
}
|
|
15
|
+
function ownKeys(e, r) {
|
|
16
|
+
var t = Object.keys(e);
|
|
17
|
+
if (Object.getOwnPropertySymbols) {
|
|
18
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
19
|
+
r && (o = o.filter(function (r) {
|
|
20
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
21
|
+
})), t.push.apply(t, o);
|
|
22
|
+
}
|
|
23
|
+
return t;
|
|
24
|
+
}
|
|
25
|
+
function _objectSpread2(e) {
|
|
26
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
27
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
28
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
29
|
+
_defineProperty(e, r, t[r]);
|
|
30
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
31
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return e;
|
|
35
|
+
}
|
|
36
|
+
function _toPrimitive(t, r) {
|
|
37
|
+
if ("object" != typeof t || !t) return t;
|
|
38
|
+
var e = t[Symbol.toPrimitive];
|
|
39
|
+
if (void 0 !== e) {
|
|
40
|
+
var i = e.call(t, r);
|
|
41
|
+
if ("object" != typeof i) return i;
|
|
42
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
43
|
+
}
|
|
44
|
+
return ("string" === r ? String : Number)(t);
|
|
45
|
+
}
|
|
46
|
+
function _toPropertyKey(t) {
|
|
47
|
+
var i = _toPrimitive(t, "string");
|
|
48
|
+
return "symbol" == typeof i ? i : i + "";
|
|
49
|
+
}
|
|
50
|
+
function _typeof(o) {
|
|
51
|
+
"@babel/helpers - typeof";
|
|
52
|
+
|
|
53
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
54
|
+
return typeof o;
|
|
55
|
+
} : function (o) {
|
|
56
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
57
|
+
}, _typeof(o);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
var defaultFont = {
|
|
61
|
+
sans: '"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif',
|
|
62
|
+
mono: 'Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace',
|
|
63
|
+
prism: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,"Liberation Mono", "Courier New", monospace'
|
|
64
|
+
};
|
|
65
|
+
var defaultBreakpoints = {
|
|
66
|
+
xs: {
|
|
67
|
+
min: '0',
|
|
68
|
+
max: '650px'
|
|
69
|
+
},
|
|
70
|
+
sm: {
|
|
71
|
+
min: '650px',
|
|
72
|
+
max: '900px'
|
|
73
|
+
},
|
|
74
|
+
md: {
|
|
75
|
+
min: '900px',
|
|
76
|
+
max: '1280px'
|
|
77
|
+
},
|
|
78
|
+
lg: {
|
|
79
|
+
min: '1280px',
|
|
80
|
+
max: '1920px'
|
|
81
|
+
},
|
|
82
|
+
xl: {
|
|
83
|
+
min: '1920px',
|
|
84
|
+
max: '10000px'
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
var defaultLayout = {
|
|
88
|
+
gap: '16pt',
|
|
89
|
+
gapNegative: '-16pt',
|
|
90
|
+
gapHalf: '8pt',
|
|
91
|
+
gapHalfNegative: '-8pt',
|
|
92
|
+
gapQuarter: '4pt',
|
|
93
|
+
gapQuarterNegative: '-4pt',
|
|
94
|
+
pageMargin: '16pt',
|
|
95
|
+
pageWidth: '750pt',
|
|
96
|
+
pageWidthWithMargin: '782pt',
|
|
97
|
+
breakpointMobile: defaultBreakpoints.xs.max,
|
|
98
|
+
breakpointTablet: defaultBreakpoints.sm.max,
|
|
99
|
+
radius: '6px',
|
|
100
|
+
unit: '16px'
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
var palette$1 = {
|
|
104
|
+
accents_1: '#fafafa',
|
|
105
|
+
accents_2: '#eaeaea',
|
|
106
|
+
accents_3: '#999',
|
|
107
|
+
accents_4: '#888',
|
|
108
|
+
accents_5: '#666',
|
|
109
|
+
accents_6: '#444',
|
|
110
|
+
accents_7: '#333',
|
|
111
|
+
accents_8: '#111',
|
|
112
|
+
background: '#fff',
|
|
113
|
+
foreground: '#000',
|
|
114
|
+
selection: '#79ffe1',
|
|
115
|
+
secondary: '#666',
|
|
116
|
+
code: '#f81ce5',
|
|
117
|
+
border: '#eaeaea',
|
|
118
|
+
error: '#e00',
|
|
119
|
+
errorLight: '#ff1a1a',
|
|
120
|
+
errorLighter: '#f7d4d6',
|
|
121
|
+
errorDark: '#c50000',
|
|
122
|
+
success: '#0070f3',
|
|
123
|
+
successLight: '#3291ff',
|
|
124
|
+
successLighter: '#d3e5ff',
|
|
125
|
+
successDark: '#0761d1',
|
|
126
|
+
warning: '#f5a623',
|
|
127
|
+
warningLight: '#f7b955',
|
|
128
|
+
warningLighter: '#ffefcf',
|
|
129
|
+
warningDark: '#ab570a',
|
|
130
|
+
cyan: '#50e3c2',
|
|
131
|
+
cyanLighter: '#aaffec',
|
|
132
|
+
cyanLight: '#79ffe1',
|
|
133
|
+
cyanDark: '#29bc9b',
|
|
134
|
+
violet: '#7928ca',
|
|
135
|
+
violetLighter: '#e3d7fc',
|
|
136
|
+
violetLight: '#8a63d2',
|
|
137
|
+
violetDark: '#4c2889',
|
|
138
|
+
purple: '#f81ce5',
|
|
139
|
+
alert: '#ff0080',
|
|
140
|
+
magenta: '#eb367f',
|
|
141
|
+
link: '#0070f3'
|
|
142
|
+
};
|
|
143
|
+
var expressiveness$1 = {
|
|
144
|
+
linkStyle: 'none',
|
|
145
|
+
linkHoverStyle: 'none',
|
|
146
|
+
dropdownBoxShadow: '0 4px 4px 0 rgba(0, 0, 0, 0.02)',
|
|
147
|
+
scrollerStart: 'rgba(255, 255, 255, 1)',
|
|
148
|
+
scrollerEnd: 'rgba(255, 255, 255, 0)',
|
|
149
|
+
shadowSmall: '0 5px 10px rgba(0, 0, 0, 0.12)',
|
|
150
|
+
shadowMedium: '0 8px 30px rgba(0, 0, 0, 0.12)',
|
|
151
|
+
shadowLarge: '0 30px 60px rgba(0, 0, 0, 0.12)',
|
|
152
|
+
portalOpacity: 0.25
|
|
153
|
+
};
|
|
154
|
+
var font$1 = defaultFont;
|
|
155
|
+
var breakpoints$1 = defaultBreakpoints;
|
|
156
|
+
var layout$1 = defaultLayout;
|
|
157
|
+
var themes$1 = {
|
|
158
|
+
type: 'light',
|
|
159
|
+
font: font$1,
|
|
160
|
+
layout: layout$1,
|
|
161
|
+
palette: palette$1,
|
|
162
|
+
breakpoints: breakpoints$1,
|
|
163
|
+
expressiveness: expressiveness$1
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
var palette = {
|
|
167
|
+
accents_1: '#111',
|
|
168
|
+
accents_2: '#333',
|
|
169
|
+
accents_3: '#444',
|
|
170
|
+
accents_4: '#666',
|
|
171
|
+
accents_5: '#888',
|
|
172
|
+
accents_6: '#999',
|
|
173
|
+
accents_7: '#eaeaea',
|
|
174
|
+
accents_8: '#fafafa',
|
|
175
|
+
background: '#000',
|
|
176
|
+
foreground: '#fff',
|
|
177
|
+
selection: '#f81ce5',
|
|
178
|
+
secondary: '#888',
|
|
179
|
+
code: '#79ffe1',
|
|
180
|
+
border: '#333',
|
|
181
|
+
error: '#e00',
|
|
182
|
+
errorLighter: '#f7d4d6',
|
|
183
|
+
errorLight: '#ff1a1a',
|
|
184
|
+
errorDark: '#c50000',
|
|
185
|
+
success: '#0070f3',
|
|
186
|
+
successLighter: '#d3e5ff',
|
|
187
|
+
successLight: '#3291ff',
|
|
188
|
+
successDark: '#0761d1',
|
|
189
|
+
warning: '#f5a623',
|
|
190
|
+
warningLighter: '#ffefcf',
|
|
191
|
+
warningLight: '#f7b955',
|
|
192
|
+
warningDark: '#ab570a',
|
|
193
|
+
cyan: '#50e3c2',
|
|
194
|
+
cyanLighter: '#aaffec',
|
|
195
|
+
cyanLight: '#79ffe1',
|
|
196
|
+
cyanDark: '#29bc9b',
|
|
197
|
+
violet: '#7928ca',
|
|
198
|
+
violetLighter: '#e3d7fc',
|
|
199
|
+
violetLight: '#8a63d2',
|
|
200
|
+
violetDark: '#4c2889',
|
|
201
|
+
purple: '#f81ce5',
|
|
202
|
+
alert: '#ff0080',
|
|
203
|
+
magenta: '#eb367f',
|
|
204
|
+
link: '#3291ff'
|
|
205
|
+
};
|
|
206
|
+
var expressiveness = {
|
|
207
|
+
linkStyle: 'none',
|
|
208
|
+
linkHoverStyle: 'none',
|
|
209
|
+
dropdownBoxShadow: '0 0 0 1px #333',
|
|
210
|
+
scrollerStart: 'rgba(255, 255, 255, 1)',
|
|
211
|
+
scrollerEnd: 'rgba(255, 255, 255, 0)',
|
|
212
|
+
shadowSmall: '0 0 0 1px #333',
|
|
213
|
+
shadowMedium: '0 0 0 1px #333',
|
|
214
|
+
shadowLarge: '0 0 0 1px #333',
|
|
215
|
+
portalOpacity: 0.75
|
|
216
|
+
};
|
|
217
|
+
var font = defaultFont;
|
|
218
|
+
var breakpoints = defaultBreakpoints;
|
|
219
|
+
var layout = defaultLayout;
|
|
220
|
+
var themes = {
|
|
221
|
+
type: 'dark',
|
|
222
|
+
font: font,
|
|
223
|
+
layout: layout,
|
|
224
|
+
palette: palette,
|
|
225
|
+
breakpoints: breakpoints,
|
|
226
|
+
expressiveness: expressiveness
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
var isObject = function isObject(target) {
|
|
230
|
+
return target && _typeof(target) === 'object';
|
|
231
|
+
};
|
|
232
|
+
var _deepDuplicable = function deepDuplicable(source, target) {
|
|
233
|
+
if (!isObject(target) || !isObject(source)) return source;
|
|
234
|
+
var sourceKeys = Object.keys(source);
|
|
235
|
+
var result = {};
|
|
236
|
+
for (var _i = 0, _sourceKeys = sourceKeys; _i < _sourceKeys.length; _i++) {
|
|
237
|
+
var key = _sourceKeys[_i];
|
|
238
|
+
var sourceValue = source[key];
|
|
239
|
+
var targetValue = target[key];
|
|
240
|
+
if (Array.isArray(sourceValue) && Array.isArray(targetValue)) {
|
|
241
|
+
result[key] = targetValue.concat(sourceValue);
|
|
242
|
+
} else if (isObject(sourceValue) && isObject(targetValue)) {
|
|
243
|
+
result[key] = _deepDuplicable(sourceValue, _objectSpread2({}, targetValue));
|
|
244
|
+
} else if (targetValue) {
|
|
245
|
+
result[key] = targetValue;
|
|
246
|
+
} else {
|
|
247
|
+
result[key] = sourceValue;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return result;
|
|
251
|
+
};
|
|
252
|
+
var getPresets = function getPresets() {
|
|
253
|
+
return [themes$1, themes];
|
|
254
|
+
};
|
|
255
|
+
var getPresetStaticTheme = function getPresetStaticTheme() {
|
|
256
|
+
return themes$1;
|
|
257
|
+
};
|
|
258
|
+
var isAvailableThemeType = function isAvailableThemeType(type) {
|
|
259
|
+
if (!type) return false;
|
|
260
|
+
var presetThemes = getPresets();
|
|
261
|
+
var hasType = presetThemes.find(function (theme) {
|
|
262
|
+
return theme.type === type;
|
|
263
|
+
});
|
|
264
|
+
return !hasType;
|
|
265
|
+
};
|
|
266
|
+
var isPresetTheme = function isPresetTheme(themeOrType) {
|
|
267
|
+
if (!themeOrType) return false;
|
|
268
|
+
var isType = typeof themeOrType === 'string';
|
|
269
|
+
var type = isType ? themeOrType : themeOrType.type;
|
|
270
|
+
return !isAvailableThemeType(type);
|
|
271
|
+
};
|
|
272
|
+
var hasUserCustomTheme = function hasUserCustomTheme() {
|
|
273
|
+
var themes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
274
|
+
return !!themes.find(function (item) {
|
|
275
|
+
return isAvailableThemeType(item.type);
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
var create = function create(base, custom) {
|
|
279
|
+
if (!isAvailableThemeType(custom.type)) {
|
|
280
|
+
throw new Error('Duplicate or unavailable theme type');
|
|
281
|
+
}
|
|
282
|
+
return _deepDuplicable(base, custom);
|
|
283
|
+
};
|
|
284
|
+
var createFromDark = function createFromDark(custom) {
|
|
285
|
+
return create(themes, custom);
|
|
286
|
+
};
|
|
287
|
+
var createFromLight = function createFromLight(custom) {
|
|
288
|
+
return create(themes$1, custom);
|
|
289
|
+
};
|
|
290
|
+
var Themes = {
|
|
291
|
+
isPresetTheme: isPresetTheme,
|
|
292
|
+
isAvailableThemeType: isAvailableThemeType,
|
|
293
|
+
hasUserCustomTheme: hasUserCustomTheme,
|
|
294
|
+
getPresets: getPresets,
|
|
295
|
+
getPresetStaticTheme: getPresetStaticTheme,
|
|
296
|
+
create: create,
|
|
297
|
+
createFromDark: createFromDark,
|
|
298
|
+
createFromLight: createFromLight
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
/* "use client" */
|
|
302
|
+
|
|
303
|
+
var defaultAllThemesConfig = {
|
|
304
|
+
themes: Themes.getPresets()
|
|
305
|
+
};
|
|
306
|
+
var AllThemesContext = /*#__PURE__*/React.createContext(defaultAllThemesConfig);
|
|
307
|
+
var useAllThemes = function useAllThemes() {
|
|
308
|
+
return React.useContext(AllThemesContext);
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
exports.default = useAllThemes;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function _typeof(o) {
|
|
6
|
+
"@babel/helpers - typeof";
|
|
7
|
+
|
|
8
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
9
|
+
return typeof o;
|
|
10
|
+
} : function (o) {
|
|
11
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
12
|
+
}, _typeof(o);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/* "use client" */
|
|
16
|
+
|
|
17
|
+
var classObjectToString = function classObjectToString(className) {
|
|
18
|
+
var keys = Object.keys(className);
|
|
19
|
+
var len = keys.length;
|
|
20
|
+
var str = '';
|
|
21
|
+
for (var index = 0; index < len; index++) {
|
|
22
|
+
var key = keys[index];
|
|
23
|
+
var val = className[keys[index]];
|
|
24
|
+
if (!val) continue;
|
|
25
|
+
str = str ? "".concat(str, " ").concat(String(key)) : String(key);
|
|
26
|
+
}
|
|
27
|
+
return str;
|
|
28
|
+
};
|
|
29
|
+
var isObjectClassName = function isObjectClassName(value) {
|
|
30
|
+
return _typeof(value) === 'object' && !Array.isArray(value);
|
|
31
|
+
};
|
|
32
|
+
var useClasses = function useClasses() {
|
|
33
|
+
var len = arguments.length;
|
|
34
|
+
var classes = '';
|
|
35
|
+
if (len === 0) return classes;
|
|
36
|
+
for (var index = 0; index < len; index++) {
|
|
37
|
+
var val = index < 0 || arguments.length <= index ? undefined : arguments[index];
|
|
38
|
+
if (!val) continue;
|
|
39
|
+
if (isObjectClassName(val)) {
|
|
40
|
+
classes += " ".concat(classObjectToString(val));
|
|
41
|
+
} else {
|
|
42
|
+
classes += " ".concat(String(val).trim());
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return classes.trim();
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports.default = useClasses;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type classNamesObject = Record<string, boolean | string | number | null | undefined>;
|
|
2
|
+
export type className = string | classNamesObject | null | undefined | boolean | number;
|
|
3
|
+
declare const useClasses: (...classNames: Array<className>) => string;
|
|
4
|
+
export default useClasses;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var react = require('react');
|
|
6
|
+
|
|
7
|
+
function _arrayLikeToArray(r, a) {
|
|
8
|
+
(null == a || a > r.length) && (a = r.length);
|
|
9
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
10
|
+
return n;
|
|
11
|
+
}
|
|
12
|
+
function _arrayWithHoles(r) {
|
|
13
|
+
if (Array.isArray(r)) return r;
|
|
14
|
+
}
|
|
15
|
+
function _iterableToArrayLimit(r, l) {
|
|
16
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
17
|
+
if (null != t) {
|
|
18
|
+
var e,
|
|
19
|
+
n,
|
|
20
|
+
i,
|
|
21
|
+
u,
|
|
22
|
+
a = [],
|
|
23
|
+
f = true,
|
|
24
|
+
o = false;
|
|
25
|
+
try {
|
|
26
|
+
if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
27
|
+
} catch (r) {
|
|
28
|
+
o = true, n = r;
|
|
29
|
+
} finally {
|
|
30
|
+
try {
|
|
31
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
32
|
+
} finally {
|
|
33
|
+
if (o) throw n;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return a;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function _nonIterableRest() {
|
|
40
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
41
|
+
}
|
|
42
|
+
function _slicedToArray(r, e) {
|
|
43
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
44
|
+
}
|
|
45
|
+
function _unsupportedIterableToArray(r, a) {
|
|
46
|
+
if (r) {
|
|
47
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
48
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
49
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
var useCurrentState = function useCurrentState(initialState) {
|
|
54
|
+
var _useState = react.useState(function () {
|
|
55
|
+
return typeof initialState === 'function' ? initialState() : initialState;
|
|
56
|
+
}),
|
|
57
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
58
|
+
state = _useState2[0],
|
|
59
|
+
setState = _useState2[1];
|
|
60
|
+
var ref = react.useRef(initialState);
|
|
61
|
+
react.useEffect(function () {
|
|
62
|
+
ref.current = state;
|
|
63
|
+
}, [state]);
|
|
64
|
+
var setValue = function setValue(val) {
|
|
65
|
+
var result = typeof val === 'function' ? val(ref.current) : val;
|
|
66
|
+
ref.current = result;
|
|
67
|
+
setState(result);
|
|
68
|
+
};
|
|
69
|
+
return [state, setValue, ref];
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
exports.default = useCurrentState;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Dispatch, MutableRefObject, SetStateAction } from 'react';
|
|
2
|
+
export type CurrentStateType<S> = [S, Dispatch<SetStateAction<S>>, MutableRefObject<S>];
|
|
3
|
+
declare const useCurrentState: <S>(initialState: S | (() => S)) => CurrentStateType<S>;
|
|
4
|
+
export default useCurrentState;
|