@superdispatch/ui-lab 0.21.12 → 0.21.14

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 (95) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +13 -38
  3. package/.babelrc.js +0 -5
  4. package/.turbo/turbo-version.log +0 -28
  5. package/pkg/README.md +0 -10
  6. package/pkg/package.json +0 -34
  7. package/playroom.ts +0 -23
  8. package/src/alert/Alert.stories.tsx +0 -105
  9. package/src/alert/Alert.tsx +0 -108
  10. package/src/banner/Banner.stories.tsx +0 -64
  11. package/src/banner/Banner.tsx +0 -120
  12. package/src/box/Box.stories.tsx +0 -20
  13. package/src/box/Box.tsx +0 -252
  14. package/src/button/Button.stories.tsx +0 -717
  15. package/src/button/Button.tsx +0 -460
  16. package/src/button-area/ButtonArea.stories.tsx +0 -65
  17. package/src/button-area/ButtonArea.tsx +0 -88
  18. package/src/container/Container.tsx +0 -48
  19. package/src/description-item/DescriptionItem.stories.tsx +0 -163
  20. package/src/description-item/DescriptionItem.tsx +0 -104
  21. package/src/file-drop-zone/FileDropZone.stories.tsx +0 -44
  22. package/src/file-drop-zone/FileDropZone.tsx +0 -170
  23. package/src/file-list-item/FileListItem.stories.tsx +0 -37
  24. package/src/file-list-item/FileListItem.tsx +0 -145
  25. package/src/file-list-item/__tests__/FileListItem.spec.tsx +0 -339
  26. package/src/index.spec.ts +0 -43
  27. package/src/index.ts +0 -28
  28. package/src/linked-text/LinkeText.stories.tsx +0 -42
  29. package/src/linked-text/LinkedText.tsx +0 -47
  30. package/src/multiline-text/MultilineText.stories.tsx +0 -30
  31. package/src/multiline-text/MultilineText.ts +0 -16
  32. package/src/navbar/Navbar.stories.tsx +0 -135
  33. package/src/navbar/Navbar.tsx +0 -111
  34. package/src/navbar/NavbarAccordion.tsx +0 -171
  35. package/src/navbar/NavbarAvatar.tsx +0 -51
  36. package/src/navbar/NavbarBottomBar.tsx +0 -135
  37. package/src/navbar/NavbarContext.tsx +0 -23
  38. package/src/navbar/NavbarItem.tsx +0 -119
  39. package/src/navbar/NavbarList.tsx +0 -225
  40. package/src/navbar/NavbarMenu.tsx +0 -102
  41. package/src/sidebar/Sidebar.stories.tsx +0 -363
  42. package/src/sidebar/Sidebar.tsx +0 -73
  43. package/src/sidebar/SidebarBackButton.tsx +0 -33
  44. package/src/sidebar/SidebarContainer.tsx +0 -114
  45. package/src/sidebar/SidebarContent.tsx +0 -119
  46. package/src/sidebar/SidebarDivider.tsx +0 -15
  47. package/src/sidebar/SidebarMenuItem.tsx +0 -211
  48. package/src/sidebar/SidebarMenuItemAction.tsx +0 -27
  49. package/src/sidebar/SidebarMenuItemAvatar.tsx +0 -59
  50. package/src/sidebar/SidebarMenuItemContext.tsx +0 -33
  51. package/src/sidebar/SidebarSubheader.tsx +0 -38
  52. package/src/styled.d.ts +0 -12
  53. package/src/text-box/TextBox.stories.tsx +0 -108
  54. package/src/text-box/TextBox.tsx +0 -229
  55. package/src/utils/RuleNormalizer.ts +0 -24
  56. package/src/utils/mergeStyles.ts +0 -28
  57. package/tsconfig.json +0 -19
  58. /package/{pkg/dist-node → dist-node}/index.js +0 -0
  59. /package/{pkg/dist-node → dist-node}/index.js.map +0 -0
  60. /package/{pkg/dist-src → dist-src}/alert/Alert.js +0 -0
  61. /package/{pkg/dist-src → dist-src}/banner/Banner.js +0 -0
  62. /package/{pkg/dist-src → dist-src}/box/Box.js +0 -0
  63. /package/{pkg/dist-src → dist-src}/button/Button.js +0 -0
  64. /package/{pkg/dist-src → dist-src}/button-area/ButtonArea.js +0 -0
  65. /package/{pkg/dist-src → dist-src}/container/Container.js +0 -0
  66. /package/{pkg/dist-src → dist-src}/description-item/DescriptionItem.js +0 -0
  67. /package/{pkg/dist-src → dist-src}/file-drop-zone/FileDropZone.js +0 -0
  68. /package/{pkg/dist-src → dist-src}/file-list-item/FileListItem.js +0 -0
  69. /package/{pkg/dist-src → dist-src}/index.js +0 -0
  70. /package/{pkg/dist-src → dist-src}/linked-text/LinkedText.js +0 -0
  71. /package/{pkg/dist-src → dist-src}/multiline-text/MultilineText.js +0 -0
  72. /package/{pkg/dist-src → dist-src}/navbar/Navbar.js +0 -0
  73. /package/{pkg/dist-src → dist-src}/navbar/NavbarAccordion.js +0 -0
  74. /package/{pkg/dist-src → dist-src}/navbar/NavbarAvatar.js +0 -0
  75. /package/{pkg/dist-src → dist-src}/navbar/NavbarBottomBar.js +0 -0
  76. /package/{pkg/dist-src → dist-src}/navbar/NavbarContext.js +0 -0
  77. /package/{pkg/dist-src → dist-src}/navbar/NavbarItem.js +0 -0
  78. /package/{pkg/dist-src → dist-src}/navbar/NavbarList.js +0 -0
  79. /package/{pkg/dist-src → dist-src}/navbar/NavbarMenu.js +0 -0
  80. /package/{pkg/dist-src → dist-src}/sidebar/Sidebar.js +0 -0
  81. /package/{pkg/dist-src → dist-src}/sidebar/SidebarBackButton.js +0 -0
  82. /package/{pkg/dist-src → dist-src}/sidebar/SidebarContainer.js +0 -0
  83. /package/{pkg/dist-src → dist-src}/sidebar/SidebarContent.js +0 -0
  84. /package/{pkg/dist-src → dist-src}/sidebar/SidebarDivider.js +0 -0
  85. /package/{pkg/dist-src → dist-src}/sidebar/SidebarMenuItem.js +0 -0
  86. /package/{pkg/dist-src → dist-src}/sidebar/SidebarMenuItemAction.js +0 -0
  87. /package/{pkg/dist-src → dist-src}/sidebar/SidebarMenuItemAvatar.js +0 -0
  88. /package/{pkg/dist-src → dist-src}/sidebar/SidebarMenuItemContext.js +0 -0
  89. /package/{pkg/dist-src → dist-src}/sidebar/SidebarSubheader.js +0 -0
  90. /package/{pkg/dist-src → dist-src}/text-box/TextBox.js +0 -0
  91. /package/{pkg/dist-src → dist-src}/utils/RuleNormalizer.js +0 -0
  92. /package/{pkg/dist-src → dist-src}/utils/mergeStyles.js +0 -0
  93. /package/{pkg/dist-types → dist-types}/index.d.ts +0 -0
  94. /package/{pkg/dist-web → dist-web}/index.js +0 -0
  95. /package/{pkg/dist-web → dist-web}/index.js.map +0 -0
package/src/box/Box.tsx DELETED
@@ -1,252 +0,0 @@
1
- import {
2
- Color,
3
- ColorProp,
4
- isColorProp,
5
- NegativeSpaceProp,
6
- parseResponsiveProp,
7
- parseSpaceProp,
8
- ResponsiveProp,
9
- SpaceProp,
10
- } from '@superdispatch/ui';
11
- import { Property } from 'csstype';
12
- import { ForwardRefExoticComponent, ReactNode, Ref } from 'react';
13
- import styled, { CSSObject } from 'styled-components';
14
- import { createRuleNormalizer, RuleNormalizer } from '../utils/RuleNormalizer';
15
-
16
- //
17
- // Colors
18
- //
19
-
20
- function normalizeColor(input: unknown): string | undefined {
21
- return isColorProp(input) ? Color[input] : undefined;
22
- }
23
-
24
- //
25
- // Space
26
- //
27
-
28
- function parseSpace(space: unknown): string {
29
- return `${parseSpaceProp(space as SpaceProp)}px`;
30
- }
31
-
32
- //
33
- // Margins
34
- //
35
-
36
- export type MarginProp = 'auto' | SpaceProp | NegativeSpaceProp;
37
- function parseMargin(input: unknown): string {
38
- if (input === 'auto') return input;
39
-
40
- let prefix = '';
41
-
42
- if (typeof input == 'string' && input.startsWith('-')) {
43
- prefix = '-';
44
- input = input.slice(1);
45
- }
46
-
47
- return prefix + parseSpace(input);
48
- }
49
-
50
- //
51
- // Borders
52
- //
53
-
54
- export type BorderRadiusProp = 'none' | 'small' | 'medium';
55
- const normalizeBorderRadius = createRuleNormalizer<BorderRadiusProp>({
56
- none: 0,
57
- small: 4,
58
- medium: 8,
59
- });
60
-
61
- export type BorderWidthProp = 'none' | 'small' | 'medium' | 'large';
62
- const normalizeBorderWidth = createRuleNormalizer<BorderWidthProp>({
63
- none: 0,
64
- small: 1,
65
- medium: 2,
66
- large: 4,
67
- });
68
-
69
- //
70
- // Rules
71
- //
72
-
73
- interface BoxRules {
74
- display?: ResponsiveProp<Property.Display>;
75
-
76
- color?: ResponsiveProp<ColorProp>;
77
- backgroundColor?: ResponsiveProp<ColorProp>;
78
-
79
- borderColor?: ResponsiveProp<ColorProp>;
80
- borderTopColor?: ResponsiveProp<ColorProp>;
81
- borderLeftColor?: ResponsiveProp<ColorProp>;
82
- borderRightColor?: ResponsiveProp<ColorProp>;
83
- borderBottomColor?: ResponsiveProp<ColorProp>;
84
-
85
- borderWidth?: ResponsiveProp<BorderWidthProp>;
86
- borderTopWidth?: ResponsiveProp<BorderWidthProp>;
87
- borderLeftWidth?: ResponsiveProp<BorderWidthProp>;
88
- borderRightWidth?: ResponsiveProp<BorderWidthProp>;
89
- borderBottomWidth?: ResponsiveProp<BorderWidthProp>;
90
-
91
- padding?: ResponsiveProp<SpaceProp>;
92
- paddingTop?: ResponsiveProp<SpaceProp>;
93
- paddingLeft?: ResponsiveProp<SpaceProp>;
94
- paddingRight?: ResponsiveProp<SpaceProp>;
95
- paddingBottom?: ResponsiveProp<SpaceProp>;
96
-
97
- margin?: ResponsiveProp<MarginProp>;
98
- marginTop?: ResponsiveProp<MarginProp>;
99
- marginLeft?: ResponsiveProp<MarginProp>;
100
- marginRight?: ResponsiveProp<MarginProp>;
101
- marginBottom?: ResponsiveProp<MarginProp>;
102
-
103
- borderRadius?: ResponsiveProp<BorderRadiusProp>;
104
- borderTopLeftRadius?: ResponsiveProp<BorderRadiusProp>;
105
- borderTopRightRadius?: ResponsiveProp<BorderRadiusProp>;
106
- borderBottomLeftRadius?: ResponsiveProp<BorderRadiusProp>;
107
- borderBottomRightRadius?: ResponsiveProp<BorderRadiusProp>;
108
-
109
- fontSize?: ResponsiveProp<Property.FontSize>;
110
-
111
- width?: ResponsiveProp<Property.Width>;
112
- maxWidth?: ResponsiveProp<Property.MaxWidth>;
113
- minWidth?: ResponsiveProp<Property.MinWidth>;
114
-
115
- height?: ResponsiveProp<Property.Height>;
116
- maxHeight?: ResponsiveProp<Property.MaxHeight>;
117
- minHeight?: ResponsiveProp<Property.MinHeight>;
118
-
119
- overflow?: ResponsiveProp<Property.Overflow>;
120
- overflowY?: ResponsiveProp<Property.OverflowY>;
121
- overflowX?: ResponsiveProp<Property.OverflowX>;
122
-
123
- top?: ResponsiveProp<Property.Top>;
124
- left?: ResponsiveProp<Property.Left>;
125
- right?: ResponsiveProp<Property.Right>;
126
- bottom?: ResponsiveProp<Property.Bottom>;
127
- position?: ResponsiveProp<Property.Position>;
128
- }
129
-
130
- const normalizers: Record<keyof BoxRules, undefined | RuleNormalizer> = {
131
- display: undefined,
132
-
133
- color: normalizeColor,
134
- backgroundColor: normalizeColor,
135
-
136
- borderColor: normalizeColor,
137
- borderTopColor: normalizeColor,
138
- borderLeftColor: normalizeColor,
139
- borderRightColor: normalizeColor,
140
- borderBottomColor: normalizeColor,
141
-
142
- borderWidth: normalizeBorderWidth,
143
- borderTopWidth: normalizeBorderWidth,
144
- borderLeftWidth: normalizeBorderWidth,
145
- borderRightWidth: normalizeBorderWidth,
146
- borderBottomWidth: normalizeBorderWidth,
147
-
148
- margin: parseMargin,
149
- marginTop: parseMargin,
150
- marginLeft: parseMargin,
151
- marginRight: parseMargin,
152
- marginBottom: parseMargin,
153
-
154
- padding: parseSpace,
155
- paddingTop: parseSpace,
156
- paddingLeft: parseSpace,
157
- paddingRight: parseSpace,
158
- paddingBottom: parseSpace,
159
-
160
- borderRadius: normalizeBorderRadius,
161
- borderTopLeftRadius: normalizeBorderRadius,
162
- borderTopRightRadius: normalizeBorderRadius,
163
- borderBottomLeftRadius: normalizeBorderRadius,
164
- borderBottomRightRadius: normalizeBorderRadius,
165
-
166
- fontSize: undefined,
167
-
168
- width: undefined,
169
- maxWidth: undefined,
170
- minWidth: undefined,
171
-
172
- height: undefined,
173
- maxHeight: undefined,
174
- minHeight: undefined,
175
-
176
- overflow: undefined,
177
- overflowY: undefined,
178
- overflowX: undefined,
179
-
180
- top: undefined,
181
- left: undefined,
182
- right: undefined,
183
- bottom: undefined,
184
- position: undefined,
185
- };
186
-
187
- function injectRule(
188
- styles: CSSObject,
189
- key: string,
190
- breakpoint: string,
191
- value: unknown,
192
- normalizer: undefined | RuleNormalizer,
193
- ): void {
194
- if (normalizer != null) value = normalizer(value);
195
-
196
- if (value != null) {
197
- let rules = styles[breakpoint];
198
-
199
- if (typeof rules != 'object') {
200
- rules = {};
201
- styles[breakpoint] = rules;
202
- }
203
-
204
- rules[key] = String(value);
205
- }
206
- }
207
-
208
- //
209
- // Box
210
- //
211
-
212
- export interface BoxProps extends BoxRules {
213
- ref?: Ref<unknown>;
214
- as?: keyof JSX.IntrinsicElements;
215
-
216
- role?: string;
217
- children?: ReactNode;
218
- }
219
-
220
- export const Box: ForwardRefExoticComponent<BoxProps> = styled.div<BoxProps>(
221
- (props) => {
222
- const { breakpoints } = props.theme;
223
- const xs = breakpoints.up('xs');
224
- const sm = breakpoints.up('sm');
225
- const md = breakpoints.up('md');
226
-
227
- const styles: CSSObject = {
228
- margin: 0,
229
- padding: 0,
230
- borderWidth: 0,
231
- borderStyle: 'solid',
232
- };
233
-
234
- for (const k in props) {
235
- if (Object.prototype.hasOwnProperty.call(props, k) && k in normalizers) {
236
- const key = k as keyof BoxRules;
237
- const prop = props[key];
238
-
239
- if (prop != null) {
240
- const [mobile, tablet, desktop] = parseResponsiveProp(prop);
241
-
242
- const normalizer = normalizers[key];
243
- injectRule(styles, key, xs, mobile, normalizer);
244
- injectRule(styles, key, sm, tablet, normalizer);
245
- injectRule(styles, key, md, desktop, normalizer);
246
- }
247
- }
248
- }
249
-
250
- return styles;
251
- },
252
- );