@arbor-education/design-system.components 0.5.5 → 0.6.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 (68) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/components/avatarGroup/AvatarGroup.d.ts +32 -0
  3. package/dist/components/avatarGroup/AvatarGroup.d.ts.map +1 -0
  4. package/dist/components/avatarGroup/AvatarGroup.js +37 -0
  5. package/dist/components/avatarGroup/AvatarGroup.js.map +1 -0
  6. package/dist/components/avatarGroup/AvatarGroup.stories.d.ts +14 -0
  7. package/dist/components/avatarGroup/AvatarGroup.stories.d.ts.map +1 -0
  8. package/dist/components/avatarGroup/AvatarGroup.stories.js +91 -0
  9. package/dist/components/avatarGroup/AvatarGroup.stories.js.map +1 -0
  10. package/dist/components/avatarGroup/AvatarGroup.test.d.ts +2 -0
  11. package/dist/components/avatarGroup/AvatarGroup.test.d.ts.map +1 -0
  12. package/dist/components/avatarGroup/AvatarGroup.test.js +155 -0
  13. package/dist/components/avatarGroup/AvatarGroup.test.js.map +1 -0
  14. package/dist/components/avatarGroup/avatarGroupOverflow.d.ts +8 -0
  15. package/dist/components/avatarGroup/avatarGroupOverflow.d.ts.map +1 -0
  16. package/dist/components/avatarGroup/avatarGroupOverflow.js +14 -0
  17. package/dist/components/avatarGroup/avatarGroupOverflow.js.map +1 -0
  18. package/dist/components/avatarGroup/collectAvatarGroupChildren.d.ts +4 -0
  19. package/dist/components/avatarGroup/collectAvatarGroupChildren.d.ts.map +1 -0
  20. package/dist/components/avatarGroup/collectAvatarGroupChildren.js +26 -0
  21. package/dist/components/avatarGroup/collectAvatarGroupChildren.js.map +1 -0
  22. package/dist/components/avatarGroup/useAvatarGroupItems.d.ts +9 -0
  23. package/dist/components/avatarGroup/useAvatarGroupItems.d.ts.map +1 -0
  24. package/dist/components/avatarGroup/useAvatarGroupItems.js +24 -0
  25. package/dist/components/avatarGroup/useAvatarGroupItems.js.map +1 -0
  26. package/dist/components/table/Table.d.ts +1 -0
  27. package/dist/components/table/Table.d.ts.map +1 -1
  28. package/dist/components/table/Table.js +2 -0
  29. package/dist/components/table/Table.js.map +1 -1
  30. package/dist/components/table/Table.stories.d.ts.map +1 -1
  31. package/dist/components/table/Table.stories.js +447 -77
  32. package/dist/components/table/Table.stories.js.map +1 -1
  33. package/dist/components/table/Table.test.js +1 -1
  34. package/dist/components/table/Table.test.js.map +1 -1
  35. package/dist/components/table/TableSettingsDropdown.d.ts.map +1 -0
  36. package/dist/components/table/{pagination/TableSettingsDropdown.js → TableSettingsDropdown.js} +6 -6
  37. package/dist/components/table/TableSettingsDropdown.js.map +1 -0
  38. package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.d.ts +2 -5
  39. package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.d.ts.map +1 -1
  40. package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.js +7 -5
  41. package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.js.map +1 -1
  42. package/dist/index.css +33 -0
  43. package/dist/index.css.map +1 -1
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +1 -0
  47. package/dist/index.js.map +1 -1
  48. package/package.json +1 -1
  49. package/src/components/avatarGroup/AvatarGroup.stories.tsx +218 -0
  50. package/src/components/avatarGroup/AvatarGroup.test.tsx +298 -0
  51. package/src/components/avatarGroup/AvatarGroup.tsx +127 -0
  52. package/src/components/avatarGroup/avatarGroup.scss +31 -0
  53. package/src/components/avatarGroup/avatarGroupOverflow.ts +29 -0
  54. package/src/components/avatarGroup/collectAvatarGroupChildren.ts +30 -0
  55. package/src/components/avatarGroup/useAvatarGroupItems.ts +39 -0
  56. package/src/components/table/Table.stories.tsx +678 -265
  57. package/src/components/table/Table.test.tsx +1 -1
  58. package/src/components/table/Table.tsx +2 -0
  59. package/src/components/table/{pagination/TableSettingsDropdown.tsx → TableSettingsDropdown.tsx} +1 -1
  60. package/src/components/table/cellRenderers/SelectDropdownCellRenderer.tsx +42 -12
  61. package/src/global.scss +1 -1
  62. package/src/index.scss +1 -0
  63. package/src/index.ts +7 -0
  64. package/src/tokens.scss +2 -0
  65. package/tokens/json/Arbor.json +13 -1
  66. package/dist/components/table/pagination/TableSettingsDropdown.d.ts.map +0 -1
  67. package/dist/components/table/pagination/TableSettingsDropdown.js.map +0 -1
  68. /package/dist/components/table/{pagination/TableSettingsDropdown.d.ts → TableSettingsDropdown.d.ts} +0 -0
@@ -0,0 +1,31 @@
1
+ .ds-avatar-group {
2
+ display: flex;
3
+ flex-direction: row;
4
+ align-items: center;
5
+ list-style: none;
6
+ margin: 0;
7
+ padding: 0;
8
+ }
9
+
10
+ .ds-avatar-group__item {
11
+ flex-shrink: 0;
12
+
13
+ &:not(:first-child) {
14
+ margin-inline-start: var(--avatar-group-overlap);
15
+ }
16
+ }
17
+
18
+ .ds-avatar-group__overflow {
19
+ flex-shrink: 0;
20
+ display: flex;
21
+ align-items: center;
22
+ margin-inline-start: var(--avatar-group-overlap);
23
+ }
24
+
25
+ .ds-avatar-group__overflow-count {
26
+ display: inline-flex;
27
+ align-items: center;
28
+ font-size: var(--avatar-group-overflow-count-font-size);
29
+ font-weight: 600;
30
+ margin-inline-start: var(--spacing-small);
31
+ }
@@ -0,0 +1,29 @@
1
+ import type { AvatarGroupNormalizedEntry } from './useAvatarGroupItems';
2
+
3
+ export type AvatarGroupListOrder = 'ascending' | 'descending';
4
+
5
+ export type AvatarGroupOverflowPartition = {
6
+ visibleItems: AvatarGroupNormalizedEntry[];
7
+ overflowCount: number;
8
+ };
9
+
10
+ export function partitionAvatarGroupOverflow(
11
+ items: readonly AvatarGroupNormalizedEntry[],
12
+ showMaxItems: number | undefined,
13
+ listOrder: AvatarGroupListOrder = 'ascending',
14
+ ): AvatarGroupOverflowPartition {
15
+ const total = items.length;
16
+ const maxItems
17
+ = showMaxItems == null || !Number.isFinite(showMaxItems) || showMaxItems < 0
18
+ ? total
19
+ : Math.floor(showMaxItems);
20
+ const visibleCount = Math.min(total, maxItems);
21
+
22
+ const overflowCount = total - visibleCount;
23
+ const startIndex = listOrder === 'ascending' ? 0 : overflowCount;
24
+
25
+ return {
26
+ visibleItems: items.slice(startIndex, startIndex + visibleCount),
27
+ overflowCount,
28
+ };
29
+ }
@@ -0,0 +1,30 @@
1
+ import { Avatar, type AvatarProps } from 'Components/avatar/Avatar';
2
+ import React from 'react';
3
+ import type { AvatarGroupItem } from './useAvatarGroupItems';
4
+
5
+ export function collectAvatarsFromChildren(children: React.ReactNode): AvatarGroupItem[] {
6
+ const out: AvatarGroupItem[] = [];
7
+
8
+ const walk = (node: React.ReactNode) => {
9
+ React.Children.forEach(node, (child) => {
10
+ if (child == null || typeof child === 'boolean') {
11
+ return;
12
+ }
13
+ if (React.isValidElement(child) && child.type === React.Fragment) {
14
+ walk((child.props as { children?: React.ReactNode }).children);
15
+ return;
16
+ }
17
+ if (React.isValidElement<AvatarProps>(child) && child.type === Avatar) {
18
+ out.push(child);
19
+ return;
20
+ }
21
+
22
+ if (React.isValidElement(child) && process.env.NODE_ENV !== 'production') {
23
+ console.warn('AvatarGroup only collects `<Avatar />` children when using the children API.');
24
+ }
25
+ });
26
+ };
27
+
28
+ walk(children);
29
+ return out;
30
+ }
@@ -0,0 +1,39 @@
1
+ import { Avatar, type AvatarProps, type AvatarSize } from 'Components/avatar/Avatar';
2
+ import React from 'react';
3
+
4
+ export type AvatarGroupItem = React.ReactElement<AvatarProps> | AvatarProps;
5
+
6
+ export type AvatarGroupNormalizedEntry = {
7
+ key: string;
8
+ avatarProps: AvatarProps;
9
+ };
10
+
11
+ export function useAvatarGroupItems(
12
+ items: readonly AvatarGroupItem[],
13
+ groupSize: AvatarSize | undefined,
14
+ ): AvatarGroupNormalizedEntry[] {
15
+ return React.useMemo(
16
+ () =>
17
+ items.map((item, index) => {
18
+ if (React.isValidElement<AvatarProps>(item) && item.type === Avatar) {
19
+ return {
20
+ key: item.key != null ? String(item.key) : String(index),
21
+ avatarProps: {
22
+ ...item.props,
23
+ size: groupSize ?? item.props.size,
24
+ },
25
+ };
26
+ }
27
+
28
+ const props = item as AvatarProps;
29
+ return {
30
+ key: String(index),
31
+ avatarProps: {
32
+ ...props,
33
+ size: groupSize ?? props.size,
34
+ },
35
+ };
36
+ }),
37
+ [items, groupSize],
38
+ );
39
+ }