@cloudscape-design/components 3.0.271 → 3.0.273

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.
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["popover/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAC7F,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAE1E,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,MAAM,MAAM,+BAA+B,CAAC;AAEnD,OAAO,gBAAgB,MAAM,aAAa,CAAC;AAC3C,OAAO,WAAW,MAAM,QAAQ,CAAC;AAEjC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAA6B,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAE7F,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAU3D,eAAe,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;AAEjD,SAAS,eAAe,CACtB,EAgBuB,EACvB,GAAkC;QAjBlC,EACE,QAAQ,GAAG,OAAO,EAClB,IAAI,GAAG,QAAQ,EACf,UAAU,GAAG,KAAK,EAClB,WAAW,GAAG,MAAM,EACpB,aAAa,GAAG,IAAI,EAEpB,QAAQ,EACR,MAAM,EACN,OAAO,EAEP,gBAAgB,GAAG,KAAK,EA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AAE,cAAc,CAAU,CAAC,CAAC,CAAC,cAAc,CACjE,CACmB,CAC7B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useEffect, useRef, useState, useImperativeHandle } from 'react';\nimport clsx from 'clsx';\n\nimport { KeyCode } from '../internal/keycode';\nimport { getBaseProps } from '../internal/base-component';\nimport { FormFieldContext } from '../internal/context/form-field-context';\n\nimport Arrow from './arrow';\nimport Portal from '../internal/components/portal';\nimport { PopoverProps } from './interfaces';\nimport PopoverContainer from './container';\nimport PopoverBody from './body';\n\nimport styles from './styles.css.js';\nimport { NonCancelableEventHandler, fireNonCancelableEvent } from '../internal/events/index';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { usePortalModeClasses } from '../internal/hooks/use-portal-mode-classes';\nimport { useInternalI18n } from '../internal/i18n/context';\n\nexport interface InternalPopoverProps extends PopoverProps, InternalBaseComponentProps {\n __onOpen?: NonCancelableEventHandler<null>;\n}\n\nexport interface InternalPopoverRef {\n dismissPopover: () => void;\n}\n\nexport default React.forwardRef(InternalPopover);\n\nfunction InternalPopover(\n {\n position = 'right',\n size = 'medium',\n fixedWidth = false,\n triggerType = 'text',\n dismissButton = true,\n\n children,\n header,\n content,\n\n renderWithPortal = false,\n\n __onOpen,\n __internalRootRef = null,\n ...restProps\n }: InternalPopoverProps,\n ref: React.Ref<InternalPopoverRef>\n) {\n const baseProps = getBaseProps(restProps);\n const triggerRef = useRef<HTMLElement | null>(null);\n const popoverRef = useRef<HTMLDivElement | null>(null);\n const clickFrameId = useRef<number | null>(null);\n\n const i18n = useInternalI18n('popover');\n const dismissAriaLabel = i18n('dismissAriaLabel', restProps.dismissAriaLabel);\n\n const [visible, setVisible] = useState(false);\n\n const focusTrigger = useCallback(() => {\n triggerRef.current?.focus();\n }, []);\n\n const onTriggerClick = useCallback(() => {\n fireNonCancelableEvent(__onOpen);\n setVisible(true);\n }, [__onOpen]);\n\n const onDismiss = useCallback(() => {\n setVisible(false);\n focusTrigger();\n }, [focusTrigger]);\n\n const onTriggerKeyDown = useCallback((event: React.KeyboardEvent) => {\n if (event.keyCode === KeyCode.tab || event.keyCode === KeyCode.escape) {\n setVisible(false);\n }\n }, []);\n\n useImperativeHandle(ref, () => ({\n dismissPopover: onDismiss,\n }));\n\n useEffect(() => {\n if (!triggerRef.current) {\n return;\n }\n const document = triggerRef.current.ownerDocument;\n\n const onDocumentClick = () => {\n // Dismiss popover unless there was a click inside within the last animation frame.\n if (clickFrameId.current === null) {\n setVisible(false);\n }\n };\n\n // useCapture=false makes sure this listener is called after the one attached to the element.\n // the options.capture notation is unsupported by IE.\n document.addEventListener('mousedown', onDocumentClick, false);\n\n return () => {\n document.removeEventListener('mousedown', onDocumentClick, false);\n };\n }, []);\n\n const popoverClasses = usePortalModeClasses(triggerRef);\n\n const triggerProps = {\n // https://github.com/microsoft/TypeScript/issues/36659\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref: triggerRef as any,\n onClick: onTriggerClick,\n onKeyDown: onTriggerKeyDown,\n className: clsx(styles.trigger, styles[`trigger-type-${triggerType}`]),\n };\n\n const popoverContent = (\n <div\n aria-live={dismissButton ? undefined : 'polite'}\n aria-atomic={dismissButton ? undefined : true}\n className={clsx(popoverClasses, styles['popover-content'])}\n >\n {visible && (\n <PopoverContainer\n size={size}\n fixedWidth={fixedWidth}\n position={position}\n trackRef={triggerRef}\n arrow={position => <Arrow position={position} />}\n renderWithPortal={renderWithPortal}\n zIndex={renderWithPortal ? 7000 : undefined}\n >\n <PopoverBody\n dismissButton={dismissButton}\n dismissAriaLabel={dismissAriaLabel}\n header={header}\n onDismiss={onDismiss}\n overflowVisible=\"both\"\n >\n {content}\n </PopoverBody>\n </PopoverContainer>\n )}\n </div>\n );\n\n const mergedRef = useMergeRefs(popoverRef, __internalRootRef);\n\n return (\n <FormFieldContext.Provider value={{}}>\n <span\n {...baseProps}\n className={clsx(styles.root, baseProps.className)}\n ref={mergedRef}\n onMouseDown={() => {\n // Indicate there was a click inside popover recently, including nested portals.\n clickFrameId.current = requestAnimationFrame(() => {\n clickFrameId.current = null;\n });\n }}\n >\n {triggerType === 'text' ? (\n <button {...triggerProps} type=\"button\" aria-haspopup=\"dialog\">\n <span className={styles['trigger-inner-text']}>{children}</span>\n </button>\n ) : (\n <span {...triggerProps}>{children}</span>\n )}\n {renderWithPortal ? <Portal>{popoverContent}</Portal> : popoverContent}\n </span>\n </FormFieldContext.Provider>\n );\n}\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["popover/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAC7F,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAE1E,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,MAAM,MAAM,+BAA+B,CAAC;AAEnD,OAAO,gBAAgB,MAAM,aAAa,CAAC;AAC3C,OAAO,WAAW,MAAM,QAAQ,CAAC;AAEjC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAA6B,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAE7F,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAU3D,eAAe,KAAK,CAAC,UAAU,CAAC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;YAC5D,8BAAM,SAAS,EAAE,MAAM,CAAC,oBAAoB,CAAC,IAAG,QAAQ,CAAQ,CACzD,CACV,CAAC,CAAC,CAAC,CACF,8CAAU,YAAY,GAAG,QAAQ,CAAQ,CAC1C;QACD,oBAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,IACjC,gBAAgB,CAAC,CAAC,CAAC,oBAAC,MAAM,QAAE,cAAc,CAAU,CAAC,CAAC,CAAC,cAAc,CAC5C,CACvB,CACR,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useEffect, useRef, useState, useImperativeHandle } from 'react';\nimport clsx from 'clsx';\n\nimport { KeyCode } from '../internal/keycode';\nimport { getBaseProps } from '../internal/base-component';\nimport { FormFieldContext } from '../internal/context/form-field-context';\n\nimport Arrow from './arrow';\nimport Portal from '../internal/components/portal';\nimport { PopoverProps } from './interfaces';\nimport PopoverContainer from './container';\nimport PopoverBody from './body';\n\nimport styles from './styles.css.js';\nimport { NonCancelableEventHandler, fireNonCancelableEvent } from '../internal/events/index';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { usePortalModeClasses } from '../internal/hooks/use-portal-mode-classes';\nimport { useInternalI18n } from '../internal/i18n/context';\n\nexport interface InternalPopoverProps extends PopoverProps, InternalBaseComponentProps {\n __onOpen?: NonCancelableEventHandler<null>;\n}\n\nexport interface InternalPopoverRef {\n dismissPopover: () => void;\n}\n\nexport default React.forwardRef(InternalPopover);\n\nfunction InternalPopover(\n {\n position = 'right',\n size = 'medium',\n fixedWidth = false,\n triggerType = 'text',\n dismissButton = true,\n\n children,\n header,\n content,\n\n renderWithPortal = false,\n\n __onOpen,\n __internalRootRef = null,\n ...restProps\n }: InternalPopoverProps,\n ref: React.Ref<InternalPopoverRef>\n) {\n const baseProps = getBaseProps(restProps);\n const triggerRef = useRef<HTMLElement | null>(null);\n const popoverRef = useRef<HTMLDivElement | null>(null);\n const clickFrameId = useRef<number | null>(null);\n\n const i18n = useInternalI18n('popover');\n const dismissAriaLabel = i18n('dismissAriaLabel', restProps.dismissAriaLabel);\n\n const [visible, setVisible] = useState(false);\n\n const focusTrigger = useCallback(() => {\n triggerRef.current?.focus();\n }, []);\n\n const onTriggerClick = useCallback(() => {\n fireNonCancelableEvent(__onOpen);\n setVisible(true);\n }, [__onOpen]);\n\n const onDismiss = useCallback(() => {\n setVisible(false);\n focusTrigger();\n }, [focusTrigger]);\n\n const onTriggerKeyDown = useCallback((event: React.KeyboardEvent) => {\n if (event.keyCode === KeyCode.tab || event.keyCode === KeyCode.escape) {\n setVisible(false);\n }\n }, []);\n\n useImperativeHandle(ref, () => ({\n dismissPopover: onDismiss,\n }));\n\n useEffect(() => {\n if (!triggerRef.current) {\n return;\n }\n const document = triggerRef.current.ownerDocument;\n\n const onDocumentClick = () => {\n // Dismiss popover unless there was a click inside within the last animation frame.\n if (clickFrameId.current === null) {\n setVisible(false);\n }\n };\n\n // useCapture=false makes sure this listener is called after the one attached to the element.\n // the options.capture notation is unsupported by IE.\n document.addEventListener('mousedown', onDocumentClick, false);\n\n return () => {\n document.removeEventListener('mousedown', onDocumentClick, false);\n };\n }, []);\n\n const popoverClasses = usePortalModeClasses(triggerRef);\n\n const triggerProps = {\n // https://github.com/microsoft/TypeScript/issues/36659\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref: triggerRef as any,\n onClick: onTriggerClick,\n onKeyDown: onTriggerKeyDown,\n className: clsx(styles.trigger, styles[`trigger-type-${triggerType}`]),\n };\n\n const popoverContent = (\n <div\n aria-live={dismissButton ? undefined : 'polite'}\n aria-atomic={dismissButton ? undefined : true}\n className={clsx(popoverClasses, styles['popover-content'])}\n >\n {visible && (\n <PopoverContainer\n size={size}\n fixedWidth={fixedWidth}\n position={position}\n trackRef={triggerRef}\n arrow={position => <Arrow position={position} />}\n renderWithPortal={renderWithPortal}\n zIndex={renderWithPortal ? 7000 : undefined}\n >\n <PopoverBody\n dismissButton={dismissButton}\n dismissAriaLabel={dismissAriaLabel}\n header={header}\n onDismiss={onDismiss}\n overflowVisible=\"both\"\n >\n {content}\n </PopoverBody>\n </PopoverContainer>\n )}\n </div>\n );\n\n const mergedRef = useMergeRefs(popoverRef, __internalRootRef);\n\n return (\n <span\n {...baseProps}\n className={clsx(styles.root, baseProps.className)}\n ref={mergedRef}\n onMouseDown={() => {\n // Indicate there was a click inside popover recently, including nested portals.\n clickFrameId.current = requestAnimationFrame(() => {\n clickFrameId.current = null;\n });\n }}\n >\n {triggerType === 'text' ? (\n <button {...triggerProps} type=\"button\" aria-haspopup=\"dialog\">\n <span className={styles['trigger-inner-text']}>{children}</span>\n </button>\n ) : (\n <span {...triggerProps}>{children}</span>\n )}\n <FormFieldContext.Provider value={{}}>\n {renderWithPortal ? <Portal>{popoverContent}</Portal> : popoverContent}\n </FormFieldContext.Provider>\n </span>\n );\n}\n"]}
@@ -21,7 +21,7 @@ export interface StickyColumnsModel {
21
21
  }
22
22
  export interface StickyColumnsState {
23
23
  cellState: Record<ColumnId, null | StickyColumnsCellState>;
24
- scrollPadding: ScrollPadding;
24
+ wrapperState: StickyColumnsWrapperState;
25
25
  }
26
26
  export interface StickyColumnsCellState {
27
27
  padLeft: boolean;
@@ -32,9 +32,9 @@ export interface StickyColumnsCellState {
32
32
  right?: number;
33
33
  };
34
34
  }
35
- export interface ScrollPadding {
36
- left: number;
37
- right: number;
35
+ export interface StickyColumnsWrapperState {
36
+ scrollPaddingLeft: number;
37
+ scrollPaddingRight: number;
38
38
  }
39
39
  export declare function useStickyColumns({ visibleColumns, stickyColumnsFirst, stickyColumnsLast, }: StickyColumnsProps): StickyColumnsModel;
40
40
  interface UseStickyCellStylesProps {
@@ -62,6 +62,7 @@ export default class StickyColumnsStore extends AsyncStore<StickyColumnsState> {
62
62
  private stickyWidthRight;
63
63
  private isStuckToTheLeft;
64
64
  private isStuckToTheRight;
65
+ private padLeft;
65
66
  constructor();
66
67
  updateCellStyles(props: UpdateCellStylesProps): void;
67
68
  private updateScroll;
@@ -1 +1 @@
1
- {"version":3,"file":"use-sticky-columns.d.ts","sourceRoot":"lib/default/","sources":["table/use-sticky-columns.ts"],"names":[],"mappings":"AAGA,OAAO,KAAkD,MAAM,OAAO,CAAC;AACvE,OAAO,UAAU,MAAM,iCAAiC,CAAC;AAKzD,eAAO,MAAM,iBAAiB,eAAgC,CAAC;AAM/D,KAAK,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAEhC,UAAU,kBAAkB;IAC1B,cAAc,EAAE,SAAS,QAAQ,EAAE,CAAC;IACpC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,kBAAkB,CAAC;IAC1B,KAAK,EAAE;QACL,OAAO,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;KAC/B,CAAC;IACF,IAAI,EAAE;QACJ,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QACtC,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QACxC,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,GAAG,WAAW,KAAK,IAAI,CAAC;KAC9D,CAAC;CACH;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAI,GAAG,sBAAsB,CAAC,CAAC;IAC3D,aAAa,EAAE,aAAa,CAAC;CAC9B;AAGD,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE;QAAE,IAAI,CAAC,EAAE,MAA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AAK;IAC7B,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,OAAO,CAAS;;IAMjB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB;IAcpD,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,kBAAkB,CAkCxB;IAEF,OAAO,CAAC,iBAAiB,CA0BvB;IAEF,OAAO,CAAC,SAAS,CAuBf;CACH"}
@@ -46,14 +46,17 @@ export function useStickyColumns({ visibleColumns, stickyColumnsFirst, stickyCol
46
46
  if (!hasStickyColumns) {
47
47
  return;
48
48
  }
49
- const selector = (state) => state.scrollPadding;
50
- const updateWrapperStyles = (state) => {
49
+ const selector = (state) => state.wrapperState;
50
+ const updateWrapperStyles = (state, prev) => {
51
+ if (isWrapperStatesEqual(state, prev)) {
52
+ return;
53
+ }
51
54
  if (wrapperRef.current) {
52
- wrapperRef.current.style.scrollPaddingLeft = state.left + 'px';
53
- wrapperRef.current.style.scrollPaddingRight = state.right + 'px';
55
+ wrapperRef.current.style.scrollPaddingLeft = state.scrollPaddingLeft + 'px';
56
+ wrapperRef.current.style.scrollPaddingRight = state.scrollPaddingRight + 'px';
54
57
  }
55
58
  };
56
- const unsubscribe = store.subscribe(selector, newState => updateWrapperStyles(selector(newState)));
59
+ const unsubscribe = store.subscribe(selector, (newState, prevState) => updateWrapperStyles(selector(newState), selector(prevState)));
57
60
  return unsubscribe;
58
61
  }, [store, hasStickyColumns]);
59
62
  const setWrapper = useCallback((node) => {
@@ -81,12 +84,7 @@ export function useStickyColumns({ visibleColumns, stickyColumnsFirst, stickyCol
81
84
  store,
82
85
  style: {
83
86
  // Provide wrapper styles as props so that a re-render won't cause invalidation.
84
- wrapper: hasStickyColumns
85
- ? {
86
- scrollPaddingLeft: store.get().scrollPadding.left + 'px',
87
- scrollPaddingRight: store.get().scrollPadding.right + 'px',
88
- }
89
- : undefined,
87
+ wrapper: hasStickyColumns ? Object.assign({}, store.get().wrapperState) : undefined,
90
88
  },
91
89
  refs: { wrapper: setWrapper, table: setTable, cell: setCell },
92
90
  };
@@ -105,7 +103,10 @@ export function useStickyCellStyles({ stickyColumns, columnId, getClassName, })
105
103
  return;
106
104
  }
107
105
  const selector = (state) => state.cellState[columnId];
108
- const updateCellStyles = (state) => {
106
+ const updateCellStyles = (state, prev) => {
107
+ if (isCellStatesEqual(state, prev)) {
108
+ return;
109
+ }
109
110
  const className = getClassName(state);
110
111
  const cellElement = cellRef.current;
111
112
  if (cellElement) {
@@ -117,11 +118,11 @@ export function useStickyCellStyles({ stickyColumns, columnId, getClassName, })
117
118
  cellElement.classList.remove(key);
118
119
  }
119
120
  });
120
- cellElement.style.left = (state === null || state === void 0 ? void 0 : state.offset.left) !== undefined ? `${state === null || state === void 0 ? void 0 : state.offset.left}px` : '';
121
- cellElement.style.right = (state === null || state === void 0 ? void 0 : state.offset.right) !== undefined ? `${state === null || state === void 0 ? void 0 : state.offset.right}px` : '';
121
+ cellElement.style.left = (state === null || state === void 0 ? void 0 : state.offset.left) !== undefined ? `${state.offset.left}px` : '';
122
+ cellElement.style.right = (state === null || state === void 0 ? void 0 : state.offset.right) !== undefined ? `${state.offset.right}px` : '';
122
123
  }
123
124
  };
124
- const unsubscribe = stickyColumns.store.subscribe(selector, newState => updateCellStyles(selector(newState)));
125
+ const unsubscribe = stickyColumns.store.subscribe(selector, (newState, prevState) => updateCellStyles(selector(newState), selector(prevState)));
125
126
  return unsubscribe;
126
127
  },
127
128
  // getClassName is expected to be pure
@@ -135,17 +136,30 @@ export function useStickyCellStyles({ stickyColumns, columnId, getClassName, })
135
136
  style: (_a = cellStyles === null || cellStyles === void 0 ? void 0 : cellStyles.offset) !== null && _a !== void 0 ? _a : undefined,
136
137
  };
137
138
  }
139
+ function isCellStatesEqual(s1, s2) {
140
+ if (s1 && s2) {
141
+ return (s1.padLeft === s2.padLeft &&
142
+ s1.lastLeft === s2.lastLeft &&
143
+ s1.lastRight === s2.lastRight &&
144
+ s1.offset.left === s2.offset.left &&
145
+ s1.offset.right === s2.offset.right);
146
+ }
147
+ return s1 === s2;
148
+ }
149
+ function isWrapperStatesEqual(s1, s2) {
150
+ return s1.scrollPaddingLeft === s2.scrollPaddingLeft && s1.scrollPaddingRight === s2.scrollPaddingRight;
151
+ }
138
152
  export default class StickyColumnsStore extends AsyncStore {
139
153
  constructor() {
140
- super({ cellState: {}, scrollPadding: { left: 0, right: 0 } });
154
+ super({ cellState: {}, wrapperState: { scrollPaddingLeft: 0, scrollPaddingRight: 0 } });
141
155
  this.cellOffsets = new Map();
142
156
  this.stickyWidthLeft = 0;
143
157
  this.stickyWidthRight = 0;
144
158
  this.isStuckToTheLeft = false;
145
159
  this.isStuckToTheRight = false;
160
+ this.padLeft = false;
146
161
  this.generateCellStyles = (props) => {
147
162
  const isEnabled = this.isEnabled(props);
148
- const tablePaddingLeft = parseFloat(getComputedStyle(props.table).paddingLeft) || 0;
149
163
  const lastLeftStickyColumnIndex = props.stickyColumnsFirst - 1;
150
164
  const lastRightStickyColumnIndex = props.visibleColumns.length - props.stickyColumnsLast;
151
165
  return props.visibleColumns.reduce((acc, columnId, index) => {
@@ -165,15 +179,14 @@ export default class StickyColumnsStore extends AsyncStore {
165
179
  const isFirstColumn = index === 0;
166
180
  const stickyColumnOffsetLeft = (_b = (_a = this.cellOffsets.get(columnId)) === null || _a === void 0 ? void 0 : _a.first) !== null && _b !== void 0 ? _b : 0;
167
181
  const stickyColumnOffsetRight = (_d = (_c = this.cellOffsets.get(columnId)) === null || _c === void 0 ? void 0 : _c.last) !== null && _d !== void 0 ? _d : 0;
168
- const cellStyle = {
169
- left: stickySide === 'left' ? stickyColumnOffsetLeft : undefined,
170
- right: stickySide === 'right' ? stickyColumnOffsetRight : undefined,
171
- };
172
182
  acc[columnId] = {
173
- padLeft: isFirstColumn && tablePaddingLeft !== 0 && this.isStuckToTheLeft,
183
+ padLeft: isFirstColumn && this.padLeft,
174
184
  lastLeft: this.isStuckToTheLeft && lastLeftStickyColumnIndex === index,
175
185
  lastRight: this.isStuckToTheRight && lastRightStickyColumnIndex === index,
176
- offset: cellStyle,
186
+ offset: {
187
+ left: stickySide === 'left' ? stickyColumnOffsetLeft : undefined,
188
+ right: stickySide === 'right' ? stickyColumnOffsetRight : undefined,
189
+ },
177
190
  };
178
191
  return acc;
179
192
  }, {});
@@ -232,7 +245,7 @@ export default class StickyColumnsStore extends AsyncStore {
232
245
  this.updateCellOffsets(props);
233
246
  this.set(() => ({
234
247
  cellState: this.generateCellStyles(props),
235
- scrollPadding: { left: this.stickyWidthLeft, right: this.stickyWidthRight },
248
+ wrapperState: { scrollPaddingLeft: this.stickyWidthLeft, scrollPaddingRight: this.stickyWidthRight },
236
249
  }));
237
250
  }
238
251
  }
@@ -246,6 +259,7 @@ export default class StickyColumnsStore extends AsyncStore {
246
259
  // Math.ceil() is used here to address an edge-case in certain browsers, where they return non-integer wrapperScrollLeft values
247
260
  // which are lower than expected (sub-pixel difference), resulting in the table always being in the "stuck to the right" state
248
261
  this.isStuckToTheRight = Math.ceil(wrapperScrollLeft) < wrapperScrollWidth - wrapperClientWidth - tablePaddingRight;
262
+ this.padLeft = tablePaddingLeft !== 0 && this.isStuckToTheLeft;
249
263
  }
250
264
  }
251
265
  //# sourceMappingURL=use-sticky-columns.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-sticky-columns.js","sourceRoot":"lib/default/","sources":["table/use-sticky-columns.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAc,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACvE,OAAO,UAAU,MAAM,iCAAiC,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACnF,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAExE,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,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K,CAAC,OAAO,CAAC,WAAW,CAAC;QACrD,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;QACrD,MAAM,gBAAgB,GAAG,UAAU,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACpF,MAAM,iBAAiB,GAAG,UAAU,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAEtF,IAAI,CAAC,gBAAgB,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;QAE7D,+HAA+H;QAC/H,8HAA8H;QAC9H,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,kBAAkB,GAAG,kBAAkB,GAAG,iBAAiB,CAAC;IACtH,CAAC;CA4FF","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react';\nimport AsyncStore from '../area-chart/model/async-store';\nimport { useStableEventHandler } from '../internal/hooks/use-stable-event-handler';\nimport clsx from 'clsx';\nimport { useResizeObserver } from '../internal/hooks/container-queries';\n\nexport const selectionColumnId = Symbol('selection-column-id');\n\n// We allow the table to have a minimum of 148px of available space besides the sum of the widths of the sticky columns\n// This value is an UX recommendation and is approximately 1/3 of our smallest breakpoint (465px)\nconst MINIMUM_SCROLLABLE_SPACE = 148;\n\ntype ColumnId = string | symbol;\n\ninterface StickyColumnsProps {\n visibleColumns: readonly ColumnId[];\n stickyColumnsFirst: number;\n stickyColumnsLast: number;\n}\n\nexport interface StickyColumnsModel {\n isEnabled: boolean;\n store: StickyColumnsStore;\n style: {\n wrapper?: React.CSSProperties;\n };\n refs: {\n table: React.RefCallback<HTMLElement>;\n wrapper: React.RefCallback<HTMLElement>;\n cell: (columnId: ColumnId, node: null | HTMLElement) => void;\n };\n}\n\nexport interface StickyColumnsState {\n cellState: Record<ColumnId, null | StickyColumnsCellState>;\n scrollPadding: ScrollPadding;\n}\n\n// Cell state is used to apply respective styles and offsets to sticky cells.\nexport interface StickyColumnsCellState {\n padLeft: boolean;\n lastLeft: boolean;\n lastRight: boolean;\n offset: { left?: number; right?: number };\n}\n\n// Scroll padding is applied to table's wrapper so that the table scrolls when focus goes behind sticky column.\nexport interface ScrollPadding {\n left: number;\n right: number;\n}\n\nexport function useStickyColumns({\n visibleColumns,\n stickyColumnsFirst,\n stickyColumnsLast,\n}: StickyColumnsProps): StickyColumnsModel {\n const store = useMemo(() => new StickyColumnsStore(), []);\n const wrapperRef = useRef<HTMLElement>(null) as React.MutableRefObject<null | HTMLElement>;\n const tableRef = useRef<HTMLElement>(null) as React.MutableRefObject<null | HTMLElement>;\n const cellsRef = useRef<Record<ColumnId, HTMLElement>>({});\n\n const hasStickyColumns = stickyColumnsFirst + stickyColumnsLast > 0;\n\n const updateStickyStyles = useStableEventHandler(() => {\n if (wrapperRef.current && tableRef.current) {\n store.updateCellStyles({\n wrapper: wrapperRef.current,\n table: tableRef.current,\n cells: cellsRef.current,\n visibleColumns,\n stickyColumnsFirst,\n stickyColumnsLast,\n });\n }\n });\n\n useResizeObserver(wrapperRef, updateStickyStyles);\n\n useResizeObserver(tableRef, updateStickyStyles);\n\n useEffect(() => {\n if (wrapperRef.current && tableRef.current) {\n store.updateCellStyles({\n wrapper: wrapperRef.current,\n table: tableRef.current,\n cells: cellsRef.current,\n visibleColumns,\n stickyColumnsFirst,\n stickyColumnsLast,\n });\n }\n }, [store, stickyColumnsFirst, stickyColumnsLast, visibleColumns]);\n\n // Update wrapper styles imperatively to avoid unnecessary re-renders.\n useEffect(() => {\n if (!hasStickyColumns) {\n return;\n }\n\n const selector = (state: StickyColumnsState) => state.scrollPadding;\n\n const updateWrapperStyles = (state: ScrollPadding) => {\n if (wrapperRef.current) {\n wrapperRef.current.style.scrollPaddingLeft = state.left + 'px';\n wrapperRef.current.style.scrollPaddingRight = state.right + 'px';\n }\n };\n\n const unsubscribe = store.subscribe(selector, newState => updateWrapperStyles(selector(newState)));\n return unsubscribe;\n }, [store, hasStickyColumns]);\n\n const setWrapper = useCallback(\n (node: null | HTMLElement) => {\n if (wrapperRef.current) {\n wrapperRef.current.removeEventListener('scroll', updateStickyStyles);\n }\n if (node && hasStickyColumns) {\n node.addEventListener('scroll', updateStickyStyles);\n }\n wrapperRef.current = node;\n },\n [hasStickyColumns, updateStickyStyles]\n );\n\n const setTable = useCallback((node: null | HTMLElement) => {\n tableRef.current = node;\n }, []);\n\n const setCell = useCallback((columnId: ColumnId, node: null | HTMLElement) => {\n if (node) {\n cellsRef.current[columnId] = node;\n } else {\n delete cellsRef.current[columnId];\n }\n }, []);\n\n return {\n isEnabled: hasStickyColumns,\n store,\n style: {\n // Provide wrapper styles as props so that a re-render won't cause invalidation.\n wrapper: hasStickyColumns\n ? {\n scrollPaddingLeft: store.get().scrollPadding.left + 'px',\n scrollPaddingRight: store.get().scrollPadding.right + 'px',\n }\n : undefined,\n },\n refs: { wrapper: setWrapper, table: setTable, cell: setCell },\n };\n}\n\ninterface UseStickyCellStylesProps {\n stickyColumns: StickyColumnsModel;\n columnId: ColumnId;\n getClassName: (styles: null | StickyColumnsCellState) => Record<string, boolean>;\n}\n\ninterface StickyCellStyles {\n ref: React.RefCallback<HTMLElement>;\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport function useStickyCellStyles({\n stickyColumns,\n columnId,\n getClassName,\n}: UseStickyCellStylesProps): StickyCellStyles {\n const cellRef = useRef<HTMLElement>(null) as React.MutableRefObject<HTMLElement>;\n const setCell = stickyColumns.refs.cell;\n const refCallback = useCallback(\n node => {\n cellRef.current = node;\n setCell(columnId, node);\n },\n [columnId, setCell]\n );\n\n // Update cell styles imperatively to avoid unnecessary re-renders.\n useEffect(\n () => {\n if (!stickyColumns.isEnabled) {\n return;\n }\n\n const selector = (state: StickyColumnsState) => state.cellState[columnId];\n\n const updateCellStyles = (state: null | StickyColumnsCellState) => {\n const className = getClassName(state);\n const cellElement = cellRef.current;\n if (cellElement) {\n Object.keys(className).forEach(key => {\n if (className[key]) {\n cellElement.classList.add(key);\n } else {\n cellElement.classList.remove(key);\n }\n });\n cellElement.style.left = state?.offset.left !== undefined ? `${state?.offset.left}px` : '';\n cellElement.style.right = state?.offset.right !== undefined ? `${state?.offset.right}px` : '';\n }\n };\n\n const unsubscribe = stickyColumns.store.subscribe(selector, newState => updateCellStyles(selector(newState)));\n return unsubscribe;\n },\n // getClassName is expected to be pure\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [stickyColumns.store, stickyColumns.isEnabled, columnId]\n );\n\n // Provide cell styles as props so that a re-render won't cause invalidation.\n const cellStyles = stickyColumns.store.get().cellState[columnId];\n return {\n ref: refCallback,\n className: cellStyles ? clsx(getClassName(cellStyles)) : undefined,\n style: cellStyles?.offset ?? undefined,\n };\n}\n\ninterface UpdateCellStylesProps {\n wrapper: HTMLElement;\n table: HTMLElement;\n cells: Record<ColumnId, HTMLElement>;\n visibleColumns: readonly ColumnId[];\n stickyColumnsFirst: number;\n stickyColumnsLast: number;\n}\n\nexport default class StickyColumnsStore extends AsyncStore<StickyColumnsState> {\n private cellOffsets = new Map<ColumnId, { first: number; last: number }>();\n private stickyWidthLeft = 0;\n private stickyWidthRight = 0;\n private isStuckToTheLeft = false;\n private isStuckToTheRight = false;\n\n constructor() {\n super({ cellState: {}, scrollPadding: { left: 0, right: 0 } });\n }\n\n public updateCellStyles(props: UpdateCellStylesProps) {\n const hasStickyColumns = props.stickyColumnsFirst + props.stickyColumnsLast > 0;\n const hadStickyColumns = this.cellOffsets.size > 0;\n\n if (hasStickyColumns || hadStickyColumns) {\n this.updateScroll(props);\n this.updateCellOffsets(props);\n this.set(() => ({\n cellState: this.generateCellStyles(props),\n scrollPadding: { left: this.stickyWidthLeft, right: this.stickyWidthRight },\n }));\n }\n }\n\n private updateScroll(props: UpdateCellStylesProps) {\n const wrapperScrollLeft = props.wrapper.scrollLeft;\n const wrapperScrollWidth = props.wrapper.scrollWidth;\n const wrapperClientWidth = props.wrapper.clientWidth;\n const tablePaddingLeft = parseFloat(getComputedStyle(props.table).paddingLeft) || 0;\n const tablePaddingRight = parseFloat(getComputedStyle(props.table).paddingRight) || 0;\n\n this.isStuckToTheLeft = wrapperScrollLeft > tablePaddingLeft;\n\n // Math.ceil() is used here to address an edge-case in certain browsers, where they return non-integer wrapperScrollLeft values\n // which are lower than expected (sub-pixel difference), resulting in the table always being in the \"stuck to the right\" state\n this.isStuckToTheRight = Math.ceil(wrapperScrollLeft) < wrapperScrollWidth - wrapperClientWidth - tablePaddingRight;\n }\n\n private generateCellStyles = (props: UpdateCellStylesProps): Record<ColumnId, null | StickyColumnsCellState> => {\n const isEnabled = this.isEnabled(props);\n const tablePaddingLeft = parseFloat(getComputedStyle(props.table).paddingLeft) || 0;\n const lastLeftStickyColumnIndex = props.stickyColumnsFirst - 1;\n const lastRightStickyColumnIndex = props.visibleColumns.length - props.stickyColumnsLast;\n\n return props.visibleColumns.reduce((acc, columnId, index) => {\n let stickySide = 'non-sticky';\n if (index < props.stickyColumnsFirst) {\n stickySide = 'left';\n } else if (index >= props.visibleColumns.length - props.stickyColumnsLast) {\n stickySide = 'right';\n }\n\n if (!isEnabled || stickySide === 'non-sticky') {\n acc[columnId] = null;\n return acc;\n }\n\n // Determine the offset of the sticky column using the `cellOffsets` state object\n const isFirstColumn = index === 0;\n const stickyColumnOffsetLeft = this.cellOffsets.get(columnId)?.first ?? 0;\n const stickyColumnOffsetRight = this.cellOffsets.get(columnId)?.last ?? 0;\n const cellStyle = {\n left: stickySide === 'left' ? stickyColumnOffsetLeft : undefined,\n right: stickySide === 'right' ? stickyColumnOffsetRight : undefined,\n };\n\n acc[columnId] = {\n padLeft: isFirstColumn && tablePaddingLeft !== 0 && this.isStuckToTheLeft,\n lastLeft: this.isStuckToTheLeft && lastLeftStickyColumnIndex === index,\n lastRight: this.isStuckToTheRight && lastRightStickyColumnIndex === index,\n offset: cellStyle,\n };\n return acc;\n }, {} as Record<ColumnId, null | StickyColumnsCellState>);\n };\n\n private updateCellOffsets = (props: UpdateCellStylesProps): void => {\n const firstColumnsWidths: number[] = [];\n for (let i = 0; i < props.visibleColumns.length; i++) {\n const element = props.cells[props.visibleColumns[i]];\n const cellWidth = element.getBoundingClientRect().width ?? 0;\n firstColumnsWidths[i] = (firstColumnsWidths[i - 1] ?? 0) + cellWidth;\n }\n\n const lastColumnsWidths: number[] = [];\n for (let i = props.visibleColumns.length - 1; i >= 0; i--) {\n const element = props.cells[props.visibleColumns[i]];\n const cellWidth = element.getBoundingClientRect().width ?? 0;\n lastColumnsWidths[i] = (lastColumnsWidths[i + 1] ?? 0) + cellWidth;\n }\n lastColumnsWidths.reverse();\n\n this.stickyWidthLeft = firstColumnsWidths[props.stickyColumnsFirst - 1] ?? 0;\n this.stickyWidthRight = lastColumnsWidths[props.stickyColumnsLast - 1] ?? 0;\n this.cellOffsets = props.visibleColumns.reduce(\n (map, columnId, columnIndex) =>\n map.set(columnId, {\n first: firstColumnsWidths[columnIndex - 1] ?? 0,\n last: lastColumnsWidths[props.visibleColumns.length - 1 - columnIndex - 1] ?? 0,\n }),\n new Map()\n );\n };\n\n private isEnabled = (props: UpdateCellStylesProps): boolean => {\n const noStickyColumns = props.stickyColumnsFirst + props.stickyColumnsLast === 0;\n if (noStickyColumns) {\n return false;\n }\n\n const wrapperWidth = props.wrapper.getBoundingClientRect().width;\n const tableWidth = props.table.getBoundingClientRect().width;\n const isWrapperScrollable = tableWidth > wrapperWidth;\n if (!isWrapperScrollable) {\n return false;\n }\n\n const totalStickySpace = this.stickyWidthLeft + this.stickyWidthRight;\n const tablePaddingLeft = parseFloat(getComputedStyle(props.table).paddingLeft) || 0;\n const tablePaddingRight = parseFloat(getComputedStyle(props.table).paddingRight) || 0;\n const hasEnoughScrollableSpace =\n totalStickySpace + MINIMUM_SCROLLABLE_SPACE + tablePaddingLeft + tablePaddingRight < wrapperWidth;\n if (!hasEnoughScrollableSpace) {\n return false;\n }\n\n return true;\n };\n}\n"]}
1
+ {"version":3,"file":"use-sticky-columns.js","sourceRoot":"lib/default/","sources":["table/use-sticky-columns.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAc,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACvE,OAAO,UAAU,MAAM,iCAAiC,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACnF,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAExE,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAE/D,uHAAuH;AACvH,iGAAiG;AACjG,MAAM,wBAAwB,GAAG,GAAG,CAAC;AA0CrC,MAAM,UAAU,gBAAgB,CAAC,EAC/B,cAAc,EACd,kBAAkB,EAClB,iBAAiB,GACE;IACnB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,kBAAkB,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1D,MAAM,UAAU,GAAG,MAAM,CAAc,IAAI,CAA+C,CAAC;IAC3F,MAAM,QAAQ,GAAG,MAAM,CAAc,IAAI,CAA+C,CAAC;IACzF,MAAM,QAAQ,GAAG,MAAM,CAAgC,EAAE,CAAC,CAAC;IAE3D,MAAM,gBAAgB,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,CAAC,CAAC;IAEpE,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,GAAG,EAAE;QACpD,IAAI,UAAU,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE;YAC1C,KAAK,CAAC,gBAAgB,CAAC;gBACrB,OAAO,EAAE,UAAU,CAAC,OAAO;gBAC3B,KAAK,EAAE,QAAQ,CAAC,OAAO;gB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,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACpF,MAAM,iBAAiB,GAAG,UAAU,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAEtF,IAAI,CAAC,gBAAgB,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;QAE7D,+HAA+H;QAC/H,8HAA8H;QAC9H,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,kBAAkB,GAAG,kBAAkB,GAAG,iBAAiB,CAAC;QAEpH,IAAI,CAAC,OAAO,GAAG,gBAAgB,KAAK,CAAC,IAAI,IAAI,CAAC,gBAAgB,CAAC;IACjE,CAAC;CA0FF","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react';\nimport AsyncStore from '../area-chart/model/async-store';\nimport { useStableEventHandler } from '../internal/hooks/use-stable-event-handler';\nimport clsx from 'clsx';\nimport { useResizeObserver } from '../internal/hooks/container-queries';\n\nexport const selectionColumnId = Symbol('selection-column-id');\n\n// We allow the table to have a minimum of 148px of available space besides the sum of the widths of the sticky columns\n// This value is an UX recommendation and is approximately 1/3 of our smallest breakpoint (465px)\nconst MINIMUM_SCROLLABLE_SPACE = 148;\n\ntype ColumnId = string | symbol;\n\ninterface StickyColumnsProps {\n visibleColumns: readonly ColumnId[];\n stickyColumnsFirst: number;\n stickyColumnsLast: number;\n}\n\nexport interface StickyColumnsModel {\n isEnabled: boolean;\n store: StickyColumnsStore;\n style: {\n wrapper?: React.CSSProperties;\n };\n refs: {\n table: React.RefCallback<HTMLElement>;\n wrapper: React.RefCallback<HTMLElement>;\n cell: (columnId: ColumnId, node: null | HTMLElement) => void;\n };\n}\n\nexport interface StickyColumnsState {\n cellState: Record<ColumnId, null | StickyColumnsCellState>;\n wrapperState: StickyColumnsWrapperState;\n}\n\n// Cell state is used to apply respective styles and offsets to sticky cells.\nexport interface StickyColumnsCellState {\n padLeft: boolean;\n lastLeft: boolean;\n lastRight: boolean;\n offset: { left?: number; right?: number };\n}\n\n// Scroll padding is applied to table's wrapper so that the table scrolls when focus goes behind sticky column.\nexport interface StickyColumnsWrapperState {\n scrollPaddingLeft: number;\n scrollPaddingRight: number;\n}\n\nexport function useStickyColumns({\n visibleColumns,\n stickyColumnsFirst,\n stickyColumnsLast,\n}: StickyColumnsProps): StickyColumnsModel {\n const store = useMemo(() => new StickyColumnsStore(), []);\n const wrapperRef = useRef<HTMLElement>(null) as React.MutableRefObject<null | HTMLElement>;\n const tableRef = useRef<HTMLElement>(null) as React.MutableRefObject<null | HTMLElement>;\n const cellsRef = useRef<Record<ColumnId, HTMLElement>>({});\n\n const hasStickyColumns = stickyColumnsFirst + stickyColumnsLast > 0;\n\n const updateStickyStyles = useStableEventHandler(() => {\n if (wrapperRef.current && tableRef.current) {\n store.updateCellStyles({\n wrapper: wrapperRef.current,\n table: tableRef.current,\n cells: cellsRef.current,\n visibleColumns,\n stickyColumnsFirst,\n stickyColumnsLast,\n });\n }\n });\n\n useResizeObserver(wrapperRef, updateStickyStyles);\n\n useResizeObserver(tableRef, updateStickyStyles);\n\n useEffect(() => {\n if (wrapperRef.current && tableRef.current) {\n store.updateCellStyles({\n wrapper: wrapperRef.current,\n table: tableRef.current,\n cells: cellsRef.current,\n visibleColumns,\n stickyColumnsFirst,\n stickyColumnsLast,\n });\n }\n }, [store, stickyColumnsFirst, stickyColumnsLast, visibleColumns]);\n\n // Update wrapper styles imperatively to avoid unnecessary re-renders.\n useEffect(() => {\n if (!hasStickyColumns) {\n return;\n }\n\n const selector = (state: StickyColumnsState) => state.wrapperState;\n\n const updateWrapperStyles = (state: StickyColumnsWrapperState, prev: StickyColumnsWrapperState) => {\n if (isWrapperStatesEqual(state, prev)) {\n return;\n }\n\n if (wrapperRef.current) {\n wrapperRef.current.style.scrollPaddingLeft = state.scrollPaddingLeft + 'px';\n wrapperRef.current.style.scrollPaddingRight = state.scrollPaddingRight + 'px';\n }\n };\n\n const unsubscribe = store.subscribe(selector, (newState, prevState) =>\n updateWrapperStyles(selector(newState), selector(prevState))\n );\n return unsubscribe;\n }, [store, hasStickyColumns]);\n\n const setWrapper = useCallback(\n (node: null | HTMLElement) => {\n if (wrapperRef.current) {\n wrapperRef.current.removeEventListener('scroll', updateStickyStyles);\n }\n if (node && hasStickyColumns) {\n node.addEventListener('scroll', updateStickyStyles);\n }\n wrapperRef.current = node;\n },\n [hasStickyColumns, updateStickyStyles]\n );\n\n const setTable = useCallback((node: null | HTMLElement) => {\n tableRef.current = node;\n }, []);\n\n const setCell = useCallback((columnId: ColumnId, node: null | HTMLElement) => {\n if (node) {\n cellsRef.current[columnId] = node;\n } else {\n delete cellsRef.current[columnId];\n }\n }, []);\n\n return {\n isEnabled: hasStickyColumns,\n store,\n style: {\n // Provide wrapper styles as props so that a re-render won't cause invalidation.\n wrapper: hasStickyColumns ? { ...store.get().wrapperState } : undefined,\n },\n refs: { wrapper: setWrapper, table: setTable, cell: setCell },\n };\n}\n\ninterface UseStickyCellStylesProps {\n stickyColumns: StickyColumnsModel;\n columnId: ColumnId;\n getClassName: (styles: null | StickyColumnsCellState) => Record<string, boolean>;\n}\n\ninterface StickyCellStyles {\n ref: React.RefCallback<HTMLElement>;\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport function useStickyCellStyles({\n stickyColumns,\n columnId,\n getClassName,\n}: UseStickyCellStylesProps): StickyCellStyles {\n const cellRef = useRef<HTMLElement>(null) as React.MutableRefObject<HTMLElement>;\n const setCell = stickyColumns.refs.cell;\n const refCallback = useCallback(\n node => {\n cellRef.current = node;\n setCell(columnId, node);\n },\n [columnId, setCell]\n );\n\n // Update cell styles imperatively to avoid unnecessary re-renders.\n useEffect(\n () => {\n if (!stickyColumns.isEnabled) {\n return;\n }\n\n const selector = (state: StickyColumnsState) => state.cellState[columnId];\n\n const updateCellStyles = (state: null | StickyColumnsCellState, prev: null | StickyColumnsCellState) => {\n if (isCellStatesEqual(state, prev)) {\n return;\n }\n\n const className = getClassName(state);\n const cellElement = cellRef.current;\n if (cellElement) {\n Object.keys(className).forEach(key => {\n if (className[key]) {\n cellElement.classList.add(key);\n } else {\n cellElement.classList.remove(key);\n }\n });\n cellElement.style.left = state?.offset.left !== undefined ? `${state.offset.left}px` : '';\n cellElement.style.right = state?.offset.right !== undefined ? `${state.offset.right}px` : '';\n }\n };\n\n const unsubscribe = stickyColumns.store.subscribe(selector, (newState, prevState) =>\n updateCellStyles(selector(newState), selector(prevState))\n );\n return unsubscribe;\n },\n // getClassName is expected to be pure\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [stickyColumns.store, stickyColumns.isEnabled, columnId]\n );\n\n // Provide cell styles as props so that a re-render won't cause invalidation.\n const cellStyles = stickyColumns.store.get().cellState[columnId];\n return {\n ref: refCallback,\n className: cellStyles ? clsx(getClassName(cellStyles)) : undefined,\n style: cellStyles?.offset ?? undefined,\n };\n}\n\nfunction isCellStatesEqual(s1: null | StickyColumnsCellState, s2: null | StickyColumnsCellState): boolean {\n if (s1 && s2) {\n return (\n s1.padLeft === s2.padLeft &&\n s1.lastLeft === s2.lastLeft &&\n s1.lastRight === s2.lastRight &&\n s1.offset.left === s2.offset.left &&\n s1.offset.right === s2.offset.right\n );\n }\n return s1 === s2;\n}\n\nfunction isWrapperStatesEqual(s1: StickyColumnsWrapperState, s2: StickyColumnsWrapperState): boolean {\n return s1.scrollPaddingLeft === s2.scrollPaddingLeft && s1.scrollPaddingRight === s2.scrollPaddingRight;\n}\n\ninterface UpdateCellStylesProps {\n wrapper: HTMLElement;\n table: HTMLElement;\n cells: Record<ColumnId, HTMLElement>;\n visibleColumns: readonly ColumnId[];\n stickyColumnsFirst: number;\n stickyColumnsLast: number;\n}\n\nexport default class StickyColumnsStore extends AsyncStore<StickyColumnsState> {\n private cellOffsets = new Map<ColumnId, { first: number; last: number }>();\n private stickyWidthLeft = 0;\n private stickyWidthRight = 0;\n private isStuckToTheLeft = false;\n private isStuckToTheRight = false;\n private padLeft = false;\n\n constructor() {\n super({ cellState: {}, wrapperState: { scrollPaddingLeft: 0, scrollPaddingRight: 0 } });\n }\n\n public updateCellStyles(props: UpdateCellStylesProps) {\n const hasStickyColumns = props.stickyColumnsFirst + props.stickyColumnsLast > 0;\n const hadStickyColumns = this.cellOffsets.size > 0;\n\n if (hasStickyColumns || hadStickyColumns) {\n this.updateScroll(props);\n this.updateCellOffsets(props);\n this.set(() => ({\n cellState: this.generateCellStyles(props),\n wrapperState: { scrollPaddingLeft: this.stickyWidthLeft, scrollPaddingRight: this.stickyWidthRight },\n }));\n }\n }\n\n private updateScroll(props: UpdateCellStylesProps) {\n const wrapperScrollLeft = props.wrapper.scrollLeft;\n const wrapperScrollWidth = props.wrapper.scrollWidth;\n const wrapperClientWidth = props.wrapper.clientWidth;\n const tablePaddingLeft = parseFloat(getComputedStyle(props.table).paddingLeft) || 0;\n const tablePaddingRight = parseFloat(getComputedStyle(props.table).paddingRight) || 0;\n\n this.isStuckToTheLeft = wrapperScrollLeft > tablePaddingLeft;\n\n // Math.ceil() is used here to address an edge-case in certain browsers, where they return non-integer wrapperScrollLeft values\n // which are lower than expected (sub-pixel difference), resulting in the table always being in the \"stuck to the right\" state\n this.isStuckToTheRight = Math.ceil(wrapperScrollLeft) < wrapperScrollWidth - wrapperClientWidth - tablePaddingRight;\n\n this.padLeft = tablePaddingLeft !== 0 && this.isStuckToTheLeft;\n }\n\n private generateCellStyles = (props: UpdateCellStylesProps): Record<ColumnId, null | StickyColumnsCellState> => {\n const isEnabled = this.isEnabled(props);\n const lastLeftStickyColumnIndex = props.stickyColumnsFirst - 1;\n const lastRightStickyColumnIndex = props.visibleColumns.length - props.stickyColumnsLast;\n\n return props.visibleColumns.reduce((acc, columnId, index) => {\n let stickySide = 'non-sticky';\n if (index < props.stickyColumnsFirst) {\n stickySide = 'left';\n } else if (index >= props.visibleColumns.length - props.stickyColumnsLast) {\n stickySide = 'right';\n }\n\n if (!isEnabled || stickySide === 'non-sticky') {\n acc[columnId] = null;\n return acc;\n }\n\n // Determine the offset of the sticky column using the `cellOffsets` state object\n const isFirstColumn = index === 0;\n const stickyColumnOffsetLeft = this.cellOffsets.get(columnId)?.first ?? 0;\n const stickyColumnOffsetRight = this.cellOffsets.get(columnId)?.last ?? 0;\n\n acc[columnId] = {\n padLeft: isFirstColumn && this.padLeft,\n lastLeft: this.isStuckToTheLeft && lastLeftStickyColumnIndex === index,\n lastRight: this.isStuckToTheRight && lastRightStickyColumnIndex === index,\n offset: {\n left: stickySide === 'left' ? stickyColumnOffsetLeft : undefined,\n right: stickySide === 'right' ? stickyColumnOffsetRight : undefined,\n },\n };\n return acc;\n }, {} as Record<ColumnId, null | StickyColumnsCellState>);\n };\n\n private updateCellOffsets = (props: UpdateCellStylesProps): void => {\n const firstColumnsWidths: number[] = [];\n for (let i = 0; i < props.visibleColumns.length; i++) {\n const element = props.cells[props.visibleColumns[i]];\n const cellWidth = element.getBoundingClientRect().width ?? 0;\n firstColumnsWidths[i] = (firstColumnsWidths[i - 1] ?? 0) + cellWidth;\n }\n\n const lastColumnsWidths: number[] = [];\n for (let i = props.visibleColumns.length - 1; i >= 0; i--) {\n const element = props.cells[props.visibleColumns[i]];\n const cellWidth = element.getBoundingClientRect().width ?? 0;\n lastColumnsWidths[i] = (lastColumnsWidths[i + 1] ?? 0) + cellWidth;\n }\n lastColumnsWidths.reverse();\n\n this.stickyWidthLeft = firstColumnsWidths[props.stickyColumnsFirst - 1] ?? 0;\n this.stickyWidthRight = lastColumnsWidths[props.stickyColumnsLast - 1] ?? 0;\n this.cellOffsets = props.visibleColumns.reduce(\n (map, columnId, columnIndex) =>\n map.set(columnId, {\n first: firstColumnsWidths[columnIndex - 1] ?? 0,\n last: lastColumnsWidths[props.visibleColumns.length - 1 - columnIndex - 1] ?? 0,\n }),\n new Map()\n );\n };\n\n private isEnabled = (props: UpdateCellStylesProps): boolean => {\n const noStickyColumns = props.stickyColumnsFirst + props.stickyColumnsLast === 0;\n if (noStickyColumns) {\n return false;\n }\n\n const wrapperWidth = props.wrapper.getBoundingClientRect().width;\n const tableWidth = props.table.getBoundingClientRect().width;\n const isWrapperScrollable = tableWidth > wrapperWidth;\n if (!isWrapperScrollable) {\n return false;\n }\n\n const totalStickySpace = this.stickyWidthLeft + this.stickyWidthRight;\n const tablePaddingLeft = parseFloat(getComputedStyle(props.table).paddingLeft) || 0;\n const tablePaddingRight = parseFloat(getComputedStyle(props.table).paddingRight) || 0;\n const hasEnoughScrollableSpace =\n totalStickySpace + MINIMUM_SCROLLABLE_SPACE + tablePaddingLeft + tablePaddingRight < wrapperWidth;\n if (!hasEnoughScrollableSpace) {\n return false;\n }\n\n return true;\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["tabs/index.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AASzC,OAAO,EAAE,SAAS,EAAE,CAAC;AAGrB,eAAO,MAAM,eAAe,cAA+E,CAAC;AAU5G,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAC3B,IAAI,EACJ,OAAmB,EACnB,QAAQ,EACR,WAAW,EAAE,eAAe,EAC5B,SAAS,EACT,cAAc,EACd,sBAA8B,EAC9B,WAAW,EACX,GAAG,IAAI,EACR,EAAE,SAAS,eAyFX"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["tabs/index.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AASzC,OAAO,EAAE,SAAS,EAAE,CAAC;AAGrB,eAAO,MAAM,eAAe,cAA+E,CAAC;AAU5G,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAC3B,IAAI,EACJ,OAAmB,EACnB,QAAQ,EACR,WAAW,EAAE,eAAe,EAC5B,SAAS,EACT,cAAc,EACd,sBAA8B,EAC9B,WAAW,EACX,GAAG,IAAI,EACR,EAAE,SAAS,eA4FX"}
package/tabs/index.js CHANGED
@@ -54,7 +54,9 @@ export default function Tabs(_a) {
54
54
  const isContentShown = isTabSelected && !selectedTab.disabled;
55
55
  return React.createElement("div", Object.assign({}, contentAttributes), isContentShown && selectedTab.content);
56
56
  };
57
- return (React.createElement("div", { className: clsx(variant === 'container' ? styles['tabs-container-content-wrapper'] : styles['tabs-content-wrapper'], {
57
+ return (React.createElement("div", { className: clsx(variant === 'container' || variant === 'stacked'
58
+ ? styles['tabs-container-content-wrapper']
59
+ : styles['tabs-content-wrapper'], {
58
60
  [styles['with-paddings']]: !disableContentPaddings,
59
61
  }) }, tabs.map(renderContent)));
60
62
  };
@@ -62,8 +64,8 @@ export default function Tabs(_a) {
62
64
  setActiveTabId(changeDetail.activeTabId);
63
65
  fireNonCancelableEvent(onChange, changeDetail);
64
66
  }, i18nStrings: i18nStrings }));
65
- if (variant === 'container') {
66
- return (React.createElement(InternalContainer, Object.assign({ header: header, disableHeaderPaddings: true }, baseProps, { className: clsx(baseProps.className, styles.root), __internalRootRef: __internalRootRef, disableContentPaddings: true }), content()));
67
+ if (variant === 'container' || variant === 'stacked') {
68
+ return (React.createElement(InternalContainer, Object.assign({ header: header, disableHeaderPaddings: true }, baseProps, { className: clsx(baseProps.className, styles.root), __internalRootRef: __internalRootRef, disableContentPaddings: true, variant: variant === 'stacked' ? 'stacked' : 'default' }), content()));
67
69
  }
68
70
  return (React.createElement("div", Object.assign({}, baseProps, { className: clsx(baseProps.className, styles.root, styles.tabs), ref: __internalRootRef }),
69
71
  header,
package/tabs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["tabs/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE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AAE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,iBAAiB;QACvG,MAAM;QACN,OAAO,EAAE,CACN,CACP,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useState } from 'react';\nimport { getBaseProps } from '../internal/base-component';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport InternalContainer from '../container/internal';\nimport { TabsProps } from './interfaces';\nimport clsx from 'clsx';\nimport styles from './styles.css.js';\nimport { getTabElementId, TabHeaderBar } from './tab-header-bar';\nimport { useControllable } from '../internal/hooks/use-controllable';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\n\nexport { TabsProps };\n\nlet lastGeneratedId = 0;\nexport const nextGeneratedId = () => `awsui-tabs-${lastGeneratedId++}-${Math.round(Math.random() * 10000)}`;\n\nfunction firstEnabledTab(tabs: ReadonlyArray<TabsProps.Tab>) {\n const enabledTabs = tabs.filter(tab => !tab.disabled);\n if (enabledTabs.length > 0) {\n return enabledTabs[0];\n }\n return null;\n}\n\nexport default function Tabs({\n tabs,\n variant = 'default',\n onChange,\n activeTabId: controlledTabId,\n ariaLabel,\n ariaLabelledby,\n disableContentPaddings = false,\n i18nStrings,\n ...rest\n}: TabsProps) {\n for (const tab of tabs) {\n checkSafeUrl('Tabs', tab.href);\n }\n const { __internalRootRef } = useBaseComponent('Tabs');\n const [idNamespace] = useState(() => nextGeneratedId());\n\n const [activeTabId, setActiveTabId] = useControllable(controlledTabId, onChange, firstEnabledTab(tabs)?.id ?? '', {\n componentName: 'Tabs',\n controlledProp: 'activeTabId',\n changeHandler: 'onChange',\n });\n\n const baseProps = getBaseProps(rest);\n\n const content = () => {\n const selectedTab = tabs.filter(tab => tab.id === activeTabId)[0];\n const renderContent = (tab: TabsProps.Tab) => {\n const isTabSelected = tab === selectedTab;\n\n const classes = clsx({\n [styles['tabs-content']]: true,\n [styles['tabs-content-active']]: isTabSelected,\n });\n\n const contentAttributes: JSX.IntrinsicElements['div'] = {\n className: classes,\n role: 'tabpanel',\n id: `${idNamespace}-${tab.id}-panel`,\n key: `${idNamespace}-${tab.id}-panel`,\n tabIndex: 0,\n 'aria-labelledby': getTabElementId({ namespace: idNamespace, tabId: tab.id }),\n };\n\n const isContentShown = isTabSelected && !selectedTab.disabled;\n return <div {...contentAttributes}>{isContentShown && selectedTab.content}</div>;\n };\n\n return (\n <div\n className={clsx(\n variant === 'container' ? styles['tabs-container-content-wrapper'] : styles['tabs-content-wrapper'],\n {\n [styles['with-paddings']]: !disableContentPaddings,\n }\n )}\n >\n {tabs.map(renderContent)}\n </div>\n );\n };\n\n const header = (\n <TabHeaderBar\n activeTabId={activeTabId}\n variant={variant}\n idNamespace={idNamespace}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n tabs={tabs}\n onChange={changeDetail => {\n setActiveTabId(changeDetail.activeTabId);\n fireNonCancelableEvent(onChange, changeDetail);\n }}\n i18nStrings={i18nStrings}\n />\n );\n\n if (variant === 'container') {\n return (\n <InternalContainer\n header={header}\n disableHeaderPaddings={true}\n {...baseProps}\n className={clsx(baseProps.className, styles.root)}\n __internalRootRef={__internalRootRef}\n disableContentPaddings={true}\n >\n {content()}\n </InternalContainer>\n );\n }\n\n return (\n <div {...baseProps} className={clsx(baseProps.className, styles.root, styles.tabs)} ref={__internalRootRef}>\n {header}\n {content()}\n </div>\n );\n}\n\napplyDisplayName(Tabs, 'Tabs');\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["tabs/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE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B,EACpC,sBAAsB,EAAE,IAAI,EAC5B,OAAO,EAAE,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,KAErD,OAAO,EAAE,CACQ,CACrB,CAAC;KACH;IAED,OAAO,CACL,6CAAS,SAAS,IAAE,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,iBAAiB;QACvG,MAAM;QACN,OAAO,EAAE,CACN,CACP,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useState } from 'react';\nimport { getBaseProps } from '../internal/base-component';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport InternalContainer from '../container/internal';\nimport { TabsProps } from './interfaces';\nimport clsx from 'clsx';\nimport styles from './styles.css.js';\nimport { getTabElementId, TabHeaderBar } from './tab-header-bar';\nimport { useControllable } from '../internal/hooks/use-controllable';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\n\nexport { TabsProps };\n\nlet lastGeneratedId = 0;\nexport const nextGeneratedId = () => `awsui-tabs-${lastGeneratedId++}-${Math.round(Math.random() * 10000)}`;\n\nfunction firstEnabledTab(tabs: ReadonlyArray<TabsProps.Tab>) {\n const enabledTabs = tabs.filter(tab => !tab.disabled);\n if (enabledTabs.length > 0) {\n return enabledTabs[0];\n }\n return null;\n}\n\nexport default function Tabs({\n tabs,\n variant = 'default',\n onChange,\n activeTabId: controlledTabId,\n ariaLabel,\n ariaLabelledby,\n disableContentPaddings = false,\n i18nStrings,\n ...rest\n}: TabsProps) {\n for (const tab of tabs) {\n checkSafeUrl('Tabs', tab.href);\n }\n const { __internalRootRef } = useBaseComponent('Tabs');\n const [idNamespace] = useState(() => nextGeneratedId());\n\n const [activeTabId, setActiveTabId] = useControllable(controlledTabId, onChange, firstEnabledTab(tabs)?.id ?? '', {\n componentName: 'Tabs',\n controlledProp: 'activeTabId',\n changeHandler: 'onChange',\n });\n\n const baseProps = getBaseProps(rest);\n\n const content = () => {\n const selectedTab = tabs.filter(tab => tab.id === activeTabId)[0];\n const renderContent = (tab: TabsProps.Tab) => {\n const isTabSelected = tab === selectedTab;\n\n const classes = clsx({\n [styles['tabs-content']]: true,\n [styles['tabs-content-active']]: isTabSelected,\n });\n\n const contentAttributes: JSX.IntrinsicElements['div'] = {\n className: classes,\n role: 'tabpanel',\n id: `${idNamespace}-${tab.id}-panel`,\n key: `${idNamespace}-${tab.id}-panel`,\n tabIndex: 0,\n 'aria-labelledby': getTabElementId({ namespace: idNamespace, tabId: tab.id }),\n };\n\n const isContentShown = isTabSelected && !selectedTab.disabled;\n return <div {...contentAttributes}>{isContentShown && selectedTab.content}</div>;\n };\n\n return (\n <div\n className={clsx(\n variant === 'container' || variant === 'stacked'\n ? styles['tabs-container-content-wrapper']\n : styles['tabs-content-wrapper'],\n {\n [styles['with-paddings']]: !disableContentPaddings,\n }\n )}\n >\n {tabs.map(renderContent)}\n </div>\n );\n };\n\n const header = (\n <TabHeaderBar\n activeTabId={activeTabId}\n variant={variant}\n idNamespace={idNamespace}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n tabs={tabs}\n onChange={changeDetail => {\n setActiveTabId(changeDetail.activeTabId);\n fireNonCancelableEvent(onChange, changeDetail);\n }}\n i18nStrings={i18nStrings}\n />\n );\n\n if (variant === 'container' || variant === 'stacked') {\n return (\n <InternalContainer\n header={header}\n disableHeaderPaddings={true}\n {...baseProps}\n className={clsx(baseProps.className, styles.root)}\n __internalRootRef={__internalRootRef}\n disableContentPaddings={true}\n variant={variant === 'stacked' ? 'stacked' : 'default'}\n >\n {content()}\n </InternalContainer>\n );\n }\n\n return (\n <div {...baseProps} className={clsx(baseProps.className, styles.root, styles.tabs)} ref={__internalRootRef}>\n {header}\n {content()}\n </div>\n );\n}\n\napplyDisplayName(Tabs, 'Tabs');\n"]}
@@ -19,7 +19,8 @@ export interface TabsProps extends BaseComponentProps {
19
19
  /**
20
20
  * The possible visual variants of tabs are the following:
21
21
  * * `default` - Use in any context.
22
- * * `container` - A variant with borders, for use alongside other containers.
22
+ * * `container` - Use this variant to have the tabs displayed within a container header.
23
+ * * `stacked` - Use this variant directly adjacent to other stacked containers (such as a container, table).
23
24
  */
24
25
  variant?: TabsProps.Variant;
25
26
  /**
@@ -54,7 +55,7 @@ export interface TabsProps extends BaseComponentProps {
54
55
  i18nStrings?: TabsProps.I18nStrings;
55
56
  }
56
57
  export declare namespace TabsProps {
57
- type Variant = 'default' | 'container';
58
+ type Variant = 'default' | 'container' | 'stacked';
58
59
  interface Tab {
59
60
  /**
60
61
  * The tab id. This value will be need to be passed to the Tabs component as `activeTabId` to select this tab.
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"lib/default/","sources":["tabs/interfaces.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,WAAW,SAAU,SAAQ,kBAAkB;IACnD;;;;;;;;;;;;OAYG;IACH,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAEnC;;;;OAIG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC;IAE5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,yBAAyB,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IAE7D;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,cAAc,CAAC,EAA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M,CAAC;IAErB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;OAEG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC,WAAW,CAAC;CACrC;AACD,yBAAiB,SAAS,CAAC;IACzB,KAAY,OAAO,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;IAE1D,UAAiB,GAAG;QAClB;;WAEG;QACH,EAAE,EAAE,MAAM,CAAC;QACX;;WAEG;QACH,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;QACvB;;WAEG;QACH,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;QAC1B;;WAEG;QACH,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB;;;;;;WAMG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;KACf;IAED,UAAiB,YAAY;QAC3B;;WAEG;QACH,WAAW,EAAE,MAAM,CAAC;QACpB;;WAEG;QACH,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB;IAED,UAAiB,WAAW;QAC1B;;WAEG;QACH,mBAAmB,EAAE,MAAM,CAAC;QAC5B;;WAEG;QACH,oBAAoB,EAAE,MAAM,CAAC;KAC9B;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["tabs/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface TabsProps extends BaseComponentProps {\n /**\n * Specifies the tabs to display. Each tab object has the following properties:\n *\n * - `id` (string) - The tab identifier. This value needs to be passed to the Tabs component as `activeTabId` to select this tab.\n * - `label` (ReactNode) - Tab label shown in the UI.\n * - `content` (ReactNode) - (Optional) Tab content to render in the container.\n * - `disabled` (boolean) - (Optional) Specifies if this tab is disabled.\n * - `href` (string) - (Optional) You can use this parameter to change the default `href` of the internal tab anchor. The\n * `click` event default behavior is prevented, unless the user clicks the tab with a key modifier (that is, CTRL,\n * ALT, SHIFT, META). This enables the user to open new browser tabs with an initially selected component tab,\n * if your application routing can handle such deep links. You can manually update routing on the current page\n * using the `activeTabHref` property of the `change` event's detail.\n */\n tabs: ReadonlyArray<TabsProps.Tab>;\n\n /**\n * The possible visual variants of tabs are the following:\n * * `default` - Use in any context.\n * * `container` - A variant with borders, for use alongside other containers.\n */\n variant?: TabsProps.Variant;\n\n /**\n * Called whenever the user selects a different tab.\n * The event's `detail` contains the new `activeTabId`.\n */\n onChange?: NonCancelableEventHandler<TabsProps.ChangeDetail>;\n\n /**\n * The `id` of the currently active tab.\n * * If you don't set this property, the component activates the first tab and switches tabs automatically when a tab header is clicked (that is, uncontrolled behavior).\n * * If you explicitly set this property, you must set define an `onChange` handler to update the property when a tab header is clicked (that is, controlled behavior).\n */\n activeTabId?: string;\n\n /**\n * Provides an `aria-label` to the tab container.\n * Don't use `ariaLabel` and `ariaLabelledby` at the same time.\n */\n ariaLabel?: string;\n\n /**\n * Sets the `aria-labelledby` property on the tab container.\n * If there's a visible label element that you can reference, use this instead of `ariaLabel`.\n * Don't use `ariaLabel` and `ariaLabelledby` at the same time.\n */\n ariaLabelledby?: string;\n\n /**\n * Determines whether the tab content has padding. If `true`, removes the default padding from the tab content area.\n */\n disableContentPaddings?: boolean;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n */\n i18nStrings?: TabsProps.I18nStrings;\n}\nexport namespace TabsProps {\n export type Variant = 'default' | 'container';\n\n export interface Tab {\n /**\n * The tab id. This value will be need to be passed to the Tabs component as `activeTabId` to select this tab.\n */\n id: string;\n /**\n * Tab label shown in the UI.\n */\n label: React.ReactNode;\n /**\n * Tab content to render in the container.\n */\n content?: React.ReactNode;\n /**\n * Whether this tab is disabled.\n */\n disabled?: boolean;\n /**\n * You can use this parameter to change the default `href` of the internal tab anchor. The\n * `click` event default behavior is prevented, unless the user clicks the tab with a key modifier (CTRL,\n * ALT, SHIFT, META). This allows to open new browser tabs with an initially selected component tab,\n * when the routing can handle such deep links. You can manually update routing on the current page\n * using the `activeTabHref` property of the `change` event's detail.\n */\n href?: string;\n }\n\n export interface ChangeDetail {\n /**\n * The ID of the clicked tab.\n */\n activeTabId: string;\n /**\n * The `href` attribute of the clicked tab, if defined.\n */\n activeTabHref?: string;\n }\n\n export interface I18nStrings {\n /**\n * ARIA label for the scroll left button that appears when the tab header is wider than the container.\n */\n scrollLeftAriaLabel: string;\n /**\n * ARIA label for the scroll right button that appears when the tab header is wider than the container.\n */\n scrollRightAriaLabel: string;\n }\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["tabs/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface TabsProps extends BaseComponentProps {\n /**\n * Specifies the tabs to display. Each tab object has the following properties:\n *\n * - `id` (string) - The tab identifier. This value needs to be passed to the Tabs component as `activeTabId` to select this tab.\n * - `label` (ReactNode) - Tab label shown in the UI.\n * - `content` (ReactNode) - (Optional) Tab content to render in the container.\n * - `disabled` (boolean) - (Optional) Specifies if this tab is disabled.\n * - `href` (string) - (Optional) You can use this parameter to change the default `href` of the internal tab anchor. The\n * `click` event default behavior is prevented, unless the user clicks the tab with a key modifier (that is, CTRL,\n * ALT, SHIFT, META). This enables the user to open new browser tabs with an initially selected component tab,\n * if your application routing can handle such deep links. You can manually update routing on the current page\n * using the `activeTabHref` property of the `change` event's detail.\n */\n tabs: ReadonlyArray<TabsProps.Tab>;\n\n /**\n * The possible visual variants of tabs are the following:\n * * `default` - Use in any context.\n * * `container` - Use this variant to have the tabs displayed within a container header.\n * * `stacked` - Use this variant directly adjacent to other stacked containers (such as a container, table).\n */\n variant?: TabsProps.Variant;\n\n /**\n * Called whenever the user selects a different tab.\n * The event's `detail` contains the new `activeTabId`.\n */\n onChange?: NonCancelableEventHandler<TabsProps.ChangeDetail>;\n\n /**\n * The `id` of the currently active tab.\n * * If you don't set this property, the component activates the first tab and switches tabs automatically when a tab header is clicked (that is, uncontrolled behavior).\n * * If you explicitly set this property, you must set define an `onChange` handler to update the property when a tab header is clicked (that is, controlled behavior).\n */\n activeTabId?: string;\n\n /**\n * Provides an `aria-label` to the tab container.\n * Don't use `ariaLabel` and `ariaLabelledby` at the same time.\n */\n ariaLabel?: string;\n\n /**\n * Sets the `aria-labelledby` property on the tab container.\n * If there's a visible label element that you can reference, use this instead of `ariaLabel`.\n * Don't use `ariaLabel` and `ariaLabelledby` at the same time.\n */\n ariaLabelledby?: string;\n\n /**\n * Determines whether the tab content has padding. If `true`, removes the default padding from the tab content area.\n */\n disableContentPaddings?: boolean;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n */\n i18nStrings?: TabsProps.I18nStrings;\n}\nexport namespace TabsProps {\n export type Variant = 'default' | 'container' | 'stacked';\n\n export interface Tab {\n /**\n * The tab id. This value will be need to be passed to the Tabs component as `activeTabId` to select this tab.\n */\n id: string;\n /**\n * Tab label shown in the UI.\n */\n label: React.ReactNode;\n /**\n * Tab content to render in the container.\n */\n content?: React.ReactNode;\n /**\n * Whether this tab is disabled.\n */\n disabled?: boolean;\n /**\n * You can use this parameter to change the default `href` of the internal tab anchor. The\n * `click` event default behavior is prevented, unless the user clicks the tab with a key modifier (CTRL,\n * ALT, SHIFT, META). This allows to open new browser tabs with an initially selected component tab,\n * when the routing can handle such deep links. You can manually update routing on the current page\n * using the `activeTabHref` property of the `change` event's detail.\n */\n href?: string;\n }\n\n export interface ChangeDetail {\n /**\n * The ID of the clicked tab.\n */\n activeTabId: string;\n /**\n * The `href` attribute of the clicked tab, if defined.\n */\n activeTabHref?: string;\n }\n\n export interface I18nStrings {\n /**\n * ARIA label for the scroll left button that appears when the tab header is wider than the container.\n */\n scrollLeftAriaLabel: string;\n /**\n * ARIA label for the scroll right button that appears when the tab header is wider than the container.\n */\n scrollRightAriaLabel: string;\n }\n}\n"]}