@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,238 @@
1
+ import {
2
+ ColorDynamic,
3
+ parseResponsiveProp,
4
+ ResponsiveProp,
5
+ ResponsivePropTuple,
6
+ SuperDispatchTheme,
7
+ } from '@superdispatch/ui';
8
+ import { forwardRef, ReactNode } from 'react';
9
+ import styled, { css, CSSObject, SimpleInterpolation } from 'styled-components';
10
+ import { mergeStyles } from '../utils/mergeStyles';
11
+ import { createRuleNormalizer } from '../utils/RuleNormalizer';
12
+
13
+ export type TextAlignProp = 'left' | 'right' | 'center';
14
+ export type TextColorProp =
15
+ | 'inherit'
16
+ | 'primary'
17
+ | 'secondary'
18
+ | 'light-gray' //*deprecated use disabled instead
19
+ | 'disabled'
20
+ | 'white'
21
+ | 'blue'
22
+ | 'green'
23
+ | 'purple'
24
+ | 'red'
25
+ | 'teal'
26
+ | 'yellow';
27
+ export type TextDisplayProp =
28
+ | 'none'
29
+ | 'block'
30
+ | 'inline'
31
+ | 'initial'
32
+ | 'inherit';
33
+
34
+ const normalizeTextColor = createRuleNormalizer<TextColorProp>({
35
+ inherit: 'inherit',
36
+ primary: ColorDynamic.Dark500,
37
+ secondary: ColorDynamic.Dark300,
38
+ 'light-gray': ColorDynamic.Dark100, //*deprecated use disabled instead
39
+ disabled: ColorDynamic.Dark100,
40
+ white: ColorDynamic.White,
41
+ blue: ColorDynamic.Blue500,
42
+ green: ColorDynamic.Green500,
43
+ purple: ColorDynamic.Purple500,
44
+ red: ColorDynamic.Red500,
45
+ teal: ColorDynamic.Teal500,
46
+ yellow: ColorDynamic.Yellow500,
47
+ });
48
+
49
+ export type TextVariantProp =
50
+ | 'heading-1'
51
+ | 'heading-2'
52
+ | 'heading-3'
53
+ | 'heading-4'
54
+ | 'heading-5'
55
+ | 'heading-6'
56
+ | 'body'
57
+ | 'body-block'
58
+ | 'body-semibold'
59
+ | 'caption'
60
+ | 'hint';
61
+
62
+ const VARIANT_TYPE_MAPPING: Record<
63
+ TextVariantProp,
64
+ undefined | keyof JSX.IntrinsicElements
65
+ > = {
66
+ 'heading-1': 'h1',
67
+ 'heading-2': 'h2',
68
+ 'heading-3': 'h3',
69
+ 'heading-4': 'h4',
70
+ 'heading-5': 'h5',
71
+ 'heading-6': 'h6',
72
+
73
+ body: 'span',
74
+ 'body-block': 'p',
75
+ 'body-semibold': 'span',
76
+ caption: 'span',
77
+ hint: 'span',
78
+ };
79
+
80
+ function variantMixin(
81
+ { typography, breakpoints }: SuperDispatchTheme,
82
+ variant: TextVariantProp,
83
+ ): CSSObject {
84
+ switch (variant) {
85
+ case 'heading-1':
86
+ return typography.h1 as CSSObject;
87
+ case 'heading-2':
88
+ return typography.h2 as CSSObject;
89
+ case 'heading-3':
90
+ return typography.h3 as CSSObject;
91
+ case 'heading-4':
92
+ return typography.h4 as CSSObject;
93
+ case 'heading-5':
94
+ return typography.h5 as CSSObject;
95
+ case 'heading-6':
96
+ return typography.h6 as CSSObject;
97
+ case 'body':
98
+ default:
99
+ return typography.body2 as CSSObject;
100
+ case 'body-block': {
101
+ return mergeStyles({}, typography.body2 as CSSObject, {
102
+ lineHeight: '24px',
103
+ [breakpoints.only('xs')]: { lineHeight: '28px' },
104
+ });
105
+ }
106
+ case 'body-semibold':
107
+ return typography.body1 as CSSObject;
108
+ case 'caption':
109
+ return typography.caption as CSSObject;
110
+ case 'hint':
111
+ return mergeStyles({}, typography.caption as CSSObject, {
112
+ lineHeight: '20px',
113
+ fontSize: '13px',
114
+ });
115
+ }
116
+ }
117
+
118
+ function textBoxMixin(
119
+ noWrap: boolean,
120
+ align: TextAlignProp,
121
+ color: TextColorProp,
122
+ display: TextDisplayProp,
123
+ wrapOverflow: boolean,
124
+ ): readonly SimpleInterpolation[] {
125
+ return css`
126
+ text-align: ${align};
127
+ color: ${normalizeTextColor(color)};
128
+ display: ${display === 'initial' && (noWrap || align !== 'left')
129
+ ? 'block'
130
+ : display};
131
+ overflow: ${noWrap ? 'hidden' : 'visible'};
132
+ white-space: ${noWrap ? 'nowrap' : 'normal'};
133
+ overflow-wrap: ${wrapOverflow ? 'break-word' : 'normal'};
134
+ `;
135
+ }
136
+
137
+ interface TextBoxRootProps {
138
+ $variant: TextVariantProp;
139
+ $noWrap: ResponsivePropTuple<boolean>;
140
+ $wrapOverflow: ResponsivePropTuple<boolean>;
141
+ $align: ResponsivePropTuple<TextAlignProp>;
142
+ $color: ResponsivePropTuple<TextColorProp>;
143
+ $display: ResponsivePropTuple<TextDisplayProp>;
144
+ }
145
+
146
+ const TextBoxRoot = styled.span<TextBoxRootProps>(
147
+ ({ theme, $noWrap, $variant, $align, $color, $display, $wrapOverflow }) =>
148
+ css`
149
+ margin: 0;
150
+ padding: 0;
151
+ text-overflow: ellipsis;
152
+
153
+ ${variantMixin(theme, $variant)};
154
+
155
+ ${textBoxMixin(
156
+ $noWrap[0],
157
+ $align[0],
158
+ $color[0],
159
+ $display[0],
160
+ $wrapOverflow[0],
161
+ )};
162
+
163
+ ${theme.breakpoints.up('sm')} {
164
+ ${textBoxMixin(
165
+ $noWrap[1],
166
+ $align[1],
167
+ $color[1],
168
+ $display[1],
169
+ $wrapOverflow[1],
170
+ )};
171
+ }
172
+
173
+ ${theme.breakpoints.up('md')} {
174
+ ${textBoxMixin(
175
+ $noWrap[2],
176
+ $align[2],
177
+ $color[2],
178
+ $display[2],
179
+ $wrapOverflow[2],
180
+ )};
181
+ }
182
+ `,
183
+ );
184
+
185
+ export interface TextBoxProps {
186
+ children?: ReactNode;
187
+ as?: keyof JSX.IntrinsicElements;
188
+
189
+ id?: string;
190
+ 'aria-label'?: string;
191
+ 'aria-labelledby'?: string;
192
+ 'aria-describedby'?: string;
193
+
194
+ variant?: TextVariantProp;
195
+
196
+ noWrap?: ResponsiveProp<boolean>;
197
+ wrapOverflow?: ResponsiveProp<boolean>;
198
+
199
+ align?: ResponsiveProp<TextAlignProp>;
200
+ color?: ResponsiveProp<TextColorProp>;
201
+ display?: ResponsiveProp<TextDisplayProp>;
202
+ }
203
+
204
+ export const TextBox = forwardRef<HTMLElement, TextBoxProps>(
205
+ (
206
+ {
207
+ variant: $variant = 'body',
208
+ as = VARIANT_TYPE_MAPPING[$variant],
209
+ align = 'left',
210
+ color = 'primary',
211
+ display = 'initial',
212
+ noWrap = false,
213
+ wrapOverflow = false,
214
+ ...props
215
+ },
216
+ ref,
217
+ ) => {
218
+ const $align = parseResponsiveProp(align);
219
+ const $color = parseResponsiveProp(color);
220
+ const $noWrap = parseResponsiveProp(noWrap);
221
+ const $display = parseResponsiveProp(display);
222
+ const $wrapOverflow = parseResponsiveProp(wrapOverflow);
223
+
224
+ return (
225
+ <TextBoxRoot
226
+ {...props}
227
+ as={as}
228
+ ref={ref}
229
+ $align={$align}
230
+ $color={$color}
231
+ $noWrap={$noWrap}
232
+ $display={$display}
233
+ $variant={$variant}
234
+ $wrapOverflow={$wrapOverflow}
235
+ />
236
+ );
237
+ },
238
+ );
@@ -0,0 +1,24 @@
1
+ export type RuleNormalizer = (input: unknown) => string | undefined;
2
+ export type RuleNormalizerRecord<T extends string = string> = Readonly<
3
+ Record<T, undefined | RuleNormalizer>
4
+ >;
5
+
6
+ export function createRuleNormalizer<TKey extends string>(
7
+ rules: Record<TKey, unknown>,
8
+ ): RuleNormalizer {
9
+ return (input) => {
10
+ if (typeof input == 'string') {
11
+ const value = rules[input as TKey];
12
+
13
+ if (typeof value == 'number') {
14
+ return `${value}px`;
15
+ }
16
+
17
+ if (typeof value == 'string') {
18
+ return value;
19
+ }
20
+ }
21
+
22
+ return undefined;
23
+ };
24
+ }
@@ -0,0 +1,28 @@
1
+ import { CSSObject } from 'styled-components';
2
+
3
+ export function mergeStyles(
4
+ styles: CSSObject,
5
+ ...sources: Array<null | false | undefined | CSSObject>
6
+ ): CSSObject {
7
+ for (const source of sources) {
8
+ if (source) {
9
+ for (const key in source) {
10
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
11
+ const stylesValue = styles[key];
12
+ const sourceValue = source[key];
13
+
14
+ if (
15
+ typeof stylesValue == 'object' &&
16
+ typeof sourceValue == 'object'
17
+ ) {
18
+ mergeStyles(stylesValue, sourceValue);
19
+ } else {
20
+ styles[key] = source[key];
21
+ }
22
+ }
23
+ }
24
+ }
25
+ }
26
+
27
+ return styles;
28
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "extends": "../../tsconfig.build",
3
+ "exclude": [
4
+ "pkg",
5
+ "playroom.ts",
6
+ "**/*.spec.*",
7
+ "**/*.stories.*",
8
+ "**/*.playroom.*",
9
+ "**/__tests__/**",
10
+ "**/__testutils__/**"
11
+ ],
12
+ "references": [{ "path": "../hooks" }, { "path": "../__testutils__" }],
13
+ "compilerOptions": {
14
+ "composite": true,
15
+ "rootDir": "src",
16
+ "outDir": "pkg/dist-types",
17
+ "tsBuildInfoFile": "pkg/dist-types/.tsbuildinfo"
18
+ }
19
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2019 Super Dispatch
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.