@cloudscape-design/components 3.0.90 → 3.0.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/code-editor/index.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AA4B/C,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,KAAK,EAAE,eAAe,eAkTxD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/code-editor/index.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AA4B/C,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,KAAK,EAAE,eAAe,eAmTxD"}
@@ -206,7 +206,7 @@ export default function CodeEditor(props) {
206
206
  React.createElement("div", { role: "group", "aria-label": i18nStrings.statusBarGroupAriaLabel },
207
207
  React.createElement(StatusBar, { languageLabel: languageLabel, cursorPosition: i18nStrings.cursorPosition(cursorPosition.row + 1, cursorPosition.column + 1), errorCount: errorCount, warningCount: warningCount, paneStatus: paneStatus, onErrorPaneToggle: onErrorPaneToggle, onWarningPaneToggle: onWarningPaneToggle, onTabFocus: onTabFocus, onTabBlur: onTabBlur, errorsTabRef: errorsTabRef, warningsTabRef: warningsTabRef, i18nStrings: i18nStrings, isTabFocused: isTabFocused, paneId: paneId, onPreferencesOpen: onPreferencesOpen, isRefresh: isRefresh }),
208
208
  React.createElement(Pane, { id: paneId, visible: paneStatus !== 'hidden', annotations: currentAnnotations, highlighted: highlightedAnnotation, onAnnotationClick: onAnnotationClick, onAnnotationClear: onAnnotationClear, onClose: onPaneClose, onAllowlist: shouldHandleFocus, cursorPositionLabel: i18nStrings.cursorPosition, closeButtonAriaLabel: i18nStrings.paneCloseButtonAriaLabel })),
209
- isPreferencesModalVisible && (React.createElement(PreferencesModal, { onConfirm: onPreferencesConfirm, onDismiss: onPreferencesDismiss, preferences: props.preferences, defaultTheme: defaultTheme, i18nStrings: {
209
+ isPreferencesModalVisible && (React.createElement(PreferencesModal, { onConfirm: onPreferencesConfirm, onDismiss: onPreferencesDismiss, themes: props.themes, preferences: props.preferences, defaultTheme: defaultTheme, i18nStrings: {
210
210
  header: i18nStrings.preferencesModalHeader,
211
211
  cancel: i18nStrings.preferencesModalCancel,
212
212
  confirm: i18nStrings.preferencesModalConfirm,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/code-editor/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjF,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EACL,gBAAgB,EAChB,WAAW,EAEX,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,GAChB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,OAAO,MAAM,kBA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AAC,sBAAsB;oBAC1C,MAAM,EAAE,WAAW,CAAC,sBAAsB;oBAC1C,OAAO,EAAE,WAAW,CAAC,uBAAuB;oBAC5C,SAAS,EAAE,WAAW,CAAC,yBAAyB;oBAChD,KAAK,EAAE,WAAW,CAAC,qBAAqB;oBACxC,WAAW,EAAE,WAAW,CAAC,2BAA2B;oBACpD,UAAU,EAAE,WAAW,CAAC,0BAA0B;iBACnD,GACD,CACH,CACA,CACJ,CACG,CACP,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { Ace } from 'ace-builds';\nimport clsx from 'clsx';\nimport { ResizableBox } from 'react-resizable';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { KeyCode } from '../internal/keycode';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { CodeEditorProps } from './interfaces';\nimport { Pane } from './pane';\nimport { useChangeEffect } from './listeners';\nimport {\n getDefaultConfig,\n getAceTheme,\n PaneStatus,\n getLanguageLabel,\n DEFAULT_DARK_THEME,\n DEFAULT_LIGHT_THEME,\n getDefaultTheme,\n} from './util';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { setupEditor } from './setup-editor';\nimport handler from './resize-handler';\nimport PreferencesModal from './preferences-modal';\nimport LoadingScreen from './loading-screen';\nimport ErrorScreen from './error-screen';\n\nimport styles from './styles.css.js';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { useContainerQuery } from '../internal/hooks/container-queries/use-container-query';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useCurrentMode } from '../internal/hooks/use-visual-mode';\nimport { StatusBar } from './status-bar';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { useControllable } from '../internal/hooks/use-controllable';\nexport { CodeEditorProps };\n\nexport default function CodeEditor(props: CodeEditorProps) {\n const { __internalRootRef } = useBaseComponent('CodeEditor');\n const { controlId, ariaLabelledby, ariaDescribedby } = useFormFieldContext(props);\n const { ace, value, language, i18nStrings, editorContentHeight, onEditorContentResize, ...rest } = props;\n const [editorHeight = 480, setEditorHeight] = useControllable(editorContentHeight, onEditorContentResize, 480, {\n componentName: 'code-editor',\n changeHandler: 'onEditorContentResize',\n controlledProp: 'editorContentHeight',\n });\n const baseProps = getBaseProps(rest);\n\n const [editor, setEditor] = useState<Ace.Editor>();\n const mode = useCurrentMode(__internalRootRef);\n const defaultTheme = mode === 'dark' ? DEFAULT_DARK_THEME : DEFAULT_LIGHT_THEME;\n\n const editorRef = useCallback(\n (elem: HTMLDivElement) => {\n if (!ace || !elem) {\n return;\n }\n\n const config = getDefaultConfig();\n setEditor(\n ace.edit(elem, {\n ...config,\n theme: getAceTheme(getDefaultTheme(elem)),\n })\n );\n },\n [ace]\n ); // loads as soon as ace lib is available\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n const { textarea } = editor.renderer as unknown as { textarea: HTMLTextAreaElement };\n if (!textarea) {\n return;\n }\n const updateAttribute = (attribute: string, value: string | undefined) =>\n value ? textarea.setAttribute(attribute, value) : textarea.removeAttribute(attribute);\n updateAttribute('id', controlId);\n updateAttribute('aria-labelledby', ariaLabelledby);\n updateAttribute('aria-describedby', ariaDescribedby);\n }, [ariaDescribedby, ariaLabelledby, controlId, editor]);\n\n const [paneStatus, setPaneStatus] = useState<PaneStatus>('hidden');\n const [annotations, setAnnotations] = useState<Ace.Annotation[]>([]);\n const [highlightedAnnotation, setHighlightedAnnotation] = useState<Ace.Annotation>();\n const [languageLabel, setLanguageLabel] = useState<string>('');\n const [cursorPosition, setCursorPosition] = useState<Ace.Point>({ row: 0, column: 0 });\n const [isTabFocused, setTabFocused] = useState<boolean>(false);\n\n const errorsTabRef = useRef<HTMLButtonElement>(null);\n const warningsTabRef = useRef<HTMLButtonElement>(null);\n\n const [codeEditorWidth, codeEditorMeasureRef] = useContainerQuery(rect => rect.width);\n const mergedRef = useMergeRefs(codeEditorMeasureRef, __internalRootRef);\n\n const isRefresh = useVisualRefresh();\n\n useEffect(() => {\n editor?.resize();\n }, [editor, editorContentHeight, codeEditorWidth]);\n\n const paneId = useUniqueId('code-editor-pane');\n\n useEffect(() => {\n if (!ace || !editor) {\n return;\n }\n\n setupEditor(ace, editor, setAnnotations, setCursorPosition, setHighlightedAnnotation, setPaneStatus);\n\n return () => {\n editor?.destroy();\n }; // TODO profile/monitor this\n }, [ace, editor, __internalRootRef]);\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n if (value === editor.getValue()) {\n return;\n }\n // TODO maintain cursor position?\n const pos = editor.session.selection.toJSON();\n editor.setValue(value, -1);\n editor.session.selection.fromJSON(pos);\n }, [editor, value]);\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n editor.session.setMode(`ace/mode/${language}`);\n\n setLanguageLabel(getLanguageLabel(language));\n }, [editor, language]);\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n\n const theme: CodeEditorProps.Theme = props.preferences?.theme ?? defaultTheme;\n\n editor.setTheme(getAceTheme(theme));\n\n editor.session.setUseWrapMode(props.preferences?.wrapLines ?? true);\n }, [editor, defaultTheme, props.preferences]);\n\n // listeners\n useChangeEffect(editor, props.onChange, props.onDelayedChange);\n // TODO implement other listeners\n\n // Hide error panel when there are no errors to show.\n useEffect(() => {\n if (annotations.length === 0) {\n setPaneStatus('hidden');\n }\n\n if (props.onValidate) {\n fireNonCancelableEvent(props.onValidate, { annotations });\n }\n }, [annotations, props.onValidate]);\n\n const errorCount = annotations.filter(a => a.type === 'error').length;\n const warningCount = annotations.filter(a => a.type === 'warning').length;\n const currentAnnotations = useMemo(() => annotations.filter(a => a.type === paneStatus), [annotations, paneStatus]);\n\n /*\n * Callbacks\n */\n\n const onEditorKeydown = useCallback(\n (e: React.KeyboardEvent) => {\n if (editor && e.target === editor.container && e.keyCode === KeyCode.enter) {\n e.stopPropagation();\n e.preventDefault();\n editor.focus();\n }\n },\n [editor]\n );\n\n const onTabFocus = useCallback(() => setTabFocused(true), []);\n const onTabBlur = useCallback(() => setTabFocused(false), []);\n\n const onResize = useCallback(() => {\n editor?.resize();\n }, [editor]);\n\n const onErrorPaneToggle = useCallback(() => {\n setPaneStatus(paneStatus !== 'error' ? 'error' : 'hidden');\n }, [paneStatus]);\n\n const onWarningPaneToggle = useCallback(() => {\n setPaneStatus(paneStatus !== 'warning' ? 'warning' : 'hidden');\n }, [paneStatus]);\n\n const onPaneClose = useCallback(() => {\n if (paneStatus === 'error' && errorsTabRef.current) {\n errorsTabRef.current.focus();\n }\n if (paneStatus === 'warning' && warningsTabRef.current) {\n warningsTabRef.current.focus();\n }\n setPaneStatus('hidden');\n }, [paneStatus]);\n\n const onAnnotationClick = ({ row = 0, column = 0 }: Ace.Annotation) => {\n if (!editor) {\n return;\n }\n editor.focus();\n editor.gotoLine(row + 1, column, false);\n setHighlightedAnnotation(undefined);\n };\n\n const onAnnotationClear = useCallback(() => {\n setHighlightedAnnotation(undefined);\n }, []);\n\n /**\n * Ignore focus lock if focused element is the pane tab button or within editor tree.\n * This check is required:\n * - When closing the pane with `ESC` key: The panel closes asynchronously and its focus lock\n * still exists when trying to focus the tab button in higher-order component.\n * - When clicking or hittin `Enter` on an annotation: The panel remains open but focus lock\n * deactivates asynchronously.\n */\n const shouldHandleFocus = useCallback(\n (activeElement: HTMLElement): boolean => {\n return (\n activeElement !== errorsTabRef.current &&\n activeElement !== warningsTabRef.current &&\n !editor?.container.contains(activeElement)\n );\n },\n [editor]\n );\n\n const [isPreferencesModalVisible, setPreferencesModalVisible] = useState(false);\n const onPreferencesOpen = () => setPreferencesModalVisible(true);\n const onPreferencesConfirm = (p: CodeEditorProps.Preferences) => {\n fireNonCancelableEvent(props.onPreferencesChange, p);\n setPreferencesModalVisible(false);\n };\n const onPreferencesDismiss = () => setPreferencesModalVisible(false);\n\n return (\n <div\n {...baseProps}\n className={clsx(styles['code-editor'], baseProps.className, { [styles['code-editor-refresh']]: isRefresh })}\n ref={mergedRef}\n >\n {props.loading && <LoadingScreen>{i18nStrings.loadingState}</LoadingScreen>}\n\n {!ace && !props.loading && (\n <ErrorScreen recoveryText={i18nStrings.errorStateRecovery} onRecoveryClick={props.onRecoveryClick}>\n {i18nStrings.errorState}\n </ErrorScreen>\n )}\n\n {ace && !props.loading && (\n <>\n <ResizableBox\n className={styles['resizable-box']}\n width={Infinity}\n height={Math.max(editorHeight, 20)}\n minConstraints={[Infinity, 20]}\n axis=\"y\"\n handle={handler}\n onResize={(e, data) => {\n setEditorHeight(data.size.height);\n onResize();\n fireNonCancelableEvent(onEditorContentResize, {\n height: data.size.height,\n });\n }}\n >\n <div\n ref={editorRef}\n className={clsx(styles.editor, styles.ace)}\n onKeyDown={onEditorKeydown}\n tabIndex={0}\n role=\"group\"\n aria-label={i18nStrings.editorGroupAriaLabel}\n />\n </ResizableBox>\n <div role=\"group\" aria-label={i18nStrings.statusBarGroupAriaLabel}>\n <StatusBar\n languageLabel={languageLabel}\n cursorPosition={i18nStrings.cursorPosition(cursorPosition.row + 1, cursorPosition.column + 1)}\n errorCount={errorCount}\n warningCount={warningCount}\n paneStatus={paneStatus}\n onErrorPaneToggle={onErrorPaneToggle}\n onWarningPaneToggle={onWarningPaneToggle}\n onTabFocus={onTabFocus}\n onTabBlur={onTabBlur}\n errorsTabRef={errorsTabRef}\n warningsTabRef={warningsTabRef}\n i18nStrings={i18nStrings}\n isTabFocused={isTabFocused}\n paneId={paneId}\n onPreferencesOpen={onPreferencesOpen}\n isRefresh={isRefresh}\n />\n <Pane\n id={paneId}\n visible={paneStatus !== 'hidden'}\n annotations={currentAnnotations}\n highlighted={highlightedAnnotation}\n onAnnotationClick={onAnnotationClick}\n onAnnotationClear={onAnnotationClear}\n onClose={onPaneClose}\n onAllowlist={shouldHandleFocus}\n cursorPositionLabel={i18nStrings.cursorPosition}\n closeButtonAriaLabel={i18nStrings.paneCloseButtonAriaLabel}\n />\n </div>\n {isPreferencesModalVisible && (\n <PreferencesModal\n onConfirm={onPreferencesConfirm}\n onDismiss={onPreferencesDismiss}\n preferences={props.preferences}\n defaultTheme={defaultTheme}\n i18nStrings={{\n header: i18nStrings.preferencesModalHeader,\n cancel: i18nStrings.preferencesModalCancel,\n confirm: i18nStrings.preferencesModalConfirm,\n wrapLines: i18nStrings.preferencesModalWrapLines,\n theme: i18nStrings.preferencesModalTheme,\n lightThemes: i18nStrings.preferencesModalLightThemes,\n darkThemes: i18nStrings.preferencesModalDarkThemes,\n }}\n />\n )}\n </>\n )}\n </div>\n );\n}\n\napplyDisplayName(CodeEditor, 'CodeEditor');\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/code-editor/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjF,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EACL,gBAAgB,EAChB,WAAW,EAEX,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,GAChB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,sBA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AoB,EAC/B,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE;oBACX,MAAM,EAAE,WAAW,CAAC,sBAAsB;oBAC1C,MAAM,EAAE,WAAW,CAAC,sBAAsB;oBAC1C,OAAO,EAAE,WAAW,CAAC,uBAAuB;oBAC5C,SAAS,EAAE,WAAW,CAAC,yBAAyB;oBAChD,KAAK,EAAE,WAAW,CAAC,qBAAqB;oBACxC,WAAW,EAAE,WAAW,CAAC,2BAA2B;oBACpD,UAAU,EAAE,WAAW,CAAC,0BAA0B;iBACnD,GACD,CACH,CACA,CACJ,CACG,CACP,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { Ace } from 'ace-builds';\nimport clsx from 'clsx';\nimport { ResizableBox } from 'react-resizable';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { KeyCode } from '../internal/keycode';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { CodeEditorProps } from './interfaces';\nimport { Pane } from './pane';\nimport { useChangeEffect } from './listeners';\nimport {\n getDefaultConfig,\n getAceTheme,\n PaneStatus,\n getLanguageLabel,\n DEFAULT_DARK_THEME,\n DEFAULT_LIGHT_THEME,\n getDefaultTheme,\n} from './util';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { setupEditor } from './setup-editor';\nimport handler from './resize-handler';\nimport PreferencesModal from './preferences-modal';\nimport LoadingScreen from './loading-screen';\nimport ErrorScreen from './error-screen';\n\nimport styles from './styles.css.js';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { useContainerQuery } from '../internal/hooks/container-queries/use-container-query';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useCurrentMode } from '../internal/hooks/use-visual-mode';\nimport { StatusBar } from './status-bar';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { useControllable } from '../internal/hooks/use-controllable';\nexport { CodeEditorProps };\n\nexport default function CodeEditor(props: CodeEditorProps) {\n const { __internalRootRef } = useBaseComponent('CodeEditor');\n const { controlId, ariaLabelledby, ariaDescribedby } = useFormFieldContext(props);\n const { ace, value, language, i18nStrings, editorContentHeight, onEditorContentResize, ...rest } = props;\n const [editorHeight = 480, setEditorHeight] = useControllable(editorContentHeight, onEditorContentResize, 480, {\n componentName: 'code-editor',\n changeHandler: 'onEditorContentResize',\n controlledProp: 'editorContentHeight',\n });\n const baseProps = getBaseProps(rest);\n\n const [editor, setEditor] = useState<Ace.Editor>();\n const mode = useCurrentMode(__internalRootRef);\n const defaultTheme = mode === 'dark' ? DEFAULT_DARK_THEME : DEFAULT_LIGHT_THEME;\n\n const editorRef = useCallback(\n (elem: HTMLDivElement) => {\n if (!ace || !elem) {\n return;\n }\n\n const config = getDefaultConfig();\n setEditor(\n ace.edit(elem, {\n ...config,\n theme: getAceTheme(getDefaultTheme(elem)),\n })\n );\n },\n [ace]\n ); // loads as soon as ace lib is available\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n const { textarea } = editor.renderer as unknown as { textarea: HTMLTextAreaElement };\n if (!textarea) {\n return;\n }\n const updateAttribute = (attribute: string, value: string | undefined) =>\n value ? textarea.setAttribute(attribute, value) : textarea.removeAttribute(attribute);\n updateAttribute('id', controlId);\n updateAttribute('aria-labelledby', ariaLabelledby);\n updateAttribute('aria-describedby', ariaDescribedby);\n }, [ariaDescribedby, ariaLabelledby, controlId, editor]);\n\n const [paneStatus, setPaneStatus] = useState<PaneStatus>('hidden');\n const [annotations, setAnnotations] = useState<Ace.Annotation[]>([]);\n const [highlightedAnnotation, setHighlightedAnnotation] = useState<Ace.Annotation>();\n const [languageLabel, setLanguageLabel] = useState<string>('');\n const [cursorPosition, setCursorPosition] = useState<Ace.Point>({ row: 0, column: 0 });\n const [isTabFocused, setTabFocused] = useState<boolean>(false);\n\n const errorsTabRef = useRef<HTMLButtonElement>(null);\n const warningsTabRef = useRef<HTMLButtonElement>(null);\n\n const [codeEditorWidth, codeEditorMeasureRef] = useContainerQuery(rect => rect.width);\n const mergedRef = useMergeRefs(codeEditorMeasureRef, __internalRootRef);\n\n const isRefresh = useVisualRefresh();\n\n useEffect(() => {\n editor?.resize();\n }, [editor, editorContentHeight, codeEditorWidth]);\n\n const paneId = useUniqueId('code-editor-pane');\n\n useEffect(() => {\n if (!ace || !editor) {\n return;\n }\n\n setupEditor(ace, editor, setAnnotations, setCursorPosition, setHighlightedAnnotation, setPaneStatus);\n\n return () => {\n editor?.destroy();\n }; // TODO profile/monitor this\n }, [ace, editor, __internalRootRef]);\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n if (value === editor.getValue()) {\n return;\n }\n // TODO maintain cursor position?\n const pos = editor.session.selection.toJSON();\n editor.setValue(value, -1);\n editor.session.selection.fromJSON(pos);\n }, [editor, value]);\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n editor.session.setMode(`ace/mode/${language}`);\n\n setLanguageLabel(getLanguageLabel(language));\n }, [editor, language]);\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n\n const theme: CodeEditorProps.Theme = props.preferences?.theme ?? defaultTheme;\n\n editor.setTheme(getAceTheme(theme));\n\n editor.session.setUseWrapMode(props.preferences?.wrapLines ?? true);\n }, [editor, defaultTheme, props.preferences]);\n\n // listeners\n useChangeEffect(editor, props.onChange, props.onDelayedChange);\n // TODO implement other listeners\n\n // Hide error panel when there are no errors to show.\n useEffect(() => {\n if (annotations.length === 0) {\n setPaneStatus('hidden');\n }\n\n if (props.onValidate) {\n fireNonCancelableEvent(props.onValidate, { annotations });\n }\n }, [annotations, props.onValidate]);\n\n const errorCount = annotations.filter(a => a.type === 'error').length;\n const warningCount = annotations.filter(a => a.type === 'warning').length;\n const currentAnnotations = useMemo(() => annotations.filter(a => a.type === paneStatus), [annotations, paneStatus]);\n\n /*\n * Callbacks\n */\n\n const onEditorKeydown = useCallback(\n (e: React.KeyboardEvent) => {\n if (editor && e.target === editor.container && e.keyCode === KeyCode.enter) {\n e.stopPropagation();\n e.preventDefault();\n editor.focus();\n }\n },\n [editor]\n );\n\n const onTabFocus = useCallback(() => setTabFocused(true), []);\n const onTabBlur = useCallback(() => setTabFocused(false), []);\n\n const onResize = useCallback(() => {\n editor?.resize();\n }, [editor]);\n\n const onErrorPaneToggle = useCallback(() => {\n setPaneStatus(paneStatus !== 'error' ? 'error' : 'hidden');\n }, [paneStatus]);\n\n const onWarningPaneToggle = useCallback(() => {\n setPaneStatus(paneStatus !== 'warning' ? 'warning' : 'hidden');\n }, [paneStatus]);\n\n const onPaneClose = useCallback(() => {\n if (paneStatus === 'error' && errorsTabRef.current) {\n errorsTabRef.current.focus();\n }\n if (paneStatus === 'warning' && warningsTabRef.current) {\n warningsTabRef.current.focus();\n }\n setPaneStatus('hidden');\n }, [paneStatus]);\n\n const onAnnotationClick = ({ row = 0, column = 0 }: Ace.Annotation) => {\n if (!editor) {\n return;\n }\n editor.focus();\n editor.gotoLine(row + 1, column, false);\n setHighlightedAnnotation(undefined);\n };\n\n const onAnnotationClear = useCallback(() => {\n setHighlightedAnnotation(undefined);\n }, []);\n\n /**\n * Ignore focus lock if focused element is the pane tab button or within editor tree.\n * This check is required:\n * - When closing the pane with `ESC` key: The panel closes asynchronously and its focus lock\n * still exists when trying to focus the tab button in higher-order component.\n * - When clicking or hittin `Enter` on an annotation: The panel remains open but focus lock\n * deactivates asynchronously.\n */\n const shouldHandleFocus = useCallback(\n (activeElement: HTMLElement): boolean => {\n return (\n activeElement !== errorsTabRef.current &&\n activeElement !== warningsTabRef.current &&\n !editor?.container.contains(activeElement)\n );\n },\n [editor]\n );\n\n const [isPreferencesModalVisible, setPreferencesModalVisible] = useState(false);\n const onPreferencesOpen = () => setPreferencesModalVisible(true);\n const onPreferencesConfirm = (p: CodeEditorProps.Preferences) => {\n fireNonCancelableEvent(props.onPreferencesChange, p);\n setPreferencesModalVisible(false);\n };\n const onPreferencesDismiss = () => setPreferencesModalVisible(false);\n\n return (\n <div\n {...baseProps}\n className={clsx(styles['code-editor'], baseProps.className, { [styles['code-editor-refresh']]: isRefresh })}\n ref={mergedRef}\n >\n {props.loading && <LoadingScreen>{i18nStrings.loadingState}</LoadingScreen>}\n\n {!ace && !props.loading && (\n <ErrorScreen recoveryText={i18nStrings.errorStateRecovery} onRecoveryClick={props.onRecoveryClick}>\n {i18nStrings.errorState}\n </ErrorScreen>\n )}\n\n {ace && !props.loading && (\n <>\n <ResizableBox\n className={styles['resizable-box']}\n width={Infinity}\n height={Math.max(editorHeight, 20)}\n minConstraints={[Infinity, 20]}\n axis=\"y\"\n handle={handler}\n onResize={(e, data) => {\n setEditorHeight(data.size.height);\n onResize();\n fireNonCancelableEvent(onEditorContentResize, {\n height: data.size.height,\n });\n }}\n >\n <div\n ref={editorRef}\n className={clsx(styles.editor, styles.ace)}\n onKeyDown={onEditorKeydown}\n tabIndex={0}\n role=\"group\"\n aria-label={i18nStrings.editorGroupAriaLabel}\n />\n </ResizableBox>\n <div role=\"group\" aria-label={i18nStrings.statusBarGroupAriaLabel}>\n <StatusBar\n languageLabel={languageLabel}\n cursorPosition={i18nStrings.cursorPosition(cursorPosition.row + 1, cursorPosition.column + 1)}\n errorCount={errorCount}\n warningCount={warningCount}\n paneStatus={paneStatus}\n onErrorPaneToggle={onErrorPaneToggle}\n onWarningPaneToggle={onWarningPaneToggle}\n onTabFocus={onTabFocus}\n onTabBlur={onTabBlur}\n errorsTabRef={errorsTabRef}\n warningsTabRef={warningsTabRef}\n i18nStrings={i18nStrings}\n isTabFocused={isTabFocused}\n paneId={paneId}\n onPreferencesOpen={onPreferencesOpen}\n isRefresh={isRefresh}\n />\n <Pane\n id={paneId}\n visible={paneStatus !== 'hidden'}\n annotations={currentAnnotations}\n highlighted={highlightedAnnotation}\n onAnnotationClick={onAnnotationClick}\n onAnnotationClear={onAnnotationClear}\n onClose={onPaneClose}\n onAllowlist={shouldHandleFocus}\n cursorPositionLabel={i18nStrings.cursorPosition}\n closeButtonAriaLabel={i18nStrings.paneCloseButtonAriaLabel}\n />\n </div>\n {isPreferencesModalVisible && (\n <PreferencesModal\n onConfirm={onPreferencesConfirm}\n onDismiss={onPreferencesDismiss}\n themes={props.themes}\n preferences={props.preferences}\n defaultTheme={defaultTheme}\n i18nStrings={{\n header: i18nStrings.preferencesModalHeader,\n cancel: i18nStrings.preferencesModalCancel,\n confirm: i18nStrings.preferencesModalConfirm,\n wrapLines: i18nStrings.preferencesModalWrapLines,\n theme: i18nStrings.preferencesModalTheme,\n lightThemes: i18nStrings.preferencesModalLightThemes,\n darkThemes: i18nStrings.preferencesModalDarkThemes,\n }}\n />\n )}\n </>\n )}\n </div>\n );\n}\n\napplyDisplayName(CodeEditor, 'CodeEditor');\n"]}
@@ -48,6 +48,11 @@ export interface CodeEditorProps extends BaseComponentProps, FormFieldControlPro
48
48
  * You can use any theme provided by Ace.
49
49
  */
50
50
  preferences?: Partial<CodeEditorProps.Preferences>;
51
+ /**
52
+ * List of Ace themes available for selection in preferences dialog. Make sure you include at least one light and at
53
+ * least one dark theme. If not set explicitly, it will render all Ace themes available for selection.
54
+ */
55
+ themes?: CodeEditorProps.AvailableThemes;
51
56
  /**
52
57
  * Called when any of the preferences change.
53
58
  * The event `detail` contains the value of all the preferences as submitted by the user.
@@ -86,6 +91,10 @@ export interface CodeEditorProps extends BaseComponentProps, FormFieldControlPro
86
91
  export declare namespace CodeEditorProps {
87
92
  type Language = typeof AceModes[number]['value'];
88
93
  type Theme = typeof LightThemes[number]['value'] | typeof DarkThemes[number]['value'];
94
+ interface AvailableThemes {
95
+ light: ReadonlyArray<string>;
96
+ dark: ReadonlyArray<string>;
97
+ }
89
98
  interface Preferences {
90
99
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E,MAAM,CAAC;QAC9B,2BAA2B,EAAE,MAAM,CAAC;QACpC,0BAA0B,EAAE,MAAM,CAAC;KACpC;IACD,UAAiB,YAAY;QAC3B,MAAM,EAAE,MAAM,CAAC;KAChB;IACD,UAAiB,YAAY;QAC3B,KAAK,EAAE,MAAM,CAAC;KACf;IAED,UAAiB,cAAc;QAC7B,WAAW,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC;KAC/B;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/code-editor/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Ace } from 'ace-builds';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { AceModes } from './ace-modes';\nimport { DarkThemes, LightThemes } from './ace-themes';\nimport { FormFieldControlProps } from '../internal/context/form-field-context';\n\nexport interface CodeEditorProps extends BaseComponentProps, FormFieldControlProps {\n /**\n * The ace object.\n */\n ace: any;\n\n /**\n * Specifies the content that's displayed in the code editor.\n */\n value: string;\n\n /**\n * Specifies the programming language. You can use any of the programming languages supported by the `ace` object that you provide.\n */\n language: CodeEditorProps.Language;\n\n /**\n * An event handler called when the value changes.\n * The event `detail` contains the current value of the code editor content.\n * **Deprecated**, replaced by `onDelayedChange`.\n */\n onChange?: NonCancelableEventHandler<CodeEditorProps.ChangeDetail>;\n\n /**\n * An event handler called when the value changes.\n * The event `detail` contains the current value of the code editor content.\n * A user interaction can cause multiple change events to be emitted by the Ace editor. They are batched together into a single `onDelayedChange` event to avoid bugs when controlling the `value` field.\n */\n onDelayedChange?: NonCancelableEventHandler<CodeEditorProps.ChangeDetail>;\n\n /**\n * Annotations returned from Ace syntax checker after code validation.\n */\n onValidate?: NonCancelableEventHandler<CodeEditorProps.ValidateDetail>;\n\n /**\n * Specifies the component preferences.\n *\n * If set to `undefined`, the component uses the following default value:\n *\n * ```\n * {\n * wrapLines: true,\n * theme: 'dawn'\n * }\n * ```\n *\n * You can use any theme provided by Ace.\n */\n preferences?: Partial<CodeEditorProps.Preferences>;\n\n /**\n * Called when any of the preferences change.\n * The event `detail` contains the value of all the preferences as submitted by the user.\n *\n */\n onPreferencesChange: NonCancelableEventHandler<CodeEditorProps.Preferences>;\n\n /**\n * Renders the code editor in a loading state.\n */\n loading?: boolean;\n\n /**\n * Called when the user clicks the recovery button in the error state.\n * Use this to retry loading the code editor or to provide another option for the user to recover from the error.\n */\n onRecoveryClick?: NonCancelableEventHandler<void>;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n * The object should contain, among others:\n *\n * * `loadingState` - Specifies the text to display while the component is loading.\n * * `errorState` - Specifies the text to display if there is an error loading Ace.\n * * `errorStateRecovery`: Specifies the text for the recovery button that's displayed next to the error text.\n * Use the `recoveryClick` event to do a recovery action (for example, retrying the request).\n */\n i18nStrings: CodeEditorProps.I18nStrings;\n\n /**\n * Specifies the height of the code editor document.\n */\n editorContentHeight?: number;\n\n /**\n * Called when the user resizes the editor by dragging the resize icon.\n * The event `detail` contains the new height of the editor in pixels.\n */\n onEditorContentResize?: NonCancelableEventHandler<CodeEditorProps.ResizeDetail>;\n}\n\nexport namespace CodeEditorProps {\n export type Language = typeof AceModes[number]['value'];\n export type Theme = typeof LightThemes[number]['value'] | typeof DarkThemes[number]['value'];\n\n export interface Preferences {\n wrapLines: boolean;\n theme: Theme;\n }\n\n export interface I18nStrings {\n loadingState: string;\n errorState: string;\n errorStateRecovery: string;\n\n editorGroupAriaLabel: string;\n statusBarGroupAriaLabel: string;\n\n cursorPosition: (row: number, column: number) => string;\n errorsTab: string;\n warningsTab: string;\n preferencesButtonAriaLabel: string;\n paneCloseButtonAriaLabel: string;\n\n preferencesModalHeader: string;\n preferencesModalCancel: string;\n preferencesModalConfirm: string;\n preferencesModalWrapLines: string;\n preferencesModalTheme: string;\n preferencesModalLightThemes: string;\n preferencesModalDarkThemes: string;\n }\n export interface ResizeDetail {\n height: number;\n }\n export interface ChangeDetail {\n value: string;\n }\n\n export interface ValidateDetail {\n annotations: Ace.Annotation[];\n }\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/code-editor/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Ace } from 'ace-builds';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { AceModes } from './ace-modes';\nimport { DarkThemes, LightThemes } from './ace-themes';\nimport { FormFieldControlProps } from '../internal/context/form-field-context';\n\nexport interface CodeEditorProps extends BaseComponentProps, FormFieldControlProps {\n /**\n * The ace object.\n */\n ace: any;\n\n /**\n * Specifies the content that's displayed in the code editor.\n */\n value: string;\n\n /**\n * Specifies the programming language. You can use any of the programming languages supported by the `ace` object that you provide.\n */\n language: CodeEditorProps.Language;\n\n /**\n * An event handler called when the value changes.\n * The event `detail` contains the current value of the code editor content.\n * **Deprecated**, replaced by `onDelayedChange`.\n */\n onChange?: NonCancelableEventHandler<CodeEditorProps.ChangeDetail>;\n\n /**\n * An event handler called when the value changes.\n * The event `detail` contains the current value of the code editor content.\n * A user interaction can cause multiple change events to be emitted by the Ace editor. They are batched together into a single `onDelayedChange` event to avoid bugs when controlling the `value` field.\n */\n onDelayedChange?: NonCancelableEventHandler<CodeEditorProps.ChangeDetail>;\n\n /**\n * Annotations returned from Ace syntax checker after code validation.\n */\n onValidate?: NonCancelableEventHandler<CodeEditorProps.ValidateDetail>;\n\n /**\n * Specifies the component preferences.\n *\n * If set to `undefined`, the component uses the following default value:\n *\n * ```\n * {\n * wrapLines: true,\n * theme: 'dawn'\n * }\n * ```\n *\n * You can use any theme provided by Ace.\n */\n preferences?: Partial<CodeEditorProps.Preferences>;\n\n /**\n * List of Ace themes available for selection in preferences dialog. Make sure you include at least one light and at\n * least one dark theme. If not set explicitly, it will render all Ace themes available for selection.\n */\n themes?: CodeEditorProps.AvailableThemes;\n\n /**\n * Called when any of the preferences change.\n * The event `detail` contains the value of all the preferences as submitted by the user.\n *\n */\n onPreferencesChange: NonCancelableEventHandler<CodeEditorProps.Preferences>;\n\n /**\n * Renders the code editor in a loading state.\n */\n loading?: boolean;\n\n /**\n * Called when the user clicks the recovery button in the error state.\n * Use this to retry loading the code editor or to provide another option for the user to recover from the error.\n */\n onRecoveryClick?: NonCancelableEventHandler<void>;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n * The object should contain, among others:\n *\n * * `loadingState` - Specifies the text to display while the component is loading.\n * * `errorState` - Specifies the text to display if there is an error loading Ace.\n * * `errorStateRecovery`: Specifies the text for the recovery button that's displayed next to the error text.\n * Use the `recoveryClick` event to do a recovery action (for example, retrying the request).\n */\n i18nStrings: CodeEditorProps.I18nStrings;\n\n /**\n * Specifies the height of the code editor document.\n */\n editorContentHeight?: number;\n\n /**\n * Called when the user resizes the editor by dragging the resize icon.\n * The event `detail` contains the new height of the editor in pixels.\n */\n onEditorContentResize?: NonCancelableEventHandler<CodeEditorProps.ResizeDetail>;\n}\n\nexport namespace CodeEditorProps {\n export type Language = typeof AceModes[number]['value'];\n export type Theme = typeof LightThemes[number]['value'] | typeof DarkThemes[number]['value'];\n\n export interface AvailableThemes {\n light: ReadonlyArray<string>;\n dark: ReadonlyArray<string>;\n }\n\n export interface Preferences {\n wrapLines: boolean;\n theme: Theme;\n }\n\n export interface I18nStrings {\n loadingState: string;\n errorState: string;\n errorStateRecovery: string;\n\n editorGroupAriaLabel: string;\n statusBarGroupAriaLabel: string;\n\n cursorPosition: (row: number, column: number) => string;\n errorsTab: string;\n warningsTab: string;\n preferencesButtonAriaLabel: string;\n paneCloseButtonAriaLabel: string;\n\n preferencesModalHeader: string;\n preferencesModalCancel: string;\n preferencesModalConfirm: string;\n preferencesModalWrapLines: string;\n preferencesModalTheme: string;\n preferencesModalLightThemes: string;\n preferencesModalDarkThemes: string;\n }\n export interface ResizeDetail {\n height: number;\n }\n export interface ChangeDetail {\n value: string;\n }\n\n export interface ValidateDetail {\n annotations: Ace.Annotation[];\n }\n}\n"]}
@@ -11,6 +11,7 @@ interface PreferencesModali18nStrings {
11
11
  interface PreferencesModalProps {
12
12
  preferences?: Partial<CodeEditorProps.Preferences>;
13
13
  i18nStrings: PreferencesModali18nStrings;
14
+ themes: CodeEditorProps['themes'];
14
15
  defaultTheme: CodeEditorProps.Theme;
15
16
  onConfirm: (preferences: CodeEditorProps.Preferences) => void;
16
17
  onDismiss: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"preferences-modal.d.ts","sourceRoot":"","sources":["../../../src/code-editor/preferences-modal.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,UAAU,2BAA2B;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,qBAAqB;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;IAEnD,WAAW,EAAE,2BAA2B,CAAC;IAEzC,YAAY,EAAE,eAAe,CAAC,KAAK,CAAC;IAEpC,SAAS,EAAE,CAAC,WAAW,EAAE,eAAe,CAAC,WAAW,KAAK,IAAI,CAAC;IAC9D,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;gCAEsB,qBAAqB;AAA5C,wBAsDE"}
1
+ {"version":3,"file":"preferences-modal.d.ts","sourceRoot":"","sources":["../../../src/code-editor/preferences-modal.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,UAAU,2BAA2B;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,qBAAqB;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;IAEnD,WAAW,EAAE,2BAA2B,CAAC;IAEzC,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC;IAClC,YAAY,EAAE,eAAe,CAAC,KAAK,CAAC;IAEpC,SAAS,EAAE,CAAC,WAAW,EAAE,eAAe,CAAC,WAAW,KAAK,IAAI,CAAC;IAC9D,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;gCASsB,qBAAqB;AAA5C,wBA6DE"}
@@ -12,11 +12,27 @@ import InternalSelect from '../select/internal';
12
12
  import InternalSpaceBetween from '../space-between/internal';
13
13
  import { FormFieldContext } from '../internal/context/form-field-context';
14
14
  import { LightThemes, DarkThemes } from './ace-themes';
15
+ function filterThemes(allThemes, available) {
16
+ if (!available) {
17
+ return allThemes;
18
+ }
19
+ return allThemes.filter(function (theme) { return available.indexOf(theme.value) > -1; });
20
+ }
15
21
  export default (function (props) {
16
- var _a, _b, _c, _d;
17
- var _e = useState((_b = (_a = props.preferences) === null || _a === void 0 ? void 0 : _a.wrapLines) !== null && _b !== void 0 ? _b : true), wrapLines = _e[0], setWrapLines = _e[1];
18
- var _f = useState((_d = (_c = props.preferences) === null || _c === void 0 ? void 0 : _c.theme) !== null && _d !== void 0 ? _d : props.defaultTheme), theme = _f[0], setTheme = _f[1];
19
- var _g = useState(function () { return __spreadArray(__spreadArray([], LightThemes, true), DarkThemes, true).filter(function (t) { return t.value === theme; })[0]; }), selectedThemeOption = _g[0], setSelectedThemeOption = _g[1];
22
+ var _a, _b, _c, _d, _e, _f;
23
+ var _g = useState((_b = (_a = props.preferences) === null || _a === void 0 ? void 0 : _a.wrapLines) !== null && _b !== void 0 ? _b : true), wrapLines = _g[0], setWrapLines = _g[1];
24
+ var _h = useState((_d = (_c = props.preferences) === null || _c === void 0 ? void 0 : _c.theme) !== null && _d !== void 0 ? _d : props.defaultTheme), theme = _h[0], setTheme = _h[1];
25
+ var themeOptions = [
26
+ {
27
+ label: props.i18nStrings.lightThemes,
28
+ options: filterThemes(LightThemes, (_e = props.themes) === null || _e === void 0 ? void 0 : _e.light)
29
+ },
30
+ {
31
+ label: props.i18nStrings.darkThemes,
32
+ options: filterThemes(DarkThemes, (_f = props.themes) === null || _f === void 0 ? void 0 : _f.dark)
33
+ },
34
+ ];
35
+ var _j = useState(function () { return __spreadArray(__spreadArray([], LightThemes, true), DarkThemes, true).filter(function (t) { return t.value === theme; })[0]; }), selectedThemeOption = _j[0], setSelectedThemeOption = _j[1];
20
36
  var onThemeSelected = function (e) {
21
37
  setTheme(e.detail.selectedOption.value);
22
38
  setSelectedThemeOption(e.detail.selectedOption);
@@ -31,9 +47,6 @@ export default (function (props) {
31
47
  React.createElement(InternalCheckbox, { checked: wrapLines, onChange: function (e) { return setWrapLines(e.detail.checked); } }, props.i18nStrings.wrapLines)),
32
48
  React.createElement("div", null,
33
49
  React.createElement(InternalFormField, { label: props.i18nStrings.theme },
34
- React.createElement(InternalSelect, { selectedOption: selectedThemeOption, onChange: onThemeSelected, options: [
35
- { label: props.i18nStrings.lightThemes, options: LightThemes },
36
- { label: props.i18nStrings.darkThemes, options: DarkThemes },
37
- ], filteringType: "auto" })))))));
50
+ React.createElement(InternalSelect, { selectedOption: selectedThemeOption, onChange: onThemeSelected, options: themeOptions, filteringType: "auto" })))))));
38
51
  });
39
52
  //# sourceMappingURL=preferences-modal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"preferences-modal.js","sourceRoot":"","sources":["../../../src/code-editor/preferences-modal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAs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WAAW,CAAC,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE;gCAC9D,EAAE,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE;6BAC7D,EACD,aAAa,EAAC,MAAM,GACpB,CACgB,CAChB,CACe,CACT,CACU,CAC7B,CAAC;AACJ,CAAC,EAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useState } from 'react';\n\nimport InternalBox from '../box/internal';\nimport { InternalButton } from '../button/internal';\nimport InternalCheckbox from '../checkbox/internal';\nimport InternalColumnLayout from '../column-layout/internal';\nimport InternalFormField from '../form-field/internal';\nimport InternalModal from '../modal/internal';\nimport { SelectProps } from '../select/interfaces';\nimport InternalSelect from '../select/internal';\nimport InternalSpaceBetween from '../space-between/internal';\nimport { FormFieldContext } from '../internal/context/form-field-context';\nimport { NonCancelableCustomEvent } from '../internal/events';\nimport { LightThemes, DarkThemes } from './ace-themes';\nimport { CodeEditorProps } from './interfaces';\n\ninterface PreferencesModali18nStrings {\n header: string;\n cancel: string;\n confirm: string;\n wrapLines: string;\n theme: string;\n lightThemes: string;\n darkThemes: string;\n}\n\ninterface PreferencesModalProps {\n preferences?: Partial<CodeEditorProps.Preferences>;\n\n i18nStrings: PreferencesModali18nStrings;\n\n defaultTheme: CodeEditorProps.Theme;\n\n onConfirm: (preferences: CodeEditorProps.Preferences) => void;\n onDismiss: () => void;\n}\n\nexport default (props: PreferencesModalProps) => {\n const [wrapLines, setWrapLines] = useState<boolean>(props.preferences?.wrapLines ?? true);\n const [theme, setTheme] = useState<CodeEditorProps.Theme>(props.preferences?.theme ?? props.defaultTheme);\n const [selectedThemeOption, setSelectedThemeOption] = useState<SelectProps.Option>(\n () => [...LightThemes, ...DarkThemes].filter(t => t.value === theme)[0]\n );\n\n const onThemeSelected = (e: NonCancelableCustomEvent<SelectProps.ChangeDetail>) => {\n setTheme(e.detail.selectedOption.value as CodeEditorProps.Theme);\n setSelectedThemeOption(e.detail.selectedOption);\n };\n\n return (\n <FormFieldContext.Provider value={{}}>\n <InternalModal\n size=\"medium\"\n visible={true}\n onDismiss={props.onDismiss}\n header={props.i18nStrings.header}\n closeAriaLabel={props.i18nStrings.cancel}\n footer={\n <InternalBox float=\"right\">\n <InternalSpaceBetween direction=\"horizontal\" size=\"xs\">\n <InternalButton onClick={props.onDismiss}>{props.i18nStrings.cancel}</InternalButton>\n <InternalButton onClick={() => props.onConfirm({ wrapLines, theme })} variant=\"primary\">\n {props.i18nStrings.confirm}\n </InternalButton>\n </InternalSpaceBetween>\n </InternalBox>\n }\n >\n <InternalColumnLayout columns={2} variant=\"text-grid\">\n <div>\n <InternalCheckbox checked={wrapLines} onChange={e => setWrapLines(e.detail.checked)}>\n {props.i18nStrings.wrapLines}\n </InternalCheckbox>\n </div>\n <div>\n <InternalFormField label={props.i18nStrings.theme}>\n <InternalSelect\n selectedOption={selectedThemeOption}\n onChange={onThemeSelected}\n options={[\n { label: props.i18nStrings.lightThemes, options: LightThemes },\n { label: props.i18nStrings.darkThemes, options: DarkThemes },\n ]}\n filteringType=\"auto\"\n />\n </InternalFormField>\n </div>\n </InternalColumnLayout>\n </InternalModal>\n </FormFieldContext.Provider>\n );\n};\n"]}
1
+ {"version":3,"file":"preferences-modal.js","sourceRoot":"","sources":["../../../src/code-editor/preferences-modal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExC,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,gBAAgB,MAAM,sBAAsB,CAAC;AACpD,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAC7D,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AACvD,OAAO,aAAa,MAAM,mBAAmB,CAA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OAAO,CAAC,EAA9B,CAA8B,IAChF,KAAK,CAAC,WAAW,CAAC,SAAS,CACX,CACf;gBACN;oBACE,oBAAC,iBAAiB,IAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,KAAK;wBAC/C,oBAAC,cAAc,IACb,cAAc,EAAE,mBAAmB,EACnC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,YAAY,EACrB,aAAa,EAAC,MAAM,GACpB,CACgB,CAChB,CACe,CACT,CACU,CAC7B,CAAC;AACJ,CAAC,EAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useState } from 'react';\n\nimport InternalBox from '../box/internal';\nimport { InternalButton } from '../button/internal';\nimport InternalCheckbox from '../checkbox/internal';\nimport InternalColumnLayout from '../column-layout/internal';\nimport InternalFormField from '../form-field/internal';\nimport InternalModal from '../modal/internal';\nimport { SelectProps } from '../select/interfaces';\nimport InternalSelect from '../select/internal';\nimport InternalSpaceBetween from '../space-between/internal';\nimport { FormFieldContext } from '../internal/context/form-field-context';\nimport { NonCancelableCustomEvent } from '../internal/events';\nimport { LightThemes, DarkThemes } from './ace-themes';\nimport { CodeEditorProps } from './interfaces';\n\ninterface PreferencesModali18nStrings {\n header: string;\n cancel: string;\n confirm: string;\n wrapLines: string;\n theme: string;\n lightThemes: string;\n darkThemes: string;\n}\n\ninterface PreferencesModalProps {\n preferences?: Partial<CodeEditorProps.Preferences>;\n\n i18nStrings: PreferencesModali18nStrings;\n\n themes: CodeEditorProps['themes'];\n defaultTheme: CodeEditorProps.Theme;\n\n onConfirm: (preferences: CodeEditorProps.Preferences) => void;\n onDismiss: () => void;\n}\n\nfunction filterThemes(allThemes: ReadonlyArray<SelectProps.Option>, available: ReadonlyArray<string> | undefined) {\n if (!available) {\n return allThemes;\n }\n return allThemes.filter(theme => available.indexOf(theme.value!) > -1);\n}\n\nexport default (props: PreferencesModalProps) => {\n const [wrapLines, setWrapLines] = useState<boolean>(props.preferences?.wrapLines ?? true);\n const [theme, setTheme] = useState<CodeEditorProps.Theme>(props.preferences?.theme ?? props.defaultTheme);\n const themeOptions = [\n {\n label: props.i18nStrings.lightThemes,\n options: filterThemes(LightThemes, props.themes?.light),\n },\n {\n label: props.i18nStrings.darkThemes,\n options: filterThemes(DarkThemes, props.themes?.dark),\n },\n ];\n const [selectedThemeOption, setSelectedThemeOption] = useState<SelectProps.Option>(\n () => [...LightThemes, ...DarkThemes].filter(t => t.value === theme)[0]\n );\n\n const onThemeSelected = (e: NonCancelableCustomEvent<SelectProps.ChangeDetail>) => {\n setTheme(e.detail.selectedOption.value as CodeEditorProps.Theme);\n setSelectedThemeOption(e.detail.selectedOption);\n };\n\n return (\n <FormFieldContext.Provider value={{}}>\n <InternalModal\n size=\"medium\"\n visible={true}\n onDismiss={props.onDismiss}\n header={props.i18nStrings.header}\n closeAriaLabel={props.i18nStrings.cancel}\n footer={\n <InternalBox float=\"right\">\n <InternalSpaceBetween direction=\"horizontal\" size=\"xs\">\n <InternalButton onClick={props.onDismiss}>{props.i18nStrings.cancel}</InternalButton>\n <InternalButton onClick={() => props.onConfirm({ wrapLines, theme })} variant=\"primary\">\n {props.i18nStrings.confirm}\n </InternalButton>\n </InternalSpaceBetween>\n </InternalBox>\n }\n >\n <InternalColumnLayout columns={2} variant=\"text-grid\">\n <div>\n <InternalCheckbox checked={wrapLines} onChange={e => setWrapLines(e.detail.checked)}>\n {props.i18nStrings.wrapLines}\n </InternalCheckbox>\n </div>\n <div>\n <InternalFormField label={props.i18nStrings.theme}>\n <InternalSelect\n selectedOption={selectedThemeOption}\n onChange={onThemeSelected}\n options={themeOptions}\n filteringType=\"auto\"\n />\n </InternalFormField>\n </div>\n </InternalColumnLayout>\n </InternalModal>\n </FormFieldContext.Provider>\n );\n};\n"]}
@@ -1,5 +1,5 @@
1
1
 
2
- export var PACKAGE_VERSION = '3.0.0 (71d1df5)';
2
+ export var PACKAGE_VERSION = '3.0.0 (5537576)';
3
3
  export var THEME = 'open-source-visual-refresh';
4
4
  export var ALWAYS_VISUAL_REFRESH = true;
5
5
 
package/package.json CHANGED
@@ -113,6 +113,6 @@
113
113
  "./internal/base-component/index.js",
114
114
  "./internal/base-component/styles.css.js"
115
115
  ],
116
- "version": "3.0.90",
116
+ "version": "3.0.92",
117
117
  "license": "Apache-2.0"
118
118
  }
@@ -1 +1 @@
1
- {"version":3,"file":"use-sticky-scrollbar.d.ts","sourceRoot":"","sources":["../../../src/table/use-sticky-scrollbar.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AA6EvD,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,SAAS,CAAC,cAAc,CAAC,EACvC,mBAAmB,EAAE,SAAS,CAAC,cAAc,CAAC,EAC9C,QAAQ,EAAE,SAAS,CAAC,gBAAgB,CAAC,EACrC,UAAU,EAAE,SAAS,CAAC,cAAc,CAAC,EACrC,YAAY,EAAE,MAAM,QA4ErB"}
1
+ {"version":3,"file":"use-sticky-scrollbar.d.ts","sourceRoot":"","sources":["../../../src/table/use-sticky-scrollbar.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AA6EvD,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,SAAS,CAAC,cAAc,CAAC,EACvC,mBAAmB,EAAE,SAAS,CAAC,cAAc,CAAC,EAC9C,QAAQ,EAAE,SAAS,CAAC,gBAAgB,CAAC,EACrC,UAAU,EAAE,SAAS,CAAC,cAAc,CAAC,EACrC,YAAY,EAAE,MAAM,QAgFrB"}
@@ -3,7 +3,7 @@
3
3
  import { ResizeObserver } from '@juggle/resize-observer';
4
4
  import { useEffect, useState } from 'react';
5
5
  import styles from './styles.css.js';
6
- import { getOverflowParentDimensions } from '../internal/utils/scrollable-containers';
6
+ import { getOverflowParentDimensions, getOverflowParents } from '../internal/utils/scrollable-containers';
7
7
  import { browserScrollbarSize } from '../internal/utils/browser-scrollbar-size';
8
8
  import { supportsStickyPosition, getContainingBlock } from '../internal/utils/dom';
9
9
  var updatePosition = function (tableEl, wrapperEl, scrollbarEl, scrollbarContentEl, hasContainingBlock, consideredFooterHeight) {
@@ -66,7 +66,10 @@ export function useStickyScrollbar(scrollbarRef, scrollbarContentRef, tableRef,
66
66
  // containing block, if present, is below the app layout and above the overflow
67
67
  // parent, which is a pretty safe assumption.
68
68
  var _a = useState(false), hasContainingBlock = _a[0], setHasContainingBlock = _a[1];
69
- var consideredFooterHeight = hasContainingBlock ? 0 : footerHeight;
69
+ // We don't take into account footer height when the overflow parent is child of document body.
70
+ // Because in this case, we think the footer is outside the overflow parent.
71
+ var _b = useState(false), hasOverflowParent = _b[0], setHasOverflowParent = _b[1];
72
+ var consideredFooterHeight = hasContainingBlock || hasOverflowParent ? 0 : footerHeight;
70
73
  useEffect(function () {
71
74
  if (supportsStickyPosition()) {
72
75
  var scrollHandler_1 = function () {
@@ -83,6 +86,7 @@ export function useStickyScrollbar(scrollbarRef, scrollbarContentRef, tableRef,
83
86
  useEffect(function () {
84
87
  if (wrapperEl && supportsStickyPosition()) {
85
88
  setHasContainingBlock(!!getContainingBlock(wrapperEl));
89
+ setHasOverflowParent(!!getOverflowParents(wrapperEl)[0]);
86
90
  }
87
91
  }, [wrapperEl]);
88
92
  useEffect(function () {
@@ -1 +1 @@
1
- {"version":3,"file":"use-sticky-scrollbar.js","sourceRoot":"","sources":["../../../src/table/use-sticky-scrollbar.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAa,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,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,UAAU,EAAE,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,sBAAsB,CAAC,CAAC,CAAC;AAC5G,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ResizeObserver } from '@juggle/resize-observer';\nimport { RefObject, useEffect, useState } from 'react';\nimport styles from './styles.css.js';\n\nimport { getOverflowParentDimensions } from '../internal/utils/scrollable-containers';\nimport { browserScrollbarSize } from '../internal/utils/browser-scrollbar-size';\nimport { supportsStickyPosition, getContainingBlock } from '../internal/utils/dom';\n\nconst updatePosition = (\n tableEl: HTMLElement | null,\n wrapperEl: HTMLElement | null,\n scrollbarEl: HTMLElement | null,\n scrollbarContentEl: HTMLElement | null,\n hasContainingBlock: boolean,\n consideredFooterHeight: number\n) => {\n if (!tableEl || !scrollbarEl || !wrapperEl) {\n return;\n }\n\n // parent is either some container or document itself\n const parent = getOverflowParentDimensions(wrapperEl)[0];\n const parentBottom = parent.top + parent.height;\n\n // table bottom is visible when\n // 1. table bottom reached end of the window\n // 2. table bottom is not overlapped by footer\n const { top: tableTop, bottom: tableBottom, width: tableWidth } = tableEl.getBoundingClientRect();\n const { width: wrapperWidth } = wrapperEl.getBoundingClientRect();\n\n //scrollbar correction is needed for\n // #1 when scrollbars are constantly visible,\n // we want no visible break when switching between fake and real scrollbars\n // #2 when scrollbars are visible only on scrolling and half transparent (on mac)\n // we want to avoid any overlap between fake and real scrollbar\n // using 15 px as a height of transparent scrollbar on mac\n const scrollbarHeight = browserScrollbarSize().height;\n const scrollBarCorrection = scrollbarHeight > 0 ? scrollbarHeight : -15 / 2;\n const tableBottomIsVisible = parentBottom - consideredFooterHeight >= tableBottom + scrollBarCorrection;\n const tableTopIsHidden = tableTop >= parentBottom - consideredFooterHeight - scrollBarCorrection;\n const areaIsScrollable = tableWidth > wrapperWidth;\n\n if (tableBottomIsVisible || tableTopIsHidden || !areaIsScrollable) {\n scrollbarEl.classList.remove(styles['sticky-scrollbar-visible']);\n } else {\n // when scrollbar is not displayed scrollLeft property cannot be set by useScrollSync\n // that's why syncing it separately\n if (!scrollbarEl.classList.contains(styles['sticky-scrollbar-visible'])) {\n requestAnimationFrame(() => {\n scrollbarEl.scrollLeft = wrapperEl.scrollLeft;\n });\n }\n\n scrollbarEl.classList.add(styles['sticky-scrollbar-visible']);\n }\n\n if (scrollbarHeight && scrollbarEl && scrollbarContentEl) {\n scrollbarEl.style.height = `${scrollbarHeight}px`;\n scrollbarContentEl.style.height = `${scrollbarHeight}px`;\n }\n\n if (tableEl && wrapperEl && scrollbarContentEl && scrollbarEl) {\n const parent = getOverflowParentDimensions(wrapperEl)[0];\n\n const wrapperElRect = wrapperEl.getBoundingClientRect();\n const tableElRect = tableEl.getBoundingClientRect();\n scrollbarEl.style.width = `${wrapperElRect.width}px`;\n scrollbarContentEl.style.width = `${tableElRect.width}px`;\n\n // when using sticky scrollbars in containers\n // we agreed to ignore dynamic bottom calculations for footer overlap\n scrollbarEl.style.left = hasContainingBlock ? '0px' : `${wrapperElRect.left}px`;\n scrollbarEl.style.top = hasContainingBlock\n ? '0px'\n : `${Math.min(parent.top + parent.height, window.innerHeight - consideredFooterHeight)}px`;\n }\n};\n\nexport function useStickyScrollbar(\n scrollbarRef: RefObject<HTMLDivElement>,\n scrollbarContentRef: RefObject<HTMLDivElement>,\n tableRef: RefObject<HTMLTableElement>,\n wrapperRef: RefObject<HTMLDivElement>,\n footerHeight: number\n) {\n // We don't take into account containing-block calculations because that would\n // unnecessarily overcomplicate the position logic. For now, we assume that a\n // containing block, if present, is below the app layout and above the overflow\n // parent, which is a pretty safe assumption.\n const [hasContainingBlock, setHasContainingBlock] = useState(false);\n const consideredFooterHeight = hasContainingBlock ? 0 : footerHeight;\n\n useEffect(() => {\n if (supportsStickyPosition()) {\n const scrollHandler = () => {\n updatePosition(\n tableRef.current,\n wrapperRef.current,\n scrollbarRef.current,\n scrollbarContentRef.current,\n hasContainingBlock,\n consideredFooterHeight\n );\n };\n scrollHandler();\n window.addEventListener('scroll', scrollHandler, true);\n return () => {\n window.removeEventListener('scroll', scrollHandler, true);\n };\n }\n }, [scrollbarRef, tableRef, wrapperRef, consideredFooterHeight, scrollbarContentRef, hasContainingBlock]);\n\n const wrapperEl = wrapperRef.current;\n useEffect(() => {\n if (wrapperEl && supportsStickyPosition()) {\n setHasContainingBlock(!!getContainingBlock(wrapperEl));\n }\n }, [wrapperEl]);\n\n useEffect(() => {\n if (supportsStickyPosition() && tableRef.current) {\n const observer = new ResizeObserver(entries => {\n if (scrollbarContentRef.current) {\n scrollbarContentRef.current.style.width = `${entries[0].borderBoxSize[0].inlineSize}px`;\n updatePosition(\n tableRef.current,\n wrapperRef.current,\n scrollbarRef.current,\n scrollbarContentRef.current,\n hasContainingBlock,\n consideredFooterHeight\n );\n }\n });\n observer.observe(tableRef.current);\n return () => {\n observer.disconnect();\n };\n }\n }, [scrollbarContentRef, scrollbarRef, tableRef, wrapperRef, consideredFooterHeight, hasContainingBlock]);\n\n useEffect(() => {\n if (supportsStickyPosition()) {\n const resizeHandler = () => {\n updatePosition(\n tableRef.current,\n wrapperRef.current,\n scrollbarRef.current,\n scrollbarContentRef.current,\n hasContainingBlock,\n consideredFooterHeight\n );\n };\n window.addEventListener('resize', resizeHandler);\n return () => {\n window.removeEventListener('resize', resizeHandler);\n };\n }\n }, [tableRef, wrapperRef, scrollbarRef, scrollbarContentRef, hasContainingBlock, consideredFooterHeight]);\n}\n"]}
1
+ {"version":3,"file":"use-sticky-scrollbar.js","sourceRoot":"","sources":["../../../src/table/use-sticky-scrollbar.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAa,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EA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,CAAC,OAAO,EAClB,YAAY,CAAC,OAAO,EACpB,mBAAmB,CAAC,OAAO,EAC3B,kBAAkB,EAClB,sBAAsB,CACvB,CAAC;YACJ,CAAC,CAAC;YACF,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,eAAa,CAAC,CAAC;YACjD,OAAO;gBACL,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,eAAa,CAAC,CAAC;YACtD,CAAC,CAAC;SACH;IACH,CAAC,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,sBAAsB,CAAC,CAAC,CAAC;AAC5G,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ResizeObserver } from '@juggle/resize-observer';\nimport { RefObject, useEffect, useState } from 'react';\nimport styles from './styles.css.js';\n\nimport { getOverflowParentDimensions, getOverflowParents } from '../internal/utils/scrollable-containers';\nimport { browserScrollbarSize } from '../internal/utils/browser-scrollbar-size';\nimport { supportsStickyPosition, getContainingBlock } from '../internal/utils/dom';\n\nconst updatePosition = (\n tableEl: HTMLElement | null,\n wrapperEl: HTMLElement | null,\n scrollbarEl: HTMLElement | null,\n scrollbarContentEl: HTMLElement | null,\n hasContainingBlock: boolean,\n consideredFooterHeight: number\n) => {\n if (!tableEl || !scrollbarEl || !wrapperEl) {\n return;\n }\n\n // parent is either some container or document itself\n const parent = getOverflowParentDimensions(wrapperEl)[0];\n const parentBottom = parent.top + parent.height;\n\n // table bottom is visible when\n // 1. table bottom reached end of the window\n // 2. table bottom is not overlapped by footer\n const { top: tableTop, bottom: tableBottom, width: tableWidth } = tableEl.getBoundingClientRect();\n const { width: wrapperWidth } = wrapperEl.getBoundingClientRect();\n\n //scrollbar correction is needed for\n // #1 when scrollbars are constantly visible,\n // we want no visible break when switching between fake and real scrollbars\n // #2 when scrollbars are visible only on scrolling and half transparent (on mac)\n // we want to avoid any overlap between fake and real scrollbar\n // using 15 px as a height of transparent scrollbar on mac\n const scrollbarHeight = browserScrollbarSize().height;\n const scrollBarCorrection = scrollbarHeight > 0 ? scrollbarHeight : -15 / 2;\n const tableBottomIsVisible = parentBottom - consideredFooterHeight >= tableBottom + scrollBarCorrection;\n const tableTopIsHidden = tableTop >= parentBottom - consideredFooterHeight - scrollBarCorrection;\n const areaIsScrollable = tableWidth > wrapperWidth;\n\n if (tableBottomIsVisible || tableTopIsHidden || !areaIsScrollable) {\n scrollbarEl.classList.remove(styles['sticky-scrollbar-visible']);\n } else {\n // when scrollbar is not displayed scrollLeft property cannot be set by useScrollSync\n // that's why syncing it separately\n if (!scrollbarEl.classList.contains(styles['sticky-scrollbar-visible'])) {\n requestAnimationFrame(() => {\n scrollbarEl.scrollLeft = wrapperEl.scrollLeft;\n });\n }\n\n scrollbarEl.classList.add(styles['sticky-scrollbar-visible']);\n }\n\n if (scrollbarHeight && scrollbarEl && scrollbarContentEl) {\n scrollbarEl.style.height = `${scrollbarHeight}px`;\n scrollbarContentEl.style.height = `${scrollbarHeight}px`;\n }\n\n if (tableEl && wrapperEl && scrollbarContentEl && scrollbarEl) {\n const parent = getOverflowParentDimensions(wrapperEl)[0];\n\n const wrapperElRect = wrapperEl.getBoundingClientRect();\n const tableElRect = tableEl.getBoundingClientRect();\n scrollbarEl.style.width = `${wrapperElRect.width}px`;\n scrollbarContentEl.style.width = `${tableElRect.width}px`;\n\n // when using sticky scrollbars in containers\n // we agreed to ignore dynamic bottom calculations for footer overlap\n scrollbarEl.style.left = hasContainingBlock ? '0px' : `${wrapperElRect.left}px`;\n scrollbarEl.style.top = hasContainingBlock\n ? '0px'\n : `${Math.min(parent.top + parent.height, window.innerHeight - consideredFooterHeight)}px`;\n }\n};\n\nexport function useStickyScrollbar(\n scrollbarRef: RefObject<HTMLDivElement>,\n scrollbarContentRef: RefObject<HTMLDivElement>,\n tableRef: RefObject<HTMLTableElement>,\n wrapperRef: RefObject<HTMLDivElement>,\n footerHeight: number\n) {\n // We don't take into account containing-block calculations because that would\n // unnecessarily overcomplicate the position logic. For now, we assume that a\n // containing block, if present, is below the app layout and above the overflow\n // parent, which is a pretty safe assumption.\n const [hasContainingBlock, setHasContainingBlock] = useState(false);\n // We don't take into account footer height when the overflow parent is child of document body.\n // Because in this case, we think the footer is outside the overflow parent.\n const [hasOverflowParent, setHasOverflowParent] = useState(false);\n const consideredFooterHeight = hasContainingBlock || hasOverflowParent ? 0 : footerHeight;\n\n useEffect(() => {\n if (supportsStickyPosition()) {\n const scrollHandler = () => {\n updatePosition(\n tableRef.current,\n wrapperRef.current,\n scrollbarRef.current,\n scrollbarContentRef.current,\n hasContainingBlock,\n consideredFooterHeight\n );\n };\n scrollHandler();\n window.addEventListener('scroll', scrollHandler, true);\n return () => {\n window.removeEventListener('scroll', scrollHandler, true);\n };\n }\n }, [scrollbarRef, tableRef, wrapperRef, consideredFooterHeight, scrollbarContentRef, hasContainingBlock]);\n\n const wrapperEl = wrapperRef.current;\n useEffect(() => {\n if (wrapperEl && supportsStickyPosition()) {\n setHasContainingBlock(!!getContainingBlock(wrapperEl));\n setHasOverflowParent(!!getOverflowParents(wrapperEl)[0]);\n }\n }, [wrapperEl]);\n\n useEffect(() => {\n if (supportsStickyPosition() && tableRef.current) {\n const observer = new ResizeObserver(entries => {\n if (scrollbarContentRef.current) {\n scrollbarContentRef.current.style.width = `${entries[0].borderBoxSize[0].inlineSize}px`;\n updatePosition(\n tableRef.current,\n wrapperRef.current,\n scrollbarRef.current,\n scrollbarContentRef.current,\n hasContainingBlock,\n consideredFooterHeight\n );\n }\n });\n observer.observe(tableRef.current);\n return () => {\n observer.disconnect();\n };\n }\n }, [scrollbarContentRef, scrollbarRef, tableRef, wrapperRef, consideredFooterHeight, hasContainingBlock]);\n\n useEffect(() => {\n if (supportsStickyPosition()) {\n const resizeHandler = () => {\n updatePosition(\n tableRef.current,\n wrapperRef.current,\n scrollbarRef.current,\n scrollbarContentRef.current,\n hasContainingBlock,\n consideredFooterHeight\n );\n };\n window.addEventListener('resize', resizeHandler);\n return () => {\n window.removeEventListener('resize', resizeHandler);\n };\n }\n }, [tableRef, wrapperRef, scrollbarRef, scrollbarContentRef, hasContainingBlock, consideredFooterHeight]);\n}\n"]}