@cloudscape-design/components-themeable 3.0.1236 → 3.0.1238
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.
- package/lib/internal/manifest.json +1 -1
- package/lib/internal/scss/internal/generated/custom-css-properties/index.scss +1 -1
- package/lib/internal/template/app-layout/interfaces.d.ts +3 -1
- package/lib/internal/template/app-layout/interfaces.d.ts.map +1 -1
- package/lib/internal/template/app-layout/interfaces.js.map +1 -1
- package/lib/internal/template/internal/base-component/styles.scoped.css +1 -1
- package/lib/internal/template/internal/environment.js +2 -2
- package/lib/internal/template/internal/environment.json +2 -2
- package/lib/internal/template/table/use-column-widths.d.ts.map +1 -1
- package/lib/internal/template/table/use-column-widths.js +3 -1
- package/lib/internal/template/table/use-column-widths.js.map +1 -1
- package/package.json +1 -1
|
@@ -199,7 +199,9 @@ export interface BaseLayoutProps extends BaseComponentProps {
|
|
|
199
199
|
/**
|
|
200
200
|
* Controls the split panel preferences.
|
|
201
201
|
*
|
|
202
|
-
* By default, the preference is `{ position: 'bottom' }
|
|
202
|
+
* By default, the preference is `{ position: 'bottom' }`.
|
|
203
|
+
*
|
|
204
|
+
* On smaller screens, the panel is forced to the `'bottom'` position and the `'side'` preference becomes disabled.
|
|
203
205
|
*/
|
|
204
206
|
splitPanelPreferences?: AppLayoutProps.SplitPanelPreferences;
|
|
205
207
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/app-layout/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO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AAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QAEpB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,wBAAwB,CAAC,EAAE,MAAM,CAAC;KACnC;IAED,UAAiB,YAAY;QAC3B,IAAI,EAAE,OAAO,CAAC;KACf;IAED,UAAiB,sBAAsB;QACrC,IAAI,EAAE,MAAM,CAAC;KACd;IAED,UAAiB,qBAAqB;QACpC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAC;KAC7B;IAGD,KAAY,kBAAkB,GAAG,MAAM,GAAG,QAAQ,CAAC;IAEnD,UAAiB,kBAAkB;QACjC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;KAC/B;CACF;AAED,MAAM,MAAM,0BAA0B,GAAG,YAAY,CACnD,IAAI,CAAC,cAAc,EAAE,gBAAgB,GAAG,gBAAgB,CAAC,EACzD,aAAa,GAAG,iBAAiB,GAAG,YAAY,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,oBAAoB,CAC/G,GAAG;IACF,SAAS,EAAE;QACT,eAAe,EAAE,MAAM,CAAC;QACxB,aAAa,EAAE,MAAM,CAAC;QACtB,gBAAgB,EAAE,MAAM,CAAC;QACzB,cAAc,EAAE,MAAM,CAAC;QACvB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/app-layout/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { IconProps } from '../icon/interfaces';\nimport { FlowType } from '../internal/analytics/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { SomeRequired } from '../internal/types';\n\nexport interface BaseLayoutProps extends BaseComponentProps {\n /**\n * Specifies additional analytics-related metadata.\n * * `instanceIdentifier` - A unique string that identifies this component instance in your application.\n * * `flowType` - Identifies the type of flow represented by the component.\n * **Note:** This API is currently experimental.\n * @analytics\n */\n analyticsMetadata?: AppLayoutProps.AnalyticsMetadata;\n\n /**\n * Determines the default behavior of the component based on some predefined page layouts.\n * Individual properties will always take precedence over the default coming from the content type.\n */\n contentType?: AppLayoutProps.ContentType;\n\n /**\n * Drawers property. If you set both `drawers` and `tools`, `drawers` will take precedence.\n\n * Each Drawer is an item in the drawers wrapper with the following properties:\n * * id (string) - the id of the drawer.\n * * content (React.ReactNode) - the content in the drawer.\n * * trigger (DrawerTrigger) - the button that opens and closes the active drawer.\n * * ariaLabels (DrawerAriaLabels) - the labels for the interactive elements of the drawer.\n * * badge (boolean) - Adds a badge to the corner of the icon to indicate a state change. For example: Unread notifications.\n * * resizable (boolean) - if the drawer is resizable or not.\n * * defaultSize (number) - starting size of the drawer. if not set, defaults to 290.\n * * onResize (({ size: number }) => void) - Fired when the active drawer is resized.\n *\n * #### DrawerTrigger\n * - `iconName` (IconProps.Name) - (Optional) Specifies the icon to be displayed.\n * - `iconSvg` (React.ReactNode) - (Optional) Specifies the SVG of a custom icon. For more information, see [SVG icon guidelines](/components/icon/?tabId=api#slots)\n *\n * #### DrawerAriaLabels\n * - `drawerName` (string) - Label for the drawer itself, and for the drawer trigger button tooltip text.\n * - `closeButton` (string) - (Optional) Label for the close button.\n * - `triggerButton` (string) - (Optional) Label for the trigger button. When `badge` is true, include the badge information in the label (for example, \"Notifications, has unread messages\").\n * - `resizeHandle` (string) - (Optional) Label for the resize handle.\n */\n drawers?: Array<AppLayoutProps.Drawer>;\n\n /**\n * The active drawer id. If you want to clear the active drawer, use `null`.\n */\n activeDrawerId?: string | null;\n\n /**\n * Fired when the active drawer is toggled.\n */\n onDrawerChange?: NonCancelableEventHandler<AppLayoutProps.DrawerChangeDetail>;\n\n /**\n * If `true`, disables outer paddings for the content slot.\n */\n disableContentPaddings?: boolean;\n\n /**\n * State of the navigation drawer.\n */\n navigationOpen?: boolean;\n\n /**\n * Navigation drawer width in pixels.\n */\n navigationWidth?: number;\n\n /**\n * If `true`, the navigation drawer is not displayed at all.\n */\n navigationHide?: boolean;\n\n /**\n * State of the tools drawer.\n */\n toolsOpen?: boolean;\n\n /**\n * If `true`, the tools drawer is not displayed at all.\n */\n toolsHide?: boolean;\n\n /**\n * Tools drawer width in pixels.\n */\n toolsWidth?: number;\n\n /**\n * Maximum main content panel width in pixels.\n *\n * If set to `Number.MAX_VALUE`, the main content panel will occupy the full available width.\n */\n maxContentWidth?: number;\n\n /**\n * Minimum main content panel width in pixels.\n */\n minContentWidth?: number;\n\n /**\n * If true, the notification slot is rendered above the scrollable\n * content area so it is always visible.\n */\n stickyNotifications?: boolean;\n\n /**\n * CSS selector for the application header.\n */\n headerSelector?: string;\n\n /**\n * CSS selector for the application footer.\n */\n footerSelector?: string;\n\n /**\n * Aria labels for the drawer operating buttons. Use this property to ensure accessibility.\n *\n * * `navigation` (string) - Label for the landmark that wraps the navigation drawer.\n * * `navigationClose` (string) - Label for the button that closes the navigation drawer.\n * * `navigationToggle` (string) - Label for the button that opens the navigation drawer.\n * * `notification` (string) - Label for the region that contains notification messages.\n * * `tools` (string) - Label for the landmark that wraps the tools drawer.\n * * `toolsClose` (string) - Label for the button that closes the tools drawer.\n * * `toolsToggle` (string) - Label for the button that opens the tools drawer.\n * * `drawers` (string) - Label for the landmark that wraps the active drawer.\n * * `drawersOverflow` (string) - Label for the ellipsis button with any overflow drawers.\n * * `drawersOverflowWithBadge` (string) - Label for the ellipsis button with any overflow drawers, with a badge.\n *\n * Example:\n * ```\n * {\n * navigation: \"Navigation drawer\",\n * navigationClose: \"Close navigation drawer\",\n * navigationToggle: \"Open navigation drawer\",\n * notifications: \"Notifications\",\n * tools: \"Help panel\",\n * toolsClose: \"Close help panel\",\n * toolsToggle: \"Open help panel\",\n * drawers: \"Drawers\",\n * drawersOverflow: \"Overflow drawers\",\n * drawersOverflowWithBadge: \"Overflow drawers (Unread notifications)\"\n * }\n * ```\n * @i18n\n */\n ariaLabels?: AppLayoutProps.Labels;\n\n /**\n * Navigation drawer.\n */\n navigation?: React.ReactNode;\n\n /**\n * Top area of the page content.\n * @deprecated Replaced by the `header` slot of the [content layout](/components/content-layout/) component.\n * @visualrefresh\n */\n contentHeader?: React.ReactNode;\n\n /**\n * Disables overlap between `contentHeader` and `content` slots.\n * @deprecated Replaced by the `disableOverlap` property of the [content layout](/components/content-layout/) component.\n * @visualrefresh\n */\n disableContentHeaderOverlap?: boolean;\n\n /**\n * Determines the visual treatment for the breadcrumbs and notifications slots. Specifically:\n * * `default` - Does not apply any visual treatment.\n * * `high-contrast` - Applies high-contrast to both slots. Use in conjunction with `headerVariant=\"high-contrast\"` in ContentLayout.\n * @visualrefresh\n */\n headerVariant?: 'default' | 'high-contrast';\n\n /**\n * Main content.\n */\n content?: React.ReactNode;\n\n /**\n * Tools drawer.\n */\n tools?: React.ReactNode;\n\n /**\n * Displayed on top of the main content in the scrollable area.\n *\n * Conceived to contain notifications (flash messages).\n */\n notifications?: React.ReactNode;\n\n /**\n * Use this slot to add the [breadcrumb group component](/components/breadcrumb-group/) to the app layout.\n */\n breadcrumbs?: React.ReactNode;\n\n /**\n * Fired when the navigation drawer is toggled.\n */\n onNavigationChange?: NonCancelableEventHandler<AppLayoutProps.ChangeDetail>;\n\n /**\n * Fired when the tools drawer is toggled.\n */\n onToolsChange?: NonCancelableEventHandler<AppLayoutProps.ChangeDetail>;\n\n /**\n * Use this slot to add the [split panel component](/components/split-panel/) to the app layout.\n *\n * Note: If provided, this property should be set to `null` or `undefined` if a split panel should not be rendered.\n */\n splitPanel?: React.ReactNode;\n\n /**\n * The size of the split panel in pixels.\n */\n splitPanelSize?: number;\n\n /**\n * State of the split panel.\n */\n splitPanelOpen?: boolean;\n /**\n * Controls the split panel preferences.\n *\n * By default, the preference is `{ position: 'bottom' }`\n */\n splitPanelPreferences?: AppLayoutProps.SplitPanelPreferences;\n /**\n * Fired when the split panel is resized.\n */\n onSplitPanelResize?: NonCancelableEventHandler<AppLayoutProps.SplitPanelResizeDetail>;\n /**\n * Fired when the split panel is toggled.\n */\n onSplitPanelToggle?: NonCancelableEventHandler<AppLayoutProps.ChangeDetail>;\n /**\n * Fired when the split panel preferences change.\n */\n onSplitPanelPreferencesChange?: NonCancelableEventHandler<AppLayoutProps.SplitPanelPreferences>;\n}\n\nexport interface AppLayoutProps extends BaseLayoutProps {\n /**\n * Activates a backwards-compatibility mode for applications with non-fixed headers and footers.\n * @deprecated This layout is being phased out and may miss some features.\n */\n disableBodyScroll?: boolean;\n}\n\nexport namespace AppLayoutProps {\n export interface AnalyticsMetadata {\n instanceIdentifier?: string;\n flowType?: FlowType;\n }\n\n export type ContentType = 'default' | 'form' | 'table' | 'cards' | 'wizard' | 'dashboard';\n\n export interface Ref {\n /**\n * Manually closes the navigation drawer if it is necessary for the current\n * viewport size.\n */\n closeNavigationIfNecessary(): void;\n\n /**\n * Opens the tools panel if it is not already open. Note that it is preferable\n * to control the state by listening to `toolsChange` and providing `toolsOpen`.\n */\n openTools(): void;\n\n /**\n * Focuses the tools panel if it is open. Use this to focus the tools panel\n * after changing the content, for example when clicking on an 'info' link while\n * the panel is already open.\n */\n focusToolsClose(): void;\n\n /**\n * Focuses the active drawer. Use this to focus the active drawer after opening it programmatically.\n */\n focusActiveDrawer(): void;\n\n /**\n * Focuses the split panel if it is open.\n */\n focusSplitPanel(): void;\n }\n\n export interface Drawer {\n id: string;\n content: React.ReactNode;\n trigger?: {\n iconName?: IconProps.Name;\n iconSvg?: React.ReactNode;\n customIcon?: React.ReactNode;\n };\n ariaLabels: DrawerAriaLabels;\n badge?: boolean;\n resizable?: boolean;\n defaultSize?: number;\n onResize?: NonCancelableEventHandler<{ size: number }>;\n preserveInactiveContent?: boolean;\n }\n\n export interface DrawerAriaLabels {\n drawerName: string;\n closeButton?: string;\n triggerButton?: string;\n resizeHandle?: string;\n resizeHandleTooltipText?: string;\n }\n\n export interface Labels {\n notifications?: string;\n\n navigation?: string;\n navigationToggle?: string;\n navigationClose?: string;\n\n tools?: string;\n toolsToggle?: string;\n toolsClose?: string;\n\n drawers?: string;\n drawersOverflow?: string;\n drawersOverflowWithBadge?: string;\n }\n\n export interface ChangeDetail {\n open: boolean;\n }\n\n export interface SplitPanelResizeDetail {\n size: number;\n }\n\n export interface SplitPanelPreferences {\n position: 'side' | 'bottom';\n }\n // Duplicated the positions because using this definition in SplitPanelPreferences would display\n // 'AppLayoutProps.SplitPanelPosition' on the API docs instead of the string values.\n export type SplitPanelPosition = 'side' | 'bottom';\n\n export interface DrawerChangeDetail {\n activeDrawerId: string | null;\n }\n}\n\nexport type AppLayoutPropsWithDefaults = SomeRequired<\n Omit<AppLayoutProps, 'headerSelector' | 'footerSelector'>,\n 'contentType' | 'navigationWidth' | 'toolsWidth' | 'minContentWidth' | 'navigationOpen' | 'onNavigationChange'\n> & {\n placement: {\n insetBlockStart: number;\n insetBlockEnd: number;\n insetInlineStart: number;\n insetInlineEnd: number;\n inlineSize: number;\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/app-layout/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { IconProps } from '../icon/interfaces';\nimport { FlowType } from '../internal/analytics/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { SomeRequired } from '../internal/types';\n\nexport interface BaseLayoutProps extends BaseComponentProps {\n /**\n * Specifies additional analytics-related metadata.\n * * `instanceIdentifier` - A unique string that identifies this component instance in your application.\n * * `flowType` - Identifies the type of flow represented by the component.\n * **Note:** This API is currently experimental.\n * @analytics\n */\n analyticsMetadata?: AppLayoutProps.AnalyticsMetadata;\n\n /**\n * Determines the default behavior of the component based on some predefined page layouts.\n * Individual properties will always take precedence over the default coming from the content type.\n */\n contentType?: AppLayoutProps.ContentType;\n\n /**\n * Drawers property. If you set both `drawers` and `tools`, `drawers` will take precedence.\n\n * Each Drawer is an item in the drawers wrapper with the following properties:\n * * id (string) - the id of the drawer.\n * * content (React.ReactNode) - the content in the drawer.\n * * trigger (DrawerTrigger) - the button that opens and closes the active drawer.\n * * ariaLabels (DrawerAriaLabels) - the labels for the interactive elements of the drawer.\n * * badge (boolean) - Adds a badge to the corner of the icon to indicate a state change. For example: Unread notifications.\n * * resizable (boolean) - if the drawer is resizable or not.\n * * defaultSize (number) - starting size of the drawer. if not set, defaults to 290.\n * * onResize (({ size: number }) => void) - Fired when the active drawer is resized.\n *\n * #### DrawerTrigger\n * - `iconName` (IconProps.Name) - (Optional) Specifies the icon to be displayed.\n * - `iconSvg` (React.ReactNode) - (Optional) Specifies the SVG of a custom icon. For more information, see [SVG icon guidelines](/components/icon/?tabId=api#slots)\n *\n * #### DrawerAriaLabels\n * - `drawerName` (string) - Label for the drawer itself, and for the drawer trigger button tooltip text.\n * - `closeButton` (string) - (Optional) Label for the close button.\n * - `triggerButton` (string) - (Optional) Label for the trigger button. When `badge` is true, include the badge information in the label (for example, \"Notifications, has unread messages\").\n * - `resizeHandle` (string) - (Optional) Label for the resize handle.\n */\n drawers?: Array<AppLayoutProps.Drawer>;\n\n /**\n * The active drawer id. If you want to clear the active drawer, use `null`.\n */\n activeDrawerId?: string | null;\n\n /**\n * Fired when the active drawer is toggled.\n */\n onDrawerChange?: NonCancelableEventHandler<AppLayoutProps.DrawerChangeDetail>;\n\n /**\n * If `true`, disables outer paddings for the content slot.\n */\n disableContentPaddings?: boolean;\n\n /**\n * State of the navigation drawer.\n */\n navigationOpen?: boolean;\n\n /**\n * Navigation drawer width in pixels.\n */\n navigationWidth?: number;\n\n /**\n * If `true`, the navigation drawer is not displayed at all.\n */\n navigationHide?: boolean;\n\n /**\n * State of the tools drawer.\n */\n toolsOpen?: boolean;\n\n /**\n * If `true`, the tools drawer is not displayed at all.\n */\n toolsHide?: boolean;\n\n /**\n * Tools drawer width in pixels.\n */\n toolsWidth?: number;\n\n /**\n * Maximum main content panel width in pixels.\n *\n * If set to `Number.MAX_VALUE`, the main content panel will occupy the full available width.\n */\n maxContentWidth?: number;\n\n /**\n * Minimum main content panel width in pixels.\n */\n minContentWidth?: number;\n\n /**\n * If true, the notification slot is rendered above the scrollable\n * content area so it is always visible.\n */\n stickyNotifications?: boolean;\n\n /**\n * CSS selector for the application header.\n */\n headerSelector?: string;\n\n /**\n * CSS selector for the application footer.\n */\n footerSelector?: string;\n\n /**\n * Aria labels for the drawer operating buttons. Use this property to ensure accessibility.\n *\n * * `navigation` (string) - Label for the landmark that wraps the navigation drawer.\n * * `navigationClose` (string) - Label for the button that closes the navigation drawer.\n * * `navigationToggle` (string) - Label for the button that opens the navigation drawer.\n * * `notification` (string) - Label for the region that contains notification messages.\n * * `tools` (string) - Label for the landmark that wraps the tools drawer.\n * * `toolsClose` (string) - Label for the button that closes the tools drawer.\n * * `toolsToggle` (string) - Label for the button that opens the tools drawer.\n * * `drawers` (string) - Label for the landmark that wraps the active drawer.\n * * `drawersOverflow` (string) - Label for the ellipsis button with any overflow drawers.\n * * `drawersOverflowWithBadge` (string) - Label for the ellipsis button with any overflow drawers, with a badge.\n *\n * Example:\n * ```\n * {\n * navigation: \"Navigation drawer\",\n * navigationClose: \"Close navigation drawer\",\n * navigationToggle: \"Open navigation drawer\",\n * notifications: \"Notifications\",\n * tools: \"Help panel\",\n * toolsClose: \"Close help panel\",\n * toolsToggle: \"Open help panel\",\n * drawers: \"Drawers\",\n * drawersOverflow: \"Overflow drawers\",\n * drawersOverflowWithBadge: \"Overflow drawers (Unread notifications)\"\n * }\n * ```\n * @i18n\n */\n ariaLabels?: AppLayoutProps.Labels;\n\n /**\n * Navigation drawer.\n */\n navigation?: React.ReactNode;\n\n /**\n * Top area of the page content.\n * @deprecated Replaced by the `header` slot of the [content layout](/components/content-layout/) component.\n * @visualrefresh\n */\n contentHeader?: React.ReactNode;\n\n /**\n * Disables overlap between `contentHeader` and `content` slots.\n * @deprecated Replaced by the `disableOverlap` property of the [content layout](/components/content-layout/) component.\n * @visualrefresh\n */\n disableContentHeaderOverlap?: boolean;\n\n /**\n * Determines the visual treatment for the breadcrumbs and notifications slots. Specifically:\n * * `default` - Does not apply any visual treatment.\n * * `high-contrast` - Applies high-contrast to both slots. Use in conjunction with `headerVariant=\"high-contrast\"` in ContentLayout.\n * @visualrefresh\n */\n headerVariant?: 'default' | 'high-contrast';\n\n /**\n * Main content.\n */\n content?: React.ReactNode;\n\n /**\n * Tools drawer.\n */\n tools?: React.ReactNode;\n\n /**\n * Displayed on top of the main content in the scrollable area.\n *\n * Conceived to contain notifications (flash messages).\n */\n notifications?: React.ReactNode;\n\n /**\n * Use this slot to add the [breadcrumb group component](/components/breadcrumb-group/) to the app layout.\n */\n breadcrumbs?: React.ReactNode;\n\n /**\n * Fired when the navigation drawer is toggled.\n */\n onNavigationChange?: NonCancelableEventHandler<AppLayoutProps.ChangeDetail>;\n\n /**\n * Fired when the tools drawer is toggled.\n */\n onToolsChange?: NonCancelableEventHandler<AppLayoutProps.ChangeDetail>;\n\n /**\n * Use this slot to add the [split panel component](/components/split-panel/) to the app layout.\n *\n * Note: If provided, this property should be set to `null` or `undefined` if a split panel should not be rendered.\n */\n splitPanel?: React.ReactNode;\n\n /**\n * The size of the split panel in pixels.\n */\n splitPanelSize?: number;\n\n /**\n * State of the split panel.\n */\n splitPanelOpen?: boolean;\n /**\n * Controls the split panel preferences.\n *\n * By default, the preference is `{ position: 'bottom' }`.\n *\n * On smaller screens, the panel is forced to the `'bottom'` position and the `'side'` preference becomes disabled.\n */\n splitPanelPreferences?: AppLayoutProps.SplitPanelPreferences;\n /**\n * Fired when the split panel is resized.\n */\n onSplitPanelResize?: NonCancelableEventHandler<AppLayoutProps.SplitPanelResizeDetail>;\n /**\n * Fired when the split panel is toggled.\n */\n onSplitPanelToggle?: NonCancelableEventHandler<AppLayoutProps.ChangeDetail>;\n /**\n * Fired when the split panel preferences change.\n */\n onSplitPanelPreferencesChange?: NonCancelableEventHandler<AppLayoutProps.SplitPanelPreferences>;\n}\n\nexport interface AppLayoutProps extends BaseLayoutProps {\n /**\n * Activates a backwards-compatibility mode for applications with non-fixed headers and footers.\n * @deprecated This layout is being phased out and may miss some features.\n */\n disableBodyScroll?: boolean;\n}\n\nexport namespace AppLayoutProps {\n export interface AnalyticsMetadata {\n instanceIdentifier?: string;\n flowType?: FlowType;\n }\n\n export type ContentType = 'default' | 'form' | 'table' | 'cards' | 'wizard' | 'dashboard';\n\n export interface Ref {\n /**\n * Manually closes the navigation drawer if it is necessary for the current\n * viewport size.\n */\n closeNavigationIfNecessary(): void;\n\n /**\n * Opens the tools panel if it is not already open. Note that it is preferable\n * to control the state by listening to `toolsChange` and providing `toolsOpen`.\n */\n openTools(): void;\n\n /**\n * Focuses the tools panel if it is open. Use this to focus the tools panel\n * after changing the content, for example when clicking on an 'info' link while\n * the panel is already open.\n */\n focusToolsClose(): void;\n\n /**\n * Focuses the active drawer. Use this to focus the active drawer after opening it programmatically.\n */\n focusActiveDrawer(): void;\n\n /**\n * Focuses the split panel if it is open.\n */\n focusSplitPanel(): void;\n }\n\n export interface Drawer {\n id: string;\n content: React.ReactNode;\n trigger?: {\n iconName?: IconProps.Name;\n iconSvg?: React.ReactNode;\n customIcon?: React.ReactNode;\n };\n ariaLabels: DrawerAriaLabels;\n badge?: boolean;\n resizable?: boolean;\n defaultSize?: number;\n onResize?: NonCancelableEventHandler<{ size: number }>;\n preserveInactiveContent?: boolean;\n }\n\n export interface DrawerAriaLabels {\n drawerName: string;\n closeButton?: string;\n triggerButton?: string;\n resizeHandle?: string;\n resizeHandleTooltipText?: string;\n }\n\n export interface Labels {\n notifications?: string;\n\n navigation?: string;\n navigationToggle?: string;\n navigationClose?: string;\n\n tools?: string;\n toolsToggle?: string;\n toolsClose?: string;\n\n drawers?: string;\n drawersOverflow?: string;\n drawersOverflowWithBadge?: string;\n }\n\n export interface ChangeDetail {\n open: boolean;\n }\n\n export interface SplitPanelResizeDetail {\n size: number;\n }\n\n export interface SplitPanelPreferences {\n position: 'side' | 'bottom';\n }\n // Duplicated the positions because using this definition in SplitPanelPreferences would display\n // 'AppLayoutProps.SplitPanelPosition' on the API docs instead of the string values.\n export type SplitPanelPosition = 'side' | 'bottom';\n\n export interface DrawerChangeDetail {\n activeDrawerId: string | null;\n }\n}\n\nexport type AppLayoutPropsWithDefaults = SomeRequired<\n Omit<AppLayoutProps, 'headerSelector' | 'footerSelector'>,\n 'contentType' | 'navigationWidth' | 'toolsWidth' | 'minContentWidth' | 'navigationOpen' | 'onNavigationChange'\n> & {\n placement: {\n insetBlockStart: number;\n insetBlockEnd: number;\n insetInlineStart: number;\n insetInlineEnd: number;\n inlineSize: number;\n };\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export var PACKAGE_SOURCE = "components";
|
|
2
|
-
export var PACKAGE_VERSION = "3.0.0 (
|
|
3
|
-
export var GIT_SHA = "
|
|
2
|
+
export var PACKAGE_VERSION = "3.0.0 (7d1f3038)";
|
|
3
|
+
export var GIT_SHA = "7d1f3038";
|
|
4
4
|
export var THEME = "open-source-visual-refresh";
|
|
5
5
|
export var SYSTEM = "core";
|
|
6
6
|
export var ALWAYS_VISUAL_REFRESH = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-column-widths.d.ts","sourceRoot":"","sources":["../../../src/table/use-column-widths.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiE,MAAM,OAAO,CAAC;AAKtF,OAAO,EAAE,gBAAgB,EAAoB,MAAM,uBAAuB,CAAC;AAE3E,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D,EAAE,EAAE,WAAW,CAAC;CACjB;AA8CD,UAAU,aAAa;IACrB,eAAe,CAAC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M,KAAK,IAAI,CAAC;IAChE,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,GAAG,WAAW,KAAK,IAAI,CAAC;CACrF;AAED,QAAA,MAAM,aAAa,8BAKjB,CAAC;AAEH,UAAU,kBAAkB;IAC1B,cAAc,EAAE,SAAS,qBAAqB,EAAE,CAAC;IACjD,gBAAgB,EAAE,OAAO,GAAG,SAAS,CAAC;IACtC,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,wBAAgB,oBAAoB,CAAC,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,kBAAkB,eA0HpH;AAED,wBAAgB,eAAe,kBAE9B"}
|
|
@@ -125,7 +125,9 @@ export function ColumnWidthsProvider({ visibleColumns, resizableColumns, contain
|
|
|
125
125
|
const column = visibleColumns[index];
|
|
126
126
|
if (!(columnWidths === null || columnWidths === void 0 ? void 0 : columnWidths.get(column.id)) && lastVisible.indexOf(column.id) === -1) {
|
|
127
127
|
updated = true;
|
|
128
|
-
|
|
128
|
+
const width = column.width || DEFAULT_COLUMN_WIDTH;
|
|
129
|
+
const minWidth = column.minWidth || width;
|
|
130
|
+
newColumnWidths.set(column.id, Math.max(width, minWidth));
|
|
129
131
|
}
|
|
130
132
|
}
|
|
131
133
|
if (updated) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-column-widths.js","sourceRoot":"","sources":["../../../src/table/use-column-widths.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtF,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,+C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O,EAAE,IAC/G,QAAQ,CACc,CAC1B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,UAAU,CAAC,aAAa,CAAC,CAAC;AACnC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { createContext, useContext, useEffect, useRef, useState } from 'react';\n\nimport { useResizeObserver, useStableCallback } from '@cloudscape-design/component-toolkit/internal';\nimport { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';\n\nimport { ColumnWidthStyle, setElementWidths } from './column-widths-utils';\n\nexport const DEFAULT_COLUMN_WIDTH = 120;\n\nexport interface ColumnWidthDefinition extends ColumnWidthStyle {\n id: PropertyKey;\n}\n\nfunction readWidths(\n getCell: (columnId: PropertyKey) => null | HTMLElement,\n visibleColumns: readonly ColumnWidthDefinition[]\n) {\n const result = new Map<PropertyKey, number>();\n for (let index = 0; index < visibleColumns.length; index++) {\n const column = visibleColumns[index];\n let width = (column.width as number) || 0;\n const minWidth = (column.minWidth as number) || width || DEFAULT_COLUMN_WIDTH;\n if (\n !width && // read width from the DOM if it is missing in the config\n index !== visibleColumns.length - 1 // skip reading for the last column, because it expands to fully fit the container\n ) {\n const colEl = getCell(column.id);\n width = colEl ? getLogicalBoundingClientRect(colEl).inlineSize : DEFAULT_COLUMN_WIDTH;\n }\n result.set(column.id, Math.max(width, minWidth));\n }\n return result;\n}\n\nfunction updateWidths(\n visibleColumns: readonly ColumnWidthDefinition[],\n oldWidths: Map<PropertyKey, number>,\n newWidth: number,\n columnId: PropertyKey\n) {\n const column = visibleColumns.find(column => column.id === columnId);\n let minWidth = DEFAULT_COLUMN_WIDTH;\n if (typeof column?.width === 'number' && column.width < DEFAULT_COLUMN_WIDTH) {\n minWidth = column?.width;\n }\n if (typeof column?.minWidth === 'number') {\n minWidth = column?.minWidth;\n }\n newWidth = Math.max(newWidth, minWidth);\n if (oldWidths.get(columnId) === newWidth) {\n return oldWidths;\n }\n const newWidths = new Map(oldWidths);\n newWidths.set(columnId, newWidth);\n return newWidths;\n}\n\ninterface WidthsContext {\n getColumnStyles(sticky: boolean, columnId: PropertyKey): ColumnWidthStyle;\n columnWidths: Map<PropertyKey, number>;\n updateColumn: (columnId: PropertyKey, newWidth: number) => void;\n setCell: (sticky: boolean, columnId: PropertyKey, node: null | HTMLElement) => void;\n}\n\nconst WidthsContext = createContext<WidthsContext>({\n getColumnStyles: () => ({}),\n columnWidths: new Map(),\n updateColumn: () => {},\n setCell: () => {},\n});\n\ninterface WidthProviderProps {\n visibleColumns: readonly ColumnWidthDefinition[];\n resizableColumns: boolean | undefined;\n containerRef: React.RefObject<HTMLElement>;\n children: React.ReactNode;\n}\n\nexport function ColumnWidthsProvider({ visibleColumns, resizableColumns, containerRef, children }: WidthProviderProps) {\n const visibleColumnsRef = useRef<PropertyKey[] | null>(null);\n const containerWidthRef = useRef(0);\n const [columnWidths, setColumnWidths] = useState<null | Map<PropertyKey, number>>(null);\n\n const cellsRef = useRef(new Map<PropertyKey, HTMLElement>());\n const stickyCellsRef = useRef(new Map<PropertyKey, HTMLElement>());\n const getCell = (columnId: PropertyKey): null | HTMLElement => cellsRef.current.get(columnId) ?? null;\n const setCell = (sticky: boolean, columnId: PropertyKey, node: null | HTMLElement) => {\n const ref = sticky ? stickyCellsRef : cellsRef;\n if (node) {\n ref.current.set(columnId, node);\n } else {\n ref.current.delete(columnId);\n }\n };\n\n const getColumnStyles = (sticky: boolean, columnId: PropertyKey): ColumnWidthStyle => {\n const column = visibleColumns.find(column => column.id === columnId);\n if (!column) {\n return {};\n }\n\n if (sticky) {\n return {\n width:\n cellsRef.current.get(column.id)?.getBoundingClientRect().width ||\n (columnWidths?.get(column.id) ?? column.width),\n };\n }\n\n if (resizableColumns && columnWidths) {\n const isLastColumn = column.id === visibleColumns[visibleColumns.length - 1]?.id;\n const totalWidth = visibleColumns.reduce(\n (sum, { id }) => sum + (columnWidths.get(id) || DEFAULT_COLUMN_WIDTH),\n 0\n );\n if (isLastColumn && containerWidthRef.current > totalWidth) {\n return { width: 'auto', minWidth: column?.minWidth };\n } else {\n return { width: columnWidths.get(column.id), minWidth: column?.minWidth };\n }\n }\n return {\n width: column.width,\n minWidth: column.minWidth,\n maxWidth: !resizableColumns ? column.maxWidth : undefined,\n };\n };\n\n // Imperatively sets width style for a cell avoiding React state.\n // This allows setting the style as soon container's size change is observed.\n const updateColumnWidths = useStableCallback(() => {\n for (const { id } of visibleColumns) {\n const element = cellsRef.current.get(id);\n if (element) {\n setElementWidths(element, getColumnStyles(false, id));\n }\n }\n // Sticky column widths must be synchronized once all real column widths are assigned.\n for (const { id } of visibleColumns) {\n const element = stickyCellsRef.current.get(id);\n if (element) {\n setElementWidths(element, getColumnStyles(true, id));\n }\n }\n });\n\n // Observes container size and requests an update to the last cell width as it depends on the container's width.\n useResizeObserver(containerRef, ({ contentBoxWidth: containerWidth }) => {\n containerWidthRef.current = containerWidth;\n requestAnimationFrame(() => updateColumnWidths());\n });\n\n // The widths of the dynamically added columns (after the first render) if not set explicitly\n // will default to the DEFAULT_COLUMN_WIDTH.\n useEffect(() => {\n updateColumnWidths();\n\n if (!resizableColumns) {\n return;\n }\n let updated = false;\n const newColumnWidths = new Map(columnWidths);\n const lastVisible = visibleColumnsRef.current;\n if (lastVisible) {\n for (let index = 0; index < visibleColumns.length; index++) {\n const column = visibleColumns[index];\n if (!columnWidths?.get(column.id) && lastVisible.indexOf(column.id) === -1) {\n updated = true;\n newColumnWidths.set(column.id, (column.width as number) || DEFAULT_COLUMN_WIDTH);\n }\n }\n if (updated) {\n setColumnWidths(newColumnWidths);\n }\n }\n visibleColumnsRef.current = visibleColumns.map(column => column.id);\n }, [columnWidths, resizableColumns, visibleColumns, updateColumnWidths]);\n\n // Read the actual column widths after the first render to employ the browser defaults for\n // those columns without explicit width.\n useEffect(() => {\n if (!resizableColumns) {\n return;\n }\n setColumnWidths(() => readWidths(getCell, visibleColumns));\n // This code is intended to run only at the first render and should not re-run when table props change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n function updateColumn(columnId: PropertyKey, newWidth: number) {\n setColumnWidths(columnWidths => updateWidths(visibleColumns, columnWidths ?? new Map(), newWidth, columnId));\n }\n\n return (\n <WidthsContext.Provider value={{ getColumnStyles, columnWidths: columnWidths ?? new Map(), updateColumn, setCell }}>\n {children}\n </WidthsContext.Provider>\n );\n}\n\nexport function useColumnWidths() {\n return useContext(WidthsContext);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"use-column-widths.js","sourceRoot":"","sources":["../../../src/table/use-column-widths.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtF,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AACrG,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAE7F,OAAO,EAAoB,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE3E,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAMxC,SAAS,UAAU,CACjB,OAAsD,EACtD,cAAgD;IAEhD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC9C,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QAC3D,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,KAAK,GAAI,MAAM,CAAC,KAAgB,IAAI,CAAC,CAAC;QAC1C,MAAM,QAAQ,GAAI,MAAM,CAAC,QAAmB,IAAI,KAAK,IAAI,oBAAoB,CAAC;QAC9E,IACE,CAAC,KAAK,IAAI,yDAAyD;YACnE,KAAK,KAAK,cAAc,CAAC,MAAM,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,CAAC,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAEzE,0FAA0F;IAC1F,wCAAwC;IACxC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,OAAO;QACT,CAAC;QACD,eAAe,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;QAC3D,sGAAsG;QACtG,uDAAuD;IACzD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,SAAS,YAAY,CAAC,QAAqB,EAAE,QAAgB;QAC3D,eAAe,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,cAAc,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,IAAI,GAAG,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC/G,CAAC;IAED,OAAO,CACL,oBAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,IAAI,GAAG,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,IAC/G,QAAQ,CACc,CAC1B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,UAAU,CAAC,aAAa,CAAC,CAAC;AACnC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { createContext, useContext, useEffect, useRef, useState } from 'react';\n\nimport { useResizeObserver, useStableCallback } from '@cloudscape-design/component-toolkit/internal';\nimport { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';\n\nimport { ColumnWidthStyle, setElementWidths } from './column-widths-utils';\n\nexport const DEFAULT_COLUMN_WIDTH = 120;\n\nexport interface ColumnWidthDefinition extends ColumnWidthStyle {\n id: PropertyKey;\n}\n\nfunction readWidths(\n getCell: (columnId: PropertyKey) => null | HTMLElement,\n visibleColumns: readonly ColumnWidthDefinition[]\n) {\n const result = new Map<PropertyKey, number>();\n for (let index = 0; index < visibleColumns.length; index++) {\n const column = visibleColumns[index];\n let width = (column.width as number) || 0;\n const minWidth = (column.minWidth as number) || width || DEFAULT_COLUMN_WIDTH;\n if (\n !width && // read width from the DOM if it is missing in the config\n index !== visibleColumns.length - 1 // skip reading for the last column, because it expands to fully fit the container\n ) {\n const colEl = getCell(column.id);\n width = colEl ? getLogicalBoundingClientRect(colEl).inlineSize : DEFAULT_COLUMN_WIDTH;\n }\n result.set(column.id, Math.max(width, minWidth));\n }\n return result;\n}\n\nfunction updateWidths(\n visibleColumns: readonly ColumnWidthDefinition[],\n oldWidths: Map<PropertyKey, number>,\n newWidth: number,\n columnId: PropertyKey\n) {\n const column = visibleColumns.find(column => column.id === columnId);\n let minWidth = DEFAULT_COLUMN_WIDTH;\n if (typeof column?.width === 'number' && column.width < DEFAULT_COLUMN_WIDTH) {\n minWidth = column?.width;\n }\n if (typeof column?.minWidth === 'number') {\n minWidth = column?.minWidth;\n }\n newWidth = Math.max(newWidth, minWidth);\n if (oldWidths.get(columnId) === newWidth) {\n return oldWidths;\n }\n const newWidths = new Map(oldWidths);\n newWidths.set(columnId, newWidth);\n return newWidths;\n}\n\ninterface WidthsContext {\n getColumnStyles(sticky: boolean, columnId: PropertyKey): ColumnWidthStyle;\n columnWidths: Map<PropertyKey, number>;\n updateColumn: (columnId: PropertyKey, newWidth: number) => void;\n setCell: (sticky: boolean, columnId: PropertyKey, node: null | HTMLElement) => void;\n}\n\nconst WidthsContext = createContext<WidthsContext>({\n getColumnStyles: () => ({}),\n columnWidths: new Map(),\n updateColumn: () => {},\n setCell: () => {},\n});\n\ninterface WidthProviderProps {\n visibleColumns: readonly ColumnWidthDefinition[];\n resizableColumns: boolean | undefined;\n containerRef: React.RefObject<HTMLElement>;\n children: React.ReactNode;\n}\n\nexport function ColumnWidthsProvider({ visibleColumns, resizableColumns, containerRef, children }: WidthProviderProps) {\n const visibleColumnsRef = useRef<PropertyKey[] | null>(null);\n const containerWidthRef = useRef(0);\n const [columnWidths, setColumnWidths] = useState<null | Map<PropertyKey, number>>(null);\n\n const cellsRef = useRef(new Map<PropertyKey, HTMLElement>());\n const stickyCellsRef = useRef(new Map<PropertyKey, HTMLElement>());\n const getCell = (columnId: PropertyKey): null | HTMLElement => cellsRef.current.get(columnId) ?? null;\n const setCell = (sticky: boolean, columnId: PropertyKey, node: null | HTMLElement) => {\n const ref = sticky ? stickyCellsRef : cellsRef;\n if (node) {\n ref.current.set(columnId, node);\n } else {\n ref.current.delete(columnId);\n }\n };\n\n const getColumnStyles = (sticky: boolean, columnId: PropertyKey): ColumnWidthStyle => {\n const column = visibleColumns.find(column => column.id === columnId);\n if (!column) {\n return {};\n }\n\n if (sticky) {\n return {\n width:\n cellsRef.current.get(column.id)?.getBoundingClientRect().width ||\n (columnWidths?.get(column.id) ?? column.width),\n };\n }\n\n if (resizableColumns && columnWidths) {\n const isLastColumn = column.id === visibleColumns[visibleColumns.length - 1]?.id;\n const totalWidth = visibleColumns.reduce(\n (sum, { id }) => sum + (columnWidths.get(id) || DEFAULT_COLUMN_WIDTH),\n 0\n );\n if (isLastColumn && containerWidthRef.current > totalWidth) {\n return { width: 'auto', minWidth: column?.minWidth };\n } else {\n return { width: columnWidths.get(column.id), minWidth: column?.minWidth };\n }\n }\n return {\n width: column.width,\n minWidth: column.minWidth,\n maxWidth: !resizableColumns ? column.maxWidth : undefined,\n };\n };\n\n // Imperatively sets width style for a cell avoiding React state.\n // This allows setting the style as soon container's size change is observed.\n const updateColumnWidths = useStableCallback(() => {\n for (const { id } of visibleColumns) {\n const element = cellsRef.current.get(id);\n if (element) {\n setElementWidths(element, getColumnStyles(false, id));\n }\n }\n // Sticky column widths must be synchronized once all real column widths are assigned.\n for (const { id } of visibleColumns) {\n const element = stickyCellsRef.current.get(id);\n if (element) {\n setElementWidths(element, getColumnStyles(true, id));\n }\n }\n });\n\n // Observes container size and requests an update to the last cell width as it depends on the container's width.\n useResizeObserver(containerRef, ({ contentBoxWidth: containerWidth }) => {\n containerWidthRef.current = containerWidth;\n requestAnimationFrame(() => updateColumnWidths());\n });\n\n // The widths of the dynamically added columns (after the first render) if not set explicitly\n // will default to the DEFAULT_COLUMN_WIDTH.\n useEffect(() => {\n updateColumnWidths();\n\n if (!resizableColumns) {\n return;\n }\n let updated = false;\n const newColumnWidths = new Map(columnWidths);\n const lastVisible = visibleColumnsRef.current;\n if (lastVisible) {\n for (let index = 0; index < visibleColumns.length; index++) {\n const column = visibleColumns[index];\n if (!columnWidths?.get(column.id) && lastVisible.indexOf(column.id) === -1) {\n updated = true;\n const width = (column.width as number) || DEFAULT_COLUMN_WIDTH;\n const minWidth = (column.minWidth as number) || width;\n newColumnWidths.set(column.id, Math.max(width, minWidth));\n }\n }\n if (updated) {\n setColumnWidths(newColumnWidths);\n }\n }\n visibleColumnsRef.current = visibleColumns.map(column => column.id);\n }, [columnWidths, resizableColumns, visibleColumns, updateColumnWidths]);\n\n // Read the actual column widths after the first render to employ the browser defaults for\n // those columns without explicit width.\n useEffect(() => {\n if (!resizableColumns) {\n return;\n }\n setColumnWidths(() => readWidths(getCell, visibleColumns));\n // This code is intended to run only at the first render and should not re-run when table props change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n function updateColumn(columnId: PropertyKey, newWidth: number) {\n setColumnWidths(columnWidths => updateWidths(visibleColumns, columnWidths ?? new Map(), newWidth, columnId));\n }\n\n return (\n <WidthsContext.Provider value={{ getColumnStyles, columnWidths: columnWidths ?? new Map(), updateColumn, setCell }}>\n {children}\n </WidthsContext.Provider>\n );\n}\n\nexport function useColumnWidths() {\n return useContext(WidthsContext);\n}\n"]}
|