cherry-styled-components 0.2.3 → 0.2.5
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/avatar-dropzone.js +7 -7
- package/dist/dropzone.js +13 -13
- package/dist/icon-button.d.ts +2 -1
- package/dist/icon-button.js +13 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/tabs.d.ts +14 -0
- package/dist/tabs.js +120 -0
- package/dist/theme-toggle.js +10 -10
- package/dist/utils/mixins.js +4 -4
- package/package.json +1 -1
package/dist/avatar-dropzone.js
CHANGED
|
@@ -115,7 +115,7 @@ function LocalAvatarDropzone({ $size, $icon = "User", $maxBytes, "aria-label": a
|
|
|
115
115
|
var AvatarDropzone = /*#__PURE__*/ forwardRef(LocalAvatarDropzone);
|
|
116
116
|
var StyledAvatarDropzoneWrapper = styled.span.withConfig({
|
|
117
117
|
displayName: "avatar-dropzone__StyledAvatarDropzoneWrapper",
|
|
118
|
-
componentId: "sc-
|
|
118
|
+
componentId: "sc-1d7e93ff-0"
|
|
119
119
|
})([
|
|
120
120
|
`position:relative;display:inline-flex;width:`,
|
|
121
121
|
`px;height:`,
|
|
@@ -123,7 +123,7 @@ var StyledAvatarDropzoneWrapper = styled.span.withConfig({
|
|
|
123
123
|
], ({ $size }) => avatarSizes[$size ?? "default"].box, ({ $size }) => avatarSizes[$size ?? "default"].box);
|
|
124
124
|
var StyledAvatarDropzone = styled.button.withConfig({
|
|
125
125
|
displayName: "avatar-dropzone__StyledAvatarDropzone",
|
|
126
|
-
componentId: "sc-
|
|
126
|
+
componentId: "sc-1d7e93ff-1"
|
|
127
127
|
})([
|
|
128
128
|
``,
|
|
129
129
|
`;display:inline-flex;align-items:center;justify-content:center;width:100%;height:100%;border-radius:50%;overflow:hidden;border:2px `,
|
|
@@ -134,9 +134,9 @@ var StyledAvatarDropzone = styled.button.withConfig({
|
|
|
134
134
|
`px;height:`,
|
|
135
135
|
`px;color:`,
|
|
136
136
|
`;}& img{width:100%;height:100%;object-fit:cover;display:block;}`,
|
|
137
|
-
`
|
|
137
|
+
` &:hover:not(:disabled){border-color:`,
|
|
138
138
|
`;background:`,
|
|
139
|
-
`;}
|
|
139
|
+
`;}&:focus{border-color:`,
|
|
140
140
|
`;box-shadow:0 0 0 4px `,
|
|
141
141
|
`;}&:disabled{cursor:not-allowed;opacity:0.6;}`
|
|
142
142
|
], resetButton, ({ $hasImage }) => $hasImage ? "solid" : "dashed", ({ theme }) => theme.colors.grayLight, ({ theme }) => theme.colors.light, ({ theme }) => theme.colors.grayDark, ({ $size }) => avatarSizes[$size ?? "default"].icon, ({ $size }) => avatarSizes[$size ?? "default"].icon, ({ theme }) => theme.colors.primary, ({ theme, $dragOver }) => $dragOver && css([
|
|
@@ -146,12 +146,12 @@ var StyledAvatarDropzone = styled.button.withConfig({
|
|
|
146
146
|
], theme.colors.primary, rgba(theme.colors.primary, theme.isDark ? .12 : .05)), ({ theme }) => theme.colors.primary, ({ theme }) => rgba(theme.colors.primary, theme.isDark ? .1 : .04), ({ theme }) => theme.colors.primary, ({ theme }) => theme.colors.primaryLight);
|
|
147
147
|
var StyledAvatarRemove = styled.button.withConfig({
|
|
148
148
|
displayName: "avatar-dropzone__StyledAvatarRemove",
|
|
149
|
-
componentId: "sc-
|
|
149
|
+
componentId: "sc-1d7e93ff-2"
|
|
150
150
|
})([
|
|
151
151
|
``,
|
|
152
152
|
`;position:absolute;top:0;right:0;display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:50%;color:#ffffff;background:`,
|
|
153
|
-
`;transition:background 0.3s ease;& svg{width:14px;height:14px;}
|
|
154
|
-
`;}
|
|
153
|
+
`;transition:background 0.3s ease;& svg{width:14px;height:14px;}&:hover:not(:disabled){background:`,
|
|
154
|
+
`;}&:disabled{cursor:not-allowed;opacity:0.6;}`
|
|
155
155
|
], resetButton, ({ theme }) => rgba(theme.colors.dark, .6), ({ theme }) => theme.colors.error);
|
|
156
156
|
//#endregion
|
|
157
157
|
export { AvatarDropzone };
|
package/dist/dropzone.js
CHANGED
|
@@ -155,11 +155,11 @@ function LocalDropzone({ $prompt = "Drag & drop files here", $browse, $hint, $ic
|
|
|
155
155
|
var Dropzone = /*#__PURE__*/ forwardRef(LocalDropzone);
|
|
156
156
|
var StyledDropzoneWrapper = styled.div.withConfig({
|
|
157
157
|
displayName: "dropzone__StyledDropzoneWrapper",
|
|
158
|
-
componentId: "sc-
|
|
158
|
+
componentId: "sc-b829ff10-0"
|
|
159
159
|
})([`display:flex;flex-direction:column;gap:12px;width:100%;`]);
|
|
160
160
|
var StyledDropzone = styled.button.withConfig({
|
|
161
161
|
displayName: "dropzone__StyledDropzone",
|
|
162
|
-
componentId: "sc-
|
|
162
|
+
componentId: "sc-b829ff10-1"
|
|
163
163
|
})([
|
|
164
164
|
``,
|
|
165
165
|
`;display:flex;flex-direction:`,
|
|
@@ -171,9 +171,9 @@ var StyledDropzone = styled.button.withConfig({
|
|
|
171
171
|
`;color:`,
|
|
172
172
|
`;text-align:`,
|
|
173
173
|
`;transition:all 0.3s ease;`,
|
|
174
|
-
`
|
|
174
|
+
` &:hover:not(:disabled){border-color:`,
|
|
175
175
|
`;background:`,
|
|
176
|
-
`;}
|
|
176
|
+
`;}&:focus{border-color:`,
|
|
177
177
|
`;box-shadow:0 0 0 4px `,
|
|
178
178
|
`;}&:disabled{cursor:not-allowed;opacity:0.6;}`
|
|
179
179
|
], resetButton, ({ $inline }) => $inline ? "row" : "column", ({ $inline }) => $inline ? "10px" : "8px", ({ $inline }) => $inline ? "10px 14px" : "24px 20px", ({ theme }) => theme.spacing.radius.lg, ({ theme }) => theme.colors.grayLight, ({ theme, $inline }) => $inline ? "transparent" : theme.colors.light, ({ theme }) => theme.colors.grayDark, ({ $inline }) => $inline ? "left" : "center", ({ theme, $dragOver }) => $dragOver && css([
|
|
@@ -183,7 +183,7 @@ var StyledDropzone = styled.button.withConfig({
|
|
|
183
183
|
], theme.colors.primary, rgba(theme.colors.primary, theme.isDark ? .12 : .05)), ({ theme }) => theme.colors.primary, ({ theme }) => rgba(theme.colors.primary, theme.isDark ? .1 : .04), ({ theme }) => theme.colors.primary, ({ theme }) => theme.colors.primaryLight);
|
|
184
184
|
var StyledDropIcon = styled.span.withConfig({
|
|
185
185
|
displayName: "dropzone__StyledDropIcon",
|
|
186
|
-
componentId: "sc-
|
|
186
|
+
componentId: "sc-b829ff10-2"
|
|
187
187
|
})([
|
|
188
188
|
`display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:`,
|
|
189
189
|
`;height:`,
|
|
@@ -197,7 +197,7 @@ var StyledDropIcon = styled.span.withConfig({
|
|
|
197
197
|
], ({ $inline }) => $inline ? "32px" : "44px", ({ $inline }) => $inline ? "32px" : "44px", ({ theme }) => theme.spacing.radius.lg, ({ theme }) => theme.colors.grayLight, ({ theme }) => theme.colors.grayLight, ({ theme }) => theme.colors.primary, ({ $inline }) => $inline ? "18px" : "22px", ({ $inline }) => $inline ? "18px" : "22px");
|
|
198
198
|
var StyledDropPrompt = styled.span.withConfig({
|
|
199
199
|
displayName: "dropzone__StyledDropPrompt",
|
|
200
|
-
componentId: "sc-
|
|
200
|
+
componentId: "sc-b829ff10-3"
|
|
201
201
|
})([
|
|
202
202
|
`display:flex;flex-direction:`,
|
|
203
203
|
`;flex-wrap:wrap;align-items:baseline;gap:`,
|
|
@@ -210,7 +210,7 @@ var StyledDropPrompt = styled.span.withConfig({
|
|
|
210
210
|
], ({ $inline }) => $inline ? "row" : "column", ({ $inline }) => $inline ? "0 6px" : "2px", ({ theme }) => theme.fonts.text, ({ theme }) => theme.fontSizes.text.xs, ({ theme }) => theme.lineHeights.text.xs, ({ theme }) => theme.colors.dark, ({ theme }) => theme.colors.grayDark);
|
|
211
211
|
var StyledDropHint = styled.span.withConfig({
|
|
212
212
|
displayName: "dropzone__StyledDropHint",
|
|
213
|
-
componentId: "sc-
|
|
213
|
+
componentId: "sc-b829ff10-4"
|
|
214
214
|
})([
|
|
215
215
|
`font-family:`,
|
|
216
216
|
`;font-size:`,
|
|
@@ -221,11 +221,11 @@ var StyledDropHint = styled.span.withConfig({
|
|
|
221
221
|
], ({ theme }) => theme.fonts.text, ({ theme }) => theme.fontSizes.small.xs, ({ theme }) => theme.lineHeights.small.xs, ({ theme }) => theme.colors.gray, ({ $inline }) => $inline && css([`margin-left:auto;`]));
|
|
222
222
|
var StyledThumbs = styled.div.withConfig({
|
|
223
223
|
displayName: "dropzone__StyledThumbs",
|
|
224
|
-
componentId: "sc-
|
|
224
|
+
componentId: "sc-b829ff10-5"
|
|
225
225
|
})([`display:grid;grid-template-columns:repeat(auto-fill,72px);gap:10px;`, `{grid-template-columns:repeat(auto-fill,84px);}`], mq("sm"));
|
|
226
226
|
var StyledThumb = styled.div.withConfig({
|
|
227
227
|
displayName: "dropzone__StyledThumb",
|
|
228
|
-
componentId: "sc-
|
|
228
|
+
componentId: "sc-b829ff10-6"
|
|
229
229
|
})([
|
|
230
230
|
`position:relative;width:72px;height:72px;border-radius:`,
|
|
231
231
|
`;overflow:hidden;border:solid 1px `,
|
|
@@ -235,7 +235,7 @@ var StyledThumb = styled.div.withConfig({
|
|
|
235
235
|
], ({ theme }) => theme.spacing.radius.lg, ({ theme }) => theme.colors.grayLight, ({ theme }) => theme.colors.light, mq("sm"));
|
|
236
236
|
var StyledThumbFile = styled.span.withConfig({
|
|
237
237
|
displayName: "dropzone__StyledThumbFile",
|
|
238
|
-
componentId: "sc-
|
|
238
|
+
componentId: "sc-b829ff10-7"
|
|
239
239
|
})([
|
|
240
240
|
`display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;width:100%;height:100%;padding:6px;color:`,
|
|
241
241
|
`;& svg{width:20px;height:20px;color:`,
|
|
@@ -244,12 +244,12 @@ var StyledThumbFile = styled.span.withConfig({
|
|
|
244
244
|
], ({ theme }) => theme.colors.grayDark, ({ theme }) => theme.colors.primary, ({ theme }) => theme.fonts.text);
|
|
245
245
|
var StyledThumbRemove = styled.button.withConfig({
|
|
246
246
|
displayName: "dropzone__StyledThumbRemove",
|
|
247
|
-
componentId: "sc-
|
|
247
|
+
componentId: "sc-b829ff10-8"
|
|
248
248
|
})([
|
|
249
249
|
``,
|
|
250
250
|
`;position:absolute;top:4px;right:4px;display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:50%;color:#ffffff;background:`,
|
|
251
|
-
`;transition:background 0.3s ease;& svg{width:14px;height:14px;}
|
|
252
|
-
`;}
|
|
251
|
+
`;transition:background 0.3s ease;& svg{width:14px;height:14px;}&:hover:not(:disabled){background:`,
|
|
252
|
+
`;}&:disabled{cursor:not-allowed;opacity:0.6;}`
|
|
253
253
|
], resetButton, ({ theme }) => rgba(theme.colors.dark, .6), ({ theme }) => theme.colors.error);
|
|
254
254
|
//#endregion
|
|
255
255
|
export { Dropzone, matchesAccept };
|
package/dist/icon-button.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonEl
|
|
|
5
5
|
"aria-label": string;
|
|
6
6
|
$size?: "default" | "big" | "small";
|
|
7
7
|
$error?: boolean;
|
|
8
|
+
$active?: boolean;
|
|
8
9
|
}
|
|
9
|
-
export declare const iconButtonStyles: (theme: Theme, $size?: "default" | "big" | "small", $error?: boolean, disabled?: boolean) => import('styled-components').RuleSet<object>;
|
|
10
|
+
export declare const iconButtonStyles: (theme: Theme, $size?: "default" | "big" | "small", $error?: boolean, disabled?: boolean, $active?: boolean) => import('styled-components').RuleSet<object>;
|
|
10
11
|
declare const IconButton: React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
11
12
|
export { IconButton };
|
package/dist/icon-button.js
CHANGED
|
@@ -4,7 +4,7 @@ import { resetButton } from "./utils/mixins.js";
|
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { forwardRef } from "react";
|
|
6
6
|
import styled, { css } from "styled-components";
|
|
7
|
-
import { darken, lighten } from "polished";
|
|
7
|
+
import { darken, lighten, rgba } from "polished";
|
|
8
8
|
//#region src/lib/icon-button.tsx
|
|
9
9
|
var iconButtonSizes = {
|
|
10
10
|
small: {
|
|
@@ -20,11 +20,11 @@ var iconButtonSizes = {
|
|
|
20
20
|
icon: 16
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
var iconButtonStyles = (theme, $size, $error, disabled) => {
|
|
23
|
+
var iconButtonStyles = (theme, $size, $error, disabled, $active) => {
|
|
24
24
|
const { box, icon } = iconButtonSizes[$size ?? "default"];
|
|
25
25
|
return css([
|
|
26
26
|
``,
|
|
27
|
-
`;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:`,
|
|
27
|
+
`;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;position:relative;width:`,
|
|
28
28
|
`px;height:`,
|
|
29
29
|
`px;border-radius:50%;background:`,
|
|
30
30
|
`;border:solid 2px `,
|
|
@@ -34,6 +34,7 @@ var iconButtonStyles = (theme, $size, $error, disabled) => {
|
|
|
34
34
|
`px;height:`,
|
|
35
35
|
`px;}`,
|
|
36
36
|
` `,
|
|
37
|
+
` `,
|
|
37
38
|
``
|
|
38
39
|
], resetButton, box, box, theme.colors.light, theme.colors.grayLight, $error ? theme.colors.error : theme.colors.grayDark, $error ? lighten(.1, theme.colors.error) : theme.colors.primaryLight, icon, icon, !disabled && ($error ? css([
|
|
39
40
|
`border-color:`,
|
|
@@ -49,7 +50,12 @@ var iconButtonStyles = (theme, $size, $error, disabled) => {
|
|
|
49
50
|
`;border-color:`,
|
|
50
51
|
`;}&:active{box-shadow:0 0 0 2px `,
|
|
51
52
|
`;}`
|
|
52
|
-
], theme.colors.primary, theme.colors.primary, theme.colors.primaryLight, theme.colors.primary, theme.colors.primaryLight)), disabled && css([
|
|
53
|
+
], theme.colors.primary, theme.colors.primary, theme.colors.primaryLight, theme.colors.primary, theme.colors.primaryLight)), !disabled && $active && css([
|
|
54
|
+
`border-color:`,
|
|
55
|
+
`;background:`,
|
|
56
|
+
`;color:`,
|
|
57
|
+
`;`
|
|
58
|
+
], theme.colors.primary, rgba(theme.colors.primary, theme.isDark ? .18 : .1), theme.colors.primary), disabled && css([
|
|
53
59
|
`cursor:not-allowed;background:`,
|
|
54
60
|
`;border-color:`,
|
|
55
61
|
`;color:`,
|
|
@@ -58,11 +64,12 @@ var iconButtonStyles = (theme, $size, $error, disabled) => {
|
|
|
58
64
|
};
|
|
59
65
|
var StyledIconButton = styled.button.withConfig({
|
|
60
66
|
displayName: "icon-button__StyledIconButton",
|
|
61
|
-
componentId: "sc-
|
|
62
|
-
})([``, ``], ({ theme, $size, $error, disabled }) => iconButtonStyles(theme, $size, $error, disabled));
|
|
67
|
+
componentId: "sc-e26e58e2-0"
|
|
68
|
+
})([``, ``], ({ theme, $size, $error, disabled, $active }) => iconButtonStyles(theme, $size, $error, disabled, $active));
|
|
63
69
|
function LocalIconButton({ ...props }, ref) {
|
|
64
70
|
return /*#__PURE__*/ jsx(StyledIconButton, {
|
|
65
71
|
type: "button",
|
|
72
|
+
"aria-pressed": props.$active === void 0 ? void 0 : props.$active,
|
|
66
73
|
...props,
|
|
67
74
|
ref
|
|
68
75
|
});
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -26,8 +26,9 @@ import { Password } from "./password.js";
|
|
|
26
26
|
import { Range } from "./range.js";
|
|
27
27
|
import { Select, StyledIconWrapper } from "./select.js";
|
|
28
28
|
import { Space } from "./space.js";
|
|
29
|
+
import { TabContent, Tabs } from "./tabs.js";
|
|
29
30
|
import { Textarea } from "./textarea.js";
|
|
30
31
|
import { ThemeToggle } from "./theme-toggle.js";
|
|
31
32
|
import { StyledNotificationItem, StyledNotifications, ToastNotifications, ToastNotificationsContext, ToastNotificationsProvider, useToastNotifications } from "./toast.js";
|
|
32
33
|
import { Toggle } from "./toggle.js";
|
|
33
|
-
export { Accordion, AvatarDropzone, Box, Button, CherryThemeProvider, ClientThemeProvider, Col, Container, Dropzone, Flex, GlobalStyles, Grid, Icon, IconArrow, IconButton, IconCalendar, IconCheck, Input, MaxWidth, Modal, Password, Range, Select, Space, StyledComponentsRegistry, StyledIconWrapper, StyledInputWrapper, StyledLabel, StyledNotificationItem, StyledNotifications, Textarea, ThemeContext, ThemeToggle, ToastNotifications, ToastNotificationsContext, ToastNotificationsProvider, Toggle, breakpoints, buttonStyles, colors, colorsDark, createThemeInitScript, createTypographyStyle, errorInteractiveStyles, fontSizes, fonts, formElementHeightStyles, fullWidthStyles, generateAlignContentStyles, generateAlignItemsStyles, generateColSpanStyles, generateColsStyles, generateDirectionStyles, generateGapStyles, generateJustifyContentStyles, generatePaddingStyles, iconButtonStyles, interactiveStyles, lineHeights, matchesAccept, mq, resetButton, resetInput, resolveTheme, shadows, shadowsDark, spacing, statusBorderStyles, styledBlockquote, styledButton, styledButtonBig, styledCode, styledH1, styledH2, styledH3, styledH4, styledH5, styledH6, styledHero1, styledHero2, styledHero3, styledInput, styledInputBig, styledSmall, styledStrong, styledText, theme, themeDark, themeInitScript, useOnClickOutside, useToastNotifications };
|
|
34
|
+
export { Accordion, AvatarDropzone, Box, Button, CherryThemeProvider, ClientThemeProvider, Col, Container, Dropzone, Flex, GlobalStyles, Grid, Icon, IconArrow, IconButton, IconCalendar, IconCheck, Input, MaxWidth, Modal, Password, Range, Select, Space, StyledComponentsRegistry, StyledIconWrapper, StyledInputWrapper, StyledLabel, StyledNotificationItem, StyledNotifications, TabContent, Tabs, Textarea, ThemeContext, ThemeToggle, ToastNotifications, ToastNotificationsContext, ToastNotificationsProvider, Toggle, breakpoints, buttonStyles, colors, colorsDark, createThemeInitScript, createTypographyStyle, errorInteractiveStyles, fontSizes, fonts, formElementHeightStyles, fullWidthStyles, generateAlignContentStyles, generateAlignItemsStyles, generateColSpanStyles, generateColsStyles, generateDirectionStyles, generateGapStyles, generateJustifyContentStyles, generatePaddingStyles, iconButtonStyles, interactiveStyles, lineHeights, matchesAccept, mq, resetButton, resetInput, resolveTheme, shadows, shadowsDark, spacing, statusBorderStyles, styledBlockquote, styledButton, styledButtonBig, styledCode, styledH1, styledH2, styledH3, styledH4, styledH5, styledH6, styledHero1, styledHero2, styledHero3, styledInput, styledInputBig, styledSmall, styledStrong, styledText, theme, themeDark, themeInitScript, useOnClickOutside, useToastNotifications };
|
package/dist/tabs.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface TabContentProps {
|
|
3
|
+
title: string;
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
declare function TabContent({ children }: TabContentProps): React.JSX.Element;
|
|
7
|
+
export interface TabsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange"> {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
onTabChange?: (index: number) => void;
|
|
10
|
+
defaultActiveTab?: number;
|
|
11
|
+
activeTab?: number;
|
|
12
|
+
}
|
|
13
|
+
declare function Tabs({ children, onTabChange, defaultActiveTab, activeTab, ...rest }: TabsProps): React.JSX.Element;
|
|
14
|
+
export { Tabs, TabContent };
|
package/dist/tabs.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { resetButton } from "./utils/mixins.js";
|
|
4
|
+
import { styledText } from "./utils/typography.js";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import React, { useId, useRef, useState } from "react";
|
|
7
|
+
import styled, { css } from "styled-components";
|
|
8
|
+
import { rgba } from "polished";
|
|
9
|
+
//#region src/lib/tabs.tsx
|
|
10
|
+
var StyledTabs = styled.div.withConfig({
|
|
11
|
+
displayName: "tabs__StyledTabs",
|
|
12
|
+
componentId: "sc-225e1742-0"
|
|
13
|
+
})([`width:100%;`]);
|
|
14
|
+
var StyledTabsList = styled.div.withConfig({
|
|
15
|
+
displayName: "tabs__StyledTabsList",
|
|
16
|
+
componentId: "sc-225e1742-1"
|
|
17
|
+
})([
|
|
18
|
+
`display:flex;overflow-x:auto;border-radius:`,
|
|
19
|
+
` `,
|
|
20
|
+
` 0 0;background:`,
|
|
21
|
+
`;border:solid 1px `,
|
|
22
|
+
`;`
|
|
23
|
+
], ({ theme }) => theme.spacing.radius.lg, ({ theme }) => theme.spacing.radius.lg, ({ theme }) => theme.colors.light, ({ theme }) => theme.colors.grayLight);
|
|
24
|
+
var StyledTabButton = styled.button.withConfig({
|
|
25
|
+
displayName: "tabs__StyledTabButton",
|
|
26
|
+
componentId: "sc-225e1742-2"
|
|
27
|
+
})([
|
|
28
|
+
``,
|
|
29
|
+
`;flex:1;min-width:fit-content;padding:12px 20px;`,
|
|
30
|
+
`;font-weight:600;color:`,
|
|
31
|
+
`;border-bottom:solid 3px transparent;transition:color 0.2s ease,background 0.2s ease,border-color 0.2s ease;@media (prefers-reduced-motion:reduce){transition:none;}&:not(:last-child){border-right:solid 1px `,
|
|
32
|
+
`;}&:focus-visible{border-radius:`,
|
|
33
|
+
`;outline:solid 2px `,
|
|
34
|
+
`;outline-offset:-4px;border-bottom-color:transparent;}`,
|
|
35
|
+
``
|
|
36
|
+
], resetButton, ({ theme }) => styledText(theme), ({ theme }) => theme.colors.dark, ({ theme }) => theme.colors.grayLight, ({ theme }) => theme.spacing.radius.xs, ({ theme }) => theme.colors.primary, ({ theme, $isActive }) => $isActive ? css([
|
|
37
|
+
`color:`,
|
|
38
|
+
`;border-bottom-color:`,
|
|
39
|
+
`;`
|
|
40
|
+
], theme.colors.primary, theme.colors.primary) : css([
|
|
41
|
+
`&:hover{color:`,
|
|
42
|
+
`;background:`,
|
|
43
|
+
`;}`
|
|
44
|
+
], theme.colors.primary, rgba(theme.colors.primaryLight, .1)));
|
|
45
|
+
var StyledTabPanel = styled.div.withConfig({
|
|
46
|
+
displayName: "tabs__StyledTabPanel",
|
|
47
|
+
componentId: "sc-225e1742-3"
|
|
48
|
+
})([
|
|
49
|
+
``,
|
|
50
|
+
`;color:`,
|
|
51
|
+
`;background:`,
|
|
52
|
+
`;padding:20px;border:solid 1px `,
|
|
53
|
+
`;border-top:none;border-radius:0 0 `,
|
|
54
|
+
` `,
|
|
55
|
+
`;`
|
|
56
|
+
], ({ theme }) => styledText(theme), ({ theme }) => theme.colors.grayDark, ({ theme }) => theme.colors.light, ({ theme }) => theme.colors.grayLight, ({ theme }) => theme.spacing.radius.lg, ({ theme }) => theme.spacing.radius.lg);
|
|
57
|
+
function TabContent({ children }) {
|
|
58
|
+
return /*#__PURE__*/ jsx(Fragment, { children });
|
|
59
|
+
}
|
|
60
|
+
function Tabs({ children, onTabChange, defaultActiveTab, activeTab, ...rest }) {
|
|
61
|
+
const [internalActive, setInternalActive] = useState(defaultActiveTab ?? 0);
|
|
62
|
+
const isControlled = activeTab !== void 0;
|
|
63
|
+
const baseId = useId();
|
|
64
|
+
const tabRefs = useRef([]);
|
|
65
|
+
const tabs = React.Children.toArray(children).filter((child) => /*#__PURE__*/ React.isValidElement(child) && typeof child.props.title === "string" && child.props.title.trim() !== "");
|
|
66
|
+
const active = Math.min(isControlled ? activeTab : internalActive, Math.max(tabs.length - 1, 0));
|
|
67
|
+
const selectTab = (index) => {
|
|
68
|
+
if (!isControlled) setInternalActive(index);
|
|
69
|
+
onTabChange?.(index);
|
|
70
|
+
};
|
|
71
|
+
const handleKeyDown = (event) => {
|
|
72
|
+
let next;
|
|
73
|
+
switch (event.key) {
|
|
74
|
+
case "ArrowRight":
|
|
75
|
+
next = (active + 1) % tabs.length;
|
|
76
|
+
break;
|
|
77
|
+
case "ArrowLeft":
|
|
78
|
+
next = (active - 1 + tabs.length) % tabs.length;
|
|
79
|
+
break;
|
|
80
|
+
case "Home":
|
|
81
|
+
next = 0;
|
|
82
|
+
break;
|
|
83
|
+
case "End":
|
|
84
|
+
next = tabs.length - 1;
|
|
85
|
+
break;
|
|
86
|
+
default: return;
|
|
87
|
+
}
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
selectTab(next);
|
|
90
|
+
tabRefs.current[next]?.focus();
|
|
91
|
+
};
|
|
92
|
+
return /*#__PURE__*/ jsxs(StyledTabs, {
|
|
93
|
+
...rest,
|
|
94
|
+
children: [/*#__PURE__*/ jsx(StyledTabsList, {
|
|
95
|
+
role: "tablist",
|
|
96
|
+
onKeyDown: handleKeyDown,
|
|
97
|
+
children: tabs.map((tab, index) => /*#__PURE__*/ jsx(StyledTabButton, {
|
|
98
|
+
type: "button",
|
|
99
|
+
role: "tab",
|
|
100
|
+
id: `${baseId}-tab-${index}`,
|
|
101
|
+
"aria-selected": index === active,
|
|
102
|
+
"aria-controls": `${baseId}-panel-${index}`,
|
|
103
|
+
tabIndex: index === active ? 0 : -1,
|
|
104
|
+
$isActive: index === active,
|
|
105
|
+
ref: (node) => {
|
|
106
|
+
tabRefs.current[index] = node;
|
|
107
|
+
},
|
|
108
|
+
onClick: () => selectTab(index),
|
|
109
|
+
children: tab.props.title
|
|
110
|
+
}, index))
|
|
111
|
+
}), /*#__PURE__*/ jsx(StyledTabPanel, {
|
|
112
|
+
role: "tabpanel",
|
|
113
|
+
id: `${baseId}-panel-${active}`,
|
|
114
|
+
"aria-labelledby": `${baseId}-tab-${active}`,
|
|
115
|
+
children: tabs[active]?.props.children
|
|
116
|
+
})]
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
export { TabContent, Tabs };
|
package/dist/theme-toggle.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
|
-
import { resetButton } from "./utils/mixins.js";
|
|
3
|
+
import { interactiveStyles, resetButton } from "./utils/mixins.js";
|
|
4
4
|
import { ThemeContext } from "./styled-components/theme-provider.js";
|
|
5
5
|
import { Icon } from "./icon.js";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -10,19 +10,19 @@ import { rgba } from "polished";
|
|
|
10
10
|
//#region src/lib/theme-toggle.tsx
|
|
11
11
|
var StyledThemeToggle = styled.button.withConfig({
|
|
12
12
|
displayName: "theme-toggle__StyledThemeToggle",
|
|
13
|
-
componentId: "sc-
|
|
13
|
+
componentId: "sc-aa19beba-0"
|
|
14
14
|
})([
|
|
15
15
|
``,
|
|
16
|
-
`
|
|
17
|
-
|
|
18
|
-
`;
|
|
16
|
+
` `,
|
|
17
|
+
` width:56px;height:30px;border-radius:30px;display:flex;align-items:center;justify-content:space-between;padding:0 6px;position:relative;margin:auto 0;background:`,
|
|
18
|
+
`;border-color:`,
|
|
19
|
+
`;&::after{content:"";position:absolute;top:2px;left:2px;width:24px;height:24px;border-radius:50%;background:`,
|
|
19
20
|
`;transition:all 0.3s ease;z-index:1;`,
|
|
20
21
|
`}`,
|
|
21
|
-
` & svg{width:16px;height:16px;object-fit:contain;
|
|
22
|
-
`;}&:hover{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
], resetButton, ({ theme }) => theme.colors.light, ({ theme }) => theme.colors.grayLight, ({ theme }) => rgba(theme.colors.primaryLight, .2), ({ theme }) => theme.isDark && css([`transform:translateX(26px);`]), ({ $hidden }) => $hidden && css([`display:none;`]), ({ theme }) => theme.colors.primary, ({ theme }) => theme.isDark ? theme.colors.primaryLight : theme.colors.primaryDark, ({ theme }) => theme.isDark ? theme.colors.primaryLight : theme.colors.primaryDark);
|
|
22
|
+
` & svg{width:16px;height:16px;object-fit:contain;transition:all 0.3s ease;position:relative;z-index:2;}& svg[stroke]{stroke:`,
|
|
23
|
+
`;}&:hover svg[stroke]{stroke:`,
|
|
24
|
+
`;}`
|
|
25
|
+
], resetButton, interactiveStyles, ({ theme }) => theme.colors.light, ({ theme }) => theme.colors.grayLight, ({ theme }) => rgba(theme.colors.primaryLight, .2), ({ theme }) => theme.isDark && css([`transform:translateX(26px);`]), ({ $hidden }) => $hidden && css([`display:none;`]), ({ theme }) => theme.colors.primary, ({ theme }) => theme.isDark ? theme.colors.primaryLight : theme.colors.primaryDark);
|
|
26
26
|
function LocalThemeToggle({ onClick, ...props }, ref) {
|
|
27
27
|
const { toggleTheme } = useContext(ThemeContext);
|
|
28
28
|
return /*#__PURE__*/ jsxs(StyledThemeToggle, {
|
package/dist/utils/mixins.js
CHANGED
|
@@ -11,8 +11,8 @@ import { rgba } from "polished";
|
|
|
11
11
|
* elements that aren't Buttons.
|
|
12
12
|
*/ var interactiveStyles = css([
|
|
13
13
|
`transition:all 0.3s ease;border:solid 1px transparent;box-shadow:0 0 0 0px `,
|
|
14
|
-
|
|
15
|
-
`;}
|
|
14
|
+
`;&:hover{border-color:`,
|
|
15
|
+
`;}&:focus{border-color:`,
|
|
16
16
|
`;box-shadow:0 0 0 4px `,
|
|
17
17
|
`;}&:active{box-shadow:0 0 0 2px `,
|
|
18
18
|
`;}`
|
|
@@ -23,8 +23,8 @@ import { rgba } from "polished";
|
|
|
23
23
|
* same red the $error Button uses). Use for delete/remove affordances.
|
|
24
24
|
*/ var errorInteractiveStyles = css([
|
|
25
25
|
`transition:all 0.3s ease;border:solid 1px transparent;box-shadow:0 0 0 0px `,
|
|
26
|
-
|
|
27
|
-
`;}
|
|
26
|
+
`;&:hover{border-color:`,
|
|
27
|
+
`;}&:focus{border-color:`,
|
|
28
28
|
`;box-shadow:0 0 0 4px `,
|
|
29
29
|
`;}&:active{box-shadow:0 0 0 2px `,
|
|
30
30
|
`;}`
|
package/package.json
CHANGED