@sproutsocial/seeds-react-menu 1.7.2 → 1.7.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 (47) hide show
  1. package/.turbo/turbo-build.log +19 -11
  2. package/BUNDLE_OPTIMIZATION.md +307 -0
  3. package/CHANGELOG.md +39 -0
  4. package/dist/esm/chunk-ROQATIB7.js +357 -0
  5. package/dist/esm/chunk-ROQATIB7.js.map +1 -0
  6. package/dist/esm/index.js +261 -2271
  7. package/dist/esm/index.js.map +1 -1
  8. package/dist/esm/v2/index.js +2000 -0
  9. package/dist/esm/v2/index.js.map +1 -0
  10. package/dist/index.d.mts +1 -0
  11. package/dist/index.d.ts +1 -0
  12. package/dist/index.js +297 -1989
  13. package/dist/index.js.map +1 -1
  14. package/dist/v2/index.d.mts +96 -0
  15. package/dist/v2/index.d.ts +96 -0
  16. package/dist/v2/index.js +2191 -0
  17. package/dist/v2/index.js.map +1 -0
  18. package/package.json +30 -14
  19. package/src/MenuItem/styles.tsx +7 -0
  20. package/src/v2/Autocomplete/Autocomplete.stories.tsx +609 -0
  21. package/src/v2/Autocomplete/MultiAutocomplete.tsx +453 -0
  22. package/src/v2/Autocomplete/SingleAutocomplete.tsx +362 -0
  23. package/src/v2/Autocomplete/index.ts +2 -0
  24. package/src/v2/Common-V2/ComboboxContent.tsx +448 -0
  25. package/src/v2/Common-V2/MenuGroup.tsx +60 -0
  26. package/src/v2/Common-V2/MenuGroupTypes.ts +30 -0
  27. package/src/v2/Common-V2/MenuHeading.tsx +83 -0
  28. package/src/v2/Common-V2/MenuItem.tsx +138 -0
  29. package/src/v2/Common-V2/Popout.tsx +102 -0
  30. package/src/v2/Common-V2/PopoutTypes.tsx +92 -0
  31. package/src/v2/Common-V2/SelectToggleButton.tsx +99 -0
  32. package/src/v2/Common-V2/index.ts +11 -0
  33. package/src/v2/Common-V2/props.ts +74 -0
  34. package/src/v2/Common-V2/styles.tsx +41 -0
  35. package/src/v2/Common-V2/types.ts +16 -0
  36. package/src/v2/Common-V2/useHighlightedIndex.ts +62 -0
  37. package/src/v2/Common-V2/utils.ts +238 -0
  38. package/src/v2/SearchableSelect/AutocompleteContent.tsx +325 -0
  39. package/src/v2/SearchableSelect/SearchableMultiSelect.tsx +521 -0
  40. package/src/v2/SearchableSelect/SearchableSelect.tsx +389 -0
  41. package/src/v2/SearchableSelect/index.ts +12 -0
  42. package/src/v2/Select/MultiSelect.tsx +404 -0
  43. package/src/v2/Select/Select.stories.tsx +593 -0
  44. package/src/v2/Select/SingleSelect.tsx +272 -0
  45. package/src/v2/Select/index.ts +2 -0
  46. package/src/v2/index.ts +2 -0
  47. package/tsup.config.ts +14 -5
@@ -1,6 +1,6 @@
1
1
  yarn run v1.22.22
2
2
  $ tsup --dts
3
- CLI Building entry: src/index.ts
3
+ CLI Building entry: {"index":"src/index.ts","v2/index":"src/v2/index.ts"}
4
4
  CLI Using tsconfig: tsconfig.json
5
5
  CLI tsup v8.5.0
6
6
  CLI Using tsup config: /home/runner/work/seeds/seeds/seeds-react/seeds-react-menu/tsup.config.ts
@@ -8,14 +8,22 @@ $ tsup --dts
8
8
  CLI Cleaning output folder
9
9
  CJS Build start
10
10
  ESM Build start
11
- CJS dist/index.js 144.65 KB
12
- CJS dist/index.js.map 372.90 KB
13
- CJS ⚡️ Build success in 403ms
14
- ESM dist/esm/index.js 134.70 KB
15
- ESM dist/esm/index.js.map 371.61 KB
16
- ESM ⚡️ Build success in 411ms
11
+ CJS dist/index.js 89.97 KB
12
+ CJS dist/v2/index.js 70.74 KB
13
+ CJS dist/index.js.map 175.39 KB
14
+ CJS dist/v2/index.js.map 146.40 KB
15
+ CJS ⚡️ Build success in 344ms
16
+ ESM dist/esm/index.js 70.94 KB
17
+ ESM dist/esm/v2/index.js 60.19 KB
18
+ ESM dist/esm/chunk-ROQATIB7.js 9.15 KB
19
+ ESM dist/esm/index.js.map 151.43 KB
20
+ ESM dist/esm/v2/index.js.map 126.72 KB
21
+ ESM dist/esm/chunk-ROQATIB7.js.map 22.93 KB
22
+ ESM ⚡️ Build success in 344ms
17
23
  DTS Build start
18
- DTS ⚡️ Build success in 8874ms
19
- DTS dist/index.d.ts 39.03 KB
20
- DTS dist/index.d.mts 39.03 KB
21
- Done in 10.34s.
24
+ DTS ⚡️ Build success in 16182ms
25
+ DTS dist/index.d.ts 39.06 KB
26
+ DTS dist/v2/index.d.ts 4.87 KB
27
+ DTS dist/index.d.mts 39.06 KB
28
+ DTS dist/v2/index.d.mts 4.87 KB
29
+ Done in 17.64s.
@@ -0,0 +1,307 @@
1
+ # Bundle Size Optimization Guide
2
+
3
+ ## Overview
4
+
5
+ This document outlines the bundle size optimization work for the `seeds-react-menu` package. Phase 1 has been completed, reducing the bundle size from **124 KB to 90 KB (27% reduction)**. This document provides guidance for future optimizations.
6
+
7
+ ---
8
+
9
+ ## Phase 1: Completed ✓
10
+
11
+ **Date**: 2025-12-19
12
+ **Status**: Completed
13
+ **Reduction**: 124 KB → 90 KB (27% reduction)
14
+
15
+ ### Changes Made
16
+
17
+ 1. **Updated tsup.config.ts** - Externalized critical dependencies:
18
+ - `styled-system` (previously bundled ~25 KB)
19
+ - `styled-components`
20
+ - All `@sproutsocial/*` packages (monorepo optimization)
21
+
22
+ 2. **Updated package.json** - Added `styled-system` to `peerDependencies`
23
+
24
+ ### Results
25
+
26
+ - **CJS Bundle**: 124 KB → 90 KB
27
+ - **ESM Bundle**: 70 KB → 71 KB (stayed similar)
28
+ - All tests passing
29
+ - No breaking changes for consumers
30
+
31
+ ---
32
+
33
+ ## Phase 2: Medium-term Optimizations (Future Work)
34
+
35
+ **Goal**: Reduce bundle from ~90 KB → 35-45 KB (additional 50%+ reduction)
36
+ **Risk**: Medium
37
+ **Breaking Changes**: Minor (removal of rarely-used system props)
38
+ **Estimated Effort**: 1-2 days
39
+
40
+ ### 2.1 Remove or Deprecate styled-system Usage
41
+
42
+ **Current Issue**: Five files import styled-system functions to enable runtime style props:
43
+ - `/Users/ozzy/code/seeds/seeds-react/seeds-react-menu/src/MenuItem/styles.tsx` (lines 105-110)
44
+ - `/Users/ozzy/code/seeds/seeds-react/seeds-react-menu/src/MenuHeader/styles.tsx`
45
+ - `/Users/ozzy/code/seeds/seeds-react/seeds-react-menu/src/MenuContent/styles.tsx`
46
+ - `/Users/ozzy/code/seeds/seeds-react/seeds-react-menu/src/MenuGroup/styles.tsx`
47
+ - `/Users/ozzy/code/seeds/seeds-react/seeds-react-menu/src/v2/Common-V2/styles.tsx`
48
+
49
+ These files use styled-system's `border`, `color`, `flexbox`, `grid`, `layout`, and `space` functions.
50
+
51
+ **Options**:
52
+ - **Option A**: Remove styled-system props entirely (breaking change, requires major version)
53
+ - **Option B**: Keep but document as deprecated for v3 (non-breaking)
54
+ - **Option C**: Remove from internal components only, keep on public APIs (hybrid approach)
55
+
56
+ **Recommendation**:
57
+ 1. First, audit usage in consuming applications to understand impact
58
+ 2. Start with Option C - remove from internal components
59
+ 3. If usage is minimal, consider Option A for v3.0
60
+
61
+ **Expected Savings**: ~10-15 KB
62
+
63
+ **Implementation Steps**:
64
+ 1. Run analytics or search consuming apps for usage of system props on Menu components
65
+ 2. If usage < 5%, proceed with removal
66
+ 3. If usage > 5%, add deprecation warnings in v2.x
67
+ 4. Update TypeScript types to remove system prop types
68
+ 5. Replace system props with direct CSS-in-JS styling
69
+
70
+ **Example Refactor**:
71
+ ```typescript
72
+ // BEFORE
73
+ export const StyledMenuItem = styled.button<{...}>`
74
+ // ... styles ...
75
+ ${border}
76
+ ${color}
77
+ ${flexbox}
78
+ ${grid}
79
+ ${layout}
80
+ ${space}
81
+ `;
82
+
83
+ // AFTER
84
+ export const StyledMenuItem = styled.button<{...}>`
85
+ // ... styles ...
86
+ // System props removed - use CSS-in-JS props or custom styled component
87
+ `;
88
+ ```
89
+
90
+ ### 2.2 Optimize seeds-react-text Import
91
+
92
+ **Current Issue**: `MenuGroup/styles.tsx` and `v2/Common-V2/styles.tsx` import the entire Text component:
93
+
94
+ ```typescript
95
+ import Text from "@sproutsocial/seeds-react-text";
96
+ export const StyledTitle = styled(Text.SmallSubHeadline)`...`;
97
+ ```
98
+
99
+ **Solution**: Replace with direct styled component implementation:
100
+
101
+ ```typescript
102
+ export const StyledTitle = styled.h3`
103
+ ${({ theme }) => theme.typography[100]};
104
+ font-weight: ${({ theme }) => theme.fontWeights.semibold};
105
+ // ... other styles from Text.SmallSubHeadline
106
+ `;
107
+ ```
108
+
109
+ **Expected Savings**: ~3-5 KB
110
+
111
+ **Implementation Steps**:
112
+ 1. Identify all Text component styles in `MenuGroup/styles.tsx`
113
+ 2. Replace with equivalent theme-based styles
114
+ 3. Test visual regression in Storybook
115
+ 4. Update v2 components similarly
116
+
117
+ ---
118
+
119
+ ## Phase 3: Architectural Changes (Long-term)
120
+
121
+ **Goal**: Reduce bundle to 20-30 KB through structural changes
122
+ **Risk**: High
123
+ **Breaking Changes**: Yes (major version bump required)
124
+ **Estimated Effort**: 1-2 weeks
125
+
126
+ ### 3.1 Package Splitting Strategy
127
+
128
+ **Proposal**: Split into multiple packages to enable better tree-shaking:
129
+
130
+ ```
131
+ @sproutsocial/seeds-react-menu-core (primitives only, ~8-12 KB)
132
+ ├── MenuItem
133
+ ├── MenuHeader
134
+ ├── MenuContent
135
+ ├── MenuFooter
136
+ └── MenuRoot
137
+
138
+ @sproutsocial/seeds-react-menu (composed menus, ~12-15 KB)
139
+ ├── ActionMenu
140
+ ├── SingleSelectMenu
141
+ ├── MultiSelectMenu
142
+ └── depends on: seeds-react-menu-core
143
+
144
+ @sproutsocial/seeds-react-menu-autocomplete (~10-15 KB)
145
+ ├── Autocomplete
146
+ ├── AutocompleteInput
147
+ └── depends on: seeds-react-menu-core
148
+
149
+ @sproutsocial/seeds-react-menu-v2 (experimental, ~8-10 KB)
150
+ └── All v2 components
151
+ ```
152
+
153
+ **Benefits**:
154
+ - Consumers only bundle what they use
155
+ - Single select menu import: ~20-25 KB total instead of 90 KB
156
+ - Clear deprecation path for v1 vs v2
157
+ - Easier to maintain and reason about
158
+
159
+ **Migration Path**:
160
+ 1. Release new packages alongside existing package
161
+ 2. Mark old package as deprecated but maintain for 6-12 months
162
+ 3. Provide codemod for automated migration
163
+ 4. Update documentation and examples
164
+
165
+ **Considerations**:
166
+ - Increased maintenance overhead (multiple packages)
167
+ - Need clear documentation on which package to use when
168
+ - Requires monorepo tooling updates
169
+ - May need umbrella package that re-exports everything for easy migration
170
+
171
+ ### 3.2 Consolidate v1 and v2 Implementations
172
+
173
+ **Current State**:
174
+ - Main export (`src/index.ts`) exports ALL v1 components (80 files)
175
+ - V2 export (`src/v2/index.ts`) exports v2 components (25 files)
176
+ - Both versions share some code but have duplicate implementations
177
+
178
+ **Proposal**: Treat v2 as the future, deprecate v1
179
+
180
+ **Timeline**:
181
+ 1. **v3.0.0**: Mark v1 as deprecated, promote v2 to stable
182
+ 2. **v3.x**: Maintain both but encourage migration
183
+ 3. **v4.0.0**: Remove v1 entirely
184
+
185
+ **Expected Savings**: ~25-30 KB (eliminating duplicate implementations)
186
+
187
+ **Migration Support**:
188
+ - Provide detailed migration guide
189
+ - Create codemod to automate v1 → v2 migration
190
+ - Maintain v2.x branch for critical security fixes
191
+ - Communication plan for deprecation timeline
192
+
193
+ ### 3.3 Evaluate Dependency Alternatives
194
+
195
+ **Downshift Analysis** (`downshift@9.0.4`)
196
+ - Currently used for menu state management
197
+ - Likely contributes significantly to bundle size
198
+ - Consider alternatives:
199
+ - Custom hook-based state management (~2-3 KB)
200
+ - Radix UI's Select primitives (already using Popover)
201
+ - Headless UI
202
+
203
+ **Action Items**:
204
+ 1. Analyze Downshift's actual bundle contribution with bundle analyzer
205
+ 2. Prototype custom state management solution
206
+ 3. Compare API complexity vs bundle savings
207
+ 4. Make decision based on maintenance overhead vs size benefit
208
+
209
+ **Motion Library Analysis** (`motion@12.6.3`)
210
+ - Only used in v2 and NestedMenu
211
+ - Consider lazy-loading for those specific use cases
212
+ - Evaluate if animation is critical or can be simplified
213
+
214
+ ---
215
+
216
+ ## Measurement Tools
217
+
218
+ ### Before Starting Optimizations
219
+
220
+ ```bash
221
+ # Build with metadata for analysis
222
+ npm run build:debug
223
+
224
+ # Analyze bundle composition
225
+ npx esbuild-visualizer --metadata dist/metafile-esm.json
226
+ ```
227
+
228
+ ### After Optimizations
229
+
230
+ ```bash
231
+ # Check bundle sizes
232
+ ls -lh dist/index.js dist/esm/index.js
233
+
234
+ # Verify externalizations
235
+ grep -r "styled-system" dist/*.js
236
+ grep -r "@sproutsocial" dist/*.js
237
+ ```
238
+
239
+ ### Consumer Impact Testing
240
+
241
+ Test in reference applications:
242
+ 1. Build consuming app and check bundle size
243
+ 2. Use webpack-bundle-analyzer or similar
244
+ 3. Verify no duplicate dependencies
245
+ 4. Check runtime performance (no regression)
246
+
247
+ ---
248
+
249
+ ## Success Metrics
250
+
251
+ | Phase | Target Size (CJS) | Target Size (ESM) | % Reduction | Status |
252
+ |-------|------------------|-------------------|-------------|--------|
253
+ | Baseline | 124 KB | 70 KB | - | - |
254
+ | **Phase 1** | **90 KB** | **71 KB** | **27%** | **✓ Completed** |
255
+ | Phase 2 | 35-45 KB | 25-30 KB | 65-72% | Planned |
256
+ | Phase 3 | 20-30 KB | 15-20 KB | 76-84% | Future |
257
+
258
+ ---
259
+
260
+ ## Additional Considerations
261
+
262
+ ### Consumer Bundle Size vs Package Size
263
+
264
+ It's important to distinguish between:
265
+ - **Package distribution size**: What gets downloaded from npm
266
+ - **Consumer bundle size**: What actually ends up in the consuming application
267
+
268
+ Phase 1 optimizations help both, but especially consumer bundle size by:
269
+ - Avoiding duplicate @sproutsocial packages in monorepo
270
+ - Ensuring styled-system is shared across all Seeds components
271
+ - Leveraging tree-shaking in modern bundlers
272
+
273
+ ### Monorepo Considerations
274
+
275
+ Since this package is part of the Seeds monorepo:
276
+ - Externalizing @sproutsocial packages is critical to avoid duplication
277
+ - Consumers using multiple Seeds packages benefit significantly
278
+ - Consider monorepo-wide bundle analysis for full picture
279
+
280
+ ### Testing Strategy
281
+
282
+ For any optimization work:
283
+ 1. **Unit Tests**: All existing tests must pass
284
+ 2. **Visual Regression**: Storybook snapshots unchanged
285
+ 3. **Integration Tests**: Test in reference applications
286
+ 4. **Performance Tests**: Ensure no runtime performance regression
287
+ 5. **Bundle Analysis**: Use visualization tools to verify savings
288
+
289
+ ---
290
+
291
+ ## Resources
292
+
293
+ - [TypeScript Monorepo Best Practices](https://colinhacks.com/essays/live-types-typescript-monorepo)
294
+ - [tsup Documentation](https://tsup.egoist.dev/)
295
+ - [Bundle Size Analysis Tools](https://bundlephobia.com/)
296
+
297
+ ---
298
+
299
+ ## Questions or Concerns?
300
+
301
+ If you're planning to tackle Phase 2 or 3 optimizations, please:
302
+ 1. Review this document and the original analysis
303
+ 2. Coordinate with the team on breaking changes
304
+ 3. Create RFCs for major architectural changes (Phase 3)
305
+ 4. Update this document with your findings and results
306
+
307
+ Last updated: 2025-12-19
package/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # @sproutsocial/seeds-react-menu
2
2
 
3
+ ## 1.7.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 2b1bb50: Optimize bundle size by externalizing dependencies
8
+
9
+ Reduced the CJS bundle size from 124 KB to 90 KB (27% reduction) by properly externalizing `styled-system`, `styled-components`, and all `@sproutsocial/*` monorepo packages in the build configuration. This prevents these dependencies from being bundled and avoids duplication in consuming applications.
10
+
11
+ Changes:
12
+
13
+ - Updated `tsup.config.ts` to externalize `styled-system`, `styled-components`, and all `@sproutsocial/*` packages
14
+ - Added `styled-system` to `peerDependencies` in `package.json`
15
+
16
+ This is a non-breaking change that improves bundle efficiency for all consumers.
17
+
18
+ ## 1.7.4
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [750d1ea]
23
+ - @sproutsocial/seeds-react-theme@3.3.0
24
+ - @sproutsocial/seeds-react-button@1.3.9
25
+ - @sproutsocial/seeds-react-checkbox@1.3.12
26
+ - @sproutsocial/seeds-react-input@1.4.15
27
+ - @sproutsocial/seeds-react-radio@1.3.6
28
+ - @sproutsocial/seeds-react-switch@1.2.12
29
+ - @sproutsocial/seeds-react-token-input@1.4.15
30
+ - @sproutsocial/seeds-react-popout@2.4.15
31
+ - @sproutsocial/seeds-react-box@1.1.8
32
+ - @sproutsocial/seeds-react-icon@2.0.4
33
+ - @sproutsocial/seeds-react-label@1.0.7
34
+
35
+ ## 1.7.3
36
+
37
+ ### Patch Changes
38
+
39
+ - 2fbf014: Alpha of new autocomplete
40
+ - 2fbf014: publish experimental revamped select and autocomplete
41
+
3
42
  ## 1.7.2
4
43
 
5
44
  ### Patch Changes