@ttoss/ui 1.15.2 → 1.16.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/README.md +4 -4
- package/dist/esm/index.js +202 -82
- package/dist/index.d.ts +4 -20
- package/dist/index.js +205 -104
- package/package.json +9 -10
- package/src/components/Box/Box.tsx +1 -3
- package/src/components/Button/Button.tsx +2 -6
- package/src/components/Card/Card.tsx +1 -3
- package/src/components/Divider/Divider.tsx +1 -1
- package/src/components/Flex/Flex.tsx +1 -3
- package/src/components/Grid/Grid.tsx +1 -1
- package/src/components/Heading/Heading.tsx +1 -1
- package/src/components/Image/Image.tsx +1 -3
- package/src/components/Input/Input.tsx +1 -3
- package/src/components/Label/Label.tsx +1 -3
- package/src/components/LinearProgress/LinearProgress.tsx +4 -5
- package/src/components/Link/Link.tsx +1 -3
- package/src/components/Select/Select.tsx +1 -3
- package/src/components/Text/Text.tsx +1 -3
- package/src/index.ts +10 -22
- package/src/theme/ThemeProvider.spec.tsx +31 -26
- package/src/theme/ThemeProvider.tsx +2 -10
- package/src/theme/defaultTheme.ts +1 -1
- package/src/components/FormField/FormField.spec.tsx +0 -54
- package/src/components/FormField/FormField.tsx +0 -41
package/README.md
CHANGED
|
@@ -17,12 +17,12 @@ $ npm install @ttoss/ui
|
|
|
17
17
|
## 📄 Examples of use
|
|
18
18
|
|
|
19
19
|
```tsx
|
|
20
|
-
import { Flex, Text, Box, Button } from
|
|
20
|
+
import { Flex, Text, Box, Button } from "@ttoss/ui";
|
|
21
21
|
|
|
22
22
|
const App = () => {
|
|
23
23
|
return (
|
|
24
24
|
<ThemeProvider>
|
|
25
|
-
<Flex sx={{ flexDirection:
|
|
25
|
+
<Flex sx={{ flexDirection: "column" }}>
|
|
26
26
|
<Text>Text Value</Text>
|
|
27
27
|
<Box>
|
|
28
28
|
<Text>Text Value</Text>
|
|
@@ -44,9 +44,9 @@ You can pass fonts URLs to `ThemeProvider` component thought `fonts` prop.
|
|
|
44
44
|
```tsx
|
|
45
45
|
<ThemeProvider
|
|
46
46
|
fonts={[
|
|
47
|
-
|
|
47
|
+
"https://fonts.googleapis.com/css?family=Roboto:400,500,700&display=swap",
|
|
48
48
|
,
|
|
49
|
-
|
|
49
|
+
"https://fonts.googleapis.com/css?family=Roboto+Mono&display=swap",
|
|
50
50
|
]}
|
|
51
51
|
>
|
|
52
52
|
<App />
|
package/dist/esm/index.js
CHANGED
|
@@ -1,37 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
1
3
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
18
10
|
};
|
|
19
|
-
var
|
|
11
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
12
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
23
|
|
|
21
24
|
// tsup.inject.js
|
|
22
25
|
import * as React from "react";
|
|
26
|
+
var init_tsup_inject = __esm({
|
|
27
|
+
"tsup.inject.js"() {
|
|
28
|
+
"use strict";
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// ../../node_modules/deepmerge/dist/cjs.js
|
|
33
|
+
var require_cjs = __commonJS({
|
|
34
|
+
"../../node_modules/deepmerge/dist/cjs.js"(exports, module) {
|
|
35
|
+
"use strict";
|
|
36
|
+
init_tsup_inject();
|
|
37
|
+
var isMergeableObject = function isMergeableObject2(value) {
|
|
38
|
+
return isNonNullObject(value) && !isSpecial(value);
|
|
39
|
+
};
|
|
40
|
+
function isNonNullObject(value) {
|
|
41
|
+
return !!value && typeof value === "object";
|
|
42
|
+
}
|
|
43
|
+
function isSpecial(value) {
|
|
44
|
+
var stringValue = Object.prototype.toString.call(value);
|
|
45
|
+
return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
|
|
46
|
+
}
|
|
47
|
+
var canUseSymbol2 = typeof Symbol === "function" && Symbol.for;
|
|
48
|
+
var REACT_ELEMENT_TYPE = canUseSymbol2 ? Symbol.for("react.element") : 60103;
|
|
49
|
+
function isReactElement(value) {
|
|
50
|
+
return value.$$typeof === REACT_ELEMENT_TYPE;
|
|
51
|
+
}
|
|
52
|
+
function emptyTarget(val) {
|
|
53
|
+
return Array.isArray(val) ? [] : {};
|
|
54
|
+
}
|
|
55
|
+
function cloneUnlessOtherwiseSpecified(value, options) {
|
|
56
|
+
return options.clone !== false && options.isMergeableObject(value) ? deepmerge2(emptyTarget(value), value, options) : value;
|
|
57
|
+
}
|
|
58
|
+
function defaultArrayMerge(target, source, options) {
|
|
59
|
+
return target.concat(source).map(function(element) {
|
|
60
|
+
return cloneUnlessOtherwiseSpecified(element, options);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function getMergeFunction(key, options) {
|
|
64
|
+
if (!options.customMerge) {
|
|
65
|
+
return deepmerge2;
|
|
66
|
+
}
|
|
67
|
+
var customMerge = options.customMerge(key);
|
|
68
|
+
return typeof customMerge === "function" ? customMerge : deepmerge2;
|
|
69
|
+
}
|
|
70
|
+
function getEnumerableOwnPropertySymbols(target) {
|
|
71
|
+
return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
|
|
72
|
+
return target.propertyIsEnumerable(symbol);
|
|
73
|
+
}) : [];
|
|
74
|
+
}
|
|
75
|
+
function getKeys(target) {
|
|
76
|
+
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
|
|
77
|
+
}
|
|
78
|
+
function propertyIsOnObject(object, property) {
|
|
79
|
+
try {
|
|
80
|
+
return property in object;
|
|
81
|
+
} catch (_) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function propertyIsUnsafe(target, key) {
|
|
86
|
+
return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
|
|
87
|
+
}
|
|
88
|
+
function mergeObject(target, source, options) {
|
|
89
|
+
var destination = {};
|
|
90
|
+
if (options.isMergeableObject(target)) {
|
|
91
|
+
getKeys(target).forEach(function(key) {
|
|
92
|
+
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
getKeys(source).forEach(function(key) {
|
|
96
|
+
if (propertyIsUnsafe(target, key)) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
|
|
100
|
+
destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
|
|
101
|
+
} else {
|
|
102
|
+
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
return destination;
|
|
106
|
+
}
|
|
107
|
+
function deepmerge2(target, source, options) {
|
|
108
|
+
options = options || {};
|
|
109
|
+
options.arrayMerge = options.arrayMerge || defaultArrayMerge;
|
|
110
|
+
options.isMergeableObject = options.isMergeableObject || isMergeableObject;
|
|
111
|
+
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
|
|
112
|
+
var sourceIsArray = Array.isArray(source);
|
|
113
|
+
var targetIsArray = Array.isArray(target);
|
|
114
|
+
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
|
|
115
|
+
if (!sourceAndTargetTypesMatch) {
|
|
116
|
+
return cloneUnlessOtherwiseSpecified(source, options);
|
|
117
|
+
} else if (sourceIsArray) {
|
|
118
|
+
return options.arrayMerge(target, source, options);
|
|
119
|
+
} else {
|
|
120
|
+
return mergeObject(target, source, options);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
deepmerge2.all = function deepmergeAll(array, options) {
|
|
124
|
+
if (!Array.isArray(array)) {
|
|
125
|
+
throw new Error("first argument should be an array");
|
|
126
|
+
}
|
|
127
|
+
return array.reduce(function(prev, next) {
|
|
128
|
+
return deepmerge2(prev, next, options);
|
|
129
|
+
}, {});
|
|
130
|
+
};
|
|
131
|
+
var deepmerge_1 = deepmerge2;
|
|
132
|
+
module.exports = deepmerge_1;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
23
135
|
|
|
24
136
|
// src/index.ts
|
|
25
|
-
|
|
137
|
+
init_tsup_inject();
|
|
26
138
|
import { useResponsiveValue, useBreakpointIndex } from "@theme-ui/match-media";
|
|
27
|
-
import { Themed } from "@theme-ui/mdx";
|
|
28
139
|
|
|
29
140
|
// src/theme/ThemeProvider.tsx
|
|
30
|
-
|
|
31
|
-
import { ThemeProvider as ThemeUiProvider, merge } from "@theme-ui/core";
|
|
141
|
+
init_tsup_inject();
|
|
32
142
|
import * as React2 from "react";
|
|
143
|
+
import { Global, css } from "@emotion/react";
|
|
144
|
+
import { ThemeProvider as ThemeUiProvider, merge } from "theme-ui";
|
|
33
145
|
|
|
34
146
|
// src/theme/defaultFonts.ts
|
|
147
|
+
init_tsup_inject();
|
|
35
148
|
var defaultFonts = [
|
|
36
149
|
"https://fonts.googleapis.com/css?family=Asap",
|
|
37
150
|
"https://fonts.googleapis.com/css?family=Overpass",
|
|
@@ -40,6 +153,7 @@ var defaultFonts = [
|
|
|
40
153
|
];
|
|
41
154
|
|
|
42
155
|
// src/theme/defaultTheme.ts
|
|
156
|
+
init_tsup_inject();
|
|
43
157
|
var defaultTheme = {
|
|
44
158
|
colors: {
|
|
45
159
|
text: "#000",
|
|
@@ -134,112 +248,118 @@ var ThemeProvider = ({
|
|
|
134
248
|
styles: css`
|
|
135
249
|
@import url('${url}');
|
|
136
250
|
`
|
|
137
|
-
})),
|
|
138
|
-
styles: {
|
|
139
|
-
"*": {
|
|
140
|
-
margin: 0
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}), children));
|
|
251
|
+
})), children));
|
|
144
252
|
};
|
|
145
253
|
var ThemeProvider_default = ThemeProvider;
|
|
146
254
|
|
|
147
255
|
// src/theme/useTheme.ts
|
|
148
|
-
|
|
256
|
+
init_tsup_inject();
|
|
257
|
+
|
|
258
|
+
// ../../node_modules/@theme-ui/core/dist/theme-ui-core.esm.js
|
|
259
|
+
init_tsup_inject();
|
|
260
|
+
var import_deepmerge = __toESM(require_cjs());
|
|
261
|
+
import { jsx as jsx$1, ThemeContext } from "@emotion/react";
|
|
262
|
+
import { createContext, useContext } from "react";
|
|
263
|
+
import packageInfo from "@emotion/react/package.json";
|
|
264
|
+
var __EMOTION_VERSION__ = packageInfo.version;
|
|
265
|
+
var __themeUiDefaultContextValue = {
|
|
266
|
+
__EMOTION_VERSION__,
|
|
267
|
+
theme: {}
|
|
268
|
+
};
|
|
269
|
+
var __ThemeUIContext = /* @__PURE__ */ createContext(__themeUiDefaultContextValue);
|
|
270
|
+
var useThemeUI = () => useContext(__ThemeUIContext);
|
|
271
|
+
var canUseSymbol = typeof Symbol === "function" && Symbol.for;
|
|
272
|
+
var REACT_ELEMENT = canUseSymbol ? Symbol.for("react.element") : 60103;
|
|
273
|
+
var FORWARD_REF = canUseSymbol ? Symbol.for("react.forward_ref") : 60103;
|
|
274
|
+
var deepmergeOptions = {
|
|
275
|
+
isMergeableObject: (n) => {
|
|
276
|
+
return !!n && typeof n === "object" && n.$$typeof !== REACT_ELEMENT && n.$$typeof !== FORWARD_REF;
|
|
277
|
+
},
|
|
278
|
+
arrayMerge: (_leftArray, rightArray) => rightArray
|
|
279
|
+
};
|
|
280
|
+
var merge2 = (a, b) => (0, import_deepmerge.default)(a, b, deepmergeOptions);
|
|
281
|
+
function mergeAll(...args) {
|
|
282
|
+
return import_deepmerge.default.all(args, deepmergeOptions);
|
|
283
|
+
}
|
|
284
|
+
merge2.all = mergeAll;
|
|
285
|
+
|
|
286
|
+
// src/theme/useTheme.ts
|
|
149
287
|
var useTheme = useThemeUI;
|
|
150
288
|
|
|
151
289
|
// src/components/Box/Box.tsx
|
|
152
|
-
|
|
290
|
+
init_tsup_inject();
|
|
291
|
+
import { Box } from "theme-ui";
|
|
153
292
|
|
|
154
293
|
// src/components/Button/Button.tsx
|
|
155
|
-
|
|
294
|
+
init_tsup_inject();
|
|
295
|
+
import { Button as ButtonUi } from "theme-ui";
|
|
156
296
|
var Button = (props) => {
|
|
157
|
-
return /* @__PURE__ */ React.createElement(ButtonUi,
|
|
158
|
-
|
|
159
|
-
|
|
297
|
+
return /* @__PURE__ */ React.createElement(ButtonUi, {
|
|
298
|
+
...props,
|
|
299
|
+
sx: { cursor: "pointer", fontFamily: "body", ...props.sx }
|
|
300
|
+
});
|
|
160
301
|
};
|
|
161
|
-
var Button_default = Button;
|
|
162
302
|
|
|
163
303
|
// src/components/Card/Card.tsx
|
|
164
|
-
|
|
304
|
+
init_tsup_inject();
|
|
305
|
+
import { Card } from "theme-ui";
|
|
165
306
|
|
|
166
307
|
// src/components/Divider/Divider.tsx
|
|
167
|
-
|
|
308
|
+
init_tsup_inject();
|
|
309
|
+
import { Divider } from "theme-ui";
|
|
168
310
|
|
|
169
311
|
// src/components/Flex/Flex.tsx
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
// src/components/FormField/FormField.tsx
|
|
173
|
-
import * as React3 from "react";
|
|
174
|
-
|
|
175
|
-
// src/components/Label/Label.tsx
|
|
176
|
-
import { Label } from "@theme-ui/components";
|
|
177
|
-
|
|
178
|
-
// src/components/Text/Text.tsx
|
|
179
|
-
import { Text } from "@theme-ui/components";
|
|
180
|
-
|
|
181
|
-
// src/components/FormField/FormField.tsx
|
|
182
|
-
var FormField = ({ children, label, error }) => {
|
|
183
|
-
const errorAsArray = (() => {
|
|
184
|
-
if (Array.isArray(error)) {
|
|
185
|
-
return error;
|
|
186
|
-
}
|
|
187
|
-
if (typeof error === "string") {
|
|
188
|
-
return [error];
|
|
189
|
-
}
|
|
190
|
-
return [];
|
|
191
|
-
})();
|
|
192
|
-
return /* @__PURE__ */ React3.createElement(Box, null, /* @__PURE__ */ React3.createElement(Label, {
|
|
193
|
-
sx: { display: "flex", flexDirection: "column" }
|
|
194
|
-
}, label && /* @__PURE__ */ React3.createElement(Text, {
|
|
195
|
-
as: "span"
|
|
196
|
-
}, label), children), errorAsArray.map((err) => /* @__PURE__ */ React3.createElement(Text, {
|
|
197
|
-
key: err,
|
|
198
|
-
as: "span",
|
|
199
|
-
variant: "error"
|
|
200
|
-
}, err)));
|
|
201
|
-
};
|
|
202
|
-
var FormField_default = FormField;
|
|
312
|
+
init_tsup_inject();
|
|
313
|
+
import { Flex } from "theme-ui";
|
|
203
314
|
|
|
204
315
|
// src/components/Grid/Grid.tsx
|
|
205
|
-
|
|
316
|
+
init_tsup_inject();
|
|
317
|
+
import { Grid } from "theme-ui";
|
|
206
318
|
|
|
207
319
|
// src/components/Heading/Heading.tsx
|
|
208
|
-
|
|
320
|
+
init_tsup_inject();
|
|
321
|
+
import { Heading } from "theme-ui";
|
|
209
322
|
|
|
210
323
|
// src/components/Image/Image.tsx
|
|
211
|
-
|
|
324
|
+
init_tsup_inject();
|
|
325
|
+
import { Image } from "theme-ui";
|
|
212
326
|
|
|
213
327
|
// src/components/Input/Input.tsx
|
|
214
|
-
|
|
328
|
+
init_tsup_inject();
|
|
329
|
+
import { Input } from "theme-ui";
|
|
215
330
|
|
|
216
331
|
// src/components/Link/Link.tsx
|
|
217
|
-
|
|
332
|
+
init_tsup_inject();
|
|
333
|
+
import { Link } from "theme-ui";
|
|
218
334
|
|
|
219
335
|
// src/components/LinearProgress/LinearProgress.tsx
|
|
220
|
-
|
|
221
|
-
|
|
336
|
+
init_tsup_inject();
|
|
337
|
+
import {
|
|
338
|
+
Progress
|
|
339
|
+
} from "theme-ui";
|
|
340
|
+
|
|
341
|
+
// src/components/Text/Text.tsx
|
|
342
|
+
init_tsup_inject();
|
|
343
|
+
import { Text } from "theme-ui";
|
|
222
344
|
|
|
223
345
|
// src/components/Select/Select.tsx
|
|
224
|
-
|
|
346
|
+
init_tsup_inject();
|
|
347
|
+
import { Select } from "theme-ui";
|
|
225
348
|
export {
|
|
226
349
|
Box,
|
|
227
|
-
|
|
350
|
+
Button,
|
|
228
351
|
Card,
|
|
229
352
|
Divider,
|
|
230
353
|
Flex,
|
|
231
|
-
FormField_default as FormField,
|
|
232
354
|
Grid,
|
|
233
355
|
Heading,
|
|
234
356
|
Image,
|
|
235
357
|
Input,
|
|
236
|
-
LinearProgress,
|
|
358
|
+
Progress as LinearProgress,
|
|
237
359
|
Link,
|
|
238
360
|
Select,
|
|
239
361
|
Text,
|
|
240
362
|
ThemeProvider_default as ThemeProvider,
|
|
241
|
-
Themed,
|
|
242
|
-
color,
|
|
243
363
|
useBreakpointIndex,
|
|
244
364
|
useResponsiveValue,
|
|
245
365
|
useTheme
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
export {
|
|
3
|
-
import * as _theme_ui_core from '@theme-ui/core';
|
|
4
|
-
import { Theme } from '@theme-ui/core';
|
|
5
|
-
export { Theme } from '@theme-ui/core';
|
|
1
|
+
import { Theme, ButtonProps } from 'theme-ui';
|
|
2
|
+
export { Box, BoxProps, ButtonProps, Card, CardProps, Divider, DividerProps, Flex, FlexProps, Grid, GridProps, Heading, HeadingProps, Image, ImageProps, Input, InputProps, Progress as LinearProgress, ProgressProps as LinearProgressProps, Link, LinkProps, Select, SelectProps, Text, TextProps, Theme } from 'theme-ui';
|
|
6
3
|
export { useBreakpointIndex, useResponsiveValue } from '@theme-ui/match-media';
|
|
7
|
-
export { Themed } from '@theme-ui/mdx';
|
|
8
4
|
import * as React from 'react';
|
|
9
|
-
import
|
|
10
|
-
export { Box, BoxProps, ButtonProps, Card, CardProps, Divider, DividerProps, Flex, FlexProps, Grid, GridProps, Heading, HeadingProps, Image, ImageProps, Input, InputProps, Link, LinkProps, Select, SelectProps, Text, TextProps } from '@theme-ui/components';
|
|
11
|
-
import * as _theme_ui_components_dist_declarations_src_types from '@theme-ui/components/dist/declarations/src/types';
|
|
5
|
+
import * as _theme_ui_core from '@theme-ui/core';
|
|
12
6
|
|
|
13
7
|
declare type ThemeProviderProps = {
|
|
14
8
|
children?: React.ReactNode;
|
|
@@ -24,14 +18,4 @@ declare const useTheme: () => _theme_ui_core.ThemeUIContextValue;
|
|
|
24
18
|
|
|
25
19
|
declare const Button: (props: ButtonProps) => JSX.Element;
|
|
26
20
|
|
|
27
|
-
|
|
28
|
-
children?: React.ReactNode;
|
|
29
|
-
label?: string;
|
|
30
|
-
error?: string[] | string;
|
|
31
|
-
};
|
|
32
|
-
declare const FormField: ({ children, label, error }: FormFieldProps) => JSX.Element;
|
|
33
|
-
|
|
34
|
-
declare type LinearProgressProps = ProgressProps;
|
|
35
|
-
declare const LinearProgress: _theme_ui_components_dist_declarations_src_types.ForwardRef<HTMLProgressElement, ProgressProps>;
|
|
36
|
-
|
|
37
|
-
export { Button, FormField, FormFieldProps, LinearProgress, LinearProgressProps, ThemeProvider, ThemeProviderProps, useTheme };
|
|
21
|
+
export { Button, ThemeProvider, ThemeProviderProps, useTheme };
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
11
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
12
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
22
13
|
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
14
|
var __export = (target, all) => {
|
|
25
15
|
for (var name in all)
|
|
26
16
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -36,46 +26,152 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
36
26
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
37
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
28
|
|
|
29
|
+
// tsup.inject.js
|
|
30
|
+
var React;
|
|
31
|
+
var init_tsup_inject = __esm({
|
|
32
|
+
"tsup.inject.js"() {
|
|
33
|
+
"use strict";
|
|
34
|
+
React = __toESM(require("react"));
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// ../../node_modules/deepmerge/dist/cjs.js
|
|
39
|
+
var require_cjs = __commonJS({
|
|
40
|
+
"../../node_modules/deepmerge/dist/cjs.js"(exports, module2) {
|
|
41
|
+
"use strict";
|
|
42
|
+
init_tsup_inject();
|
|
43
|
+
var isMergeableObject = function isMergeableObject2(value) {
|
|
44
|
+
return isNonNullObject(value) && !isSpecial(value);
|
|
45
|
+
};
|
|
46
|
+
function isNonNullObject(value) {
|
|
47
|
+
return !!value && typeof value === "object";
|
|
48
|
+
}
|
|
49
|
+
function isSpecial(value) {
|
|
50
|
+
var stringValue = Object.prototype.toString.call(value);
|
|
51
|
+
return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
|
|
52
|
+
}
|
|
53
|
+
var canUseSymbol2 = typeof Symbol === "function" && Symbol.for;
|
|
54
|
+
var REACT_ELEMENT_TYPE = canUseSymbol2 ? Symbol.for("react.element") : 60103;
|
|
55
|
+
function isReactElement(value) {
|
|
56
|
+
return value.$$typeof === REACT_ELEMENT_TYPE;
|
|
57
|
+
}
|
|
58
|
+
function emptyTarget(val) {
|
|
59
|
+
return Array.isArray(val) ? [] : {};
|
|
60
|
+
}
|
|
61
|
+
function cloneUnlessOtherwiseSpecified(value, options) {
|
|
62
|
+
return options.clone !== false && options.isMergeableObject(value) ? deepmerge2(emptyTarget(value), value, options) : value;
|
|
63
|
+
}
|
|
64
|
+
function defaultArrayMerge(target, source, options) {
|
|
65
|
+
return target.concat(source).map(function(element) {
|
|
66
|
+
return cloneUnlessOtherwiseSpecified(element, options);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function getMergeFunction(key, options) {
|
|
70
|
+
if (!options.customMerge) {
|
|
71
|
+
return deepmerge2;
|
|
72
|
+
}
|
|
73
|
+
var customMerge = options.customMerge(key);
|
|
74
|
+
return typeof customMerge === "function" ? customMerge : deepmerge2;
|
|
75
|
+
}
|
|
76
|
+
function getEnumerableOwnPropertySymbols(target) {
|
|
77
|
+
return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
|
|
78
|
+
return target.propertyIsEnumerable(symbol);
|
|
79
|
+
}) : [];
|
|
80
|
+
}
|
|
81
|
+
function getKeys(target) {
|
|
82
|
+
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
|
|
83
|
+
}
|
|
84
|
+
function propertyIsOnObject(object, property) {
|
|
85
|
+
try {
|
|
86
|
+
return property in object;
|
|
87
|
+
} catch (_) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function propertyIsUnsafe(target, key) {
|
|
92
|
+
return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
|
|
93
|
+
}
|
|
94
|
+
function mergeObject(target, source, options) {
|
|
95
|
+
var destination = {};
|
|
96
|
+
if (options.isMergeableObject(target)) {
|
|
97
|
+
getKeys(target).forEach(function(key) {
|
|
98
|
+
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
getKeys(source).forEach(function(key) {
|
|
102
|
+
if (propertyIsUnsafe(target, key)) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
|
|
106
|
+
destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
|
|
107
|
+
} else {
|
|
108
|
+
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
return destination;
|
|
112
|
+
}
|
|
113
|
+
function deepmerge2(target, source, options) {
|
|
114
|
+
options = options || {};
|
|
115
|
+
options.arrayMerge = options.arrayMerge || defaultArrayMerge;
|
|
116
|
+
options.isMergeableObject = options.isMergeableObject || isMergeableObject;
|
|
117
|
+
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
|
|
118
|
+
var sourceIsArray = Array.isArray(source);
|
|
119
|
+
var targetIsArray = Array.isArray(target);
|
|
120
|
+
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
|
|
121
|
+
if (!sourceAndTargetTypesMatch) {
|
|
122
|
+
return cloneUnlessOtherwiseSpecified(source, options);
|
|
123
|
+
} else if (sourceIsArray) {
|
|
124
|
+
return options.arrayMerge(target, source, options);
|
|
125
|
+
} else {
|
|
126
|
+
return mergeObject(target, source, options);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
deepmerge2.all = function deepmergeAll(array, options) {
|
|
130
|
+
if (!Array.isArray(array)) {
|
|
131
|
+
throw new Error("first argument should be an array");
|
|
132
|
+
}
|
|
133
|
+
return array.reduce(function(prev, next) {
|
|
134
|
+
return deepmerge2(prev, next, options);
|
|
135
|
+
}, {});
|
|
136
|
+
};
|
|
137
|
+
var deepmerge_1 = deepmerge2;
|
|
138
|
+
module2.exports = deepmerge_1;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
39
142
|
// src/index.ts
|
|
40
143
|
var src_exports = {};
|
|
41
144
|
__export(src_exports, {
|
|
42
|
-
Box: () =>
|
|
43
|
-
Button: () =>
|
|
44
|
-
Card: () =>
|
|
45
|
-
Divider: () =>
|
|
46
|
-
Flex: () =>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
Text: () => import_components7.Text,
|
|
145
|
+
Box: () => import_theme_ui2.Box,
|
|
146
|
+
Button: () => Button,
|
|
147
|
+
Card: () => import_theme_ui4.Card,
|
|
148
|
+
Divider: () => import_theme_ui5.Divider,
|
|
149
|
+
Flex: () => import_theme_ui6.Flex,
|
|
150
|
+
Grid: () => import_theme_ui7.Grid,
|
|
151
|
+
Heading: () => import_theme_ui8.Heading,
|
|
152
|
+
Image: () => import_theme_ui9.Image,
|
|
153
|
+
Input: () => import_theme_ui10.Input,
|
|
154
|
+
LinearProgress: () => import_theme_ui12.Progress,
|
|
155
|
+
Link: () => import_theme_ui11.Link,
|
|
156
|
+
Select: () => import_theme_ui14.Select,
|
|
157
|
+
Text: () => import_theme_ui13.Text,
|
|
56
158
|
ThemeProvider: () => ThemeProvider_default,
|
|
57
|
-
Themed: () => import_mdx.Themed,
|
|
58
|
-
color: () => color,
|
|
59
159
|
useBreakpointIndex: () => import_match_media.useBreakpointIndex,
|
|
60
160
|
useResponsiveValue: () => import_match_media.useResponsiveValue,
|
|
61
161
|
useTheme: () => useTheme
|
|
62
162
|
});
|
|
63
163
|
module.exports = __toCommonJS(src_exports);
|
|
64
|
-
|
|
65
|
-
// tsup.inject.js
|
|
66
|
-
var React = __toESM(require("react"));
|
|
67
|
-
|
|
68
|
-
// src/index.ts
|
|
69
|
-
var color = __toESM(require("@theme-ui/color"));
|
|
164
|
+
init_tsup_inject();
|
|
70
165
|
var import_match_media = require("@theme-ui/match-media");
|
|
71
|
-
var import_mdx = require("@theme-ui/mdx");
|
|
72
166
|
|
|
73
167
|
// src/theme/ThemeProvider.tsx
|
|
74
|
-
|
|
75
|
-
var import_core = require("@theme-ui/core");
|
|
168
|
+
init_tsup_inject();
|
|
76
169
|
var React2 = __toESM(require("react"));
|
|
170
|
+
var import_react = require("@emotion/react");
|
|
171
|
+
var import_theme_ui = require("theme-ui");
|
|
77
172
|
|
|
78
173
|
// src/theme/defaultFonts.ts
|
|
174
|
+
init_tsup_inject();
|
|
79
175
|
var defaultFonts = [
|
|
80
176
|
"https://fonts.googleapis.com/css?family=Asap",
|
|
81
177
|
"https://fonts.googleapis.com/css?family=Overpass",
|
|
@@ -84,6 +180,7 @@ var defaultFonts = [
|
|
|
84
180
|
];
|
|
85
181
|
|
|
86
182
|
// src/theme/defaultTheme.ts
|
|
183
|
+
init_tsup_inject();
|
|
87
184
|
var defaultTheme = {
|
|
88
185
|
colors: {
|
|
89
186
|
text: "#000",
|
|
@@ -169,103 +266,110 @@ var ThemeProvider = ({
|
|
|
169
266
|
if (typeof theme === "function") {
|
|
170
267
|
return theme;
|
|
171
268
|
}
|
|
172
|
-
return (0,
|
|
269
|
+
return (0, import_theme_ui.merge)(defaultTheme, theme);
|
|
173
270
|
}, [theme]);
|
|
174
|
-
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
|
|
271
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(import_theme_ui.ThemeProvider, {
|
|
175
272
|
theme: mergedTheme
|
|
176
273
|
}, fonts.map((url) => /* @__PURE__ */ React2.createElement(import_react.Global, {
|
|
177
274
|
key: url,
|
|
178
275
|
styles: import_react.css`
|
|
179
276
|
@import url('${url}');
|
|
180
277
|
`
|
|
181
|
-
})),
|
|
182
|
-
styles: {
|
|
183
|
-
"*": {
|
|
184
|
-
margin: 0
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}), children));
|
|
278
|
+
})), children));
|
|
188
279
|
};
|
|
189
280
|
var ThemeProvider_default = ThemeProvider;
|
|
190
281
|
|
|
191
282
|
// src/theme/useTheme.ts
|
|
192
|
-
|
|
193
|
-
|
|
283
|
+
init_tsup_inject();
|
|
284
|
+
|
|
285
|
+
// ../../node_modules/@theme-ui/core/dist/theme-ui-core.esm.js
|
|
286
|
+
init_tsup_inject();
|
|
287
|
+
var import_react2 = require("@emotion/react");
|
|
288
|
+
var import_react3 = require("react");
|
|
289
|
+
var import_deepmerge = __toESM(require_cjs());
|
|
290
|
+
var import_package = __toESM(require("@emotion/react/package.json"));
|
|
291
|
+
var __EMOTION_VERSION__ = import_package.default.version;
|
|
292
|
+
var __themeUiDefaultContextValue = {
|
|
293
|
+
__EMOTION_VERSION__,
|
|
294
|
+
theme: {}
|
|
295
|
+
};
|
|
296
|
+
var __ThemeUIContext = /* @__PURE__ */ (0, import_react3.createContext)(__themeUiDefaultContextValue);
|
|
297
|
+
var useThemeUI = () => (0, import_react3.useContext)(__ThemeUIContext);
|
|
298
|
+
var canUseSymbol = typeof Symbol === "function" && Symbol.for;
|
|
299
|
+
var REACT_ELEMENT = canUseSymbol ? Symbol.for("react.element") : 60103;
|
|
300
|
+
var FORWARD_REF = canUseSymbol ? Symbol.for("react.forward_ref") : 60103;
|
|
301
|
+
var deepmergeOptions = {
|
|
302
|
+
isMergeableObject: (n) => {
|
|
303
|
+
return !!n && typeof n === "object" && n.$$typeof !== REACT_ELEMENT && n.$$typeof !== FORWARD_REF;
|
|
304
|
+
},
|
|
305
|
+
arrayMerge: (_leftArray, rightArray) => rightArray
|
|
306
|
+
};
|
|
307
|
+
var merge2 = (a, b) => (0, import_deepmerge.default)(a, b, deepmergeOptions);
|
|
308
|
+
function mergeAll(...args) {
|
|
309
|
+
return import_deepmerge.default.all(args, deepmergeOptions);
|
|
310
|
+
}
|
|
311
|
+
merge2.all = mergeAll;
|
|
312
|
+
|
|
313
|
+
// src/theme/useTheme.ts
|
|
314
|
+
var useTheme = useThemeUI;
|
|
194
315
|
|
|
195
316
|
// src/components/Box/Box.tsx
|
|
196
|
-
|
|
317
|
+
init_tsup_inject();
|
|
318
|
+
var import_theme_ui2 = require("theme-ui");
|
|
197
319
|
|
|
198
320
|
// src/components/Button/Button.tsx
|
|
199
|
-
|
|
321
|
+
init_tsup_inject();
|
|
322
|
+
var import_theme_ui3 = require("theme-ui");
|
|
200
323
|
var Button = (props) => {
|
|
201
|
-
return /* @__PURE__ */ React.createElement(
|
|
202
|
-
|
|
203
|
-
|
|
324
|
+
return /* @__PURE__ */ React.createElement(import_theme_ui3.Button, {
|
|
325
|
+
...props,
|
|
326
|
+
sx: { cursor: "pointer", fontFamily: "body", ...props.sx }
|
|
327
|
+
});
|
|
204
328
|
};
|
|
205
|
-
var Button_default = Button;
|
|
206
329
|
|
|
207
330
|
// src/components/Card/Card.tsx
|
|
208
|
-
|
|
331
|
+
init_tsup_inject();
|
|
332
|
+
var import_theme_ui4 = require("theme-ui");
|
|
209
333
|
|
|
210
334
|
// src/components/Divider/Divider.tsx
|
|
211
|
-
|
|
335
|
+
init_tsup_inject();
|
|
336
|
+
var import_theme_ui5 = require("theme-ui");
|
|
212
337
|
|
|
213
338
|
// src/components/Flex/Flex.tsx
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
// src/components/FormField/FormField.tsx
|
|
217
|
-
var React3 = __toESM(require("react"));
|
|
218
|
-
|
|
219
|
-
// src/components/Label/Label.tsx
|
|
220
|
-
var import_components6 = require("@theme-ui/components");
|
|
221
|
-
|
|
222
|
-
// src/components/Text/Text.tsx
|
|
223
|
-
var import_components7 = require("@theme-ui/components");
|
|
224
|
-
|
|
225
|
-
// src/components/FormField/FormField.tsx
|
|
226
|
-
var FormField = ({ children, label, error }) => {
|
|
227
|
-
const errorAsArray = (() => {
|
|
228
|
-
if (Array.isArray(error)) {
|
|
229
|
-
return error;
|
|
230
|
-
}
|
|
231
|
-
if (typeof error === "string") {
|
|
232
|
-
return [error];
|
|
233
|
-
}
|
|
234
|
-
return [];
|
|
235
|
-
})();
|
|
236
|
-
return /* @__PURE__ */ React3.createElement(import_components.Box, null, /* @__PURE__ */ React3.createElement(import_components6.Label, {
|
|
237
|
-
sx: { display: "flex", flexDirection: "column" }
|
|
238
|
-
}, label && /* @__PURE__ */ React3.createElement(import_components7.Text, {
|
|
239
|
-
as: "span"
|
|
240
|
-
}, label), children), errorAsArray.map((err) => /* @__PURE__ */ React3.createElement(import_components7.Text, {
|
|
241
|
-
key: err,
|
|
242
|
-
as: "span",
|
|
243
|
-
variant: "error"
|
|
244
|
-
}, err)));
|
|
245
|
-
};
|
|
246
|
-
var FormField_default = FormField;
|
|
339
|
+
init_tsup_inject();
|
|
340
|
+
var import_theme_ui6 = require("theme-ui");
|
|
247
341
|
|
|
248
342
|
// src/components/Grid/Grid.tsx
|
|
249
|
-
|
|
343
|
+
init_tsup_inject();
|
|
344
|
+
var import_theme_ui7 = require("theme-ui");
|
|
250
345
|
|
|
251
346
|
// src/components/Heading/Heading.tsx
|
|
252
|
-
|
|
347
|
+
init_tsup_inject();
|
|
348
|
+
var import_theme_ui8 = require("theme-ui");
|
|
253
349
|
|
|
254
350
|
// src/components/Image/Image.tsx
|
|
255
|
-
|
|
351
|
+
init_tsup_inject();
|
|
352
|
+
var import_theme_ui9 = require("theme-ui");
|
|
256
353
|
|
|
257
354
|
// src/components/Input/Input.tsx
|
|
258
|
-
|
|
355
|
+
init_tsup_inject();
|
|
356
|
+
var import_theme_ui10 = require("theme-ui");
|
|
259
357
|
|
|
260
358
|
// src/components/Link/Link.tsx
|
|
261
|
-
|
|
359
|
+
init_tsup_inject();
|
|
360
|
+
var import_theme_ui11 = require("theme-ui");
|
|
262
361
|
|
|
263
362
|
// src/components/LinearProgress/LinearProgress.tsx
|
|
264
|
-
|
|
265
|
-
var
|
|
363
|
+
init_tsup_inject();
|
|
364
|
+
var import_theme_ui12 = require("theme-ui");
|
|
365
|
+
|
|
366
|
+
// src/components/Text/Text.tsx
|
|
367
|
+
init_tsup_inject();
|
|
368
|
+
var import_theme_ui13 = require("theme-ui");
|
|
266
369
|
|
|
267
370
|
// src/components/Select/Select.tsx
|
|
268
|
-
|
|
371
|
+
init_tsup_inject();
|
|
372
|
+
var import_theme_ui14 = require("theme-ui");
|
|
269
373
|
// Annotate the CommonJS export names for ESM import in node:
|
|
270
374
|
0 && (module.exports = {
|
|
271
375
|
Box,
|
|
@@ -273,7 +377,6 @@ var import_components14 = require("@theme-ui/components");
|
|
|
273
377
|
Card,
|
|
274
378
|
Divider,
|
|
275
379
|
Flex,
|
|
276
|
-
FormField,
|
|
277
380
|
Grid,
|
|
278
381
|
Heading,
|
|
279
382
|
Image,
|
|
@@ -283,8 +386,6 @@ var import_components14 = require("@theme-ui/components");
|
|
|
283
386
|
Select,
|
|
284
387
|
Text,
|
|
285
388
|
ThemeProvider,
|
|
286
|
-
Themed,
|
|
287
|
-
color,
|
|
288
389
|
useBreakpointIndex,
|
|
289
390
|
useResponsiveValue,
|
|
290
391
|
useTheme
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.5",
|
|
4
4
|
"description": "Primitive layout, typographic, and other components for styling applications.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"publishConfig": {
|
|
@@ -33,20 +33,19 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@emotion/react": "^11",
|
|
36
|
-
"@emotion/styled": "^11",
|
|
37
36
|
"@mdx-js/react": "^1",
|
|
38
|
-
"@theme-ui/color": "^0.14.3",
|
|
39
|
-
"@theme-ui/components": "^0.14.3",
|
|
40
|
-
"@theme-ui/core": "^0.14.3",
|
|
41
37
|
"@theme-ui/match-media": "^0.14.3",
|
|
42
|
-
"
|
|
38
|
+
"theme-ui": "^0.14.6"
|
|
43
39
|
},
|
|
44
40
|
"peerDependencies": {
|
|
45
|
-
"react": ">=
|
|
41
|
+
"react": ">=18.0.0"
|
|
46
42
|
},
|
|
47
43
|
"devDependencies": {
|
|
48
|
-
"@ttoss/config": "^1.
|
|
49
|
-
"@ttoss/test-utils": "^1.
|
|
44
|
+
"@ttoss/config": "^1.16.1",
|
|
45
|
+
"@ttoss/test-utils": "^1.16.5",
|
|
46
|
+
"@types/jest": "^28.1.3",
|
|
47
|
+
"jest": "^28.1.1",
|
|
48
|
+
"tsup": "^6.1.2"
|
|
50
49
|
},
|
|
51
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "84559f07bf60bfccb886db9cea042da09e99bcdb"
|
|
52
51
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { Button as ButtonUi } from '
|
|
2
|
-
|
|
3
|
-
import type { ButtonProps } from '@theme-ui/components';
|
|
1
|
+
import { type ButtonProps, Button as ButtonUi } from 'theme-ui';
|
|
4
2
|
|
|
5
3
|
export type { ButtonProps };
|
|
6
4
|
|
|
7
|
-
const Button = (props: ButtonProps) => {
|
|
5
|
+
export const Button = (props: ButtonProps) => {
|
|
8
6
|
return (
|
|
9
7
|
<ButtonUi
|
|
10
8
|
{...props}
|
|
@@ -12,5 +10,3 @@ const Button = (props: ButtonProps) => {
|
|
|
12
10
|
/>
|
|
13
11
|
);
|
|
14
12
|
};
|
|
15
|
-
|
|
16
|
-
export default Button;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Divider, DividerProps } from '
|
|
1
|
+
export { Divider, type DividerProps } from 'theme-ui';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Grid, type GridProps } from '
|
|
1
|
+
export { Grid, type GridProps } from 'theme-ui';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Heading, HeadingProps } from '
|
|
1
|
+
export { Heading, type HeadingProps } from 'theme-ui';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const LinearProgress = Progress;
|
|
1
|
+
export {
|
|
2
|
+
Progress as LinearProgress,
|
|
3
|
+
type ProgressProps as LinearProgressProps,
|
|
4
|
+
} from 'theme-ui';
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export type { Theme } from '@theme-ui/core';
|
|
1
|
+
export type { Theme } from 'theme-ui';
|
|
3
2
|
export { useResponsiveValue, useBreakpointIndex } from '@theme-ui/match-media';
|
|
4
|
-
export { Themed } from '@theme-ui/mdx';
|
|
5
3
|
|
|
6
4
|
export {
|
|
7
5
|
default as ThemeProvider,
|
|
@@ -10,29 +8,19 @@ export {
|
|
|
10
8
|
|
|
11
9
|
export { useTheme } from './theme/useTheme';
|
|
12
10
|
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
|
|
16
|
-
type ButtonProps,
|
|
17
|
-
} from './components/Button/Button';
|
|
18
|
-
export { default as Card, type CardProps } from './components/Card/Card';
|
|
11
|
+
export { Box, type BoxProps } from './components/Box/Box';
|
|
12
|
+
export { Button, type ButtonProps } from './components/Button/Button';
|
|
13
|
+
export { Card, type CardProps } from './components/Card/Card';
|
|
19
14
|
export { Divider, type DividerProps } from './components/Divider/Divider';
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
22
|
-
default as FormField,
|
|
23
|
-
type FormFieldProps,
|
|
24
|
-
} from './components/FormField/FormField';
|
|
15
|
+
export { Flex, type FlexProps } from './components/Flex/Flex';
|
|
25
16
|
export { Grid, type GridProps } from './components/Grid/Grid';
|
|
26
17
|
export { Heading, type HeadingProps } from './components/Heading/Heading';
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
29
|
-
export {
|
|
18
|
+
export { Image, type ImageProps } from './components/Image/Image';
|
|
19
|
+
export { Input, type InputProps } from './components/Input/Input';
|
|
20
|
+
export { Link, type LinkProps } from './components/Link/Link';
|
|
30
21
|
export {
|
|
31
22
|
LinearProgress,
|
|
32
23
|
type LinearProgressProps,
|
|
33
24
|
} from './components/LinearProgress/LinearProgress';
|
|
34
|
-
export {
|
|
35
|
-
export {
|
|
36
|
-
default as Select,
|
|
37
|
-
type SelectProps,
|
|
38
|
-
} from './components/Select/Select';
|
|
25
|
+
export { Text, type TextProps } from './components/Text/Text';
|
|
26
|
+
export { Select, type SelectProps } from './components/Select/Select';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { renderHook } from '@ttoss/test-utils';
|
|
2
|
-
|
|
3
1
|
import { defaultTheme } from './defaultTheme';
|
|
4
|
-
import
|
|
2
|
+
import { renderHook } from '@ttoss/test-utils';
|
|
5
3
|
import { useTheme } from './useTheme';
|
|
4
|
+
import ThemeProvider from './ThemeProvider';
|
|
6
5
|
|
|
7
6
|
test('should return default theme colors', () => {
|
|
8
7
|
const { result } = renderHook(() => useTheme(), {
|
|
@@ -10,30 +9,33 @@ test('should return default theme colors', () => {
|
|
|
10
9
|
initialProps: { theme: {} },
|
|
11
10
|
});
|
|
12
11
|
|
|
13
|
-
expect(result.current.theme.
|
|
12
|
+
expect(result.current.theme.rawColors).toEqual(defaultTheme.colors);
|
|
14
13
|
});
|
|
15
14
|
|
|
16
15
|
test('should return new theme colors', () => {
|
|
17
16
|
const newColor = '#000';
|
|
18
17
|
|
|
19
18
|
const { result } = renderHook(() => useTheme(), {
|
|
20
|
-
wrapper:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
wrapper: ({ children }: any) => (
|
|
20
|
+
<ThemeProvider
|
|
21
|
+
theme={{
|
|
22
|
+
colors: {
|
|
23
|
+
background: newColor,
|
|
24
|
+
text: newColor,
|
|
25
|
+
primary: newColor,
|
|
26
|
+
secondary: newColor,
|
|
27
|
+
},
|
|
28
|
+
}}
|
|
29
|
+
>
|
|
30
|
+
{children}
|
|
31
|
+
</ThemeProvider>
|
|
32
|
+
),
|
|
31
33
|
});
|
|
32
34
|
|
|
33
|
-
expect(result.current.theme.
|
|
34
|
-
expect(result.current.theme.
|
|
35
|
-
expect(result.current.theme.
|
|
36
|
-
expect(result.current.theme.
|
|
35
|
+
expect(result.current.theme.rawColors?.background).toEqual(newColor);
|
|
36
|
+
expect(result.current.theme.rawColors?.text).toEqual(newColor);
|
|
37
|
+
expect(result.current.theme.rawColors?.primary).toEqual(newColor);
|
|
38
|
+
expect(result.current.theme.rawColors?.secondary).toEqual(newColor);
|
|
37
39
|
});
|
|
38
40
|
|
|
39
41
|
test('should pass variants', () => {
|
|
@@ -55,13 +57,16 @@ test('should pass variants', () => {
|
|
|
55
57
|
};
|
|
56
58
|
|
|
57
59
|
const { result } = renderHook(() => useTheme(), {
|
|
58
|
-
wrapper:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
wrapper: ({ children }: any) => (
|
|
61
|
+
<ThemeProvider
|
|
62
|
+
theme={{
|
|
63
|
+
colors: {},
|
|
64
|
+
...variants,
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
67
|
+
{children}
|
|
68
|
+
</ThemeProvider>
|
|
69
|
+
),
|
|
65
70
|
});
|
|
66
71
|
|
|
67
72
|
expect(result.current.theme.cards).toEqual(
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Global, css } from '@emotion/react';
|
|
2
|
-
import { ThemeProvider as ThemeUiProvider, Theme, merge } from '@theme-ui/core';
|
|
3
1
|
import * as React from 'react';
|
|
4
|
-
|
|
2
|
+
import { Global, css } from '@emotion/react';
|
|
3
|
+
import { Theme, ThemeProvider as ThemeUiProvider, merge } from 'theme-ui';
|
|
5
4
|
import { defaultFonts } from './defaultFonts';
|
|
6
5
|
import { defaultTheme } from './defaultTheme';
|
|
7
6
|
|
|
@@ -38,13 +37,6 @@ const ThemeProvider = ({
|
|
|
38
37
|
`}
|
|
39
38
|
/>
|
|
40
39
|
))}
|
|
41
|
-
<Global
|
|
42
|
-
styles={{
|
|
43
|
-
'*': {
|
|
44
|
-
margin: 0,
|
|
45
|
-
},
|
|
46
|
-
}}
|
|
47
|
-
/>
|
|
48
40
|
{children}
|
|
49
41
|
</ThemeUiProvider>
|
|
50
42
|
</>
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '@ttoss/test-utils';
|
|
2
|
-
|
|
3
|
-
import Input from '../Input/Input';
|
|
4
|
-
|
|
5
|
-
import FormField from './FormField';
|
|
6
|
-
|
|
7
|
-
const label = 'Label';
|
|
8
|
-
const value = 'Value';
|
|
9
|
-
|
|
10
|
-
test('check if label is rendered on screen', () => {
|
|
11
|
-
render(
|
|
12
|
-
<FormField label={label}>
|
|
13
|
-
<Input defaultValue={value} />
|
|
14
|
-
</FormField>
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
expect(screen.getByText(label)).toBeInTheDocument();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test('check if label is associated with input', () => {
|
|
21
|
-
render(
|
|
22
|
-
<FormField label={label}>
|
|
23
|
-
<Input defaultValue={value} />
|
|
24
|
-
</FormField>
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
expect(screen.getByLabelText(label)).toHaveValue(value);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('check if renders a single error', () => {
|
|
31
|
-
const error = 'Error';
|
|
32
|
-
|
|
33
|
-
render(
|
|
34
|
-
<FormField label={label} error={error}>
|
|
35
|
-
<Input defaultValue={value} />
|
|
36
|
-
</FormField>
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
expect(screen.getByText(error)).toBeInTheDocument();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('check if renders multiple errors', () => {
|
|
43
|
-
const errors = ['Error1', 'Error2', 'Error3'];
|
|
44
|
-
|
|
45
|
-
render(
|
|
46
|
-
<FormField label={label} error={errors}>
|
|
47
|
-
<Input defaultValue={value} />
|
|
48
|
-
</FormField>
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
errors.forEach((error) => {
|
|
52
|
-
expect(screen.getByText(error)).toBeInTheDocument();
|
|
53
|
-
});
|
|
54
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
import Box from '../Box/Box';
|
|
4
|
-
import Label from '../Label/Label';
|
|
5
|
-
import Text from '../Text/Text';
|
|
6
|
-
|
|
7
|
-
export type FormFieldProps = {
|
|
8
|
-
children?: React.ReactNode;
|
|
9
|
-
label?: string;
|
|
10
|
-
error?: string[] | string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const FormField = ({ children, label, error }: FormFieldProps) => {
|
|
14
|
-
const errorAsArray = (() => {
|
|
15
|
-
if (Array.isArray(error)) {
|
|
16
|
-
return error;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (typeof error === 'string') {
|
|
20
|
-
return [error];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return [];
|
|
24
|
-
})();
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<Box>
|
|
28
|
-
<Label sx={{ display: 'flex', flexDirection: 'column' }}>
|
|
29
|
-
{label && <Text as="span">{label}</Text>}
|
|
30
|
-
{children}
|
|
31
|
-
</Label>
|
|
32
|
-
{errorAsArray.map((err) => (
|
|
33
|
-
<Text key={err} as="span" variant="error">
|
|
34
|
-
{err}
|
|
35
|
-
</Text>
|
|
36
|
-
))}
|
|
37
|
-
</Box>
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export default FormField;
|