@cloudscape-design/components 3.0.1310 → 3.0.1312

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 (198) hide show
  1. package/app-layout/runtime-drawer/index.js +1 -1
  2. package/app-layout/runtime-drawer/index.js.map +1 -1
  3. package/app-layout/visual-refresh/drawers.d.ts.map +1 -1
  4. package/app-layout/visual-refresh/drawers.js +3 -0
  5. package/app-layout/visual-refresh/drawers.js.map +1 -1
  6. package/app-layout/visual-refresh/styles.css.js +87 -86
  7. package/app-layout/visual-refresh/styles.scoped.css +176 -164
  8. package/app-layout/visual-refresh/styles.selectors.js +87 -86
  9. package/app-layout/visual-refresh/tools.d.ts.map +1 -1
  10. package/app-layout/visual-refresh/tools.js +2 -0
  11. package/app-layout/visual-refresh/tools.js.map +1 -1
  12. package/app-layout/visual-refresh-toolbar/drawer/styles.css.js +32 -32
  13. package/app-layout/visual-refresh-toolbar/drawer/styles.scoped.css +84 -84
  14. package/app-layout/visual-refresh-toolbar/drawer/styles.selectors.js +32 -32
  15. package/app-layout/visual-refresh-toolbar/navigation/styles.css.js +4 -4
  16. package/app-layout/visual-refresh-toolbar/navigation/styles.scoped.css +6 -6
  17. package/app-layout/visual-refresh-toolbar/navigation/styles.selectors.js +4 -4
  18. package/breadcrumb-group/implementation.d.ts.map +1 -1
  19. package/breadcrumb-group/implementation.js +2 -2
  20. package/breadcrumb-group/implementation.js.map +1 -1
  21. package/breadcrumb-group/item/item.d.ts.map +1 -1
  22. package/breadcrumb-group/item/item.js +2 -1
  23. package/breadcrumb-group/item/item.js.map +1 -1
  24. package/button/internal.d.ts +3 -0
  25. package/button/internal.d.ts.map +1 -1
  26. package/button/internal.js +2 -2
  27. package/button/internal.js.map +1 -1
  28. package/button-dropdown/category-elements/expandable-category-element.d.ts.map +1 -1
  29. package/button-dropdown/category-elements/expandable-category-element.js +4 -2
  30. package/button-dropdown/category-elements/expandable-category-element.js.map +1 -1
  31. package/button-dropdown/category-elements/mobile-expandable-category-element.d.ts.map +1 -1
  32. package/button-dropdown/category-elements/mobile-expandable-category-element.js +4 -2
  33. package/button-dropdown/category-elements/mobile-expandable-category-element.js.map +1 -1
  34. package/button-dropdown/category-elements/styles.css.js +19 -18
  35. package/button-dropdown/category-elements/styles.scoped.css +32 -28
  36. package/button-dropdown/category-elements/styles.selectors.js +19 -18
  37. package/button-dropdown/index.d.ts.map +1 -1
  38. package/button-dropdown/index.js +4 -3
  39. package/button-dropdown/index.js.map +1 -1
  40. package/button-dropdown/interfaces.d.ts +22 -0
  41. package/button-dropdown/interfaces.d.ts.map +1 -1
  42. package/button-dropdown/interfaces.js.map +1 -1
  43. package/button-dropdown/internal.d.ts.map +1 -1
  44. package/button-dropdown/internal.js +15 -6
  45. package/button-dropdown/internal.js.map +1 -1
  46. package/button-dropdown/styles.css.js +23 -21
  47. package/button-dropdown/styles.scoped.css +39 -29
  48. package/button-dropdown/styles.selectors.js +23 -21
  49. package/button-group/icon-toggle-button-item.js +1 -1
  50. package/button-group/icon-toggle-button-item.js.map +1 -1
  51. package/button-group/interfaces.d.ts +12 -1
  52. package/button-group/interfaces.d.ts.map +1 -1
  53. package/button-group/interfaces.js.map +1 -1
  54. package/button-group/menu-dropdown-item.d.ts.map +1 -1
  55. package/button-group/menu-dropdown-item.js +2 -1
  56. package/button-group/menu-dropdown-item.js.map +1 -1
  57. package/dropdown/internal.d.ts.map +1 -1
  58. package/dropdown/internal.js +14 -2
  59. package/dropdown/internal.js.map +1 -1
  60. package/expandable-section/expandable-section-header.d.ts.map +1 -1
  61. package/expandable-section/expandable-section-header.js +5 -5
  62. package/expandable-section/expandable-section-header.js.map +1 -1
  63. package/expandable-section/styles.css.js +36 -35
  64. package/expandable-section/styles.scoped.css +81 -66
  65. package/expandable-section/styles.selectors.js +36 -35
  66. package/icon/generated/icons.d.ts +1 -0
  67. package/icon/generated/icons.d.ts.map +1 -1
  68. package/icon/generated/icons.js +2 -0
  69. package/icon/generated/icons.js.map +1 -1
  70. package/icon-provider/interfaces.d.ts +1 -1
  71. package/icon-provider/interfaces.d.ts.map +1 -1
  72. package/icon-provider/interfaces.js.map +1 -1
  73. package/internal/base-component/styles.scoped.css +37 -1
  74. package/internal/components/button-trigger/index.d.ts.map +1 -1
  75. package/internal/components/button-trigger/index.js +3 -2
  76. package/internal/components/button-trigger/index.js.map +1 -1
  77. package/internal/components/button-trigger/styles.css.js +15 -14
  78. package/internal/components/button-trigger/styles.scoped.css +35 -29
  79. package/internal/components/button-trigger/styles.selectors.js +15 -14
  80. package/internal/components/checkbox-icon/index.d.ts.map +1 -1
  81. package/internal/components/checkbox-icon/index.js +11 -2
  82. package/internal/components/checkbox-icon/index.js.map +1 -1
  83. package/internal/components/drag-handle/styles.css.js +14 -14
  84. package/internal/components/drag-handle/styles.scoped.css +20 -19
  85. package/internal/components/drag-handle/styles.selectors.js +14 -14
  86. package/internal/components/drag-handle-wrapper/index.d.ts.map +1 -1
  87. package/internal/components/drag-handle-wrapper/index.js +6 -3
  88. package/internal/components/drag-handle-wrapper/index.js.map +1 -1
  89. package/internal/components/drag-handle-wrapper/portal-overlay.d.ts +2 -0
  90. package/internal/components/drag-handle-wrapper/portal-overlay.d.ts.map +1 -1
  91. package/internal/components/drag-handle-wrapper/portal-overlay.js +2 -2
  92. package/internal/components/drag-handle-wrapper/portal-overlay.js.map +1 -1
  93. package/internal/components/expand-toggle-button/index.js +2 -2
  94. package/internal/components/expand-toggle-button/index.js.map +1 -1
  95. package/internal/environment.js +2 -2
  96. package/internal/environment.json +2 -2
  97. package/internal/generated/styles/tokens.d.ts +8 -0
  98. package/internal/generated/styles/tokens.js +8 -0
  99. package/internal/generated/theming/index.cjs +236 -0
  100. package/internal/generated/theming/index.cjs.d.ts +72 -0
  101. package/internal/generated/theming/index.d.ts +72 -0
  102. package/internal/generated/theming/index.js +236 -0
  103. package/internal/hooks/use-mouse-down-target.js +2 -2
  104. package/internal/hooks/use-mouse-down-target.js.map +1 -1
  105. package/internal/hooks/use-portal-mode-classes/index.d.ts.map +1 -1
  106. package/internal/hooks/use-portal-mode-classes/index.js +4 -2
  107. package/internal/hooks/use-portal-mode-classes/index.js.map +1 -1
  108. package/internal/hooks/use-visual-mode/index.d.ts +2 -1
  109. package/internal/hooks/use-visual-mode/index.d.ts.map +1 -1
  110. package/internal/hooks/use-visual-mode/index.js +2 -1
  111. package/internal/hooks/use-visual-mode/index.js.map +1 -1
  112. package/internal/manifest.json +1 -1
  113. package/internal/utils/throttle.d.ts.map +1 -1
  114. package/internal/utils/throttle.js +3 -1
  115. package/internal/utils/throttle.js.map +1 -1
  116. package/manifest.json +2 -2
  117. package/package.json +1 -1
  118. package/progress-bar/index.d.ts.map +1 -1
  119. package/progress-bar/index.js +1 -0
  120. package/progress-bar/index.js.map +1 -1
  121. package/segmented-control/styles.css.js +16 -16
  122. package/segmented-control/styles.scoped.css +34 -34
  123. package/segmented-control/styles.selectors.js +16 -16
  124. package/status-indicator/internal.d.ts.map +1 -1
  125. package/status-indicator/internal.js +4 -3
  126. package/status-indicator/internal.js.map +1 -1
  127. package/status-indicator/styles.css.js +25 -24
  128. package/status-indicator/styles.scoped.css +75 -40
  129. package/status-indicator/styles.selectors.js +25 -24
  130. package/steps/internal.d.ts.map +1 -1
  131. package/steps/internal.js +20 -6
  132. package/steps/internal.js.map +1 -1
  133. package/steps/styles.css.js +12 -9
  134. package/steps/styles.scoped.css +43 -15
  135. package/steps/styles.selectors.js +12 -9
  136. package/table/header-cell/group-header-cell.d.ts.map +1 -1
  137. package/table/header-cell/group-header-cell.js +4 -16
  138. package/table/header-cell/group-header-cell.js.map +1 -1
  139. package/table/header-cell/index.d.ts.map +1 -1
  140. package/table/header-cell/index.js +2 -1
  141. package/table/header-cell/index.js.map +1 -1
  142. package/table/header-cell/styles.css.js +33 -33
  143. package/table/header-cell/styles.scoped.css +80 -73
  144. package/table/header-cell/styles.selectors.js +33 -33
  145. package/table/header-cell/th-element.d.ts +6 -6
  146. package/table/header-cell/th-element.d.ts.map +1 -1
  147. package/table/header-cell/th-element.js +4 -3
  148. package/table/header-cell/th-element.js.map +1 -1
  149. package/table/resizer/index.d.ts +5 -1
  150. package/table/resizer/index.d.ts.map +1 -1
  151. package/table/resizer/index.js +4 -4
  152. package/table/resizer/index.js.map +1 -1
  153. package/table/resizer/styles.css.js +17 -16
  154. package/table/resizer/styles.scoped.css +32 -24
  155. package/table/resizer/styles.selectors.js +17 -16
  156. package/table/selection/selection-cell.d.ts +2 -0
  157. package/table/selection/selection-cell.d.ts.map +1 -1
  158. package/table/selection/selection-cell.js +2 -2
  159. package/table/selection/selection-cell.js.map +1 -1
  160. package/table/sticky-columns/use-sticky-columns.d.ts +3 -1
  161. package/table/sticky-columns/use-sticky-columns.d.ts.map +1 -1
  162. package/table/sticky-columns/use-sticky-columns.js +31 -7
  163. package/table/sticky-columns/use-sticky-columns.js.map +1 -1
  164. package/table/thead.d.ts.map +1 -1
  165. package/table/thead.js +2 -2
  166. package/table/thead.js.map +1 -1
  167. package/test-utils/dom/table/index.js +1 -1
  168. package/test-utils/dom/table/index.js.map +1 -1
  169. package/test-utils/selectors/table/index.js +1 -1
  170. package/test-utils/selectors/table/index.js.map +1 -1
  171. package/theming/index.d.ts +3 -1
  172. package/theming/index.d.ts.map +1 -1
  173. package/theming/index.js +55 -0
  174. package/theming/index.js.map +1 -1
  175. package/toggle/styles.css.js +10 -10
  176. package/toggle/styles.scoped.css +18 -18
  177. package/toggle/styles.selectors.js +10 -10
  178. package/toggle-button/internal.d.ts.map +1 -1
  179. package/toggle-button/internal.js +3 -1
  180. package/toggle-button/internal.js.map +1 -1
  181. package/toggle-button/styles.css.js +4 -3
  182. package/toggle-button/styles.scoped.css +8 -3
  183. package/toggle-button/styles.selectors.js +4 -3
  184. package/token/dismiss-button.d.ts.map +1 -1
  185. package/token/dismiss-button.js +3 -1
  186. package/token/dismiss-button.js.map +1 -1
  187. package/token/internal.d.ts.map +1 -1
  188. package/token/internal.js +11 -3
  189. package/token/internal.js.map +1 -1
  190. package/token/styles.css.js +14 -14
  191. package/token/styles.scoped.css +33 -30
  192. package/token/styles.selectors.js +14 -14
  193. package/tree-view/tree-item/index.d.ts.map +1 -1
  194. package/tree-view/tree-item/index.js +2 -1
  195. package/tree-view/tree-item/index.js.map +1 -1
  196. package/tree-view/tree-item/styles.css.js +10 -9
  197. package/tree-view/tree-item/styles.scoped.css +19 -12
  198. package/tree-view/tree-item/styles.selectors.js +10 -9
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/checkbox-icon/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAsB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AA0BrC,6CAA6C;AAC7C,MAAM,iBAAiB,GAA0D;IAC/E,OAAO,EAAE;QACP,OAAO,EAAE,WAAW;QACpB,aAAa,EAAE,cAAc;QAC7B,OAAO,EAAE,iBAAiB;QAC1B,EAAE,EAAE,GAAG;QACP,CAAC,EAAE,GAAG;QACN,IAAI,EAAE,EAAE;KACT;IACD,OAAO,EAAE;QACP,OAAO,EAAE,WAAW;QACpB,aAAa,EAAE,cAAc;QAC7B,OAAO,EAAE,iBAAiB;QAC1B,EAAE,EAAE,GAAG;QACP,CAAC,EAAE,CAAC;QACJ,IAAI,EAAE,EAAE;KACT;CACF,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,EACpB,OAAO,EACP,aAAa,EACb,QAAQ,GAAG,KAAK,EAChB,QAAQ,GAAG,KAAK,EAChB,KAAK,EACL,GAAG,SAAS,EACM,EAAE,EAAE;;IACtB,MAAM,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1C,MAAM,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C,CAAC,EACF,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,EACrE,KAAK,EAAE,EAAE,MAAM,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,0CAAE,MAAM,EAAE,GACtC,CACH,CAAC,CAAC,CAAC,IAAI,CACJ,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport clsx from 'clsx';\n\nimport { BaseComponentProps, getBaseProps } from '../../base-component';\nimport { useVisualRefresh } from '../../hooks/use-visual-mode';\n\nimport styles from './styles.css.js';\n\ninterface CheckboxIconProps extends BaseComponentProps {\n checked?: boolean;\n indeterminate?: boolean;\n disabled?: boolean;\n readOnly?: boolean;\n style?: {\n box?: {\n fill?: string;\n stroke?: string;\n };\n line?: {\n stroke?: string;\n };\n };\n}\ninterface Dimension {\n viewBox: string;\n indeterminate: string;\n checked: string;\n xy: number;\n r: number;\n size: number;\n}\n\n// Can't use css variables for svg attributes\nconst dimensionsByTheme: Record<NonNullable<'default' | 'refresh'>, Dimension> = {\n default: {\n viewBox: '0 0 14 14',\n indeterminate: '2.5,7 11.5,7',\n checked: '2.5,7 6,10 11,3',\n xy: 0.5,\n r: 1.5,\n size: 13,\n },\n refresh: {\n viewBox: '0 0 16 16',\n indeterminate: '3.5,8 12.5,8',\n checked: '3.5,8 7,11 12,4',\n xy: 0.5,\n r: 3,\n size: 15,\n },\n};\n\nconst CheckboxIcon = ({\n checked,\n indeterminate,\n disabled = false,\n readOnly = false,\n style,\n ...restProps\n}: CheckboxIconProps) => {\n const baseProps = getBaseProps(restProps);\n const theme = useVisualRefresh() ? 'refresh' : 'default';\n const dimensions = dimensionsByTheme[theme];\n\n return (\n <svg className={styles.root} viewBox={dimensions.viewBox} aria-hidden=\"true\" focusable=\"false\" {...baseProps}>\n <rect\n className={clsx(styles['styled-box'], {\n [styles['styled-box-checked']]: checked,\n [styles['styled-box-indeterminate']]: indeterminate,\n [styles['styled-box-disabled']]: disabled,\n [styles['styled-box-readonly']]: readOnly,\n })}\n x={dimensions.xy}\n y={dimensions.xy}\n rx={dimensions.r}\n ry={dimensions.r}\n width={dimensions.size}\n height={dimensions.size}\n style={{ fill: style?.box?.fill, stroke: style?.box?.stroke }}\n />\n {checked || indeterminate ? (\n <polyline\n className={clsx(styles['styled-line'], {\n [styles['styled-line-disabled']]: disabled,\n [styles['styled-line-readonly']]: readOnly,\n })}\n points={indeterminate ? dimensions.indeterminate : dimensions.checked}\n style={{ stroke: style?.line?.stroke }}\n />\n ) : null}\n </svg>\n );\n};\n\nexport default CheckboxIcon;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/checkbox-icon/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAsB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE5E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AA0BrC,6CAA6C;AAC7C,MAAM,iBAAiB,GAAkE;IACvF,OAAO,EAAE;QACP,OAAO,EAAE,WAAW;QACpB,aAAa,EAAE,cAAc;QAC7B,OAAO,EAAE,iBAAiB;QAC1B,EAAE,EAAE,GAAG;QACP,CAAC,EAAE,GAAG;QACN,IAAI,EAAE,EAAE;KACT;IACD,OAAO,EAAE;QACP,OAAO,EAAE,WAAW;QACpB,aAAa,EAAE,cAAc;QAC7B,OAAO,EAAE,iBAAiB;QAC1B,EAAE,EAAE,GAAG;QACP,CAAC,EAAE,CAAC;QACJ,IAAI,EAAE,EAAE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CAAC,CAAC,EAChB,KAAK,EAAE,UAAU,CAAC,IAAI,EACtB,MAAM,EAAE,UAAU,CAAC,IAAI,EACvB,KAAK,EAAE,EAAE,IAAI,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,GAAG,0CAAE,IAAI,EAAE,MAAM,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,GAAG,0CAAE,MAAM,EAAE,GAC7D;QACD,OAAO,IAAI,aAAa,CAAC,CAAC,CAAC,CAC1B,kCACE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE;gBACrC,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,EAAE,QAAQ;gBAC1C,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,EAAE,QAAQ;aAC3C,CAAC,EACF,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,EACrE,KAAK,EAAE,EAAE,MAAM,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,0CAAE,MAAM,EAAE,GACtC,CACH,CAAC,CAAC,CAAC,IAAI,CACJ,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport clsx from 'clsx';\n\nimport { BaseComponentProps, getBaseProps } from '../../base-component';\nimport { useOneTheme, useVisualRefresh } from '../../hooks/use-visual-mode';\n\nimport styles from './styles.css.js';\n\ninterface CheckboxIconProps extends BaseComponentProps {\n checked?: boolean;\n indeterminate?: boolean;\n disabled?: boolean;\n readOnly?: boolean;\n style?: {\n box?: {\n fill?: string;\n stroke?: string;\n };\n line?: {\n stroke?: string;\n };\n };\n}\ninterface Dimension {\n viewBox: string;\n indeterminate: string;\n checked: string;\n xy: number;\n r: number;\n size: number;\n}\n\n// Can't use css variables for svg attributes\nconst dimensionsByTheme: Record<NonNullable<'default' | 'refresh' | 'one'>, Dimension> = {\n default: {\n viewBox: '0 0 14 14',\n indeterminate: '2.5,7 11.5,7',\n checked: '2.5,7 6,10 11,3',\n xy: 0.5,\n r: 1.5,\n size: 13,\n },\n refresh: {\n viewBox: '0 0 16 16',\n indeterminate: '3.5,8 12.5,8',\n checked: '3.5,8 7,11 12,4',\n xy: 0.5,\n r: 3,\n size: 15,\n },\n one: {\n viewBox: '0 0 16 16',\n indeterminate: '3.5,8 12.5,8',\n checked: '3.5,8 7,11 12,4',\n xy: 0.5,\n r: 2,\n size: 15,\n },\n};\n\nconst CheckboxIcon = ({\n checked,\n indeterminate,\n disabled = false,\n readOnly = false,\n style,\n ...restProps\n}: CheckboxIconProps) => {\n const baseProps = getBaseProps(restProps);\n const oneTheme = useOneTheme();\n const theme = useVisualRefresh() ? (oneTheme ? 'one' : 'refresh') : 'default';\n const dimensions = dimensionsByTheme[theme];\n\n return (\n <svg className={styles.root} viewBox={dimensions.viewBox} aria-hidden=\"true\" focusable=\"false\" {...baseProps}>\n <rect\n className={clsx(styles['styled-box'], {\n [styles['styled-box-checked']]: checked,\n [styles['styled-box-indeterminate']]: indeterminate,\n [styles['styled-box-disabled']]: disabled,\n [styles['styled-box-readonly']]: readOnly,\n })}\n x={dimensions.xy}\n y={dimensions.xy}\n rx={dimensions.r}\n ry={dimensions.r}\n width={dimensions.size}\n height={dimensions.size}\n style={{ fill: style?.box?.fill, stroke: style?.box?.stroke }}\n />\n {checked || indeterminate ? (\n <polyline\n className={clsx(styles['styled-line'], {\n [styles['styled-line-disabled']]: disabled,\n [styles['styled-line-readonly']]: readOnly,\n })}\n points={indeterminate ? dimensions.indeterminate : dimensions.checked}\n style={{ stroke: style?.line?.stroke }}\n />\n ) : null}\n </svg>\n );\n};\n\nexport default CheckboxIcon;\n"]}
@@ -1,19 +1,19 @@
1
1
 
2
2
  import './styles.scoped.css';
3
3
  export default {
4
- "handle": "awsui_handle_sdha6_45ome_145",
5
- "handle-size-normal": "awsui_handle-size-normal_sdha6_45ome_153",
6
- "handle-size-small": "awsui_handle-size-small_sdha6_45ome_157",
7
- "handle-drag-indicator": "awsui_handle-drag-indicator_sdha6_45ome_160",
8
- "handle-disabled": "awsui_handle-disabled_sdha6_45ome_160",
9
- "active": "awsui_active_sdha6_45ome_163",
10
- "handle-resize-area": "awsui_handle-resize-area_sdha6_45ome_166",
11
- "handle-resize-horizontal": "awsui_handle-resize-horizontal_sdha6_45ome_173",
12
- "handle-resize-vertical": "awsui_handle-resize-vertical_sdha6_45ome_176",
13
- "hide-focus": "awsui_hide-focus_sdha6_45ome_186",
14
- "resize-icon": "awsui_resize-icon_sdha6_45ome_208",
15
- "resize-icon-vertical": "awsui_resize-icon-vertical_sdha6_45ome_214",
16
- "resize-icon-horizontal": "awsui_resize-icon-horizontal_sdha6_45ome_218",
17
- "prevent-pointer": "awsui_prevent-pointer_sdha6_45ome_222"
4
+ "handle": "awsui_handle_sdha6_njfm3_145",
5
+ "handle-size-normal": "awsui_handle-size-normal_sdha6_njfm3_153",
6
+ "handle-size-small": "awsui_handle-size-small_sdha6_njfm3_157",
7
+ "handle-drag-indicator": "awsui_handle-drag-indicator_sdha6_njfm3_160",
8
+ "handle-disabled": "awsui_handle-disabled_sdha6_njfm3_160",
9
+ "active": "awsui_active_sdha6_njfm3_163",
10
+ "handle-resize-area": "awsui_handle-resize-area_sdha6_njfm3_166",
11
+ "handle-resize-horizontal": "awsui_handle-resize-horizontal_sdha6_njfm3_173",
12
+ "handle-resize-vertical": "awsui_handle-resize-vertical_sdha6_njfm3_176",
13
+ "hide-focus": "awsui_hide-focus_sdha6_njfm3_186",
14
+ "resize-icon": "awsui_resize-icon_sdha6_njfm3_209",
15
+ "resize-icon-vertical": "awsui_resize-icon-vertical_sdha6_njfm3_215",
16
+ "resize-icon-horizontal": "awsui_resize-icon-horizontal_sdha6_njfm3_219",
17
+ "prevent-pointer": "awsui_prevent-pointer_sdha6_njfm3_223"
18
18
  };
19
19
 
@@ -142,7 +142,7 @@
142
142
  */
143
143
  /* Style used for links in slots/components that are text heavy, to help links stand out among
144
144
  surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F73#description */
145
- .awsui_handle_sdha6_45ome_145:not(#\9) {
145
+ .awsui_handle_sdha6_njfm3_145:not(#\9) {
146
146
  appearance: none;
147
147
  color: var(--color-text-interactive-default-ugh9wp, #424650);
148
148
  background: transparent;
@@ -151,47 +151,47 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
151
151
  /* stylelint-disable-next-line plugin/no-unsupported-browser-features */
152
152
  touch-action: none;
153
153
  }
154
- .awsui_handle-size-normal_sdha6_45ome_153:not(#\9) {
154
+ .awsui_handle-size-normal_sdha6_njfm3_153:not(#\9) {
155
155
  block-size: var(--line-height-body-m-2mh3ke, 20px);
156
156
  padding-inline: var(--space-scaled-xxxs-oo06c7, 2px);
157
157
  }
158
- .awsui_handle-size-small_sdha6_45ome_157:not(#\9) {
158
+ .awsui_handle-size-small_sdha6_njfm3_157:not(#\9) {
159
159
  block-size: var(--line-height-body-s-nu5hx1, 16px);
160
160
  }
161
- .awsui_handle-drag-indicator_sdha6_45ome_160:not(#\9):not(.awsui_handle-disabled_sdha6_45ome_160) {
161
+ .awsui_handle-drag-indicator_sdha6_njfm3_160:not(#\9):not(.awsui_handle-disabled_sdha6_njfm3_160) {
162
162
  cursor: grab;
163
163
  }
164
- .awsui_handle-drag-indicator_sdha6_45ome_160:not(#\9):not(.awsui_handle-disabled_sdha6_45ome_160).awsui_active_sdha6_45ome_163 {
164
+ .awsui_handle-drag-indicator_sdha6_njfm3_160:not(#\9):not(.awsui_handle-disabled_sdha6_njfm3_160).awsui_active_sdha6_njfm3_163 {
165
165
  cursor: grabbing;
166
166
  }
167
- .awsui_handle-resize-area_sdha6_45ome_166:not(#\9) {
167
+ .awsui_handle-resize-area_sdha6_njfm3_166:not(#\9) {
168
168
  cursor: nwse-resize;
169
169
  /* stylelint-disable-next-line plugin/no-unsupported-browser-features */
170
170
  }
171
- .awsui_handle-resize-area_sdha6_45ome_166:not(#\9):dir(rtl) {
171
+ .awsui_handle-resize-area_sdha6_njfm3_166:not(#\9):dir(rtl) {
172
172
  cursor: nesw-resize;
173
173
  }
174
- .awsui_handle-resize-horizontal_sdha6_45ome_173:not(#\9) {
174
+ .awsui_handle-resize-horizontal_sdha6_njfm3_173:not(#\9) {
175
175
  cursor: ew-resize;
176
176
  }
177
- .awsui_handle-resize-vertical_sdha6_45ome_176:not(#\9) {
177
+ .awsui_handle-resize-vertical_sdha6_njfm3_176:not(#\9) {
178
178
  cursor: ns-resize;
179
179
  }
180
- .awsui_handle_sdha6_45ome_145:not(#\9):hover {
180
+ .awsui_handle_sdha6_njfm3_145:not(#\9):hover {
181
181
  color: var(--color-text-interactive-hover-6naf7i, #0f141a);
182
182
  }
183
- .awsui_handle_sdha6_45ome_145:not(#\9):focus {
183
+ .awsui_handle_sdha6_njfm3_145:not(#\9):focus {
184
184
  outline: none;
185
185
  text-decoration: none;
186
186
  }
187
- body[data-awsui-focus-visible=true] .awsui_handle_sdha6_45ome_145:not(#\9):focus:not(.awsui_hide-focus_sdha6_45ome_186) {
187
+ body[data-awsui-focus-visible=true] .awsui_handle_sdha6_njfm3_145:not(#\9):focus:not(.awsui_hide-focus_sdha6_njfm3_186) {
188
188
  position: relative;
189
189
  }
190
- body[data-awsui-focus-visible=true] .awsui_handle_sdha6_45ome_145:not(#\9):focus:not(.awsui_hide-focus_sdha6_45ome_186) {
190
+ body[data-awsui-focus-visible=true] .awsui_handle_sdha6_njfm3_145:not(#\9):focus:not(.awsui_hide-focus_sdha6_njfm3_186) {
191
191
  outline: 2px dotted transparent;
192
192
  outline-offset: calc(0px - 1px);
193
193
  }
194
- body[data-awsui-focus-visible=true] .awsui_handle_sdha6_45ome_145:not(#\9):focus:not(.awsui_hide-focus_sdha6_45ome_186)::before {
194
+ body[data-awsui-focus-visible=true] .awsui_handle_sdha6_njfm3_145:not(#\9):focus:not(.awsui_hide-focus_sdha6_njfm3_186)::before {
195
195
  content: " ";
196
196
  display: block;
197
197
  position: absolute;
@@ -204,22 +204,23 @@ body[data-awsui-focus-visible=true] .awsui_handle_sdha6_45ome_145:not(#\9):focus
204
204
  border-end-start-radius: var(--border-radius-control-default-focus-ring-1uabki, 4px);
205
205
  border-end-end-radius: var(--border-radius-control-default-focus-ring-1uabki, 4px);
206
206
  box-shadow: 0 0 0 2px var(--color-border-item-focused-uk47pl, #006ce0);
207
+ z-index: 2;
207
208
  }
208
209
 
209
- .awsui_resize-icon_sdha6_45ome_208:not(#\9) {
210
+ .awsui_resize-icon_sdha6_njfm3_209:not(#\9) {
210
211
  stroke: var(--color-text-interactive-default-ugh9wp, #424650);
211
212
  }
212
- .awsui_resize-icon_sdha6_45ome_208:not(#\9):hover {
213
+ .awsui_resize-icon_sdha6_njfm3_209:not(#\9):hover {
213
214
  stroke: var(--color-text-interactive-hover-6naf7i, #0f141a);
214
215
  }
215
- .awsui_resize-icon-vertical_sdha6_45ome_214:not(#\9) {
216
+ .awsui_resize-icon-vertical_sdha6_njfm3_215:not(#\9) {
216
217
  margin-block: auto;
217
218
  margin-inline: auto;
218
219
  }
219
- .awsui_resize-icon-horizontal_sdha6_45ome_218:not(#\9) {
220
+ .awsui_resize-icon-horizontal_sdha6_njfm3_219:not(#\9) {
220
221
  transform: rotate(90deg);
221
222
  }
222
223
 
223
- .awsui_prevent-pointer_sdha6_45ome_222:not(#\9) {
224
+ .awsui_prevent-pointer_sdha6_njfm3_223:not(#\9) {
224
225
  pointer-events: none;
225
226
  }
@@ -2,19 +2,19 @@
2
2
  // es-module interop with Babel and Typescript
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  module.exports.default = {
5
- "handle": "awsui_handle_sdha6_45ome_145",
6
- "handle-size-normal": "awsui_handle-size-normal_sdha6_45ome_153",
7
- "handle-size-small": "awsui_handle-size-small_sdha6_45ome_157",
8
- "handle-drag-indicator": "awsui_handle-drag-indicator_sdha6_45ome_160",
9
- "handle-disabled": "awsui_handle-disabled_sdha6_45ome_160",
10
- "active": "awsui_active_sdha6_45ome_163",
11
- "handle-resize-area": "awsui_handle-resize-area_sdha6_45ome_166",
12
- "handle-resize-horizontal": "awsui_handle-resize-horizontal_sdha6_45ome_173",
13
- "handle-resize-vertical": "awsui_handle-resize-vertical_sdha6_45ome_176",
14
- "hide-focus": "awsui_hide-focus_sdha6_45ome_186",
15
- "resize-icon": "awsui_resize-icon_sdha6_45ome_208",
16
- "resize-icon-vertical": "awsui_resize-icon-vertical_sdha6_45ome_214",
17
- "resize-icon-horizontal": "awsui_resize-icon-horizontal_sdha6_45ome_218",
18
- "prevent-pointer": "awsui_prevent-pointer_sdha6_45ome_222"
5
+ "handle": "awsui_handle_sdha6_njfm3_145",
6
+ "handle-size-normal": "awsui_handle-size-normal_sdha6_njfm3_153",
7
+ "handle-size-small": "awsui_handle-size-small_sdha6_njfm3_157",
8
+ "handle-drag-indicator": "awsui_handle-drag-indicator_sdha6_njfm3_160",
9
+ "handle-disabled": "awsui_handle-disabled_sdha6_njfm3_160",
10
+ "active": "awsui_active_sdha6_njfm3_163",
11
+ "handle-resize-area": "awsui_handle-resize-area_sdha6_njfm3_166",
12
+ "handle-resize-horizontal": "awsui_handle-resize-horizontal_sdha6_njfm3_173",
13
+ "handle-resize-vertical": "awsui_handle-resize-vertical_sdha6_njfm3_176",
14
+ "hide-focus": "awsui_hide-focus_sdha6_njfm3_186",
15
+ "resize-icon": "awsui_resize-icon_sdha6_njfm3_209",
16
+ "resize-icon-vertical": "awsui_resize-icon-vertical_sdha6_njfm3_215",
17
+ "resize-icon-horizontal": "awsui_resize-icon-horizontal_sdha6_njfm3_219",
18
+ "prevent-pointer": "awsui_prevent-pointer_sdha6_njfm3_223"
19
19
  };
20
20
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle-wrapper/index.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAa,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAYjE,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,UAAU,EACV,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,WAAqB,EACrB,kBAA0B,EAC1B,qBAA6B,EAC7B,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,GACnB,EAAE,sBAAsB,eAoPxB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle-wrapper/index.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAa,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAYjE,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,UAAU,EACV,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,WAAqB,EACrB,kBAA0B,EAC1B,qBAA6B,EAC7B,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,GACnB,EAAE,sBAAsB,eAwPxB"}
@@ -3,7 +3,7 @@
3
3
  import React, { useEffect, useRef, useState } from 'react';
4
4
  import clsx from 'clsx';
5
5
  import { nodeContains } from '@cloudscape-design/component-toolkit/dom';
6
- import { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';
6
+ import { getLogicalBoundingClientRect, useUniqueId } from '@cloudscape-design/component-toolkit/internal';
7
7
  import Tooltip from '../tooltip';
8
8
  import DirectionButton from './direction-button';
9
9
  import PortalOverlay from './portal-overlay';
@@ -17,6 +17,9 @@ const DIRECTIONS_ORDER = ['block-end', 'block-start', 'inline-end', 'inline-star
17
17
  export default function DragHandleWrapper({ directions, tooltipText, children, onDirectionClick, triggerMode = 'focus', initialShowButtons = false, controlledShowButtons = false, wrapperClassName, hideButtonsOnDrag, clickDragThreshold, }) {
18
18
  const wrapperRef = useRef(null);
19
19
  const dragHandleRef = useRef(null);
20
+ // Links the portaled UAP buttons back to the drag handle's position in the regular DOM,
21
+ // so outside-click / focus detection treats them as belonging to the handle's container.
22
+ const referrerId = useUniqueId('drag-handle');
20
23
  const [showTooltip, setShowTooltip] = useState(false);
21
24
  const [uncontrolledShowButtons, setUncontrolledShowButtons] = useState(initialShowButtons);
22
25
  const isPointerDown = useRef(false);
@@ -172,11 +175,11 @@ export default function DragHandleWrapper({ directions, tooltipText, children, o
172
175
  return (React.createElement(React.Fragment, null,
173
176
  React.createElement("div", { className: clsx(testUtilsStyles.root, styles.contents), ref: wrapperRef, onFocus: onWrapperFocusIn, onBlur: onWrapperFocusOut },
174
177
  React.createElement("div", { className: styles.contents, onPointerEnter: onTooltipGroupPointerEnter, onPointerLeave: onTooltipGroupPointerLeave },
175
- React.createElement("div", { className: clsx(styles['drag-handle'], wrapperClassName), ref: dragHandleRef, onPointerDown: onHandlePointerDown, onKeyDown: onDragHandleKeyDown }, children),
178
+ React.createElement("div", { className: clsx(styles['drag-handle'], wrapperClassName), ref: dragHandleRef, id: referrerId, onPointerDown: onHandlePointerDown, onKeyDown: onDragHandleKeyDown }, children),
176
179
  !isDisabled && !showButtons && showTooltip && tooltipText && (
177
180
  // Rendered in a portal but pointerenter/pointerleave events still propagate
178
181
  // up the React DOM tree, which is why it's placed in this nested context.
179
182
  React.createElement(Tooltip, { trackRef: dragHandleRef, value: tooltipText, onDismiss: () => setShowTooltip(false) })))),
180
- React.createElement(PortalOverlay, { track: dragHandleRef, isDisabled: !showButtons }, visibleDirections.map((direction, index) => directions[direction] && (React.createElement(DirectionButton, { key: direction, show: !isDisabled && showButtons, direction: direction, state: directions[direction], onClick: () => onDirectionClick === null || onDirectionClick === void 0 ? void 0 : onDirectionClick(direction), forcedPosition: forcedPosition, forcedIndex: index }))))));
183
+ React.createElement(PortalOverlay, { track: dragHandleRef, isDisabled: !showButtons, referrerId: referrerId }, visibleDirections.map((direction, index) => directions[direction] && (React.createElement(DirectionButton, { key: direction, show: !isDisabled && showButtons, direction: direction, state: directions[direction], onClick: () => onDirectionClick === null || onDirectionClick === void 0 ? void 0 : onDirectionClick(direction), forcedPosition: forcedPosition, forcedIndex: index }))))));
181
184
  }
182
185
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle-wrapper/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAE7F,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,eAAe,MAAM,oBAAoB,CAAC;AAEjD,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAE3D,+FAA+F;AAC/F,MAAM,4BAA4B,GAAG,EAAE,CAAC;AACxC,uEAAuE;AACvE,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,gBAAgB,GAAgB,CAAC,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;AAEjG,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,UAAU,EACV,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,WAAW,GAAG,OAAO,EACrB,kBAAkB,GAAG,KAAK,EAC1B,qBAAqB,GAAG,KAAK,EAC7B,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,GACK;IACvB,MAAM,UAAU,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IACvD,MAAM,aAAa,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IAC1D,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC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;YAGzB,6BACE,SAAS,EAAE,MAAM,CAAC,QAAQ,EAC1B,cAAc,EAAE,0BAA0B,EAC1C,cAAc,EAAE,0BAA0B;gBAI1C,6BACE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,gBAAgB,CAAC,EACxD,GAAG,EAAE,aAAa,EAClB,aAAa,EAAE,mBAAmB,EAClC,SAAS,EAAE,mBAAmB,IAE7B,QAAQ,CACL;gBAEL,CAAC,UAAU,IAAI,CAAC,WAAW,IAAI,WAAW,IAAI,WAAW,IAAI;gBAC5D,4EAA4E;gBAC5E,0EAA0E;gBAC1E,oBAAC,OAAO,IAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,GAAI,CACjG,CACG,CACF;QAEN,oBAAC,aAAa,IAAC,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,WAAW,IAC1D,iBAAiB,CAAC,GAAG,CACpB,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,CACnB,UAAU,CAAC,SAAS,CAAC,IAAI,CACvB,oBAAC,eAAe,IACd,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,CAAC,UAAU,IAAI,WAAW,EAChC,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,EAC5B,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAG,SAAS,CAAC,EAC5C,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,KAAK,GAClB,CACH,CACJ,CACa,CACf,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\nimport { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';\n\nimport Tooltip from '../tooltip';\nimport DirectionButton from './direction-button';\nimport { Direction, DragHandleWrapperProps } from './interfaces';\nimport PortalOverlay from './portal-overlay';\n\nimport styles from './styles.css.js';\nimport testUtilsStyles from './test-classes/styles.css.js';\n\n// The UAP buttons are forced to top/bottom position if the handle is close to the screen edge.\nconst FORCED_POSITION_PROXIMITY_PX = 50;\n// Approximate UAP button size with margins to decide forced direction.\nconst UAP_BUTTON_SIZE_PX = 40;\nconst DIRECTIONS_ORDER: Direction[] = ['block-end', 'block-start', 'inline-end', 'inline-start'];\n\nexport default function DragHandleWrapper({\n directions,\n tooltipText,\n children,\n onDirectionClick,\n triggerMode = 'focus',\n initialShowButtons = false,\n controlledShowButtons = false,\n wrapperClassName,\n hideButtonsOnDrag,\n clickDragThreshold,\n}: DragHandleWrapperProps) {\n const wrapperRef = useRef<HTMLDivElement | null>(null);\n const dragHandleRef = useRef<HTMLDivElement | null>(null);\n const [showTooltip, setShowTooltip] = useState(false);\n const [uncontrolledShowButtons, setUncontrolledShowButtons] = useState(initialShowButtons);\n\n const isPointerDown = useRef(false);\n const initialPointerPosition = useRef<{ x: number; y: number } | undefined>();\n const didPointerDrag = useRef(false);\n\n // The tooltip (\"Drag or select to move/resize\") shouldn't show if clicking\n // on the handle wouldn't do anything.\n const isDisabled =\n !directions['block-start'] && !directions['block-end'] && !directions['inline-start'] && !directions['inline-end'];\n\n const onWrapperFocusIn: React.FocusEventHandler = event => {\n // The drag handle is focused when it's either tabbed to, or the pointer\n // is pressed on it. We exclude handling the pointer press in this handler,\n // since it could be the start of a drag event - the pointer stuff is\n // handled in the \"pointerup\" listener instead. In cases where focus is moved\n // to the button (by manually calling `.focus()`), the buttons should only appear\n // if the action that triggered the focus move was the result of a keypress.\n if (document.body.dataset.awsuiFocusVisible && !nodeContains(wrapperRef.current, event.relatedTarget)) {\n setShowTooltip(false);\n if (triggerMode === 'focus') {\n setUncontrolledShowButtons(true);\n }\n }\n };\n\n const onWrapperFocusOut: React.FocusEventHandler = event => {\n // Close the directional buttons when the focus leaves the drag handle.\n // \"focusout\" is also triggered when the user switches to another tab, but\n // since it'll be returned when they switch back anyway, we exclude that\n // case by checking for `document.hasFocus()`.\n if (document.hasFocus() && !nodeContains(wrapperRef.current, event.relatedTarget)) {\n setUncontrolledShowButtons(false);\n }\n };\n\n useEffect(() => {\n const controller = new AbortController();\n\n // We need to differentiate between a \"click\" and a \"drag\" action.\n // We can say a \"click\" happens when a \"pointerdown\" is followed by\n // a \"pointerup\" with no \"pointermove\" between the two.\n // However, it would be a poor usability experience if a \"click\" isn't\n // registered because, while pressing my mouse, I moved it by just one\n // pixel, making it a \"drag\" instead. So we allow the pointer to move by\n // `clickDragThreshold` pixels before setting `didPointerDrag` to true.\n document.addEventListener(\n 'pointermove',\n event => {\n if (\n isPointerDown.current &&\n initialPointerPosition.current &&\n (event.clientX > initialPointerPosition.current.x + clickDragThreshold ||\n event.clientX < initialPointerPosition.current.x - clickDragThreshold ||\n event.clientY > initialPointerPosition.current.y + clickDragThreshold ||\n event.clientY < initialPointerPosition.current.y - clickDragThreshold)\n ) {\n didPointerDrag.current = true;\n if (hideButtonsOnDrag) {\n setUncontrolledShowButtons(false);\n }\n }\n },\n { signal: controller.signal }\n );\n\n // Shared behavior when a \"pointerdown\" state ends. This is shared so it\n // can be called for both \"pointercancel\" and \"pointerup\" events.\n const resetPointerDownState = () => {\n isPointerDown.current = false;\n initialPointerPosition.current = undefined;\n };\n\n document.addEventListener(\n 'pointercancel',\n () => {\n resetPointerDownState();\n },\n { signal: controller.signal }\n );\n\n document.addEventListener(\n 'pointerup',\n () => {\n if (isPointerDown.current && !didPointerDrag.current) {\n // The cursor didn't move much between \"pointerdown\" and \"pointerup\".\n // Handle this as a \"click\" instead of a \"drag\".\n setUncontrolledShowButtons(true);\n }\n resetPointerDownState();\n },\n { signal: controller.signal }\n );\n\n return () => controller.abort();\n }, [clickDragThreshold, hideButtonsOnDrag]);\n\n const onHandlePointerDown: React.PointerEventHandler = event => {\n // Tooltip behavior: the tooltip should appear on hover, but disappear when\n // the pointer starts dragging (having the tooltip get in the way while\n // you're trying to drag upwards is annoying). Additionally, the tooltip\n // shouldn't reappear when dragging ends, but only when the pointer leaves\n // the drag handle and comes back.\n\n isPointerDown.current = true;\n didPointerDrag.current = false;\n initialPointerPosition.current = { x: event.clientX, y: event.clientY };\n setShowTooltip(false);\n };\n\n // Tooltip behavior: the tooltip should stay open when the cursor moves\n // from the drag handle into the tooltip content itself. This is why the\n // handler is set on the wrapper for both the drag handle and the tooltip.\n const onTooltipGroupPointerEnter: React.PointerEventHandler = () => {\n if (!isPointerDown.current) {\n setShowTooltip(true);\n }\n };\n const onTooltipGroupPointerLeave: React.PointerEventHandler = () => {\n setShowTooltip(false);\n };\n\n const onDragHandleKeyDown: React.KeyboardEventHandler = event => {\n // For accessibility reasons, pressing escape should always close the floating controls.\n if (event.key === 'Escape') {\n setUncontrolledShowButtons(false);\n } else if (triggerMode === 'keyboard-activate' && (event.key === 'Enter' || event.key === ' ')) {\n // toggle buttons when Enter or space is pressed in 'keyboard-activate' triggerMode\n setUncontrolledShowButtons(prevShowButtons => !prevShowButtons);\n } else if (\n event.key !== 'Alt' &&\n event.key !== 'Control' &&\n event.key !== 'Meta' &&\n event.key !== 'Shift' &&\n triggerMode === 'focus'\n ) {\n // Pressing any other key will display the focus-visible ring around the\n // drag handle if it's in focus, so we should also show the buttons now.\n setUncontrolledShowButtons(true);\n }\n };\n\n const showButtons = triggerMode === 'controlled' ? controlledShowButtons : uncontrolledShowButtons;\n\n const [forcedPosition, setForcedPosition] = useState<null | 'top' | 'bottom'>(null);\n const directionsOrder = forcedPosition === 'bottom' ? [...DIRECTIONS_ORDER].reverse() : DIRECTIONS_ORDER;\n const visibleDirections = directionsOrder.filter(dir => directions[dir]);\n\n // Continuously monitor position while buttons are shown to handle CSS transitions/animations.\n // The position needs to be recalculated as the element may animate into its final position.\n useEffect(() => {\n if (!showButtons || !dragHandleRef.current) {\n if (forcedPosition !== null) {\n setForcedPosition(null);\n }\n return;\n }\n\n let frameId: number;\n\n const checkPosition = () => {\n if (!dragHandleRef.current) {\n return;\n }\n const rect = getLogicalBoundingClientRect(dragHandleRef.current);\n const conflicts = {\n 'block-start': rect.insetBlockStart < FORCED_POSITION_PROXIMITY_PX,\n 'block-end': window.innerHeight - rect.insetBlockEnd < FORCED_POSITION_PROXIMITY_PX,\n 'inline-start': rect.insetInlineStart < FORCED_POSITION_PROXIMITY_PX,\n 'inline-end': window.innerWidth - rect.insetInlineEnd < FORCED_POSITION_PROXIMITY_PX,\n };\n if (visibleDirections.some(direction => conflicts[direction])) {\n const hasEnoughSpaceAbove = rect.insetBlockStart > visibleDirections.length * UAP_BUTTON_SIZE_PX;\n setForcedPosition(hasEnoughSpaceAbove ? 'top' : 'bottom');\n } else {\n setForcedPosition(null);\n }\n frameId = requestAnimationFrame(checkPosition);\n };\n\n frameId = requestAnimationFrame(checkPosition);\n\n return () => {\n cancelAnimationFrame(frameId);\n };\n }, [forcedPosition, showButtons, visibleDirections]);\n\n return (\n <>\n {/* Wrapper for focus detection. The buttons are shown when any element inside this wrapper is\n focused, either via the keyboard or a pointer press. The UAP buttons will never receive focus. */}\n <div\n className={clsx(testUtilsStyles.root, styles.contents)}\n ref={wrapperRef}\n onFocus={onWrapperFocusIn}\n onBlur={onWrapperFocusOut}\n >\n {/* Wrapper for pointer detection. Determines whether or not the tooltip should be shown. */}\n <div\n className={styles.contents}\n onPointerEnter={onTooltipGroupPointerEnter}\n onPointerLeave={onTooltipGroupPointerLeave}\n >\n {/* Position tracking wrapper used to position the tooltip and drag buttons accurately.\n Its dimensions must match the inner button's dimensions. */}\n <div\n className={clsx(styles['drag-handle'], wrapperClassName)}\n ref={dragHandleRef}\n onPointerDown={onHandlePointerDown}\n onKeyDown={onDragHandleKeyDown}\n >\n {children}\n </div>\n\n {!isDisabled && !showButtons && showTooltip && tooltipText && (\n // Rendered in a portal but pointerenter/pointerleave events still propagate\n // up the React DOM tree, which is why it's placed in this nested context.\n <Tooltip trackRef={dragHandleRef} value={tooltipText} onDismiss={() => setShowTooltip(false)} />\n )}\n </div>\n </div>\n\n <PortalOverlay track={dragHandleRef} isDisabled={!showButtons}>\n {visibleDirections.map(\n (direction, index) =>\n directions[direction] && (\n <DirectionButton\n key={direction}\n show={!isDisabled && showButtons}\n direction={direction}\n state={directions[direction]}\n onClick={() => onDirectionClick?.(direction)}\n forcedPosition={forcedPosition}\n forcedIndex={index}\n />\n )\n )}\n </PortalOverlay>\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle-wrapper/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAE1G,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,eAAe,MAAM,oBAAoB,CAAC;AAEjD,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAE3D,+FAA+F;AAC/F,MAAM,4BAA4B,GAAG,EAAE,CAAC;AACxC,uEAAuE;AACvE,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,gBAAgB,GAAgB,CAAC,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;AAEjG,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,UAAU,EACV,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,WAAW,GAAG,OAA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,CAAC,SAAS,CAAC,EAC5B,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAG,SAAS,CAAC,EAC5C,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,KAAK,GAClB,CACH,CACJ,CACa,CACf,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\nimport { getLogicalBoundingClientRect, useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport Tooltip from '../tooltip';\nimport DirectionButton from './direction-button';\nimport { Direction, DragHandleWrapperProps } from './interfaces';\nimport PortalOverlay from './portal-overlay';\n\nimport styles from './styles.css.js';\nimport testUtilsStyles from './test-classes/styles.css.js';\n\n// The UAP buttons are forced to top/bottom position if the handle is close to the screen edge.\nconst FORCED_POSITION_PROXIMITY_PX = 50;\n// Approximate UAP button size with margins to decide forced direction.\nconst UAP_BUTTON_SIZE_PX = 40;\nconst DIRECTIONS_ORDER: Direction[] = ['block-end', 'block-start', 'inline-end', 'inline-start'];\n\nexport default function DragHandleWrapper({\n directions,\n tooltipText,\n children,\n onDirectionClick,\n triggerMode = 'focus',\n initialShowButtons = false,\n controlledShowButtons = false,\n wrapperClassName,\n hideButtonsOnDrag,\n clickDragThreshold,\n}: DragHandleWrapperProps) {\n const wrapperRef = useRef<HTMLDivElement | null>(null);\n const dragHandleRef = useRef<HTMLDivElement | null>(null);\n // Links the portaled UAP buttons back to the drag handle's position in the regular DOM,\n // so outside-click / focus detection treats them as belonging to the handle's container.\n const referrerId = useUniqueId('drag-handle');\n const [showTooltip, setShowTooltip] = useState(false);\n const [uncontrolledShowButtons, setUncontrolledShowButtons] = useState(initialShowButtons);\n\n const isPointerDown = useRef(false);\n const initialPointerPosition = useRef<{ x: number; y: number } | undefined>();\n const didPointerDrag = useRef(false);\n\n // The tooltip (\"Drag or select to move/resize\") shouldn't show if clicking\n // on the handle wouldn't do anything.\n const isDisabled =\n !directions['block-start'] && !directions['block-end'] && !directions['inline-start'] && !directions['inline-end'];\n\n const onWrapperFocusIn: React.FocusEventHandler = event => {\n // The drag handle is focused when it's either tabbed to, or the pointer\n // is pressed on it. We exclude handling the pointer press in this handler,\n // since it could be the start of a drag event - the pointer stuff is\n // handled in the \"pointerup\" listener instead. In cases where focus is moved\n // to the button (by manually calling `.focus()`), the buttons should only appear\n // if the action that triggered the focus move was the result of a keypress.\n if (document.body.dataset.awsuiFocusVisible && !nodeContains(wrapperRef.current, event.relatedTarget)) {\n setShowTooltip(false);\n if (triggerMode === 'focus') {\n setUncontrolledShowButtons(true);\n }\n }\n };\n\n const onWrapperFocusOut: React.FocusEventHandler = event => {\n // Close the directional buttons when the focus leaves the drag handle.\n // \"focusout\" is also triggered when the user switches to another tab, but\n // since it'll be returned when they switch back anyway, we exclude that\n // case by checking for `document.hasFocus()`.\n if (document.hasFocus() && !nodeContains(wrapperRef.current, event.relatedTarget)) {\n setUncontrolledShowButtons(false);\n }\n };\n\n useEffect(() => {\n const controller = new AbortController();\n\n // We need to differentiate between a \"click\" and a \"drag\" action.\n // We can say a \"click\" happens when a \"pointerdown\" is followed by\n // a \"pointerup\" with no \"pointermove\" between the two.\n // However, it would be a poor usability experience if a \"click\" isn't\n // registered because, while pressing my mouse, I moved it by just one\n // pixel, making it a \"drag\" instead. So we allow the pointer to move by\n // `clickDragThreshold` pixels before setting `didPointerDrag` to true.\n document.addEventListener(\n 'pointermove',\n event => {\n if (\n isPointerDown.current &&\n initialPointerPosition.current &&\n (event.clientX > initialPointerPosition.current.x + clickDragThreshold ||\n event.clientX < initialPointerPosition.current.x - clickDragThreshold ||\n event.clientY > initialPointerPosition.current.y + clickDragThreshold ||\n event.clientY < initialPointerPosition.current.y - clickDragThreshold)\n ) {\n didPointerDrag.current = true;\n if (hideButtonsOnDrag) {\n setUncontrolledShowButtons(false);\n }\n }\n },\n { signal: controller.signal }\n );\n\n // Shared behavior when a \"pointerdown\" state ends. This is shared so it\n // can be called for both \"pointercancel\" and \"pointerup\" events.\n const resetPointerDownState = () => {\n isPointerDown.current = false;\n initialPointerPosition.current = undefined;\n };\n\n document.addEventListener(\n 'pointercancel',\n () => {\n resetPointerDownState();\n },\n { signal: controller.signal }\n );\n\n document.addEventListener(\n 'pointerup',\n () => {\n if (isPointerDown.current && !didPointerDrag.current) {\n // The cursor didn't move much between \"pointerdown\" and \"pointerup\".\n // Handle this as a \"click\" instead of a \"drag\".\n setUncontrolledShowButtons(true);\n }\n resetPointerDownState();\n },\n { signal: controller.signal }\n );\n\n return () => controller.abort();\n }, [clickDragThreshold, hideButtonsOnDrag]);\n\n const onHandlePointerDown: React.PointerEventHandler = event => {\n // Tooltip behavior: the tooltip should appear on hover, but disappear when\n // the pointer starts dragging (having the tooltip get in the way while\n // you're trying to drag upwards is annoying). Additionally, the tooltip\n // shouldn't reappear when dragging ends, but only when the pointer leaves\n // the drag handle and comes back.\n\n isPointerDown.current = true;\n didPointerDrag.current = false;\n initialPointerPosition.current = { x: event.clientX, y: event.clientY };\n setShowTooltip(false);\n };\n\n // Tooltip behavior: the tooltip should stay open when the cursor moves\n // from the drag handle into the tooltip content itself. This is why the\n // handler is set on the wrapper for both the drag handle and the tooltip.\n const onTooltipGroupPointerEnter: React.PointerEventHandler = () => {\n if (!isPointerDown.current) {\n setShowTooltip(true);\n }\n };\n const onTooltipGroupPointerLeave: React.PointerEventHandler = () => {\n setShowTooltip(false);\n };\n\n const onDragHandleKeyDown: React.KeyboardEventHandler = event => {\n // For accessibility reasons, pressing escape should always close the floating controls.\n if (event.key === 'Escape') {\n setUncontrolledShowButtons(false);\n } else if (triggerMode === 'keyboard-activate' && (event.key === 'Enter' || event.key === ' ')) {\n // toggle buttons when Enter or space is pressed in 'keyboard-activate' triggerMode\n setUncontrolledShowButtons(prevShowButtons => !prevShowButtons);\n } else if (\n event.key !== 'Alt' &&\n event.key !== 'Control' &&\n event.key !== 'Meta' &&\n event.key !== 'Shift' &&\n triggerMode === 'focus'\n ) {\n // Pressing any other key will display the focus-visible ring around the\n // drag handle if it's in focus, so we should also show the buttons now.\n setUncontrolledShowButtons(true);\n }\n };\n\n const showButtons = triggerMode === 'controlled' ? controlledShowButtons : uncontrolledShowButtons;\n\n const [forcedPosition, setForcedPosition] = useState<null | 'top' | 'bottom'>(null);\n const directionsOrder = forcedPosition === 'bottom' ? [...DIRECTIONS_ORDER].reverse() : DIRECTIONS_ORDER;\n const visibleDirections = directionsOrder.filter(dir => directions[dir]);\n\n // Continuously monitor position while buttons are shown to handle CSS transitions/animations.\n // The position needs to be recalculated as the element may animate into its final position.\n useEffect(() => {\n if (!showButtons || !dragHandleRef.current) {\n if (forcedPosition !== null) {\n setForcedPosition(null);\n }\n return;\n }\n\n let frameId: number;\n\n const checkPosition = () => {\n if (!dragHandleRef.current) {\n return;\n }\n const rect = getLogicalBoundingClientRect(dragHandleRef.current);\n const conflicts = {\n 'block-start': rect.insetBlockStart < FORCED_POSITION_PROXIMITY_PX,\n 'block-end': window.innerHeight - rect.insetBlockEnd < FORCED_POSITION_PROXIMITY_PX,\n 'inline-start': rect.insetInlineStart < FORCED_POSITION_PROXIMITY_PX,\n 'inline-end': window.innerWidth - rect.insetInlineEnd < FORCED_POSITION_PROXIMITY_PX,\n };\n if (visibleDirections.some(direction => conflicts[direction])) {\n const hasEnoughSpaceAbove = rect.insetBlockStart > visibleDirections.length * UAP_BUTTON_SIZE_PX;\n setForcedPosition(hasEnoughSpaceAbove ? 'top' : 'bottom');\n } else {\n setForcedPosition(null);\n }\n frameId = requestAnimationFrame(checkPosition);\n };\n\n frameId = requestAnimationFrame(checkPosition);\n\n return () => {\n cancelAnimationFrame(frameId);\n };\n }, [forcedPosition, showButtons, visibleDirections]);\n\n return (\n <>\n {/* Wrapper for focus detection. The buttons are shown when any element inside this wrapper is\n focused, either via the keyboard or a pointer press. The UAP buttons will never receive focus. */}\n <div\n className={clsx(testUtilsStyles.root, styles.contents)}\n ref={wrapperRef}\n onFocus={onWrapperFocusIn}\n onBlur={onWrapperFocusOut}\n >\n {/* Wrapper for pointer detection. Determines whether or not the tooltip should be shown. */}\n <div\n className={styles.contents}\n onPointerEnter={onTooltipGroupPointerEnter}\n onPointerLeave={onTooltipGroupPointerLeave}\n >\n {/* Position tracking wrapper used to position the tooltip and drag buttons accurately.\n Its dimensions must match the inner button's dimensions. */}\n <div\n className={clsx(styles['drag-handle'], wrapperClassName)}\n ref={dragHandleRef}\n id={referrerId}\n onPointerDown={onHandlePointerDown}\n onKeyDown={onDragHandleKeyDown}\n >\n {children}\n </div>\n\n {!isDisabled && !showButtons && showTooltip && tooltipText && (\n // Rendered in a portal but pointerenter/pointerleave events still propagate\n // up the React DOM tree, which is why it's placed in this nested context.\n <Tooltip trackRef={dragHandleRef} value={tooltipText} onDismiss={() => setShowTooltip(false)} />\n )}\n </div>\n </div>\n\n <PortalOverlay track={dragHandleRef} isDisabled={!showButtons} referrerId={referrerId}>\n {visibleDirections.map(\n (direction, index) =>\n directions[direction] && (\n <DirectionButton\n key={direction}\n show={!isDisabled && showButtons}\n direction={direction}\n state={directions[direction]}\n onClick={() => onDirectionClick?.(direction)}\n forcedPosition={forcedPosition}\n forcedIndex={index}\n />\n )\n )}\n </PortalOverlay>\n </>\n );\n}\n"]}
@@ -2,9 +2,11 @@ import React from 'react';
2
2
  export default function PortalOverlay({
3
3
  track,
4
4
  isDisabled,
5
+ referrerId,
5
6
  children
6
7
  }: {
7
8
  track: React.RefObject<HTMLElement | null>;
8
9
  isDisabled: boolean;
10
+ referrerId?: string;
9
11
  children: React.ReactNode;
10
12
  }): JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"portal-overlay.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle-wrapper/portal-overlay.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAuD,MAAM,OAAO,CAAC;AAY5E,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,KAAK,EACL,UAAU,EACV,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC3C,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,eAkEA"}
1
+ {"version":3,"file":"portal-overlay.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle-wrapper/portal-overlay.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAuD,MAAM,OAAO,CAAC;AAY5E,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,KAAK,EACL,UAAU,EACV,UAAU,EACV,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC3C,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,eA0EA"}
@@ -4,7 +4,7 @@ import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
4
4
  import clsx from 'clsx';
5
5
  import { getIsRtl, getLogicalBoundingClientRect, getScrollInlineStart, Portal, } from '@cloudscape-design/component-toolkit/internal';
6
6
  import styles from './styles.css.js';
7
- export default function PortalOverlay({ track, isDisabled, children, }) {
7
+ export default function PortalOverlay({ track, isDisabled, referrerId, children, }) {
8
8
  const ref = useRef(null);
9
9
  const [container, setContainer] = useState(null);
10
10
  useLayoutEffect(() => {
@@ -57,7 +57,7 @@ export default function PortalOverlay({ track, isDisabled, children, }) {
57
57
  };
58
58
  }, [isDisabled, track]);
59
59
  return (React.createElement(Portal, { container: container },
60
- React.createElement("span", { ref: ref, className: clsx(styles['portal-overlay'], isDisabled && styles['portal-overlay-disabled']) },
60
+ React.createElement("span", { ref: ref, "data-awsui-referrer-id": referrerId, className: clsx(styles['portal-overlay'], isDisabled && styles['portal-overlay-disabled']) },
61
61
  React.createElement("span", { className: styles['portal-overlay-contents'] }, children))));
62
62
  }
63
63
  //# sourceMappingURL=portal-overlay.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"portal-overlay.js","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle-wrapper/portal-overlay.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EACL,QAAQ,EACR,4BAA4B,EAC5B,oBAAoB,EACpB,MAAM,GACP,MAAM,+CAA+C,CAAC;AAEvD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,KAAK,EACL,UAAU,EACV,QAAQ,GAKT;IACC,MAAM,GAAG,GAAG,MAAM,CAAyB,IAAI,CAAC,CAAC;IACjD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAwB,IAAI,CAAC,CAAC;IAExE,eAAe,CAAC,GAAG,EAAE;QACnB,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YACtE,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;YAC3D,YAAY,CAAC,YAAY,CAAC,CAAC;YAC3B,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;QACrC,CAAC;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,KAAK,CAAC,OAA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K,GAAG,GAAG,UAAU,IAAI,CAAC;oBAC5C,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,SAAS,IAAI,CAAC;oBAC5C,cAAc,GAAG,UAAU,CAAC;oBAC5B,aAAa,GAAG,SAAS,CAAC;gBAC5B,CAAC;YACH,CAAC;YACD,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,qBAAqB,CAAC,aAAa,CAAC,CAAC;YACvC,CAAC;QACH,CAAC,CAAC;QACF,aAAa,EAAE,CAAC;QAEhB,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;IAExB,OAAO,CACL,oBAAC,MAAM,IAAC,SAAS,EAAE,SAAS;QAC1B,8BAAM,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,UAAU,IAAI,MAAM,CAAC,yBAAyB,CAAC,CAAC;YACxG,8BAAM,SAAS,EAAE,MAAM,CAAC,yBAAyB,CAAC,IAAG,QAAQ,CAAQ,CAChE,CACA,CACV,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport {\n getIsRtl,\n getLogicalBoundingClientRect,\n getScrollInlineStart,\n Portal,\n} from '@cloudscape-design/component-toolkit/internal';\n\nimport styles from './styles.css.js';\n\nexport default function PortalOverlay({\n track,\n isDisabled,\n children,\n}: {\n track: React.RefObject<HTMLElement | null>;\n isDisabled: boolean;\n children: React.ReactNode;\n}) {\n const ref = useRef<HTMLSpanElement | null>(null);\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n\n useLayoutEffect(() => {\n if (track.current) {\n const newContainer = track.current.ownerDocument.createElement('div');\n track.current.ownerDocument.body.appendChild(newContainer);\n setContainer(newContainer);\n return () => newContainer.remove();\n }\n }, [track]);\n\n useEffect(() => {\n if (track.current === null || isDisabled) {\n return;\n }\n\n let cleanedUp = false;\n let lastX: number | undefined;\n let lastY: number | undefined;\n let lastInlineSize: number | undefined;\n let lastBlockSize: number | undefined;\n const updateElement = () => {\n // It could be that the portal hasn't been attached to the DOM yet - ensure the ref exists and is attached DOM tree.\n if (track.current && ref.current && document.body.contains(ref.current)) {\n const isRtl = getIsRtl(ref.current);\n const { insetInlineStart, insetBlockStart, inlineSize, blockSize } = getLogicalBoundingClientRect(\n track.current\n );\n // For simplicity, we just make all our calculations independent of\n // the browser's scrolling edge. When it comes to applying the changes,\n // translate is independent of writing direction, so we need to invert\n // the X coordinate ourselves just before applying the values.\n const newX = (insetInlineStart + getScrollInlineStart(document.documentElement)) * (isRtl ? -1 : 1);\n const newY = insetBlockStart + document.documentElement.scrollTop;\n if (lastX !== newX || lastY !== newY) {\n ref.current.style.translate = `${newX}px ${newY}px`;\n lastX = newX;\n lastY = newY;\n }\n if (lastInlineSize !== inlineSize || lastBlockSize !== blockSize) {\n ref.current.style.width = `${inlineSize}px`;\n ref.current.style.height = `${blockSize}px`;\n lastInlineSize = inlineSize;\n lastBlockSize = blockSize;\n }\n }\n if (!cleanedUp) {\n requestAnimationFrame(updateElement);\n }\n };\n updateElement();\n\n return () => {\n cleanedUp = true;\n };\n }, [isDisabled, track]);\n\n return (\n <Portal container={container}>\n <span ref={ref} className={clsx(styles['portal-overlay'], isDisabled && styles['portal-overlay-disabled'])}>\n <span className={styles['portal-overlay-contents']}>{children}</span>\n </span>\n </Portal>\n );\n}\n"]}
1
+ {"version":3,"file":"portal-overlay.js","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle-wrapper/portal-overlay.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE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GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;IAExB,OAAO,CACL,oBAAC,MAAM,IAAC,SAAS,EAAE,SAAS;QAK1B,8BACE,GAAG,EAAE,GAAG,4BACgB,UAAU,EAClC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,UAAU,IAAI,MAAM,CAAC,yBAAyB,CAAC,CAAC;YAE1F,8BAAM,SAAS,EAAE,MAAM,CAAC,yBAAyB,CAAC,IAAG,QAAQ,CAAQ,CAChE,CACA,CACV,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport {\n getIsRtl,\n getLogicalBoundingClientRect,\n getScrollInlineStart,\n Portal,\n} from '@cloudscape-design/component-toolkit/internal';\n\nimport styles from './styles.css.js';\n\nexport default function PortalOverlay({\n track,\n isDisabled,\n referrerId,\n children,\n}: {\n track: React.RefObject<HTMLElement | null>;\n isDisabled: boolean;\n referrerId?: string;\n children: React.ReactNode;\n}) {\n const ref = useRef<HTMLSpanElement | null>(null);\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n\n useLayoutEffect(() => {\n if (track.current) {\n const newContainer = track.current.ownerDocument.createElement('div');\n track.current.ownerDocument.body.appendChild(newContainer);\n setContainer(newContainer);\n return () => newContainer.remove();\n }\n }, [track]);\n\n useEffect(() => {\n if (track.current === null || isDisabled) {\n return;\n }\n\n let cleanedUp = false;\n let lastX: number | undefined;\n let lastY: number | undefined;\n let lastInlineSize: number | undefined;\n let lastBlockSize: number | undefined;\n const updateElement = () => {\n // It could be that the portal hasn't been attached to the DOM yet - ensure the ref exists and is attached DOM tree.\n if (track.current && ref.current && document.body.contains(ref.current)) {\n const isRtl = getIsRtl(ref.current);\n const { insetInlineStart, insetBlockStart, inlineSize, blockSize } = getLogicalBoundingClientRect(\n track.current\n );\n // For simplicity, we just make all our calculations independent of\n // the browser's scrolling edge. When it comes to applying the changes,\n // translate is independent of writing direction, so we need to invert\n // the X coordinate ourselves just before applying the values.\n const newX = (insetInlineStart + getScrollInlineStart(document.documentElement)) * (isRtl ? -1 : 1);\n const newY = insetBlockStart + document.documentElement.scrollTop;\n if (lastX !== newX || lastY !== newY) {\n ref.current.style.translate = `${newX}px ${newY}px`;\n lastX = newX;\n lastY = newY;\n }\n if (lastInlineSize !== inlineSize || lastBlockSize !== blockSize) {\n ref.current.style.width = `${inlineSize}px`;\n ref.current.style.height = `${blockSize}px`;\n lastInlineSize = inlineSize;\n lastBlockSize = blockSize;\n }\n }\n if (!cleanedUp) {\n requestAnimationFrame(updateElement);\n }\n };\n updateElement();\n\n return () => {\n cleanedUp = true;\n };\n }, [isDisabled, track]);\n\n return (\n <Portal container={container}>\n {/* `data-awsui-referrer-id` links this portaled overlay back to the tracked element in the\n regular DOM, so outside-click / focus detection (see `nodeBelongs`) treats interactions\n with the UAP buttons as belonging to wherever the drag handle is mounted (e.g. inside a\n dropdown), instead of as a click outside it. */}\n <span\n ref={ref}\n data-awsui-referrer-id={referrerId}\n className={clsx(styles['portal-overlay'], isDisabled && styles['portal-overlay-disabled'])}\n >\n <span className={styles['portal-overlay-contents']}>{children}</span>\n </span>\n </Portal>\n );\n}\n"]}
@@ -2,12 +2,12 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import React, { useRef } from 'react';
4
4
  import clsx from 'clsx';
5
- import { useSingleTabStopNavigation } from '@cloudscape-design/component-toolkit/internal';
5
+ import { isThemeActive, Theme, useSingleTabStopNavigation } from '@cloudscape-design/component-toolkit/internal';
6
6
  import InternalIcon from '../../../icon/internal';
7
7
  import styles from './styles.css.js';
8
8
  export function ExpandToggleButton({ isExpanded, onExpandableItemToggle, expandButtonLabel, collapseButtonLabel, customIcon, className, disableFocusHighlight, }) {
9
9
  const buttonRef = useRef(null);
10
10
  const { tabIndex } = useSingleTabStopNavigation(buttonRef);
11
- return (React.createElement("button", { type: "button", ref: buttonRef, tabIndex: tabIndex, "aria-label": isExpanded ? collapseButtonLabel : expandButtonLabel, "aria-expanded": isExpanded, className: clsx(styles['expand-toggle'], disableFocusHighlight && styles['disable-focus-highlight'], className), onClick: onExpandableItemToggle }, customIcon !== null && customIcon !== void 0 ? customIcon : (React.createElement(InternalIcon, { size: "small", name: "caret-down-filled", className: clsx(styles['expand-toggle-icon'], isExpanded && styles['expand-toggle-icon-expanded']) }))));
11
+ return (React.createElement("button", { type: "button", ref: buttonRef, tabIndex: tabIndex, "aria-label": isExpanded ? collapseButtonLabel : expandButtonLabel, "aria-expanded": isExpanded, className: clsx(styles['expand-toggle'], disableFocusHighlight && styles['disable-focus-highlight'], className), onClick: onExpandableItemToggle }, customIcon !== null && customIcon !== void 0 ? customIcon : (React.createElement(InternalIcon, { size: isThemeActive(Theme.OneTheme) ? 'x-small' : 'small', name: isThemeActive(Theme.OneTheme) ? 'angle-down' : 'caret-down-filled', className: clsx(styles['expand-toggle-icon'], isExpanded && styles['expand-toggle-icon-expanded']) }))));
12
12
  }
13
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/expand-toggle-button/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAE3F,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAElD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,MAAM,UAAU,kBAAkB,CAAC,EACjC,UAAU,EACV,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,EACV,SAAS,EACT,qBAAqB,GAStB;IACC,MAAM,SAAS,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAClD,MAAM,EAAE,QAAQ,EAAE,GAAG,0BAA0B,CAAC,SAAS,CAAC,CAAC;IAE3D,OAAO,CACL,gCACE,IAAI,EAAC,QAAQ,EACb,GAAG,EAAE,SAAS,EACd,QAAQ,EAAE,QAAQ,gBACN,UAAU,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,iBAAiB,mBACjD,UAAU,EACzB,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,qBAAqB,IAAI,MAAM,CAAC,yBAAyB,CAAC,EAAE,SAAS,CAAC,EAC/G,OAAO,EAAE,sBAAsB,IAE9B,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,CACb,oBAAC,YAAY,IACX,IAAI,EAAC,OAAO,EACZ,IAAI,EAAC,mBAAmB,EACxB,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,EAAE,UAAU,IAAI,MAAM,CAAC,6BAA6B,CAAC,CAAC,GAClG,CACH,CACM,CACV,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useSingleTabStopNavigation } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalIcon from '../../../icon/internal';\n\nimport styles from './styles.css.js';\n\nexport function ExpandToggleButton({\n isExpanded,\n onExpandableItemToggle,\n expandButtonLabel,\n collapseButtonLabel,\n customIcon,\n className,\n disableFocusHighlight,\n}: {\n isExpanded?: boolean;\n onExpandableItemToggle?: () => void;\n expandButtonLabel?: string;\n collapseButtonLabel?: string;\n customIcon?: React.ReactNode;\n className?: string;\n disableFocusHighlight?: boolean;\n}) {\n const buttonRef = useRef<HTMLButtonElement>(null);\n const { tabIndex } = useSingleTabStopNavigation(buttonRef);\n\n return (\n <button\n type=\"button\"\n ref={buttonRef}\n tabIndex={tabIndex}\n aria-label={isExpanded ? collapseButtonLabel : expandButtonLabel}\n aria-expanded={isExpanded}\n className={clsx(styles['expand-toggle'], disableFocusHighlight && styles['disable-focus-highlight'], className)}\n onClick={onExpandableItemToggle}\n >\n {customIcon ?? (\n <InternalIcon\n size=\"small\"\n name=\"caret-down-filled\"\n className={clsx(styles['expand-toggle-icon'], isExpanded && styles['expand-toggle-icon-expanded'])}\n />\n )}\n </button>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/expand-toggle-button/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAEjH,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAElD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,MAAM,UAAU,kBAAkB,CAAC,EACjC,UAAU,EACV,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,EACV,SAAS,EACT,qBAAqB,GAStB;IACC,MAAM,SAAS,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAClD,MAAM,EAAE,QAAQ,EAAE,GAAG,0BAA0B,CAAC,SAAS,CAAC,CAAC;IAE3D,OAAO,CACL,gCACE,IAAI,EAAC,QAAQ,EACb,GAAG,EAAE,SAAS,EACd,QAAQ,EAAE,QAAQ,gBACN,UAAU,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,iBAAiB,mBACjD,UAAU,EACzB,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,qBAAqB,IAAI,MAAM,CAAC,yBAAyB,CAAC,EAAE,SAAS,CAAC,EAC/G,OAAO,EAAE,sBAAsB,IAE9B,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,CACb,oBAAC,YAAY,IACX,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,EACzD,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,mBAAmB,EACxE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,EAAE,UAAU,IAAI,MAAM,CAAC,6BAA6B,CAAC,CAAC,GAClG,CACH,CACM,CACV,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { isThemeActive, Theme, useSingleTabStopNavigation } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalIcon from '../../../icon/internal';\n\nimport styles from './styles.css.js';\n\nexport function ExpandToggleButton({\n isExpanded,\n onExpandableItemToggle,\n expandButtonLabel,\n collapseButtonLabel,\n customIcon,\n className,\n disableFocusHighlight,\n}: {\n isExpanded?: boolean;\n onExpandableItemToggle?: () => void;\n expandButtonLabel?: string;\n collapseButtonLabel?: string;\n customIcon?: React.ReactNode;\n className?: string;\n disableFocusHighlight?: boolean;\n}) {\n const buttonRef = useRef<HTMLButtonElement>(null);\n const { tabIndex } = useSingleTabStopNavigation(buttonRef);\n\n return (\n <button\n type=\"button\"\n ref={buttonRef}\n tabIndex={tabIndex}\n aria-label={isExpanded ? collapseButtonLabel : expandButtonLabel}\n aria-expanded={isExpanded}\n className={clsx(styles['expand-toggle'], disableFocusHighlight && styles['disable-focus-highlight'], className)}\n onClick={onExpandableItemToggle}\n >\n {customIcon ?? (\n <InternalIcon\n size={isThemeActive(Theme.OneTheme) ? 'x-small' : 'small'}\n name={isThemeActive(Theme.OneTheme) ? 'angle-down' : 'caret-down-filled'}\n className={clsx(styles['expand-toggle-icon'], isExpanded && styles['expand-toggle-icon-expanded'])}\n />\n )}\n </button>\n );\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  export var PACKAGE_SOURCE = "components";
2
- export var PACKAGE_VERSION = "3.0.0 (22d5a6b4)";
3
- export var GIT_SHA = "22d5a6b4";
2
+ export var PACKAGE_VERSION = "3.0.0 (82d11d66)";
3
+ export var GIT_SHA = "82d11d66";
4
4
  export var THEME = "open-source-visual-refresh";
5
5
  export var SYSTEM = "core";
6
6
  export var ALWAYS_VISUAL_REFRESH = true;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "PACKAGE_SOURCE": "components",
3
- "PACKAGE_VERSION": "3.0.0 (22d5a6b4)",
4
- "GIT_SHA": "22d5a6b4",
3
+ "PACKAGE_VERSION": "3.0.0 (82d11d66)",
4
+ "GIT_SHA": "82d11d66",
5
5
  "THEME": "open-source-visual-refresh",
6
6
  "SYSTEM": "core",
7
7
  "ALWAYS_VISUAL_REFRESH": true,
@@ -300,6 +300,7 @@ export const colorBackgroundButtonNormalDisabled: string;
300
300
  export const colorBackgroundButtonNormalHover: string;
301
301
  export const colorBackgroundToggleButtonNormalPressed: string;
302
302
  export const colorBackgroundToggleButtonNormalDefault: string;
303
+ export const colorBackgroundToggleButtonNormalHover: string;
303
304
  export const colorBackgroundButtonPrimaryActive: string;
304
305
  export const colorBackgroundButtonPrimaryDefault: string;
305
306
  export const colorBackgroundButtonPrimaryDisabled: string;
@@ -339,6 +340,7 @@ export const colorBackgroundLayoutMain: string;
339
340
  export const colorBackgroundDrawer: string;
340
341
  export const colorBackgroundDrawerBackdrop: string;
341
342
  export const colorBackgroundLayoutMobilePanel: string;
343
+ export const colorBackgroundLayoutPanel: string;
342
344
  export const colorBackgroundLayoutPanelContent: string;
343
345
  export const colorBackgroundLayoutPanelHover: string;
344
346
  export const colorBackgroundLayoutToolbar: string;
@@ -405,6 +407,8 @@ export const colorBorderButtonLinkDisabled: string;
405
407
  export const colorBorderButtonNormalActive: string;
406
408
  export const colorBorderButtonNormalDefault: string;
407
409
  export const colorBorderToggleButtonNormalPressed: string;
410
+ export const colorBorderToggleButtonNormalDefault: string;
411
+ export const colorBorderToggleButtonNormalHover: string;
408
412
  export const colorBorderButtonNormalDisabled: string;
409
413
  export const colorTextButtonNormalDisabled: string;
410
414
  export const colorBorderButtonNormalHover: string;
@@ -436,6 +440,7 @@ export const colorBorderDividerDefault: string;
436
440
  export const colorBorderDividerPanelBottom: string;
437
441
  export const colorBorderDividerPanelSide: string;
438
442
  export const colorBorderDividerSecondary: string;
443
+ export const colorBorderDividerTableGroup: string;
439
444
  export const colorBorderDropdownContainer: string;
440
445
  export const colorBorderDropdownGroup: string;
441
446
  export const colorBorderDropdownItemDefault: string;
@@ -459,6 +464,7 @@ export const colorBorderSegmentActive: string;
459
464
  export const colorBorderSegmentDefault: string;
460
465
  export const colorBorderSegmentDisabled: string;
461
466
  export const colorBorderSegmentHover: string;
467
+ export const colorBorderSegmentWrapper: string;
462
468
  export const colorBorderStatusError: string;
463
469
  export const colorBorderStatusInfo: string;
464
470
  export const colorBorderStatusSuccess: string;
@@ -476,6 +482,7 @@ export const colorForegroundControlReadOnly: string;
476
482
  export const colorShadowDefault: string;
477
483
  export const colorShadowMedium: string;
478
484
  export const colorShadowSide: string;
485
+ export const colorShadowToggleHandle: string;
479
486
  export const colorStrokeChartLine: string;
480
487
  export const colorStrokeCodeEditorGutterActiveLineDefault: string;
481
488
  export const colorStrokeCodeEditorGutterActiveLineHover: string;
@@ -732,6 +739,7 @@ export const borderRadiusStatusIndicator: string;
732
739
  export const borderRadiusTabsFocusRing: string;
733
740
  export const borderRadiusTiles: string;
734
741
  export const borderRadiusToken: string;
742
+ export const borderRadiusTokenInline: string;
735
743
  export const borderRadiusTutorialPanelItem: string;
736
744
  export const borderTableStickyWidth: string;
737
745
  export const borderWidthActionCardActive: string;
@@ -300,6 +300,7 @@ export var colorBackgroundButtonNormalDisabled = "var(--color-background-button-
300
300
  export var colorBackgroundButtonNormalHover = "var(--color-background-button-normal-hover-53op9s, #f0fbff)";
301
301
  export var colorBackgroundToggleButtonNormalPressed = "var(--color-background-toggle-button-normal-pressed-4khex7, #d1f1ff)";
302
302
  export var colorBackgroundToggleButtonNormalDefault = "var(--color-background-toggle-button-normal-default-ipnqr5, #ffffff)";
303
+ export var colorBackgroundToggleButtonNormalHover = "var(--color-background-toggle-button-normal-hover-0r2lj4, #f0fbff)";
303
304
  export var colorBackgroundButtonPrimaryActive = "var(--color-background-button-primary-active-5cqoqt, #002b66)";
304
305
  export var colorBackgroundButtonPrimaryDefault = "var(--color-background-button-primary-default-vdt0fu, #006ce0)";
305
306
  export var colorBackgroundButtonPrimaryDisabled = "var(--color-background-button-primary-disabled-sgo4zo, #ebebf0)";
@@ -339,6 +340,7 @@ export var colorBackgroundLayoutMain = "var(--color-background-layout-main-5ilwc
339
340
  export var colorBackgroundDrawer = "var(--color-background-drawer-5hs0eh, #ffffff)";
340
341
  export var colorBackgroundDrawerBackdrop = "var(--color-background-drawer-backdrop-ducxi3, rgba(35, 43, 55, 0.7))";
341
342
  export var colorBackgroundLayoutMobilePanel = "var(--color-background-layout-mobile-panel-ed0ava, #0f141a)";
343
+ export var colorBackgroundLayoutPanel = "var(--color-background-layout-panel-jv6exs, #ffffff)";
342
344
  export var colorBackgroundLayoutPanelContent = "var(--color-background-layout-panel-content-xto15e, #ffffff)";
343
345
  export var colorBackgroundLayoutPanelHover = "var(--color-background-layout-panel-hover-tguulw, #ebebf0)";
344
346
  export var colorBackgroundLayoutToolbar = "var(--color-background-layout-toolbar-y0cu80, #ffffff)";
@@ -405,6 +407,8 @@ export var colorBorderButtonLinkDisabled = "var(--color-border-button-link-disab
405
407
  export var colorBorderButtonNormalActive = "var(--color-border-button-normal-active-ru7yhb, #002b66)";
406
408
  export var colorBorderButtonNormalDefault = "var(--color-border-button-normal-default-glqfp1, #006ce0)";
407
409
  export var colorBorderToggleButtonNormalPressed = "var(--color-border-toggle-button-normal-pressed-tq8o41, #006ce0)";
410
+ export var colorBorderToggleButtonNormalDefault = "var(--color-border-toggle-button-normal-default-13wcrj, #006ce0)";
411
+ export var colorBorderToggleButtonNormalHover = "var(--color-border-toggle-button-normal-hover-0gzb6n, #002b66)";
408
412
  export var colorBorderButtonNormalDisabled = "var(--color-border-button-normal-disabled-pkhetz, #b4b4bb)";
409
413
  export var colorTextButtonNormalDisabled = "var(--color-text-button-normal-disabled-05p74s, #8c8c94)";
410
414
  export var colorBorderButtonNormalHover = "var(--color-border-button-normal-hover-6a2tdq, #002b66)";
@@ -436,6 +440,7 @@ export var colorBorderDividerDefault = "var(--color-border-divider-default-nr68j
436
440
  export var colorBorderDividerPanelBottom = "var(--color-border-divider-panel-bottom-bruvuz, #c6c6cd)";
437
441
  export var colorBorderDividerPanelSide = "var(--color-border-divider-panel-side-an0w07, #c6c6cd)";
438
442
  export var colorBorderDividerSecondary = "var(--color-border-divider-secondary-qoitch, #ebebf0)";
443
+ export var colorBorderDividerTableGroup = "var(--color-border-divider-table-group-l55omi, #8c8c94)";
439
444
  export var colorBorderDropdownContainer = "var(--color-border-dropdown-container-cmthq7, #b4b4bb)";
440
445
  export var colorBorderDropdownGroup = "var(--color-border-dropdown-group-ylcnh8, #c6c6cd)";
441
446
  export var colorBorderDropdownItemDefault = "var(--color-border-dropdown-item-default-kape37, #c6c6cd)";
@@ -459,6 +464,7 @@ export var colorBorderSegmentActive = "var(--color-border-segment-active-ls9t4n,
459
464
  export var colorBorderSegmentDefault = "var(--color-border-segment-default-6ig2mo, #424650)";
460
465
  export var colorBorderSegmentDisabled = "var(--color-border-segment-disabled-fcrbcl, #424650)";
461
466
  export var colorBorderSegmentHover = "var(--color-border-segment-hover-0o9ey3, #424650)";
467
+ export var colorBorderSegmentWrapper = "var(--color-border-segment-wrapper-mvxnza, #8c8c94)";
462
468
  export var colorBorderStatusError = "var(--color-border-status-error-j8acpp, #db0000)";
463
469
  export var colorBorderStatusInfo = "var(--color-border-status-info-qf6jok, #006ce0)";
464
470
  export var colorBorderStatusSuccess = "var(--color-border-status-success-8z5f8u, #00802f)";
@@ -476,6 +482,7 @@ export var colorForegroundControlReadOnly = "var(--color-foreground-control-read
476
482
  export var colorShadowDefault = "var(--color-shadow-default-o7dmmm, rgba(15, 20, 26, 0.12))";
477
483
  export var colorShadowMedium = "var(--color-shadow-medium-x7of55, rgba(15, 20, 26, 0.12))";
478
484
  export var colorShadowSide = "var(--color-shadow-side-rtsbda, rgba(15, 20, 26, 0.12))";
485
+ export var colorShadowToggleHandle = "var(--color-shadow-toggle-handle-at8aqh, rgba(0, 0, 0, 0.25))";
479
486
  export var colorStrokeChartLine = "var(--color-stroke-chart-line-3nsnk6, #8c8c94)";
480
487
  export var colorStrokeCodeEditorGutterActiveLineDefault = "var(--color-stroke-code-editor-gutter-active-line-default-5hrdmu, #dedee3)";
481
488
  export var colorStrokeCodeEditorGutterActiveLineHover = "var(--color-stroke-code-editor-gutter-active-line-hover-vqrb6s, #f9f9fa)";
@@ -732,6 +739,7 @@ export var borderRadiusStatusIndicator = "var(--border-radius-status-indicator-f
732
739
  export var borderRadiusTabsFocusRing = "var(--border-radius-tabs-focus-ring-o4qku1, 20px)";
733
740
  export var borderRadiusTiles = "var(--border-radius-tiles-wm1vgw, 8px)";
734
741
  export var borderRadiusToken = "var(--border-radius-token-ycnemh, 8px)";
742
+ export var borderRadiusTokenInline = "var(--border-radius-token-inline-tio0a0, 4px)";
735
743
  export var borderRadiusTutorialPanelItem = "var(--border-radius-tutorial-panel-item-ojaqxg, 8px)";
736
744
  export var borderTableStickyWidth = "var(--border-table-sticky-width-ai31mi, 1px)";
737
745
  export var borderWidthActionCardActive = "var(--border-width-action-card-active-pwtgzu, 1px)";