@cloudscape-design/components 3.0.272 → 3.0.274
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/expandable-section/styles.css.js +24 -24
- package/expandable-section/styles.scoped.css +47 -51
- package/expandable-section/styles.selectors.js +24 -24
- package/internal/environment.js +1 -1
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
- package/popover/internal.js +9 -10
- package/popover/internal.js.map +1 -1
- package/property-filter/controller.d.ts +8 -16
- package/property-filter/controller.d.ts.map +1 -1
- package/property-filter/controller.js +17 -48
- package/property-filter/controller.js.map +1 -1
- package/property-filter/index.d.ts.map +1 -1
- package/property-filter/index.js +38 -14
- package/property-filter/index.js.map +1 -1
- package/property-filter/interfaces.d.ts +18 -2
- package/property-filter/interfaces.d.ts.map +1 -1
- package/property-filter/interfaces.js.map +1 -1
- package/property-filter/property-editor.d.ts +4 -4
- package/property-filter/property-editor.d.ts.map +1 -1
- package/property-filter/property-editor.js +1 -1
- package/property-filter/property-editor.js.map +1 -1
- package/property-filter/token-editor.d.ts +3 -3
- package/property-filter/token-editor.d.ts.map +1 -1
- package/property-filter/token-editor.js +11 -11
- package/property-filter/token-editor.js.map +1 -1
- package/property-filter/token.d.ts +3 -3
- package/property-filter/token.d.ts.map +1 -1
- package/property-filter/token.js +1 -1
- package/property-filter/token.js.map +1 -1
- package/property-filter/use-load-items.d.ts +1 -1
- package/property-filter/use-load-items.js +1 -1
- package/property-filter/use-load-items.js.map +1 -1
- package/property-filter/utils.d.ts +10 -3
- package/property-filter/utils.d.ts.map +1 -1
- package/property-filter/utils.js +12 -0
- package/property-filter/utils.js.map +1 -1
- package/table/use-sticky-columns.d.ts +5 -4
- package/table/use-sticky-columns.d.ts.map +1 -1
- package/table/use-sticky-columns.js +38 -24
- package/table/use-sticky-columns.js.map +1 -1
- package/top-navigation/interfaces.d.ts +1 -1
- package/top-navigation/interfaces.js.map +1 -1
|
@@ -46,14 +46,17 @@ export function useStickyColumns({ visibleColumns, stickyColumnsFirst, stickyCol
|
|
|
46
46
|
if (!hasStickyColumns) {
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
-
const selector = (state) => state.
|
|
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.
|
|
53
|
-
wrapperRef.current.style.scrollPaddingRight = state.
|
|
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
|
|
121
|
-
cellElement.style.right = (state === null || state === void 0 ? void 0 : state.offset.right) !== undefined ? `${state
|
|
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: {},
|
|
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 &&
|
|
183
|
+
padLeft: isFirstColumn && this.padLeft,
|
|
174
184
|
lastLeft: this.isStuckToTheLeft && lastLeftStickyColumnIndex === index,
|
|
175
185
|
lastRight: this.isStuckToTheRight && lastRightStickyColumnIndex === index,
|
|
176
|
-
offset:
|
|
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
|
-
|
|
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 @@
|
|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CAAC;YACzB,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAC9B,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;gBACd,SAAS,EAAE,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC;gBACzC,aAAa,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,eAAe,EAAE,KAAK,EAAE,IAAI,CAAC,gBAAgB,EAAE;aAC5E,CAAC,CAAC,CAAC;SACL;IACH,CAAC;IAEO,YAAY,CAAC,KAA4B;QAC/C,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;QACnD,MAAM,kBAAkB,GAAG,KAAK,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,C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,CAAC;gBACzC,YAAY,EAAE,EAAE,iBAAiB,EAAE,IAAI,CAAC,eAAe,EAAE,kBAAkB,EAAE,IAAI,CAAC,gBAAgB,EAAE;aACrG,CAAC,CAAC,CAAC;SACL;IACH,CAAC;IAEO,YAAY,CAAC,KAA4B;QAC/C,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;QACnD,MAAM,kBAAkB,GAAG,KAAK,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;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"]}
|
|
@@ -9,7 +9,7 @@ export interface TopNavigationProps extends BaseComponentProps {
|
|
|
9
9
|
* Properties describing the product identity. They are as follows:
|
|
10
10
|
*
|
|
11
11
|
* * `title` (string) - Specifies the title text.
|
|
12
|
-
* * `logo` ({ src: string, alt: string }) - Specifies the logo for the product.
|
|
12
|
+
* * `logo` ({ src: string, alt: string }) - Specifies the logo for the product. Use fixed width and height for SVG images to ensure proper rendering.
|
|
13
13
|
* * `href` (string) - Specifies the `href` that the header links to.
|
|
14
14
|
* * `onFollow` (() => void) - Specifies the event handler called when the identity is clicked without any modifier keys.
|
|
15
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["top-navigation/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { CancelableEventHandler } from '../internal/events';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { IconProps } from '../icon/interfaces';\nimport { ButtonDropdownProps } from '../button-dropdown/interfaces';\nimport { ButtonProps } from '../button/interfaces';\n\nexport interface TopNavigationProps extends BaseComponentProps {\n /**\n * Properties describing the product identity. They are as follows:\n *\n * * `title` (string) - Specifies the title text.\n * * `logo` ({ src: string, alt: string }) - Specifies the logo for the product.\n * * `href` (string) - Specifies the `href` that the header links to.\n * * `onFollow` (() => void) - Specifies the event handler called when the identity is clicked without any modifier keys.\n */\n identity: TopNavigationProps.Identity;\n\n /**\n * Use with an input or autosuggest control for a global search query.\n */\n search?: React.ReactNode;\n\n /**\n * A list of utility navigation elements.\n * The supported utility types are: `button` and `menu-dropdown`.\n *\n * The following properties are supported across all utility types:\n *\n * * `type` (string) - The type of the utility. Can be `button` or `menu-dropdown`.\n * * `text` (string) - Specifies the text shown in the top navigation or the title inside the dropdown if no explicit `title` property is set.\n * * `title` (string) - The title displayed inside the dropdown.\n * * `iconName` (string) - The name of an existing icon to display next to the utility.\n * * `iconUrl` (string) - Specifies the URL of a custom icon. Use this property if the icon you want isn't available.\n * * `iconAlt` (string) - Specifies alternate text for a custom icon provided using `iconUrl`. We recommend that you provide this for accessibility.\n * * `iconSvg` (string) - Specifies the SVG of a custom icon.\n * * `ariaLabel` (string) - Adds `aria-label` to the button or dropdown trigger. This is recommended for accessibility if a text is not provided.\n * * `badge` (boolean) - Adds a badge to the corner of the icon to indicate a state change. For example: Unread notifications.\n * * `disableTextCollapse` (boolean) - Prevents the utility text from being hidden on smaller screens.\n * * `disableUtilityCollapse` (boolean) - Prevents the utility from being moved to an overflow menu on smaller screens.\n *\n * ### button\n *\n * * `variant` ('primary-button' | 'link') - The visual appearance of the button. The default value is 'link'.\n * * `href` (string) - Specifies the `href` for a link styled as a button.\n * * `target` (string) - Specifies where to open the linked URL (for example, to open in a new browser window or tab use `_blank`). This property only applies when an `href` is provided.\n * * `rel` (string) - Adds a `rel` attribute to the link. By default, the component sets the `rel` attribute to \"noopener noreferrer\" when `target` is `\"_blank\"`. If the `rel` property is provided, it overrides the default behavior.\n * * `external` (boolean) - Marks the link as external by adding an icon after the text. When clicked, the link opens in a new tab.\n * * `externalIconAriaLabel` (string) - Adds an `aria-label` for the external icon.\n * * `onClick` (() => void) - Specifies the event handler called when the utility is clicked.\n *\n * ### menu-dropdown\n *\n * * `description` (string) - The description displayed inside the dropdown.\n * * `items` (ButtonDropdownProps.Items) - An array of dropdown items. This follows the same structure as the `items` property of the [button dropdown component](/components/button-dropdown).\n * * `onItemClick` (NonCancelableEventHandler<ButtonDropdownProps.ItemClickDetails>) - Specifies the event handler called when a dropdown item is selected.\n */\n utilities?: ReadonlyArray<TopNavigationProps.Utility>;\n\n /**\n * An object containing all the localized strings required by the component.\n */\n i18nStrings: TopNavigationProps.I18nStrings;\n}\n\nexport namespace TopNavigationProps {\n export interface Identity {\n title?: string;\n logo?: Logo;\n href: string;\n onFollow?: CancelableEventHandler;\n }\n\n export interface Logo {\n src: string;\n alt?: string;\n }\n\n interface BaseUtility {\n text?: string;\n title?: string;\n iconName?: IconProps.Name;\n iconUrl?: string;\n iconAlt?: string;\n iconSvg?: React.ReactNode;\n ariaLabel?: string;\n\n badge?: boolean;\n disableUtilityCollapse?: boolean;\n disableTextCollapse?: boolean;\n }\n\n export interface MenuDropdownUtility extends BaseUtility {\n type: 'menu-dropdown';\n description?: string;\n items: ButtonDropdownProps.Items;\n onItemClick?: CancelableEventHandler<ButtonDropdownProps.ItemClickDetails>;\n onItemFollow?: CancelableEventHandler<ButtonDropdownProps.ItemClickDetails>;\n }\n\n export interface ButtonUtility extends BaseUtility {\n type: 'button';\n variant?: 'primary-button' | 'link';\n onClick?: CancelableEventHandler;\n onFollow?: CancelableEventHandler<ButtonProps.FollowDetail>;\n href?: string;\n target?: string;\n rel?: string;\n external?: boolean;\n externalIconAriaLabel?: string;\n }\n\n export type Utility = MenuDropdownUtility | ButtonUtility;\n\n export interface I18nStrings {\n searchIconAriaLabel?: string;\n searchDismissIconAriaLabel?: string;\n overflowMenuDismissIconAriaLabel?: string;\n overflowMenuBackIconAriaLabel?: string;\n overflowMenuTriggerText: string;\n overflowMenuTitleText: string;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["top-navigation/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { CancelableEventHandler } from '../internal/events';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { IconProps } from '../icon/interfaces';\nimport { ButtonDropdownProps } from '../button-dropdown/interfaces';\nimport { ButtonProps } from '../button/interfaces';\n\nexport interface TopNavigationProps extends BaseComponentProps {\n /**\n * Properties describing the product identity. They are as follows:\n *\n * * `title` (string) - Specifies the title text.\n * * `logo` ({ src: string, alt: string }) - Specifies the logo for the product. Use fixed width and height for SVG images to ensure proper rendering.\n * * `href` (string) - Specifies the `href` that the header links to.\n * * `onFollow` (() => void) - Specifies the event handler called when the identity is clicked without any modifier keys.\n */\n identity: TopNavigationProps.Identity;\n\n /**\n * Use with an input or autosuggest control for a global search query.\n */\n search?: React.ReactNode;\n\n /**\n * A list of utility navigation elements.\n * The supported utility types are: `button` and `menu-dropdown`.\n *\n * The following properties are supported across all utility types:\n *\n * * `type` (string) - The type of the utility. Can be `button` or `menu-dropdown`.\n * * `text` (string) - Specifies the text shown in the top navigation or the title inside the dropdown if no explicit `title` property is set.\n * * `title` (string) - The title displayed inside the dropdown.\n * * `iconName` (string) - The name of an existing icon to display next to the utility.\n * * `iconUrl` (string) - Specifies the URL of a custom icon. Use this property if the icon you want isn't available.\n * * `iconAlt` (string) - Specifies alternate text for a custom icon provided using `iconUrl`. We recommend that you provide this for accessibility.\n * * `iconSvg` (string) - Specifies the SVG of a custom icon.\n * * `ariaLabel` (string) - Adds `aria-label` to the button or dropdown trigger. This is recommended for accessibility if a text is not provided.\n * * `badge` (boolean) - Adds a badge to the corner of the icon to indicate a state change. For example: Unread notifications.\n * * `disableTextCollapse` (boolean) - Prevents the utility text from being hidden on smaller screens.\n * * `disableUtilityCollapse` (boolean) - Prevents the utility from being moved to an overflow menu on smaller screens.\n *\n * ### button\n *\n * * `variant` ('primary-button' | 'link') - The visual appearance of the button. The default value is 'link'.\n * * `href` (string) - Specifies the `href` for a link styled as a button.\n * * `target` (string) - Specifies where to open the linked URL (for example, to open in a new browser window or tab use `_blank`). This property only applies when an `href` is provided.\n * * `rel` (string) - Adds a `rel` attribute to the link. By default, the component sets the `rel` attribute to \"noopener noreferrer\" when `target` is `\"_blank\"`. If the `rel` property is provided, it overrides the default behavior.\n * * `external` (boolean) - Marks the link as external by adding an icon after the text. When clicked, the link opens in a new tab.\n * * `externalIconAriaLabel` (string) - Adds an `aria-label` for the external icon.\n * * `onClick` (() => void) - Specifies the event handler called when the utility is clicked.\n *\n * ### menu-dropdown\n *\n * * `description` (string) - The description displayed inside the dropdown.\n * * `items` (ButtonDropdownProps.Items) - An array of dropdown items. This follows the same structure as the `items` property of the [button dropdown component](/components/button-dropdown).\n * * `onItemClick` (NonCancelableEventHandler<ButtonDropdownProps.ItemClickDetails>) - Specifies the event handler called when a dropdown item is selected.\n */\n utilities?: ReadonlyArray<TopNavigationProps.Utility>;\n\n /**\n * An object containing all the localized strings required by the component.\n */\n i18nStrings: TopNavigationProps.I18nStrings;\n}\n\nexport namespace TopNavigationProps {\n export interface Identity {\n title?: string;\n logo?: Logo;\n href: string;\n onFollow?: CancelableEventHandler;\n }\n\n export interface Logo {\n src: string;\n alt?: string;\n }\n\n interface BaseUtility {\n text?: string;\n title?: string;\n iconName?: IconProps.Name;\n iconUrl?: string;\n iconAlt?: string;\n iconSvg?: React.ReactNode;\n ariaLabel?: string;\n\n badge?: boolean;\n disableUtilityCollapse?: boolean;\n disableTextCollapse?: boolean;\n }\n\n export interface MenuDropdownUtility extends BaseUtility {\n type: 'menu-dropdown';\n description?: string;\n items: ButtonDropdownProps.Items;\n onItemClick?: CancelableEventHandler<ButtonDropdownProps.ItemClickDetails>;\n onItemFollow?: CancelableEventHandler<ButtonDropdownProps.ItemClickDetails>;\n }\n\n export interface ButtonUtility extends BaseUtility {\n type: 'button';\n variant?: 'primary-button' | 'link';\n onClick?: CancelableEventHandler;\n onFollow?: CancelableEventHandler<ButtonProps.FollowDetail>;\n href?: string;\n target?: string;\n rel?: string;\n external?: boolean;\n externalIconAriaLabel?: string;\n }\n\n export type Utility = MenuDropdownUtility | ButtonUtility;\n\n export interface I18nStrings {\n searchIconAriaLabel?: string;\n searchDismissIconAriaLabel?: string;\n overflowMenuDismissIconAriaLabel?: string;\n overflowMenuBackIconAriaLabel?: string;\n overflowMenuTriggerText: string;\n overflowMenuTitleText: string;\n }\n}\n"]}
|