@pega/cosmos-react-core 9.0.0-build.6.8 → 9.0.0-build.7.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 (120) hide show
  1. package/lib/components/ComboBox/ComboBox.d.ts.map +1 -1
  2. package/lib/components/ComboBox/ComboBox.js +1 -1
  3. package/lib/components/ComboBox/ComboBox.js.map +1 -1
  4. package/lib/components/Currency/CurrencyInput.d.ts.map +1 -1
  5. package/lib/components/Currency/CurrencyInput.js +1 -1
  6. package/lib/components/Currency/CurrencyInput.js.map +1 -1
  7. package/lib/components/DateTime/Input/DateInput.d.ts.map +1 -1
  8. package/lib/components/DateTime/Input/DateInput.js +1 -1
  9. package/lib/components/DateTime/Input/DateInput.js.map +1 -1
  10. package/lib/components/DateTime/Input/DateTimeInput.d.ts.map +1 -1
  11. package/lib/components/DateTime/Input/DateTimeInput.js +8 -6
  12. package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
  13. package/lib/components/DateTime/Input/MonthInput.d.ts.map +1 -1
  14. package/lib/components/DateTime/Input/MonthInput.js +1 -1
  15. package/lib/components/DateTime/Input/MonthInput.js.map +1 -1
  16. package/lib/components/DateTime/Input/QuarterInput.d.ts.map +1 -1
  17. package/lib/components/DateTime/Input/QuarterInput.js +1 -1
  18. package/lib/components/DateTime/Input/QuarterInput.js.map +1 -1
  19. package/lib/components/DateTime/Input/TimeInput.d.ts.map +1 -1
  20. package/lib/components/DateTime/Input/TimeInput.js +1 -1
  21. package/lib/components/DateTime/Input/TimeInput.js.map +1 -1
  22. package/lib/components/DateTime/Input/WeekInput.d.ts.map +1 -1
  23. package/lib/components/DateTime/Input/WeekInput.js +1 -1
  24. package/lib/components/DateTime/Input/WeekInput.js.map +1 -1
  25. package/lib/components/DateTime/Input/utils.d.ts +2 -2
  26. package/lib/components/DateTime/Input/utils.d.ts.map +1 -1
  27. package/lib/components/DateTime/Input/utils.js +4 -3
  28. package/lib/components/DateTime/Input/utils.js.map +1 -1
  29. package/lib/components/DateTime/Picker/utils.d.ts.map +1 -1
  30. package/lib/components/DateTime/Picker/utils.js +2 -6
  31. package/lib/components/DateTime/Picker/utils.js.map +1 -1
  32. package/lib/components/FieldGroup/FieldGroup.d.ts +5 -0
  33. package/lib/components/FieldGroup/FieldGroup.d.ts.map +1 -1
  34. package/lib/components/FieldGroup/FieldGroup.js +10 -6
  35. package/lib/components/FieldGroup/FieldGroup.js.map +1 -1
  36. package/lib/components/FieldGroup/FieldGroupList.d.ts +17 -2
  37. package/lib/components/FieldGroup/FieldGroupList.d.ts.map +1 -1
  38. package/lib/components/FieldGroup/FieldGroupList.js +200 -50
  39. package/lib/components/FieldGroup/FieldGroupList.js.map +1 -1
  40. package/lib/components/FieldGroup/FieldGroupList.utils.d.ts +33 -0
  41. package/lib/components/FieldGroup/FieldGroupList.utils.d.ts.map +1 -0
  42. package/lib/components/FieldGroup/FieldGroupList.utils.js +74 -0
  43. package/lib/components/FieldGroup/FieldGroupList.utils.js.map +1 -0
  44. package/lib/components/FieldGroup/FieldGroupListContext.d.ts +8 -0
  45. package/lib/components/FieldGroup/FieldGroupListContext.d.ts.map +1 -0
  46. package/lib/components/FieldGroup/FieldGroupListContext.js +9 -0
  47. package/lib/components/FieldGroup/FieldGroupListContext.js.map +1 -0
  48. package/lib/components/FieldGroup/index.d.ts +2 -0
  49. package/lib/components/FieldGroup/index.d.ts.map +1 -1
  50. package/lib/components/FieldGroup/index.js +2 -0
  51. package/lib/components/FieldGroup/index.js.map +1 -1
  52. package/lib/components/FieldValueList/FieldValueList.d.ts.map +1 -1
  53. package/lib/components/FieldValueList/FieldValueList.js +3 -3
  54. package/lib/components/FieldValueList/FieldValueList.js.map +1 -1
  55. package/lib/components/Form/Form.d.ts +2 -0
  56. package/lib/components/Form/Form.d.ts.map +1 -1
  57. package/lib/components/Form/Form.js +2 -2
  58. package/lib/components/Form/Form.js.map +1 -1
  59. package/lib/components/FormField/FormField.d.ts.map +1 -1
  60. package/lib/components/FormField/FormField.js +3 -2
  61. package/lib/components/FormField/FormField.js.map +1 -1
  62. package/lib/components/Icon/streamline-icons/lock-closed.icon.d.ts +5 -0
  63. package/lib/components/Icon/streamline-icons/lock-closed.icon.d.ts.map +1 -0
  64. package/lib/components/Icon/streamline-icons/lock-closed.icon.js +7 -0
  65. package/lib/components/Icon/streamline-icons/lock-closed.icon.js.map +1 -0
  66. package/lib/components/Icon/streamlineIconNames.d.ts +1 -1
  67. package/lib/components/Icon/streamlineIconNames.d.ts.map +1 -1
  68. package/lib/components/Icon/streamlineIconNames.js +1 -0
  69. package/lib/components/Icon/streamlineIconNames.js.map +1 -1
  70. package/lib/components/Lightbox/Lightbox.d.ts +1 -1
  71. package/lib/components/Lightbox/Lightbox.d.ts.map +1 -1
  72. package/lib/components/Lightbox/Lightbox.js +9 -3
  73. package/lib/components/Lightbox/Lightbox.js.map +1 -1
  74. package/lib/components/Lightbox/Lightbox.test-ids.d.ts +1 -1
  75. package/lib/components/Lightbox/Lightbox.test-ids.d.ts.map +1 -1
  76. package/lib/components/Lightbox/Lightbox.test-ids.js +1 -0
  77. package/lib/components/Lightbox/Lightbox.test-ids.js.map +1 -1
  78. package/lib/components/Location/LocationInput.d.ts.map +1 -1
  79. package/lib/components/Location/LocationInput.js +1 -1
  80. package/lib/components/Location/LocationInput.js.map +1 -1
  81. package/lib/components/MetaList/MetaList.d.ts.map +1 -1
  82. package/lib/components/MetaList/MetaList.js +3 -2
  83. package/lib/components/MetaList/MetaList.js.map +1 -1
  84. package/lib/components/MultiStepForm/MultiStepForm.d.ts.map +1 -1
  85. package/lib/components/MultiStepForm/MultiStepForm.js +29 -3
  86. package/lib/components/MultiStepForm/MultiStepForm.js.map +1 -1
  87. package/lib/components/Phone/PhoneInput.d.ts.map +1 -1
  88. package/lib/components/Phone/PhoneInput.js +1 -1
  89. package/lib/components/Phone/PhoneInput.js.map +1 -1
  90. package/lib/components/Popover/Popover.styles.d.ts.map +1 -1
  91. package/lib/components/Popover/Popover.styles.js +2 -2
  92. package/lib/components/Popover/Popover.styles.js.map +1 -1
  93. package/lib/hooks/useAnimatedText.d.ts.map +1 -1
  94. package/lib/hooks/useAnimatedText.js +5 -2
  95. package/lib/hooks/useAnimatedText.js.map +1 -1
  96. package/lib/hooks/useI18n.d.ts +7 -0
  97. package/lib/hooks/useI18n.d.ts.map +1 -1
  98. package/lib/hooks/useItemIntersection.d.ts.map +1 -1
  99. package/lib/hooks/useItemIntersection.js +3 -1
  100. package/lib/hooks/useItemIntersection.js.map +1 -1
  101. package/lib/i18n/default.d.ts +7 -0
  102. package/lib/i18n/default.d.ts.map +1 -1
  103. package/lib/i18n/default.js +9 -1
  104. package/lib/i18n/default.js.map +1 -1
  105. package/lib/i18n/i18n.d.ts +7 -0
  106. package/lib/i18n/i18n.d.ts.map +1 -1
  107. package/lib/theme/theme.d.ts +12 -0
  108. package/lib/theme/theme.d.ts.map +1 -1
  109. package/lib/theme/themeDefinition.json +6 -0
  110. package/lib/theme/themeOverrides.schema.json +9 -0
  111. package/lib/theme/themes/studioDarkTheme.json +7 -4
  112. package/lib/utils/focusNonInteractiveElement.d.ts +9 -0
  113. package/lib/utils/focusNonInteractiveElement.d.ts.map +1 -0
  114. package/lib/utils/focusNonInteractiveElement.js +27 -0
  115. package/lib/utils/focusNonInteractiveElement.js.map +1 -0
  116. package/lib/utils/index.d.ts +1 -0
  117. package/lib/utils/index.d.ts.map +1 -1
  118. package/lib/utils/index.js +1 -0
  119. package/lib/utils/index.js.map +1 -1
  120. package/package.json +4 -2
@@ -1,75 +1,225 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useEffect, useRef } from 'react';
2
+ import { forwardRef, useRef, useLayoutEffect, useContext, useMemo, useState } from 'react';
3
3
  import styled, { css } from 'styled-components';
4
+ import { transparentize } from 'polished';
4
5
  import Button from '../Button';
5
6
  import Icon, { registerIcon } from '../Icon';
6
7
  import * as plusIcon from '../Icon/icons/plus.icon';
7
- import { useI18n } from '../../hooks';
8
+ import { useDirection, useI18n } from '../../hooks';
8
9
  import { defaultThemeProp } from '../../theme';
9
- import { getActiveElement, getFocusables } from '../../utils';
10
- import FieldGroup, { StyledFieldGroup } from './FieldGroup';
10
+ import { getActiveElement, getFocusables, tryCatch } from '../../utils';
11
+ import Flex from '../Flex';
12
+ import EmptyState from '../EmptyState';
13
+ import AdditionalInfo from '../AdditionalInfo';
14
+ import Text from '../Text';
15
+ import { nlpColors, readableHue } from '../../styles';
16
+ import { getIndexDetails } from './FieldGroupList.utils';
17
+ import FieldGroup, { StyledFieldGroup, StyledFieldGroupContent, StyledFieldGroupLegend, StyledGroupContainer, StyledFieldHeader } from './FieldGroup';
18
+ import FieldGroupListContext from './FieldGroupListContext';
11
19
  registerIcon(plusIcon);
12
- const StyledFieldGroupList = styled.div(({ theme }) => css `
13
- margin-block-start: ${theme.base.spacing};
14
-
15
- ${StyledFieldGroup} {
16
- margin-block-start: 0;
17
- }
20
+ const StyledFieldGroupList = styled.ol(() => css `
21
+ list-style: none;
18
22
  `);
19
23
  StyledFieldGroupList.defaultProps = defaultThemeProp;
20
- export const StyledListItem = styled(FieldGroup)(({ theme }) => css `
21
- padding: ${theme.base.spacing} 0 calc(2 * ${theme.base.spacing});
24
+ export const StyledListItem = styled.li(({ theme: { base: { spacing, palette, 'border-radius': borderRadius } }, depth, listGroupIndex, shouldHighlight }) => {
25
+ const bgColor = tryCatch(() => readableHue(nlpColors[listGroupIndex % nlpColors.length], palette['app-background']), () => nlpColors[listGroupIndex % nlpColors.length]);
26
+ return css `
27
+ display: block;
22
28
 
23
- &:not(:last-of-type) {
24
- border-bottom: 0.0625rem solid ${theme.base.palette['border-line']};
25
- margin-block-end: calc(2 * ${theme.base.spacing});
26
- }
29
+ > ${StyledGroupContainer} {
30
+ position: relative;
31
+ padding-inline-end: ${spacing};
27
32
 
28
- legend {
29
- margin-block-end: 0;
30
- }
31
- `);
33
+ &::before {
34
+ content: '';
35
+ position: absolute;
36
+ inset-block-start: 0;
37
+ bottom: 0;
38
+ inset-inline-start: 0;
39
+ width: calc(0.5 * ${spacing});
40
+ background: ${transparentize(0.75, bgColor)};
41
+ }
42
+
43
+ ${depth > 1 &&
44
+ css `
45
+ margin-inline-end: -${spacing};
46
+ `}
47
+
48
+ ${shouldHighlight &&
49
+ css `
50
+ border-start-end-radius: calc(0.5 * ${borderRadius});
51
+ border-end-end-radius: calc(0.5 * ${borderRadius});
52
+ background: ${transparentize(0.95, palette['foreground-color'])};
53
+ `}
54
+ }
55
+
56
+ > ${StyledGroupContainer} > ${StyledFieldGroup} {
57
+ margin-block-start: 0;
58
+ padding: ${spacing} 0;
59
+
60
+ &:not(:last-of-type) {
61
+ border-bottom: 0.0625rem solid ${palette['border-line']};
62
+ margin-block-end: calc(2 * ${spacing});
63
+ }
64
+
65
+ legend {
66
+ margin-block-end: 0;
67
+ }
68
+ }
69
+
70
+ > ${StyledGroupContainer} > ${StyledFieldGroup} > ${StyledFieldGroupContent} {
71
+ padding-inline-start: calc(1.5 * ${spacing});
72
+ }
73
+
74
+ > ${StyledGroupContainer} > ${StyledFieldGroup} > ${StyledFieldGroupLegend} {
75
+ ${StyledFieldHeader} {
76
+ margin-inline-start: calc(0.5 * ${spacing});
77
+ padding-inline: ${spacing};
78
+ height: calc(4 * ${spacing});
79
+ border-start-end-radius: calc(0.5 * ${borderRadius});
80
+ border-end-end-radius: calc(0.5 * ${borderRadius});
81
+ background: ${transparentize(0.75, bgColor)};
82
+ }
83
+ }
84
+ `;
85
+ });
32
86
  StyledListItem.defaultProps = defaultThemeProp;
33
- const StyledAddButton = styled(Button)(({ theme }) => css `
34
- margin-top: ${theme.base.spacing};
87
+ const StyledAddButton = styled(Button)(({ theme: { base: { spacing, 'hit-area': { 'mouse-min': hitAreaMouse } } } }) => css `
88
+ display: inline-flex;
89
+ align-items: center;
90
+ min-height: ${hitAreaMouse};
91
+ min-width: ${hitAreaMouse};
92
+ width: fit-content;
93
+ margin-inline-start: calc(2 * ${spacing});
35
94
  `);
36
95
  StyledAddButton.defaultProps = defaultThemeProp;
37
- const FieldGroupList = forwardRef(function FieldGroupList({ items, onAdd, onDelete, contextualLabel, ...restProps }, ref) {
96
+ const StyledFieldGroupListContainer = styled.div(({ theme: { base: { spacing, palette, 'border-radius': borderRadius } }, hasAdd }) => css `
97
+ position: relative;
98
+ margin-block-start: ${spacing};
99
+
100
+ ${hasAdd &&
101
+ css `
102
+ &::before {
103
+ content: '';
104
+ position: absolute;
105
+ inset-inline-start: 0;
106
+ bottom: calc(1.5 * ${spacing});
107
+ width: calc(1.5 * ${spacing});
108
+ height: calc(2.5 * ${spacing});
109
+ border-end-start-radius: calc(0.5 * ${borderRadius});
110
+ border-inline-start: calc(0.5 * ${spacing}) solid ${palette['border-line']};
111
+ border-bottom: calc(0.5 * ${spacing}) solid ${palette['border-line']};
112
+ }
113
+ `}
114
+ `);
115
+ StyledFieldGroupListContainer.defaultProps = defaultThemeProp;
116
+ const StyledDivider = styled.div(({ theme: { base: { spacing, palette } } }) => css `
117
+ flex: 1;
118
+ height: calc(0.5 * ${spacing});
119
+ background-color: ${palette['border-line']};
120
+ `);
121
+ StyledDivider.defaultProps = defaultThemeProp;
122
+ const ListItem = ({ item, index, isAddFocused, handleDelete, fieldGroupRef }) => {
123
+ const { id, children, name = '', isDynamic, headingTag, ...restItemProps } = item;
124
+ const t = useI18n();
125
+ const { rtl } = useDirection();
126
+ const { depth = 1, ancestorIndices = [], isAncestorHighlighted = false } = useContext(FieldGroupListContext);
127
+ const [isItemFocused, setIsItemFocused] = useState(false);
128
+ const [isDeleteHovered, setIsDeleteHovered] = useState(false);
129
+ const listIndices = [...ancestorIndices, index];
130
+ const { rootIndex, currentIndex, compoundIndex } = getIndexDetails(listIndices);
131
+ const shouldHighlight = !isAncestorHighlighted && (isAddFocused || isDeleteHovered || isItemFocused);
132
+ let formattedName;
133
+ if (isDynamic) {
134
+ formattedName = name;
135
+ }
136
+ else {
137
+ formattedName = rtl ? `${currentIndex}\u200F ${name}` : `${currentIndex} ${name}`;
138
+ }
139
+ const contextualLabel = isDynamic ? name : `${name} ${compoundIndex}`;
140
+ const ctxValue = useMemo(() => ({
141
+ depth: depth + 1,
142
+ isAncestorHighlighted: shouldHighlight || isAncestorHighlighted,
143
+ ancestorIndices: listIndices
144
+ }), [depth, index, shouldHighlight, isAncestorHighlighted, listIndices]);
145
+ return (_jsx(StyledListItem, { depth: depth, listGroupIndex: rootIndex, shouldHighlight: shouldHighlight, onFocus: () => {
146
+ setIsItemFocused(true);
147
+ }, onBlur: () => {
148
+ setIsItemFocused(false);
149
+ }, children: _jsx(FieldGroupListContext.Provider, { value: ctxValue, children: _jsx(FieldGroup, { name: formattedName, contextualLabel: contextualLabel, headingTag: headingTag, ...restItemProps, actions: handleDelete
150
+ ? [
151
+ {
152
+ id: 'delete',
153
+ text: t('delete'),
154
+ icon: 'trash',
155
+ iconOnly: true,
156
+ onClick: () => {
157
+ handleDelete(id);
158
+ },
159
+ onMouseEnter: () => setIsDeleteHovered(true),
160
+ onMouseLeave: () => setIsDeleteHovered(false)
161
+ }
162
+ ]
163
+ : undefined, ref: fieldGroupRef, children: children }) }) }));
164
+ };
165
+ const FieldGroupList = forwardRef(function FieldGroupList({ label, additionalContext, items, onAdd, onDelete, contextualLabel, ...restProps }, ref) {
38
166
  const t = useI18n();
39
- const lastItemRef = useRef(null);
40
167
  const addBtnRef = useRef(null);
41
- useEffect(() => {
168
+ const itemRefs = useRef([]);
169
+ const deletedItemIndexRef = useRef(null);
170
+ const [isAddFocused, setIsAddFocused] = useState(false);
171
+ const focusElement = (itemRef, focusPreference) => {
172
+ if (!itemRef)
173
+ return;
174
+ const focusables = getFocusables(itemRef);
175
+ const groupItemLegend = itemRef.querySelector(':scope > legend');
176
+ const groupActionButtons = focusables.filter(focusable => groupItemLegend?.contains(focusable));
177
+ const groupContentFocusables = focusables.filter(focusable => !groupItemLegend?.contains(focusable));
178
+ if (focusPreference === 'action') {
179
+ (groupActionButtons[0] || groupContentFocusables[0])?.focus();
180
+ }
181
+ else {
182
+ (groupContentFocusables[0] || groupActionButtons[0])?.focus();
183
+ }
184
+ };
185
+ useLayoutEffect(() => {
42
186
  const currentActiveEl = getActiveElement();
43
- if (currentActiveEl === addBtnRef.current && lastItemRef.current) {
44
- const groupItemLegend = lastItemRef.current.querySelector(':scope > legend');
45
- const focusables = getFocusables(lastItemRef.current);
46
- const groupActionButtons = focusables.filter(focusable => groupItemLegend?.contains(focusable));
47
- const groupContentFocusables = focusables.filter(focusable => !groupItemLegend?.contains(focusable));
48
- if (groupContentFocusables.length > 0) {
49
- groupContentFocusables[0].focus();
187
+ if (deletedItemIndexRef.current !== null) {
188
+ const deletedIndex = deletedItemIndexRef.current;
189
+ if (items.length === 0 && addBtnRef.current) {
190
+ addBtnRef.current.focus();
50
191
  }
51
192
  else {
52
- groupActionButtons[0]?.focus();
193
+ const nextIndex = Math.min(deletedIndex, items.length - 1);
194
+ const nextItemRef = itemRefs.current[nextIndex];
195
+ focusElement(nextItemRef, 'action');
53
196
  }
197
+ deletedItemIndexRef.current = null;
198
+ }
199
+ if (currentActiveEl === addBtnRef.current) {
200
+ const lastIndex = items.length - 1;
201
+ const lastItemRef = itemRefs.current[lastIndex];
202
+ focusElement(lastItemRef, 'content');
54
203
  }
55
204
  }, [items.length]);
56
- return (_jsxs(StyledFieldGroupList, { ref: ref, ...restProps, children: [items.map(({ id, children, name, headingTag, onDelete: itemOnDelete, ...restItemProps }, index) => {
57
- const isLastItem = index === items.length - 1;
58
- return (_jsx(StyledListItem, { name: name, headingTag: headingTag, ...restItemProps, actions: onDelete || itemOnDelete
59
- ? [
60
- {
61
- id: 'delete',
62
- text: t('delete'),
63
- icon: 'trash',
64
- iconOnly: true,
65
- onClick: () => {
66
- itemOnDelete?.(id);
67
- onDelete?.(id);
68
- }
69
- }
70
- ]
71
- : undefined, ref: isLastItem ? lastItemRef : undefined, children: children }, id));
72
- }), onAdd && (_jsxs(StyledAddButton, { variant: 'link', onClick: onAdd, ref: addBtnRef, children: [_jsx(Icon, { name: 'plus' }), contextualLabel ? t('add_noun', [contextualLabel]) : t('add')] }))] }));
205
+ return (_jsxs(Flex, { container: { direction: 'column', gap: 1 }, as: StyledFieldGroupListContainer, hasAdd: !!onAdd, onFocus: (e) => {
206
+ e.stopPropagation();
207
+ }, onBlur: (e) => {
208
+ e.stopPropagation();
209
+ }, children: [label && (_jsxs(Flex, { container: { gap: 0.5, alignItems: 'center' }, children: [_jsx(Text, { variant: 'h3', children: label }), additionalContext && (_jsx(AdditionalInfo, { contextualLabel: label, children: additionalContext })), _jsx(StyledDivider, { "aria-hidden": 'true' })] })), items.length === 0 ? (_jsx(EmptyState, {})) : (_jsx(Flex, { container: { direction: 'column', gap: 1 }, as: StyledFieldGroupList, ref: ref, ...restProps, children: items.map((item, index) => {
210
+ const handleDelete = onDelete || item.onDelete
211
+ ? (id) => {
212
+ deletedItemIndexRef.current = index;
213
+ item.onDelete?.(id);
214
+ onDelete?.(id);
215
+ }
216
+ : undefined;
217
+ return (_jsx(ListItem, { item: item, index: index, isAddFocused: isAddFocused, handleDelete: handleDelete, fieldGroupRef: (el) => {
218
+ itemRefs.current[index] = el;
219
+ } }, item.id));
220
+ }) })), onAdd && (_jsxs(StyledAddButton, { variant: 'link', onClick: onAdd, onFocus: () => {
221
+ setIsAddFocused(true);
222
+ }, onBlur: () => setIsAddFocused(false), ref: addBtnRef, children: [_jsx(Icon, { name: 'plus' }), contextualLabel ? t('add_noun', [contextualLabel]) : t('add')] }))] }));
73
223
  });
74
224
  export default FieldGroupList;
75
225
  //# sourceMappingURL=FieldGroupList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FieldGroupList.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroupList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,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,EACF,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,QAAQ,EAAE,YAAY,EACtB,GAAG,aAAa,EACQ,EAC1B,KAAK,EACL,EAAE;gBACF,MAAM,UAAU,GAAG,KAAK,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;gBAC9C,OAAO,CACL,KAAC,cAAc,IAEb,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,KAClB,aAAa,EACjB,OAAO,EACL,QAAQ,IAAI,YAAY;wBACtB,CAAC,CAAC;4BACE;gCACE,EAAE,EAAE,QAAQ;gCACZ,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC;gCACjB,IAAI,EAAE,OAAO;gCACb,QAAQ,EAAE,IAAI;gCACd,OAAO,EAAE,GAAG,EAAE;oCACZ,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC;oCACnB,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;gCACjB,CAAC;6BACF;yBACF;wBACH,CAAC,CAAC,SAAS,EAEf,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,YAExC,QAAQ,IAtBJ,EAAE,CAuBQ,CAClB,CAAC;YACJ,CAAC,CACF,EACA,KAAK,IAAI,CACR,MAAC,eAAe,IAAC,OAAO,EAAC,MAAM,EAAC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,aAC5D,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,EACnB,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAC9C,CACnB,IACoB,CACxB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { forwardRef, useEffect, useRef } from 'react';\nimport type { PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport type { ForwardRefForwardPropsComponent } from '../../types';\nimport Button from '../Button';\nimport Icon, { registerIcon } from '../Icon';\nimport * as plusIcon from '../Icon/icons/plus.icon';\nimport { useI18n } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport { getActiveElement, getFocusables } from '../../utils';\n\nimport FieldGroup, { StyledFieldGroup } from './FieldGroup';\nimport type { FieldGroupProps } from './FieldGroup';\n\nregisterIcon(plusIcon);\n\nexport type FieldGroupListItemProps = FieldGroupProps & {\n /** The ID of the field group list item */\n id: string;\n /** Item level onDelete callback. */\n onDelete?: (id: string) => void;\n};\n\nexport interface FieldGroupListProps {\n items: FieldGroupListItemProps[];\n contextualLabel?: string;\n onAdd?: () => void;\n onDelete?: (id: string) => void;\n ref?: Ref<HTMLDivElement>;\n}\n\nconst StyledFieldGroupList = styled.div(\n ({ theme }) => css`\n margin-block-start: ${theme.base.spacing};\n\n ${StyledFieldGroup} {\n margin-block-start: 0;\n }\n `\n);\n\nStyledFieldGroupList.defaultProps = defaultThemeProp;\n\nexport const StyledListItem = styled(FieldGroup)(\n ({ theme }) => css`\n padding: ${theme.base.spacing} 0 calc(2 * ${theme.base.spacing});\n\n &:not(:last-of-type) {\n border-bottom: 0.0625rem solid ${theme.base.palette['border-line']};\n margin-block-end: calc(2 * ${theme.base.spacing});\n }\n\n legend {\n margin-block-end: 0;\n }\n `\n);\n\nStyledListItem.defaultProps = defaultThemeProp;\n\nconst StyledAddButton = styled(Button)(\n ({ theme }) => css`\n margin-top: ${theme.base.spacing};\n `\n);\n\nStyledAddButton.defaultProps = defaultThemeProp;\n\nconst FieldGroupList: ForwardRefForwardPropsComponent<FieldGroupListProps> = forwardRef(\n function FieldGroupList(\n { items, onAdd, onDelete, contextualLabel, ...restProps }: PropsWithoutRef<FieldGroupListProps>,\n ref: FieldGroupListProps['ref']\n ) {\n const t = useI18n();\n const lastItemRef = useRef<HTMLDivElement>(null);\n const addBtnRef = useRef<HTMLButtonElement>(null);\n\n useEffect(() => {\n const currentActiveEl = getActiveElement();\n if (currentActiveEl === addBtnRef.current && lastItemRef.current) {\n const groupItemLegend = lastItemRef.current.querySelector(':scope > legend');\n const focusables = getFocusables(lastItemRef.current);\n\n const groupActionButtons = focusables.filter(focusable =>\n groupItemLegend?.contains(focusable)\n );\n\n const groupContentFocusables = focusables.filter(\n focusable => !groupItemLegend?.contains(focusable)\n );\n\n if (groupContentFocusables.length > 0) {\n groupContentFocusables[0].focus();\n } else {\n groupActionButtons[0]?.focus();\n }\n }\n }, [items.length]);\n\n return (\n <StyledFieldGroupList ref={ref} {...restProps}>\n {items.map(\n (\n {\n id,\n children,\n name,\n headingTag,\n onDelete: itemOnDelete,\n ...restItemProps\n }: FieldGroupListItemProps,\n index\n ) => {\n const isLastItem = index === items.length - 1;\n return (\n <StyledListItem\n key={id}\n name={name}\n headingTag={headingTag}\n {...restItemProps}\n actions={\n onDelete || itemOnDelete\n ? [\n {\n id: 'delete',\n text: t('delete'),\n icon: 'trash',\n iconOnly: true,\n onClick: () => {\n itemOnDelete?.(id);\n onDelete?.(id);\n }\n }\n ]\n : undefined\n }\n ref={isLastItem ? lastItemRef : undefined}\n >\n {children}\n </StyledListItem>\n );\n }\n )}\n {onAdd && (\n <StyledAddButton variant='link' onClick={onAdd} ref={addBtnRef}>\n <Icon name='plus' />\n {contextualLabel ? t('add_noun', [contextualLabel]) : t('add')}\n </StyledAddButton>\n )}\n </StyledFieldGroupList>\n );\n }\n);\n\nexport default FieldGroupList;\n"]}
1
+ {"version":3,"file":"FieldGroupList.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroupList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE3F,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,OAAO,MAAM,MAAM,WAA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Ref, FocusEvent } from 'react';\nimport styled, { css } from 'styled-components';\nimport { transparentize } from 'polished';\n\nimport type { ForwardRefForwardPropsComponent } from '../../types';\nimport Button from '../Button';\nimport Icon, { registerIcon } from '../Icon';\nimport * as plusIcon from '../Icon/icons/plus.icon';\nimport { useDirection, useI18n } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport { getActiveElement, getFocusables, tryCatch } from '../../utils';\nimport Flex from '../Flex';\nimport EmptyState from '../EmptyState';\nimport AdditionalInfo from '../AdditionalInfo';\nimport Text from '../Text';\nimport { nlpColors, readableHue } from '../../styles';\n\nimport { getIndexDetails } from './FieldGroupList.utils';\nimport FieldGroup, {\n StyledFieldGroup,\n StyledFieldGroupContent,\n StyledFieldGroupLegend,\n StyledGroupContainer,\n StyledFieldHeader\n} from './FieldGroup';\nimport type { FieldGroupProps } from './FieldGroup';\nimport FieldGroupListContext from './FieldGroupListContext';\n\nregisterIcon(plusIcon);\n\nexport type FieldGroupListItemProps = FieldGroupProps & {\n /** The ID of the field group list item */\n id: string;\n /** Item level onDelete callback. */\n onDelete?: (id: string) => void;\n /** Indicates if the item is dynamic. */\n isDynamic?: boolean;\n};\n\nexport interface FieldGroupListProps {\n items: FieldGroupListItemProps[];\n contextualLabel?: string;\n label?: string;\n additionalContext?: string | JSX.Element;\n onAdd?: () => void;\n onDelete?: (id: string) => void;\n ref?: Ref<HTMLOListElement>;\n}\n\nexport interface ListItemProps {\n item: FieldGroupListItemProps;\n index: number;\n isAddFocused: boolean;\n handleDelete: FieldGroupListProps['onDelete'];\n fieldGroupRef: (el: HTMLFieldSetElement | null) => void;\n}\n\nconst StyledFieldGroupList = styled.ol(\n () => css`\n list-style: none;\n `\n);\n\nStyledFieldGroupList.defaultProps = defaultThemeProp;\n\nexport const StyledListItem = styled.li<{\n depth: number;\n listGroupIndex: number;\n shouldHighlight: boolean;\n}>(\n ({\n theme: {\n base: { spacing, palette, 'border-radius': borderRadius }\n },\n depth,\n listGroupIndex,\n shouldHighlight\n }) => {\n const bgColor = tryCatch(\n () => readableHue(nlpColors[listGroupIndex % nlpColors.length], palette['app-background']),\n () => nlpColors[listGroupIndex % nlpColors.length]\n );\n\n return css`\n display: block;\n\n > ${StyledGroupContainer} {\n position: relative;\n padding-inline-end: ${spacing};\n\n &::before {\n content: '';\n position: absolute;\n inset-block-start: 0;\n bottom: 0;\n inset-inline-start: 0;\n width: calc(0.5 * ${spacing});\n background: ${transparentize(0.75, bgColor)};\n }\n\n ${depth > 1 &&\n css`\n margin-inline-end: -${spacing};\n `}\n\n ${shouldHighlight &&\n css`\n border-start-end-radius: calc(0.5 * ${borderRadius});\n border-end-end-radius: calc(0.5 * ${borderRadius});\n background: ${transparentize(0.95, palette['foreground-color'])};\n `}\n }\n\n > ${StyledGroupContainer} > ${StyledFieldGroup} {\n margin-block-start: 0;\n padding: ${spacing} 0;\n\n &:not(:last-of-type) {\n border-bottom: 0.0625rem solid ${palette['border-line']};\n margin-block-end: calc(2 * ${spacing});\n }\n\n legend {\n margin-block-end: 0;\n }\n }\n\n > ${StyledGroupContainer} > ${StyledFieldGroup} > ${StyledFieldGroupContent} {\n padding-inline-start: calc(1.5 * ${spacing});\n }\n\n > ${StyledGroupContainer} > ${StyledFieldGroup} > ${StyledFieldGroupLegend} {\n ${StyledFieldHeader} {\n margin-inline-start: calc(0.5 * ${spacing});\n padding-inline: ${spacing};\n height: calc(4 * ${spacing});\n border-start-end-radius: calc(0.5 * ${borderRadius});\n border-end-end-radius: calc(0.5 * ${borderRadius});\n background: ${transparentize(0.75, bgColor)};\n }\n }\n `;\n }\n);\n\nStyledListItem.defaultProps = defaultThemeProp;\n\nconst StyledAddButton = styled(Button)(\n ({\n theme: {\n base: {\n spacing,\n 'hit-area': { 'mouse-min': hitAreaMouse }\n }\n }\n }) => css`\n display: inline-flex;\n align-items: center;\n min-height: ${hitAreaMouse};\n min-width: ${hitAreaMouse};\n width: fit-content;\n margin-inline-start: calc(2 * ${spacing});\n `\n);\n\nStyledAddButton.defaultProps = defaultThemeProp;\n\nconst StyledFieldGroupListContainer = styled.div<{ hasAdd: boolean }>(\n ({\n theme: {\n base: { spacing, palette, 'border-radius': borderRadius }\n },\n hasAdd\n }) => css`\n position: relative;\n margin-block-start: ${spacing};\n\n ${hasAdd &&\n css`\n &::before {\n content: '';\n position: absolute;\n inset-inline-start: 0;\n bottom: calc(1.5 * ${spacing});\n width: calc(1.5 * ${spacing});\n height: calc(2.5 * ${spacing});\n border-end-start-radius: calc(0.5 * ${borderRadius});\n border-inline-start: calc(0.5 * ${spacing}) solid ${palette['border-line']};\n border-bottom: calc(0.5 * ${spacing}) solid ${palette['border-line']};\n }\n `}\n `\n);\n\nStyledFieldGroupListContainer.defaultProps = defaultThemeProp;\n\nconst StyledDivider = styled.div(\n ({\n theme: {\n base: { spacing, palette }\n }\n }) => css`\n flex: 1;\n height: calc(0.5 * ${spacing});\n background-color: ${palette['border-line']};\n `\n);\n\nStyledDivider.defaultProps = defaultThemeProp;\n\nconst ListItem = ({ item, index, isAddFocused, handleDelete, fieldGroupRef }: ListItemProps) => {\n const { id, children, name = '', isDynamic, headingTag, ...restItemProps } = item;\n\n const t = useI18n();\n const { rtl } = useDirection();\n const {\n depth = 1,\n ancestorIndices = [],\n isAncestorHighlighted = false\n } = useContext(FieldGroupListContext);\n\n const [isItemFocused, setIsItemFocused] = useState(false);\n const [isDeleteHovered, setIsDeleteHovered] = useState(false);\n\n const listIndices = [...ancestorIndices, index];\n const { rootIndex, currentIndex, compoundIndex } = getIndexDetails(listIndices);\n\n const shouldHighlight =\n !isAncestorHighlighted && (isAddFocused || isDeleteHovered || isItemFocused);\n\n let formattedName: string;\n if (isDynamic) {\n formattedName = name;\n } else {\n formattedName = rtl ? `${currentIndex}\\u200F ${name}` : `${currentIndex} ${name}`;\n }\n const contextualLabel = isDynamic ? name : `${name} ${compoundIndex}`;\n\n const ctxValue = useMemo(\n () => ({\n depth: depth + 1,\n isAncestorHighlighted: shouldHighlight || isAncestorHighlighted,\n ancestorIndices: listIndices\n }),\n [depth, index, shouldHighlight, isAncestorHighlighted, listIndices]\n );\n\n return (\n <StyledListItem\n depth={depth}\n listGroupIndex={rootIndex}\n shouldHighlight={shouldHighlight}\n onFocus={() => {\n setIsItemFocused(true);\n }}\n onBlur={() => {\n setIsItemFocused(false);\n }}\n >\n <FieldGroupListContext.Provider value={ctxValue}>\n <FieldGroup\n name={formattedName}\n contextualLabel={contextualLabel}\n headingTag={headingTag}\n {...restItemProps}\n actions={\n handleDelete\n ? [\n {\n id: 'delete',\n text: t('delete'),\n icon: 'trash',\n iconOnly: true,\n onClick: () => {\n handleDelete(id);\n },\n onMouseEnter: () => setIsDeleteHovered(true),\n onMouseLeave: () => setIsDeleteHovered(false)\n }\n ]\n : undefined\n }\n ref={fieldGroupRef}\n >\n {children}\n </FieldGroup>\n </FieldGroupListContext.Provider>\n </StyledListItem>\n );\n};\n\nconst FieldGroupList: ForwardRefForwardPropsComponent<FieldGroupListProps> = forwardRef(\n function FieldGroupList(\n {\n label,\n additionalContext,\n items,\n onAdd,\n onDelete,\n contextualLabel,\n ...restProps\n }: PropsWithoutRef<FieldGroupListProps>,\n ref: FieldGroupListProps['ref']\n ) {\n const t = useI18n();\n\n const addBtnRef = useRef<HTMLButtonElement>(null);\n const itemRefs = useRef<(HTMLFieldSetElement | null)[]>([]);\n const deletedItemIndexRef = useRef<number | null>(null);\n\n const [isAddFocused, setIsAddFocused] = useState(false);\n\n const focusElement = (\n itemRef: HTMLFieldSetElement | null,\n focusPreference: 'action' | 'content'\n ) => {\n if (!itemRef) return;\n\n const focusables = getFocusables(itemRef);\n const groupItemLegend = itemRef.querySelector(':scope > legend');\n\n const groupActionButtons = focusables.filter(focusable =>\n groupItemLegend?.contains(focusable)\n );\n\n const groupContentFocusables = focusables.filter(\n focusable => !groupItemLegend?.contains(focusable)\n );\n\n if (focusPreference === 'action') {\n (groupActionButtons[0] || groupContentFocusables[0])?.focus();\n } else {\n (groupContentFocusables[0] || groupActionButtons[0])?.focus();\n }\n };\n\n useLayoutEffect(() => {\n const currentActiveEl = getActiveElement();\n\n if (deletedItemIndexRef.current !== null) {\n const deletedIndex = deletedItemIndexRef.current;\n\n if (items.length === 0 && addBtnRef.current) {\n addBtnRef.current.focus();\n } else {\n const nextIndex = Math.min(deletedIndex, items.length - 1);\n const nextItemRef = itemRefs.current[nextIndex];\n focusElement(nextItemRef, 'action');\n }\n\n deletedItemIndexRef.current = null;\n }\n\n if (currentActiveEl === addBtnRef.current) {\n const lastIndex = items.length - 1;\n const lastItemRef = itemRefs.current[lastIndex];\n focusElement(lastItemRef, 'content');\n }\n }, [items.length]);\n\n return (\n <Flex\n container={{ direction: 'column', gap: 1 }}\n as={StyledFieldGroupListContainer}\n hasAdd={!!onAdd}\n onFocus={(e: FocusEvent) => {\n e.stopPropagation();\n }}\n onBlur={(e: FocusEvent) => {\n e.stopPropagation();\n }}\n >\n {label && (\n <Flex container={{ gap: 0.5, alignItems: 'center' }}>\n <Text variant='h3'>{label}</Text>\n\n {additionalContext && (\n <AdditionalInfo contextualLabel={label}>{additionalContext}</AdditionalInfo>\n )}\n\n <StyledDivider aria-hidden='true' />\n </Flex>\n )}\n\n {items.length === 0 ? (\n <EmptyState />\n ) : (\n <Flex\n container={{ direction: 'column', gap: 1 }}\n as={StyledFieldGroupList}\n ref={ref}\n {...restProps}\n >\n {items.map((item, index) => {\n const handleDelete =\n onDelete || item.onDelete\n ? (id: string) => {\n deletedItemIndexRef.current = index;\n item.onDelete?.(id);\n onDelete?.(id);\n }\n : undefined;\n\n return (\n <ListItem\n key={item.id}\n item={item}\n index={index}\n isAddFocused={isAddFocused}\n handleDelete={handleDelete}\n fieldGroupRef={(el: HTMLFieldSetElement | null) => {\n itemRefs.current[index] = el;\n }}\n />\n );\n })}\n </Flex>\n )}\n\n {onAdd && (\n <StyledAddButton\n variant='link'\n onClick={onAdd}\n onFocus={() => {\n setIsAddFocused(true);\n }}\n onBlur={() => setIsAddFocused(false)}\n ref={addBtnRef}\n >\n <Icon name='plus' />\n {contextualLabel ? t('add_noun', [contextualLabel]) : t('add')}\n </StyledAddButton>\n )}\n </Flex>\n );\n }\n);\n\nexport default FieldGroupList;\n"]}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Converts a number to a Roman numeral.
3
+ * @param num - The number to convert.
4
+ * @returns The Roman numeral representation.
5
+ */
6
+ export declare const convertToRoman: (num: number) => string;
7
+ /**
8
+ * Converts a number to a base-26 alphabetic string (a, b, c... aa, ab, ac...).
9
+ * @param num - The 0-based index to convert.
10
+ * @returns The alphabetic representation.
11
+ */
12
+ export declare const convertToAlphabetic: (num: number) => string;
13
+ /**
14
+ * Generates a list number based on depth and index.
15
+ * @param levelIndex - The index of the item in the list (0-based).
16
+ * @param depth - The depth of the list (0-based).
17
+ * @returns The formatted list number.
18
+ */
19
+ export declare const getFormattedListNumber: (levelIndex: number, depth: number) => string;
20
+ /**
21
+ * Generates a compound index and the current list index based on the depth and index of the current item and its ancestors.
22
+ * @param indices - An array of indices representing the position at each depth (e.g., [0, 1, 2]).
23
+ * @returns An object containing:
24
+ * - `rootIndex`: The zero-based index at the root level (e.g., 0 for "1.", 1 for "2.").
25
+ * - `currentIndex`: The index at the latest depth (e.g., "a." or "i.").
26
+ * - `compoundIndex`: The full compound index (e.g., "1.a.i").
27
+ */
28
+ export declare const getIndexDetails: (indices: number[]) => {
29
+ rootIndex: number;
30
+ currentIndex: string;
31
+ compoundIndex: string;
32
+ };
33
+ //# sourceMappingURL=FieldGroupList.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldGroupList.utils.d.ts","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroupList.utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,WA0BzC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,KAAK,MAAM,WAQ9C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,YAAY,MAAM,EAAE,OAAO,MAAM,WAUvE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,EAAE,KAChB;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAUlE,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Converts a number to a Roman numeral.
3
+ * @param num - The number to convert.
4
+ * @returns The Roman numeral representation.
5
+ */
6
+ export const convertToRoman = (num) => {
7
+ const romanMap = [
8
+ ['m', 1000],
9
+ ['cm', 900],
10
+ ['d', 500],
11
+ ['cd', 400],
12
+ ['c', 100],
13
+ ['xc', 90],
14
+ ['l', 50],
15
+ ['xl', 40],
16
+ ['x', 10],
17
+ ['ix', 9],
18
+ ['v', 5],
19
+ ['iv', 4],
20
+ ['i', 1]
21
+ ];
22
+ let result = '';
23
+ for (const [roman, value] of romanMap) {
24
+ while (num >= value) {
25
+ result += roman;
26
+ num -= value;
27
+ }
28
+ }
29
+ return result;
30
+ };
31
+ /**
32
+ * Converts a number to a base-26 alphabetic string (a, b, c... aa, ab, ac...).
33
+ * @param num - The 0-based index to convert.
34
+ * @returns The alphabetic representation.
35
+ */
36
+ export const convertToAlphabetic = (num) => {
37
+ let result = '';
38
+ while (num >= 0) {
39
+ result = String.fromCharCode((num % 26) + 97) + result;
40
+ num = Math.floor(num / 26) - 1;
41
+ }
42
+ return result;
43
+ };
44
+ /**
45
+ * Generates a list number based on depth and index.
46
+ * @param levelIndex - The index of the item in the list (0-based).
47
+ * @param depth - The depth of the list (0-based).
48
+ * @returns The formatted list number.
49
+ */
50
+ export const getFormattedListNumber = (levelIndex, depth) => {
51
+ if (depth % 3 === 0) {
52
+ return (levelIndex + 1).toString();
53
+ }
54
+ if (depth % 3 === 1) {
55
+ return convertToAlphabetic(levelIndex);
56
+ }
57
+ return convertToRoman(levelIndex + 1);
58
+ };
59
+ /**
60
+ * Generates a compound index and the current list index based on the depth and index of the current item and its ancestors.
61
+ * @param indices - An array of indices representing the position at each depth (e.g., [0, 1, 2]).
62
+ * @returns An object containing:
63
+ * - `rootIndex`: The zero-based index at the root level (e.g., 0 for "1.", 1 for "2.").
64
+ * - `currentIndex`: The index at the latest depth (e.g., "a." or "i.").
65
+ * - `compoundIndex`: The full compound index (e.g., "1.a.i").
66
+ */
67
+ export const getIndexDetails = (indices) => {
68
+ const indexSegments = indices.map((levelIndex, index) => getFormattedListNumber(levelIndex, index));
69
+ const rootIndex = indices[0];
70
+ const currentIndex = `${indexSegments[indexSegments.length - 1]}.`;
71
+ const compoundIndex = indexSegments.join('.');
72
+ return { rootIndex, currentIndex, compoundIndex };
73
+ };
74
+ //# sourceMappingURL=FieldGroupList.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldGroupList.utils.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroupList.utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE,EAAE;IAC5C,MAAM,QAAQ,GAAuB;QACnC,CAAC,GAAG,EAAE,IAAI,CAAC;QACX,CAAC,IAAI,EAAE,GAAG,CAAC;QACX,CAAC,GAAG,EAAE,GAAG,CAAC;QACV,CAAC,IAAI,EAAE,GAAG,CAAC;QACX,CAAC,GAAG,EAAE,GAAG,CAAC;QACV,CAAC,IAAI,EAAE,EAAE,CAAC;QACV,CAAC,GAAG,EAAE,EAAE,CAAC;QACT,CAAC,IAAI,EAAE,EAAE,CAAC;QACV,CAAC,GAAG,EAAE,EAAE,CAAC;QACT,CAAC,IAAI,EAAE,CAAC,CAAC;QACT,CAAC,GAAG,EAAE,CAAC,CAAC;QACR,CAAC,IAAI,EAAE,CAAC,CAAC;QACT,CAAC,GAAG,EAAE,CAAC,CAAC;KACT,CAAC;IAEF,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,M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AK,CAAC,CAC1C,CAAC;IAEF,MAAM,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,YAAY,GAAG,GAAG,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC;IACnE,MAAM,aAAa,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE9C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC;AACpD,CAAC,CAAC","sourcesContent":["/**\n * Converts a number to a Roman numeral.\n * @param num - The number to convert.\n * @returns The Roman numeral representation.\n */\nexport const convertToRoman = (num: number) => {\n const romanMap: [string, number][] = [\n ['m', 1000],\n ['cm', 900],\n ['d', 500],\n ['cd', 400],\n ['c', 100],\n ['xc', 90],\n ['l', 50],\n ['xl', 40],\n ['x', 10],\n ['ix', 9],\n ['v', 5],\n ['iv', 4],\n ['i', 1]\n ];\n\n let result = '';\n for (const [roman, value] of romanMap) {\n while (num >= value) {\n result += roman;\n num -= value;\n }\n }\n\n return result;\n};\n\n/**\n * Converts a number to a base-26 alphabetic string (a, b, c... aa, ab, ac...).\n * @param num - The 0-based index to convert.\n * @returns The alphabetic representation.\n */\nexport const convertToAlphabetic = (num: number) => {\n let result = '';\n while (num >= 0) {\n result = String.fromCharCode((num % 26) + 97) + result;\n num = Math.floor(num / 26) - 1;\n }\n\n return result;\n};\n\n/**\n * Generates a list number based on depth and index.\n * @param levelIndex - The index of the item in the list (0-based).\n * @param depth - The depth of the list (0-based).\n * @returns The formatted list number.\n */\nexport const getFormattedListNumber = (levelIndex: number, depth: number) => {\n if (depth % 3 === 0) {\n return (levelIndex + 1).toString();\n }\n\n if (depth % 3 === 1) {\n return convertToAlphabetic(levelIndex);\n }\n\n return convertToRoman(levelIndex + 1);\n};\n\n/**\n * Generates a compound index and the current list index based on the depth and index of the current item and its ancestors.\n * @param indices - An array of indices representing the position at each depth (e.g., [0, 1, 2]).\n * @returns An object containing:\n * - `rootIndex`: The zero-based index at the root level (e.g., 0 for \"1.\", 1 for \"2.\").\n * - `currentIndex`: The index at the latest depth (e.g., \"a.\" or \"i.\").\n * - `compoundIndex`: The full compound index (e.g., \"1.a.i\").\n */\nexport const getIndexDetails = (\n indices: number[]\n): { rootIndex: number; currentIndex: string; compoundIndex: string } => {\n const indexSegments = indices.map((levelIndex, index) =>\n getFormattedListNumber(levelIndex, index)\n );\n\n const rootIndex = indices[0];\n const currentIndex = `${indexSegments[indexSegments.length - 1]}.`;\n const compoundIndex = indexSegments.join('.');\n\n return { rootIndex, currentIndex, compoundIndex };\n};\n"]}
@@ -0,0 +1,8 @@
1
+ export interface FieldGroupListContextValue {
2
+ depth: number;
3
+ ancestorIndices: number[];
4
+ isAncestorHighlighted: boolean;
5
+ }
6
+ declare const FieldGroupListContext: import("react").Context<FieldGroupListContextValue>;
7
+ export default FieldGroupListContext;
8
+ //# sourceMappingURL=FieldGroupListContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldGroupListContext.d.ts","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroupListContext.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,qBAAqB,EAAE,OAAO,CAAC;CAChC;AAQD,QAAA,MAAM,qBAAqB,qDAA4D,CAAC;AAExF,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { createContext } from 'react';
2
+ const defaultContext = {
3
+ depth: 1,
4
+ ancestorIndices: [],
5
+ isAncestorHighlighted: false
6
+ };
7
+ const FieldGroupListContext = createContext(defaultContext);
8
+ export default FieldGroupListContext;
9
+ //# sourceMappingURL=FieldGroupListContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldGroupListContext.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/FieldGroupListContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAQtC,MAAM,cAAc,GAAG;IACrB,KAAK,EAAE,CAAC;IACR,eAAe,EAAE,EAAE;IACnB,qBAAqB,EAAE,KAAK;CAC7B,CAAC;AAEF,MAAM,qBAAqB,GAAG,aAAa,CAA6B,cAAc,CAAC,CAAC;AAExF,eAAe,qBAAqB,CAAC","sourcesContent":["import { createContext } from 'react';\n\nexport interface FieldGroupListContextValue {\n depth: number;\n ancestorIndices: number[];\n isAncestorHighlighted: boolean;\n}\n\nconst defaultContext = {\n depth: 1,\n ancestorIndices: [],\n isAncestorHighlighted: false\n};\n\nconst FieldGroupListContext = createContext<FieldGroupListContextValue>(defaultContext);\n\nexport default FieldGroupListContext;\n"]}
@@ -2,4 +2,6 @@ export { default, StyledFieldGroup, StyledFieldGroupLegend } from './FieldGroup'
2
2
  export type { FieldGroupProps } from './FieldGroup';
3
3
  export { default as FieldGroupList } from './FieldGroupList';
4
4
  export type { FieldGroupListProps, FieldGroupListItemProps } from './FieldGroupList';
5
+ export { default as FieldGroupListContext } from './FieldGroupListContext';
6
+ export { getIndexDetails } from './FieldGroupList.utils';
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FieldGroup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACjF,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FieldGroup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACjF,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1,3 +1,5 @@
1
1
  export { default, StyledFieldGroup, StyledFieldGroupLegend } from './FieldGroup';
2
2
  export { default as FieldGroupList } from './FieldGroupList';
3
+ export { default as FieldGroupListContext } from './FieldGroupListContext';
4
+ export { getIndexDetails } from './FieldGroupList.utils';
3
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEjF,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["export { default, StyledFieldGroup, StyledFieldGroupLegend } from './FieldGroup';\nexport type { FieldGroupProps } from './FieldGroup';\nexport { default as FieldGroupList } from './FieldGroupList';\nexport type { FieldGroupListProps, FieldGroupListItemProps } from './FieldGroupList';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/FieldGroup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEjF,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["export { default, StyledFieldGroup, StyledFieldGroupLegend } from './FieldGroup';\nexport type { FieldGroupProps } from './FieldGroup';\nexport { default as FieldGroupList } from './FieldGroupList';\nexport type { FieldGroupListProps, FieldGroupListItemProps } from './FieldGroupList';\nexport { default as FieldGroupListContext } from './FieldGroupListContext';\nexport { getIndexDetails } from './FieldGroupList.utils';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FieldValueList.d.ts","sourceRoot":"","sources":["../../../src/components/FieldValueList/FieldValueList.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAO,MAAM,OAAO,CAAC;AAG/D,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,YAAY,EACZ,cAAc,EACd,UAAU,EACX,MAAM,aAAa,CAAC;AAWrB,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,SAAS,CAAC;AAErD,UAAU,sBAAuB,SAAQ,UAAU;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,iBAAiB,CAAC;CAC7B;AAED,MAAM,MAAM,uBAAuB,GAC/B,CAAC,sBAAsB,GAAG;IACxB,KAAK,CAAC,EAAE,aAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC3C,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,CAAC,GACF,CAAC,sBAAsB,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC,CAAC;AAEP,MAAM,WAAW,mBAAoB,SAAQ,SAAS,EAAE,cAAc,EAAE,UAAU;IAChF,qDAAqD;IACrD,MAAM,EAAE,uBAAuB,EAAE,CAAC;IAClC;;;OAGG;IACH,OAAO,CAAC,EAAE,iBAAiB,GAAG,kBAAkB,CAAC;CAClD;AAED,eAAO,MAAM,eAAe,wGAE3B,CAAC;AAEF,eAAO,M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AAEF,eAAO,MAAM,gBAAgB,wGAE5B,CAAC;AAEF,eAAO,MAAM,uBAAuB,yGAAe,CAAC;AAEpD,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC;AAE7E,eAAO,MAAM,oBAAoB,+HAsD/B,CAAC;AAIH,eAAO,MAAM,cAAc,gDACsC,uBAAuB;;CA4BvF,CAAC;;;;AA6EF,wBAAqE"}
@@ -86,7 +86,7 @@ const FieldValueList = forwardRef(function FieldValueList({ testId, fields, vari
86
86
  : 'minmax(0, 1fr)',
87
87
  colGap: !detached && variant !== 'value-comparison' ? 2 : 0,
88
88
  rowGap: !detached && variant !== 'value-comparison' ? 1 : 0.5
89
- }, as: StyledFieldValueList, variant: isXSContentWidthOrAbove ? variant : 'stacked', children: fields.map(({ id, name, value, truncate = true, variant: fieldVariant }) => {
89
+ }, as: StyledFieldValueList, variant: isXSContentWidthOrAbove ? variant : 'stacked', children: fields.map(({ testId: fieldTestId, id, name, value, truncate = true, variant: fieldVariant }) => {
90
90
  const sharedProps = {
91
91
  name,
92
92
  variant: (fieldVariant ?? variant) === 'stacked' || !isXSContentWidthOrAbove
@@ -94,9 +94,9 @@ const FieldValueList = forwardRef(function FieldValueList({ testId, fields, vari
94
94
  : 'inline'
95
95
  };
96
96
  if (typeof value === 'string') {
97
- return (_jsx(FieldValueItem, { ...sharedProps, value: value, truncate: truncate }, id ?? name));
97
+ return (_jsx(FieldValueItem, { testId: fieldTestId, ...sharedProps, value: value, truncate: truncate }, id ?? name));
98
98
  }
99
- return _jsx(FieldValueItem, { ...sharedProps, value: value }, id ?? name);
99
+ return (_jsx(FieldValueItem, { testId: fieldTestId, ...sharedProps, value: value }, id ?? name));
100
100
  }) }));
101
101
  });
102
102
  export default withTestIds(FieldValueList, getFieldValueListTestIds);
@@ -1 +1 @@
1
- {"version":3,"file":"FieldValueList.js","sourceRoot":"","sources":["../../../src/components/FieldValueList/FieldValueList.tsx"],"names":[],"mapp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,YAAY,EAAE,EAAE,EAAE;YAC1E,MAAM,WAAW,GAA2B;gBAC1C,IAAI;gBACJ,OAAO,EACL,CAAC,YAAY,IAAI,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,uBAAuB;oBACjE,CAAC,CAAC,SAAS;oBACX,CAAC,CAAC,QAAQ;aACf,CAAC;YAEF,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,OAAO,CACL,KAAC,cAAc,OAAsB,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,IAA7D,EAAE,IAAI,IAAI,CAAuD,CACvF,CAAC;YACJ,CAAC;YAED,OAAO,KAAC,cAAc,OAAsB,WAAW,EAAE,KAAK,EAAE,KAAK,IAAzC,EAAE,IAAI,IAAI,CAAmC,CAAC;QAC5E,CAAC,CAAC,GACG,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC,cAAc,EAAE,wBAAwB,CAAC,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { ReactNode, FunctionComponent, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport type {\n BaseProps,\n ExcludeStrict,\n ForwardProps,\n NoChildrenProp,\n TestIdProp\n} from '../../types';\nimport Grid from '../Grid';\nimport { StyledLabel } from '../Label';\nimport { useBreakpoint, useConsolidatedRef, useTestIds, useTheme } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport ShowMoreLess from '../ShowMoreLess';\nimport { withTestIds } from '../../utils';\nimport NoValue from '../NoValue/NoValue';\n\nimport { getFieldValueListTestIds, getFieldValueItemTestIds } from './FieldValueList.test-ids';\n\nexport type FieldValueVariant = 'inline' | 'stacked';\n\ninterface BaseFieldValueListItem extends TestIdProp {\n name: string;\n id?: string;\n variant?: FieldValueVariant;\n}\n\nexport type FieldValueListItemProps =\n | (BaseFieldValueListItem & {\n value?: ExcludeStrict<ReactNode, 'string'>;\n truncate?: never;\n })\n | (BaseFieldValueListItem & {\n value: string;\n truncate?: boolean;\n });\n\nexport interface FieldValueListProps extends BaseProps, NoChildrenProp, TestIdProp {\n /** The set of field values to render in the list. */\n fields: FieldValueListItemProps[];\n /**\n * Determines if the field and values should be displayed on the same line, or stacked with the field above the value.\n * @default 'inline'\n */\n variant?: FieldValueVariant | 'value-comparison';\n}\n\nexport const StyledFieldName = styled.dt`\n word-break: break-word;\n`;\n\nexport const StyledFieldValue = styled.dd`\n word-break: break-word;\n`;\n\nexport const StyledStackedFieldValue = styled.div``;\n\nexport type StyledFieldValueListProps = Pick<FieldValueListProps, 'variant'>;\n\nexport const StyledFieldValueList = styled.dl<StyledFieldValueListProps>(({ variant, theme }) => {\n const {\n components: {\n 'field-value-list': {\n inline: { detached }\n }\n }\n } = theme;\n return css`\n width: 100%;\n\n ${variant === 'value-comparison' &&\n css`\n dt {\n width: 100%;\n }\n && dd {\n text-align: end;\n padding-inline-start: calc(2 * ${theme.base.spacing});\n\n /* Unset negative margin from Details to prevent field value misalignment */\n margin: unset;\n }\n ${StyledLabel} {\n max-width: unset;\n }\n dd:not(:last-of-type),\n dt:not(:last-of-type) {\n border-bottom: 0.0625rem solid ${theme.base.palette['border-line']};\n padding-bottom: calc(0.5 * ${theme.base.spacing});\n }\n `}\n\n ${detached &&\n variant === 'inline' &&\n css`\n dt {\n width: 100%;\n padding-inline-end: calc(${theme.base.spacing});\n }\n ${StyledLabel} {\n max-width: unset;\n }\n dd:not(:last-of-type),\n dt:not(:last-of-type),\n dd:has(+ ${StyledStackedFieldValue}),\n dt:has(+ dd + ${StyledStackedFieldValue}),\n ${StyledStackedFieldValue}:has(+ dt + dd),\n ${StyledStackedFieldValue}:not(:last-of-type) {\n border-bottom: 0.0625rem dashed ${theme.base.palette['border-line']};\n padding-bottom: calc(0.5 * ${theme.base.spacing});\n }\n `}\n `;\n});\n\nStyledFieldValueList.defaultProps = defaultThemeProp;\n\nexport const FieldValueItem = withTestIds(\n ({ testId, name, value, variant = 'inline', truncate = true }: FieldValueListItemProps) => {\n const testIds = useTestIds(testId, getFieldValueItemTestIds);\n\n const displayValue =\n typeof value === 'string' && truncate ? (\n <ShowMoreLess lines={3}>{value}</ShowMoreLess>\n ) : (\n value\n );\n\n const labelAndValue = (\n <>\n <StyledLabel data-testid={testIds.name} as={StyledFieldName}>\n {name}\n </StyledLabel>\n <StyledFieldValue data-testid={testIds.value}>\n {value ? displayValue : <NoValue />}\n </StyledFieldValue>\n </>\n );\n\n return variant === 'stacked' ? (\n <StyledStackedFieldValue data-testid={testIds.root}>{labelAndValue}</StyledStackedFieldValue>\n ) : (\n <>{labelAndValue}</>\n );\n },\n getFieldValueItemTestIds\n);\n\nconst FieldValueList: FunctionComponent<FieldValueListProps & ForwardProps> = forwardRef(\n function FieldValueList(\n { testId, fields, variant = 'inline', ...restProps }: FieldValueListProps,\n ref: Ref<HTMLDivElement>\n ) {\n const testIds = useTestIds(testId, getFieldValueListTestIds);\n\n const fieldValueListRef = useConsolidatedRef<HTMLDivElement>(ref);\n\n const isXSContentWidthOrAbove = useBreakpoint('xs', {\n breakpointRef: fieldValueListRef,\n themeProp: 'content-width'\n });\n\n const {\n components: {\n 'field-value-list': {\n inline: { detached }\n }\n }\n } = useTheme();\n\n return (\n <Grid\n data-testid={testIds.root}\n {...restProps}\n ref={fieldValueListRef}\n container={{\n cols:\n ['inline', 'value-comparison'].includes(variant) && isXSContentWidthOrAbove\n ? '16ch minmax(0, 1fr)'\n : 'minmax(0, 1fr)',\n colGap: !detached && variant !== 'value-comparison' ? 2 : 0,\n rowGap: !detached && variant !== 'value-comparison' ? 1 : 0.5\n }}\n as={StyledFieldValueList}\n variant={isXSContentWidthOrAbove ? variant : 'stacked'}\n >\n {fields.map(({ id, name, value, truncate = true, variant: fieldVariant }) => {\n const sharedProps: BaseFieldValueListItem = {\n name,\n variant:\n (fieldVariant ?? variant) === 'stacked' || !isXSContentWidthOrAbove\n ? 'stacked'\n : 'inline'\n };\n\n if (typeof value === 'string') {\n return (\n <FieldValueItem key={id ?? name} {...sharedProps} value={value} truncate={truncate} />\n );\n }\n\n return <FieldValueItem key={id ?? name} {...sharedProps} value={value} />;\n })}\n </Grid>\n );\n }\n);\n\nexport default withTestIds(FieldValueList, getFieldValueListTestIds);\n"]}
1
+ {"version":3,"file":"FieldValueList.js","sourceRoot":"","sources":["../../../src/components/FieldValueList/FieldValueList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAShD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,OAAO,MAAM,oBAAoB,CAAC;AAEzC,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AA8B/F,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,EAAE,CAAA;;CAEvC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,EAAE,CAAA;;CAExC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAIpD,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,EAAE,CAA4B,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE;IAC9F,MAAM,EACJ,UAAU,EAAE,EACV,kBAAkB,EAAE,EAClB,MAAM,EAAE,EAAE,QAAQ,EAAE,EACrB,EACF,EACF,GAAG,KAAK,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CAAC,CAAC,GAAG;SAC9D,EACD,EAAE,EAAE,oBAAoB,EACxB,OAAO,EAAE,uBAAuB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,YAErD,MAAM,CAAC,GAAG,CACT,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE;YACnF,MAAM,WAAW,GAA2B;gBAC1C,IAAI;gBACJ,OAAO,EACL,CAAC,YAAY,IAAI,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,uBAAuB;oBACjE,CAAC,CAAC,SAAS;oBACX,CAAC,CAAC,QAAQ;aACf,CAAC;YAEF,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,OAAO,CACL,KAAC,cAAc,IACb,MAAM,EAAE,WAAW,KAEf,WAAW,EACf,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,IAHb,EAAE,IAAI,IAAI,CAIf,CACH,CAAC;YACJ,CAAC;YAED,OAAO,CACL,KAAC,cAAc,IACb,MAAM,EAAE,WAAW,KAEf,WAAW,EACf,KAAK,EAAE,KAAK,IAFP,EAAE,IAAI,IAAI,CAGf,CACH,CAAC;QACJ,CAAC,CACF,GACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC,cAAc,EAAE,wBAAwB,CAAC,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { ReactNode, FunctionComponent, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport type {\n BaseProps,\n ExcludeStrict,\n ForwardProps,\n NoChildrenProp,\n TestIdProp\n} from '../../types';\nimport Grid from '../Grid';\nimport { StyledLabel } from '../Label';\nimport { useBreakpoint, useConsolidatedRef, useTestIds, useTheme } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport ShowMoreLess from '../ShowMoreLess';\nimport { withTestIds } from '../../utils';\nimport NoValue from '../NoValue/NoValue';\n\nimport { getFieldValueListTestIds, getFieldValueItemTestIds } from './FieldValueList.test-ids';\n\nexport type FieldValueVariant = 'inline' | 'stacked';\n\ninterface BaseFieldValueListItem extends TestIdProp {\n name: string;\n id?: string;\n variant?: FieldValueVariant;\n}\n\nexport type FieldValueListItemProps =\n | (BaseFieldValueListItem & {\n value?: ExcludeStrict<ReactNode, 'string'>;\n truncate?: never;\n })\n | (BaseFieldValueListItem & {\n value: string;\n truncate?: boolean;\n });\n\nexport interface FieldValueListProps extends BaseProps, NoChildrenProp, TestIdProp {\n /** The set of field values to render in the list. */\n fields: FieldValueListItemProps[];\n /**\n * Determines if the field and values should be displayed on the same line, or stacked with the field above the value.\n * @default 'inline'\n */\n variant?: FieldValueVariant | 'value-comparison';\n}\n\nexport const StyledFieldName = styled.dt`\n word-break: break-word;\n`;\n\nexport const StyledFieldValue = styled.dd`\n word-break: break-word;\n`;\n\nexport const StyledStackedFieldValue = styled.div``;\n\nexport type StyledFieldValueListProps = Pick<FieldValueListProps, 'variant'>;\n\nexport const StyledFieldValueList = styled.dl<StyledFieldValueListProps>(({ variant, theme }) => {\n const {\n components: {\n 'field-value-list': {\n inline: { detached }\n }\n }\n } = theme;\n return css`\n width: 100%;\n\n ${variant === 'value-comparison' &&\n css`\n dt {\n width: 100%;\n }\n && dd {\n text-align: end;\n padding-inline-start: calc(2 * ${theme.base.spacing});\n\n /* Unset negative margin from Details to prevent field value misalignment */\n margin: unset;\n }\n ${StyledLabel} {\n max-width: unset;\n }\n dd:not(:last-of-type),\n dt:not(:last-of-type) {\n border-bottom: 0.0625rem solid ${theme.base.palette['border-line']};\n padding-bottom: calc(0.5 * ${theme.base.spacing});\n }\n `}\n\n ${detached &&\n variant === 'inline' &&\n css`\n dt {\n width: 100%;\n padding-inline-end: calc(${theme.base.spacing});\n }\n ${StyledLabel} {\n max-width: unset;\n }\n dd:not(:last-of-type),\n dt:not(:last-of-type),\n dd:has(+ ${StyledStackedFieldValue}),\n dt:has(+ dd + ${StyledStackedFieldValue}),\n ${StyledStackedFieldValue}:has(+ dt + dd),\n ${StyledStackedFieldValue}:not(:last-of-type) {\n border-bottom: 0.0625rem dashed ${theme.base.palette['border-line']};\n padding-bottom: calc(0.5 * ${theme.base.spacing});\n }\n `}\n `;\n});\n\nStyledFieldValueList.defaultProps = defaultThemeProp;\n\nexport const FieldValueItem = withTestIds(\n ({ testId, name, value, variant = 'inline', truncate = true }: FieldValueListItemProps) => {\n const testIds = useTestIds(testId, getFieldValueItemTestIds);\n\n const displayValue =\n typeof value === 'string' && truncate ? (\n <ShowMoreLess lines={3}>{value}</ShowMoreLess>\n ) : (\n value\n );\n\n const labelAndValue = (\n <>\n <StyledLabel data-testid={testIds.name} as={StyledFieldName}>\n {name}\n </StyledLabel>\n <StyledFieldValue data-testid={testIds.value}>\n {value ? displayValue : <NoValue />}\n </StyledFieldValue>\n </>\n );\n\n return variant === 'stacked' ? (\n <StyledStackedFieldValue data-testid={testIds.root}>{labelAndValue}</StyledStackedFieldValue>\n ) : (\n <>{labelAndValue}</>\n );\n },\n getFieldValueItemTestIds\n);\n\nconst FieldValueList: FunctionComponent<FieldValueListProps & ForwardProps> = forwardRef(\n function FieldValueList(\n { testId, fields, variant = 'inline', ...restProps }: FieldValueListProps,\n ref: Ref<HTMLDivElement>\n ) {\n const testIds = useTestIds(testId, getFieldValueListTestIds);\n\n const fieldValueListRef = useConsolidatedRef<HTMLDivElement>(ref);\n\n const isXSContentWidthOrAbove = useBreakpoint('xs', {\n breakpointRef: fieldValueListRef,\n themeProp: 'content-width'\n });\n\n const {\n components: {\n 'field-value-list': {\n inline: { detached }\n }\n }\n } = useTheme();\n\n return (\n <Grid\n data-testid={testIds.root}\n {...restProps}\n ref={fieldValueListRef}\n container={{\n cols:\n ['inline', 'value-comparison'].includes(variant) && isXSContentWidthOrAbove\n ? '16ch minmax(0, 1fr)'\n : 'minmax(0, 1fr)',\n colGap: !detached && variant !== 'value-comparison' ? 2 : 0,\n rowGap: !detached && variant !== 'value-comparison' ? 1 : 0.5\n }}\n as={StyledFieldValueList}\n variant={isXSContentWidthOrAbove ? variant : 'stacked'}\n >\n {fields.map(\n ({ testId: fieldTestId, id, name, value, truncate = true, variant: fieldVariant }) => {\n const sharedProps: BaseFieldValueListItem = {\n name,\n variant:\n (fieldVariant ?? variant) === 'stacked' || !isXSContentWidthOrAbove\n ? 'stacked'\n : 'inline'\n };\n\n if (typeof value === 'string') {\n return (\n <FieldValueItem\n testId={fieldTestId}\n key={id ?? name}\n {...sharedProps}\n value={value}\n truncate={truncate}\n />\n );\n }\n\n return (\n <FieldValueItem\n testId={fieldTestId}\n key={id ?? name}\n {...sharedProps}\n value={value}\n />\n );\n }\n )}\n </Grid>\n );\n }\n);\n\nexport default withTestIds(FieldValueList, getFieldValueListTestIds);\n"]}