@pega/cosmos-react-core 10.0.0-build.2.9 → 10.0.0-build.3.1

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 (104) hide show
  1. package/lib/components/ClassificationMarking/ClassificationMarking.styles.d.ts.map +1 -1
  2. package/lib/components/ClassificationMarking/ClassificationMarking.styles.js +5 -3
  3. package/lib/components/ClassificationMarking/ClassificationMarking.styles.js.map +1 -1
  4. package/lib/components/ComboBox/ComboBox.d.ts.map +1 -1
  5. package/lib/components/ComboBox/ComboBox.js +1 -1
  6. package/lib/components/ComboBox/ComboBox.js.map +1 -1
  7. package/lib/components/ComboBox/ComboBox.styles.d.ts.map +1 -1
  8. package/lib/components/ComboBox/ComboBox.styles.js +14 -2
  9. package/lib/components/ComboBox/ComboBox.styles.js.map +1 -1
  10. package/lib/components/ComboBox/ComboBox.types.d.ts +2 -0
  11. package/lib/components/ComboBox/ComboBox.types.d.ts.map +1 -1
  12. package/lib/components/ComboBox/ComboBox.types.js.map +1 -1
  13. package/lib/components/ComboBox/ComboBoxInput.d.ts +1 -0
  14. package/lib/components/ComboBox/ComboBoxInput.d.ts.map +1 -1
  15. package/lib/components/ComboBox/ComboBoxInput.js.map +1 -1
  16. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.d.ts.map +1 -1
  17. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js +9 -3
  18. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js.map +1 -1
  19. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.d.ts +2 -0
  20. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.d.ts.map +1 -1
  21. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.js.map +1 -1
  22. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.d.ts.map +1 -1
  23. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js +28 -9
  24. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js.map +1 -1
  25. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.types.d.ts +2 -0
  26. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.types.d.ts.map +1 -1
  27. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.types.js.map +1 -1
  28. package/lib/components/DateTime/Input/DateTime.styles.d.ts.map +1 -1
  29. package/lib/components/DateTime/Input/DateTime.styles.js +1 -2
  30. package/lib/components/DateTime/Input/DateTime.styles.js.map +1 -1
  31. package/lib/components/DateTime/Input/MonthInput.d.ts.map +1 -1
  32. package/lib/components/DateTime/Input/MonthInput.js +2 -1
  33. package/lib/components/DateTime/Input/MonthInput.js.map +1 -1
  34. package/lib/components/DateTime/Input/QuarterInput.d.ts.map +1 -1
  35. package/lib/components/DateTime/Input/QuarterInput.js +2 -2
  36. package/lib/components/DateTime/Input/QuarterInput.js.map +1 -1
  37. package/lib/components/DateTime/Picker/DatePicker.styles.d.ts.map +1 -1
  38. package/lib/components/DateTime/Picker/DatePicker.styles.js +5 -0
  39. package/lib/components/DateTime/Picker/DatePicker.styles.js.map +1 -1
  40. package/lib/components/EmptyState/EmptyState.d.ts +6 -1
  41. package/lib/components/EmptyState/EmptyState.d.ts.map +1 -1
  42. package/lib/components/EmptyState/EmptyState.js +18 -11
  43. package/lib/components/EmptyState/EmptyState.js.map +1 -1
  44. package/lib/components/FieldGroup/FieldGroupList.js +1 -1
  45. package/lib/components/FieldGroup/FieldGroupList.js.map +1 -1
  46. package/lib/components/File/FileVisual.js +1 -1
  47. package/lib/components/File/FileVisual.js.map +1 -1
  48. package/lib/components/Lightbox/Lightbox.styles.d.ts.map +1 -1
  49. package/lib/components/Lightbox/Lightbox.styles.js +1 -0
  50. package/lib/components/Lightbox/Lightbox.styles.js.map +1 -1
  51. package/lib/components/ListToolbar/ListToolbar.d.ts.map +1 -1
  52. package/lib/components/ListToolbar/ListToolbar.js +37 -5
  53. package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
  54. package/lib/components/ListToolbar/ListToolbar.styles.d.ts +64 -62
  55. package/lib/components/ListToolbar/ListToolbar.styles.d.ts.map +1 -1
  56. package/lib/components/ListToolbar/ListToolbar.styles.js +43 -37
  57. package/lib/components/ListToolbar/ListToolbar.styles.js.map +1 -1
  58. package/lib/components/MenuButton/MenuButton.d.ts.map +1 -1
  59. package/lib/components/MenuButton/MenuButton.js +1 -0
  60. package/lib/components/MenuButton/MenuButton.js.map +1 -1
  61. package/lib/components/Number/NumberDisplay.d.ts +5 -0
  62. package/lib/components/Number/NumberDisplay.d.ts.map +1 -1
  63. package/lib/components/Number/NumberDisplay.js +3 -2
  64. package/lib/components/Number/NumberDisplay.js.map +1 -1
  65. package/lib/components/Number/utils.d.ts +3 -1
  66. package/lib/components/Number/utils.d.ts.map +1 -1
  67. package/lib/components/Number/utils.js +10 -8
  68. package/lib/components/Number/utils.js.map +1 -1
  69. package/lib/components/PageTemplates/GridLayout/EditorBackground.js +1 -1
  70. package/lib/components/PageTemplates/GridLayout/EditorBackground.js.map +1 -1
  71. package/lib/components/Preview/PreviewManager.d.ts.map +1 -1
  72. package/lib/components/Preview/PreviewManager.js +10 -1
  73. package/lib/components/Preview/PreviewManager.js.map +1 -1
  74. package/lib/components/Preview/PreviewPanel.d.ts.map +1 -1
  75. package/lib/components/Preview/PreviewPanel.js +7 -2
  76. package/lib/components/Preview/PreviewPanel.js.map +1 -1
  77. package/lib/components/RadioCheckGroup/RadioCheckGroup.d.ts +1 -1
  78. package/lib/components/RadioCheckGroup/RadioCheckGroup.d.ts.map +1 -1
  79. package/lib/components/RadioCheckGroup/RadioCheckGroup.js +44 -23
  80. package/lib/components/RadioCheckGroup/RadioCheckGroup.js.map +1 -1
  81. package/lib/components/ResponsiveActions/ResponsiveActions.d.ts.map +1 -1
  82. package/lib/components/ResponsiveActions/ResponsiveActions.js +1 -0
  83. package/lib/components/ResponsiveActions/ResponsiveActions.js.map +1 -1
  84. package/lib/components/SelectionCard/SelectionCard.styles.js +1 -1
  85. package/lib/components/SelectionCard/SelectionCard.styles.js.map +1 -1
  86. package/lib/hooks/useI18n.d.ts +12 -1
  87. package/lib/hooks/useI18n.d.ts.map +1 -1
  88. package/lib/i18n/default.d.ts +12 -1
  89. package/lib/i18n/default.d.ts.map +1 -1
  90. package/lib/i18n/default.js +15 -3
  91. package/lib/i18n/default.js.map +1 -1
  92. package/lib/i18n/i18n.d.ts +12 -1
  93. package/lib/i18n/i18n.d.ts.map +1 -1
  94. package/lib/theme/index.d.ts +2 -0
  95. package/lib/theme/index.d.ts.map +1 -1
  96. package/lib/theme/index.js +2 -0
  97. package/lib/theme/index.js.map +1 -1
  98. package/lib/theme/theme.d.ts +24 -0
  99. package/lib/theme/theme.d.ts.map +1 -1
  100. package/lib/theme/themeDefinition.json +12 -0
  101. package/lib/theme/themeOverrides.schema.json +18 -0
  102. package/lib/theme/themes/aurigaDarkTheme.json +146 -0
  103. package/lib/theme/themes/aurigaTheme.json +143 -0
  104. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ListToolbar.styles.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.styles.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAYvD,eAAO,MAAM,wBAAwB;;2JAAmB,CAAC;AAGzD,eAAO,MAAM,gBAAgB,6NAK5B,CAAC;AAEF,eAAO,MAAM,kBAAkB;cAA6B,OAAO;YA4BjE,CAAC;AAIH,eAAO,MAAM,iBAAiB;oBAAgC,OAAO;YAsBpE,CAAC;AAIF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;uRAWlC,CAAC;AAIH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;0MAYnC,CAAC;AAIH,eAAO,MAAM,eAAe,kYAK3B,CAAC;AAIF,eAAO,MAAM,aAAa;eACb,OAAO;cACR,OAAO;gBACL,UAAU;YAwDtB,CAAC;AAIH,eAAO,MAAM,eAAe;;;;mBAM1B,CAAC;AAIH,eAAO,MAAM,UAAU,qQAatB,CAAC;AAIF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0MAQjC,CAAC"}
@@ -20,7 +20,6 @@ export const StyledSearchForm = styled.div `
20
20
  }
21
21
  `;
22
22
  export const StyledViewSelector = styled.button(({ theme, required }) => {
23
- const fontSizes = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);
24
23
  const { urgent } = theme.base.palette;
25
24
  const hitAreaMouse = theme.base['hit-area']['mouse-min'];
26
25
  const hitAreaFinger = theme.base['hit-area']['finger-min'];
@@ -31,7 +30,6 @@ export const StyledViewSelector = styled.button(({ theme, required }) => {
31
30
 
32
31
  ${StyledText} {
33
32
  white-space: nowrap;
34
- font-size: ${fontSizes[theme.components.text.h2['font-size']]};
35
33
  line-height: ${hitAreaMouse};
36
34
  word-break: break-word;
37
35
  @media (pointer: coarse) {
@@ -102,52 +100,60 @@ export const StyledErrorIcon = styled(Icon)(({ theme }) => css `
102
100
  margin-inline-end: ${theme.base.spacing};
103
101
  `);
104
102
  StyledErrorIcon.defaultProps = defaultThemeProp;
105
- export const StyledHeading = styled.div(({ theme, required, showName }) => {
103
+ export const StyledHeading = styled.div(({ theme, required, showName, headingTag }) => {
106
104
  const { urgent } = theme.base.palette;
107
105
  const hitAreaCompact = theme.base['hit-area'].compact;
106
+ const fontSizes = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);
107
+ const fontSizeKeys = ['xxs', 'xs', 's', 'm', 'l', 'xl', 'xxl'];
108
+ const headingFontSizeKey = theme.components.text[headingTag]['font-size'];
109
+ const headingFontSize = fontSizes[fontSizeKeys.find(k => k === headingFontSizeKey) ?? 'm'];
108
110
  return css `
109
- min-width: 0;
110
- position: relative;
111
- line-height: ${hitAreaCompact};
112
- word-break: break-word;
113
- display: flex;
114
- align-items: center;
111
+ min-width: 0;
112
+ position: relative;
113
+ line-height: ${hitAreaCompact};
114
+ word-break: break-word;
115
+ display: flex;
116
+ align-items: center;
115
117
 
116
- ${required &&
118
+ ${required &&
117
119
  css `
118
- padding-inline-end: calc(1.5 * ${theme.base.spacing});
119
- `}
120
- &::after {
121
- display: ${required ? 'inline' : 'none'};
122
- content: '\\00a0*';
123
- vertical-align: top;
124
- color: ${urgent};
125
- position: absolute;
126
- inset-inline-end: 0;
127
- inset-block-start: 0;
128
- }
120
+ padding-inline-end: calc(1.5 * ${theme.base.spacing});
121
+ `}
122
+ &::after {
123
+ display: ${required ? 'inline' : 'none'};
124
+ content: '\\00a0*';
125
+ vertical-align: top;
126
+ color: ${urgent};
127
+ position: absolute;
128
+ inset-inline-end: 0;
129
+ inset-block-start: 0;
130
+ }
129
131
 
130
- ${StyledErrorIcon} {
131
- margin-inline-end: calc(0.5 * ${theme.base.spacing});
132
- }
132
+ ${StyledErrorIcon} {
133
+ margin-inline-end: calc(0.5 * ${theme.base.spacing});
134
+ }
133
135
 
134
- ${StyledText} {
135
- line-height: ${hitAreaCompact};
136
- ${ellipsisOverflow};
137
- }
136
+ ${StyledText} {
137
+ line-height: ${hitAreaCompact};
138
+ ${ellipsisOverflow};
139
+ }
138
140
 
139
- ${!required &&
141
+ ${StyledViewSelector} {
142
+ font-size: ${headingFontSize};
143
+ }
144
+
145
+ ${!required &&
140
146
  !showName &&
141
147
  css `
142
- > ${StyledText} {
143
- ${hideVisually}
144
- }
148
+ > ${StyledText} {
149
+ ${hideVisually}
150
+ }
145
151
 
146
- &:not(:has(${StyledViewSelector})) {
147
- margin-inline-end: -${theme.base.spacing};
148
- }
149
- `}
150
- `;
152
+ &:not(:has(${StyledViewSelector})) {
153
+ margin-inline-end: -${theme.base.spacing};
154
+ }
155
+ `}
156
+ `;
151
157
  });
152
158
  StyledHeading.defaultProps = defaultThemeProp;
153
159
  export const StyledCountMeta = styled(StyledCount)(({ theme }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"ListToolbar.styles.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA,EAAE,CAAC;AACzD,wBAAwB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAA;IACtC,iBAAiB;;;;CAIpB,CAAC;AAEF,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AGpB,CACF,CAAC;AAEF,qBAAqB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\nimport { hideVisually } from 'polished';\n\nimport { StyledDialogContent } from '../Dialog/Dialog.styles';\nimport { StyledCount } from '../Badges/Count';\nimport type { FormControlProps } from '../FormControl';\nimport Icon from '../Icon';\nimport Flex from '../Flex';\nimport { StyledSearchInput } from '../SearchInput';\nimport { StyledText } from '../Text';\nimport { defaultThemeProp } from '../../theme';\nimport { calculateFontSize } from '../../styles';\nimport type { FontSize } from '../../styles';\nimport Button, { StyledButton } from '../Button';\nimport FormDialog from '../Dialog/FormDialog';\nimport { ellipsisOverflow } from '../../styles/mixins';\n\nexport const StyledExpandSearchButton = styled(Button)``;\nStyledExpandSearchButton.defaultProps = defaultThemeProp;\n\nexport const StyledSearchForm = styled.div`\n ${StyledSearchInput} {\n flex-grow: 1;\n max-width: min(100%, 40ch);\n }\n`;\n\nexport const StyledViewSelector = styled.button<{ required: boolean }>(({ theme, required }) => {\n const fontSizes = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n const { urgent } = theme.base.palette;\n const hitAreaMouse = theme.base['hit-area']['mouse-min'];\n const hitAreaFinger = theme.base['hit-area']['finger-min'];\n\n return css`\n flex-shrink: initial;\n white-space: initial;\n max-width: 100%;\n\n ${StyledText} {\n white-space: nowrap;\n font-size: ${fontSizes[theme.components.text.h2['font-size'] as FontSize]};\n line-height: ${hitAreaMouse};\n word-break: break-word;\n @media (pointer: coarse) {\n line-height: ${hitAreaFinger};\n }\n }\n\n ${StyledText}::after {\n display: ${required ? 'inline-block' : 'none'};\n content: '\\\\00a0*';\n vertical-align: top;\n color: ${urgent};\n }\n `;\n});\n\nStyledViewSelector.defaultProps = defaultThemeProp;\n\nexport const StyledListToolbar = styled.div<{ isSmallOrAbove: boolean }>(\n ({ theme, isSmallOrAbove }) => {\n return css`\n width: 100%;\n margin-block-end: calc(0.5 * ${theme.base.spacing});\n\n ${isSmallOrAbove &&\n css`\n ${StyledExpandSearchButton} {\n margin-inline-start: calc(0.5 * ${theme.base.spacing});\n }\n\n ${StyledSearchInput} {\n margin-inline-start: ${theme.base.spacing};\n\n input {\n min-width: 20ch;\n }\n }\n `}\n `;\n }\n);\n\nStyledListToolbar.defaultProps = defaultThemeProp;\n\nexport const StyledListToolbarDialog = styled(FormDialog)(({ theme }) => {\n return css`\n min-width: min(${theme.base['content-width'].lg}, calc(100% - 2rem));\n max-width: calc(100vw - 4 * ${theme.base.spacing});\n\n ${StyledDialogContent} {\n @media (height >= 31.25rem) {\n min-height: 2rem;\n }\n }\n `;\n});\n\nStyledListToolbarDialog.defaultProps = defaultThemeProp;\n\nexport const StyledListToolbarContent = styled(Flex)(({ theme }) => {\n return css`\n border-radius: calc(0.25 * ${theme.base['border-radius']});\n\n ${StyledButton} + ${StyledButton} {\n margin-inline-start: 0;\n }\n\n ${StyledButton}:focus {\n z-index: 1;\n }\n `;\n});\n\nStyledListToolbarContent.defaultProps = defaultThemeProp;\n\nexport const StyledErrorIcon = styled(Icon)(\n ({ theme }) => css`\n color: ${theme.base.palette.urgent};\n margin-inline-end: ${theme.base.spacing};\n `\n);\n\nStyledErrorIcon.defaultProps = defaultThemeProp;\n\nexport const StyledHeading = styled.div<{ required?: boolean; showName: boolean }>(\n ({ theme, required, showName }) => {\n const { urgent } = theme.base.palette;\n const hitAreaCompact = theme.base['hit-area'].compact;\n\n return css`\n min-width: 0;\n position: relative;\n line-height: ${hitAreaCompact};\n word-break: break-word;\n display: flex;\n align-items: center;\n\n ${required &&\n css`\n padding-inline-end: calc(1.5 * ${theme.base.spacing});\n `}\n &::after {\n display: ${required ? 'inline' : 'none'};\n content: '\\\\00a0*';\n vertical-align: top;\n color: ${urgent};\n position: absolute;\n inset-inline-end: 0;\n inset-block-start: 0;\n }\n\n ${StyledErrorIcon} {\n margin-inline-end: calc(0.5 * ${theme.base.spacing});\n }\n\n ${StyledText} {\n line-height: ${hitAreaCompact};\n ${ellipsisOverflow};\n }\n\n ${!required &&\n !showName &&\n css`\n > ${StyledText} {\n ${hideVisually}\n }\n\n &:not(:has(${StyledViewSelector})) {\n margin-inline-end: -${theme.base.spacing};\n }\n `}\n `;\n }\n);\n\nStyledHeading.defaultProps = defaultThemeProp;\n\nexport const StyledCountMeta = styled(StyledCount)(({ theme }) => {\n return css`\n white-space: nowrap;\n margin-inline-end: ${theme.base.spacing};\n width: fit-content;\n `;\n});\n\nStyledCountMeta.defaultProps = defaultThemeProp;\n\nexport const StyledInfo = styled.div<Pick<FormControlProps, 'status'>>(\n ({\n status,\n theme: {\n components: { 'form-field': formField }\n }\n }) => css`\n ${status &&\n formField[status] &&\n css`\n color: ${formField[status]['status-color']};\n `}\n `\n);\n\nStyledInfo.defaultProps = defaultThemeProp;\n\nexport const StyledSearchContainer = styled(Flex)(\n ({ theme }) => css`\n margin-block: calc(0.5 * ${theme.base.spacing});\n\n ${StyledSearchInput} {\n max-width: 100%;\n }\n `\n);\n\nStyledSearchContainer.defaultProps = defaultThemeProp;\n"]}
1
+ {"version":3,"file":"ListToolbar.styles.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;A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,EAAE,EAAE;IAC/D,OAAO,GAAG,CAAA;;yBAEa,KAAK,CAAC,IAAI,CAAC,OAAO;;GAExC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEhD,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAClC,CAAC,EACC,MAAM,EACN,KAAK,EAAE,EACL,UAAU,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,EACxC,EACF,EAAE,EAAE,CAAC,GAAG,CAAA;MACL,MAAM;IACR,SAAS,CAAC,MAAM,CAAC;IACjB,GAAG,CAAA;eACQ,SAAS,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC;KAC3C;GACF,CACF,CAAC;AAEF,UAAU,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE3C,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,IAAI,CAAC,CAC/C,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA;+BACW,KAAK,CAAC,IAAI,CAAC,OAAO;;MAE3C,iBAAiB;;;GAGpB,CACF,CAAC;AAEF,qBAAqB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\nimport { hideVisually } from 'polished';\n\nimport { StyledDialogContent } from '../Dialog/Dialog.styles';\nimport { StyledCount } from '../Badges/Count';\nimport type { FormControlProps } from '../FormControl';\nimport Icon from '../Icon';\nimport Flex from '../Flex';\nimport { StyledSearchInput } from '../SearchInput';\nimport { StyledText } from '../Text';\nimport type { HeadingTag } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { calculateFontSize } from '../../styles';\nimport type { FontSize } from '../../styles';\nimport Button, { StyledButton } from '../Button';\nimport FormDialog from '../Dialog/FormDialog';\nimport { ellipsisOverflow } from '../../styles/mixins';\n\nexport const StyledExpandSearchButton = styled(Button)``;\nStyledExpandSearchButton.defaultProps = defaultThemeProp;\n\nexport const StyledSearchForm = styled.div`\n ${StyledSearchInput} {\n flex-grow: 1;\n max-width: min(100%, 40ch);\n }\n`;\n\nexport const StyledViewSelector = styled.button<{ required: boolean }>(({ theme, required }) => {\n const { urgent } = theme.base.palette;\n const hitAreaMouse = theme.base['hit-area']['mouse-min'];\n const hitAreaFinger = theme.base['hit-area']['finger-min'];\n\n return css`\n flex-shrink: initial;\n white-space: initial;\n max-width: 100%;\n\n ${StyledText} {\n white-space: nowrap;\n line-height: ${hitAreaMouse};\n word-break: break-word;\n @media (pointer: coarse) {\n line-height: ${hitAreaFinger};\n }\n }\n\n ${StyledText}::after {\n display: ${required ? 'inline-block' : 'none'};\n content: '\\\\00a0*';\n vertical-align: top;\n color: ${urgent};\n }\n `;\n});\n\nStyledViewSelector.defaultProps = defaultThemeProp;\n\nexport const StyledListToolbar = styled.div<{ isSmallOrAbove: boolean }>(\n ({ theme, isSmallOrAbove }) => {\n return css`\n width: 100%;\n margin-block-end: calc(0.5 * ${theme.base.spacing});\n\n ${isSmallOrAbove &&\n css`\n ${StyledExpandSearchButton} {\n margin-inline-start: calc(0.5 * ${theme.base.spacing});\n }\n\n ${StyledSearchInput} {\n margin-inline-start: ${theme.base.spacing};\n\n input {\n min-width: 20ch;\n }\n }\n `}\n `;\n }\n);\n\nStyledListToolbar.defaultProps = defaultThemeProp;\n\nexport const StyledListToolbarDialog = styled(FormDialog)(({ theme }) => {\n return css`\n min-width: min(${theme.base['content-width'].lg}, calc(100% - 2rem));\n max-width: calc(100vw - 4 * ${theme.base.spacing});\n\n ${StyledDialogContent} {\n @media (height >= 31.25rem) {\n min-height: 2rem;\n }\n }\n `;\n});\n\nStyledListToolbarDialog.defaultProps = defaultThemeProp;\n\nexport const StyledListToolbarContent = styled(Flex)(({ theme }) => {\n return css`\n border-radius: calc(0.25 * ${theme.base['border-radius']});\n\n ${StyledButton} + ${StyledButton} {\n margin-inline-start: 0;\n }\n\n ${StyledButton}:focus {\n z-index: 1;\n }\n `;\n});\n\nStyledListToolbarContent.defaultProps = defaultThemeProp;\n\nexport const StyledErrorIcon = styled(Icon)(\n ({ theme }) => css`\n color: ${theme.base.palette.urgent};\n margin-inline-end: ${theme.base.spacing};\n `\n);\n\nStyledErrorIcon.defaultProps = defaultThemeProp;\n\nexport const StyledHeading = styled.div<{\n required?: boolean;\n showName: boolean;\n headingTag: HeadingTag;\n}>(({ theme, required, showName, headingTag }) => {\n const { urgent } = theme.base.palette;\n const hitAreaCompact = theme.base['hit-area'].compact;\n const fontSizes = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n const fontSizeKeys: FontSize[] = ['xxs', 'xs', 's', 'm', 'l', 'xl', 'xxl'];\n const headingFontSizeKey = theme.components.text[headingTag]['font-size'];\n const headingFontSize = fontSizes[fontSizeKeys.find(k => k === headingFontSizeKey) ?? 'm'];\n\n return css`\n min-width: 0;\n position: relative;\n line-height: ${hitAreaCompact};\n word-break: break-word;\n display: flex;\n align-items: center;\n\n ${required &&\n css`\n padding-inline-end: calc(1.5 * ${theme.base.spacing});\n `}\n &::after {\n display: ${required ? 'inline' : 'none'};\n content: '\\\\00a0*';\n vertical-align: top;\n color: ${urgent};\n position: absolute;\n inset-inline-end: 0;\n inset-block-start: 0;\n }\n\n ${StyledErrorIcon} {\n margin-inline-end: calc(0.5 * ${theme.base.spacing});\n }\n\n ${StyledText} {\n line-height: ${hitAreaCompact};\n ${ellipsisOverflow};\n }\n\n ${StyledViewSelector} {\n font-size: ${headingFontSize};\n }\n\n ${!required &&\n !showName &&\n css`\n > ${StyledText} {\n ${hideVisually}\n }\n\n &:not(:has(${StyledViewSelector})) {\n margin-inline-end: -${theme.base.spacing};\n }\n `}\n `;\n});\n\nStyledHeading.defaultProps = defaultThemeProp;\n\nexport const StyledCountMeta = styled(StyledCount)(({ theme }) => {\n return css`\n white-space: nowrap;\n margin-inline-end: ${theme.base.spacing};\n width: fit-content;\n `;\n});\n\nStyledCountMeta.defaultProps = defaultThemeProp;\n\nexport const StyledInfo = styled.div<Pick<FormControlProps, 'status'>>(\n ({\n status,\n theme: {\n components: { 'form-field': formField }\n }\n }) => css`\n ${status &&\n formField[status] &&\n css`\n color: ${formField[status]['status-color']};\n `}\n `\n);\n\nStyledInfo.defaultProps = defaultThemeProp;\n\nexport const StyledSearchContainer = styled(Flex)(\n ({ theme }) => css`\n margin-block: calc(0.5 * ${theme.base.spacing});\n\n ${StyledSearchInput} {\n max-width: 100%;\n }\n `\n);\n\nStyledSearchContainer.defaultProps = defaultThemeProp;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"MenuButton.d.ts","sourceRoot":"","sources":["../../../src/components/MenuButton/MenuButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,iBAAiB,EAIjB,oBAAoB,EAErB,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EACV,SAAS,EACT,+BAA+B,EAC/B,cAAc,EACd,UAAU,EACV,UAAU,EACX,MAAM,aAAa,CAAC;AAYrB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAKpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAOlD,MAAM,WAAW,eAAgB,SAAQ,SAAS,EAAE,cAAc,EAAE,UAAU;IAC5E,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACjC,+CAA+C;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC/B,qEAAqE;IACrE,KAAK,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IAC/B,4CAA4C;IAC5C,OAAO,CAAC,EAAE,iBAAiB,CAAC;IA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AC/B,qEAAqE;IACrE,KAAK,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IAC/B,4CAA4C;IAC5C,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,0BAA0B;IAC1B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,6BAA6B;IAC7B,OAAO,CAAC,EAAE,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC,CAAC;IACnE,qCAAqC;IACrC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,kCAAkC;IAClC,GAAG,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IACzB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,oBAAoB,CAAC;IACjC,mEAAmE;IACnE,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,gBAAgB,yOAiB5B,CAAC;;;;AAwPF,wBAA6D"}
@@ -157,6 +157,7 @@ const MenuButton = forwardRef(function MenuButton(props, ref) {
157
157
  // When clicking an item (by mouse or keyboard) and the menu is not multi-select, close the menu.
158
158
  if (menu.mode !== 'multi-select') {
159
159
  setIsOpen(false);
160
+ buttonRef.current?.focus();
160
161
  }
161
162
  menu.onItemClick?.(itemId, e);
162
163
  }, focusControlEl: menu.focusControlEl || buttonRef.current || undefined })) })] }));
@@ -1 +1 @@
1
- {"version":3,"file":"MenuButton.js","sourceRoot":"","sources":["../../../src/components/MenuButton/MenuButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAS1D,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAShD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,cAAc,EACd,YAAY,EACZ,UAAU,EACV,SAAS,EACT,UAAU,EACX,MAAM,aAAa,CAAC;A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CAAC,KAAK,CAAC,CAAC;wBACnB,CAAC;wBACD,IAAI,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;oBAChC,CAAC,EACD,cAAc,EAAE,IAAI,CAAC,cAAc,IAAI,SAAS,CAAC,OAAO,IAAI,SAAS,GACrE,CACH,GACuB,IACzB,CACJ,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["import { forwardRef, useState, useCallback } from 'react';\nimport type {\n MouseEventHandler,\n MouseEvent,\n UIEvent,\n PropsWithoutRef,\n KeyboardEventHandler,\n KeyboardEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport type {\n BaseProps,\n ForwardRefForwardPropsComponent,\n NoChildrenProp,\n OmitStrict,\n TestIdProp\n} from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport {\n useConsolidatedRef,\n useUID,\n useFocusWithin,\n useDirection,\n useTestIds,\n useEscape,\n useElement\n} from '../../hooks';\nimport Button, { StyledButton } from '../Button';\nimport type { ButtonProps } from '../Button';\nimport Popover, { StyledPopover } from '../Popover';\nimport type { PopoverProps } from '../Popover';\nimport Menu from '../Menu';\nimport type { MenuProps } from '../Menu/Menu.types';\nimport Icon, { registerIcon, StyledIcon } from '../Icon';\nimport * as arrowMicroDownIcon from '../Icon/icons/arrow-micro-down.icon';\nimport Flex from '../Flex';\nimport { Count } from '../Badges';\nimport type { CountProps } from '../Badges/Count';\nimport { getActiveElement, getFocusables, isInstance, withTestIds } from '../../utils';\n\nimport { getMenuButtonTestIds } from './MenuButton.test-ids';\n\nregisterIcon(arrowMicroDownIcon);\n\nexport interface MenuButtonProps extends BaseProps, NoChildrenProp, TestIdProp {\n /** The text for the MenuButton also used to set the aria-label. */\n text: string;\n /**\n * Determines the Button variant for the MenuButton.\n * @default 'secondary'\n */\n variant?: ButtonProps['variant'];\n /** The name of the icon for the MenuButton. */\n icon?: string;\n /** Only display the icon. The text prop will be forwarded to a tooltip. */\n iconOnly?: ButtonProps['icon'];\n /** The total count representing the list data which was selected. */\n count?: CountProps['children'];\n /** The click handler for the MenuButton. */\n onClick?: MouseEventHandler;\n /** Menu related props. */\n menu?: MenuProps;\n /** Popover related props. */\n popover?: OmitStrict<PopoverProps, 'show' | 'target' | 'children'>;\n /** DOM id for the button element. */\n id?: string;\n /** Ref for the button element. */\n ref?: ButtonProps['ref'];\n /** The keydown handler for the MenuButton. */\n onKeyDown?: KeyboardEventHandler;\n /** Whether to display an arrow when only the icon is displayed. */\n showArrow?: boolean;\n}\n\nexport const StyledMenuButton = styled.button(\n ({\n theme: {\n base: { spacing }\n }\n }) => {\n return css`\n gap: ${spacing};\n flex-shrink: 0;\n white-space: nowrap;\n max-width: 100%;\n\n & + ${StyledPopover} + ${StyledButton} {\n margin-inline-start: ${spacing};\n }\n `;\n }\n);\n\nStyledMenuButton.defaultProps = defaultThemeProp;\n\nconst StyledMenuButtonText = styled.span`\n text-overflow: ellipsis;\n overflow: hidden;\n`;\n\nconst StyledMenuButtonChildren = styled.span<{ padIcon?: boolean }>(({ theme, padIcon }) => {\n const {\n base: {\n 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger }\n },\n components: {\n icon: {\n size: { s: iconSize }\n }\n }\n } = theme;\n\n return css`\n max-width: 100%;\n\n ${padIcon &&\n css`\n padding-inline-start: calc((${hitAreaMouse} - ${iconSize}) / 2);\n\n @media (pointer: coarse) {\n padding-inline-start: calc(${hitAreaFinger} - ${iconSize} * 2);\n }\n `}\n\n ${StyledIcon}:last-child:not(:first-child) {\n /* Offsets the flex gap to make the down arrow appear to trail the text. */\n margin-inline-start: -${theme.base.spacing};\n }\n `;\n});\n\nStyledMenuButtonChildren.defaultProps = defaultThemeProp;\n\nconst StyledMenuButtonPopover = styled(Popover)`\n min-width: 20ch;\n`;\n\nconst MenuButton: ForwardRefForwardPropsComponent<MenuButtonProps> = forwardRef(function MenuButton(\n props: PropsWithoutRef<MenuButtonProps>,\n ref: MenuButtonProps['ref']\n) {\n const uid = useUID();\n const {\n testId,\n id = uid,\n text,\n menu,\n popover,\n onClick,\n icon,\n count,\n iconOnly = false,\n showArrow,\n onKeyDown: onKeyDownProp,\n ...restProps\n } = props;\n const testIds = useTestIds(testId, getMenuButtonTestIds);\n const [isOpen, setIsOpen] = useState(false);\n\n const buttonRef = useConsolidatedRef(ref);\n // Force re-render when popoverRef is set, so useFocusWithin has a non-null ref to read\n const [, forceRerender] = useElement(null);\n const popoverRef = useConsolidatedRef<HTMLDivElement>(popover?.ref, forceRerender);\n const filterInputRef = useConsolidatedRef<HTMLInputElement>(menu?.filterInputProps?.ref);\n const menuRef = useConsolidatedRef<HTMLDivElement>(menu?.ref);\n\n // FIXME: Type assertion required for issue in useFocusWithin generic\n useFocusWithin<HTMLElement>(\n [popoverRef, buttonRef],\n useCallback((isFocused: boolean) => {\n if (!isFocused) setIsOpen(false);\n }, [])\n );\n\n useEscape(e => {\n if (isOpen) {\n setIsOpen(false);\n e.stopPropagation();\n }\n }, buttonRef);\n\n useEscape(e => {\n if (isOpen) {\n setIsOpen(false);\n e.stopPropagation();\n buttonRef.current?.focus();\n }\n }, menu?.focusControlEl);\n\n useEscape(e => {\n if (isOpen) {\n setIsOpen(false);\n e.stopPropagation();\n buttonRef.current?.focus();\n }\n }, filterInputRef);\n\n const { rtl } = useDirection();\n\n const onKeyDown = useCallback(\n (e: KeyboardEvent) => {\n onKeyDownProp?.(e);\n if (e.key !== 'Tab' || !menu) return;\n\n const footerEl = menuRef.current?.querySelector('footer');\n if (!footerEl) return;\n\n const tabbingForward = !e.shiftKey;\n\n if (tabbingForward) {\n const footerFocusables = getFocusables(footerEl);\n\n if (footerFocusables.length > 0) {\n e.preventDefault();\n footerFocusables[0].focus();\n return;\n }\n }\n\n setIsOpen(false);\n },\n [menu]\n );\n\n return (\n <>\n <Button\n data-testid={testIds.root}\n as={StyledMenuButton}\n aria-label={text}\n {...restProps}\n id={id}\n ref={buttonRef}\n aria-expanded={isOpen}\n aria-haspopup='menu'\n aria-controls={isOpen ? `${id}-popover` : undefined}\n label={iconOnly && !isOpen ? text : undefined}\n onClick={(e: MouseEvent<HTMLButtonElement> & UIEvent<HTMLButtonElement>) => {\n // e.detail is 0 when triggered by keyboard.\n const mouseClick = e.detail > 0;\n\n if (isOpen) {\n if (mouseClick) {\n // Close the menu if it is open and it is a *mouse* click on the button.\n setIsOpen(false);\n }\n } else {\n // Open the menu if it's closed, for mouse or keyboard click.\n setIsOpen(true);\n }\n\n // If the menu is closed or the user mouse clicks.\n // This avoids Enter key firing onClick when selecting a menu item.\n if (!isOpen || mouseClick) {\n onClick?.(e);\n }\n }}\n onKeyDown={onKeyDown}\n icon={iconOnly}\n >\n <Flex\n as={StyledMenuButtonChildren}\n container={{ alignItems: 'center', gap: 1 }}\n padIcon={iconOnly && showArrow}\n >\n {icon && <Icon name={icon} />}\n {!iconOnly && (\n <>\n <StyledMenuButtonText>{text}</StyledMenuButtonText>\n {typeof count === 'number' && <Count>{count}</Count>}\n </>\n )}\n {((!iconOnly && showArrow === undefined) || showArrow) && (\n <Icon name='arrow-micro-down' />\n )}\n </Flex>\n </Button>\n\n <StyledMenuButtonPopover\n placement={rtl ? 'bottom-end' : 'bottom-start'}\n hideOnTargetHidden\n {...popover}\n id={`${id}-popover`}\n show={!!menu && isOpen}\n target={buttonRef.current}\n ref={popoverRef}\n onKeyDown={(e: KeyboardEvent) => {\n if (e.key !== 'Tab' || !buttonRef.current) return;\n\n const footerEl = menuRef.current?.querySelector('footer');\n if (!footerEl || !footerEl?.contains(getActiveElement())) return;\n\n const footerFocusables = getFocusables(footerEl);\n\n if (isInstance(e.target, HTMLElement)) {\n const currentIndex = footerFocusables.indexOf(e.target);\n const tabbingForward = !e.shiftKey;\n const isLastFocusable = currentIndex === footerFocusables.length - 1;\n\n if (tabbingForward && isLastFocusable) {\n e.preventDefault();\n const rootNode = buttonRef.current.getRootNode();\n if (!isInstance(rootNode, Document, ShadowRoot)) return;\n\n const allFocusables = getFocusables(rootNode);\n const nextIndex = allFocusables.indexOf(buttonRef.current) + 1;\n\n allFocusables[nextIndex]?.focus();\n setIsOpen(false);\n } else if (!tabbingForward && currentIndex === 0) {\n e.preventDefault();\n buttonRef.current?.focus();\n }\n }\n }}\n >\n {menu && (\n <Menu\n testId={testIds.root}\n {...menu}\n ref={menuRef}\n loading={menu.loading}\n items={menu.items}\n onItemClick={(itemId, e) => {\n // When clicking an item (by mouse or keyboard) and the menu is not multi-select, close the menu.\n if (menu.mode !== 'multi-select') {\n setIsOpen(false);\n }\n menu.onItemClick?.(itemId, e);\n }}\n focusControlEl={menu.focusControlEl || buttonRef.current || undefined}\n />\n )}\n </StyledMenuButtonPopover>\n </>\n );\n});\n\nexport default withTestIds(MenuButton, getMenuButtonTestIds);\n"]}
1
+ {"version":3,"file":"MenuButton.js","sourceRoot":"","sources":["../../../src/components/MenuButton/MenuButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAS1D,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAShD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,cAAc,EACd,YAAY,EACZ,UAAU,EACV,SAAS,EACT,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEjD,OAAO,OAAO,EAAE,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,kBAAkB,MAAM,qCAAqC,CAAC;AAC1E,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B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UAAU,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["import { forwardRef, useState, useCallback } from 'react';\nimport type {\n MouseEventHandler,\n MouseEvent,\n UIEvent,\n PropsWithoutRef,\n KeyboardEventHandler,\n KeyboardEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport type {\n BaseProps,\n ForwardRefForwardPropsComponent,\n NoChildrenProp,\n OmitStrict,\n TestIdProp\n} from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport {\n useConsolidatedRef,\n useUID,\n useFocusWithin,\n useDirection,\n useTestIds,\n useEscape,\n useElement\n} from '../../hooks';\nimport Button, { StyledButton } from '../Button';\nimport type { ButtonProps } from '../Button';\nimport Popover, { StyledPopover } from '../Popover';\nimport type { PopoverProps } from '../Popover';\nimport Menu from '../Menu';\nimport type { MenuProps } from '../Menu/Menu.types';\nimport Icon, { registerIcon, StyledIcon } from '../Icon';\nimport * as arrowMicroDownIcon from '../Icon/icons/arrow-micro-down.icon';\nimport Flex from '../Flex';\nimport { Count } from '../Badges';\nimport type { CountProps } from '../Badges/Count';\nimport { getActiveElement, getFocusables, isInstance, withTestIds } from '../../utils';\n\nimport { getMenuButtonTestIds } from './MenuButton.test-ids';\n\nregisterIcon(arrowMicroDownIcon);\n\nexport interface MenuButtonProps extends BaseProps, NoChildrenProp, TestIdProp {\n /** The text for the MenuButton also used to set the aria-label. */\n text: string;\n /**\n * Determines the Button variant for the MenuButton.\n * @default 'secondary'\n */\n variant?: ButtonProps['variant'];\n /** The name of the icon for the MenuButton. */\n icon?: string;\n /** Only display the icon. The text prop will be forwarded to a tooltip. */\n iconOnly?: ButtonProps['icon'];\n /** The total count representing the list data which was selected. */\n count?: CountProps['children'];\n /** The click handler for the MenuButton. */\n onClick?: MouseEventHandler;\n /** Menu related props. */\n menu?: MenuProps;\n /** Popover related props. */\n popover?: OmitStrict<PopoverProps, 'show' | 'target' | 'children'>;\n /** DOM id for the button element. */\n id?: string;\n /** Ref for the button element. */\n ref?: ButtonProps['ref'];\n /** The keydown handler for the MenuButton. */\n onKeyDown?: KeyboardEventHandler;\n /** Whether to display an arrow when only the icon is displayed. */\n showArrow?: boolean;\n}\n\nexport const StyledMenuButton = styled.button(\n ({\n theme: {\n base: { spacing }\n }\n }) => {\n return css`\n gap: ${spacing};\n flex-shrink: 0;\n white-space: nowrap;\n max-width: 100%;\n\n & + ${StyledPopover} + ${StyledButton} {\n margin-inline-start: ${spacing};\n }\n `;\n }\n);\n\nStyledMenuButton.defaultProps = defaultThemeProp;\n\nconst StyledMenuButtonText = styled.span`\n text-overflow: ellipsis;\n overflow: hidden;\n`;\n\nconst StyledMenuButtonChildren = styled.span<{ padIcon?: boolean }>(({ theme, padIcon }) => {\n const {\n base: {\n 'hit-area': { 'mouse-min': hitAreaMouse, 'finger-min': hitAreaFinger }\n },\n components: {\n icon: {\n size: { s: iconSize }\n }\n }\n } = theme;\n\n return css`\n max-width: 100%;\n\n ${padIcon &&\n css`\n padding-inline-start: calc((${hitAreaMouse} - ${iconSize}) / 2);\n\n @media (pointer: coarse) {\n padding-inline-start: calc(${hitAreaFinger} - ${iconSize} * 2);\n }\n `}\n\n ${StyledIcon}:last-child:not(:first-child) {\n /* Offsets the flex gap to make the down arrow appear to trail the text. */\n margin-inline-start: -${theme.base.spacing};\n }\n `;\n});\n\nStyledMenuButtonChildren.defaultProps = defaultThemeProp;\n\nconst StyledMenuButtonPopover = styled(Popover)`\n min-width: 20ch;\n`;\n\nconst MenuButton: ForwardRefForwardPropsComponent<MenuButtonProps> = forwardRef(function MenuButton(\n props: PropsWithoutRef<MenuButtonProps>,\n ref: MenuButtonProps['ref']\n) {\n const uid = useUID();\n const {\n testId,\n id = uid,\n text,\n menu,\n popover,\n onClick,\n icon,\n count,\n iconOnly = false,\n showArrow,\n onKeyDown: onKeyDownProp,\n ...restProps\n } = props;\n const testIds = useTestIds(testId, getMenuButtonTestIds);\n const [isOpen, setIsOpen] = useState(false);\n\n const buttonRef = useConsolidatedRef(ref);\n // Force re-render when popoverRef is set, so useFocusWithin has a non-null ref to read\n const [, forceRerender] = useElement(null);\n const popoverRef = useConsolidatedRef<HTMLDivElement>(popover?.ref, forceRerender);\n const filterInputRef = useConsolidatedRef<HTMLInputElement>(menu?.filterInputProps?.ref);\n const menuRef = useConsolidatedRef<HTMLDivElement>(menu?.ref);\n\n // FIXME: Type assertion required for issue in useFocusWithin generic\n useFocusWithin<HTMLElement>(\n [popoverRef, buttonRef],\n useCallback((isFocused: boolean) => {\n if (!isFocused) setIsOpen(false);\n }, [])\n );\n\n useEscape(e => {\n if (isOpen) {\n setIsOpen(false);\n e.stopPropagation();\n }\n }, buttonRef);\n\n useEscape(e => {\n if (isOpen) {\n setIsOpen(false);\n e.stopPropagation();\n buttonRef.current?.focus();\n }\n }, menu?.focusControlEl);\n\n useEscape(e => {\n if (isOpen) {\n setIsOpen(false);\n e.stopPropagation();\n buttonRef.current?.focus();\n }\n }, filterInputRef);\n\n const { rtl } = useDirection();\n\n const onKeyDown = useCallback(\n (e: KeyboardEvent) => {\n onKeyDownProp?.(e);\n if (e.key !== 'Tab' || !menu) return;\n\n const footerEl = menuRef.current?.querySelector('footer');\n if (!footerEl) return;\n\n const tabbingForward = !e.shiftKey;\n\n if (tabbingForward) {\n const footerFocusables = getFocusables(footerEl);\n\n if (footerFocusables.length > 0) {\n e.preventDefault();\n footerFocusables[0].focus();\n return;\n }\n }\n\n setIsOpen(false);\n },\n [menu]\n );\n\n return (\n <>\n <Button\n data-testid={testIds.root}\n as={StyledMenuButton}\n aria-label={text}\n {...restProps}\n id={id}\n ref={buttonRef}\n aria-expanded={isOpen}\n aria-haspopup='menu'\n aria-controls={isOpen ? `${id}-popover` : undefined}\n label={iconOnly && !isOpen ? text : undefined}\n onClick={(e: MouseEvent<HTMLButtonElement> & UIEvent<HTMLButtonElement>) => {\n // e.detail is 0 when triggered by keyboard.\n const mouseClick = e.detail > 0;\n\n if (isOpen) {\n if (mouseClick) {\n // Close the menu if it is open and it is a *mouse* click on the button.\n setIsOpen(false);\n }\n } else {\n // Open the menu if it's closed, for mouse or keyboard click.\n setIsOpen(true);\n }\n\n // If the menu is closed or the user mouse clicks.\n // This avoids Enter key firing onClick when selecting a menu item.\n if (!isOpen || mouseClick) {\n onClick?.(e);\n }\n }}\n onKeyDown={onKeyDown}\n icon={iconOnly}\n >\n <Flex\n as={StyledMenuButtonChildren}\n container={{ alignItems: 'center', gap: 1 }}\n padIcon={iconOnly && showArrow}\n >\n {icon && <Icon name={icon} />}\n {!iconOnly && (\n <>\n <StyledMenuButtonText>{text}</StyledMenuButtonText>\n {typeof count === 'number' && <Count>{count}</Count>}\n </>\n )}\n {((!iconOnly && showArrow === undefined) || showArrow) && (\n <Icon name='arrow-micro-down' />\n )}\n </Flex>\n </Button>\n\n <StyledMenuButtonPopover\n placement={rtl ? 'bottom-end' : 'bottom-start'}\n hideOnTargetHidden\n {...popover}\n id={`${id}-popover`}\n show={!!menu && isOpen}\n target={buttonRef.current}\n ref={popoverRef}\n onKeyDown={(e: KeyboardEvent) => {\n if (e.key !== 'Tab' || !buttonRef.current) return;\n\n const footerEl = menuRef.current?.querySelector('footer');\n if (!footerEl || !footerEl?.contains(getActiveElement())) return;\n\n const footerFocusables = getFocusables(footerEl);\n\n if (isInstance(e.target, HTMLElement)) {\n const currentIndex = footerFocusables.indexOf(e.target);\n const tabbingForward = !e.shiftKey;\n const isLastFocusable = currentIndex === footerFocusables.length - 1;\n\n if (tabbingForward && isLastFocusable) {\n e.preventDefault();\n const rootNode = buttonRef.current.getRootNode();\n if (!isInstance(rootNode, Document, ShadowRoot)) return;\n\n const allFocusables = getFocusables(rootNode);\n const nextIndex = allFocusables.indexOf(buttonRef.current) + 1;\n\n allFocusables[nextIndex]?.focus();\n setIsOpen(false);\n } else if (!tabbingForward && currentIndex === 0) {\n e.preventDefault();\n buttonRef.current?.focus();\n }\n }\n }}\n >\n {menu && (\n <Menu\n testId={testIds.root}\n {...menu}\n ref={menuRef}\n loading={menu.loading}\n items={menu.items}\n onItemClick={(itemId, e) => {\n // When clicking an item (by mouse or keyboard) and the menu is not multi-select, close the menu.\n if (menu.mode !== 'multi-select') {\n setIsOpen(false);\n buttonRef.current?.focus();\n }\n menu.onItemClick?.(itemId, e);\n }}\n focusControlEl={menu.focusControlEl || buttonRef.current || undefined}\n />\n )}\n </StyledMenuButtonPopover>\n </>\n );\n});\n\nexport default withTestIds(MenuButton, getMenuButtonTestIds);\n"]}
@@ -21,6 +21,11 @@ export type NumberDisplayProps = WithAttributes<'span', NoChildrenProp & {
21
21
  * @default true
22
22
  */
23
23
  groupSeparators?: boolean;
24
+ /**
25
+ * Determines negative value notation: using minus sign or parentheses (accounting format).
26
+ * @default 'minus-sign'
27
+ */
28
+ negative?: 'minus-sign' | 'parentheses';
24
29
  };
25
30
  }>;
26
31
  declare const _default: import("react").ForwardRefExoticComponent<Omit<NumberDisplayProps, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
@@ -1 +1 @@
1
- {"version":3,"file":"NumberDisplay.d.ts","sourceRoot":"","sources":["../../../src/components/Number/NumberDisplay.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAc,cAAc,EAAE,MAAM,aAAa,CAAC;AAM9E,MAAM,MAAM,kBAAkB,GAAG,cAAc,CAC7C,MAAM,EACN,cAAc,GAAG;IACf,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,iBAAiB,CAAC,EAAE;QAClB;;;WAGG;QACH,QAAQ,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;QAClC;;;;WAIG;QACH,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB;;;WAGG;QACH,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3B,CAAC;CACH,CACF,CAAC;;AAEF,wBA+BE"}
1
+ {"version":3,"file":"NumberDisplay.d.ts","sourceRoot":"","sources":["../../../src/components/Number/NumberDisplay.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAc,cAAc,EAAE,MAAM,aAAa,CAAC;AAM9E,MAAM,MAAM,kBAAkB,GAAG,cAAc,CAC7C,MAAM,EACN,cAAc,GAAG;IACf,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,iBAAiB,CAAC,EAAE;QAClB;;;WAGG;QACH,QAAQ,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;QAClC;;;;WAIG;QACH,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB;;;WAGG;QACH,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B;;;WAGG;QACH,QAAQ,CAAC,EAAE,YAAY,GAAG,aAAa,CAAC;KACzC,CAAC;CACH,CACF,CAAC;;AAEF,wBAiCE"}
@@ -3,13 +3,14 @@ import { forwardRef } from 'react';
3
3
  import { useConfiguration } from '../../hooks';
4
4
  import NoValue from '../NoValue/NoValue';
5
5
  import { getFraction, getFormattedValue } from './utils';
6
- export default forwardRef(function NumberDisplay({ value, unit = '', formattingOptions: { fractionDigits = getFraction(String(value)).substring(1).length, notation, groupSeparators = true } = {}, ...restProps }, ref) {
6
+ export default forwardRef(function NumberDisplay({ value, unit = '', formattingOptions: { fractionDigits = getFraction(String(value)).substring(1).length, notation, groupSeparators = true, negative } = {}, ...restProps }, ref) {
7
7
  const { locale } = useConfiguration();
8
8
  return (_jsx("span", { ref: ref, ...restProps, children: value || value === 0 ? (getFormattedValue(value.toString(), locale, unit, {
9
9
  notation,
10
10
  useGrouping: groupSeparators,
11
11
  maximumFractionDigits: fractionDigits,
12
- minimumFractionDigits: fractionDigits
12
+ minimumFractionDigits: fractionDigits,
13
+ negative
13
14
  })) : (_jsx(NoValue, {})) }));
14
15
  });
15
16
  //# sourceMappingURL=NumberDisplay.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NumberDisplay.js","sourceRoot":"","sources":["../../../src/components/Number/NumberDisplay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAInC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,OAAO,MAAM,oBAAoB,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AA+BzD,eAAe,UAAU,CACvB,SAAS,aAAa,CACpB,EACE,KAAK,EACL,IAAI,GAAG,EAAE,EACT,iBAAiB,EAAE,EACjB,cAAc,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,EAC/D,QAAQ,EACR,eAAe,GAAG,IAAI,EACvB,GAAG,EAAE,EACN,GAAG,SAAS,EACb,EACD,GAAG;IAEH,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,EAAE,CAAC;IAEtC,OAAO,CACL,eAAM,GAAG,EAAE,GAAG,KAAM,SAAS,YAC1B,KAAK,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CACtB,iBAAiB,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;YAChD,QAAQ;YACR,WAAW,EAAE,eAAe;YAC5B,qBAAqB,EAAE,cAAc;YACrC,qBAAqB,EAAE,cAAc;SACtC,CAAC,CACH,CAAC,CAAC,CAAC,CACF,KAAC,OAAO,KAAG,CACZ,GACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { PropsWithoutRef } from 'react';\n\nimport type { NoChildrenProp, RefElement, WithAttributes } from '../../types';\nimport { useConfiguration } from '../../hooks';\nimport NoValue from '../NoValue/NoValue';\n\nimport { getFraction, getFormattedValue } from './utils';\n\nexport type NumberDisplayProps = WithAttributes<\n 'span',\n NoChildrenProp & {\n /** Number value */\n value?: number | bigint;\n /** Unit to be included in the text, for example '%' */\n unit?: string;\n\n formattingOptions?: {\n /**\n * Value display notation.\n * @default 'standard'\n */\n notation?: 'standard' | 'compact';\n /**\n * Determines the fixed number of fraction digits. The value is rounded to the given precision.\n * Maximum is 20, default is value precision.\n * @default variable\n */\n fractionDigits?: number;\n /**\n * Determines whether group separators should be shown.\n * @default true\n */\n groupSeparators?: boolean;\n };\n }\n>;\n\nexport default forwardRef<RefElement<NumberDisplayProps>, PropsWithoutRef<NumberDisplayProps>>(\n function NumberDisplay(\n {\n value,\n unit = '',\n formattingOptions: {\n fractionDigits = getFraction(String(value)).substring(1).length,\n notation,\n groupSeparators = true\n } = {},\n ...restProps\n },\n ref\n ) {\n const { locale } = useConfiguration();\n\n return (\n <span ref={ref} {...restProps}>\n {value || value === 0 ? (\n getFormattedValue(value.toString(), locale, unit, {\n notation,\n useGrouping: groupSeparators,\n maximumFractionDigits: fractionDigits,\n minimumFractionDigits: fractionDigits\n })\n ) : (\n <NoValue />\n )}\n </span>\n );\n }\n);\n"]}
1
+ {"version":3,"file":"NumberDisplay.js","sourceRoot":"","sources":["../../../src/components/Number/NumberDisplay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAInC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,OAAO,MAAM,oBAAoB,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAoCzD,eAAe,UAAU,CACvB,SAAS,aAAa,CACpB,EACE,KAAK,EACL,IAAI,GAAG,EAAE,EACT,iBAAiB,EAAE,EACjB,cAAc,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,EAC/D,QAAQ,EACR,eAAe,GAAG,IAAI,EACtB,QAAQ,EACT,GAAG,EAAE,EACN,GAAG,SAAS,EACb,EACD,GAAG;IAEH,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,EAAE,CAAC;IAEtC,OAAO,CACL,eAAM,GAAG,EAAE,GAAG,KAAM,SAAS,YAC1B,KAAK,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CACtB,iBAAiB,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;YAChD,QAAQ;YACR,WAAW,EAAE,eAAe;YAC5B,qBAAqB,EAAE,cAAc;YACrC,qBAAqB,EAAE,cAAc;YACrC,QAAQ;SACT,CAAC,CACH,CAAC,CAAC,CAAC,CACF,KAAC,OAAO,KAAG,CACZ,GACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { PropsWithoutRef } from 'react';\n\nimport type { NoChildrenProp, RefElement, WithAttributes } from '../../types';\nimport { useConfiguration } from '../../hooks';\nimport NoValue from '../NoValue/NoValue';\n\nimport { getFraction, getFormattedValue } from './utils';\n\nexport type NumberDisplayProps = WithAttributes<\n 'span',\n NoChildrenProp & {\n /** Number value */\n value?: number | bigint;\n /** Unit to be included in the text, for example '%' */\n unit?: string;\n\n formattingOptions?: {\n /**\n * Value display notation.\n * @default 'standard'\n */\n notation?: 'standard' | 'compact';\n /**\n * Determines the fixed number of fraction digits. The value is rounded to the given precision.\n * Maximum is 20, default is value precision.\n * @default variable\n */\n fractionDigits?: number;\n /**\n * Determines whether group separators should be shown.\n * @default true\n */\n groupSeparators?: boolean;\n /**\n * Determines negative value notation: using minus sign or parentheses (accounting format).\n * @default 'minus-sign'\n */\n negative?: 'minus-sign' | 'parentheses';\n };\n }\n>;\n\nexport default forwardRef<RefElement<NumberDisplayProps>, PropsWithoutRef<NumberDisplayProps>>(\n function NumberDisplay(\n {\n value,\n unit = '',\n formattingOptions: {\n fractionDigits = getFraction(String(value)).substring(1).length,\n notation,\n groupSeparators = true,\n negative\n } = {},\n ...restProps\n },\n ref\n ) {\n const { locale } = useConfiguration();\n\n return (\n <span ref={ref} {...restProps}>\n {value || value === 0 ? (\n getFormattedValue(value.toString(), locale, unit, {\n notation,\n useGrouping: groupSeparators,\n maximumFractionDigits: fractionDigits,\n minimumFractionDigits: fractionDigits,\n negative\n })\n ) : (\n <NoValue />\n )}\n </span>\n );\n }\n);\n"]}
@@ -1,7 +1,9 @@
1
1
  export declare function getDecimalSign(locale: Intl.UnicodeBCP47LocaleIdentifier, options?: Intl.NumberFormatOptions): string;
2
2
  export declare function getFraction(value: string): string;
3
3
  export declare function getCleanedValue(value: string, decimalSign: string, maximumFractionDigits: number): string;
4
- export declare const getFormattedValue: (value: string, locale: string, unit?: string, { notation, useGrouping, maximumFractionDigits, minimumFractionDigits }?: Pick<Intl.NumberFormatOptions, "notation" | "useGrouping" | "maximumFractionDigits" | "minimumFractionDigits">) => string;
4
+ export declare const getFormattedValue: (value: string, locale: string, unit?: string, { notation, useGrouping, maximumFractionDigits, minimumFractionDigits, negative }?: Pick<Intl.NumberFormatOptions, "notation" | "useGrouping" | "maximumFractionDigits" | "minimumFractionDigits"> & {
5
+ negative?: "minus-sign" | "parentheses";
6
+ }) => string;
5
7
  export declare function isValueInRange(value: number, min?: number, max?: number): boolean;
6
8
  export declare function getIncrementedValue(value: string, min: number, max: number, step: number): string;
7
9
  export declare function getDecrementedValue(value: string, min: number, max: number, step: number): string;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/Number/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,cAAc,CAC5B,MAAM,EAAE,IAAI,CAAC,4BAA4B,EACzC,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,GACjC,MAAM,CAMR;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,UAIxC;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,qBAAqB,EAAE,MAAM,GAC5B,MAAM,CAQR;AAYD,eAAO,MAAM,iB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,MAAM,EACb,oFAMG,IAAI,CACL,IAAI,CAAC,mBAAmB,EACxB,UAAU,GAAG,aAAa,GAAG,uBAAuB,GAAG,uBAAuB,CAC/E,GAAG;IAAE,QAAQ,CAAC,EAAE,YAAY,GAAG,aAAa,CAAA;CAAO,WA2CrD,CAAC;AAEF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAEjF;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAUjG;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAUjG;AAED,UAAU,mBAAmB;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC;CACpC;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,mBAAmB,UAI5F"}
@@ -29,9 +29,11 @@ const isValidUnit = (unit) => {
29
29
  return false;
30
30
  }
31
31
  };
32
- export const getFormattedValue = (value, locale, unit, { notation = 'standard', useGrouping = false, maximumFractionDigits, minimumFractionDigits } = {}) => {
32
+ export const getFormattedValue = (value, locale, unit, { notation = 'standard', useGrouping = false, maximumFractionDigits, minimumFractionDigits, negative = 'minus-sign' } = {}) => {
33
33
  const isUnit = unit ? isValidUnit(unit) : false;
34
- const [integer, fractionPart] = value.split('.', 2);
34
+ const isNegative = value.startsWith('-');
35
+ const formattingValue = negative === 'parentheses' && isNegative ? value.slice(1) : value;
36
+ const [integer = '0', fractionPart] = formattingValue.split('.', 2);
35
37
  const formatter = new Intl.NumberFormat(locale, {
36
38
  notation,
37
39
  useGrouping,
@@ -41,10 +43,10 @@ export const getFormattedValue = (value, locale, unit, { notation = 'standard',
41
43
  unit: isUnit ? unit : undefined,
42
44
  numberingSystem: 'latn'
43
45
  });
44
- let formatted = value;
45
- if (value && !Number.isNaN(parseFloat(integer))) {
46
+ let formatted = formattingValue;
47
+ if (formattingValue && !Number.isNaN(parseFloat(integer))) {
46
48
  const endsWithDot = fractionPart === '';
47
- const valueNumber = endsWithDot ? `${value}1` : value;
49
+ const valueNumber = endsWithDot ? `${formattingValue}1` : formattingValue;
48
50
  formatted =
49
51
  formatter
50
52
  .formatToParts(valueNumber)
@@ -57,12 +59,12 @@ export const getFormattedValue = (value, locale, unit, { notation = 'standard',
57
59
  else if (unit) {
58
60
  if (isUnit)
59
61
  formatted = formatter
60
- .formatToParts(value.startsWith('-') ? -1 : 1)
62
+ .formatToParts(formattingValue.startsWith('-') ? -1 : 1)
61
63
  .reduce((result, { type, value: part }) => ['unit', 'minusSign'].includes(type) ? result + part : result, '');
62
64
  else
63
- formatted = value.startsWith('-') ? `- ${unit}` : unit;
65
+ formatted = formattingValue.startsWith('-') ? `- ${unit}` : unit;
64
66
  }
65
- return formatted;
67
+ return negative === 'parentheses' && isNegative ? `(${formatted})` : formatted;
66
68
  };
67
69
  export function isValueInRange(value, min, max) {
68
70
  return !((min !== undefined && value < min) || (max !== undefined && value > max));
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/Number/utils.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,MAAM,UAAU,cAAc,CAC5B,MAAyC,EACzC,OAAkC;IAElC,OAAO,CACL,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC;SACnC,aAAa,CAAC,GAAG,CAAC;SAClB,MAAM,CAAC,CAAC,IAAqC,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,C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icodeBCP47LocaleIdentifier,\n options?: Intl.NumberFormatOptions\n): string {\n return (\n new Intl.NumberFormat(locale, options)\n .formatToParts(0.1)\n .filter((part: { type: string; value: string }) => part.type === 'decimal')[0]?.value || ''\n );\n}\n\nexport function getFraction(value: string) {\n const decPos = value.indexOf('.');\n const substrLength = decPos === -1 ? value.length : decPos;\n return value.substring(substrLength);\n}\n\nexport function getCleanedValue(\n value: string,\n decimalSign: string,\n maximumFractionDigits: number\n): string {\n let rawValue = value.replace(new RegExp(`[^${decimalSign}\\\\d-]+`, 'gu'), '');\n if (decimalSign && decimalSign !== '.') rawValue = rawValue.replace(decimalSign, '.');\n const match = rawValue.match(new RegExp(`-?\\\\d*(\\\\.\\\\d{0,${maximumFractionDigits}})?`));\n if (match && match.length > 0) {\n rawValue = match[0];\n }\n return rawValue;\n}\n\nconst isValidUnit = (unit: string) => {\n try {\n // eslint-disable-next-line no-new\n new Intl.NumberFormat(undefined, { style: 'unit', unit });\n return true;\n } catch {\n return false;\n }\n};\n\nexport const getFormattedValue = (\n value: string,\n locale: string,\n unit?: string,\n {\n notation = 'standard',\n useGrouping = false,\n maximumFractionDigits,\n minimumFractionDigits\n }: Pick<\n Intl.NumberFormatOptions,\n 'notation' | 'useGrouping' | 'maximumFractionDigits' | 'minimumFractionDigits'\n > = {}\n) => {\n const isUnit = unit ? isValidUnit(unit) : false;\n const [integer, fractionPart] = value.split('.', 2) as [string, string?];\n\n const formatter = new Intl.NumberFormat(locale, {\n notation,\n useGrouping,\n minimumFractionDigits:\n minimumFractionDigits ?? Math.min(maximumFractionDigits ?? 0, fractionPart?.length ?? 0),\n maximumFractionDigits,\n style: isUnit ? 'unit' : undefined,\n unit: isUnit ? unit : undefined,\n numberingSystem: 'latn'\n });\n\n let formatted = value;\n\n if (value && !Number.isNaN(parseFloat(integer))) {\n const endsWithDot = fractionPart === '';\n const valueNumber = endsWithDot ? `${value}1` : value;\n formatted =\n formatter\n .formatToParts(valueNumber as `${number}`)\n .reduce((result, { type, value: part }) => {\n if (type === 'fraction' && endsWithDot) return result;\n return result + part;\n }, '') + (!isUnit && unit ? `\\u00a0${unit}` : '');\n } else if (unit) {\n if (isUnit)\n formatted = formatter\n .formatToParts(value.startsWith('-') ? -1 : 1)\n .reduce(\n (result, { type, value: part }) =>\n ['unit', 'minusSign'].includes(type) ? result + part : result,\n ''\n );\n else formatted = value.startsWith('-') ? `- ${unit}` : unit;\n }\n\n return formatted;\n};\n\nexport function isValueInRange(value: number, min?: number, max?: number): boolean {\n return !((min !== undefined && value < min) || (max !== undefined && value > max));\n}\n\nexport function getIncrementedValue(value: string, min: number, max: number, step: number): string {\n const numberValue = parseFloat(value) || 0;\n const newValue = new BigNumber(numberValue).plus(step);\n if (isValueInRange(newValue.toNumber(), min, max)) {\n return newValue.toFixed();\n }\n if (min !== undefined && newValue.toNumber() < min) {\n return min.toString();\n }\n return value;\n}\n\nexport function getDecrementedValue(value: string, min: number, max: number, step: number): string {\n const numberValue = parseFloat(value) || 0;\n const newValue = new BigNumber(numberValue).minus(step);\n if (isValueInRange(newValue.toNumber(), min, max)) {\n return newValue.toFixed();\n }\n if (max !== undefined && newValue.toNumber() > max) {\n return max.toString();\n }\n return value;\n}\n\ninterface NumberFormatOptions {\n locale: string;\n options?: Intl.NumberFormatOptions;\n}\n\nexport function formatNumber(value: number | bigint, { locale, options }: NumberFormatOptions) {\n const formatter = new Intl.NumberFormat(locale, options);\n\n return formatter.format(value);\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/Number/utils.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,MAAM,UAAU,cAAc,CAC5B,MAAyC,EACzC,OAAkC;IAElC,OAAO,CACL,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC;SACnC,aAAa,CAAC,GAAG,CAAC;SAClB,MAAM,CAAC,CAAC,IAAqC,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,K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AE,CAAC;IACxB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAOD,MAAM,UAAU,YAAY,CAAC,KAAsB,EAAE,EAAE,MAAM,EAAE,OAAO,EAAuB;IAC3F,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEzD,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC","sourcesContent":["import BigNumber from 'bignumber.js';\n\nexport function getDecimalSign(\n locale: Intl.UnicodeBCP47LocaleIdentifier,\n options?: Intl.NumberFormatOptions\n): string {\n return (\n new Intl.NumberFormat(locale, options)\n .formatToParts(0.1)\n .filter((part: { type: string; value: string }) => part.type === 'decimal')[0]?.value || ''\n );\n}\n\nexport function getFraction(value: string) {\n const decPos = value.indexOf('.');\n const substrLength = decPos === -1 ? value.length : decPos;\n return value.substring(substrLength);\n}\n\nexport function getCleanedValue(\n value: string,\n decimalSign: string,\n maximumFractionDigits: number\n): string {\n let rawValue = value.replace(new RegExp(`[^${decimalSign}\\\\d-]+`, 'gu'), '');\n if (decimalSign && decimalSign !== '.') rawValue = rawValue.replace(decimalSign, '.');\n const match = rawValue.match(new RegExp(`-?\\\\d*(\\\\.\\\\d{0,${maximumFractionDigits}})?`));\n if (match && match.length > 0) {\n rawValue = match[0];\n }\n return rawValue;\n}\n\nconst isValidUnit = (unit: string) => {\n try {\n // eslint-disable-next-line no-new\n new Intl.NumberFormat(undefined, { style: 'unit', unit });\n return true;\n } catch {\n return false;\n }\n};\n\nexport const getFormattedValue = (\n value: string,\n locale: string,\n unit?: string,\n {\n notation = 'standard',\n useGrouping = false,\n maximumFractionDigits,\n minimumFractionDigits,\n negative = 'minus-sign'\n }: Pick<\n Intl.NumberFormatOptions,\n 'notation' | 'useGrouping' | 'maximumFractionDigits' | 'minimumFractionDigits'\n > & { negative?: 'minus-sign' | 'parentheses' } = {}\n) => {\n const isUnit = unit ? isValidUnit(unit) : false;\n const isNegative = value.startsWith('-');\n const formattingValue = negative === 'parentheses' && isNegative ? value.slice(1) : value;\n const [integer = '0', fractionPart] = formattingValue.split('.', 2);\n\n const formatter = new Intl.NumberFormat(locale, {\n notation,\n useGrouping,\n minimumFractionDigits:\n minimumFractionDigits ?? Math.min(maximumFractionDigits ?? 0, fractionPart?.length ?? 0),\n maximumFractionDigits,\n style: isUnit ? 'unit' : undefined,\n unit: isUnit ? unit : undefined,\n numberingSystem: 'latn'\n });\n\n let formatted = formattingValue;\n\n if (formattingValue && !Number.isNaN(parseFloat(integer))) {\n const endsWithDot = fractionPart === '';\n const valueNumber = endsWithDot ? `${formattingValue}1` : formattingValue;\n formatted =\n formatter\n .formatToParts(valueNumber as `${number}`)\n .reduce((result, { type, value: part }) => {\n if (type === 'fraction' && endsWithDot) return result;\n return result + part;\n }, '') + (!isUnit && unit ? `\\u00a0${unit}` : '');\n } else if (unit) {\n if (isUnit)\n formatted = formatter\n .formatToParts(formattingValue.startsWith('-') ? -1 : 1)\n .reduce(\n (result, { type, value: part }) =>\n ['unit', 'minusSign'].includes(type) ? result + part : result,\n ''\n );\n else formatted = formattingValue.startsWith('-') ? `- ${unit}` : unit;\n }\n\n return negative === 'parentheses' && isNegative ? `(${formatted})` : formatted;\n};\n\nexport function isValueInRange(value: number, min?: number, max?: number): boolean {\n return !((min !== undefined && value < min) || (max !== undefined && value > max));\n}\n\nexport function getIncrementedValue(value: string, min: number, max: number, step: number): string {\n const numberValue = parseFloat(value) || 0;\n const newValue = new BigNumber(numberValue).plus(step);\n if (isValueInRange(newValue.toNumber(), min, max)) {\n return newValue.toFixed();\n }\n if (min !== undefined && newValue.toNumber() < min) {\n return min.toString();\n }\n return value;\n}\n\nexport function getDecrementedValue(value: string, min: number, max: number, step: number): string {\n const numberValue = parseFloat(value) || 0;\n const newValue = new BigNumber(numberValue).minus(step);\n if (isValueInRange(newValue.toNumber(), min, max)) {\n return newValue.toFixed();\n }\n if (max !== undefined && newValue.toNumber() > max) {\n return max.toString();\n }\n return value;\n}\n\ninterface NumberFormatOptions {\n locale: string;\n options?: Intl.NumberFormatOptions;\n}\n\nexport function formatNumber(value: number | bigint, { locale, options }: NumberFormatOptions) {\n const formatter = new Intl.NumberFormat(locale, options);\n\n return formatter.format(value);\n}\n"]}
@@ -43,7 +43,7 @@ const StyledPageBreak = styled.div(({ containerPadding, rowHeight, theme, margin
43
43
  font-size: 0.75rem;
44
44
  line-height: 1;
45
45
  transform: translate(0, -50%);
46
- background-color: ${palette['app-background']};
46
+ background: ${palette['app-background']};
47
47
  color: ${palette['border-line']};
48
48
  padding-inline-end: 0.25rem;
49
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EditorBackground.js","sourceRoot":"","sources":["../../../../src/components/PageTemplates/GridLayout/EditorBackground.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,IAAI,MAAM,YAAY,CAAC;AAE9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,OAAO,mBAAmB,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;;;;CAK9B,CAAC;AAEF,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAC/B,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,EAAE;IACpC,MAAM,EACJ,IAAI,EAAE,EAAE,OAAO,EAAE,EAClB,GAAG,KAAK,CAAC;IACV,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;IAClE,MAAM,UAAU,GAAG,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M,EACd,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAL5B,CAAC,CAMN,CACH,CAAC,IACS,CACd,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import type { FC } from 'react';\nimport styled, { css } from 'styled-components';\nimport type { Layout } from 'react-grid-layout';\nimport { rgba } from 'polished';\n\nimport Grid from '../../Grid';\nimport type { NoChildrenProp } from '../../../types';\nimport { defaultThemeProp } from '../../../theme';\nimport { useI18n } from '../../../hooks';\n\nimport useGridLayoutConfig from './config';\nimport { getArrayFromRange } from './utils';\n\nconst StyledGrid = styled(Grid)`\n position: absolute;\n z-index: -1;\n pointer-events: none;\n inline-size: 100%;\n`;\n\nconst StyledGridCell = styled.div<{ rowHeight: number; highlighted: boolean }>(\n ({ theme, highlighted, rowHeight }) => {\n const {\n base: { palette }\n } = theme;\n const borderColor = palette[highlighted ? 'warn' : 'border-line'];\n const background = highlighted ? rgba(palette.warn, 0.1) : 'transparent';\n\n return css`\n /* stylelint-disable-next-line unit-allowed-list */\n border: 1px solid ${borderColor};\n background: ${background};\n block-size: ${rowHeight}px;\n border-radius: ${theme.components.card['border-radius']};\n `;\n }\n);\nStyledGridCell.defaultProps = defaultThemeProp;\n\ninterface PageBreakProps {\n rowsAbove: number;\n rowHeight: number;\n margin: [number, number];\n containerPadding: [number, number];\n prefix: string;\n}\n\nconst StyledPageBreak = styled.div<PageBreakProps>(\n ({ containerPadding, rowHeight, theme, margin, rowsAbove, prefix }) => {\n const {\n base: { palette }\n } = theme;\n return css`\n position: absolute;\n inset-inline-start: ${containerPadding[0]}px;\n inset-inline-end: ${containerPadding[0]}px;\n inset-block-start: ${containerPadding[1] + rowsAbove * (rowHeight + margin[1])}px;\n /* stylelint-disable-next-line unit-allowed-list */\n margin-block-start: ${-margin[1] / 2 - 1}px;\n /* stylelint-disable-next-line unit-allowed-list */\n border-block-start: 2px dashed ${palette['border-line']};\n\n &::before {\n content: '${prefix}';\n position: absolute;\n font-size: 0.75rem;\n line-height: 1;\n transform: translate(0, -50%);\n background-color: ${palette['app-background']};\n color: ${palette['border-line']};\n padding-inline-end: 0.25rem;\n }\n `;\n }\n);\nStyledPageBreak.defaultProps = defaultThemeProp;\n\ninterface EditorBackgroundProps extends NoChildrenProp {\n layout?: Layout[];\n numColumns: number;\n rowHeight: number;\n rowsPerPage: number | null; // null when not applying auto-fit\n highlighted: boolean;\n}\n\n/**\n * Renders background grid-cells for GridEditor\n * @component\n */\nconst EditorBackground: FC<EditorBackgroundProps> = ({\n layout,\n numColumns,\n rowHeight,\n rowsPerPage,\n highlighted\n}) => {\n const t = useI18n();\n const { margin, containerPadding } = useGridLayoutConfig(true);\n\n const maxYInLayout = layout ? Math.max(...layout.map(item => item.y + item.h)) : 0;\n const maxY = Math.max(maxYInLayout, rowsPerPage || 0);\n const numGridCells = (maxY + 1) * numColumns;\n const cells = getArrayFromRange(0, numGridCells, false);\n\n // rowsPerPage will be null if auto-fit is disabled. Don't show pageBreaks in that case.\n const numPageBreaks = rowsPerPage ? Math.floor(maxY / rowsPerPage) : 0;\n const pageBreaks = getArrayFromRange(0, numPageBreaks, false);\n\n return (\n <StyledGrid container={{ cols: `repeat(${numColumns}, 1fr)`, gap: 2, pad: [0, 2, 2, 2] }}>\n {cells.map(n => (\n <StyledGridCell\n key={n}\n rowHeight={rowHeight}\n // Highlight all cells except the dummy row at the bottom\n highlighted={highlighted && n < numGridCells - numColumns}\n />\n ))}\n {pageBreaks.map(n => (\n <StyledPageBreak\n key={n}\n rowsAbove={(n + 1) * rowsPerPage!}\n rowHeight={rowHeight}\n margin={margin}\n containerPadding={containerPadding}\n prefix={t('page_number', [n + 1])}\n />\n ))}\n </StyledGrid>\n );\n};\n\nexport default EditorBackground;\n"]}
1
+ {"version":3,"file":"EditorBackground.js","sourceRoot":"","sources":["../../../../src/components/PageTemplates/GridLayout/EditorBackground.t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,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvE,MAAM,UAAU,GAAG,iBAAiB,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,CAAC;IAE9D,OAAO,CACL,MAAC,UAAU,IAAC,SAAS,EAAE,EAAE,IAAI,EAAE,UAAU,UAAU,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,aACrF,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CACd,KAAC,cAAc,IAEb,SAAS,EAAE,SAAS;gBACpB,yDAAyD;gBACzD,WAAW,EAAE,WAAW,IAAI,CAAC,GAAG,YAAY,GAAG,UAAU,IAHpD,CAAC,CAIN,CACH,CAAC,EACD,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CACnB,KAAC,eAAe,IAEd,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,WAAY,EACjC,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAL5B,CAAC,CAMN,CACH,CAAC,IACS,CACd,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import type { FC } from 'react';\nimport styled, { css } from 'styled-components';\nimport type { Layout } from 'react-grid-layout';\nimport { rgba } from 'polished';\n\nimport Grid from '../../Grid';\nimport type { NoChildrenProp } from '../../../types';\nimport { defaultThemeProp } from '../../../theme';\nimport { useI18n } from '../../../hooks';\n\nimport useGridLayoutConfig from './config';\nimport { getArrayFromRange } from './utils';\n\nconst StyledGrid = styled(Grid)`\n position: absolute;\n z-index: -1;\n pointer-events: none;\n inline-size: 100%;\n`;\n\nconst StyledGridCell = styled.div<{ rowHeight: number; highlighted: boolean }>(\n ({ theme, highlighted, rowHeight }) => {\n const {\n base: { palette }\n } = theme;\n const borderColor = palette[highlighted ? 'warn' : 'border-line'];\n const background = highlighted ? rgba(palette.warn, 0.1) : 'transparent';\n\n return css`\n /* stylelint-disable-next-line unit-allowed-list */\n border: 1px solid ${borderColor};\n background: ${background};\n block-size: ${rowHeight}px;\n border-radius: ${theme.components.card['border-radius']};\n `;\n }\n);\nStyledGridCell.defaultProps = defaultThemeProp;\n\ninterface PageBreakProps {\n rowsAbove: number;\n rowHeight: number;\n margin: [number, number];\n containerPadding: [number, number];\n prefix: string;\n}\n\nconst StyledPageBreak = styled.div<PageBreakProps>(\n ({ containerPadding, rowHeight, theme, margin, rowsAbove, prefix }) => {\n const {\n base: { palette }\n } = theme;\n return css`\n position: absolute;\n inset-inline-start: ${containerPadding[0]}px;\n inset-inline-end: ${containerPadding[0]}px;\n inset-block-start: ${containerPadding[1] + rowsAbove * (rowHeight + margin[1])}px;\n /* stylelint-disable-next-line unit-allowed-list */\n margin-block-start: ${-margin[1] / 2 - 1}px;\n /* stylelint-disable-next-line unit-allowed-list */\n border-block-start: 2px dashed ${palette['border-line']};\n\n &::before {\n content: '${prefix}';\n position: absolute;\n font-size: 0.75rem;\n line-height: 1;\n transform: translate(0, -50%);\n background: ${palette['app-background']};\n color: ${palette['border-line']};\n padding-inline-end: 0.25rem;\n }\n `;\n }\n);\nStyledPageBreak.defaultProps = defaultThemeProp;\n\ninterface EditorBackgroundProps extends NoChildrenProp {\n layout?: Layout[];\n numColumns: number;\n rowHeight: number;\n rowsPerPage: number | null; // null when not applying auto-fit\n highlighted: boolean;\n}\n\n/**\n * Renders background grid-cells for GridEditor\n * @component\n */\nconst EditorBackground: FC<EditorBackgroundProps> = ({\n layout,\n numColumns,\n rowHeight,\n rowsPerPage,\n highlighted\n}) => {\n const t = useI18n();\n const { margin, containerPadding } = useGridLayoutConfig(true);\n\n const maxYInLayout = layout ? Math.max(...layout.map(item => item.y + item.h)) : 0;\n const maxY = Math.max(maxYInLayout, rowsPerPage || 0);\n const numGridCells = (maxY + 1) * numColumns;\n const cells = getArrayFromRange(0, numGridCells, false);\n\n // rowsPerPage will be null if auto-fit is disabled. Don't show pageBreaks in that case.\n const numPageBreaks = rowsPerPage ? Math.floor(maxY / rowsPerPage) : 0;\n const pageBreaks = getArrayFromRange(0, numPageBreaks, false);\n\n return (\n <StyledGrid container={{ cols: `repeat(${numColumns}, 1fr)`, gap: 2, pad: [0, 2, 2, 2] }}>\n {cells.map(n => (\n <StyledGridCell\n key={n}\n rowHeight={rowHeight}\n // Highlight all cells except the dummy row at the bottom\n highlighted={highlighted && n < numGridCells - numColumns}\n />\n ))}\n {pageBreaks.map(n => (\n <StyledPageBreak\n key={n}\n rowsAbove={(n + 1) * rowsPerPage!}\n rowHeight={rowHeight}\n margin={margin}\n containerPadding={containerPadding}\n prefix={t('page_number', [n + 1])}\n />\n ))}\n </StyledGrid>\n );\n};\n\nexport default EditorBackground;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PreviewManager.d.ts","sourceRoot":"","sources":["../../../src/components/Preview/PreviewManager.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA2B,OAAO,EAAoC,MAAM,OAAO,CAAC;AAIhG,OAAO,YAAY,CAAC;AAKpB,OAAO,KAAK,EAEV,0BAA0B,EAG1B,mBAAmB,EACpB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAiB,aAAa;QAC5B,qBAAqB,CAAC,EAAE,OAAO,CAAC,0BAA0B,CAAC,CAAC;KAC7D;CACF;AA0GD,QAAA,MAAM,cAAc,GAAI,cAAc,mBAAmB,4CAkFxD,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"PreviewManager.d.ts","sourceRoot":"","sources":["../../../src/components/Preview/PreviewManager.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA2B,OAAO,EAAoC,MAAM,OAAO,CAAC;AAIhG,OAAO,YAAY,CAAC;AAKpB,OAAO,KAAK,EAEV,0BAA0B,EAG1B,mBAAmB,EACpB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAiB,aAAa;QAC5B,qBAAqB,CAAC,EAAE,OAAO,CAAC,0BAA0B,CAAC,CAAC;KAC7D;CACF;AA8GD,QAAA,MAAM,cAAc,GAAI,cAAc,mBAAmB,4CA0FxD,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -4,7 +4,7 @@ import { useReducer, useState, useMemo, useContext, useRef, useEffect, memo } fr
4
4
  import { createPortal } from 'react-dom';
5
5
  import { createUID, windowIsAvailable } from '../../utils';
6
6
  import '../../init';
7
- import { useConfiguration } from '../../hooks';
7
+ import { useBreakpoint, useConfiguration } from '../../hooks';
8
8
  import PreviewPanel from './PreviewPanel';
9
9
  import { PreviewContext, PreviewManagerContext } from './Contexts';
10
10
  const reducer = (previews, payload) => {
@@ -30,6 +30,8 @@ const reducer = (previews, payload) => {
30
30
  : preview);
31
31
  case 'unmount':
32
32
  return previews.filter(preview => preview.id !== payload.id);
33
+ case 'clear':
34
+ return [];
33
35
  default:
34
36
  return previews;
35
37
  }
@@ -76,6 +78,13 @@ const PreviewManager = ({ children }) => {
76
78
  const [previewActive, setPreviewActive] = useState(false);
77
79
  const previewTriggerRef = useRef(null);
78
80
  const { portalTarget } = useConfiguration();
81
+ const isSmallOrAbove = useBreakpoint('sm');
82
+ // Dismiss all previews when screen size reflows below sm breakpoint
83
+ useEffect(() => {
84
+ if (!isSmallOrAbove && previews.length > 0) {
85
+ dispatch({ type: 'clear' });
86
+ }
87
+ }, [isSmallOrAbove, previews.length]);
79
88
  const providerValue = useMemo(() => ({
80
89
  previewActive,
81
90
  setPreviewActive,
@@ -1 +1 @@
1
- {"version":3,"file":"PreviewManager.js","sourceRoot":"","sources":["../../../src/components/Preview/PreviewManager.ts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E;oBACF,SAAS;oBACT,OAAO;oBACP,KAAK,EAAE,CAAC,KAAK,IAAI,EAAE,CAAM;oBACzB,OAAO;iBACR;aACF,CAAC,CAAC;YAEH,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,cAAc;QACd,WAAW,EAAE,IAAI;KAClB,CAAC,EACF,CAAC,aAAa,CAAC,CAChB,CAAC;IAEF,MAAM,OAAO,GAAG,iBAAiB;QAC/B,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,qBAAqB,IAAI,qBAAqB;QAC9D,CAAC,CAAC,qBAAqB,CAAC;IAC1B,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAErC,4CAA4C;IAC5C,IAAI,QAAQ,CAAC,WAAW;QAAE,OAAO,KAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,YAAG,QAAQ,GAAoB,CAAC;IAElG,MAAM,aAAa,GACjB,YAAY,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QACjC,CAAC,CAAC,YAAY,CACV,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CACtB,eAAC,cAAc,OACT,OAAO,EACX,GAAG,EAAE,OAAO,CAAC,EAAE,EACf,kBAAkB,EAAE,gBAAgB,EACpC,iBAAiB,EAAE,iBAAiB,GACpC,CACH,CAAC,EACF,YAAY,CACb;QACH,CAAC,CAAC,IAAI,CAAC;IAEX,OAAO,CACL,KAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa,YAEpC,MAAC,cAAc,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,iBAAiB,EAAE,aACtE,QAAQ,EACR,aAAa,IACU,GACT,CACpB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { useReducer, useState, useMemo, useContext, useRef, useEffect, memo } from 'react';\nimport type { ComponentType, Dispatch, Context, MutableRefObject, SetStateAction } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { createUID, windowIsAvailable } from '../../utils';\nimport '../../init';\nimport { useConfiguration } from '../../hooks';\nimport type { DeferInfer } from '../../types';\n\nimport PreviewPanel from './PreviewPanel';\nimport type {\n PreviewOptions,\n PreviewManagerContextValue,\n PreviewMethods,\n PreviewObject,\n PreviewManagerProps\n} from './Preview.types';\nimport { PreviewContext, PreviewManagerContext } from './Contexts';\n\ndeclare module '../../init' {\n export interface CosmosGlobals {\n previewManagerContext?: Context<PreviewManagerContextValue>;\n }\n}\n\ntype PreviewReducerPayload<P extends object> =\n | { type: 'create'; preview: PreviewObject<P> }\n | { type: 'update'; id: string; props: Partial<P>; options?: Partial<PreviewOptions> }\n | { type: 'unmount'; id: string };\n\nconst reducer = <P extends object>(\n previews: PreviewObject[] | [],\n payload: PreviewReducerPayload<P>\n): PreviewObject<object>[] => {\n switch (payload.type) {\n case 'create':\n // Stub for multiple preview support\n // return [...previews, payload.preview as unknown as PreviewObject<object>];\n return [payload.preview as unknown as PreviewObject<object>];\n\n case 'update':\n return previews.map(preview =>\n preview.id === payload.id\n ? {\n ...preview,\n props: { ...preview.props, ...payload.props },\n options: {\n ...preview.options,\n ...payload.options,\n previewProps: {\n ...preview.options?.previewProps,\n ...payload.options?.previewProps\n }\n }\n }\n : preview\n );\n\n case 'unmount':\n return previews.filter(preview => preview.id !== payload.id);\n\n default:\n return previews;\n }\n};\n\nconst WrappedPreview = memo(\n ({\n Component,\n props,\n options,\n previewStateSetter,\n previewTriggerRef,\n methods\n }: PreviewObject & {\n previewStateSetter: Dispatch<SetStateAction<boolean>>;\n previewTriggerRef: MutableRefObject<HTMLElement | null>;\n }) => {\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n // This state change is required to transition the case preview in.\n const [open, setOpen] = useState(false);\n const openRef = useRef(false);\n\n const cleanupPreview = () => {\n setOpen(false);\n openRef.current = false;\n previewStateSetter(false);\n optionsRef.current?.previewProps.onAfterClose?.();\n methods.unmountPreview();\n };\n\n useEffect(() => {\n setOpen(true);\n openRef.current = true;\n previewStateSetter(true);\n return () => {\n // Guard with openRef so we don't double-fire if already closed via the close button.\n if (openRef.current) {\n optionsRef.current?.previewProps.onBeforeClose?.();\n cleanupPreview();\n }\n };\n }, []);\n\n return (\n <PreviewContext.Provider\n // eslint-disable-next-line react/jsx-no-constructed-context-values\n value={{\n initialized: true,\n previewTriggerRef,\n ...methods\n }}\n >\n <PreviewPanel\n open={open}\n {...options?.previewProps}\n onAfterClose={() => {\n cleanupPreview();\n }}\n >\n <Component {...(props as Record<string, unknown>)} />\n </PreviewPanel>\n </PreviewContext.Provider>\n );\n }\n);\n\nconst PreviewManager = ({ children }: PreviewManagerProps) => {\n const [previews, dispatch] = useReducer(reducer, []);\n const [previewActive, setPreviewActive] = useState(false);\n const previewTriggerRef = useRef<HTMLElement | null>(null);\n const { portalTarget } = useConfiguration();\n\n const providerValue = useMemo(\n () => ({\n previewActive,\n setPreviewActive,\n createPreview: <P extends object>(\n Component: ComponentType<P>,\n props?: DeferInfer<P>,\n options?: PreviewOptions\n ): PreviewMethods<P> => {\n const id = createUID();\n\n const methods = {\n updatePreview: (updatedProps: Partial<P>, updatedOptions?: Partial<PreviewOptions>) => {\n (dispatch as Dispatch<PreviewReducerPayload<P>>)({\n type: 'update',\n id,\n props: updatedProps,\n options: updatedOptions\n });\n },\n unmountPreview: () => {\n dispatch({ type: 'unmount', id });\n }\n };\n\n (dispatch as Dispatch<PreviewReducerPayload<P>>)({\n type: 'create',\n preview: {\n id,\n Component,\n methods,\n props: (props ?? {}) as P,\n options\n }\n });\n\n return methods;\n },\n PreviewContext,\n initialized: true\n }),\n [previewActive]\n );\n\n const context = windowIsAvailable\n ? window.cosmos.previewManagerContext ?? PreviewManagerContext\n : PreviewManagerContext;\n const priorCtx = useContext(context);\n\n // Don't create additional Preview managers.\n if (priorCtx.initialized) return <context.Provider value={priorCtx}>{children}</context.Provider>;\n\n const previewPortal =\n portalTarget && previews.length > 0\n ? createPortal(\n previews.map(preview => (\n <WrappedPreview\n {...preview}\n key={preview.id}\n previewStateSetter={setPreviewActive}\n previewTriggerRef={previewTriggerRef}\n />\n )),\n portalTarget\n )\n : null;\n\n return (\n <context.Provider value={providerValue}>\n {/* eslint-disable-next-line react/jsx-no-constructed-context-values */}\n <PreviewContext.Provider value={{ initialized: false, previewTriggerRef }}>\n {children}\n {previewPortal}\n </PreviewContext.Provider>\n </context.Provider>\n );\n};\n\nexport default PreviewManager;\n"]}
1
+ {"version":3,"file":"PreviewManager.js","sourceRoot":"","sources":["../../../src/components/Preview/PreviewManager.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAE3F,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG9D,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAQ1C,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAcnE,MAAM,OAAO,GAAG,CACd,QAA8B,EAC9B,OAAiC,EACR,EAAE;IAC3B,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,QAAQ;YACX,oCAAoC;YACpC,6EAA6E;YAC7E,OAAO,CAAC,OAAO,CAAC,OAA2C,CAAC,CAAC;QAE/D,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAC5B,OAAO,CAAC,EAAE,KAAK,OAAO,CAAC,EAAE;gBACvB,CAAC,CAAC;oBACE,GAAG,OAAO;oBACV,KAAK,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,GAA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,QAAQ,IAAC,KAAK,EAAE,QAAQ,YAAG,QAAQ,GAAoB,CAAC;IAElG,MAAM,aAAa,GACjB,YAAY,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QACjC,CAAC,CAAC,YAAY,CACV,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CACtB,eAAC,cAAc,OACT,OAAO,EACX,GAAG,EAAE,OAAO,CAAC,EAAE,EACf,kBAAkB,EAAE,gBAAgB,EACpC,iBAAiB,EAAE,iBAAiB,GACpC,CACH,CAAC,EACF,YAAY,CACb;QACH,CAAC,CAAC,IAAI,CAAC;IAEX,OAAO,CACL,KAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa,YAEpC,MAAC,cAAc,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,iBAAiB,EAAE,aACtE,QAAQ,EACR,aAAa,IACU,GACT,CACpB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { useReducer, useState, useMemo, useContext, useRef, useEffect, memo } from 'react';\nimport type { ComponentType, Dispatch, Context, MutableRefObject, SetStateAction } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { createUID, windowIsAvailable } from '../../utils';\nimport '../../init';\nimport { useBreakpoint, useConfiguration } from '../../hooks';\nimport type { DeferInfer } from '../../types';\n\nimport PreviewPanel from './PreviewPanel';\nimport type {\n PreviewOptions,\n PreviewManagerContextValue,\n PreviewMethods,\n PreviewObject,\n PreviewManagerProps\n} from './Preview.types';\nimport { PreviewContext, PreviewManagerContext } from './Contexts';\n\ndeclare module '../../init' {\n export interface CosmosGlobals {\n previewManagerContext?: Context<PreviewManagerContextValue>;\n }\n}\n\ntype PreviewReducerPayload<P extends object> =\n | { type: 'create'; preview: PreviewObject<P> }\n | { type: 'update'; id: string; props: Partial<P>; options?: Partial<PreviewOptions> }\n | { type: 'unmount'; id: string }\n | { type: 'clear' };\n\nconst reducer = <P extends object>(\n previews: PreviewObject[] | [],\n payload: PreviewReducerPayload<P>\n): PreviewObject<object>[] => {\n switch (payload.type) {\n case 'create':\n // Stub for multiple preview support\n // return [...previews, payload.preview as unknown as PreviewObject<object>];\n return [payload.preview as unknown as PreviewObject<object>];\n\n case 'update':\n return previews.map(preview =>\n preview.id === payload.id\n ? {\n ...preview,\n props: { ...preview.props, ...payload.props },\n options: {\n ...preview.options,\n ...payload.options,\n previewProps: {\n ...preview.options?.previewProps,\n ...payload.options?.previewProps\n }\n }\n }\n : preview\n );\n\n case 'unmount':\n return previews.filter(preview => preview.id !== payload.id);\n\n case 'clear':\n return [];\n\n default:\n return previews;\n }\n};\n\nconst WrappedPreview = memo(\n ({\n Component,\n props,\n options,\n previewStateSetter,\n previewTriggerRef,\n methods\n }: PreviewObject & {\n previewStateSetter: Dispatch<SetStateAction<boolean>>;\n previewTriggerRef: MutableRefObject<HTMLElement | null>;\n }) => {\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n // This state change is required to transition the case preview in.\n const [open, setOpen] = useState(false);\n const openRef = useRef(false);\n\n const cleanupPreview = () => {\n setOpen(false);\n openRef.current = false;\n previewStateSetter(false);\n optionsRef.current?.previewProps.onAfterClose?.();\n methods.unmountPreview();\n };\n\n useEffect(() => {\n setOpen(true);\n openRef.current = true;\n previewStateSetter(true);\n return () => {\n // Guard with openRef so we don't double-fire if already closed via the close button.\n if (openRef.current) {\n optionsRef.current?.previewProps.onBeforeClose?.();\n cleanupPreview();\n }\n };\n }, []);\n\n return (\n <PreviewContext.Provider\n // eslint-disable-next-line react/jsx-no-constructed-context-values\n value={{\n initialized: true,\n previewTriggerRef,\n ...methods\n }}\n >\n <PreviewPanel\n open={open}\n {...options?.previewProps}\n onAfterClose={() => {\n cleanupPreview();\n }}\n >\n <Component {...(props as Record<string, unknown>)} />\n </PreviewPanel>\n </PreviewContext.Provider>\n );\n }\n);\n\nconst PreviewManager = ({ children }: PreviewManagerProps) => {\n const [previews, dispatch] = useReducer(reducer, []);\n const [previewActive, setPreviewActive] = useState(false);\n const previewTriggerRef = useRef<HTMLElement | null>(null);\n const { portalTarget } = useConfiguration();\n const isSmallOrAbove = useBreakpoint('sm');\n\n // Dismiss all previews when screen size reflows below sm breakpoint\n useEffect(() => {\n if (!isSmallOrAbove && previews.length > 0) {\n dispatch({ type: 'clear' });\n }\n }, [isSmallOrAbove, previews.length]);\n\n const providerValue = useMemo(\n () => ({\n previewActive,\n setPreviewActive,\n createPreview: <P extends object>(\n Component: ComponentType<P>,\n props?: DeferInfer<P>,\n options?: PreviewOptions\n ): PreviewMethods<P> => {\n const id = createUID();\n\n const methods = {\n updatePreview: (updatedProps: Partial<P>, updatedOptions?: Partial<PreviewOptions>) => {\n (dispatch as Dispatch<PreviewReducerPayload<P>>)({\n type: 'update',\n id,\n props: updatedProps,\n options: updatedOptions\n });\n },\n unmountPreview: () => {\n dispatch({ type: 'unmount', id });\n }\n };\n\n (dispatch as Dispatch<PreviewReducerPayload<P>>)({\n type: 'create',\n preview: {\n id,\n Component,\n methods,\n props: (props ?? {}) as P,\n options\n }\n });\n\n return methods;\n },\n PreviewContext,\n initialized: true\n }),\n [previewActive]\n );\n\n const context = windowIsAvailable\n ? window.cosmos.previewManagerContext ?? PreviewManagerContext\n : PreviewManagerContext;\n const priorCtx = useContext(context);\n\n // Don't create additional Preview managers.\n if (priorCtx.initialized) return <context.Provider value={priorCtx}>{children}</context.Provider>;\n\n const previewPortal =\n portalTarget && previews.length > 0\n ? createPortal(\n previews.map(preview => (\n <WrappedPreview\n {...preview}\n key={preview.id}\n previewStateSetter={setPreviewActive}\n previewTriggerRef={previewTriggerRef}\n />\n )),\n portalTarget\n )\n : null;\n\n return (\n <context.Provider value={providerValue}>\n {/* eslint-disable-next-line react/jsx-no-constructed-context-values */}\n <PreviewContext.Provider value={{ initialized: false, previewTriggerRef }}>\n {children}\n {previewPortal}\n </PreviewContext.Provider>\n </context.Provider>\n );\n};\n\nexport default PreviewManager;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PreviewPanel.d.ts","sourceRoot":"","sources":["../../../src/components/Preview/PreviewPanel.tsx"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAIzD,eAAO,MAAM,mBAAmB,mVA2B9B,CAAC;;;;AA4HH,wBAAiE"}
1
+ {"version":3,"file":"PreviewPanel.d.ts","sourceRoot":"","sources":["../../../src/components/Preview/PreviewPanel.tsx"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAIzD,eAAO,MAAM,mBAAmB,mVA2B9B,CAAC;;;;AAqIH,wBAAiE"}