@ttoss/ui 1.30.0 → 1.30.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/ui",
3
- "version": "1.30.0",
3
+ "version": "1.30.2",
4
4
  "description": "Primitive layout, typographic, and other components for styling applications.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "ttoss",
@@ -22,20 +22,20 @@
22
22
  "typings": "dist/index.d.ts",
23
23
  "dependencies": {
24
24
  "@emotion/react": "^11.10.5",
25
- "@iconify/react": "^4.1.0",
26
- "@theme-ui/match-media": "^0.15.4",
27
- "theme-ui": "^0.15.4"
25
+ "@theme-ui/match-media": "^0.15.5",
26
+ "theme-ui": "^0.15.5"
28
27
  },
29
28
  "peerDependencies": {
30
29
  "react": ">=16.8.0"
31
30
  },
32
31
  "devDependencies": {
33
- "@ttoss/config": "^1.28.0",
34
- "@ttoss/test-utils": "^1.20.2",
35
- "@ttoss/theme": "^1.2.3",
32
+ "@iconify-icon/react": "^1.0.5",
33
+ "@ttoss/config": "^1.28.1",
34
+ "@ttoss/test-utils": "^1.20.3",
35
+ "@ttoss/theme": "^1.2.4",
36
36
  "@types/jest": "^29.4.0",
37
- "jest": "^29.4.1",
38
- "tsup": "^6.5.0"
37
+ "jest": "^29.4.2",
38
+ "tsup": "^6.6.3"
39
39
  },
40
40
  "keywords": [
41
41
  "React",
@@ -45,5 +45,5 @@
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  },
48
- "gitHead": "7852c1c6c570e30cd03a603902f45fb4849c7701"
48
+ "gitHead": "d4df96176c1d3fce4ebf7842de5847a618a33d9e"
49
49
  }
@@ -1,12 +1,57 @@
1
- import { type ButtonProps, Button as ButtonUi } from 'theme-ui';
1
+ import * as React from 'react';
2
+ import {
3
+ type ButtonProps as ButtonPropsUi,
4
+ Button as ButtonUi,
5
+ } from 'theme-ui';
6
+ import { Icon } from './Icon';
2
7
 
3
- export type { ButtonProps };
8
+ export type ButtonProps = ButtonPropsUi & {
9
+ leftIcon?: React.ReactNode | string;
10
+ rightIcon?: React.ReactNode | string;
11
+ };
12
+
13
+ const RenderIcon = ({ icon }: { icon: React.ReactNode | string }) => {
14
+ if (!icon) {
15
+ return null;
16
+ }
4
17
 
5
- export const Button = (props: ButtonProps) => {
6
- return (
7
- <ButtonUi
8
- {...props}
9
- sx={{ cursor: 'pointer', fontFamily: 'body', ...props.sx }}
10
- />
11
- );
18
+ if (typeof icon === 'string') {
19
+ return (
20
+ <>
21
+ <Icon icon={icon} />
22
+ </>
23
+ );
24
+ }
25
+
26
+ return <>{icon}</>;
12
27
  };
28
+
29
+ const MemoizedRenderIcon = React.memo(RenderIcon);
30
+
31
+ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
32
+ (props, ref) => {
33
+ const { children, leftIcon, rightIcon, ...restProps } = props;
34
+
35
+ return (
36
+ <ButtonUi
37
+ ref={ref}
38
+ {...restProps}
39
+ sx={{
40
+ cursor: 'pointer',
41
+ paddingX: 'lg',
42
+ paddingY: 'md',
43
+ display: 'inline-flex',
44
+ alignItems: 'center',
45
+ gap: 'lg',
46
+ ...restProps.sx,
47
+ }}
48
+ >
49
+ <MemoizedRenderIcon icon={leftIcon} />
50
+ {children}
51
+ <MemoizedRenderIcon icon={rightIcon} />
52
+ </ButtonUi>
53
+ );
54
+ }
55
+ );
56
+
57
+ Button.displayName = 'Button';
@@ -1,15 +1,377 @@
1
- import { IconProps as IconPropsUI, Icon as IconUI } from '@iconify/react';
2
- import { Text, TextProps } from './Text';
1
+ import { Icon as IconUI, IconifyIconProps } from '@iconify-icon/react';
3
2
 
4
- export type IconProps = TextProps & {
5
- icon: IconPropsUI['icon'];
6
- iconProps?: Omit<IconPropsUI, 'icon'>;
7
- };
3
+ export type IconProps = Pick<
4
+ IconifyIconProps,
5
+ | 'preserveAspectRatio'
6
+ | 'rotate'
7
+ | 'cite'
8
+ | 'data'
9
+ | 'form'
10
+ | 'label'
11
+ | 'slot'
12
+ | 'span'
13
+ | 'style'
14
+ | 'summary'
15
+ | 'title'
16
+ | 'pattern'
17
+ | 'accept'
18
+ | 'acceptCharset'
19
+ | 'action'
20
+ | 'allowFullScreen'
21
+ | 'allowTransparency'
22
+ | 'alt'
23
+ | 'as'
24
+ | 'async'
25
+ | 'autoComplete'
26
+ | 'autoFocus'
27
+ | 'autoPlay'
28
+ | 'capture'
29
+ | 'cellPadding'
30
+ | 'cellSpacing'
31
+ | 'charSet'
32
+ | 'challenge'
33
+ | 'checked'
34
+ | 'classID'
35
+ | 'cols'
36
+ | 'colSpan'
37
+ | 'content'
38
+ | 'controls'
39
+ | 'coords'
40
+ | 'crossOrigin'
41
+ | 'dateTime'
42
+ | 'default'
43
+ | 'defer'
44
+ | 'disabled'
45
+ | 'download'
46
+ | 'encType'
47
+ | 'formAction'
48
+ | 'formEncType'
49
+ | 'formMethod'
50
+ | 'formNoValidate'
51
+ | 'formTarget'
52
+ | 'frameBorder'
53
+ | 'headers'
54
+ | 'height'
55
+ | 'high'
56
+ | 'href'
57
+ | 'hrefLang'
58
+ | 'htmlFor'
59
+ | 'httpEquiv'
60
+ | 'integrity'
61
+ | 'keyParams'
62
+ | 'keyType'
63
+ | 'kind'
64
+ | 'list'
65
+ | 'loop'
66
+ | 'low'
67
+ | 'manifest'
68
+ | 'marginHeight'
69
+ | 'marginWidth'
70
+ | 'max'
71
+ | 'maxLength'
72
+ | 'media'
73
+ | 'mediaGroup'
74
+ | 'method'
75
+ | 'min'
76
+ | 'minLength'
77
+ | 'multiple'
78
+ | 'muted'
79
+ | 'name'
80
+ | 'noValidate'
81
+ | 'open'
82
+ | 'optimum'
83
+ | 'placeholder'
84
+ | 'playsInline'
85
+ | 'poster'
86
+ | 'preload'
87
+ | 'readOnly'
88
+ | 'rel'
89
+ | 'required'
90
+ | 'reversed'
91
+ | 'rows'
92
+ | 'rowSpan'
93
+ | 'sandbox'
94
+ | 'scope'
95
+ | 'scoped'
96
+ | 'scrolling'
97
+ | 'seamless'
98
+ | 'selected'
99
+ | 'shape'
100
+ | 'size'
101
+ | 'sizes'
102
+ | 'src'
103
+ | 'srcDoc'
104
+ | 'srcLang'
105
+ | 'srcSet'
106
+ | 'start'
107
+ | 'step'
108
+ | 'target'
109
+ | 'type'
110
+ | 'useMap'
111
+ | 'value'
112
+ | 'width'
113
+ | 'wmode'
114
+ | 'wrap'
115
+ | 'defaultChecked'
116
+ | 'defaultValue'
117
+ | 'suppressContentEditableWarning'
118
+ | 'suppressHydrationWarning'
119
+ | 'accessKey'
120
+ | 'className'
121
+ | 'contentEditable'
122
+ | 'contextMenu'
123
+ | 'dir'
124
+ | 'draggable'
125
+ | 'hidden'
126
+ | 'id'
127
+ | 'lang'
128
+ | 'nonce'
129
+ | 'spellCheck'
130
+ | 'tabIndex'
131
+ | 'translate'
132
+ | 'radioGroup'
133
+ | 'role'
134
+ | 'about'
135
+ | 'datatype'
136
+ | 'inlist'
137
+ | 'prefix'
138
+ | 'property'
139
+ | 'resource'
140
+ | 'typeof'
141
+ | 'vocab'
142
+ | 'autoCapitalize'
143
+ | 'autoCorrect'
144
+ | 'autoSave'
145
+ | 'color'
146
+ | 'itemProp'
147
+ | 'itemScope'
148
+ | 'itemType'
149
+ | 'itemID'
150
+ | 'itemRef'
151
+ | 'results'
152
+ | 'security'
153
+ | 'unselectable'
154
+ | 'inputMode'
155
+ | 'is'
156
+ | 'aria-activedescendant'
157
+ | 'aria-atomic'
158
+ | 'aria-autocomplete'
159
+ | 'aria-busy'
160
+ | 'aria-checked'
161
+ | 'aria-colcount'
162
+ | 'aria-colindex'
163
+ | 'aria-colspan'
164
+ | 'aria-controls'
165
+ | 'aria-current'
166
+ | 'aria-describedby'
167
+ | 'aria-details'
168
+ | 'aria-disabled'
169
+ | 'aria-dropeffect'
170
+ | 'aria-errormessage'
171
+ | 'aria-expanded'
172
+ | 'aria-flowto'
173
+ | 'aria-grabbed'
174
+ | 'aria-haspopup'
175
+ | 'aria-hidden'
176
+ | 'aria-invalid'
177
+ | 'aria-keyshortcuts'
178
+ | 'aria-label'
179
+ | 'aria-labelledby'
180
+ | 'aria-level'
181
+ | 'aria-live'
182
+ | 'aria-modal'
183
+ | 'aria-multiline'
184
+ | 'aria-multiselectable'
185
+ | 'aria-orientation'
186
+ | 'aria-owns'
187
+ | 'aria-placeholder'
188
+ | 'aria-posinset'
189
+ | 'aria-pressed'
190
+ | 'aria-readonly'
191
+ | 'aria-relevant'
192
+ | 'aria-required'
193
+ | 'aria-roledescription'
194
+ | 'aria-rowcount'
195
+ | 'aria-rowindex'
196
+ | 'aria-rowspan'
197
+ | 'aria-selected'
198
+ | 'aria-setsize'
199
+ | 'aria-sort'
200
+ | 'aria-valuemax'
201
+ | 'aria-valuemin'
202
+ | 'aria-valuenow'
203
+ | 'aria-valuetext'
204
+ | 'children'
205
+ | 'dangerouslySetInnerHTML'
206
+ | 'onCopy'
207
+ | 'onCopyCapture'
208
+ | 'onCut'
209
+ | 'onCutCapture'
210
+ | 'onPaste'
211
+ | 'onPasteCapture'
212
+ | 'onCompositionEnd'
213
+ | 'onCompositionEndCapture'
214
+ | 'onCompositionStart'
215
+ | 'onCompositionStartCapture'
216
+ | 'onCompositionUpdate'
217
+ | 'onCompositionUpdateCapture'
218
+ | 'onFocus'
219
+ | 'onFocusCapture'
220
+ | 'onBlur'
221
+ | 'onBlurCapture'
222
+ | 'onChange'
223
+ | 'onChangeCapture'
224
+ | 'onBeforeInput'
225
+ | 'onBeforeInputCapture'
226
+ | 'onInput'
227
+ | 'onInputCapture'
228
+ | 'onReset'
229
+ | 'onResetCapture'
230
+ | 'onSubmit'
231
+ | 'onSubmitCapture'
232
+ | 'onInvalid'
233
+ | 'onInvalidCapture'
234
+ | 'onLoad'
235
+ | 'onLoadCapture'
236
+ | 'onError'
237
+ | 'onErrorCapture'
238
+ | 'onKeyDown'
239
+ | 'onKeyDownCapture'
240
+ | 'onKeyPress'
241
+ | 'onKeyPressCapture'
242
+ | 'onKeyUp'
243
+ | 'onKeyUpCapture'
244
+ | 'onAbort'
245
+ | 'onAbortCapture'
246
+ | 'onCanPlay'
247
+ | 'onCanPlayCapture'
248
+ | 'onCanPlayThrough'
249
+ | 'onCanPlayThroughCapture'
250
+ | 'onDurationChange'
251
+ | 'onDurationChangeCapture'
252
+ | 'onEmptied'
253
+ | 'onEmptiedCapture'
254
+ | 'onEncrypted'
255
+ | 'onEncryptedCapture'
256
+ | 'onEnded'
257
+ | 'onEndedCapture'
258
+ | 'onLoadedData'
259
+ | 'onLoadedDataCapture'
260
+ | 'onLoadedMetadata'
261
+ | 'onLoadedMetadataCapture'
262
+ | 'onLoadStart'
263
+ | 'onLoadStartCapture'
264
+ | 'onPause'
265
+ | 'onPauseCapture'
266
+ | 'onPlay'
267
+ | 'onPlayCapture'
268
+ | 'onPlaying'
269
+ | 'onPlayingCapture'
270
+ | 'onProgress'
271
+ | 'onProgressCapture'
272
+ | 'onRateChange'
273
+ | 'onRateChangeCapture'
274
+ | 'onResize'
275
+ | 'onResizeCapture'
276
+ | 'onSeeked'
277
+ | 'onSeekedCapture'
278
+ | 'onSeeking'
279
+ | 'onSeekingCapture'
280
+ | 'onStalled'
281
+ | 'onStalledCapture'
282
+ | 'onSuspend'
283
+ | 'onSuspendCapture'
284
+ | 'onTimeUpdate'
285
+ | 'onTimeUpdateCapture'
286
+ | 'onVolumeChange'
287
+ | 'onVolumeChangeCapture'
288
+ | 'onWaiting'
289
+ | 'onWaitingCapture'
290
+ | 'onAuxClick'
291
+ | 'onAuxClickCapture'
292
+ | 'onClick'
293
+ | 'onClickCapture'
294
+ | 'onContextMenu'
295
+ | 'onContextMenuCapture'
296
+ | 'onDoubleClick'
297
+ | 'onDoubleClickCapture'
298
+ | 'onDrag'
299
+ | 'onDragCapture'
300
+ | 'onDragEnd'
301
+ | 'onDragEndCapture'
302
+ | 'onDragEnter'
303
+ | 'onDragEnterCapture'
304
+ | 'onDragExit'
305
+ | 'onDragExitCapture'
306
+ | 'onDragLeave'
307
+ | 'onDragLeaveCapture'
308
+ | 'onDragOver'
309
+ | 'onDragOverCapture'
310
+ | 'onDragStart'
311
+ | 'onDragStartCapture'
312
+ | 'onDrop'
313
+ | 'onDropCapture'
314
+ | 'onMouseDown'
315
+ | 'onMouseDownCapture'
316
+ | 'onMouseEnter'
317
+ | 'onMouseLeave'
318
+ | 'onMouseMove'
319
+ | 'onMouseMoveCapture'
320
+ | 'onMouseOut'
321
+ | 'onMouseOutCapture'
322
+ | 'onMouseOver'
323
+ | 'onMouseOverCapture'
324
+ | 'onMouseUp'
325
+ | 'onMouseUpCapture'
326
+ | 'onSelect'
327
+ | 'onSelectCapture'
328
+ | 'onTouchCancel'
329
+ | 'onTouchCancelCapture'
330
+ | 'onTouchEnd'
331
+ | 'onTouchEndCapture'
332
+ | 'onTouchMove'
333
+ | 'onTouchMoveCapture'
334
+ | 'onTouchStart'
335
+ | 'onTouchStartCapture'
336
+ | 'onPointerDown'
337
+ | 'onPointerDownCapture'
338
+ | 'onPointerMove'
339
+ | 'onPointerMoveCapture'
340
+ | 'onPointerUp'
341
+ | 'onPointerUpCapture'
342
+ | 'onPointerCancel'
343
+ | 'onPointerCancelCapture'
344
+ | 'onPointerEnter'
345
+ | 'onPointerEnterCapture'
346
+ | 'onPointerLeave'
347
+ | 'onPointerLeaveCapture'
348
+ | 'onPointerOver'
349
+ | 'onPointerOverCapture'
350
+ | 'onPointerOut'
351
+ | 'onPointerOutCapture'
352
+ | 'onGotPointerCapture'
353
+ | 'onGotPointerCaptureCapture'
354
+ | 'onLostPointerCapture'
355
+ | 'onLostPointerCaptureCapture'
356
+ | 'onScroll'
357
+ | 'onScrollCapture'
358
+ | 'onWheel'
359
+ | 'onWheelCapture'
360
+ | 'onAnimationStart'
361
+ | 'onAnimationStartCapture'
362
+ | 'onAnimationEnd'
363
+ | 'onAnimationEndCapture'
364
+ | 'onAnimationIteration'
365
+ | 'onAnimationIterationCapture'
366
+ | 'onTransitionEnd'
367
+ | 'onTransitionEndCapture'
368
+ | 'key'
369
+ | 'icon'
370
+ | 'mode'
371
+ | 'inline'
372
+ | 'flip'
373
+ >;
8
374
 
9
- export const Icon = ({ icon, sx, iconProps, ...props }: IconProps) => {
10
- return (
11
- <Text sx={sx} {...props}>
12
- <IconUI {...iconProps} icon={icon} />
13
- </Text>
14
- );
375
+ export const Icon = (props: IconProps) => {
376
+ return <IconUI {...props} />;
15
377
  };
package/src/index.ts CHANGED
@@ -1,10 +1,7 @@
1
- export type { Theme } from 'theme-ui';
1
+ export { BaseStyles, type Theme } from 'theme-ui';
2
2
  export { useResponsiveValue, useBreakpointIndex } from '@theme-ui/match-media';
3
3
 
4
- export {
5
- default as ThemeProvider,
6
- type ThemeProviderProps,
7
- } from './theme/ThemeProvider';
4
+ export { ThemeProvider, type ThemeProviderProps } from './theme/ThemeProvider';
8
5
 
9
6
  export { useTheme } from './theme/useTheme';
10
7
 
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { BruttalFonts, BruttalTheme } from '@ttoss/theme';
3
3
  import { Global, css } from '@emotion/react';
4
- import { Theme, ThemeProvider as ThemeUiProvider, merge } from 'theme-ui';
4
+ import { Theme, ThemeProvider as ThemeUiProvider } from 'theme-ui';
5
5
 
6
6
  export type ThemeProviderProps = {
7
7
  children?: React.ReactNode;
@@ -12,36 +12,25 @@ export type ThemeProviderProps = {
12
12
  fonts?: string[];
13
13
  };
14
14
 
15
- const ThemeProvider = ({
15
+ export const ThemeProvider = ({
16
16
  children,
17
- theme = {},
17
+ theme = BruttalTheme,
18
18
  fonts = BruttalFonts,
19
19
  }: ThemeProviderProps) => {
20
- const mergedTheme = React.useMemo(() => {
21
- if (typeof theme === 'function') {
22
- return theme;
23
- }
24
-
25
- return merge(BruttalTheme, theme);
26
- }, [theme]);
27
-
28
20
  return (
29
21
  <>
30
- <ThemeUiProvider theme={mergedTheme}>
31
- {fonts.map((url) => {
32
- return (
33
- <Global
34
- key={url}
35
- styles={css`
36
- @import url('${url}');
37
- `}
38
- />
39
- );
40
- })}
22
+ <ThemeUiProvider theme={theme}>
23
+ <Global
24
+ styles={css`
25
+ ${fonts
26
+ .map((url) => {
27
+ return `@import url('${url}');`;
28
+ })
29
+ .join('\n')}
30
+ `}
31
+ />
41
32
  {children}
42
33
  </ThemeUiProvider>
43
34
  </>
44
35
  );
45
36
  };
46
-
47
- export default ThemeProvider;