@easypost/easy-ui 1.0.0-alpha.4 → 1.0.0-alpha.6
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/Badge/index.js +32 -26
- package/Badge/index.mjs +32 -26
- package/Banner/index.js +15 -16
- package/Banner/index.mjs +15 -16
- package/Button/Button.d.ts +61 -0
- package/Button/Button.d.ts.map +1 -1
- package/Button/index.js +34 -69
- package/Button/index.mjs +33 -68
- package/CHANGELOG.md +21 -0
- package/Card/index.js +84 -5
- package/Card/index.mjs +84 -5
- package/Checkbox/index.js +84 -72
- package/Checkbox/index.mjs +84 -72
- package/CodeBlock/index.js +43 -49
- package/CodeBlock/index.mjs +43 -49
- package/DropdownButton/DropdownButton.d.ts +48 -0
- package/DropdownButton/DropdownButton.d.ts.map +1 -1
- package/DropdownButton/index.js +29 -101
- package/DropdownButton/index.mjs +29 -85
- package/HorizontalGrid/index.js +11 -31
- package/HorizontalGrid/index.mjs +11 -31
- package/HorizontalStack/index.js +48 -4
- package/HorizontalStack/index.mjs +48 -4
- package/Icon/Icon.d.ts +51 -0
- package/Icon/Icon.d.ts.map +1 -1
- package/Icon/index.js +38 -4
- package/Icon/index.mjs +38 -4
- package/IconButton/IconButton.d.ts +62 -0
- package/IconButton/IconButton.d.ts.map +1 -1
- package/IconButton/index.js +26 -43
- package/IconButton/index.mjs +25 -42
- package/InputField/Label.d.ts +2 -2
- package/InputField/index.js +282 -10
- package/InputField/index.mjs +266 -10
- package/InputField/utilities.d.ts +1 -1
- package/InputField/utilities.d.ts.map +1 -1
- package/Menu/MenuOverlay.d.ts.map +1 -1
- package/Menu/index.js +178 -1958
- package/Menu/index.mjs +168 -1948
- package/Menu/utilities.d.ts +11 -0
- package/Menu/utilities.d.ts.map +1 -0
- package/Notification/index.js +1534 -14
- package/Notification/index.mjs +1518 -14
- package/Provider/index.js +15 -15
- package/Provider/index.mjs +15 -15
- package/RadioGroup/index.js +63 -63
- package/RadioGroup/index.mjs +63 -63
- package/Select/Select.d.ts +88 -0
- package/Select/Select.d.ts.map +1 -0
- package/Select/Select.stories.d.ts +17 -0
- package/Select/Select.stories.d.ts.map +1 -0
- package/Select/Select.test.d.ts +2 -0
- package/Select/Select.test.d.ts.map +1 -0
- package/Select/SelectContext.d.ts +14 -0
- package/Select/SelectContext.d.ts.map +1 -0
- package/Select/SelectField.d.ts +62 -0
- package/Select/SelectField.d.ts.map +1 -0
- package/Select/SelectOption.d.ts +23 -0
- package/Select/SelectOption.d.ts.map +1 -0
- package/Select/SelectOverlay.d.ts +3 -0
- package/Select/SelectOverlay.d.ts.map +1 -0
- package/Select/SelectSection.d.ts +22 -0
- package/Select/SelectSection.d.ts.map +1 -0
- package/Select/SelectTrigger.d.ts +30 -0
- package/Select/SelectTrigger.d.ts.map +1 -0
- package/Select/index.d.ts +2 -0
- package/Select/index.d.ts.map +1 -0
- package/Select/index.js +816 -0
- package/Select/index.mjs +816 -0
- package/SelectorErrorTooltip/index.js +102 -11
- package/SelectorErrorTooltip/index.mjs +86 -11
- package/Text/index.js +85 -4
- package/Text/index.mjs +85 -4
- package/TextField/index.js +19 -38
- package/TextField/index.mjs +19 -38
- package/Textarea/index.js +20 -37
- package/Textarea/index.mjs +20 -37
- package/Theme/index.js +145 -9
- package/Theme/index.mjs +145 -9
- package/Toggle/index.js +51 -50
- package/Toggle/index.mjs +51 -50
- package/Tooltip/index.js +299 -10
- package/Tooltip/index.mjs +299 -10
- package/UnstyledButton/index.js +4 -4
- package/UnstyledButton/index.mjs +3 -3
- package/VerticalStack/index.js +13 -47
- package/VerticalStack/index.mjs +13 -47
- package/__chunks__/ExpandMore400-7c5263a4.mjs +49 -0
- package/__chunks__/ExpandMore400-92646971.js +65 -0
- package/__chunks__/InputIcon-2317befd.mjs +148 -0
- package/__chunks__/InputIcon-d3963cf8.js +147 -0
- package/__chunks__/{import-e7f45c7e.mjs → import-0561e1ba.mjs} +3 -3
- package/__chunks__/{import-b7971a11.mjs → import-19bc38ac.mjs} +72 -34
- package/__chunks__/{import-01299af6.js → import-24a482e1.js} +3 -2
- package/__chunks__/{import-baa3cd0c.mjs → import-29af6941.mjs} +4 -3
- package/__chunks__/{import-0d1b4d93.js → import-2b302763.js} +193 -141
- package/__chunks__/{import-ab878fb6.mjs → import-3d962a94.mjs} +205 -153
- package/__chunks__/{import-86330a7c.mjs → import-6a831ca1.mjs} +16 -15
- package/__chunks__/{import-7545401a.js → import-8b6c0bc7.js} +3 -3
- package/__chunks__/{import-63bf0645.js → import-a1e0f814.js} +47 -9
- package/__chunks__/{import-3ab42f86.js → import-a2023d8f.js} +35 -22
- package/__chunks__/{import-76076ca6.js → import-dea5a24d.js} +15 -14
- package/__chunks__/{import-856e0385.mjs → import-f1f4792a.mjs} +36 -23
- package/__chunks__/{UnstyledButton-883f0c6c.mjs → index-29d7bca9.mjs} +17 -42
- package/__chunks__/{UnstyledButton-96172ec0.js → index-3985350a.js} +17 -42
- package/__chunks__/{overlayscrollbars-react.es-c8369a03.mjs → overlayscrollbars-react.es-7f332a3b.mjs} +4 -4
- package/__chunks__/{overlayscrollbars-react.es-20563393.js → overlayscrollbars-react.es-f2a0bcff.js} +4 -4
- package/__chunks__/{real-module-e4cd2301.mjs → real-module-515df21d.mjs} +1 -1
- package/__chunks__/{real-module-ae2a4342.js → real-module-e36b1436.js} +1 -1
- package/__chunks__/useTriggerWidth-156b038a.js +2030 -0
- package/__chunks__/useTriggerWidth-addcd1d6.mjs +2031 -0
- package/package.json +11 -11
- package/style.css +1423 -1196
- package/utilities/css.js +14 -58
- package/utilities/css.mjs +14 -58
- package/__chunks__/Card-7bbd41e0.mjs +0 -110
- package/__chunks__/Card-dac53c75.js +0 -109
- package/__chunks__/HorizontalStack-a441c63f.mjs +0 -80
- package/__chunks__/HorizontalStack-a862839b.js +0 -79
- package/__chunks__/Icon-3d00481a.js +0 -44
- package/__chunks__/Icon-a75b5201.mjs +0 -45
- package/__chunks__/InputField-4fbaae06.js +0 -487
- package/__chunks__/InputField-a272f602.mjs +0 -472
- package/__chunks__/Notification-b8eafec6.mjs +0 -1456
- package/__chunks__/Notification-c5b34eb3.js +0 -1471
- package/__chunks__/SelectorErrorTooltip-43c5e29e.js +0 -84
- package/__chunks__/SelectorErrorTooltip-b6204987.mjs +0 -69
- package/__chunks__/Text-1ae70c19.js +0 -102
- package/__chunks__/Text-4ae50d5c.mjs +0 -103
- package/__chunks__/Theme-4e498252.mjs +0 -132
- package/__chunks__/Theme-751e5575.js +0 -131
- package/__chunks__/Tooltip-bd55165e.js +0 -317
- package/__chunks__/Tooltip-f7e67b21.mjs +0 -318
package/Textarea/index.mjs
CHANGED
|
@@ -1,50 +1,33 @@
|
|
|
1
1
|
import React__default from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { InputField } from "../InputField/index.mjs";
|
|
3
3
|
import "../utilities/css.mjs";
|
|
4
|
-
import "../__chunks__/
|
|
5
|
-
import "../
|
|
6
|
-
import "../
|
|
7
|
-
import "../__chunks__/
|
|
4
|
+
import "../__chunks__/InputIcon-2317befd.mjs";
|
|
5
|
+
import "../Text/index.mjs";
|
|
6
|
+
import "../Icon/index.mjs";
|
|
7
|
+
import "../__chunks__/index-29d7bca9.mjs";
|
|
8
|
+
import "../__chunks__/import-19bc38ac.mjs";
|
|
8
9
|
import "../__chunks__/omit-f17deb8f.mjs";
|
|
9
|
-
import "../__chunks__/import-
|
|
10
|
-
import "../__chunks__/import-
|
|
10
|
+
import "../__chunks__/import-3d962a94.mjs";
|
|
11
|
+
import "../__chunks__/import-29af6941.mjs";
|
|
11
12
|
function Textarea(props) {
|
|
12
|
-
const {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
const { size = "md", isLabelVisuallyHidden = false, isDisabled = false, isRequired = false, validationState = "valid", isLabelEmphasized = false, autoFocus = false, label, errorText, helperText, placeholder, value, defaultValue, rows = 1 } = props;
|
|
14
|
+
return React__default.createElement(InputField, {
|
|
15
|
+
isMultiline: true,
|
|
16
|
+
size,
|
|
17
|
+
isLabelVisuallyHidden,
|
|
18
|
+
isDisabled,
|
|
19
|
+
isRequired,
|
|
20
|
+
validationState,
|
|
21
|
+
isLabelEmphasized,
|
|
22
|
+
autoFocus,
|
|
20
23
|
label,
|
|
21
24
|
errorText,
|
|
22
25
|
helperText,
|
|
23
26
|
placeholder,
|
|
24
27
|
value,
|
|
25
28
|
defaultValue,
|
|
26
|
-
rows
|
|
27
|
-
}
|
|
28
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
29
|
-
InputField,
|
|
30
|
-
{
|
|
31
|
-
isMultiline: true,
|
|
32
|
-
size,
|
|
33
|
-
isLabelVisuallyHidden,
|
|
34
|
-
isDisabled,
|
|
35
|
-
isRequired,
|
|
36
|
-
validationState,
|
|
37
|
-
isLabelEmphasized,
|
|
38
|
-
autoFocus,
|
|
39
|
-
label,
|
|
40
|
-
errorText,
|
|
41
|
-
helperText,
|
|
42
|
-
placeholder,
|
|
43
|
-
value,
|
|
44
|
-
defaultValue,
|
|
45
|
-
rows
|
|
46
|
-
}
|
|
47
|
-
);
|
|
29
|
+
rows
|
|
30
|
+
});
|
|
48
31
|
}
|
|
49
32
|
export {
|
|
50
33
|
Textarea
|
package/Theme/index.js
CHANGED
|
@@ -1,11 +1,147 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
require("
|
|
5
|
-
require("../
|
|
6
|
-
require("../utilities/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const tokens = require("../__chunks__/tokens-e696ca96.js");
|
|
5
|
+
const utilities_tokens = require("../utilities/tokens.js");
|
|
6
|
+
const utilities_css = require("../utilities/css.js");
|
|
7
|
+
const defaultTheme = createTheme(() => {
|
|
8
|
+
return getThemeFromTokens("theme.base");
|
|
9
|
+
});
|
|
10
|
+
const invertedColorSchemes = {
|
|
11
|
+
light: "dark",
|
|
12
|
+
dark: "light",
|
|
13
|
+
system: "inverted",
|
|
14
|
+
inverted: "system"
|
|
15
|
+
};
|
|
16
|
+
function NoopComponent(props) {
|
|
17
|
+
return React.createElement(React.Fragment, null, props.children);
|
|
18
|
+
}
|
|
19
|
+
const TrackerContext = React.createContext(0);
|
|
20
|
+
const ThemeContext = React.createContext(null);
|
|
21
|
+
const ColorSchemeContext = React.createContext(null);
|
|
22
|
+
function ThemeProvider({ children, colorScheme: colorSchemeFromUser, theme: themeFromUser }) {
|
|
23
|
+
const parentTheme = React.useContext(ThemeContext);
|
|
24
|
+
const isRoot = !parentTheme;
|
|
25
|
+
if (!isRoot && !themeFromUser && !colorSchemeFromUser) {
|
|
26
|
+
throw new Error("Must supply theme or colorScheme to ThemeProvider");
|
|
27
|
+
}
|
|
28
|
+
const parentContext = React.useContext(TrackerContext);
|
|
29
|
+
const [count] = React.useState(() => parentContext + 1);
|
|
30
|
+
const ThemeContextComponent = isRoot || themeFromUser ? ThemeContextProvider : NoopComponent;
|
|
31
|
+
const ColorSchemeContextComponent = isRoot || colorSchemeFromUser ? ColorSchemeContextProvider : NoopComponent;
|
|
32
|
+
const theme = themeFromUser ? themeFromUser : defaultTheme;
|
|
33
|
+
const colorScheme = colorSchemeFromUser ? colorSchemeFromUser : "system";
|
|
34
|
+
return React.createElement(TrackerContext.Provider, {
|
|
35
|
+
value: count
|
|
36
|
+
}, React.createElement(ThemeContextComponent, {
|
|
37
|
+
theme
|
|
38
|
+
}, React.createElement(ColorSchemeContextComponent, {
|
|
39
|
+
colorScheme
|
|
40
|
+
}, React.createElement(React.Fragment, null, React.createElement(Style, {
|
|
41
|
+
isRoot
|
|
42
|
+
}), children))));
|
|
43
|
+
}
|
|
44
|
+
function createTheme(themeCreator) {
|
|
45
|
+
return themeCreator;
|
|
46
|
+
}
|
|
47
|
+
function useTheme() {
|
|
48
|
+
const themeContext = React.useContext(ThemeContext);
|
|
49
|
+
if (!themeContext) {
|
|
50
|
+
throw new Error("useTheme() must be used within a ThemeProvier");
|
|
51
|
+
}
|
|
52
|
+
return themeContext;
|
|
53
|
+
}
|
|
54
|
+
function useColorScheme() {
|
|
55
|
+
const colorSchemeContext = React.useContext(ColorSchemeContext);
|
|
56
|
+
if (!colorSchemeContext) {
|
|
57
|
+
throw new Error("useColorScheme() must be used within a ThemeProvider");
|
|
58
|
+
}
|
|
59
|
+
return colorSchemeContext;
|
|
60
|
+
}
|
|
61
|
+
function Style({ isRoot }) {
|
|
62
|
+
const parentContext = React.useContext(TrackerContext);
|
|
63
|
+
const themeCreator = useTheme();
|
|
64
|
+
const { resolvedColorScheme } = useColorScheme();
|
|
65
|
+
const fingerprint = React.useMemo(() => {
|
|
66
|
+
return `ezui-theme-style-level-${parentContext}`;
|
|
67
|
+
}, [parentContext]);
|
|
68
|
+
const selector = isRoot ? ":root" : `#${fingerprint} ~ *`;
|
|
69
|
+
const css = React.useMemo(() => {
|
|
70
|
+
return resolvedColorScheme === "system" ? `${selector} {
|
|
71
|
+
${renderThemeVariables(themeCreator({
|
|
72
|
+
colorScheme: "light"
|
|
73
|
+
}))}
|
|
74
|
+
}
|
|
75
|
+
@media (prefers-color-scheme: dark) {
|
|
76
|
+
${selector} {
|
|
77
|
+
${renderThemeVariables(themeCreator({
|
|
78
|
+
colorScheme: "dark"
|
|
79
|
+
}))}
|
|
80
|
+
}
|
|
81
|
+
}` : resolvedColorScheme === "inverted" ? `${selector} {
|
|
82
|
+
${renderThemeVariables(themeCreator({
|
|
83
|
+
colorScheme: "dark"
|
|
84
|
+
}))}
|
|
85
|
+
}
|
|
86
|
+
@media (prefers-color-scheme: dark) {
|
|
87
|
+
${selector} {
|
|
88
|
+
${renderThemeVariables(themeCreator({
|
|
89
|
+
colorScheme: "light"
|
|
90
|
+
}))}
|
|
91
|
+
}
|
|
92
|
+
}` : `${selector} {
|
|
93
|
+
${renderThemeVariables(themeCreator({
|
|
94
|
+
colorScheme: resolvedColorScheme
|
|
95
|
+
}))}
|
|
96
|
+
}`;
|
|
97
|
+
}, [resolvedColorScheme, selector, themeCreator]);
|
|
98
|
+
return React.createElement("style", {
|
|
99
|
+
id: fingerprint,
|
|
100
|
+
dangerouslySetInnerHTML: {
|
|
101
|
+
__html: css
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function ThemeContextProvider({ theme, children }) {
|
|
106
|
+
return React.createElement(ThemeContext.Provider, {
|
|
107
|
+
value: theme
|
|
108
|
+
}, children);
|
|
109
|
+
}
|
|
110
|
+
function ColorSchemeContextProvider({ colorScheme, children }) {
|
|
111
|
+
const parentColorSchemeContext = React.useContext(ColorSchemeContext);
|
|
112
|
+
const colorSchemeContextValue = React.useMemo(() => {
|
|
113
|
+
const resolvedColorScheme = colorScheme === "inverted" && parentColorSchemeContext ? invertedColorSchemes[parentColorSchemeContext.resolvedColorScheme] : colorScheme;
|
|
114
|
+
return {
|
|
115
|
+
userColorScheme: colorScheme,
|
|
116
|
+
resolvedColorScheme
|
|
117
|
+
};
|
|
118
|
+
}, [colorScheme, parentColorSchemeContext]);
|
|
119
|
+
return React.createElement(ColorSchemeContext.Provider, {
|
|
120
|
+
value: colorSchemeContextValue
|
|
121
|
+
}, children);
|
|
122
|
+
}
|
|
123
|
+
function getThemeInstanceVariables(theme) {
|
|
124
|
+
return Object.fromEntries(Object.entries(theme).map(([key, value]) => {
|
|
125
|
+
const property = utilities_css.tokenSafeKebabCase(key);
|
|
126
|
+
return [`--ezui-t-${property}`, value];
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
129
|
+
function renderThemeVariables(theme) {
|
|
130
|
+
const variables = getThemeInstanceVariables(theme);
|
|
131
|
+
const css = Object.entries(variables).map((entry) => entry.join(": ") + ";").join("\n");
|
|
132
|
+
return css;
|
|
133
|
+
}
|
|
134
|
+
function getThemeFromTokens(prefix) {
|
|
135
|
+
const theme = Object.fromEntries(Object.keys(tokens.ezuiTokens).filter((key) => key.startsWith(`${prefix}.`)).map((key) => key.replace(new RegExp(`^${prefix}.`), "")).map((key) => {
|
|
136
|
+
const value = `var(--ezui-${utilities_css.tokenSafeKebabCase(prefix)}-${utilities_css.tokenSafeKebabCase(key)})`;
|
|
137
|
+
return [key, value];
|
|
138
|
+
}));
|
|
139
|
+
return theme;
|
|
140
|
+
}
|
|
141
|
+
function getThemeTokenAliases(pattern) {
|
|
142
|
+
return utilities_tokens.getTokenAliases(getThemeFromTokens("theme.base"), pattern);
|
|
143
|
+
}
|
|
144
|
+
exports.ThemeProvider = ThemeProvider;
|
|
145
|
+
exports.createTheme = createTheme;
|
|
146
|
+
exports.defaultTheme = defaultTheme;
|
|
147
|
+
exports.getThemeTokenAliases = getThemeTokenAliases;
|
package/Theme/index.mjs
CHANGED
|
@@ -1,11 +1,147 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "
|
|
3
|
-
import "../
|
|
4
|
-
import "../utilities/
|
|
5
|
-
|
|
1
|
+
import React__default, { createContext, useContext, useState, useMemo } from "react";
|
|
2
|
+
import { e as ezuiTokens } from "../__chunks__/tokens-6be8e137.mjs";
|
|
3
|
+
import { getTokenAliases } from "../utilities/tokens.mjs";
|
|
4
|
+
import { tokenSafeKebabCase } from "../utilities/css.mjs";
|
|
5
|
+
const defaultTheme = createTheme(() => {
|
|
6
|
+
return getThemeFromTokens("theme.base");
|
|
7
|
+
});
|
|
8
|
+
const invertedColorSchemes = {
|
|
9
|
+
light: "dark",
|
|
10
|
+
dark: "light",
|
|
11
|
+
system: "inverted",
|
|
12
|
+
inverted: "system"
|
|
13
|
+
};
|
|
14
|
+
function NoopComponent(props) {
|
|
15
|
+
return React__default.createElement(React__default.Fragment, null, props.children);
|
|
16
|
+
}
|
|
17
|
+
const TrackerContext = createContext(0);
|
|
18
|
+
const ThemeContext = createContext(null);
|
|
19
|
+
const ColorSchemeContext = createContext(null);
|
|
20
|
+
function ThemeProvider({ children, colorScheme: colorSchemeFromUser, theme: themeFromUser }) {
|
|
21
|
+
const parentTheme = useContext(ThemeContext);
|
|
22
|
+
const isRoot = !parentTheme;
|
|
23
|
+
if (!isRoot && !themeFromUser && !colorSchemeFromUser) {
|
|
24
|
+
throw new Error("Must supply theme or colorScheme to ThemeProvider");
|
|
25
|
+
}
|
|
26
|
+
const parentContext = useContext(TrackerContext);
|
|
27
|
+
const [count] = useState(() => parentContext + 1);
|
|
28
|
+
const ThemeContextComponent = isRoot || themeFromUser ? ThemeContextProvider : NoopComponent;
|
|
29
|
+
const ColorSchemeContextComponent = isRoot || colorSchemeFromUser ? ColorSchemeContextProvider : NoopComponent;
|
|
30
|
+
const theme = themeFromUser ? themeFromUser : defaultTheme;
|
|
31
|
+
const colorScheme = colorSchemeFromUser ? colorSchemeFromUser : "system";
|
|
32
|
+
return React__default.createElement(TrackerContext.Provider, {
|
|
33
|
+
value: count
|
|
34
|
+
}, React__default.createElement(ThemeContextComponent, {
|
|
35
|
+
theme
|
|
36
|
+
}, React__default.createElement(ColorSchemeContextComponent, {
|
|
37
|
+
colorScheme
|
|
38
|
+
}, React__default.createElement(React__default.Fragment, null, React__default.createElement(Style, {
|
|
39
|
+
isRoot
|
|
40
|
+
}), children))));
|
|
41
|
+
}
|
|
42
|
+
function createTheme(themeCreator) {
|
|
43
|
+
return themeCreator;
|
|
44
|
+
}
|
|
45
|
+
function useTheme() {
|
|
46
|
+
const themeContext = useContext(ThemeContext);
|
|
47
|
+
if (!themeContext) {
|
|
48
|
+
throw new Error("useTheme() must be used within a ThemeProvier");
|
|
49
|
+
}
|
|
50
|
+
return themeContext;
|
|
51
|
+
}
|
|
52
|
+
function useColorScheme() {
|
|
53
|
+
const colorSchemeContext = useContext(ColorSchemeContext);
|
|
54
|
+
if (!colorSchemeContext) {
|
|
55
|
+
throw new Error("useColorScheme() must be used within a ThemeProvider");
|
|
56
|
+
}
|
|
57
|
+
return colorSchemeContext;
|
|
58
|
+
}
|
|
59
|
+
function Style({ isRoot }) {
|
|
60
|
+
const parentContext = useContext(TrackerContext);
|
|
61
|
+
const themeCreator = useTheme();
|
|
62
|
+
const { resolvedColorScheme } = useColorScheme();
|
|
63
|
+
const fingerprint = useMemo(() => {
|
|
64
|
+
return `ezui-theme-style-level-${parentContext}`;
|
|
65
|
+
}, [parentContext]);
|
|
66
|
+
const selector = isRoot ? ":root" : `#${fingerprint} ~ *`;
|
|
67
|
+
const css = useMemo(() => {
|
|
68
|
+
return resolvedColorScheme === "system" ? `${selector} {
|
|
69
|
+
${renderThemeVariables(themeCreator({
|
|
70
|
+
colorScheme: "light"
|
|
71
|
+
}))}
|
|
72
|
+
}
|
|
73
|
+
@media (prefers-color-scheme: dark) {
|
|
74
|
+
${selector} {
|
|
75
|
+
${renderThemeVariables(themeCreator({
|
|
76
|
+
colorScheme: "dark"
|
|
77
|
+
}))}
|
|
78
|
+
}
|
|
79
|
+
}` : resolvedColorScheme === "inverted" ? `${selector} {
|
|
80
|
+
${renderThemeVariables(themeCreator({
|
|
81
|
+
colorScheme: "dark"
|
|
82
|
+
}))}
|
|
83
|
+
}
|
|
84
|
+
@media (prefers-color-scheme: dark) {
|
|
85
|
+
${selector} {
|
|
86
|
+
${renderThemeVariables(themeCreator({
|
|
87
|
+
colorScheme: "light"
|
|
88
|
+
}))}
|
|
89
|
+
}
|
|
90
|
+
}` : `${selector} {
|
|
91
|
+
${renderThemeVariables(themeCreator({
|
|
92
|
+
colorScheme: resolvedColorScheme
|
|
93
|
+
}))}
|
|
94
|
+
}`;
|
|
95
|
+
}, [resolvedColorScheme, selector, themeCreator]);
|
|
96
|
+
return React__default.createElement("style", {
|
|
97
|
+
id: fingerprint,
|
|
98
|
+
dangerouslySetInnerHTML: {
|
|
99
|
+
__html: css
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function ThemeContextProvider({ theme, children }) {
|
|
104
|
+
return React__default.createElement(ThemeContext.Provider, {
|
|
105
|
+
value: theme
|
|
106
|
+
}, children);
|
|
107
|
+
}
|
|
108
|
+
function ColorSchemeContextProvider({ colorScheme, children }) {
|
|
109
|
+
const parentColorSchemeContext = useContext(ColorSchemeContext);
|
|
110
|
+
const colorSchemeContextValue = useMemo(() => {
|
|
111
|
+
const resolvedColorScheme = colorScheme === "inverted" && parentColorSchemeContext ? invertedColorSchemes[parentColorSchemeContext.resolvedColorScheme] : colorScheme;
|
|
112
|
+
return {
|
|
113
|
+
userColorScheme: colorScheme,
|
|
114
|
+
resolvedColorScheme
|
|
115
|
+
};
|
|
116
|
+
}, [colorScheme, parentColorSchemeContext]);
|
|
117
|
+
return React__default.createElement(ColorSchemeContext.Provider, {
|
|
118
|
+
value: colorSchemeContextValue
|
|
119
|
+
}, children);
|
|
120
|
+
}
|
|
121
|
+
function getThemeInstanceVariables(theme) {
|
|
122
|
+
return Object.fromEntries(Object.entries(theme).map(([key, value]) => {
|
|
123
|
+
const property = tokenSafeKebabCase(key);
|
|
124
|
+
return [`--ezui-t-${property}`, value];
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
function renderThemeVariables(theme) {
|
|
128
|
+
const variables = getThemeInstanceVariables(theme);
|
|
129
|
+
const css = Object.entries(variables).map((entry) => entry.join(": ") + ";").join("\n");
|
|
130
|
+
return css;
|
|
131
|
+
}
|
|
132
|
+
function getThemeFromTokens(prefix) {
|
|
133
|
+
const theme = Object.fromEntries(Object.keys(ezuiTokens).filter((key) => key.startsWith(`${prefix}.`)).map((key) => key.replace(new RegExp(`^${prefix}.`), "")).map((key) => {
|
|
134
|
+
const value = `var(--ezui-${tokenSafeKebabCase(prefix)}-${tokenSafeKebabCase(key)})`;
|
|
135
|
+
return [key, value];
|
|
136
|
+
}));
|
|
137
|
+
return theme;
|
|
138
|
+
}
|
|
139
|
+
function getThemeTokenAliases(pattern) {
|
|
140
|
+
return getTokenAliases(getThemeFromTokens("theme.base"), pattern);
|
|
141
|
+
}
|
|
6
142
|
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
143
|
+
ThemeProvider,
|
|
144
|
+
createTheme,
|
|
145
|
+
defaultTheme,
|
|
146
|
+
getThemeTokenAliases
|
|
11
147
|
};
|
package/Toggle/index.js
CHANGED
|
@@ -20,12 +20,12 @@ var __spreadValues = (a, b) => {
|
|
|
20
20
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
21
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
22
22
|
const React = require("react");
|
|
23
|
-
const
|
|
23
|
+
const Text_index = require("../Text/index.js");
|
|
24
24
|
const utilities_css = require("../utilities/css.js");
|
|
25
|
-
const _import = require("../__chunks__/import-
|
|
26
|
-
const _import$1 = require("../__chunks__/import-
|
|
27
|
-
const _import$2 = require("../__chunks__/import-
|
|
28
|
-
require("../__chunks__/import-
|
|
25
|
+
const _import = require("../__chunks__/import-8b6c0bc7.js");
|
|
26
|
+
const _import$1 = require("../__chunks__/import-2b302763.js");
|
|
27
|
+
const _import$2 = require("../__chunks__/import-a1e0f814.js");
|
|
28
|
+
require("../__chunks__/import-dea5a24d.js");
|
|
29
29
|
function $b418ec0c85c52f27$export$d853f7095ae95f88(props, state, ref) {
|
|
30
30
|
let { inputProps, isSelected, isPressed, isDisabled, isReadOnly } = _import.$d2c8e2b0480f3f34$export$cbe85ee05b554577(props, state, ref);
|
|
31
31
|
return {
|
|
@@ -39,13 +39,13 @@ function $b418ec0c85c52f27$export$d853f7095ae95f88(props, state, ref) {
|
|
|
39
39
|
isReadOnly
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
const Switch$1 = "
|
|
43
|
-
const focusVisible = "
|
|
44
|
-
const track = "
|
|
45
|
-
const thumb = "
|
|
46
|
-
const hovered = "
|
|
47
|
-
const disabled = "
|
|
48
|
-
const selected = "
|
|
42
|
+
const Switch$1 = "_Switch_1au2a_5";
|
|
43
|
+
const focusVisible = "_focusVisible_1au2a_13";
|
|
44
|
+
const track = "_track_1au2a_25";
|
|
45
|
+
const thumb = "_thumb_1au2a_29";
|
|
46
|
+
const hovered = "_hovered_1au2a_33";
|
|
47
|
+
const disabled = "_disabled_1au2a_33";
|
|
48
|
+
const selected = "_selected_1au2a_37";
|
|
49
49
|
const styles$1 = {
|
|
50
50
|
Switch: Switch$1,
|
|
51
51
|
focusVisible,
|
|
@@ -57,36 +57,30 @@ const styles$1 = {
|
|
|
57
57
|
};
|
|
58
58
|
function Switch(props) {
|
|
59
59
|
const { isDisabled, isFocusVisible, isHovered, isSelected } = props;
|
|
60
|
-
const className = utilities_css.classNames(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
className: styles$1.thumb,
|
|
81
|
-
cx: isSelected ? 32 - 8 : 8,
|
|
82
|
-
cy: 8,
|
|
83
|
-
r: 6
|
|
84
|
-
}
|
|
85
|
-
)));
|
|
60
|
+
const className = utilities_css.classNames(styles$1.Switch, isDisabled && styles$1.disabled, isFocusVisible && styles$1.focusVisible, isHovered && styles$1.hovered, isSelected && styles$1.selected);
|
|
61
|
+
return React.createElement("span", {
|
|
62
|
+
className
|
|
63
|
+
}, React.createElement("svg", {
|
|
64
|
+
width: 32,
|
|
65
|
+
height: 16,
|
|
66
|
+
"aria-hidden": "true"
|
|
67
|
+
}, React.createElement("rect", {
|
|
68
|
+
className: styles$1.track,
|
|
69
|
+
x: 0,
|
|
70
|
+
y: 0,
|
|
71
|
+
width: 32,
|
|
72
|
+
height: 16,
|
|
73
|
+
rx: 8
|
|
74
|
+
}), React.createElement("circle", {
|
|
75
|
+
className: styles$1.thumb,
|
|
76
|
+
cx: isSelected ? 32 - 8 : 8,
|
|
77
|
+
cy: 8,
|
|
78
|
+
r: 6
|
|
79
|
+
})));
|
|
86
80
|
}
|
|
87
|
-
const Toggle$1 = "
|
|
88
|
-
const text = "
|
|
89
|
-
const input = "
|
|
81
|
+
const Toggle$1 = "_Toggle_sl5qh_5";
|
|
82
|
+
const text = "_text_sl5qh_24";
|
|
83
|
+
const input = "_input_sl5qh_25";
|
|
90
84
|
const styles = {
|
|
91
85
|
Toggle: Toggle$1,
|
|
92
86
|
text,
|
|
@@ -105,14 +99,21 @@ function Toggle(props) {
|
|
|
105
99
|
const RootComponent = children ? "label" : "span";
|
|
106
100
|
const rootProps = children ? hoverProps : {};
|
|
107
101
|
const inputProps = children ? _import$2.$3ef42575df84b30b$export$9d1611c77c2fe928(inputPropsFromSwitch, focusProps) : _import$2.$3ef42575df84b30b$export$9d1611c77c2fe928(inputPropsFromSwitch, focusProps, hoverProps);
|
|
108
|
-
return
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
102
|
+
return React.createElement(RootComponent, __spreadProps(__spreadValues({}, rootProps), {
|
|
103
|
+
className
|
|
104
|
+
}), React.createElement("input", __spreadProps(__spreadValues({}, inputProps), {
|
|
105
|
+
className: styles.input,
|
|
106
|
+
ref
|
|
107
|
+
})), React.createElement(Switch, {
|
|
108
|
+
isDisabled,
|
|
109
|
+
isFocusVisible,
|
|
110
|
+
isHovered,
|
|
111
|
+
isSelected
|
|
112
|
+
}), children && React.createElement("span", {
|
|
113
|
+
className: styles.text
|
|
114
|
+
}, React.createElement(Text_index.Text, {
|
|
115
|
+
variant: "body1",
|
|
116
|
+
color: textColor
|
|
117
|
+
}, children)));
|
|
117
118
|
}
|
|
118
119
|
exports.Toggle = Toggle;
|
package/Toggle/index.mjs
CHANGED
|
@@ -18,12 +18,12 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import React__default from "react";
|
|
21
|
-
import {
|
|
21
|
+
import { Text } from "../Text/index.mjs";
|
|
22
22
|
import { classNames } from "../utilities/css.mjs";
|
|
23
|
-
import { $ as $d2c8e2b0480f3f34$export$cbe85ee05b554577, a as $3017fa7ffdddec74$export$8042c6c013fd5226 } from "../__chunks__/import-
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import "../__chunks__/import-
|
|
23
|
+
import { $ as $d2c8e2b0480f3f34$export$cbe85ee05b554577, a as $3017fa7ffdddec74$export$8042c6c013fd5226 } from "../__chunks__/import-0561e1ba.mjs";
|
|
24
|
+
import { e as $f7dceffc5ad7768b$export$4e328f61c538687f, f as $6179b936705e76d3$export$ae780daf29e6d456 } from "../__chunks__/import-3d962a94.mjs";
|
|
25
|
+
import { a as $3ef42575df84b30b$export$9d1611c77c2fe928 } from "../__chunks__/import-19bc38ac.mjs";
|
|
26
|
+
import "../__chunks__/import-6a831ca1.mjs";
|
|
27
27
|
function $b418ec0c85c52f27$export$d853f7095ae95f88(props, state, ref) {
|
|
28
28
|
let { inputProps, isSelected, isPressed, isDisabled, isReadOnly } = $d2c8e2b0480f3f34$export$cbe85ee05b554577(props, state, ref);
|
|
29
29
|
return {
|
|
@@ -37,13 +37,13 @@ function $b418ec0c85c52f27$export$d853f7095ae95f88(props, state, ref) {
|
|
|
37
37
|
isReadOnly
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
const Switch$1 = "
|
|
41
|
-
const focusVisible = "
|
|
42
|
-
const track = "
|
|
43
|
-
const thumb = "
|
|
44
|
-
const hovered = "
|
|
45
|
-
const disabled = "
|
|
46
|
-
const selected = "
|
|
40
|
+
const Switch$1 = "_Switch_1au2a_5";
|
|
41
|
+
const focusVisible = "_focusVisible_1au2a_13";
|
|
42
|
+
const track = "_track_1au2a_25";
|
|
43
|
+
const thumb = "_thumb_1au2a_29";
|
|
44
|
+
const hovered = "_hovered_1au2a_33";
|
|
45
|
+
const disabled = "_disabled_1au2a_33";
|
|
46
|
+
const selected = "_selected_1au2a_37";
|
|
47
47
|
const styles$1 = {
|
|
48
48
|
Switch: Switch$1,
|
|
49
49
|
focusVisible,
|
|
@@ -55,36 +55,30 @@ const styles$1 = {
|
|
|
55
55
|
};
|
|
56
56
|
function Switch(props) {
|
|
57
57
|
const { isDisabled, isFocusVisible, isHovered, isSelected } = props;
|
|
58
|
-
const className = classNames(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
className: styles$1.thumb,
|
|
79
|
-
cx: isSelected ? 32 - 8 : 8,
|
|
80
|
-
cy: 8,
|
|
81
|
-
r: 6
|
|
82
|
-
}
|
|
83
|
-
)));
|
|
58
|
+
const className = classNames(styles$1.Switch, isDisabled && styles$1.disabled, isFocusVisible && styles$1.focusVisible, isHovered && styles$1.hovered, isSelected && styles$1.selected);
|
|
59
|
+
return React__default.createElement("span", {
|
|
60
|
+
className
|
|
61
|
+
}, React__default.createElement("svg", {
|
|
62
|
+
width: 32,
|
|
63
|
+
height: 16,
|
|
64
|
+
"aria-hidden": "true"
|
|
65
|
+
}, React__default.createElement("rect", {
|
|
66
|
+
className: styles$1.track,
|
|
67
|
+
x: 0,
|
|
68
|
+
y: 0,
|
|
69
|
+
width: 32,
|
|
70
|
+
height: 16,
|
|
71
|
+
rx: 8
|
|
72
|
+
}), React__default.createElement("circle", {
|
|
73
|
+
className: styles$1.thumb,
|
|
74
|
+
cx: isSelected ? 32 - 8 : 8,
|
|
75
|
+
cy: 8,
|
|
76
|
+
r: 6
|
|
77
|
+
})));
|
|
84
78
|
}
|
|
85
|
-
const Toggle$1 = "
|
|
86
|
-
const text = "
|
|
87
|
-
const input = "
|
|
79
|
+
const Toggle$1 = "_Toggle_sl5qh_5";
|
|
80
|
+
const text = "_text_sl5qh_24";
|
|
81
|
+
const input = "_input_sl5qh_25";
|
|
88
82
|
const styles = {
|
|
89
83
|
Toggle: Toggle$1,
|
|
90
84
|
text,
|
|
@@ -103,15 +97,22 @@ function Toggle(props) {
|
|
|
103
97
|
const RootComponent = children ? "label" : "span";
|
|
104
98
|
const rootProps = children ? hoverProps : {};
|
|
105
99
|
const inputProps = children ? $3ef42575df84b30b$export$9d1611c77c2fe928(inputPropsFromSwitch, focusProps) : $3ef42575df84b30b$export$9d1611c77c2fe928(inputPropsFromSwitch, focusProps, hoverProps);
|
|
106
|
-
return
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
100
|
+
return React__default.createElement(RootComponent, __spreadProps(__spreadValues({}, rootProps), {
|
|
101
|
+
className
|
|
102
|
+
}), React__default.createElement("input", __spreadProps(__spreadValues({}, inputProps), {
|
|
103
|
+
className: styles.input,
|
|
104
|
+
ref
|
|
105
|
+
})), React__default.createElement(Switch, {
|
|
106
|
+
isDisabled,
|
|
107
|
+
isFocusVisible,
|
|
108
|
+
isHovered,
|
|
109
|
+
isSelected
|
|
110
|
+
}), children && React__default.createElement("span", {
|
|
111
|
+
className: styles.text
|
|
112
|
+
}, React__default.createElement(Text, {
|
|
113
|
+
variant: "body1",
|
|
114
|
+
color: textColor
|
|
115
|
+
}, children)));
|
|
115
116
|
}
|
|
116
117
|
export {
|
|
117
118
|
Toggle
|