@ttoss/ui 1.20.4 → 1.21.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.
@@ -0,0 +1,206 @@
1
+ /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
+
3
+ // tsup.inject.js
4
+ import * as React from "react";
5
+
6
+ // src/index.ts
7
+ import { useResponsiveValue, useBreakpointIndex } from "@theme-ui/match-media";
8
+
9
+ // src/theme/ThemeProvider.tsx
10
+ import * as React2 from "react";
11
+
12
+ // ../theme/dist/esm/index.js
13
+ var DefaultTheme = {
14
+ colors: {
15
+ text: "#000",
16
+ background: "#fff",
17
+ primary: "#07c",
18
+ secondary: "#639",
19
+ gray: "#555",
20
+ muted: "#f6f6f6",
21
+ danger: "red"
22
+ },
23
+ space: [0, 4, 8, 16, 32, 64, 128, 256, 512, 1024],
24
+ fonts: {
25
+ body: '"Asap", sans-serif',
26
+ heading: '"Overpass", sans-serif',
27
+ monospace: '"Overpass Mono", sans-serif'
28
+ },
29
+ styles: {
30
+ root: {
31
+ fontFamily: "body",
32
+ fontWeight: "body"
33
+ },
34
+ a: {
35
+ color: "primary",
36
+ textDecoration: "underline",
37
+ cursor: "pointer",
38
+ fontFamily: "body"
39
+ },
40
+ progress: {
41
+ color: "primary",
42
+ backgroundColor: "background"
43
+ }
44
+ },
45
+ buttons: {
46
+ cta: {
47
+ color: "white",
48
+ backgroundColor: "primary"
49
+ },
50
+ muted: {
51
+ color: "text",
52
+ backgroundColor: "muted"
53
+ },
54
+ danger: {
55
+ color: "white",
56
+ backgroundColor: "danger"
57
+ }
58
+ },
59
+ cards: {
60
+ primary: {
61
+ backgroundColor: "background",
62
+ border: "1px solid black",
63
+ padding: [4, 5],
64
+ display: "flex",
65
+ flexDirection: "column",
66
+ alignItems: "center",
67
+ width: "fit-content"
68
+ }
69
+ },
70
+ forms: {
71
+ input: {
72
+ fontFamily: "body"
73
+ }
74
+ },
75
+ text: {
76
+ default: {
77
+ color: "text",
78
+ fontFamily: "body"
79
+ },
80
+ title: {
81
+ fontFamily: "heading",
82
+ fontSize: 4,
83
+ lineSpace: "3.5"
84
+ }
85
+ }
86
+ };
87
+ var DefaultFonts = [
88
+ "https://fonts.googleapis.com/css?family=Asap",
89
+ "https://fonts.googleapis.com/css?family=Overpass",
90
+ "https://fonts.googleapis.com/css?family=Overpass+Mono",
91
+ "https://fonts.googleapis.com/css?family=Flamenco"
92
+ ];
93
+
94
+ // src/theme/ThemeProvider.tsx
95
+ import { Global, css } from "@emotion/react";
96
+ import { ThemeProvider as ThemeUiProvider, merge } from "theme-ui";
97
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
98
+ var ThemeProvider = ({
99
+ children,
100
+ theme = {},
101
+ fonts = DefaultFonts
102
+ }) => {
103
+ const mergedTheme = React2.useMemo(() => {
104
+ if (typeof theme === "function") {
105
+ return theme;
106
+ }
107
+ return merge(DefaultTheme, theme);
108
+ }, [theme]);
109
+ return /* @__PURE__ */ jsx(Fragment, {
110
+ children: /* @__PURE__ */ jsxs(ThemeUiProvider, {
111
+ theme: mergedTheme,
112
+ children: [
113
+ fonts.map((url) => /* @__PURE__ */ jsx(Global, {
114
+ styles: css`
115
+ @import url('${url}');
116
+ `
117
+ }, url)),
118
+ children
119
+ ]
120
+ })
121
+ });
122
+ };
123
+ var ThemeProvider_default = ThemeProvider;
124
+
125
+ // src/theme/useTheme.ts
126
+ import { useThemeUI } from "theme-ui";
127
+ var useTheme = useThemeUI;
128
+
129
+ // src/components/Box/Box.tsx
130
+ import { Box } from "theme-ui";
131
+
132
+ // src/components/Button/Button.tsx
133
+ import { Button as ButtonUi } from "theme-ui";
134
+ import { jsx as jsx2 } from "react/jsx-runtime";
135
+ var Button = (props) => {
136
+ return /* @__PURE__ */ jsx2(ButtonUi, {
137
+ ...props,
138
+ sx: { cursor: "pointer", fontFamily: "body", ...props.sx }
139
+ });
140
+ };
141
+
142
+ // src/components/Card/Card.tsx
143
+ import { Card } from "theme-ui";
144
+
145
+ // src/components/Divider/Divider.tsx
146
+ import { Divider } from "theme-ui";
147
+
148
+ // src/components/Flex/Flex.tsx
149
+ import { Flex } from "theme-ui";
150
+
151
+ // src/components/Grid/Grid.tsx
152
+ import { Grid } from "theme-ui";
153
+
154
+ // src/components/Heading/Heading.tsx
155
+ import { Heading } from "theme-ui";
156
+
157
+ // src/components/Image/Image.tsx
158
+ import { Image } from "theme-ui";
159
+
160
+ // src/components/Input/Input.tsx
161
+ import { Input } from "theme-ui";
162
+
163
+ // src/components/Label/Label.tsx
164
+ import { Label } from "theme-ui";
165
+
166
+ // src/components/Link/Link.tsx
167
+ import { Link } from "theme-ui";
168
+
169
+ // src/components/LinearProgress/LinearProgress.tsx
170
+ import {
171
+ Progress
172
+ } from "theme-ui";
173
+
174
+ // src/components/Text/Text.tsx
175
+ import { Text } from "theme-ui";
176
+
177
+ // src/components/Select/Select.tsx
178
+ import { Select } from "theme-ui";
179
+
180
+ // src/components/Spinner/Spinner.tsx
181
+ import { Spinner } from "theme-ui";
182
+
183
+ // src/components/Radio/Radio.tsx
184
+ import { Radio } from "theme-ui";
185
+ export {
186
+ Box,
187
+ Button,
188
+ Card,
189
+ Divider,
190
+ Flex,
191
+ Grid,
192
+ Heading,
193
+ Image,
194
+ Input,
195
+ Label,
196
+ Progress as LinearProgress,
197
+ Link,
198
+ Radio,
199
+ Select,
200
+ Spinner,
201
+ Text,
202
+ ThemeProvider_default as ThemeProvider,
203
+ useBreakpointIndex,
204
+ useResponsiveValue,
205
+ useTheme
206
+ };
@@ -0,0 +1,21 @@
1
+ import * as theme_ui from 'theme-ui';
2
+ import { Theme, ButtonProps } from 'theme-ui';
3
+ export { Box, BoxProps, ButtonProps, Card, CardProps, Divider, DividerProps, Flex, FlexProps, Grid, GridProps, Heading, HeadingProps, Image, ImageProps, Input, InputProps, Label, LabelProps, Progress as LinearProgress, ProgressProps as LinearProgressProps, Link, LinkProps, Radio, RadioProps, Select, SelectProps, Spinner, SpinnerProps, Text, TextProps, Theme } from 'theme-ui';
4
+ export { useBreakpointIndex, useResponsiveValue } from '@theme-ui/match-media';
5
+ import * as React from 'react';
6
+
7
+ declare type ThemeProviderProps = {
8
+ children?: React.ReactNode;
9
+ theme?: Theme;
10
+ /**
11
+ * Fonts URLs.
12
+ */
13
+ fonts?: string[];
14
+ };
15
+ declare const ThemeProvider: ({ children, theme, fonts, }: ThemeProviderProps) => JSX.Element;
16
+
17
+ declare const useTheme: () => theme_ui.ThemeUIContextValue;
18
+
19
+ declare const Button: (props: ButtonProps) => JSX.Element;
20
+
21
+ export { Button, ThemeProvider, ThemeProviderProps, useTheme };
package/dist/index.js ADDED
@@ -0,0 +1,255 @@
1
+ /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
26
+
27
+ // src/index.ts
28
+ var src_exports = {};
29
+ __export(src_exports, {
30
+ Box: () => import_theme_ui3.Box,
31
+ Button: () => Button,
32
+ Card: () => import_theme_ui5.Card,
33
+ Divider: () => import_theme_ui6.Divider,
34
+ Flex: () => import_theme_ui7.Flex,
35
+ Grid: () => import_theme_ui8.Grid,
36
+ Heading: () => import_theme_ui9.Heading,
37
+ Image: () => import_theme_ui10.Image,
38
+ Input: () => import_theme_ui11.Input,
39
+ Label: () => import_theme_ui12.Label,
40
+ LinearProgress: () => import_theme_ui14.Progress,
41
+ Link: () => import_theme_ui13.Link,
42
+ Radio: () => import_theme_ui18.Radio,
43
+ Select: () => import_theme_ui16.Select,
44
+ Spinner: () => import_theme_ui17.Spinner,
45
+ Text: () => import_theme_ui15.Text,
46
+ ThemeProvider: () => ThemeProvider_default,
47
+ useBreakpointIndex: () => import_match_media.useBreakpointIndex,
48
+ useResponsiveValue: () => import_match_media.useResponsiveValue,
49
+ useTheme: () => useTheme
50
+ });
51
+ module.exports = __toCommonJS(src_exports);
52
+
53
+ // tsup.inject.js
54
+ var React = __toESM(require("react"));
55
+
56
+ // src/index.ts
57
+ var import_match_media = require("@theme-ui/match-media");
58
+
59
+ // src/theme/ThemeProvider.tsx
60
+ var React2 = __toESM(require("react"));
61
+
62
+ // ../theme/dist/esm/index.js
63
+ var DefaultTheme = {
64
+ colors: {
65
+ text: "#000",
66
+ background: "#fff",
67
+ primary: "#07c",
68
+ secondary: "#639",
69
+ gray: "#555",
70
+ muted: "#f6f6f6",
71
+ danger: "red"
72
+ },
73
+ space: [0, 4, 8, 16, 32, 64, 128, 256, 512, 1024],
74
+ fonts: {
75
+ body: '"Asap", sans-serif',
76
+ heading: '"Overpass", sans-serif',
77
+ monospace: '"Overpass Mono", sans-serif'
78
+ },
79
+ styles: {
80
+ root: {
81
+ fontFamily: "body",
82
+ fontWeight: "body"
83
+ },
84
+ a: {
85
+ color: "primary",
86
+ textDecoration: "underline",
87
+ cursor: "pointer",
88
+ fontFamily: "body"
89
+ },
90
+ progress: {
91
+ color: "primary",
92
+ backgroundColor: "background"
93
+ }
94
+ },
95
+ buttons: {
96
+ cta: {
97
+ color: "white",
98
+ backgroundColor: "primary"
99
+ },
100
+ muted: {
101
+ color: "text",
102
+ backgroundColor: "muted"
103
+ },
104
+ danger: {
105
+ color: "white",
106
+ backgroundColor: "danger"
107
+ }
108
+ },
109
+ cards: {
110
+ primary: {
111
+ backgroundColor: "background",
112
+ border: "1px solid black",
113
+ padding: [4, 5],
114
+ display: "flex",
115
+ flexDirection: "column",
116
+ alignItems: "center",
117
+ width: "fit-content"
118
+ }
119
+ },
120
+ forms: {
121
+ input: {
122
+ fontFamily: "body"
123
+ }
124
+ },
125
+ text: {
126
+ default: {
127
+ color: "text",
128
+ fontFamily: "body"
129
+ },
130
+ title: {
131
+ fontFamily: "heading",
132
+ fontSize: 4,
133
+ lineSpace: "3.5"
134
+ }
135
+ }
136
+ };
137
+ var DefaultFonts = [
138
+ "https://fonts.googleapis.com/css?family=Asap",
139
+ "https://fonts.googleapis.com/css?family=Overpass",
140
+ "https://fonts.googleapis.com/css?family=Overpass+Mono",
141
+ "https://fonts.googleapis.com/css?family=Flamenco"
142
+ ];
143
+
144
+ // src/theme/ThemeProvider.tsx
145
+ var import_react = require("@emotion/react");
146
+ var import_theme_ui = require("theme-ui");
147
+ var import_jsx_runtime = require("react/jsx-runtime");
148
+ var ThemeProvider = ({
149
+ children,
150
+ theme = {},
151
+ fonts = DefaultFonts
152
+ }) => {
153
+ const mergedTheme = React2.useMemo(() => {
154
+ if (typeof theme === "function") {
155
+ return theme;
156
+ }
157
+ return (0, import_theme_ui.merge)(DefaultTheme, theme);
158
+ }, [theme]);
159
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
160
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_theme_ui.ThemeProvider, {
161
+ theme: mergedTheme,
162
+ children: [
163
+ fonts.map((url) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Global, {
164
+ styles: import_react.css`
165
+ @import url('${url}');
166
+ `
167
+ }, url)),
168
+ children
169
+ ]
170
+ })
171
+ });
172
+ };
173
+ var ThemeProvider_default = ThemeProvider;
174
+
175
+ // src/theme/useTheme.ts
176
+ var import_theme_ui2 = require("theme-ui");
177
+ var useTheme = import_theme_ui2.useThemeUI;
178
+
179
+ // src/components/Box/Box.tsx
180
+ var import_theme_ui3 = require("theme-ui");
181
+
182
+ // src/components/Button/Button.tsx
183
+ var import_theme_ui4 = require("theme-ui");
184
+ var import_jsx_runtime2 = require("react/jsx-runtime");
185
+ var Button = (props) => {
186
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_theme_ui4.Button, {
187
+ ...props,
188
+ sx: { cursor: "pointer", fontFamily: "body", ...props.sx }
189
+ });
190
+ };
191
+
192
+ // src/components/Card/Card.tsx
193
+ var import_theme_ui5 = require("theme-ui");
194
+
195
+ // src/components/Divider/Divider.tsx
196
+ var import_theme_ui6 = require("theme-ui");
197
+
198
+ // src/components/Flex/Flex.tsx
199
+ var import_theme_ui7 = require("theme-ui");
200
+
201
+ // src/components/Grid/Grid.tsx
202
+ var import_theme_ui8 = require("theme-ui");
203
+
204
+ // src/components/Heading/Heading.tsx
205
+ var import_theme_ui9 = require("theme-ui");
206
+
207
+ // src/components/Image/Image.tsx
208
+ var import_theme_ui10 = require("theme-ui");
209
+
210
+ // src/components/Input/Input.tsx
211
+ var import_theme_ui11 = require("theme-ui");
212
+
213
+ // src/components/Label/Label.tsx
214
+ var import_theme_ui12 = require("theme-ui");
215
+
216
+ // src/components/Link/Link.tsx
217
+ var import_theme_ui13 = require("theme-ui");
218
+
219
+ // src/components/LinearProgress/LinearProgress.tsx
220
+ var import_theme_ui14 = require("theme-ui");
221
+
222
+ // src/components/Text/Text.tsx
223
+ var import_theme_ui15 = require("theme-ui");
224
+
225
+ // src/components/Select/Select.tsx
226
+ var import_theme_ui16 = require("theme-ui");
227
+
228
+ // src/components/Spinner/Spinner.tsx
229
+ var import_theme_ui17 = require("theme-ui");
230
+
231
+ // src/components/Radio/Radio.tsx
232
+ var import_theme_ui18 = require("theme-ui");
233
+ // Annotate the CommonJS export names for ESM import in node:
234
+ 0 && (module.exports = {
235
+ Box,
236
+ Button,
237
+ Card,
238
+ Divider,
239
+ Flex,
240
+ Grid,
241
+ Heading,
242
+ Image,
243
+ Input,
244
+ Label,
245
+ LinearProgress,
246
+ Link,
247
+ Radio,
248
+ Select,
249
+ Spinner,
250
+ Text,
251
+ ThemeProvider,
252
+ useBreakpointIndex,
253
+ useResponsiveValue,
254
+ useTheme
255
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/ui",
3
- "version": "1.20.4",
3
+ "version": "1.21.1",
4
4
  "description": "Primitive layout, typographic, and other components for styling applications.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "ttoss",
@@ -31,6 +31,7 @@
31
31
  "@emotion/react": "^11.10.4",
32
32
  "@ttoss/config": "^1.18.3",
33
33
  "@ttoss/test-utils": "^1.16.10",
34
+ "@ttoss/theme": "^1.0.1",
34
35
  "@types/jest": "^29.1.1",
35
36
  "jest": "^29.1.2",
36
37
  "tsup": "^6.2.3"
@@ -43,5 +44,5 @@
43
44
  "publishConfig": {
44
45
  "access": "public"
45
46
  },
46
- "gitHead": "b9f9de9b8389be76965f125b593166f10c2171e6"
47
+ "gitHead": "3879642eff43efd073abf52595ed0efe7196946a"
47
48
  }
@@ -0,0 +1 @@
1
+ export { Radio, type RadioProps } from 'theme-ui';
@@ -6,4 +6,5 @@ test('should export methods', () => {
6
6
  expect(uiModule.useTheme).toBeDefined();
7
7
 
8
8
  expect(uiModule.Divider).toBeDefined();
9
+ expect(uiModule.Radio).toBeDefined();
9
10
  });
package/src/index.ts CHANGED
@@ -26,3 +26,4 @@ export {
26
26
  export { Text, type TextProps } from './components/Text/Text';
27
27
  export { Select, type SelectProps } from './components/Select/Select';
28
28
  export { Spinner, type SpinnerProps } from './components/Spinner/Spinner';
29
+ export { Radio, type RadioProps } from './components/Radio/Radio';
@@ -1,4 +1,4 @@
1
- import { defaultTheme } from './defaultTheme';
1
+ import { DefaultTheme } from '@ttoss/theme';
2
2
  import { renderHook } from '@ttoss/test-utils';
3
3
  import { useTheme } from './useTheme';
4
4
  import ThemeProvider from './ThemeProvider';
@@ -9,7 +9,7 @@ test('should return default theme colors', () => {
9
9
  initialProps: { theme: {} },
10
10
  });
11
11
 
12
- expect(result.current.theme.rawColors).toEqual(defaultTheme.colors);
12
+ expect(result.current.theme.rawColors).toEqual(DefaultTheme.colors);
13
13
  });
14
14
 
15
15
  test('should return new theme colors', () => {
@@ -1,8 +1,7 @@
1
1
  import * as React from 'react';
2
+ import { DefaultFonts, DefaultTheme } from '@ttoss/theme';
2
3
  import { Global, css } from '@emotion/react';
3
4
  import { Theme, ThemeProvider as ThemeUiProvider, merge } from 'theme-ui';
4
- import { defaultFonts } from './defaultFonts';
5
- import { defaultTheme } from './defaultTheme';
6
5
 
7
6
  export type ThemeProviderProps = {
8
7
  children?: React.ReactNode;
@@ -16,14 +15,14 @@ export type ThemeProviderProps = {
16
15
  const ThemeProvider = ({
17
16
  children,
18
17
  theme = {},
19
- fonts = defaultFonts,
18
+ fonts = DefaultFonts,
20
19
  }: ThemeProviderProps) => {
21
20
  const mergedTheme = React.useMemo(() => {
22
21
  if (typeof theme === 'function') {
23
22
  return theme;
24
23
  }
25
24
 
26
- return merge(defaultTheme, theme);
25
+ return merge(DefaultTheme, theme);
27
26
  }, [theme]);
28
27
 
29
28
  return (
@@ -1,6 +0,0 @@
1
- export const defaultFonts = [
2
- 'https://fonts.googleapis.com/css?family=Asap',
3
- 'https://fonts.googleapis.com/css?family=Overpass',
4
- 'https://fonts.googleapis.com/css?family=Overpass+Mono',
5
- 'https://fonts.googleapis.com/css?family=Flamenco',
6
- ];
@@ -1,76 +0,0 @@
1
- import { Theme } from 'theme-ui';
2
-
3
- export const defaultTheme: Theme = {
4
- colors: {
5
- text: '#000',
6
- background: '#fff',
7
- primary: '#07c',
8
- secondary: '#639',
9
- gray: '#555',
10
- muted: '#f6f6f6',
11
- danger: 'red',
12
- },
13
- space: [0, 4, 8, 16, 32, 64, 128, 256, 512, 1024],
14
- fonts: {
15
- body: '"Asap", sans-serif',
16
- heading: '"Overpass", sans-serif',
17
- monospace: '"Overpass Mono", sans-serif',
18
- },
19
- styles: {
20
- root: {
21
- fontFamily: 'body',
22
- fontWeight: 'body',
23
- },
24
- a: {
25
- color: 'primary',
26
- textDecoration: 'underline',
27
- cursor: 'pointer',
28
- fontFamily: 'body',
29
- },
30
- progress: {
31
- color: 'primary',
32
- backgroundColor: 'background',
33
- },
34
- },
35
- buttons: {
36
- cta: {
37
- color: 'white',
38
- backgroundColor: 'primary',
39
- },
40
- muted: {
41
- color: 'text',
42
- backgroundColor: 'muted',
43
- },
44
- danger: {
45
- color: 'white',
46
- backgroundColor: 'danger',
47
- },
48
- },
49
- cards: {
50
- primary: {
51
- backgroundColor: 'background',
52
- border: '1px solid black',
53
- padding: [4, 5],
54
- display: 'flex',
55
- flexDirection: 'column',
56
- alignItems: 'center',
57
- width: 'fit-content',
58
- },
59
- },
60
- forms: {
61
- input: {
62
- fontFamily: 'body',
63
- },
64
- },
65
- text: {
66
- default: {
67
- color: 'text',
68
- fontFamily: 'body',
69
- },
70
- title: {
71
- fontFamily: 'heading',
72
- fontSize: 4,
73
- lineSpace: '3.5',
74
- },
75
- },
76
- };