oneslash-design-system 2.22.0 → 2.23.0

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 (88) hide show
  1. package/README.md +1 -1
  2. package/dist/DESIGN.md +12 -1
  3. package/dist/cases/admin-inbox/split.jsx +22 -10
  4. package/dist/cases/admin-inbox.md +28 -23
  5. package/dist/cases/api-keys.md +1 -1
  6. package/dist/cases/breadcrumb/back-link.d.ts +1 -0
  7. package/dist/cases/breadcrumb/back-link.jsx +23 -0
  8. package/dist/cases/breadcrumb/trail.d.ts +1 -0
  9. package/dist/cases/breadcrumb/trail.jsx +28 -0
  10. package/dist/cases/breadcrumb.md +105 -0
  11. package/dist/cases/date-field/calendar.d.ts +1 -0
  12. package/dist/cases/date-field/calendar.jsx +80 -0
  13. package/dist/cases/date-field/typed.d.ts +1 -0
  14. package/dist/cases/date-field/typed.jsx +58 -0
  15. package/dist/cases/date-field.md +232 -0
  16. package/dist/cases/docs-component-page/reference.jsx +11 -1
  17. package/dist/cases/docs-component-page.md +19 -8
  18. package/dist/cases/file-upload/files.d.ts +1 -0
  19. package/dist/cases/file-upload/files.jsx +118 -0
  20. package/dist/cases/file-upload/picture.d.ts +1 -0
  21. package/dist/cases/file-upload/picture.jsx +50 -0
  22. package/dist/cases/file-upload.md +270 -0
  23. package/dist/cases/filter-menu.md +1 -1
  24. package/dist/cases/image-viewer/with-video.d.ts +1 -0
  25. package/dist/cases/image-viewer/with-video.jsx +42 -0
  26. package/dist/cases/image-viewer.md +72 -4
  27. package/dist/cases/master-detail/split.jsx +17 -10
  28. package/dist/cases/master-detail.md +26 -24
  29. package/dist/cases/message-reactions/picker.d.ts +1 -0
  30. package/dist/cases/message-reactions/picker.jsx +145 -0
  31. package/dist/cases/message-reactions/quick-pick.jsx +1 -1
  32. package/dist/cases/message-reactions.md +184 -3
  33. package/dist/cases/page-header.md +1 -1
  34. package/dist/cases/people-row/names.d.ts +1 -0
  35. package/dist/cases/people-row/names.jsx +20 -0
  36. package/dist/cases/people-row/stack.d.ts +1 -0
  37. package/dist/cases/people-row/stack.jsx +33 -0
  38. package/dist/cases/people-row.md +110 -0
  39. package/dist/cases/profile-form/form.jsx +21 -10
  40. package/dist/cases/profile-form.md +38 -9
  41. package/dist/cases.json +306 -25
  42. package/dist/components/avatarStack.d.ts +22 -0
  43. package/dist/components/avatarStack.jsx +32 -0
  44. package/dist/components/breadcrumb.d.ts +12 -0
  45. package/dist/components/breadcrumb.jsx +24 -0
  46. package/dist/components/calendar.d.ts +19 -0
  47. package/dist/components/calendar.jsx +126 -0
  48. package/dist/components/dateField.d.ts +35 -0
  49. package/dist/components/dateField.jsx +76 -0
  50. package/dist/components/dropZone.d.ts +53 -0
  51. package/dist/components/dropZone.jsx +136 -0
  52. package/dist/components/emojiPicker.d.ts +22 -0
  53. package/dist/components/emojiPicker.jsx +161 -0
  54. package/dist/components/itemList.d.ts +31 -0
  55. package/dist/components/itemList.jsx +81 -0
  56. package/dist/components/lightbox.d.ts +33 -9
  57. package/dist/components/lightbox.jsx +58 -27
  58. package/dist/components/menuItem.d.ts +1 -1
  59. package/dist/components/menuItem.jsx +3 -3
  60. package/dist/internal/date.d.ts +35 -0
  61. package/dist/internal/date.js +122 -0
  62. package/dist/internal/dropZone.d.ts +28 -0
  63. package/dist/internal/dropZone.js +42 -0
  64. package/dist/internal/emoji.d.ts +13 -0
  65. package/dist/internal/emoji.js +182 -0
  66. package/dist/internal/overlayStack.js +1 -1
  67. package/dist/internal/people.d.ts +1 -0
  68. package/dist/internal/people.js +12 -0
  69. package/dist/native-mapping.json +45 -3
  70. package/dist/stories/AvatarStack.stories.d.ts +7 -0
  71. package/dist/stories/AvatarStack.stories.jsx +46 -0
  72. package/dist/stories/Breadcrumb.stories.d.ts +7 -0
  73. package/dist/stories/Breadcrumb.stories.jsx +26 -0
  74. package/dist/stories/Calendar.stories.d.ts +6 -0
  75. package/dist/stories/Calendar.stories.jsx +15 -0
  76. package/dist/stories/Cases.generated.stories.d.ts +10 -0
  77. package/dist/stories/Cases.generated.stories.jsx +20 -0
  78. package/dist/stories/DateField.stories.d.ts +10 -0
  79. package/dist/stories/DateField.stories.jsx +132 -0
  80. package/dist/stories/DropZone.stories.d.ts +12 -0
  81. package/dist/stories/DropZone.stories.jsx +151 -0
  82. package/dist/stories/EmojiPicker.stories.d.ts +6 -0
  83. package/dist/stories/EmojiPicker.stories.jsx +92 -0
  84. package/dist/stories/ItemList.stories.d.ts +9 -0
  85. package/dist/stories/ItemList.stories.jsx +86 -0
  86. package/dist/stories/Lightbox.stories.d.ts +4 -0
  87. package/dist/stories/Lightbox.stories.jsx +44 -0
  88. package/package.json +3 -2
@@ -17,6 +17,7 @@ A person changes how they appear and how they sign in: their picture, their name
17
17
  - Show a problem with a field under it, as the rule 'A form error shows next to the problem' says: 'Enter your name.' and 'Use at least 8 characters.'
18
18
  - Disable the field while its request runs, and keep what the person typed when the save fails.
19
19
  - Use `UserImage` with the person's name as `userHandle`, so a person with no picture sees their initial.
20
+ - Follow the case 'File upload' for the picture.
20
21
 
21
22
  ## Don't
22
23
 
@@ -28,7 +29,7 @@ A person changes how they appear and how they sign in: their picture, their name
28
29
 
29
30
  ## Example: Picture, name and password
30
31
 
31
- Uses: `Alert`, `Button`, `Center`, `Cluster`, `Form`, `FormField`, `Heading`, `SettingsSection`, `Stack`, `TextField`, `UserImage`
32
+ Uses: `Button`, `Center`, `Cluster`, `DropZone`, `Form`, `FormField`, `Heading`, `SettingsSection`, `Stack`, `TextField`, `UserImage`, `formatBytes`
32
33
 
33
34
  ```tsx
34
35
  'use client';
@@ -38,8 +39,9 @@ import Form from 'oneslash-design-system/components/form';
38
39
  import FormField from 'oneslash-design-system/components/formField';
39
40
  import TextField from 'oneslash-design-system/components/textField';
40
41
  import Button from 'oneslash-design-system/components/button';
41
- import Alert from 'oneslash-design-system/components/alert';
42
42
  import UserImage from 'oneslash-design-system/components/userImage';
43
+ import DropZone, { type FileRejection } from 'oneslash-design-system/components/dropZone';
44
+ import { formatBytes } from 'oneslash-design-system/components/formatNumber';
43
45
  import SettingsSection from 'oneslash-design-system/components/settingsSection';
44
46
  import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
45
47
 
@@ -47,6 +49,17 @@ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout
47
49
  const chosenPicture =
48
50
  "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' fill='%232f6b4f'/%3E%3Ccircle cx='32' cy='25' r='11' fill='%23fff'/%3E%3Cpath d='M10 64c2-15 11-22 22-22s20 7 22 22z' fill='%23fff'/%3E%3C/svg%3E";
49
51
 
52
+ // 5 MB as formatBytes counts it (base 1024), so the words and the check agree
53
+ const maxPictureBytes = 5 * 1024 * 1024;
54
+
55
+ // The zone reports a reason. The words are this page's, shown under the picture.
56
+ function sayRejected(rejections: FileRejection[]) {
57
+ const reason = rejections[0].reason;
58
+ if (reason === 'type') return 'Choose a JPG, PNG or WebP picture.';
59
+ if (reason === 'size') return `Choose a picture under ${formatBytes(maxPictureBytes)}.`;
60
+ return 'Choose one picture.';
61
+ }
62
+
50
63
  const minPasswordLength = 8;
51
64
  // Stands in for the server's check. In this example every current password is right except this one.
52
65
  const wrongCurrentPassword = 'incorrect';
@@ -157,16 +170,32 @@ export default function ProfileForm() {
157
170
  <Heading level={1} size="h5">Profile</Heading>
158
171
 
159
172
  <SettingsSection title="Picture" description="Shown beside your name in Acme.">
160
- <Cluster gap="large">
161
- <UserImage userHandle={savedName} userImgUrl={picture} size={64} />
162
- <Stack gap="small">
173
+ {/* The error shows under the picture and its Buttons, and is read with the zone. */}
174
+ <FormField id="profile-form-picture" label="New picture" error={pictureError}>
175
+ {(f) => (
163
176
  <Cluster gap="small">
164
- <Button size="small" type="secondary" state={savingPicture === 'remove' ? 'disabled' : 'enabled'} label="Change Picture" loading={savingPicture === 'change'} onClickButton={() => savePicture(chosenPicture, 'change')} />
177
+ <DropZone
178
+ id={f.id}
179
+ size="compact"
180
+ label="Drop a picture here"
181
+ buttonLabel="Change Picture"
182
+ hint={`JPG, PNG or WebP, up to ${formatBytes(maxPictureBytes)}`}
183
+ accept={['image/jpeg', 'image/png', 'image/webp']}
184
+ maxBytes={maxPictureBytes}
185
+ loading={savingPicture === 'change'}
186
+ disabled={savingPicture === 'remove'}
187
+ aria-describedby={f['aria-describedby']}
188
+ aria-invalid={f['aria-invalid']}
189
+ status={pictureError || undefined}
190
+ onFiles={() => savePicture(chosenPicture, 'change')}
191
+ onReject={(rejections) => setPictureError(sayRejected(rejections))}
192
+ >
193
+ <UserImage userHandle={savedName} userImgUrl={picture} size={64} />
194
+ </DropZone>
165
195
  {picture && <Button size="small" type="tertiary" state={savingPicture === 'change' ? 'disabled' : 'enabled'} label="Remove" aria-label="Remove picture" loading={savingPicture === 'remove'} onClickButton={() => savePicture(undefined, 'remove')} />}
166
196
  </Cluster>
167
- {pictureError && <Alert type="error" variant="inline" autoDismiss={false} message={pictureError} />}
168
- </Stack>
169
- </Cluster>
197
+ )}
198
+ </FormField>
170
199
  </SettingsSection>
171
200
 
172
201
  <SettingsSection title="Name" description="How people see you in messages and on tasks.">