@pega/cosmos-react-core 2.0.0-dev.16.1 → 2.0.0-dev.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/lib/components/AppShell/AppShell.d.ts.map +1 -1
  2. package/lib/components/AppShell/AppShell.js +24 -7
  3. package/lib/components/AppShell/AppShell.js.map +1 -1
  4. package/lib/components/AppShell/AppShell.styles.d.ts +11 -2
  5. package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -1
  6. package/lib/components/AppShell/AppShell.styles.js +61 -23
  7. package/lib/components/AppShell/AppShell.styles.js.map +1 -1
  8. package/lib/components/AppShell/AppShell.types.d.ts +2 -2
  9. package/lib/components/AppShell/AppShell.types.d.ts.map +1 -1
  10. package/lib/components/AppShell/AppShell.types.js.map +1 -1
  11. package/lib/components/AppShell/AppShellList.d.ts +4 -3
  12. package/lib/components/AppShell/AppShellList.d.ts.map +1 -1
  13. package/lib/components/AppShell/AppShellList.js +17 -9
  14. package/lib/components/AppShell/AppShellList.js.map +1 -1
  15. package/lib/components/AppShell/Drawer.d.ts.map +1 -1
  16. package/lib/components/AppShell/Drawer.js +3 -1
  17. package/lib/components/AppShell/Drawer.js.map +1 -1
  18. package/lib/components/AppShell/SkipNavigation.d.ts.map +1 -1
  19. package/lib/components/AppShell/SkipNavigation.js +29 -38
  20. package/lib/components/AppShell/SkipNavigation.js.map +1 -1
  21. package/lib/components/Badges/Selection.d.ts.map +1 -1
  22. package/lib/components/Badges/Selection.js +3 -1
  23. package/lib/components/Badges/Selection.js.map +1 -1
  24. package/lib/components/Banner/Banner.d.ts.map +1 -1
  25. package/lib/components/Banner/Banner.js +3 -1
  26. package/lib/components/Banner/Banner.js.map +1 -1
  27. package/lib/components/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
  28. package/lib/components/Breadcrumbs/Breadcrumbs.js +4 -1
  29. package/lib/components/Breadcrumbs/Breadcrumbs.js.map +1 -1
  30. package/lib/components/Button/Button.d.ts.map +1 -1
  31. package/lib/components/Button/Button.js +2 -2
  32. package/lib/components/Button/Button.js.map +1 -1
  33. package/lib/components/Card/CollapsibleCard.d.ts.map +1 -1
  34. package/lib/components/Card/CollapsibleCard.js +3 -1
  35. package/lib/components/Card/CollapsibleCard.js.map +1 -1
  36. package/lib/components/ComboBox/ComboBox.d.ts.map +1 -1
  37. package/lib/components/ComboBox/ComboBox.js +4 -1
  38. package/lib/components/ComboBox/ComboBox.js.map +1 -1
  39. package/lib/components/Configuration/Configuration.js +2 -2
  40. package/lib/components/Configuration/Configuration.js.map +1 -1
  41. package/lib/components/Currency/CurrencyDisplay.d.ts +2 -0
  42. package/lib/components/Currency/CurrencyDisplay.d.ts.map +1 -1
  43. package/lib/components/Currency/CurrencyDisplay.js +3 -2
  44. package/lib/components/Currency/CurrencyDisplay.js.map +1 -1
  45. package/lib/components/Currency/CurrencyInput.d.ts.map +1 -1
  46. package/lib/components/Currency/CurrencyInput.js +2 -2
  47. package/lib/components/Currency/CurrencyInput.js.map +1 -1
  48. package/lib/components/Currency/CurrencyInput.types.d.ts +2 -0
  49. package/lib/components/Currency/CurrencyInput.types.d.ts.map +1 -1
  50. package/lib/components/Currency/CurrencyInput.types.js.map +1 -1
  51. package/lib/components/DateTime/Input/DateInput.d.ts.map +1 -1
  52. package/lib/components/DateTime/Input/DateInput.js +4 -1
  53. package/lib/components/DateTime/Input/DateInput.js.map +1 -1
  54. package/lib/components/DateTime/Input/DateTimeInput.d.ts.map +1 -1
  55. package/lib/components/DateTime/Input/DateTimeInput.js +4 -1
  56. package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
  57. package/lib/components/DateTime/Input/TimeInput.d.ts.map +1 -1
  58. package/lib/components/DateTime/Input/TimeInput.js +4 -1
  59. package/lib/components/DateTime/Input/TimeInput.js.map +1 -1
  60. package/lib/components/DateTime/Input/WeekInput.d.ts.map +1 -1
  61. package/lib/components/DateTime/Input/WeekInput.js +4 -1
  62. package/lib/components/DateTime/Input/WeekInput.js.map +1 -1
  63. package/lib/components/DateTime/Input/useAutoFocusNextInput.d.ts.map +1 -1
  64. package/lib/components/DateTime/Input/useAutoFocusNextInput.js +6 -4
  65. package/lib/components/DateTime/Input/useAutoFocusNextInput.js.map +1 -1
  66. package/lib/components/DateTime/Picker/DatePicker.d.ts.map +1 -1
  67. package/lib/components/DateTime/Picker/DatePicker.js +4 -1
  68. package/lib/components/DateTime/Picker/DatePicker.js.map +1 -1
  69. package/lib/components/DateTime/Picker/DateRangePicker.d.ts.map +1 -1
  70. package/lib/components/DateTime/Picker/DateRangePicker.js +4 -1
  71. package/lib/components/DateTime/Picker/DateRangePicker.js.map +1 -1
  72. package/lib/components/EmptyState/EmptyState.d.ts.map +1 -1
  73. package/lib/components/EmptyState/EmptyState.js +3 -1
  74. package/lib/components/EmptyState/EmptyState.js.map +1 -1
  75. package/lib/components/ErrorState/ErrorState.d.ts.map +1 -1
  76. package/lib/components/ErrorState/ErrorState.js +3 -1
  77. package/lib/components/ErrorState/ErrorState.js.map +1 -1
  78. package/lib/components/FieldGroup/FieldGroup.d.ts.map +1 -1
  79. package/lib/components/FieldGroup/FieldGroup.js +3 -1
  80. package/lib/components/FieldGroup/FieldGroup.js.map +1 -1
  81. package/lib/components/FieldGroup/FieldGroupList.d.ts.map +1 -1
  82. package/lib/components/FieldGroup/FieldGroupList.js +3 -1
  83. package/lib/components/FieldGroup/FieldGroupList.js.map +1 -1
  84. package/lib/components/File/FileInput.d.ts.map +1 -1
  85. package/lib/components/File/FileInput.js +3 -1
  86. package/lib/components/File/FileInput.js.map +1 -1
  87. package/lib/components/Form/Form.d.ts +4 -0
  88. package/lib/components/Form/Form.d.ts.map +1 -1
  89. package/lib/components/Form/Form.js +5 -2
  90. package/lib/components/Form/Form.js.map +1 -1
  91. package/lib/components/Location/CurrentLocationButton.d.ts.map +1 -1
  92. package/lib/components/Location/CurrentLocationButton.js +3 -1
  93. package/lib/components/Location/CurrentLocationButton.js.map +1 -1
  94. package/lib/components/Menu/Menu.d.ts.map +1 -1
  95. package/lib/components/Menu/Menu.js +48 -23
  96. package/lib/components/Menu/Menu.js.map +1 -1
  97. package/lib/components/Menu/MenuItem.d.ts.map +1 -1
  98. package/lib/components/Menu/MenuItem.js +5 -2
  99. package/lib/components/Menu/MenuItem.js.map +1 -1
  100. package/lib/components/Menu/MenuList.d.ts +1 -1
  101. package/lib/components/Menu/MenuList.d.ts.map +1 -1
  102. package/lib/components/Menu/MenuList.js +10 -10
  103. package/lib/components/Menu/MenuList.js.map +1 -1
  104. package/lib/components/MenuButton/MenuButton.d.ts +3 -1
  105. package/lib/components/MenuButton/MenuButton.d.ts.map +1 -1
  106. package/lib/components/MenuButton/MenuButton.js +5 -2
  107. package/lib/components/MenuButton/MenuButton.js.map +1 -1
  108. package/lib/components/Modal/MinimizedModal.d.ts.map +1 -1
  109. package/lib/components/Modal/MinimizedModal.js +5 -1
  110. package/lib/components/Modal/MinimizedModal.js.map +1 -1
  111. package/lib/components/Modal/Modal.d.ts.map +1 -1
  112. package/lib/components/Modal/Modal.js +7 -2
  113. package/lib/components/Modal/Modal.js.map +1 -1
  114. package/lib/components/Modal/Modal.styles.d.ts.map +1 -1
  115. package/lib/components/Modal/Modal.styles.js +6 -4
  116. package/lib/components/Modal/Modal.styles.js.map +1 -1
  117. package/lib/components/Number/NumberInput.d.ts.map +1 -1
  118. package/lib/components/Number/NumberInput.js +4 -1
  119. package/lib/components/Number/NumberInput.js.map +1 -1
  120. package/lib/components/Pagination/Pagination.d.ts.map +1 -1
  121. package/lib/components/Pagination/Pagination.js +4 -1
  122. package/lib/components/Pagination/Pagination.js.map +1 -1
  123. package/lib/components/Rating/Rating.d.ts.map +1 -1
  124. package/lib/components/Rating/Rating.js +4 -1
  125. package/lib/components/Rating/Rating.js.map +1 -1
  126. package/lib/components/SearchInput/SearchInput.d.ts.map +1 -1
  127. package/lib/components/SearchInput/SearchInput.js +3 -1
  128. package/lib/components/SearchInput/SearchInput.js.map +1 -1
  129. package/lib/components/Slider/Slider.d.ts.map +1 -1
  130. package/lib/components/Slider/Slider.js +3 -4
  131. package/lib/components/Slider/Slider.js.map +1 -1
  132. package/lib/components/Slider/Slider.styles.d.ts +3 -0
  133. package/lib/components/Slider/Slider.styles.d.ts.map +1 -1
  134. package/lib/components/Slider/Slider.styles.js +16 -4
  135. package/lib/components/Slider/Slider.styles.js.map +1 -1
  136. package/lib/components/Slider/SliderTicks.d.ts +1 -0
  137. package/lib/components/Slider/SliderTicks.d.ts.map +1 -1
  138. package/lib/components/Slider/SliderTicks.js +16 -8
  139. package/lib/components/Slider/SliderTicks.js.map +1 -1
  140. package/lib/components/Slider/utils.d.ts +10 -1
  141. package/lib/components/Slider/utils.d.ts.map +1 -1
  142. package/lib/components/Slider/utils.js +21 -3
  143. package/lib/components/Slider/utils.js.map +1 -1
  144. package/lib/components/SummaryItem/SummaryItem.d.ts +2 -2
  145. package/lib/components/SummaryItem/SummaryItem.d.ts.map +1 -1
  146. package/lib/components/SummaryItem/SummaryItem.js.map +1 -1
  147. package/lib/components/Switch/Switch.d.ts.map +1 -1
  148. package/lib/components/Switch/Switch.js +3 -1
  149. package/lib/components/Switch/Switch.js.map +1 -1
  150. package/lib/components/Toaster/Toaster.d.ts +8 -36
  151. package/lib/components/Toaster/Toaster.d.ts.map +1 -1
  152. package/lib/components/Toaster/Toaster.js +94 -95
  153. package/lib/components/Toaster/Toaster.js.map +1 -1
  154. package/lib/hooks/useAutoResize.d.ts.map +1 -1
  155. package/lib/hooks/useAutoResize.js +6 -7
  156. package/lib/hooks/useAutoResize.js.map +1 -1
  157. package/lib/hooks/useI18n.d.ts +6 -0
  158. package/lib/hooks/useI18n.d.ts.map +1 -1
  159. package/lib/i18n/default.json +8 -2
  160. package/lib/i18n/i18n.d.ts +12 -0
  161. package/lib/i18n/i18n.d.ts.map +1 -1
  162. package/lib/types/types.d.ts +2 -0
  163. package/lib/types/types.d.ts.map +1 -1
  164. package/lib/types/types.js.map +1 -1
  165. package/package.json +1 -2
@@ -4,8 +4,8 @@ import { useDirection } from '../../hooks';
4
4
  import { defaultThemeProp } from '../../theme';
5
5
  import { tryCatch } from '../../utils';
6
6
  import { StyledGrid } from '../Grid';
7
+ import { NumberDisplay } from '../Number';
7
8
  import StyledNumberInput from '../Number/NumberInput.styles';
8
- import { StyledText } from '../Text';
9
9
  export const StyledThumb = styled.div(({ theme: { base: { palette: { 'primary-background': bgColor, 'border-line': borderColor }, spacing, 'border-radius': borderRadius }, components: { progress: { 'progress-color': fgColor }, button } } }) => {
10
10
  const hoverBgColor = tryCatch(() => mix(0.2, fgColor, bgColor));
11
11
  return css `
@@ -104,13 +104,18 @@ export const StyledSliderTrackWrapper = styled.div `
104
104
  width: 100%;
105
105
  `;
106
106
  StyledSliderTrackWrapper.defaultProps = defaultThemeProp;
107
+ export const StyledPreview = styled(NumberDisplay) `
108
+ width: ${props => props.size}ch;
109
+ flex-shrink: 0;
110
+ `;
111
+ StyledPreview.defaultProps = defaultThemeProp;
107
112
  export const StyledSlider = styled.div(props => {
108
113
  const { theme: { base: { spacing, palette }, components: { 'form-field': formField } }, status, orientation } = props;
109
114
  const statusColor = status && formField[status] ? formField[status]['status-color'] : 'transparent';
110
115
  const thumbBgColor = tryCatch(() => mix(0.2, statusColor, palette['primary-background']));
111
116
  const borderColor = status && formField[status] ? formField[status]['status-color'] : palette['border-line'];
112
117
  return css `
113
- ${StyledText} {
118
+ > span {
114
119
  line-height: calc(${spacing} * 4);
115
120
  }
116
121
 
@@ -132,16 +137,23 @@ export const StyledSlider = styled.div(props => {
132
137
  ${orientation === 'horizontal' &&
133
138
  css `
134
139
  ${StyledSliderTrackWrapper} {
140
+ margin-inline: calc(1.5 * ${spacing});
141
+
135
142
  ${StyledTrack},
136
143
  ${StyledThumb} {
137
144
  grid-row: 1;
138
145
  }
139
146
 
147
+ ${StyledBar} {
148
+ /* extend by thumb width */
149
+ min-width: calc(100% + ${spacing} * 3);
150
+ }
151
+
140
152
  ${StyledTicksContainer} {
141
153
  grid-row: 2;
142
154
  }
143
155
 
144
- & + ${StyledNumberInput}, & + ${StyledText} {
156
+ & + ${StyledNumberInput}, & + ${StyledPreview} {
145
157
  margin-inline-start: calc(2 * ${spacing});
146
158
  }
147
159
  }
@@ -186,7 +198,7 @@ export const StyledSlider = styled.div(props => {
186
198
  height: 100%;
187
199
  }
188
200
 
189
- & + ${StyledNumberInput}, & + ${StyledText} {
201
+ & + ${StyledNumberInput}, & + ${StyledPreview} {
190
202
  margin-top: calc(2 * ${spacing});
191
203
  width: calc(${spacing} * 4);
192
204
  text-align: center;
@@ -1 +1 @@
1
- {"version":3,"file":"Slider.styles.js","sourceRoot":"","sources":["../../../src/components/Slider/Slider.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,iBAAiB,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAMrC,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CACnC,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,OAAO,EAAE,EAAE,oBAAoB,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,EACtE,OAAO,EACP,eAAe,EAAE,YAAY,EAC9B,EACD,UAAU,EAAE,EACV,QAAQ,EAAE,EAAE,gBAAgB,EAAE,OAAO,EAAE,EACvC,MAAM,EACP,EACF,EACF,EAAE,EAAE;IACH,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,EAA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EC,iBAAiB;YACnB,GAAG,CAAA;;;;;;OAMF;KACF;;MAEC,WAAW,KAAK,UAAU;QAC5B,GAAG,CAAA;;;;;iBAKU,OAAO;uBACD,OAAO;UACpB,GAAG;YACH,CAAC,CAAC,GAAG,CAAA;;aAEF;YACH,CAAC,CAAC,GAAG,CAAA;;aAEF;;KAER;;;;GAIF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE/C,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAA;;;;;;;CAO1C,CAAC;AAEF,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import { mix } from 'polished';\nimport styled, { css } from 'styled-components';\n\nimport { useDirection } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport { PropsWithDefaults } from '../../types';\nimport { tryCatch } from '../../utils';\nimport { FormControlProps } from '../FormControl';\nimport { StyledGrid } from '../Grid';\nimport StyledNumberInput from '../Number/NumberInput.styles';\nimport { StyledText } from '../Text';\n\nimport SliderProps from './Slider.types';\n\nexport type SliderPropsWithDefaults = PropsWithDefaults<SliderProps>;\n\nexport const StyledThumb = styled.div(\n ({\n theme: {\n base: {\n palette: { 'primary-background': bgColor, 'border-line': borderColor },\n spacing,\n 'border-radius': borderRadius\n },\n components: {\n progress: { 'progress-color': fgColor },\n button\n }\n }\n }) => {\n const hoverBgColor = tryCatch(() => mix(0.2, fgColor, bgColor));\n\n return css`\n border: ${button['border-width']} solid ${borderColor};\n border-radius: calc(${borderRadius} * 3);\n outline: none;\n background-color: ${bgColor};\n width: calc(${spacing} * 3);\n height: calc(${spacing} * 3);\n cursor: pointer;\n\n &:focus {\n box-shadow: ${button['focus-shadow']};\n }\n\n &:hover,\n &:active {\n background-color: ${hoverBgColor};\n border-color: ${fgColor};\n }\n `;\n }\n);\n\nStyledThumb.defaultProps = defaultThemeProp;\n\nexport const StyledBar = styled.div<{ showProgress?: boolean }>(({ theme, showProgress }) => {\n const {\n base: { spacing, colors, 'border-radius': borderRadius },\n components: {\n progress: { 'progress-color': progressColor }\n }\n } = theme;\n\n const { ltr } = useDirection();\n\n return css`\n border-radius: ${borderRadius};\n height: ${spacing};\n width: 100%;\n overflow: hidden;\n position: relative;\n background-color: ${colors.gray.light};\n\n ${showProgress &&\n css`\n ::before {\n position: absolute;\n left: 0;\n top: 0;\n content: '';\n display: block;\n width: 100%;\n height: 100%;\n background-color: ${progressColor};\n ${ltr\n ? css`\n transform: translateX(calc(-100% + var(--slider-value, 0)));\n `\n : css`\n transform: translateX(calc(100% - var(--slider-value, 0)));\n `}\n }\n `}\n `;\n});\n\nStyledBar.defaultProps = defaultThemeProp;\n\nexport const StyledTrack = styled.div(\n ({\n theme: {\n base: { spacing }\n }\n }) => {\n const { ltr } = useDirection();\n return css`\n height: calc(${spacing} * 4);\n width: 100%;\n cursor: pointer;\n position: relative;\n\n > ${StyledThumb} {\n z-index: 1;\n position: absolute;\n top: calc(${spacing} / 2);\n left: var(--slider-value);\n right: var(--slider-value);\n ${ltr\n ? css`\n transform: translate(-50%, 0);\n `\n : css`\n transform: translate(50%, 0);\n `}\n }\n `;\n }\n);\n\nStyledTrack.defaultProps = defaultThemeProp;\n\nexport const StyledTicksContainer = styled.div`\n width: 100%;\n\n div {\n &::before {\n content: '';\n display: table;\n background: ${p => p.theme.base.palette['foreground-color']};\n }\n }\n`;\n\nStyledTicksContainer.defaultProps = defaultThemeProp;\n\nexport const StyledSliderTrackWrapper = styled.div`\n width: 100%;\n`;\n\nStyledSliderTrackWrapper.defaultProps = defaultThemeProp;\n\nexport const StyledSlider = styled.div<{\n orientation: 'vertical' | 'horizontal';\n status: FormControlProps['status'];\n}>(props => {\n const {\n theme: {\n base: { spacing, palette },\n components: { 'form-field': formField }\n },\n status,\n orientation\n } = props;\n\n const statusColor =\n status && formField[status] ? formField[status]['status-color'] : 'transparent';\n const thumbBgColor = tryCatch(() => mix(0.2, statusColor, palette['primary-background']));\n\n const borderColor =\n status && formField[status] ? formField[status]['status-color'] : palette['border-line'];\n\n return css`\n ${StyledText} {\n line-height: calc(${spacing} * 4);\n }\n\n ${status &&\n css`\n ${StyledBar}::before {\n background-color: ${statusColor};\n }\n\n ${StyledThumb} {\n border-color: ${borderColor};\n :hover,\n :active {\n background-color: ${thumbBgColor};\n }\n }\n `}\n\n ${orientation === 'horizontal' &&\n css`\n ${StyledSliderTrackWrapper} {\n ${StyledTrack},\n ${StyledThumb} {\n grid-row: 1;\n }\n\n ${StyledTicksContainer} {\n grid-row: 2;\n }\n\n & + ${StyledNumberInput}, & + ${StyledText} {\n margin-inline-start: calc(2 * ${spacing});\n }\n }\n `}\n\n /* disabling 'duplicate selectors' rule to keep the css rules grouped by orientation prop */\n\n /* stylelint-disable no-duplicate-selectors */\n ${orientation === 'vertical' &&\n css`\n ${StyledSliderTrackWrapper} {\n grid-template-columns: calc(${spacing} * 4) minmax(0, 1fr);\n grid-template-rows: 0.5em [track-start] minmax(calc(${spacing} * 20), max-content) [track-end] 0.5em;\n margin-top: ${spacing};\n\n ${StyledTrack} {\n grid-row: track-start / track-end;\n height: 100%;\n transform: scale(-1);\n\n ${StyledBar} {\n height: 100%;\n width: ${spacing};\n\n ::before {\n transform: translateY(calc(-100% + var(--slider-value, 0)));\n }\n }\n }\n\n ${StyledThumb} {\n grid-row: track-start / track-end;\n top: auto;\n bottom: calc(100% - var(--slider-value));\n left: calc(${spacing} / 2);\n right: calc(${spacing} / 2);\n transform: translate(0, 50%);\n }\n\n ${StyledTicksContainer} {\n grid-row: 1 / -1;\n height: 100%;\n }\n\n & + ${StyledNumberInput}, & + ${StyledText} {\n margin-top: calc(2 * ${spacing});\n width: calc(${spacing} * 4);\n text-align: center;\n\n /* fix NumberInput double padding issue */\n &,\n & > input {\n padding: 0;\n }\n }\n }\n `}\n\n /* stylelint-enable no-duplicate-selectors */\n\n\n &[disabled],\n &[readonly] {\n ${StyledTrack} {\n cursor: default;\n }\n\n ${StyledThumb} {\n cursor: default;\n border-color: ${palette['border-line']};\n :hover,\n :active {\n background-color: ${palette['background-color']};\n }\n }\n }\n `;\n});\n\nStyledSlider.defaultProps = defaultThemeProp;\n\nexport const StyledTickItem = styled(StyledGrid)<{\n lowerBoundaryItem?: boolean;\n upperBoundaryItem?: boolean;\n orientation: 'horizontal' | 'vertical';\n}>(({ lowerBoundaryItem, upperBoundaryItem, orientation, theme }) => {\n const spacing = theme.base.spacing;\n\n const { ltr } = useDirection();\n\n return css`\n /* disabling 'duplicate selectors' rule to keep the css rules grouped by orientation prop */\n\n /* stylelint-disable no-duplicate-selectors */\n ${orientation === 'horizontal' &&\n css`\n text-align: center;\n text-overflow: ellipsis;\n white-space: nowrap;\n &::before {\n width: 0.0625rem;\n height: ${spacing};\n transform: translateY(-50%);\n margin: 0 auto;\n }\n\n ${lowerBoundaryItem &&\n css`\n text-align: start;\n transform: translate(-0.5ch, 0);\n &::before {\n margin-inline-start: 0.5ch;\n }\n `}\n\n ${upperBoundaryItem &&\n css`\n text-align: end;\n transform: translate(0.5ch, 0);\n &::before {\n margin-inline-end: 0.5ch;\n }\n `}\n `}\n\n ${orientation === 'vertical' &&\n css`\n display: flex;\n align-items: center;\n\n &::before {\n width: ${spacing};\n height: calc(${spacing} / 8);\n ${ltr\n ? css`\n transform: translateX(-50%);\n `\n : css`\n transform: translateX(50%);\n `}\n }\n `}\n\n /* stylelint-enable no-duplicate-selectors */\n overflow: hidden;\n `;\n});\n\nStyledTickItem.defaultProps = defaultThemeProp;\n\nexport const StyledTickButton = styled.span`\n cursor: pointer;\n line-height: 1em;\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n outline: 0;\n`;\n\nStyledTickButton.defaultProps = defaultThemeProp;\n"]}
1
+ {"version":3,"file":"Slider.styles.js","sourceRoot":"","sources":["../../../src/components/Slider/Slider.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,MAA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AC,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAA;;;;;;;CAO1C,CAAC;AAEF,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import { mix } from 'polished';\nimport styled, { css } from 'styled-components';\n\nimport { useDirection } from '../../hooks';\nimport { defaultThemeProp } from '../../theme';\nimport { PropsWithDefaults } from '../../types';\nimport { tryCatch } from '../../utils';\nimport { FormControlProps } from '../FormControl';\nimport { StyledGrid } from '../Grid';\nimport { NumberDisplay } from '../Number';\nimport StyledNumberInput from '../Number/NumberInput.styles';\n\nimport SliderProps from './Slider.types';\n\nexport type SliderPropsWithDefaults = PropsWithDefaults<SliderProps>;\n\nexport const StyledThumb = styled.div(\n ({\n theme: {\n base: {\n palette: { 'primary-background': bgColor, 'border-line': borderColor },\n spacing,\n 'border-radius': borderRadius\n },\n components: {\n progress: { 'progress-color': fgColor },\n button\n }\n }\n }) => {\n const hoverBgColor = tryCatch(() => mix(0.2, fgColor, bgColor));\n\n return css`\n border: ${button['border-width']} solid ${borderColor};\n border-radius: calc(${borderRadius} * 3);\n outline: none;\n background-color: ${bgColor};\n width: calc(${spacing} * 3);\n height: calc(${spacing} * 3);\n cursor: pointer;\n\n &:focus {\n box-shadow: ${button['focus-shadow']};\n }\n\n &:hover,\n &:active {\n background-color: ${hoverBgColor};\n border-color: ${fgColor};\n }\n `;\n }\n);\n\nStyledThumb.defaultProps = defaultThemeProp;\n\nexport const StyledBar = styled.div<{ showProgress?: boolean }>(({ theme, showProgress }) => {\n const {\n base: { spacing, colors, 'border-radius': borderRadius },\n components: {\n progress: { 'progress-color': progressColor }\n }\n } = theme;\n\n const { ltr } = useDirection();\n\n return css`\n border-radius: ${borderRadius};\n height: ${spacing};\n width: 100%;\n overflow: hidden;\n position: relative;\n background-color: ${colors.gray.light};\n\n ${showProgress &&\n css`\n ::before {\n position: absolute;\n left: 0;\n top: 0;\n content: '';\n display: block;\n width: 100%;\n height: 100%;\n background-color: ${progressColor};\n ${ltr\n ? css`\n transform: translateX(calc(-100% + var(--slider-value, 0)));\n `\n : css`\n transform: translateX(calc(100% - var(--slider-value, 0)));\n `}\n }\n `}\n `;\n});\n\nStyledBar.defaultProps = defaultThemeProp;\n\nexport const StyledTrack = styled.div(\n ({\n theme: {\n base: { spacing }\n }\n }) => {\n const { ltr } = useDirection();\n return css`\n height: calc(${spacing} * 4);\n width: 100%;\n cursor: pointer;\n position: relative;\n\n > ${StyledThumb} {\n z-index: 1;\n position: absolute;\n top: calc(${spacing} / 2);\n left: var(--slider-value);\n right: var(--slider-value);\n ${ltr\n ? css`\n transform: translate(-50%, 0);\n `\n : css`\n transform: translate(50%, 0);\n `}\n }\n `;\n }\n);\n\nStyledTrack.defaultProps = defaultThemeProp;\n\nexport const StyledTicksContainer = styled.div`\n width: 100%;\n\n div {\n &::before {\n content: '';\n display: table;\n background: ${p => p.theme.base.palette['foreground-color']};\n }\n }\n`;\n\nStyledTicksContainer.defaultProps = defaultThemeProp;\n\nexport const StyledSliderTrackWrapper = styled.div`\n width: 100%;\n`;\n\nStyledSliderTrackWrapper.defaultProps = defaultThemeProp;\n\nexport const StyledPreview = styled(NumberDisplay)<{ size: number }>`\n width: ${props => props.size}ch;\n flex-shrink: 0;\n`;\n\nStyledPreview.defaultProps = defaultThemeProp;\n\nexport const StyledSlider = styled.div<{\n orientation: 'vertical' | 'horizontal';\n status: FormControlProps['status'];\n}>(props => {\n const {\n theme: {\n base: { spacing, palette },\n components: { 'form-field': formField }\n },\n status,\n orientation\n } = props;\n\n const statusColor =\n status && formField[status] ? formField[status]['status-color'] : 'transparent';\n const thumbBgColor = tryCatch(() => mix(0.2, statusColor, palette['primary-background']));\n\n const borderColor =\n status && formField[status] ? formField[status]['status-color'] : palette['border-line'];\n\n return css`\n > span {\n line-height: calc(${spacing} * 4);\n }\n\n ${status &&\n css`\n ${StyledBar}::before {\n background-color: ${statusColor};\n }\n\n ${StyledThumb} {\n border-color: ${borderColor};\n :hover,\n :active {\n background-color: ${thumbBgColor};\n }\n }\n `}\n\n ${orientation === 'horizontal' &&\n css`\n ${StyledSliderTrackWrapper} {\n margin-inline: calc(1.5 * ${spacing});\n\n ${StyledTrack},\n ${StyledThumb} {\n grid-row: 1;\n }\n\n ${StyledBar} {\n /* extend by thumb width */\n min-width: calc(100% + ${spacing} * 3);\n }\n\n ${StyledTicksContainer} {\n grid-row: 2;\n }\n\n & + ${StyledNumberInput}, & + ${StyledPreview} {\n margin-inline-start: calc(2 * ${spacing});\n }\n }\n `}\n\n /* disabling 'duplicate selectors' rule to keep the css rules grouped by orientation prop */\n\n /* stylelint-disable no-duplicate-selectors */\n ${orientation === 'vertical' &&\n css`\n ${StyledSliderTrackWrapper} {\n grid-template-columns: calc(${spacing} * 4) minmax(0, 1fr);\n grid-template-rows: 0.5em [track-start] minmax(calc(${spacing} * 20), max-content) [track-end] 0.5em;\n margin-top: ${spacing};\n\n ${StyledTrack} {\n grid-row: track-start / track-end;\n height: 100%;\n transform: scale(-1);\n\n ${StyledBar} {\n height: 100%;\n width: ${spacing};\n\n ::before {\n transform: translateY(calc(-100% + var(--slider-value, 0)));\n }\n }\n }\n\n ${StyledThumb} {\n grid-row: track-start / track-end;\n top: auto;\n bottom: calc(100% - var(--slider-value));\n left: calc(${spacing} / 2);\n right: calc(${spacing} / 2);\n transform: translate(0, 50%);\n }\n\n ${StyledTicksContainer} {\n grid-row: 1 / -1;\n height: 100%;\n }\n\n & + ${StyledNumberInput}, & + ${StyledPreview} {\n margin-top: calc(2 * ${spacing});\n width: calc(${spacing} * 4);\n text-align: center;\n\n /* fix NumberInput double padding issue */\n &,\n & > input {\n padding: 0;\n }\n }\n }\n `}\n\n /* stylelint-enable no-duplicate-selectors */\n\n\n &[disabled],\n &[readonly] {\n ${StyledTrack} {\n cursor: default;\n }\n\n ${StyledThumb} {\n cursor: default;\n border-color: ${palette['border-line']};\n :hover,\n :active {\n background-color: ${palette['background-color']};\n }\n }\n }\n `;\n});\n\nStyledSlider.defaultProps = defaultThemeProp;\n\nexport const StyledTickItem = styled(StyledGrid)<{\n lowerBoundaryItem?: boolean;\n upperBoundaryItem?: boolean;\n orientation: 'horizontal' | 'vertical';\n}>(({ lowerBoundaryItem, upperBoundaryItem, orientation, theme }) => {\n const spacing = theme.base.spacing;\n\n const { ltr } = useDirection();\n\n return css`\n /* disabling 'duplicate selectors' rule to keep the css rules grouped by orientation prop */\n\n /* stylelint-disable no-duplicate-selectors */\n ${orientation === 'horizontal' &&\n css`\n text-align: center;\n text-overflow: ellipsis;\n white-space: nowrap;\n &::before {\n width: 0.0625rem;\n height: ${spacing};\n transform: translateY(-50%);\n margin: 0 auto;\n }\n\n ${lowerBoundaryItem &&\n css`\n text-align: start;\n transform: translate(-0.5ch, 0);\n &::before {\n margin-inline-start: 0.5ch;\n }\n `}\n\n ${upperBoundaryItem &&\n css`\n text-align: end;\n transform: translate(0.5ch, 0);\n &::before {\n margin-inline-end: 0.5ch;\n }\n `}\n `}\n\n ${orientation === 'vertical' &&\n css`\n display: flex;\n align-items: center;\n\n &::before {\n width: ${spacing};\n height: calc(${spacing} / 8);\n ${ltr\n ? css`\n transform: translateX(-50%);\n `\n : css`\n transform: translateX(50%);\n `}\n }\n `}\n\n /* stylelint-enable no-duplicate-selectors */\n overflow: hidden;\n `;\n});\n\nStyledTickItem.defaultProps = defaultThemeProp;\n\nexport const StyledTickButton = styled.span`\n cursor: pointer;\n line-height: 1em;\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n outline: 0;\n`;\n\nStyledTickButton.defaultProps = defaultThemeProp;\n"]}
@@ -4,6 +4,7 @@ interface SliderTicksProps {
4
4
  ticks: NonNullable<SliderProps['ticks']>;
5
5
  min: number;
6
6
  max: number;
7
+ step: number;
7
8
  orientation: NonNullable<SliderProps['orientation']>;
8
9
  onClick: (value: number) => void;
9
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SliderTicks.d.ts","sourceRoot":"","sources":["../../../src/components/Slider/SliderTicks.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAW,MAAM,OAAO,CAAC;AAKpC,OAAO,WAAW,MAAM,gBAAgB,CAAC;AAGzC,UAAU,gBAAgB;IACxB,KAAK,EAAE,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;IACrD,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAuDrC,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"SliderTicks.d.ts","sourceRoot":"","sources":["../../../src/components/Slider/SliderTicks.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAW,MAAM,OAAO,CAAC;AAKpC,OAAO,WAAW,MAAM,gBAAgB,CAAC;AAGzC,UAAU,gBAAgB;IACxB,KAAK,EAAE,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;IACrD,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CA2DrC,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -3,14 +3,22 @@ import { useMemo } from 'react';
3
3
  import Grid from '../Grid';
4
4
  import { StyledTickButton, StyledTickItem, StyledTicksContainer } from './Slider.styles';
5
5
  import { calculateTicksRegions } from './utils';
6
- const SliderTicks = ({ ticks, min, max, orientation, onClick }) => {
7
- const cellsCount = max - min + 1;
8
- const ticksDefinitions = useMemo(() => calculateTicksRegions(ticks, min, max, orientation === 'horizontal'), [ticks, min, max, orientation]);
9
- return (_jsx(Grid, Object.assign({ container: orientation === 'horizontal'
10
- ? {
11
- cols: `minmax(0, 0.5fr) repeat(${cellsCount - 2}, minmax(0, 1fr)) minmax(0, 0.5fr)`
12
- }
13
- : { rows: `repeat(${cellsCount}, 1em)`, alignContent: 'between' }, as: StyledTicksContainer }, { children: ticksDefinitions.map(tick => {
6
+ const SliderTicks = ({ ticks, min, max, step, orientation, onClick }) => {
7
+ const cellsCount = (max - min) / step + 1;
8
+ const ticksDefinitions = useMemo(() => calculateTicksRegions(ticks, min, max, step, orientation === 'horizontal'), [ticks, min, max, orientation]);
9
+ let repeatCells;
10
+ let gridContainerConfig;
11
+ if (orientation === 'horizontal') {
12
+ repeatCells = cellsCount > 2 ? `repeat(${cellsCount - 2}, minmax(0, 1fr))` : '';
13
+ gridContainerConfig = {
14
+ cols: `minmax(0, 0.5fr) ${repeatCells} minmax(0, 0.5fr)`
15
+ };
16
+ }
17
+ else {
18
+ repeatCells = `repeat(${cellsCount}, 1em)`;
19
+ gridContainerConfig = { rows: repeatCells, alignContent: 'between' };
20
+ }
21
+ return (_jsx(Grid, Object.assign({ container: gridContainerConfig, as: StyledTicksContainer }, { children: ticksDefinitions.map(tick => {
14
22
  return (_jsx(StyledTickItem, Object.assign({ item: orientation === 'horizontal'
15
23
  ? {
16
24
  colStartEnd: `${tick.start} / ${tick.end}`
@@ -1 +1 @@
1
- {"version":3,"file":"SliderTicks.js","sourceRoot":"","sources":["../../../src/components/Slider/SliderTicks.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,OAAO,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAA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K,CAAC,gBAEjC,IAAI,CAAC,KAAK,YACM,KAZd,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAad,CAClB,CAAC;QACJ,CAAC,CAAC,YACG,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { FC, useMemo } from 'react';\n\nimport Grid from '../Grid';\n\nimport { StyledTickButton, StyledTickItem, StyledTicksContainer } from './Slider.styles';\nimport SliderProps from './Slider.types';\nimport { calculateTicksRegions } from './utils';\n\ninterface SliderTicksProps {\n ticks: NonNullable<SliderProps['ticks']>;\n min: number;\n max: number;\n orientation: NonNullable<SliderProps['orientation']>;\n onClick: (value: number) => void;\n}\n\nconst SliderTicks: FC<SliderTicksProps> = ({\n ticks,\n min,\n max,\n orientation,\n onClick\n}: SliderTicksProps) => {\n const cellsCount = max - min + 1;\n\n const ticksDefinitions = useMemo(\n () => calculateTicksRegions(ticks, min, max, orientation === 'horizontal'),\n [ticks, min, max, orientation]\n );\n\n return (\n <Grid\n container={\n orientation === 'horizontal'\n ? {\n cols: `minmax(0, 0.5fr) repeat(${cellsCount - 2}, minmax(0, 1fr)) minmax(0, 0.5fr)`\n }\n : { rows: `repeat(${cellsCount}, 1em)`, alignContent: 'between' }\n }\n as={StyledTicksContainer}\n >\n {ticksDefinitions.map(tick => {\n return (\n <StyledTickItem\n item={\n orientation === 'horizontal'\n ? {\n colStartEnd: `${tick.start} / ${tick.end}`\n }\n : {\n rowStartEnd: `${-tick.start} / ${-tick.end}`\n }\n }\n key={tick.label ?? tick.value}\n orientation={orientation}\n lowerBoundaryItem={tick.value === min}\n upperBoundaryItem={tick.value === max}\n >\n <StyledTickButton\n tabIndex={-1}\n role='button'\n aria-hidden\n onClick={() => onClick(tick.value)}\n >\n {tick.label}\n </StyledTickButton>\n </StyledTickItem>\n );\n })}\n </Grid>\n );\n};\n\nexport default SliderTicks;\n"]}
1
+ {"version":3,"file":"SliderTicks.js","sourceRoot":"","sources":["../../../src/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3B,OAAO,CACL,KAAC,cAAc,kBACb,IAAI,EACF,WAAW,KAAK,YAAY;oBAC1B,CAAC,CAAC;wBACE,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,MAAM,IAAI,CAAC,GAAG,EAAE;qBAC3C;oBACH,CAAC,CAAC;wBACE,WAAW,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;qBAC7C,EAGP,WAAW,EAAE,WAAW,EACxB,iBAAiB,EAAE,IAAI,CAAC,KAAK,KAAK,GAAG,EACrC,iBAAiB,EAAE,IAAI,CAAC,KAAK,KAAK,GAAG,gBAErC,KAAC,gBAAgB,kBACf,QAAQ,EAAE,CAAC,CAAC,EACZ,IAAI,EAAC,QAAQ,uBAEb,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,gBAEjC,IAAI,CAAC,KAAK,YACM,KAZd,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAad,CAClB,CAAC;QACJ,CAAC,CAAC,YACG,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { FC, useMemo } from 'react';\n\nimport Grid, { GridContainerProps } from '../Grid';\n\nimport { StyledTickButton, StyledTickItem, StyledTicksContainer } from './Slider.styles';\nimport SliderProps from './Slider.types';\nimport { calculateTicksRegions } from './utils';\n\ninterface SliderTicksProps {\n ticks: NonNullable<SliderProps['ticks']>;\n min: number;\n max: number;\n step: number;\n orientation: NonNullable<SliderProps['orientation']>;\n onClick: (value: number) => void;\n}\n\nconst SliderTicks: FC<SliderTicksProps> = ({\n ticks,\n min,\n max,\n step,\n orientation,\n onClick\n}: SliderTicksProps) => {\n const cellsCount = (max - min) / step + 1;\n\n const ticksDefinitions = useMemo(\n () => calculateTicksRegions(ticks, min, max, step, orientation === 'horizontal'),\n [ticks, min, max, orientation]\n );\n\n let repeatCells: string;\n let gridContainerConfig: GridContainerProps;\n if (orientation === 'horizontal') {\n repeatCells = cellsCount > 2 ? `repeat(${cellsCount - 2}, minmax(0, 1fr))` : '';\n gridContainerConfig = {\n cols: `minmax(0, 0.5fr) ${repeatCells} minmax(0, 0.5fr)`\n };\n } else {\n repeatCells = `repeat(${cellsCount}, 1em)`;\n gridContainerConfig = { rows: repeatCells, alignContent: 'between' };\n }\n\n return (\n <Grid container={gridContainerConfig} as={StyledTicksContainer}>\n {ticksDefinitions.map(tick => {\n return (\n <StyledTickItem\n item={\n orientation === 'horizontal'\n ? {\n colStartEnd: `${tick.start} / ${tick.end}`\n }\n : {\n rowStartEnd: `${-tick.start} / ${-tick.end}`\n }\n }\n key={tick.label ?? tick.value}\n orientation={orientation}\n lowerBoundaryItem={tick.value === min}\n upperBoundaryItem={tick.value === max}\n >\n <StyledTickButton\n tabIndex={-1}\n role='button'\n aria-hidden\n onClick={() => onClick(tick.value)}\n >\n {tick.label}\n </StyledTickButton>\n </StyledTickItem>\n );\n })}\n </Grid>\n );\n};\n\nexport default SliderTicks;\n"]}
@@ -12,10 +12,11 @@ import SliderProps, { TickDefinition } from './Slider.types';
12
12
  * @param ticksMap ticks configuration to calculate ticks definition from
13
13
  * @param min minimum allowed value in the range
14
14
  * @param max maximum allowed value in the range
15
+ * @param step step in the range
15
16
  * @param stretch flag indicating the regions should be stretched
16
17
  * @returns ticks definitions array
17
18
  */
18
- export declare const calculateTicksRegions: (ticksMap: NonNullable<SliderProps['ticks']>, min: number, max: number, stretch: boolean) => TickDefinition[];
19
+ export declare const calculateTicksRegions: (ticksMap: NonNullable<SliderProps['ticks']>, min: number, max: number, step: number, stretch: boolean) => TickDefinition[];
19
20
  /**
20
21
  * Function for given input returns nearest discrete value from a series {min, max}
21
22
  * @param input the value to look for nearest value
@@ -25,4 +26,12 @@ export declare const calculateTicksRegions: (ticksMap: NonNullable<SliderProps['
25
26
  * @returns nearest value as a number
26
27
  */
27
28
  export declare const getNearestValue: (input: number, min: number, max: number, step: number) => number;
29
+ /**
30
+ * Function calculates minimum length of the field where any value from the set of possible values will fit in.
31
+ * @param min minimum value
32
+ * @param max maximum value
33
+ * @param step step in range
34
+ * @returns minimum number of characters the field needs
35
+ */
36
+ export declare const calculateValueLength: (min: number, max: number, step: number) => number;
28
37
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/Slider/utils.ts"],"names":[],"mappings":"AAEA,OAAO,WAAW,EAAE,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE7D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,qBAAqB,aACtB,YAAY,WAAW,CAAC,OAAO,CAAC,CAAC,OACtC,MAAM,OACN,MAAM,WACF,OAAO,KACf,cAAc,EAkDhB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,UAAW,MAAM,OAAO,MAAM,OAAO,MAAM,QAAQ,MAAM,KAAG,MAKvF,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/Slider/utils.ts"],"names":[],"mappings":"AAEA,OAAO,WAAW,EAAE,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE7D;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,qBAAqB,aACtB,YAAY,WAAW,CAAC,OAAO,CAAC,CAAC,OACtC,MAAM,OACN,MAAM,QACL,MAAM,WACH,OAAO,KACf,cAAc,EAkDhB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,UAAW,MAAM,OAAO,MAAM,OAAO,MAAM,QAAQ,MAAM,KAAG,MAKvF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,QAAS,MAAM,OAAO,MAAM,QAAQ,MAAM,KAAG,MAW7E,CAAC"}
@@ -12,16 +12,17 @@ import { triple } from '../../utils';
12
12
  * @param ticksMap ticks configuration to calculate ticks definition from
13
13
  * @param min minimum allowed value in the range
14
14
  * @param max maximum allowed value in the range
15
+ * @param step step in the range
15
16
  * @param stretch flag indicating the regions should be stretched
16
17
  * @returns ticks definitions array
17
18
  */
18
- export const calculateTicksRegions = (ticksMap, min, max, stretch) => {
19
+ export const calculateTicksRegions = (ticksMap, min, max, step, stretch) => {
19
20
  // calculate initial positions for every tick, the tick segment has the width = 1
20
21
  const defs = Object.entries(ticksMap)
21
22
  .filter(([tickValue]) => Number(tickValue) >= min && Number(tickValue) <= max)
22
23
  .sort(([tickValue1], [tickValue2]) => Number(tickValue1) - Number(tickValue2))
23
24
  .map(([tickValue, tickLabel]) => {
24
- const cell = Number(tickValue) - min + 1; // shift by 'min' value and increment to always start from 1
25
+ const cell = (Number(tickValue) - min) / step + 1; // shift by 'min' value, divide by a step and increment, as index starts from 1
25
26
  const cellStart = cell;
26
27
  const cellEnd = cellStart + 1;
27
28
  return {
@@ -33,7 +34,7 @@ export const calculateTicksRegions = (ticksMap, min, max, stretch) => {
33
34
  });
34
35
  if (!stretch)
35
36
  return defs;
36
- const maxCell = max - min + 2;
37
+ const maxCell = (max - min) / step + 2;
37
38
  const result = [];
38
39
  // extend the tick segments one by one
39
40
  // eslint-disable-next-line no-restricted-syntax
@@ -78,4 +79,21 @@ export const getNearestValue = (input, min, max, step) => {
78
79
  const decimals = step.toString().split('.')[1]?.length;
79
80
  return Number(output.toFixed(decimals || 0));
80
81
  };
82
+ /**
83
+ * Function calculates minimum length of the field where any value from the set of possible values will fit in.
84
+ * @param min minimum value
85
+ * @param max maximum value
86
+ * @param step step in range
87
+ * @returns minimum number of characters the field needs
88
+ */
89
+ export const calculateValueLength = (min, max, step) => {
90
+ const [minIntegerPart, minDecimalPart = ''] = min.toString().split('.');
91
+ const [maxIntegerPart, maxDecimalPart = ''] = max.toString().split('.');
92
+ const stepDecimalPart = step.toString().split('.')[1] ?? '';
93
+ return (Math.max(minIntegerPart.length, maxIntegerPart.length) +
94
+ Math.max(maxDecimalPart.length, minDecimalPart.length, stepDecimalPart.length) +
95
+ (maxDecimalPart || minDecimalPart || stepDecimalPart
96
+ ? 1 // if there's decimal part, reserve a space for the separator
97
+ : 0));
98
+ };
81
99
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/Slider/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,QAA2C,EAC3C,GAAW,EACX,GAAW,EACX,OAAgB,EACE,EAAE;IACpB,iFAAiF;IACjF,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;SAClC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC;SAC7E,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;SAC7E,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,EAAE,EAAE;QAC9B,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,4DAA4D;QACtG,MAAM,SAAS,GAAG,IAAI,CAAC;QACvB,MAAM,OAAO,GAAG,SAAS,GAAG,CAAC,CAAC;QAC9B,OAAO;YACL,KAAK,EAAE,SAAS;YAChB,GAAG,EAAE,OAAO;YACZ,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC;YACxB,KAAK,EAAE,SAAS;SACjB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEL,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAE1B,MAAM,OAAO,GAAG,GAAG,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OAAO,CAAC,KAAK;SACrB,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW,EAAE,IAAY,EAAU,EAAE;IAC/F,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAE/C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IACvD,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC,CAAC","sourcesContent":["import { triple } from '../../utils';\n\nimport SliderProps, { TickDefinition } from './Slider.types';\n\n/**\n * The function accepts ticks map and produces an array of tick definitions. The definition\n * consist of tick value, its label and starting and ending index.\n * Function can stretch the ticks regions to allow more text to fit in the cell.\n * To calculate the stretched regions: {min} and {max} values produce the line which is then\n * divided to equal segments. These segments have indices that correspond to CSS grid cells.\n * Then the indices are optimized in the way that every segment is stretched by the half of length\n * between current tick's index and previous tick's index or next tick's index whichever is smaller.\n * |______________|__________|________________________|\n * 1------^ ^----2----^^----3----^ ^------------4\n * @param ticksMap ticks configuration to calculate ticks definition from\n * @param min minimum allowed value in the range\n * @param max maximum allowed value in the range\n * @param stretch flag indicating the regions should be stretched\n * @returns ticks definitions array\n */\nexport const calculateTicksRegions = (\n ticksMap: NonNullable<SliderProps['ticks']>,\n min: number,\n max: number,\n stretch: boolean\n): TickDefinition[] => {\n // calculate initial positions for every tick, the tick segment has the width = 1\n const defs = Object.entries(ticksMap)\n .filter(([tickValue]) => Number(tickValue) >= min && Number(tickValue) <= max)\n .sort(([tickValue1], [tickValue2]) => Number(tickValue1) - Number(tickValue2))\n .map(([tickValue, tickLabel]) => {\n const cell = Number(tickValue) - min + 1; // shift by 'min' value and increment to always start from 1\n const cellStart = cell;\n const cellEnd = cellStart + 1;\n return {\n start: cellStart,\n end: cellEnd,\n value: Number(tickValue),\n label: tickLabel\n };\n });\n\n if (!stretch) return defs;\n\n const maxCell = max - min + 2;\n\n const result = [];\n // extend the tick segments one by one\n // eslint-disable-next-line no-restricted-syntax\n for (const { prev, current, next } of triple(defs)) {\n let start = current.start;\n let end = current.end;\n if (start === 1) {\n // if the tick is marginal (starting) - expand to the 'right'\n end = next ? Math.floor((next.start - end) / 2) + end : maxCell;\n } else if (end === maxCell) {\n // if the tick is marginal (ending) - expand to the 'left'\n start = prev ? Math.floor((start - prev.end) / 2) + prev.end : 1;\n } else {\n // calculate length between current and prev / next tick and choose the smaller value\n const length = Math.min(start - (prev?.end ?? 1), (next?.start ?? maxCell) - end);\n // expand the segment to the left\n start -= Math.floor(length / 2);\n // expand to the right\n end += Math.floor(length / 2);\n }\n result.push({\n start,\n end,\n value: current.value,\n label: current.label\n });\n }\n\n return result;\n};\n\n/**\n * Function for given input returns nearest discrete value from a series {min, max}\n * @param input the value to look for nearest value\n * @param step step value determining discrete series\n * @param min minimal value in the series\n * @param max maximum value in the series\n * @returns nearest value as a number\n */\nexport const getNearestValue = (input: number, min: number, max: number, step: number): number => {\n const output = Math.round(input / step) * step;\n\n const decimals = step.toString().split('.')[1]?.length;\n return Number(output.toFixed(decimals || 0));\n};\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/Slider/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,QAA2C,EAC3C,GAAW,EACX,GAAW,EACX,IAAY,EACZ,OAAgB,EACE,EAAE;IACpB,iFAAiF;IACjF,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;S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ACvD,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAW,EAAE,GAAW,EAAE,IAAY,EAAU,EAAE;IACrF,MAAM,CAAC,cAAc,EAAE,cAAc,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxE,MAAM,CAAC,cAAc,EAAE,cAAc,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxE,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC5D,OAAO,CACL,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC;QACtD,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC;QAC9E,CAAC,cAAc,IAAI,cAAc,IAAI,eAAe;YAClD,CAAC,CAAC,CAAC,CAAC,6DAA6D;YACjE,CAAC,CAAC,CAAC,CAAC,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { triple } from '../../utils';\n\nimport SliderProps, { TickDefinition } from './Slider.types';\n\n/**\n * The function accepts ticks map and produces an array of tick definitions. The definition\n * consist of tick value, its label and starting and ending index.\n * Function can stretch the ticks regions to allow more text to fit in the cell.\n * To calculate the stretched regions: {min} and {max} values produce the line which is then\n * divided to equal segments. These segments have indices that correspond to CSS grid cells.\n * Then the indices are optimized in the way that every segment is stretched by the half of length\n * between current tick's index and previous tick's index or next tick's index whichever is smaller.\n * |______________|__________|________________________|\n * 1------^ ^----2----^^----3----^ ^------------4\n * @param ticksMap ticks configuration to calculate ticks definition from\n * @param min minimum allowed value in the range\n * @param max maximum allowed value in the range\n * @param step step in the range\n * @param stretch flag indicating the regions should be stretched\n * @returns ticks definitions array\n */\nexport const calculateTicksRegions = (\n ticksMap: NonNullable<SliderProps['ticks']>,\n min: number,\n max: number,\n step: number,\n stretch: boolean\n): TickDefinition[] => {\n // calculate initial positions for every tick, the tick segment has the width = 1\n const defs = Object.entries(ticksMap)\n .filter(([tickValue]) => Number(tickValue) >= min && Number(tickValue) <= max)\n .sort(([tickValue1], [tickValue2]) => Number(tickValue1) - Number(tickValue2))\n .map(([tickValue, tickLabel]) => {\n const cell = (Number(tickValue) - min) / step + 1; // shift by 'min' value, divide by a step and increment, as index starts from 1\n const cellStart = cell;\n const cellEnd = cellStart + 1;\n return {\n start: cellStart,\n end: cellEnd,\n value: Number(tickValue),\n label: tickLabel\n };\n });\n\n if (!stretch) return defs;\n\n const maxCell = (max - min) / step + 2;\n\n const result = [];\n // extend the tick segments one by one\n // eslint-disable-next-line no-restricted-syntax\n for (const { prev, current, next } of triple(defs)) {\n let start = current.start;\n let end = current.end;\n if (start === 1) {\n // if the tick is marginal (starting) - expand to the 'right'\n end = next ? Math.floor((next.start - end) / 2) + end : maxCell;\n } else if (end === maxCell) {\n // if the tick is marginal (ending) - expand to the 'left'\n start = prev ? Math.floor((start - prev.end) / 2) + prev.end : 1;\n } else {\n // calculate length between current and prev / next tick and choose the smaller value\n const length = Math.min(start - (prev?.end ?? 1), (next?.start ?? maxCell) - end);\n // expand the segment to the left\n start -= Math.floor(length / 2);\n // expand to the right\n end += Math.floor(length / 2);\n }\n result.push({\n start,\n end,\n value: current.value,\n label: current.label\n });\n }\n\n return result;\n};\n\n/**\n * Function for given input returns nearest discrete value from a series {min, max}\n * @param input the value to look for nearest value\n * @param step step value determining discrete series\n * @param min minimal value in the series\n * @param max maximum value in the series\n * @returns nearest value as a number\n */\nexport const getNearestValue = (input: number, min: number, max: number, step: number): number => {\n const output = Math.round(input / step) * step;\n\n const decimals = step.toString().split('.')[1]?.length;\n return Number(output.toFixed(decimals || 0));\n};\n\n/**\n * Function calculates minimum length of the field where any value from the set of possible values will fit in.\n * @param min minimum value\n * @param max maximum value\n * @param step step in range\n * @returns minimum number of characters the field needs\n */\nexport const calculateValueLength = (min: number, max: number, step: number): number => {\n const [minIntegerPart, minDecimalPart = ''] = min.toString().split('.');\n const [maxIntegerPart, maxDecimalPart = ''] = max.toString().split('.');\n const stepDecimalPart = step.toString().split('.')[1] ?? '';\n return (\n Math.max(minIntegerPart.length, maxIntegerPart.length) +\n Math.max(maxDecimalPart.length, minDecimalPart.length, stepDecimalPart.length) +\n (maxDecimalPart || minDecimalPart || stepDecimalPart\n ? 1 // if there's decimal part, reserve a space for the separator\n : 0)\n );\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { FunctionComponent, ReactNode, Ref } from 'react';
1
+ import { FunctionComponent, ReactNode, Ref, ElementType } from 'react';
2
2
  import { GridContainerProps } from '../Grid';
3
3
  import { ForwardProps } from '../../types';
4
4
  export interface SummaryItemProps {
@@ -17,7 +17,7 @@ export interface SummaryItemProps {
17
17
  */
18
18
  overflowStrategy?: 'wrap' | 'ellipsis';
19
19
  /** HTML tag to render the SummaryItem's element with. */
20
- as?: string;
20
+ as?: ElementType;
21
21
  /** Ref for the SummaryItem. */
22
22
  ref?: Ref<HTMLElement>;
23
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SummaryItem.d.ts","sourceRoot":"","sources":["../../../src/components/SummaryItem/SummaryItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,GAAG,EAA+B,MAAM,OAAO,CAAC;AAGvF,OAAa,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,MAAM,WAAW,gBAAgB;IAC/B,0CAA0C;IAC1C,OAAO,EAAE,SAAS,CAAC;I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AS,YACM,CACnB,EACA,OAAO,IAAI,CACV,KAAC,IAAI,kBAAC,EAAE,EAAE,wBAAwB,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAC/E,OAAO,YACH,CACR,aACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { FunctionComponent, ReactNode, Ref, forwardRef, PropsWithoutRef } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Grid, { GridContainerProps } from '../Grid';\nimport { defaultThemeProp } from '../../theme';\nimport { ForwardProps } from '../../types';\nimport { StyledProgressRing } from '../Progress';\n\nexport interface SummaryItemProps {\n /** Region for the primary information. */\n primary: ReactNode;\n /** Region for displaying supporting metadata. */\n secondary?: ReactNode;\n /** Region for an Avatar, Icon, or other supporting visual. */\n visual?: ReactNode;\n /** Region for adding Actions, Buttons, or Links. */\n actions?: ReactNode;\n /* Override the default Grid container props on SummaryItem. */\n container?: GridContainerProps;\n /**\n * Determines how the text within primary and secondary fields should handle overflow.\n * @default \"wrap\"\n */\n overflowStrategy?: 'wrap' | 'ellipsis';\n /** HTML tag to render the SummaryItem's element with. */\n as?: string;\n /** Ref for the SummaryItem. */\n ref?: Ref<HTMLElement>;\n}\n\nexport const StyledVisual = styled.div`\n > ${StyledProgressRing}, img {\n display: block;\n object-fit: cover;\n width: 2rem;\n height: 2rem;\n }\n`;\n\nStyledVisual.defaultProps = defaultThemeProp;\n\nexport const StyledPrimary = styled(Grid)<{\n isString?: boolean;\n overflowStrategy?: SummaryItemProps['overflowStrategy'];\n}>(({ theme, isString, overflowStrategy }) => {\n return css`\n ${overflowStrategy === 'ellipsis'\n ? css`\n overflow: hidden;\n text-overflow: ellipsis;\n `\n : css`\n word-break: break-word;\n `}\n\n ${isString &&\n css`\n font-weight: ${theme.base['font-weight']['semi-bold']};\n `}\n `;\n});\n\nStyledPrimary.defaultProps = defaultThemeProp;\n\nexport const StyledSecondary = styled(Grid)<{\n overflowStrategy?: SummaryItemProps['overflowStrategy'];\n}>(({ overflowStrategy }) => {\n return css`\n ${overflowStrategy === 'ellipsis'\n ? css`\n overflow: hidden;\n text-overflow: ellipsis;\n `\n : css`\n word-break: break-word;\n `}\n `;\n});\n\nexport const StyledSummaryItemActions = styled.div`\n white-space: nowrap;\n`;\n\nexport const StyledSummaryItem = styled.div``;\n\nconst getColumns = ({ visual, actions }: Pick<SummaryItemProps, 'visual' | 'actions'>) => {\n return `${visual ? 'auto ' : ''}minmax(0, 1fr)${actions ? ' auto' : ''}`;\n};\n\nconst getAreas = ({\n secondary,\n visual,\n actions\n}: Pick<SummaryItemProps, 'secondary' | 'visual' | 'actions'>) => {\n return `\"${visual ? 'visual ' : ''}primary${actions ? ' actions' : ''}\"${\n secondary ? `\\n\"${visual ? 'visual ' : ''}secondary${actions ? ' actions' : ''}\"` : ''\n }`;\n};\n\nconst SummaryItem: FunctionComponent<SummaryItemProps & ForwardProps> = forwardRef(\n (\n {\n visual,\n primary,\n secondary,\n actions,\n container,\n overflowStrategy = 'wrap',\n as,\n ...restProps\n }: PropsWithoutRef<SummaryItemProps>,\n ref: SummaryItemProps['ref']\n ) => {\n return (\n <Grid\n {...restProps}\n ref={ref}\n container={{\n cols: getColumns({ visual, actions }),\n colGap: 2,\n areas: getAreas({ secondary, visual, actions }),\n ...container\n }}\n as={StyledSummaryItem}\n forwardedAs={as}\n >\n {visual && (\n <Grid as={StyledVisual} item={{ area: 'visual', alignSelf: 'center' }}>\n {visual}\n </Grid>\n )}\n <StyledPrimary\n item={{ area: 'primary', alignSelf: secondary ? 'end' : 'center' }}\n isString={typeof primary === 'string'}\n overflowStrategy={overflowStrategy}\n >\n {primary}\n </StyledPrimary>\n {secondary && (\n <StyledSecondary\n item={{ area: 'secondary', alignSelf: 'start' }}\n overflowStrategy={overflowStrategy}\n >\n {secondary}\n </StyledSecondary>\n )}\n {actions && (\n <Grid as={StyledSummaryItemActions} item={{ area: 'actions', alignSelf: 'center' }}>\n {actions}\n </Grid>\n )}\n </Grid>\n );\n }\n);\n\nexport default SummaryItem;\n"]}
1
+ {"version":3,"file":"SummaryItem.js","sourceRoot":"","sources":["../../../src/components/SummaryItem/SummaryItem.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqC,UAAU,EAAgC,MAAM,OAAO,CAAC;AACpG,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,IAA4B,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAwBjD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAA;MAChC,kBAAkB;;;;;;CAMvB,CAAC;AAEF,YAAY,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE7C,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,CAGtC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,EAAE,EAAE;IAC3C,OAAO,GAAG,CAAA;MACN,gBAAgB,KAAK,UAAU;QAC/B,CAAC,CAAC,GAAG,CAAA;;;SAGF;QACH,CAAC,CAAC,GAAG,CAAA;;SAEF;;MAEH,QAAQ;QACV,GAAG,CAAA;qBACc,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,WAAW,CAAC;KACtD;GACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,aAAa,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE9C,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,CAExC,CAAC,EAAE,gBAAgB,EAAE,EAAE,EAAE;IAC1B,OAAO,GAAG,CAAA;MACN,gBAAgB,KAAK,UAAU;QAC/B,CAAC,CAAC,GAAG,CAAA;;;SAGF;QACH,CAAC,CAAC,GAAG,CAAA;;SAEF;GACN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AAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;YAC/C,GAAG,SAAS;SACb,EACD,EAAE,EAAE,iBAAiB,EACrB,WAAW,EAAE,EAAE,iBAEd,MAAM,IAAI,CACT,KAAC,IAAI,kBAAC,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAClE,MAAM,YACF,CACR,EACD,KAAC,aAAa,kBACZ,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,EAClE,QAAQ,EAAE,OAAO,OAAO,KAAK,QAAQ,EACrC,gBAAgB,EAAE,gBAAgB,gBAEjC,OAAO,YACM,EACf,SAAS,IAAI,CACZ,KAAC,eAAe,kBACd,IAAI,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,EAC/C,gBAAgB,EAAE,gBAAgB,gBAEjC,SAAS,YACM,CACnB,EACA,OAAO,IAAI,CACV,KAAC,IAAI,kBAAC,EAAE,EAAE,wBAAwB,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAC/E,OAAO,YACH,CACR,aACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { FunctionComponent, ReactNode, Ref, forwardRef, PropsWithoutRef, ElementType } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Grid, { GridContainerProps } from '../Grid';\nimport { defaultThemeProp } from '../../theme';\nimport { ForwardProps } from '../../types';\nimport { StyledProgressRing } from '../Progress';\n\nexport interface SummaryItemProps {\n /** Region for the primary information. */\n primary: ReactNode;\n /** Region for displaying supporting metadata. */\n secondary?: ReactNode;\n /** Region for an Avatar, Icon, or other supporting visual. */\n visual?: ReactNode;\n /** Region for adding Actions, Buttons, or Links. */\n actions?: ReactNode;\n /* Override the default Grid container props on SummaryItem. */\n container?: GridContainerProps;\n /**\n * Determines how the text within primary and secondary fields should handle overflow.\n * @default \"wrap\"\n */\n overflowStrategy?: 'wrap' | 'ellipsis';\n /** HTML tag to render the SummaryItem's element with. */\n as?: ElementType;\n /** Ref for the SummaryItem. */\n ref?: Ref<HTMLElement>;\n}\n\nexport const StyledVisual = styled.div`\n > ${StyledProgressRing}, img {\n display: block;\n object-fit: cover;\n width: 2rem;\n height: 2rem;\n }\n`;\n\nStyledVisual.defaultProps = defaultThemeProp;\n\nexport const StyledPrimary = styled(Grid)<{\n isString?: boolean;\n overflowStrategy?: SummaryItemProps['overflowStrategy'];\n}>(({ theme, isString, overflowStrategy }) => {\n return css`\n ${overflowStrategy === 'ellipsis'\n ? css`\n overflow: hidden;\n text-overflow: ellipsis;\n `\n : css`\n word-break: break-word;\n `}\n\n ${isString &&\n css`\n font-weight: ${theme.base['font-weight']['semi-bold']};\n `}\n `;\n});\n\nStyledPrimary.defaultProps = defaultThemeProp;\n\nexport const StyledSecondary = styled(Grid)<{\n overflowStrategy?: SummaryItemProps['overflowStrategy'];\n}>(({ overflowStrategy }) => {\n return css`\n ${overflowStrategy === 'ellipsis'\n ? css`\n overflow: hidden;\n text-overflow: ellipsis;\n `\n : css`\n word-break: break-word;\n `}\n `;\n});\n\nexport const StyledSummaryItemActions = styled.div`\n white-space: nowrap;\n`;\n\nexport const StyledSummaryItem = styled.div``;\n\nconst getColumns = ({ visual, actions }: Pick<SummaryItemProps, 'visual' | 'actions'>) => {\n return `${visual ? 'auto ' : ''}minmax(0, 1fr)${actions ? ' auto' : ''}`;\n};\n\nconst getAreas = ({\n secondary,\n visual,\n actions\n}: Pick<SummaryItemProps, 'secondary' | 'visual' | 'actions'>) => {\n return `\"${visual ? 'visual ' : ''}primary${actions ? ' actions' : ''}\"${\n secondary ? `\\n\"${visual ? 'visual ' : ''}secondary${actions ? ' actions' : ''}\"` : ''\n }`;\n};\n\nconst SummaryItem: FunctionComponent<SummaryItemProps & ForwardProps> = forwardRef(\n (\n {\n visual,\n primary,\n secondary,\n actions,\n container,\n overflowStrategy = 'wrap',\n as,\n ...restProps\n }: PropsWithoutRef<SummaryItemProps>,\n ref: SummaryItemProps['ref']\n ) => {\n return (\n <Grid\n {...restProps}\n ref={ref}\n container={{\n cols: getColumns({ visual, actions }),\n colGap: 2,\n areas: getAreas({ secondary, visual, actions }),\n ...container\n }}\n as={StyledSummaryItem}\n forwardedAs={as}\n >\n {visual && (\n <Grid as={StyledVisual} item={{ area: 'visual', alignSelf: 'center' }}>\n {visual}\n </Grid>\n )}\n <StyledPrimary\n item={{ area: 'primary', alignSelf: secondary ? 'end' : 'center' }}\n isString={typeof primary === 'string'}\n overflowStrategy={overflowStrategy}\n >\n {primary}\n </StyledPrimary>\n {secondary && (\n <StyledSecondary\n item={{ area: 'secondary', alignSelf: 'start' }}\n overflowStrategy={overflowStrategy}\n >\n {secondary}\n </StyledSecondary>\n )}\n {actions && (\n <Grid as={StyledSummaryItemActions} item={{ area: 'actions', alignSelf: 'center' }}>\n {actions}\n </Grid>\n )}\n </Grid>\n );\n }\n);\n\nexport default SummaryItem;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../../src/components/Switch/Switch.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAc,iBAAiB,EAAmB,GAAG,EAAE,MAAM,OAAO,CAAC;AAIzF,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAOlD,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C;;;OAGG;IACH,EAAE,CAAC,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC5B,2DAA2D;IAC3D,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAClC;;;OAGG;IAC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gBAAgB,CAAC,CAAC;CAC7B;AAED,eAAO,MAAM,WAAW,2GAwEvB,CAAC;AAIF,eAAO,MAAM,WAAW,2GAkEvB,CAAC;AAIF,eAAO,MAAM,YAAY,yGAAe,CAAC;AAEzC,QAAA,MAAM,MAAM,EAAE,iBAAiB,CAAC,WAAW,GAAG,YAAY,CAyBzD,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -6,8 +6,10 @@ import { defaultThemeProp } from '../../theme';
6
6
  import { useDirection, useUID } from '../../hooks';
7
7
  import Flex from '../Flex';
8
8
  import { getHoverColors } from '../../styles';
9
- import Icon, { StyledIcon } from '../Icon';
9
+ import Icon, { StyledIcon, registerIcon } from '../Icon';
10
+ import * as checkIcon from '../Icon/icons/check.icon';
10
11
  import { tryCatch } from '../../utils';
12
+ registerIcon(checkIcon);
11
13
  export const SwitchLabel = styled.label(({ theme: { base, components: { switch: { width, height, 'touch-width': touchWidth, 'touch-height': touchHeight, off } } } }) => {
12
14
  return css `
13
15
  position: relative;
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.js","sourceRoot":"","sources":["../../../src/components/Switch/Switch.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAe,UAAU,EAA2C,MAAM,OAAO,CAAC;AACzF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AA0BvC,MAAM,CAAC,MAAM,WAAW,G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M,GAAG,GAAG,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,EAAE,GAAG,GAAG,EAAE,KAAK,EAAE,QAAQ,GAAG,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAExF,OAAO,CACL,MAAC,YAAY,eACX,KAAC,WAAW,oBACN,SAAS,IACb,EAAE,EAAE,EAAE,EACN,IAAI,EAAC,UAAU,EACf,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,EAAE,kBACG,EAAE,EAChB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,YACR,EACF,MAAC,IAAI,kBAAC,SAAS,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,iBACpE,KAAK,EACL,EAAE,IAAI,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,WAAG,aACvB,YACM,CAChB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["import { ChangeEvent, forwardRef, FunctionComponent, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\nimport { hideVisually, readableColor } from 'polished';\n\nimport { BaseProps, ForwardProps } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { FormControlProps } from '../FormControl';\nimport { useDirection, useUID } from '../../hooks';\nimport Flex from '../Flex';\nimport { getHoverColors } from '../../styles';\nimport Icon, { StyledIcon } from '../Icon';\nimport { tryCatch } from '../../utils';\n\nexport interface SwitchProps extends BaseProps {\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /**\n * Disables the control.\n * @default false\n */\n disabled?: FormControlProps['disabled'];\n /**\n * Sets checked prop via onChange.\n * @default false\n */\n on?: boolean;\n /** Callback that is triggered when the Switch is toggled. */\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n /** Ref for the input element. */\n ref?: Ref<HTMLInputElement>;\n}\n\nexport const SwitchLabel = styled.label(\n ({\n theme: {\n base,\n components: {\n switch: { width, height, 'touch-width': touchWidth, 'touch-height': touchHeight, off }\n }\n }\n }) => {\n return css`\n position: relative;\n cursor: pointer;\n padding-inline-end: calc(${width} + 0.5rem);\n height: ${height};\n width: 100%;\n\n @media (pointer: coarse) {\n padding-inline-end: calc(${touchWidth} + 0.5rem);\n height: ${touchHeight};\n }\n\n /** Checkmark */\n & > ${StyledIcon} {\n position: absolute;\n inset-inline-end: calc(0.5 * ${width} + 0.25rem);\n height: calc(0.5 * ${height});\n width: calc(0.5 * ${height});\n\n @media (pointer: coarse) {\n inset-inline-end: calc(0.5 * ${touchWidth} + 0.25rem);\n height: calc(0.5 * ${touchHeight});\n width: calc(0.5 * ${touchHeight});\n }\n }\n\n /** Track */\n &::before {\n position: absolute;\n content: '';\n inset-inline-end: 0;\n width: ${width};\n height: ${height};\n background-color: ${off.color};\n transition: background-color calc(0.5 * ${base.animation.speed})\n ${base.animation.timing.ease};\n border-radius: calc(9999 * ${base['border-radius']});\n\n @media (pointer: coarse) {\n width: ${touchWidth};\n height: ${touchHeight};\n }\n }\n\n /** Switch */\n &::after {\n position: absolute;\n content: '';\n inset-inline-end: calc(${width} - ${height} + 0.0625rem);\n height: calc(${height} - 0.125rem);\n width: calc(${height} - 0.125rem);\n background-color: ${base.palette['primary-background']};\n transition: transform calc(0.5 * ${base.animation.speed}) ${base.animation.timing.ease};\n border-radius: calc(9999 * ${base['border-radius']});\n\n @media (pointer: coarse) {\n inset-inline-end: calc(${touchWidth} - ${touchHeight} + 0.0625rem);\n height: calc(${touchHeight} - 0.125rem);\n width: calc(${touchHeight} - 0.125rem);\n }\n }\n `;\n }\n);\n\nSwitchLabel.defaultProps = defaultThemeProp;\n\nexport const SwitchInput = styled.input(\n ({\n theme: {\n base,\n components: {\n 'form-control': {\n ':focus': { 'box-shadow': shadow }\n },\n switch: { height, width, 'touch-height': touchHeight, 'touch-width': touchWidth, on, off }\n }\n }\n }) => {\n const { ltr } = useDirection();\n\n const checkmarkColor = tryCatch(() => readableColor(on.color));\n\n const onHoverColors = getHoverColors(on.color);\n const offHoverColors = getHoverColors(off.color);\n\n return css`\n ${hideVisually}\n\n & + ${SwitchLabel} {\n min-height: ${base['hit-area']['mouse-min']};\n @media (pointer: coarse) {\n min-height: ${base['hit-area']['finger-min']};\n }\n }\n\n & + ${SwitchLabel} > ${StyledIcon} {\n color: ${checkmarkColor};\n }\n\n &:checked + ${SwitchLabel}::before {\n background-color: ${on.color};\n }\n\n &:checked + ${SwitchLabel}::after {\n transform: translateX(calc((${width} - ${height}) * ${ltr ? '1' : '-1'}));\n\n @media (pointer: coarse) {\n transform: translateX(calc((${touchWidth} - ${touchHeight}) * ${ltr ? '1' : '-1'}));\n }\n }\n\n &:hover + ${SwitchLabel} > ${StyledIcon} {\n color: ${onHoverColors.foreground};\n }\n\n &:hover:checked + ${SwitchLabel}::before {\n background-color: ${onHoverColors.background};\n }\n\n &:hover + ${SwitchLabel}::before {\n background-color: ${offHoverColors.background};\n }\n\n &:focus + ${SwitchLabel}::before {\n box-shadow: ${shadow};\n }\n\n &:disabled + ${SwitchLabel} {\n opacity: ${base['disabled-opacity']};\n }\n `;\n }\n);\n\nSwitchInput.defaultProps = defaultThemeProp;\n\nexport const StyledSwitch = styled.div``;\n\nconst Switch: FunctionComponent<SwitchProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<SwitchProps>, ref: SwitchProps['ref']) => {\n const uid = useUID();\n const { id = uid, label, disabled = false, on = false, onChange, ...restProps } = props;\n\n return (\n <StyledSwitch>\n <SwitchInput\n {...restProps}\n id={id}\n type='checkbox'\n role='switch'\n checked={on}\n aria-checked={on}\n disabled={disabled}\n onChange={onChange}\n ref={ref}\n />\n <Flex container={{ alignItems: 'center' }} as={SwitchLabel} htmlFor={id}>\n {label}\n {on && <Icon name='check' />}\n </Flex>\n </StyledSwitch>\n );\n }\n);\n\nexport default Switch;\n"]}
1
+ {"version":3,"file":"Switch.js","sourceRoot":"","sources":["../../../src/components/Switch/Switch.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAe,UAAU,EAA2C,MAAM,OAAO,CAAC;AACzF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,IAAI,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,YAAY,CAAC,SAAS,CAAC,CAAC;AA0BxB,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CACrC,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EACJ,UAAU,EAAE,EACV,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,GAAG,EAAE,EACvF,EACF,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;;;iCAGmB,KAAK;gBACtB,MAAM;;;;mCAIa,UAAU;kBAC3B,WAAW;;;;YAIjB,UAAU;;uCAEiB,KAAK;6BACf,MAAM;4BACP,MAAM;;;yCAGO,UAAU;+BACpB,WAAW;8BACZ,WAAW;;;;;;;;;iBASxB,KAAK;kBACJ,MAAM;4BACI,GAAG,CAA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AC,SAAS,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,iBACpE,KAAK,EACL,EAAE,IAAI,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,WAAG,aACvB,YACM,CAChB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["import { ChangeEvent, forwardRef, FunctionComponent, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\nimport { hideVisually, readableColor } from 'polished';\n\nimport { BaseProps, ForwardProps } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { FormControlProps } from '../FormControl';\nimport { useDirection, useUID } from '../../hooks';\nimport Flex from '../Flex';\nimport { getHoverColors } from '../../styles';\nimport Icon, { StyledIcon, registerIcon } from '../Icon';\nimport * as checkIcon from '../Icon/icons/check.icon';\nimport { tryCatch } from '../../utils';\n\nregisterIcon(checkIcon);\n\nexport interface SwitchProps extends BaseProps {\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /**\n * Disables the control.\n * @default false\n */\n disabled?: FormControlProps['disabled'];\n /**\n * Sets checked prop via onChange.\n * @default false\n */\n on?: boolean;\n /** Callback that is triggered when the Switch is toggled. */\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n /** Ref for the input element. */\n ref?: Ref<HTMLInputElement>;\n}\n\nexport const SwitchLabel = styled.label(\n ({\n theme: {\n base,\n components: {\n switch: { width, height, 'touch-width': touchWidth, 'touch-height': touchHeight, off }\n }\n }\n }) => {\n return css`\n position: relative;\n cursor: pointer;\n padding-inline-end: calc(${width} + 0.5rem);\n height: ${height};\n width: 100%;\n\n @media (pointer: coarse) {\n padding-inline-end: calc(${touchWidth} + 0.5rem);\n height: ${touchHeight};\n }\n\n /** Checkmark */\n & > ${StyledIcon} {\n position: absolute;\n inset-inline-end: calc(0.5 * ${width} + 0.25rem);\n height: calc(0.5 * ${height});\n width: calc(0.5 * ${height});\n\n @media (pointer: coarse) {\n inset-inline-end: calc(0.5 * ${touchWidth} + 0.25rem);\n height: calc(0.5 * ${touchHeight});\n width: calc(0.5 * ${touchHeight});\n }\n }\n\n /** Track */\n &::before {\n position: absolute;\n content: '';\n inset-inline-end: 0;\n width: ${width};\n height: ${height};\n background-color: ${off.color};\n transition: background-color calc(0.5 * ${base.animation.speed})\n ${base.animation.timing.ease};\n border-radius: calc(9999 * ${base['border-radius']});\n\n @media (pointer: coarse) {\n width: ${touchWidth};\n height: ${touchHeight};\n }\n }\n\n /** Switch */\n &::after {\n position: absolute;\n content: '';\n inset-inline-end: calc(${width} - ${height} + 0.0625rem);\n height: calc(${height} - 0.125rem);\n width: calc(${height} - 0.125rem);\n background-color: ${base.palette['primary-background']};\n transition: transform calc(0.5 * ${base.animation.speed}) ${base.animation.timing.ease};\n border-radius: calc(9999 * ${base['border-radius']});\n\n @media (pointer: coarse) {\n inset-inline-end: calc(${touchWidth} - ${touchHeight} + 0.0625rem);\n height: calc(${touchHeight} - 0.125rem);\n width: calc(${touchHeight} - 0.125rem);\n }\n }\n `;\n }\n);\n\nSwitchLabel.defaultProps = defaultThemeProp;\n\nexport const SwitchInput = styled.input(\n ({\n theme: {\n base,\n components: {\n 'form-control': {\n ':focus': { 'box-shadow': shadow }\n },\n switch: { height, width, 'touch-height': touchHeight, 'touch-width': touchWidth, on, off }\n }\n }\n }) => {\n const { ltr } = useDirection();\n\n const checkmarkColor = tryCatch(() => readableColor(on.color));\n\n const onHoverColors = getHoverColors(on.color);\n const offHoverColors = getHoverColors(off.color);\n\n return css`\n ${hideVisually}\n\n & + ${SwitchLabel} {\n min-height: ${base['hit-area']['mouse-min']};\n @media (pointer: coarse) {\n min-height: ${base['hit-area']['finger-min']};\n }\n }\n\n & + ${SwitchLabel} > ${StyledIcon} {\n color: ${checkmarkColor};\n }\n\n &:checked + ${SwitchLabel}::before {\n background-color: ${on.color};\n }\n\n &:checked + ${SwitchLabel}::after {\n transform: translateX(calc((${width} - ${height}) * ${ltr ? '1' : '-1'}));\n\n @media (pointer: coarse) {\n transform: translateX(calc((${touchWidth} - ${touchHeight}) * ${ltr ? '1' : '-1'}));\n }\n }\n\n &:hover + ${SwitchLabel} > ${StyledIcon} {\n color: ${onHoverColors.foreground};\n }\n\n &:hover:checked + ${SwitchLabel}::before {\n background-color: ${onHoverColors.background};\n }\n\n &:hover + ${SwitchLabel}::before {\n background-color: ${offHoverColors.background};\n }\n\n &:focus + ${SwitchLabel}::before {\n box-shadow: ${shadow};\n }\n\n &:disabled + ${SwitchLabel} {\n opacity: ${base['disabled-opacity']};\n }\n `;\n }\n);\n\nSwitchInput.defaultProps = defaultThemeProp;\n\nexport const StyledSwitch = styled.div``;\n\nconst Switch: FunctionComponent<SwitchProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<SwitchProps>, ref: SwitchProps['ref']) => {\n const uid = useUID();\n const { id = uid, label, disabled = false, on = false, onChange, ...restProps } = props;\n\n return (\n <StyledSwitch>\n <SwitchInput\n {...restProps}\n id={id}\n type='checkbox'\n role='switch'\n checked={on}\n aria-checked={on}\n disabled={disabled}\n onChange={onChange}\n ref={ref}\n />\n <Flex container={{ alignItems: 'center' }} as={SwitchLabel} htmlFor={id}>\n {label}\n {on && <Icon name='check' />}\n </Flex>\n </StyledSwitch>\n );\n }\n);\n\nexport default Switch;\n"]}
@@ -1,16 +1,15 @@
1
1
  import { FunctionComponent, ReactNode, Context } from 'react';
2
- import { DeepRequired } from '../../types';
3
2
  export declare const initializedKey: unique symbol;
4
3
  export interface ToasterContextValue {
5
- push: (message: IncomingMessage) => void;
4
+ push: (message: ToastMessage) => void;
6
5
  [initializedKey]: boolean;
7
6
  }
8
7
  export declare const ToasterContext: Context<ToasterContextValue>;
9
- interface ToastMessage {
8
+ export interface ToastMessage {
10
9
  /** String to identify the specific message. Used as onDismiss callback arg. */
11
- id: string;
12
- /** Recommend a simple string message. */
13
- content: ReactNode;
10
+ id?: string;
11
+ /** A short message to provide feedback based upon a user action. */
12
+ content: string;
14
13
  /**
15
14
  * Time in milliseconds to automatically dismiss toast.
16
15
  * Can be set globally on Toaster and overridden individually at a message level.
@@ -19,31 +18,9 @@ interface ToastMessage {
19
18
  dismissAfter?: number;
20
19
  /** Called when user or timer dismisses toasts. Callback is passed the message id and boolean indicating if the dismissal was timed. */
21
20
  onDismiss?: ({ id, timeout }: {
22
- id: string;
21
+ id: ToastState['id'];
23
22
  timeout: boolean;
24
23
  }) => void;
25
- /** internal prop */
26
- dismissed: boolean;
27
- /** internal prop */
28
- timeoutId?: number;
29
- /** internal prop */
30
- translateY: number;
31
- }
32
- export interface IncomingMessage {
33
- /** Id of the Toast. */
34
- id?: string;
35
- /** The content to display within the Toast. */
36
- content: ReactNode;
37
- /**
38
- * Time in milliseconds to automatically dismiss Toast.
39
- * Can be set globally on Toaster and overridden individually at a message level.
40
- * @default Infinity
41
- */
42
- dismissAfter?: ToastMessage['dismissAfter'];
43
- /** Called when user or timer dismisses Toasts. Callback is passed the message id and boolean indicating if the dismissal was timed. */
44
- onDismiss?: ToastMessage['onDismiss'];
45
- /** The id of the timeout controlling the Toast duration. */
46
- timeoutId?: ToastMessage['timeoutId'];
47
24
  }
48
25
  export interface ToasterProps {
49
26
  /** The element(s) responsible for handling the Toaster state. */
@@ -59,14 +36,9 @@ export interface ToasterProps {
59
36
  /** Context to read previous values from. */
60
37
  context?: Context<ToasterContextValue>;
61
38
  }
62
- declare type DispatchAction = 'push' | 'dismiss' | 'remove' | 'adjust';
63
- interface ToastProps extends ToastMessage {
64
- dispatch: (message: {
65
- action: DispatchAction;
66
- message: DeepRequired<IncomingMessage>;
67
- }) => void;
39
+ interface ToastState extends ToastMessage {
40
+ id: NonNullable<ToastMessage['id']>;
68
41
  }
69
- export declare const Toast: FunctionComponent<ToastProps>;
70
42
  declare const Toaster: FunctionComponent<ToasterProps>;
71
43
  export default Toaster;
72
44
  //# sourceMappingURL=Toaster.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Toaster.d.ts","sourceRoot":"","sources":["../../../src/components/Toaster/Toaster.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,iBAAiB,EACjB,SAAS,EAGT,OAAO,EACR,MAAM,OAAO,CAAC;AAOf,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,eAAO,MAAM,cAAc,eAA4D,CAAC;AAExF,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IACzC,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,eAAO,MAAM,cAAc,8BAGzB,CAAC;AAEH,UAAU,YAAY;IACpB,+EAA+E;IAC/E,EAAE,EAAE,MAAM,CAAC;IACX,yCAAyC;IACzC,OAAO,EAAE,SAAS,CAAC;IACnB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uIAAuI;IACvI,SAAS,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;IACxE,oBAAoB;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,oBAAoB;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,uBAAuB;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,+CAA+C;IAC/C,OAAO,EAAE,SAAS,CAAC;IACnB;;;;OAIG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;IAC5C,uIAAuI;IACvI,SAAS,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;IACtC,4DAA4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