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