@marigold/system 0.3.3 → 0.5.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @marigold/system
2
2
 
3
+ ## 0.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1795](https://github.com/marigold-ui/marigold/pull/1795) [`a178eafe`](https://github.com/marigold-ui/marigold/commit/a178eafe8c8380ee23b4587d953ee52b231414ff) Thanks [@ti10le](https://github.com/ti10le)! - refa: use interface instead of type
8
+
9
+ ## 0.5.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#1723](https://github.com/marigold-ui/marigold/pull/1723) [`5936de75`](https://github.com/marigold-ui/marigold/commit/5936de75e5a0134584438117c53c5edfe15c6c5d) Thanks [@sebald](https://github.com/sebald)! - feat(system): add hook that allows to use values based on screen size
14
+
15
+ ## 0.4.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [`f9526234`](https://github.com/marigold-ui/marigold/commit/f9526234257a149b12c14191a524691470da3942) Thanks [@sebald](https://github.com/sebald)! - chore: Use `tsup` to build packages
20
+
21
+ * [`f9526234`](https://github.com/marigold-ui/marigold/commit/f9526234257a149b12c14191a524691470da3942) Thanks [@sebald](https://github.com/sebald)! - Improved size in node_modules
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies [[`f9526234`](https://github.com/marigold-ui/marigold/commit/f9526234257a149b12c14191a524691470da3942)]:
26
+ - @marigold/types@0.4.0
27
+
3
28
  ## 0.3.1
4
29
 
5
30
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,8 +1,373 @@
1
- export * from './Box';
2
- export * from './Global';
3
- export * from './normalize';
4
- export * from './SVG';
5
- export * from './theme';
6
- export * from './types';
7
- export * from './useTheme';
8
- export * from './variant';
1
+ import { PolymorphicPropsWithRef, PolymorphicComponentWithRef, ComponentProps } from '@marigold/types';
2
+ import * as _theme_ui_css from '@theme-ui/css';
3
+ import { ResponsiveStyleValue as ResponsiveStyleValue$1, ThemeUIStyleObject, ThemeUICSSObject, ThemeUICSSProperties, NestedScaleDict } from '@theme-ui/css';
4
+ import React, { ElementType, ReactNode } from 'react';
5
+ import * as CSS from 'csstype';
6
+
7
+ /**
8
+ * Create type aliases for `theme-ui` so that it doesn't leak too much into our code.
9
+ */
10
+
11
+ declare type ResponsiveStyleValue<T> = ResponsiveStyleValue$1<T>;
12
+ declare type StyleObject = ThemeUIStyleObject;
13
+ declare type CSSObject = ThemeUICSSObject;
14
+ declare type CSSProperties = ThemeUICSSProperties;
15
+
16
+ interface StyleProps extends Pick<CSSObject, 'display' | 'height' | 'width' | 'minWidth' | 'maxWidth' | 'position' | 'top' | 'bottom' | 'right' | 'left' | 'zIndex' | 'p' | 'px' | 'py' | 'pt' | 'pb' | 'pl' | 'pr' | 'm' | 'mx' | 'my' | 'mt' | 'mb' | 'ml' | 'mr' | 'flexDirection' | 'flexWrap' | 'flexShrink' | 'flexGrow' | 'alignItems' | 'justifyContent' | 'bg' | 'border' | 'borderRadius' | 'boxShadow' | 'opacity' | 'overflow' | 'transition'> {
17
+ }
18
+ interface BoxOwnProps extends StyleProps {
19
+ css?: CSSObject;
20
+ variant?: string | string[];
21
+ /**
22
+ * Use to set base styles for the component
23
+ * @internal Used to set default styles for Marigold components
24
+ */
25
+ __baseCSS?: CSSObject;
26
+ }
27
+ interface BoxProps extends PolymorphicPropsWithRef<BoxOwnProps, 'div'> {
28
+ }
29
+ declare const Box: PolymorphicComponentWithRef<BoxOwnProps, 'div'>;
30
+
31
+ declare const Global: () => JSX.Element;
32
+
33
+ /**
34
+ * Normalize styling of certain elements between browsers.
35
+ * Based on https://www.joshwcomeau.com/css/custom-css-reset/
36
+ */
37
+
38
+ declare const normalize: {
39
+ readonly base: {
40
+ readonly boxSizing: "border-box";
41
+ readonly margin: 0;
42
+ readonly minWidth: 0;
43
+ };
44
+ readonly a: {
45
+ readonly textDecoration: "none";
46
+ readonly boxSizing: "border-box";
47
+ readonly margin: 0;
48
+ readonly minWidth: 0;
49
+ };
50
+ readonly p: {
51
+ readonly overflowWrap: "break-word";
52
+ readonly boxSizing: "border-box";
53
+ readonly margin: 0;
54
+ readonly minWidth: 0;
55
+ };
56
+ readonly h1: {
57
+ readonly overflowWrap: "break-word";
58
+ readonly boxSizing: "border-box";
59
+ readonly margin: 0;
60
+ readonly minWidth: 0;
61
+ };
62
+ readonly h2: {
63
+ readonly overflowWrap: "break-word";
64
+ readonly boxSizing: "border-box";
65
+ readonly margin: 0;
66
+ readonly minWidth: 0;
67
+ };
68
+ readonly h3: {
69
+ readonly overflowWrap: "break-word";
70
+ readonly boxSizing: "border-box";
71
+ readonly margin: 0;
72
+ readonly minWidth: 0;
73
+ };
74
+ readonly h4: {
75
+ readonly overflowWrap: "break-word";
76
+ readonly boxSizing: "border-box";
77
+ readonly margin: 0;
78
+ readonly minWidth: 0;
79
+ };
80
+ readonly h5: {
81
+ readonly overflowWrap: "break-word";
82
+ readonly boxSizing: "border-box";
83
+ readonly margin: 0;
84
+ readonly minWidth: 0;
85
+ };
86
+ readonly h6: {
87
+ readonly overflowWrap: "break-word";
88
+ readonly boxSizing: "border-box";
89
+ readonly margin: 0;
90
+ readonly minWidth: 0;
91
+ };
92
+ readonly img: {
93
+ readonly display: "block";
94
+ readonly maxWidth: "100%";
95
+ readonly boxSizing: "border-box";
96
+ readonly margin: 0;
97
+ readonly minWidth: 0;
98
+ };
99
+ readonly picture: {
100
+ readonly display: "block";
101
+ readonly maxWidth: "100%";
102
+ readonly boxSizing: "border-box";
103
+ readonly margin: 0;
104
+ readonly minWidth: 0;
105
+ };
106
+ readonly video: {
107
+ readonly display: "block";
108
+ readonly maxWidth: "100%";
109
+ readonly boxSizing: "border-box";
110
+ readonly margin: 0;
111
+ readonly minWidth: 0;
112
+ };
113
+ readonly canvas: {
114
+ readonly display: "block";
115
+ readonly maxWidth: "100%";
116
+ readonly boxSizing: "border-box";
117
+ readonly margin: 0;
118
+ readonly minWidth: 0;
119
+ };
120
+ readonly svg: {
121
+ readonly display: "block";
122
+ readonly maxWidth: "100%";
123
+ readonly boxSizing: "border-box";
124
+ readonly margin: 0;
125
+ readonly minWidth: 0;
126
+ };
127
+ readonly select: {
128
+ readonly display: "block";
129
+ readonly appearance: "none";
130
+ readonly font: "inherit";
131
+ readonly '&::-ms-expand': {
132
+ readonly display: "none";
133
+ };
134
+ readonly boxSizing: "border-box";
135
+ readonly margin: 0;
136
+ readonly minWidth: 0;
137
+ };
138
+ readonly button: {
139
+ readonly display: "block";
140
+ readonly appearance: "none";
141
+ readonly font: "inherit";
142
+ readonly background: "transparent";
143
+ readonly textAlign: "center";
144
+ readonly boxSizing: "border-box";
145
+ readonly margin: 0;
146
+ readonly minWidth: 0;
147
+ };
148
+ readonly textarea: {
149
+ readonly display: "block";
150
+ readonly appearance: "none";
151
+ readonly font: "inherit";
152
+ readonly boxSizing: "border-box";
153
+ readonly margin: 0;
154
+ readonly minWidth: 0;
155
+ };
156
+ readonly input: {
157
+ readonly display: "block";
158
+ readonly appearance: "none";
159
+ readonly font: "inherit";
160
+ readonly '&::-ms-clear': {
161
+ readonly display: "none";
162
+ };
163
+ readonly '&::-webkit-search-cancel-button': {
164
+ readonly WebkitAppearance: "none";
165
+ };
166
+ readonly boxSizing: "border-box";
167
+ readonly margin: 0;
168
+ readonly minWidth: 0;
169
+ };
170
+ };
171
+ declare type NormalizedElement = keyof typeof normalize;
172
+ /**
173
+ * Type-safe helper to get normalization. If no normalization is found,
174
+ * returns the *base* normalization.
175
+ */
176
+ declare const getNormalizedStyles: (val?: ElementType<any> | undefined) => {
177
+ readonly boxSizing: "border-box";
178
+ readonly margin: 0;
179
+ readonly minWidth: 0;
180
+ };
181
+
182
+ interface SVGProps extends ComponentProps<'svg'> {
183
+ size?: number;
184
+ }
185
+ declare const SVG: React.FC<SVGProps>;
186
+
187
+ /**
188
+ * Value used to define a scale.
189
+ *
190
+ * Can be nested to support a default value.
191
+ *
192
+ * @example
193
+ * Given a theme
194
+ * ```
195
+ * {
196
+ * colors: {
197
+ * primary: { __default: '#00f', light: '#33f' }
198
+ * }
199
+ * }
200
+ * ```
201
+ * `css{{ color: 'primary' }}` resolves to `color: #00f`.
202
+ */
203
+ declare type ScaleValue<T> = T | T[] | NestedScaleDict<T> | undefined;
204
+ /**
205
+ * Scales are a set of named, pre-defined CSS values which are used
206
+ * to create consitency in sizing across visual elements. They give
207
+ * plain values semantics meaning.
208
+ *
209
+ * Marigold uses a plain object to define scales, where the key should be a
210
+ * descriptive name for the scale (e.g. `small`/`medium`/.. or `body`/`heading`/...),
211
+ * and the value is the CSS value.
212
+ */
213
+ declare type Scale<T> = {
214
+ [key: string]: ScaleValue<T>;
215
+ };
216
+ /**
217
+ * Predefined {@link Scale} scale which uses size values.
218
+ */
219
+ declare type SizeScale<T> = {
220
+ xxsmall?: ScaleValue<T>;
221
+ xsmall?: ScaleValue<T>;
222
+ small?: ScaleValue<T>;
223
+ medium?: ScaleValue<T>;
224
+ large?: ScaleValue<T>;
225
+ xlarge?: ScaleValue<T>;
226
+ xxlarge?: ScaleValue<T>;
227
+ };
228
+ /**
229
+ * A {@link SizeScale} that also includes a required `none` value, which is
230
+ * usually used to define the blank value (e.g `0`).
231
+ */
232
+ declare type ZeroScale<T> = {
233
+ none: ScaleValue<T>;
234
+ } & Scale<T>;
235
+ /**
236
+ * Base theme with typings for available scales properties.
237
+ */
238
+ interface Theme {
239
+ /**
240
+ * To configure the default breakpoints used in responsive array values,
241
+ * add a breakpoints array to your theme.
242
+ *
243
+ * Each breakpoint should be a string with a CSS length unit included or a
244
+ * string including a CSS media query. String values with a CSS length unit
245
+ * will be used to generate a mobile-first (i.e. min-width) media query.
246
+ *
247
+ * @example
248
+ * ```ts
249
+ * {
250
+ * breakpoints: [
251
+ * '40em', '@media (min-width: 56em) and (orientation: landscape)', '64em',
252
+ * ],
253
+ * }
254
+ * ```
255
+ */
256
+ breakpoints?: Array<string>;
257
+ colors?: Scale<CSS.Property.Color | NestedScaleDict<CSS.Property.Color>>;
258
+ /**
259
+ * Used to define a scale for whitspace values,
260
+ * like `padding`, `margin`, `gap`, etc.
261
+ */
262
+ space?: ZeroScale<CSS.Property.Margin<number | string>>;
263
+ /**
264
+ * Used to define a `font-size` scale.
265
+ */
266
+ fontSizes?: Scale<CSS.Property.FontSize<number>>;
267
+ /**
268
+ * Used to define a `font-family` scale.
269
+ */
270
+ fonts?: Scale<CSS.Property.FontFamily>;
271
+ /**
272
+ * Used to define a `font-weight` scale.
273
+ */
274
+ fontWeights?: Scale<CSS.Property.FontWeight>;
275
+ /**
276
+ * Used to define a `line-height` scale.
277
+ */
278
+ lineHeights?: Scale<CSS.Property.LineHeight<string | 0 | number>>;
279
+ /**
280
+ * Used to define a `letter-spacing` scale.
281
+ */
282
+ letterSpacings?: ZeroScale<CSS.Property.LetterSpacing<string | 0 | number>>;
283
+ /**
284
+ * Used to define a scale for size values,
285
+ * like `height`, `width`, `flexBasis`, etc.
286
+ */
287
+ sizes?: ZeroScale<CSS.Property.Height<{}> | CSS.Property.Width<{}>>;
288
+ /**
289
+ * Used to define different `border` styles.
290
+ */
291
+ borders?: ZeroScale<CSS.Property.Border<{}>>;
292
+ /**
293
+ * Used to define `border-style` styles.
294
+ */
295
+ borderStyles?: Scale<CSS.Property.Border<{}>>;
296
+ /**
297
+ * Used to define `border-width` styles.
298
+ */
299
+ borderWidths?: ZeroScale<CSS.Property.BorderWidth<string | 0 | number>>;
300
+ /**
301
+ * Used to define `border-radius` styles.
302
+ */
303
+ radii?: ZeroScale<CSS.Property.BorderRadius<string | 0 | number>>;
304
+ /**
305
+ * Used to define `Shadow` styles.
306
+ */
307
+ shadows?: ZeroScale<CSS.Property.BoxShadow>;
308
+ /**
309
+ * Used to define a `z-index` scake.
310
+ */
311
+ zIndices?: Scale<CSS.Property.ZIndex>;
312
+ /**
313
+ * Used to define a `opacity` scale.
314
+ */
315
+ opacities?: Scale<CSS.Property.Opacity>;
316
+ /**
317
+ * Used to define a `transition` styles.
318
+ */
319
+ transitions?: ZeroScale<CSS.Property.Transition>;
320
+ }
321
+
322
+ /**
323
+ * Hook that can be used to return values based on the current screen size,
324
+ * using breakpoints from the theme (`theme.breakpoints`). Note that this
325
+ * hook is client.side only.
326
+ */
327
+ declare const useResponsiveValue: <T>(values: T[], defaultIndex?: number) => T;
328
+
329
+ /**
330
+ * @internal
331
+ */
332
+ declare const __defaultTheme: Theme;
333
+ declare const useTheme: () => {
334
+ theme: Theme;
335
+ css: (style: StyleObject) => _theme_ui_css.CSSObject;
336
+ };
337
+ interface ThemeProviderProps<T extends Theme> {
338
+ theme: T;
339
+ children: ReactNode;
340
+ }
341
+ declare function ThemeProvider<T extends Theme>({ theme, children, }: ThemeProviderProps<T>): JSX.Element;
342
+
343
+ /**
344
+ * Ensures that the `val` is an array. Will return an empty array if `val` is falsy.
345
+ */
346
+ declare const ensureArray: <T>(val?: T | T[] | undefined) => T[];
347
+ /**
348
+ * Removes trailing dot from variant, if necessary. This is necessary to support
349
+ * `__default` styles. See https://github.com/system-ui/theme-ui/pull/951
350
+ */
351
+ declare const ensureVariantDefault: (val: string) => string;
352
+ /**
353
+ * Ensures that the `variant` is an array and supports the `__default` key.
354
+ */
355
+ declare const ensureArrayVariant: <T extends string>(variant?: T | T[] | undefined) => string[];
356
+ interface State {
357
+ checked?: boolean;
358
+ focus?: boolean;
359
+ hover?: boolean;
360
+ disabled?: boolean;
361
+ error?: boolean;
362
+ }
363
+ /**
364
+ * Appends given `state` to a `variant`.
365
+ */
366
+ declare const appendVariantState: (variant: string, state: keyof State) => string;
367
+ /**
368
+ * Create a variant array from a `variant` and `state` containing
369
+ * passed states, if they are truthy.
370
+ */
371
+ declare const conditional: (variant: string, { disabled, ...states }: State) => string[];
372
+
373
+ export { Box, BoxOwnProps, BoxProps, CSSObject, CSSProperties, Global, NormalizedElement, ResponsiveStyleValue, SVG, SVGProps, Scale, ScaleValue, SizeScale, State, StyleObject, StyleProps, Theme, ThemeProvider, ThemeProviderProps, ZeroScale, __defaultTheme, appendVariantState, conditional, ensureArray, ensureArrayVariant, ensureVariantDefault, getNormalizedStyles, normalize, useResponsiveValue, useTheme };