@mirohq/design-system-stitches 3.2.0-fix-stitches-types.0 → 3.2.0-fix-stitches-types.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.
Files changed (2) hide show
  1. package/dist/types.d.ts +179 -201
  2. package/package.json +3 -3
package/dist/types.d.ts CHANGED
@@ -1,10 +1,180 @@
1
1
  import * as React$1 from 'react';
2
2
  import React__default, { ElementType, ComponentPropsWithRef, ExoticComponent, JSXElementConstructor, ComponentType } from 'react';
3
+ import { CSS as CSS$2, VariantProps } from '@stitches/react';
3
4
  import { OnlyHTMLAttributes, ExtractValidKeys } from '@mirohq/design-system-types';
4
- import * as _mirohq_design_system_themes_web from '@mirohq/design-system-themes/web';
5
+ import * as _mirohq_design_system_themes_web from '@mirohq/design-tokens';
5
6
  import * as _mirohq_design_system_themes from '@mirohq/design-system-themes';
6
7
  import { Theme as Theme$1 } from '@mirohq/design-system-themes';
7
8
 
9
+ interface ScaleValue {
10
+ token: number | string
11
+ value: number | string
12
+ scale: string
13
+ prefix: string
14
+ }
15
+
16
+ interface Token<
17
+ /** Token name. */
18
+ NameType extends number | string = string,
19
+
20
+ /** Token value. */
21
+ ValueType extends number | string = string,
22
+
23
+ /** Token scale. */
24
+ ScaleType extends string | void = void,
25
+
26
+ /** Token prefix. */
27
+ PrefixType extends string | void = void,
28
+ > extends ScaleValue {
29
+ new (name: NameType, value: ValueType, scale?: ScaleType, prefix?: PrefixType): this
30
+
31
+ /** Name of the token. */
32
+ token: NameType
33
+
34
+ /** Value of the token. */
35
+ value: ValueType
36
+
37
+ /** Category of interface the token applies to. */
38
+ scale: ScaleType extends string ? ScaleType : ''
39
+
40
+ /** Prefix added before the serialized custom property. */
41
+ prefix: PrefixType extends string ? PrefixType : ''
42
+
43
+ /** Serialized custom property representing the token. */
44
+ variable: `--${this['prefix'] extends '' ? '' : `${this['prefix']}-`}${this['scale'] extends '' ? '' : `${this['scale']}-`}${this['token']}`
45
+
46
+ /** Serialized CSS var() representing the token. */
47
+ computedValue: `var(${this['variable']})`
48
+
49
+ /** Returns a serialized CSS var() representing the token. */
50
+ toString(): this['computedValue']
51
+ }
52
+
53
+ /* Utilities */
54
+ /* ========================================================================== */
55
+
56
+ /** Returns a string with the given prefix followed by the given values. */
57
+ type Prefixed<K extends string, T> = `${K}${Extract<T, boolean | number | string>}`
58
+
59
+ /** Returns a widened value from the given value. */
60
+ type Widen<T> =
61
+ T extends number
62
+ ? `${T}` | T
63
+ : T extends 'true'
64
+ ? boolean | T
65
+ : T extends 'false'
66
+ ? boolean | T
67
+ : T extends `${number}`
68
+ ? number | T
69
+ : T
70
+
71
+ /** Narrowed string. */
72
+ type String = string & Record<never, never>
73
+
74
+ /** Narrowed number or string. */
75
+ type Index = (number | string) & Record<never, never>
76
+
77
+ /** Narrowed function. */
78
+ type Function = (...args: any[]) => unknown
79
+
80
+ /** Widened object. */
81
+ type WideObject = { [name in number | string]: boolean | number | string | undefined | WideObject }
82
+
83
+ /** Returns a new CSS Component. */
84
+ interface CssComponent<
85
+ Type = 'span',
86
+ Props = {},
87
+ Media = {},
88
+ CSS = {}
89
+ > {
90
+ (
91
+ props?:
92
+ & TransformProps<Props, Media>
93
+ & {
94
+ css?: CSS
95
+ }
96
+ & {
97
+ [name in number | string]: any
98
+ }
99
+ ): string & {
100
+ className: string
101
+ selector: string
102
+ props: {}
103
+ }
104
+
105
+ className: string
106
+ selector: string
107
+
108
+ [$$StyledComponentType]: Type
109
+ [$$StyledComponentProps]: Props
110
+ [$$StyledComponentMedia]: Media
111
+ }
112
+
113
+ type TransformProps<Props, Media> = {
114
+ [K in keyof Props]: (
115
+ | Props[K]
116
+ | (
117
+ & {
118
+ [KMedia in Prefixed<'@', 'initial' | keyof Media>]?: Props[K]
119
+ }
120
+ & {
121
+ [KMedia in string]: Props[K]
122
+ }
123
+ )
124
+ )
125
+ }
126
+
127
+ /** Unique symbol used to reference the type of a Styled Component. */
128
+ declare const $$StyledComponentType: unique symbol
129
+
130
+ /** Unique symbol used to reference the type of a Styled Component. */
131
+ type $$StyledComponentType = typeof $$StyledComponentType
132
+
133
+ /** Unique symbol used to reference the props of a Styled Component. */
134
+ declare const $$StyledComponentProps: unique symbol
135
+
136
+ /** Unique symbol used to reference the props of a Styled Component. */
137
+ type $$StyledComponentProps = typeof $$StyledComponentProps
138
+
139
+ /** Unique symbol used to reference the media passed into a Styled Component. */
140
+ declare const $$StyledComponentMedia: unique symbol
141
+
142
+ /** Unique symbol used to reference the media passed into a Styled Component. */
143
+ type $$StyledComponentMedia = typeof $$StyledComponentMedia
144
+
145
+ /** Returns the first Styled Component type from the given array of compositions. */
146
+ type StyledComponentType<T extends any[]> = (
147
+ T[0] extends never
148
+ ? 'span'
149
+ : T[0] extends string
150
+ ? T[0]
151
+ : T[0] extends (props: any) => any
152
+ ? T[0]
153
+ : T[0] extends { [$$StyledComponentType]: unknown }
154
+ ? T[0][$$StyledComponentType]
155
+ : T extends [lead: any, ...tail: infer V]
156
+ ? StyledComponentType<V>
157
+ : never
158
+ )
159
+
160
+ /** Returns the cumulative variants from the given array of compositions. */
161
+ type StyledComponentProps$1<T extends any[]> = (
162
+ & (
163
+ $$StyledComponentProps extends keyof T[0]
164
+ ? T[0][$$StyledComponentProps]
165
+ : T[0] extends { variants: { [name: string]: unknown } }
166
+ ? {
167
+ [K in keyof T[0]['variants']]?: Widen<keyof T[0]['variants'][K]>
168
+ }
169
+ : {}
170
+ )
171
+ & (
172
+ T extends [lead: any, ...tail: infer V]
173
+ ? StyledComponentProps$1<V>
174
+ : {}
175
+ )
176
+ )
177
+
8
178
  /** @license MIT License
9
179
  * Copyright (c) 2017-present, Fredrik Nicol
10
180
  * Copyright (c) 2021-present, Jonathan Neal
@@ -5827,80 +5997,6 @@ interface DefaultThemeMap {
5827
5997
  zIndex: 'zIndices'
5828
5998
  }
5829
5999
 
5830
- interface ScaleValue {
5831
- token: number | string
5832
- value: number | string
5833
- scale: string
5834
- prefix: string
5835
- }
5836
-
5837
- interface Token<
5838
- /** Token name. */
5839
- NameType extends number | string = string,
5840
-
5841
- /** Token value. */
5842
- ValueType extends number | string = string,
5843
-
5844
- /** Token scale. */
5845
- ScaleType extends string | void = void,
5846
-
5847
- /** Token prefix. */
5848
- PrefixType extends string | void = void,
5849
- > extends ScaleValue {
5850
- new (name: NameType, value: ValueType, scale?: ScaleType, prefix?: PrefixType): this
5851
-
5852
- /** Name of the token. */
5853
- token: NameType
5854
-
5855
- /** Value of the token. */
5856
- value: ValueType
5857
-
5858
- /** Category of interface the token applies to. */
5859
- scale: ScaleType extends string ? ScaleType : ''
5860
-
5861
- /** Prefix added before the serialized custom property. */
5862
- prefix: PrefixType extends string ? PrefixType : ''
5863
-
5864
- /** Serialized custom property representing the token. */
5865
- variable: `--${this['prefix'] extends '' ? '' : `${this['prefix']}-`}${this['scale'] extends '' ? '' : `${this['scale']}-`}${this['token']}`
5866
-
5867
- /** Serialized CSS var() representing the token. */
5868
- computedValue: `var(${this['variable']})`
5869
-
5870
- /** Returns a serialized CSS var() representing the token. */
5871
- toString(): this['computedValue']
5872
- }
5873
-
5874
- /* Utilities */
5875
- /* ========================================================================== */
5876
-
5877
- /** Returns a string with the given prefix followed by the given values. */
5878
- type Prefixed<K extends string, T> = `${K}${Extract<T, boolean | number | string>}`
5879
-
5880
- /** Returns a widened value from the given value. */
5881
- type Widen<T> =
5882
- T extends number
5883
- ? `${T}` | T
5884
- : T extends 'true'
5885
- ? boolean | T
5886
- : T extends 'false'
5887
- ? boolean | T
5888
- : T extends `${number}`
5889
- ? number | T
5890
- : T
5891
-
5892
- /** Narrowed string. */
5893
- type String = string & Record<never, never>
5894
-
5895
- /** Narrowed number or string. */
5896
- type Index = (number | string) & Record<never, never>
5897
-
5898
- /** Narrowed function. */
5899
- type Function = (...args: any[]) => unknown
5900
-
5901
- /** Widened object. */
5902
- type WideObject = { [name in number | string]: boolean | number | string | undefined | WideObject }
5903
-
5904
6000
  /** CSS style declaration object. */
5905
6001
  interface CSSProperties$1 extends StandardLonghandProperties, StandardShorthandProperties, SvgProperties {}
5906
6002
 
@@ -5911,7 +6007,7 @@ type TokenByPropertyName<PropertyName, Theme, ThemeMap> = PropertyName extends k
5911
6007
  type TokenByScaleName<ScaleName, Theme> = ScaleName extends keyof Theme ? Prefixed<'$', keyof Theme[ScaleName]> : never
5912
6008
 
5913
6009
  /** Returns a Style interface, leveraging the given media and style map. */
5914
- type CSS$2<
6010
+ type CSS$1<
5915
6011
  Media = {},
5916
6012
  Theme = {},
5917
6013
  ThemeMap = DefaultThemeMap,
@@ -5919,7 +6015,7 @@ type CSS$2<
5919
6015
  > = (
5920
6016
  // nested at-rule css styles
5921
6017
  & {
5922
- [K in Prefixed<'@', keyof Media>]?: CSS$2<Media, Theme, ThemeMap, Utils>
6018
+ [K in Prefixed<'@', keyof Media>]?: CSS$1<Media, Theme, ThemeMap, Utils>
5923
6019
  }
5924
6020
  // known property styles
5925
6021
  & {
@@ -6015,101 +6111,6 @@ type WithPropertyValue<T> = {
6015
6111
  readonly [K in $$PropertyValue]: T
6016
6112
  }
6017
6113
 
6018
- /** Returns a new CSS Component. */
6019
- interface CssComponent<
6020
- Type = 'span',
6021
- Props = {},
6022
- Media = {},
6023
- CSS = {}
6024
- > {
6025
- (
6026
- props?:
6027
- & TransformProps<Props, Media>
6028
- & {
6029
- css?: CSS
6030
- }
6031
- & {
6032
- [name in number | string]: any
6033
- }
6034
- ): string & {
6035
- className: string
6036
- selector: string
6037
- props: {}
6038
- }
6039
-
6040
- className: string
6041
- selector: string
6042
-
6043
- [$$StyledComponentType]: Type
6044
- [$$StyledComponentProps]: Props
6045
- [$$StyledComponentMedia]: Media
6046
- }
6047
-
6048
- type TransformProps<Props, Media> = {
6049
- [K in keyof Props]: (
6050
- | Props[K]
6051
- | (
6052
- & {
6053
- [KMedia in Prefixed<'@', 'initial' | keyof Media>]?: Props[K]
6054
- }
6055
- & {
6056
- [KMedia in string]: Props[K]
6057
- }
6058
- )
6059
- )
6060
- }
6061
-
6062
- /** Unique symbol used to reference the type of a Styled Component. */
6063
- declare const $$StyledComponentType: unique symbol
6064
-
6065
- /** Unique symbol used to reference the type of a Styled Component. */
6066
- type $$StyledComponentType = typeof $$StyledComponentType
6067
-
6068
- /** Unique symbol used to reference the props of a Styled Component. */
6069
- declare const $$StyledComponentProps: unique symbol
6070
-
6071
- /** Unique symbol used to reference the props of a Styled Component. */
6072
- type $$StyledComponentProps = typeof $$StyledComponentProps
6073
-
6074
- /** Unique symbol used to reference the media passed into a Styled Component. */
6075
- declare const $$StyledComponentMedia: unique symbol
6076
-
6077
- /** Unique symbol used to reference the media passed into a Styled Component. */
6078
- type $$StyledComponentMedia = typeof $$StyledComponentMedia
6079
-
6080
- /** Returns the first Styled Component type from the given array of compositions. */
6081
- type StyledComponentType<T extends any[]> = (
6082
- T[0] extends never
6083
- ? 'span'
6084
- : T[0] extends string
6085
- ? T[0]
6086
- : T[0] extends (props: any) => any
6087
- ? T[0]
6088
- : T[0] extends { [$$StyledComponentType]: unknown }
6089
- ? T[0][$$StyledComponentType]
6090
- : T extends [lead: any, ...tail: infer V]
6091
- ? StyledComponentType<V>
6092
- : never
6093
- )
6094
-
6095
- /** Returns the cumulative variants from the given array of compositions. */
6096
- type StyledComponentProps$1<T extends any[]> = (
6097
- & (
6098
- $$StyledComponentProps extends keyof T[0]
6099
- ? T[0][$$StyledComponentProps]
6100
- : T[0] extends { variants: { [name: string]: unknown } }
6101
- ? {
6102
- [K in keyof T[0]['variants']]?: Widen<keyof T[0]['variants'][K]>
6103
- }
6104
- : {}
6105
- )
6106
- & (
6107
- T extends [lead: any, ...tail: infer V]
6108
- ? StyledComponentProps$1<V>
6109
- : {}
6110
- )
6111
- )
6112
-
6113
6114
  /** Remove an index signature from a type */
6114
6115
  type RemoveIndex<T> = {[k in keyof T as string extends k ? never : number extends k ? never : k]: T[k]}
6115
6116
 
@@ -6126,32 +6127,12 @@ type ThemeTokens<Values, Prefix> = {
6126
6127
 
6127
6128
  type CSSProperties = CSSProperties$1
6128
6129
 
6129
- /** Returns a Style interface from a configuration, leveraging the given media and style map. */
6130
- type CSS$1<
6131
- Config extends {
6132
- media?: {}
6133
- theme?: {}
6134
- themeMap?: {}
6135
- utils?: {}
6136
- } = {
6137
- media: {},
6138
- theme: {},
6139
- themeMap: {},
6140
- utils: {}
6141
- }
6142
- > = CSS$2<
6143
- Config['media'],
6144
- Config['theme'],
6145
- Config['themeMap'],
6146
- Config['utils']
6147
- >
6148
-
6149
6130
  /** Returns a type that expects a value to be a kind of CSS property value. */
6150
6131
  type PropertyValue<Property extends keyof CSSProperties$1, Config = null> = (
6151
6132
  Config extends null
6152
6133
  ? WithPropertyValue<Property>
6153
6134
  : Config extends { [K: string]: any }
6154
- ? CSS$2<
6135
+ ? CSS$1<
6155
6136
  Config['media'],
6156
6137
  Config['theme'],
6157
6138
  Config['themeMap'],
@@ -6160,9 +6141,6 @@ type PropertyValue<Property extends keyof CSSProperties$1, Config = null> = (
6160
6141
  : never
6161
6142
  )
6162
6143
 
6163
- /** Returns a type that suggests variants from a component as possible prop values. */
6164
- type VariantProps<Component extends {[key: symbol | string]: any}> = TransformProps<Component[$$StyledComponentProps], Component[$$StyledComponentMedia]>
6165
-
6166
6144
  declare const config: {
6167
6145
  prefix: "";
6168
6146
  media: {};
@@ -8819,7 +8797,7 @@ declare const createTheme: <Argument0 extends string | ({
8819
8797
  } & (Argument0 extends string ? ThemeTokens<Argument1, ""> : ThemeTokens<Argument0, "">);
8820
8798
  declare const css: <Composers extends (string | React.ExoticComponent<any> | React.JSXElementConstructor<any> | Function | {
8821
8799
  [name: string]: unknown;
8822
- })[], CSS = CSS$2<{}, {
8800
+ })[], CSS = CSS$1<{}, {
8823
8801
  'border-widths': {
8824
8802
  readonly none: 0;
8825
8803
  readonly sm: "1px";
@@ -9819,7 +9797,7 @@ declare const globalCss: <Styles extends {
9819
9797
  '@import'?: unknown;
9820
9798
  '@font-face'?: unknown;
9821
9799
  } & { [K in keyof Styles]: K extends "@import" ? string | string[] : K extends "@font-face" ? AtRule.FontFace | AtRule.FontFace[] : K extends `@keyframes ${string}` ? {
9822
- [x: string]: CSS$2<{}, {
9800
+ [x: string]: CSS$1<{}, {
9823
9801
  'border-widths': {
9824
9802
  readonly none: 0;
9825
9803
  readonly sm: "1px";
@@ -10801,7 +10779,7 @@ declare const globalCss: <Styles extends {
10801
10779
  '&:hover, &[data-hovered]': CSSProperties$1;
10802
10780
  };
10803
10781
  }>;
10804
- } : K extends `@property ${string}` ? AtRule.Property : CSS$2<{}, {
10782
+ } : K extends `@property ${string}` ? AtRule.Property : CSS$1<{}, {
10805
10783
  'border-widths': {
10806
10784
  readonly none: 0;
10807
10785
  readonly sm: "1px";
@@ -11786,7 +11764,7 @@ declare const globalCss: <Styles extends {
11786
11764
  (): string;
11787
11765
  };
11788
11766
  declare const keyframes: (style: {
11789
- [offset: string]: CSS$2<{}, {
11767
+ [offset: string]: CSS$1<{}, {
11790
11768
  'border-widths': {
11791
11769
  readonly none: 0;
11792
11770
  readonly sm: "1px";
@@ -12778,7 +12756,7 @@ declare const fontFace: (...fonts: FontFace[]) => string;
12778
12756
  type ForbiddenProps = 'className' | 'style' | 'as';
12779
12757
  type AllowedProps = 'css' | 'asChild' | 'UNSAFE_style' | 'children';
12780
12758
  type SafeProps<T> = Omit<T, ForbiddenProps>;
12781
- type CSS = CSS$1<typeof config>;
12759
+ type CSS = CSS$2<typeof config>;
12782
12760
  /**
12783
12761
  * Build a type with all props from a element and Stitches CSS keys
12784
12762
  * and remove dangerous attributes that could cause styles issues
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mirohq/design-system-stitches",
3
- "version": "3.2.0-fix-stitches-types.0",
3
+ "version": "3.2.0-fix-stitches-types.1",
4
4
  "description": "",
5
5
  "author": "Miro",
6
6
  "source": "src/index.ts",
@@ -27,9 +27,9 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "lodash.merge": "^4.6.2",
30
+ "@mirohq/design-system-themes": "^1.1.1",
30
31
  "@mirohq/design-system-types": "^1.0.1",
31
- "@mirohq/design-tokens": "^7.0.1",
32
- "@mirohq/design-system-themes": "^1.1.1"
32
+ "@mirohq/design-tokens": "^7.0.1"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/lodash.merge": "^4.6.7"