@cloudscape-design/components-themeable 3.0.953 → 3.0.955
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/internal/manifest.json +1 -1
- package/lib/internal/scss/popover/container.scss +48 -0
- package/lib/internal/scss/table/resizer/styles.scss +1 -1
- package/lib/internal/template/app-layout/visual-refresh-toolbar/toolbar/trigger-button/index.d.ts.map +1 -1
- package/lib/internal/template/app-layout/visual-refresh-toolbar/toolbar/trigger-button/index.js +4 -10
- package/lib/internal/template/app-layout/visual-refresh-toolbar/toolbar/trigger-button/index.js.map +1 -1
- package/lib/internal/template/breadcrumb-group/item/item.d.ts.map +1 -1
- package/lib/internal/template/breadcrumb-group/item/item.js +9 -18
- package/lib/internal/template/breadcrumb-group/item/item.js.map +1 -1
- package/lib/internal/template/code-editor/resizable-box/index.d.ts.map +1 -1
- package/lib/internal/template/code-editor/resizable-box/index.js +2 -0
- package/lib/internal/template/code-editor/resizable-box/index.js.map +1 -1
- package/lib/internal/template/internal/environment.js +1 -1
- package/lib/internal/template/internal/environment.json +1 -1
- package/lib/internal/template/popover/styles.css.js +54 -54
- package/lib/internal/template/popover/styles.scoped.css +101 -77
- package/lib/internal/template/popover/styles.selectors.js +54 -54
- package/lib/internal/template/slider/internal.d.ts.map +1 -1
- package/lib/internal/template/slider/internal.js +48 -47
- package/lib/internal/template/slider/internal.js.map +1 -1
- package/lib/internal/template/table/resizer/styles.css.js +8 -8
- package/lib/internal/template/table/resizer/styles.scoped.css +18 -18
- package/lib/internal/template/table/resizer/styles.selectors.js +8 -8
- package/package.json +1 -1
- package/lib/internal/template/internal/components/tooltip/registry.d.ts +0 -4
- package/lib/internal/template/internal/components/tooltip/registry.d.ts.map +0 -1
- package/lib/internal/template/internal/components/tooltip/registry.js +0 -28
- package/lib/internal/template/internal/components/tooltip/registry.js.map +0 -1
|
@@ -75,58 +75,59 @@ export default function InternalSlider(_a) {
|
|
|
75
75
|
};
|
|
76
76
|
const thumbSize = readOnly ? THUMB_READONLY_SIZE : THUMB_SIZE;
|
|
77
77
|
return (React.createElement("div", Object.assign({}, baseProps, { ref: __internalRootRef, className: clsx(baseProps.className, styles.root) }),
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
React.createElement("div", { className: clsx(styles['slider-track'], {
|
|
86
|
-
[styles.disabled]: disabled,
|
|
78
|
+
React.createElement("div", { onMouseEnter: () => {
|
|
79
|
+
setShowTooltip(true);
|
|
80
|
+
}, onMouseLeave: () => {
|
|
81
|
+
setShowTooltip(false);
|
|
82
|
+
} },
|
|
83
|
+
showTooltip && (React.createElement(Tooltip, { value: valueFormatter ? valueFormatter(sliderValue) : sliderValue, trackRef: handleRef, onDismiss: () => setShowTooltip(false) })),
|
|
84
|
+
React.createElement("div", { ref: handleRef, className: clsx(styles['tooltip-thumb'], {
|
|
87
85
|
[styles.readonly]: readOnly,
|
|
88
|
-
})
|
|
89
|
-
|
|
86
|
+
}), style: {
|
|
87
|
+
[customCssProps.sliderTooltipPosition]: `calc(${percent}% - ${thumbSize}px)`,
|
|
88
|
+
} }),
|
|
89
|
+
React.createElement("div", { className: styles.slider },
|
|
90
|
+
React.createElement("div", { className: clsx(styles['slider-track'], {
|
|
91
|
+
[styles.disabled]: disabled,
|
|
92
|
+
[styles.readonly]: readOnly,
|
|
93
|
+
}) }),
|
|
94
|
+
!hideFillLine && (React.createElement("div", { className: clsx(styles['slider-range'], {
|
|
95
|
+
[styles.error]: invalid,
|
|
96
|
+
[styles.warning]: showWarning,
|
|
97
|
+
[styles.active]: isActive,
|
|
98
|
+
[styles['error-active']]: invalid && isActive,
|
|
99
|
+
[styles['warning-active']]: showWarning && isActive,
|
|
100
|
+
[styles.disabled]: disabled,
|
|
101
|
+
[styles.readonly]: readOnly,
|
|
102
|
+
}), style: { [customCssProps.sliderRangeInlineSize]: `${percent}%` } }))),
|
|
103
|
+
!!step && tickMarks && (React.createElement(SliderTickMarks, { hideFillLine: hideFillLine, disabled: disabled, readOnly: readOnly, invalid: invalid, warning: warning, isActive: isActive, step: step, min: min, max: max, value: sliderValue })),
|
|
104
|
+
React.createElement("input", {
|
|
105
|
+
// we need to add this because input[type=range] isn't natively focusable in Safari.
|
|
106
|
+
tabIndex: 0, "aria-label": ariaLabel, "aria-labelledby": ariaLabel && !rest.ariaLabelledby ? undefined : ariaLabelledby, "aria-describedby": valueFormatter ? (ariaDescribedby ? `${labelsId} ${ariaDescribedby}` : labelsId) : ariaDescribedby, "aria-valuetext": getAriaValueText(), "aria-invalid": invalid ? 'true' : undefined, "aria-disabled": readOnly && !disabled ? 'true' : undefined, id: controlId, type: "range", min: min, max: max, disabled: disabled, onFocus: () => {
|
|
107
|
+
setShowTooltip(true);
|
|
108
|
+
setIsActive(true);
|
|
109
|
+
}, onBlur: () => {
|
|
110
|
+
setShowTooltip(false);
|
|
111
|
+
setIsActive(false);
|
|
112
|
+
}, onTouchStart: () => {
|
|
113
|
+
setShowTooltip(true);
|
|
114
|
+
setIsActive(true);
|
|
115
|
+
}, onTouchEnd: () => {
|
|
116
|
+
setShowTooltip(false);
|
|
117
|
+
setIsActive(false);
|
|
118
|
+
}, step: step, value: sliderValue, onChange: event => {
|
|
119
|
+
if (readOnly) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
fireNonCancelableEvent(onChange, { value: Number(event.target.value) });
|
|
123
|
+
}, className: clsx(styles.thumb, {
|
|
90
124
|
[styles.error]: invalid,
|
|
91
125
|
[styles.warning]: showWarning,
|
|
92
|
-
[styles.active]: isActive,
|
|
93
|
-
[styles['error-active']]: invalid && isActive,
|
|
94
|
-
[styles['warning-active']]: showWarning && isActive,
|
|
95
126
|
[styles.disabled]: disabled,
|
|
96
127
|
[styles.readonly]: readOnly,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
// we need to add this because input[type=range] isn't natively focusable in Safari.
|
|
101
|
-
tabIndex: 0, "aria-label": ariaLabel, "aria-labelledby": ariaLabel && !rest.ariaLabelledby ? undefined : ariaLabelledby, "aria-describedby": valueFormatter ? (ariaDescribedby ? `${labelsId} ${ariaDescribedby}` : labelsId) : ariaDescribedby, "aria-valuetext": getAriaValueText(), "aria-invalid": invalid ? 'true' : undefined, "aria-disabled": readOnly && !disabled ? 'true' : undefined, id: controlId, type: "range", min: min, max: max, disabled: disabled, onFocus: () => {
|
|
102
|
-
setShowTooltip(true);
|
|
103
|
-
setIsActive(true);
|
|
104
|
-
}, onBlur: () => {
|
|
105
|
-
setShowTooltip(false);
|
|
106
|
-
setIsActive(false);
|
|
107
|
-
}, onMouseEnter: () => {
|
|
108
|
-
setShowTooltip(true);
|
|
109
|
-
}, onMouseLeave: () => {
|
|
110
|
-
setShowTooltip(false);
|
|
111
|
-
}, onTouchStart: () => {
|
|
112
|
-
setShowTooltip(true);
|
|
113
|
-
setIsActive(true);
|
|
114
|
-
}, onTouchEnd: () => {
|
|
115
|
-
setShowTooltip(false);
|
|
116
|
-
setIsActive(false);
|
|
117
|
-
}, step: step, value: sliderValue, onChange: event => {
|
|
118
|
-
if (readOnly) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
onChange && fireNonCancelableEvent(onChange, { value: Number(event.target.value) });
|
|
122
|
-
}, className: clsx(styles.thumb, {
|
|
123
|
-
[styles.error]: invalid,
|
|
124
|
-
[styles.warning]: showWarning,
|
|
125
|
-
[styles.disabled]: disabled,
|
|
126
|
-
[styles.readonly]: readOnly,
|
|
127
|
-
[styles.min]: sliderValue <= min || max < min,
|
|
128
|
-
[styles.max]: sliderValue >= max && min < max,
|
|
129
|
-
}) }),
|
|
128
|
+
[styles.min]: sliderValue <= min || max < min,
|
|
129
|
+
[styles.max]: sliderValue >= max && min < max,
|
|
130
|
+
}) })),
|
|
130
131
|
React.createElement(SliderLabels, { min: min, max: max, referenceValues: referenceValues, valueFormatter: valueFormatter, labelsId: labelsId, ariaDescription: ariaDescription })));
|
|
131
132
|
}
|
|
132
133
|
//# sourceMappingURL=internal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/slider/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,OAAO,MAAM,yCAAyC,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,cAAc,MAAM,sDAAsD,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAEvE,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,eAAe,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACL,wBAAwB,EACxB,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,UAAU,EACV,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAIrC,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAiBjB;QAjBiB,EACrC,KAAK,EACL,GAAG,EACH,GAAG,EACH,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,eAAe,EACf,eAAe,EACf,SAAS,EACT,YAAY,EACZ,cAAc,EACd,WAAW,EACX,iBAAiB,GAAG,IAAI,OAEJ,EADjB,IAAI,cAhB8B,yMAiBtC,CADQ;IAEP,MAAM,SAAS,GAAG,YAAY,CAAC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AAc,CAAC,KAAK,CAAC,CAAC;gBACtB,WAAW,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC,EACD,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,KAAK,CAAC,EAAE;gBAChB,IAAI,QAAQ,EAAE;oBACZ,OAAO;iBACR;gBAED,QAAQ,IAAI,sBAAsB,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACtF,CAAC,EACD,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;gBAC5B,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO;gBACvB,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,WAAW;gBAC7B,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ;gBAC3B,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ;gBAC3B,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,WAAW,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG;gBAC7C,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,WAAW,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG;aAC9C,CAAC,GACF;QAEF,oBAAC,YAAY,IACX,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,eAAe,GAChC,CACE,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useInternalI18n } from '../i18n/context';\nimport { getBaseProps } from '../internal/base-component/index.js';\nimport Tooltip from '../internal/components/tooltip/index.js';\nimport { useFormFieldContext } from '../internal/context/form-field-context.js';\nimport { fireNonCancelableEvent } from '../internal/events/index.js';\nimport customCssProps from '../internal/generated/custom-css-properties/index.js';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useUniqueId } from '../internal/hooks/use-unique-id/index.js';\nimport { SliderProps } from './interfaces.js';\nimport SliderLabels from './slider-labels.js';\nimport SliderTickMarks from './tick-marks.js';\nimport {\n findLowerAndHigherValues,\n getPercent,\n getStepArray,\n THUMB_READONLY_SIZE,\n THUMB_SIZE,\n valuesAreValid,\n} from './utils.js';\n\nimport styles from './styles.css.js';\n\ninterface InternalSliderProps extends SliderProps, InternalBaseComponentProps {}\n\nexport default function InternalSlider({\n value,\n min,\n max,\n onChange,\n step,\n disabled,\n readOnly,\n ariaLabel,\n ariaDescription,\n referenceValues,\n tickMarks,\n hideFillLine,\n valueFormatter,\n i18nStrings,\n __internalRootRef = null,\n ...rest\n}: InternalSliderProps) {\n const baseProps = getBaseProps(rest);\n const i18n = useInternalI18n('slider');\n\n const handleRef = useRef<HTMLDivElement>(null);\n const [showTooltip, setShowTooltip] = useState(false);\n const [isActive, setIsActive] = useState(false);\n const labelsId = useUniqueId('labels');\n const { ariaLabelledby, ariaDescribedby, controlId, invalid, warning } = useFormFieldContext(rest);\n\n const showWarning = warning && !invalid;\n\n if (referenceValues && valuesAreValid(referenceValues) === false) {\n warnOnce('Slider', 'All reference values must be integers. Non-integer values will not be displayed.');\n }\n\n if (min >= max) {\n warnOnce('Slider', 'The min value cannot be greater than the max value.');\n }\n\n if (step && step > max - min) {\n warnOnce('Slider', 'The step value cannot be greater than the difference between the min and max.');\n }\n\n if (step && value !== undefined && (value - min) % step !== 0) {\n warnOnce('Slider', 'Slider value must be a multiple of the step. The value will round to the nearest step value.');\n }\n\n const getValue = () => {\n const stepIsValid = step && step < max - min && step > min;\n\n if (value === undefined) {\n // this is the default html input's fallback value\n return max < min ? min : min + (max - min) / 2;\n }\n\n if (!step) {\n return value;\n }\n\n // if the value is not a multiple of the step, then find the closest step\n // and make that the value (this is also the native input behavior)\n if (step && stepIsValid && (value - min) % step !== 0) {\n const closest = getStepArray(step, [min, max]).reduce(function (prev, curr) {\n return Math.abs(curr - value) < Math.abs(prev - value) ? curr : prev;\n });\n\n return closest;\n }\n\n return value;\n };\n\n const sliderValue = getValue();\n const percent = getPercent(Math.max(Math.min(sliderValue, max), min), [min, max]);\n\n const getAriaValueText = () => {\n if (valueFormatter && valueFormatter(sliderValue)) {\n return valueFormatter(sliderValue);\n }\n\n if (valueFormatter && !valueFormatter(sliderValue)) {\n const middleValues = referenceValues ? referenceValues : [];\n const valueArray = [min, ...middleValues, sliderValue, max];\n const prevAndNext = findLowerAndHigherValues(valueArray, sliderValue);\n const previousValue = prevAndNext.lower ? valueFormatter(prevAndNext.lower) : valueFormatter(min);\n const nextValue = prevAndNext.higher ? valueFormatter(prevAndNext.higher) : valueFormatter(max);\n const value = sliderValue;\n\n return i18n('i18nStrings.valueTextRange', i18nStrings?.valueTextRange(previousValue, value, nextValue), format =>\n format({ value, previousValue, nextValue })\n );\n }\n\n return undefined;\n };\n\n const thumbSize = readOnly ? THUMB_READONLY_SIZE : THUMB_SIZE;\n\n return (\n <div {...baseProps} ref={__internalRootRef} className={clsx(baseProps.className, styles.root)}>\n {showTooltip && (\n <Tooltip\n value={valueFormatter ? valueFormatter(sliderValue) : sliderValue}\n trackRef={handleRef}\n onDismiss={() => setShowTooltip(false)}\n />\n )}\n <div\n ref={handleRef}\n className={clsx(styles['tooltip-thumb'], {\n [styles.readonly]: readOnly,\n })}\n style={{\n [customCssProps.sliderTooltipPosition]: `calc(${percent}% - ${thumbSize}px)`,\n }}\n />\n <div className={styles.slider}>\n <div\n className={clsx(styles['slider-track'], {\n [styles.disabled]: disabled,\n [styles.readonly]: readOnly,\n })}\n />\n\n {!hideFillLine && (\n <div\n className={clsx(styles['slider-range'], {\n [styles.error]: invalid,\n [styles.warning]: showWarning,\n [styles.active]: isActive,\n [styles['error-active']]: invalid && isActive,\n [styles['warning-active']]: showWarning && isActive,\n [styles.disabled]: disabled,\n [styles.readonly]: readOnly,\n })}\n style={{ [customCssProps.sliderRangeInlineSize]: `${percent}%` }}\n />\n )}\n </div>\n {!!step && tickMarks && (\n <SliderTickMarks\n hideFillLine={hideFillLine}\n disabled={disabled}\n readOnly={readOnly}\n invalid={invalid}\n warning={warning}\n isActive={isActive}\n step={step}\n min={min}\n max={max}\n value={sliderValue}\n />\n )}\n\n <input\n // we need to add this because input[type=range] isn't natively focusable in Safari.\n tabIndex={0}\n aria-label={ariaLabel}\n // aria-labelledby has precedence over aria-label in accessible name calculation.\n // When aria-label is provided for Input, it should override aria-labelledBy from form-field context.\n // If both aria-label and aria-labelledby come from Input props, aria-labelledby will be used in accessible name\n aria-labelledby={ariaLabel && !rest.ariaLabelledby ? undefined : ariaLabelledby}\n // Slider labels, if present and something other than numbers, should be associated to the input with aria-describedby\n aria-describedby={\n valueFormatter ? (ariaDescribedby ? `${labelsId} ${ariaDescribedby}` : labelsId) : ariaDescribedby\n }\n aria-valuetext={getAriaValueText()}\n aria-invalid={invalid ? 'true' : undefined}\n aria-disabled={readOnly && !disabled ? 'true' : undefined}\n id={controlId}\n type=\"range\"\n min={min}\n max={max}\n disabled={disabled}\n onFocus={() => {\n setShowTooltip(true);\n setIsActive(true);\n }}\n onBlur={() => {\n setShowTooltip(false);\n setIsActive(false);\n }}\n onMouseEnter={() => {\n setShowTooltip(true);\n }}\n onMouseLeave={() => {\n setShowTooltip(false);\n }}\n onTouchStart={() => {\n setShowTooltip(true);\n setIsActive(true);\n }}\n onTouchEnd={() => {\n setShowTooltip(false);\n setIsActive(false);\n }}\n step={step}\n value={sliderValue}\n onChange={event => {\n if (readOnly) {\n return;\n }\n\n onChange && fireNonCancelableEvent(onChange, { value: Number(event.target.value) });\n }}\n className={clsx(styles.thumb, {\n [styles.error]: invalid,\n [styles.warning]: showWarning,\n [styles.disabled]: disabled,\n [styles.readonly]: readOnly,\n [styles.min]: sliderValue <= min || max < min,\n [styles.max]: sliderValue >= max && min < max,\n })}\n />\n\n <SliderLabels\n min={min}\n max={max}\n referenceValues={referenceValues}\n valueFormatter={valueFormatter}\n labelsId={labelsId}\n ariaDescription={ariaDescription}\n />\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/slider/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,OAAO,MAAM,yCAAyC,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,cAAc,MAAM,sDAAsD,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAEvE,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,eAAe,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACL,wBAAwB,EACxB,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,UAAU,EACV,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAIrC,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAiBjB;QAjBiB,EACrC,KAAK,EACL,GAAG,EACH,GAAG,EACH,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,eAAe,EACf,eAAe,EACf,SAAS,EACT,YAAY,EACZ,cAAc,EAC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EAAE;oBACjB,cAAc,CAAC,IAAI,CAAC,CAAC;oBACrB,WAAW,CAAC,IAAI,CAAC,CAAC;gBACpB,CAAC,EACD,UAAU,EAAE,GAAG,EAAE;oBACf,cAAc,CAAC,KAAK,CAAC,CAAC;oBACtB,WAAW,CAAC,KAAK,CAAC,CAAC;gBACrB,CAAC,EACD,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,KAAK,CAAC,EAAE;oBAChB,IAAI,QAAQ,EAAE;wBACZ,OAAO;qBACR;oBACD,sBAAsB,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBAC1E,CAAC,EACD,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;oBAC5B,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO;oBACvB,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,WAAW;oBAC7B,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ;oBAC3B,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ;oBAC3B,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,WAAW,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG;oBAC7C,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,WAAW,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG;iBAC9C,CAAC,GACF,CACE;QAEN,oBAAC,YAAY,IACX,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,eAAe,GAChC,CACE,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useInternalI18n } from '../i18n/context';\nimport { getBaseProps } from '../internal/base-component/index.js';\nimport Tooltip from '../internal/components/tooltip/index.js';\nimport { useFormFieldContext } from '../internal/context/form-field-context.js';\nimport { fireNonCancelableEvent } from '../internal/events/index.js';\nimport customCssProps from '../internal/generated/custom-css-properties/index.js';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useUniqueId } from '../internal/hooks/use-unique-id/index.js';\nimport { SliderProps } from './interfaces.js';\nimport SliderLabels from './slider-labels.js';\nimport SliderTickMarks from './tick-marks.js';\nimport {\n findLowerAndHigherValues,\n getPercent,\n getStepArray,\n THUMB_READONLY_SIZE,\n THUMB_SIZE,\n valuesAreValid,\n} from './utils.js';\n\nimport styles from './styles.css.js';\n\ninterface InternalSliderProps extends SliderProps, InternalBaseComponentProps {}\n\nexport default function InternalSlider({\n value,\n min,\n max,\n onChange,\n step,\n disabled,\n readOnly,\n ariaLabel,\n ariaDescription,\n referenceValues,\n tickMarks,\n hideFillLine,\n valueFormatter,\n i18nStrings,\n __internalRootRef = null,\n ...rest\n}: InternalSliderProps) {\n const baseProps = getBaseProps(rest);\n const i18n = useInternalI18n('slider');\n\n const handleRef = useRef<HTMLDivElement>(null);\n const [showTooltip, setShowTooltip] = useState(false);\n const [isActive, setIsActive] = useState(false);\n const labelsId = useUniqueId('labels');\n const { ariaLabelledby, ariaDescribedby, controlId, invalid, warning } = useFormFieldContext(rest);\n\n const showWarning = warning && !invalid;\n\n if (referenceValues && valuesAreValid(referenceValues) === false) {\n warnOnce('Slider', 'All reference values must be integers. Non-integer values will not be displayed.');\n }\n\n if (min >= max) {\n warnOnce('Slider', 'The min value cannot be greater than the max value.');\n }\n\n if (step && step > max - min) {\n warnOnce('Slider', 'The step value cannot be greater than the difference between the min and max.');\n }\n\n if (step && value !== undefined && (value - min) % step !== 0) {\n warnOnce('Slider', 'Slider value must be a multiple of the step. The value will round to the nearest step value.');\n }\n\n const getValue = () => {\n const stepIsValid = step && step < max - min && step > min;\n\n if (value === undefined) {\n // this is the default html input's fallback value\n return max < min ? min : min + (max - min) / 2;\n }\n\n if (!step) {\n return value;\n }\n\n // if the value is not a multiple of the step, then find the closest step\n // and make that the value (this is also the native input behavior)\n if (step && stepIsValid && (value - min) % step !== 0) {\n const closest = getStepArray(step, [min, max]).reduce(function (prev, curr) {\n return Math.abs(curr - value) < Math.abs(prev - value) ? curr : prev;\n });\n\n return closest;\n }\n\n return value;\n };\n\n const sliderValue = getValue();\n const percent = getPercent(Math.max(Math.min(sliderValue, max), min), [min, max]);\n\n const getAriaValueText = () => {\n if (valueFormatter && valueFormatter(sliderValue)) {\n return valueFormatter(sliderValue);\n }\n\n if (valueFormatter && !valueFormatter(sliderValue)) {\n const middleValues = referenceValues ? referenceValues : [];\n const valueArray = [min, ...middleValues, sliderValue, max];\n const prevAndNext = findLowerAndHigherValues(valueArray, sliderValue);\n const previousValue = prevAndNext.lower ? valueFormatter(prevAndNext.lower) : valueFormatter(min);\n const nextValue = prevAndNext.higher ? valueFormatter(prevAndNext.higher) : valueFormatter(max);\n const value = sliderValue;\n\n return i18n('i18nStrings.valueTextRange', i18nStrings?.valueTextRange(previousValue, value, nextValue), format =>\n format({ value, previousValue, nextValue })\n );\n }\n\n return undefined;\n };\n\n const thumbSize = readOnly ? THUMB_READONLY_SIZE : THUMB_SIZE;\n\n return (\n <div {...baseProps} ref={__internalRootRef} className={clsx(baseProps.className, styles.root)}>\n <div\n onMouseEnter={() => {\n setShowTooltip(true);\n }}\n onMouseLeave={() => {\n setShowTooltip(false);\n }}\n >\n {showTooltip && (\n <Tooltip\n value={valueFormatter ? valueFormatter(sliderValue) : sliderValue}\n trackRef={handleRef}\n onDismiss={() => setShowTooltip(false)}\n />\n )}\n <div\n ref={handleRef}\n className={clsx(styles['tooltip-thumb'], {\n [styles.readonly]: readOnly,\n })}\n style={{\n [customCssProps.sliderTooltipPosition]: `calc(${percent}% - ${thumbSize}px)`,\n }}\n />\n <div className={styles.slider}>\n <div\n className={clsx(styles['slider-track'], {\n [styles.disabled]: disabled,\n [styles.readonly]: readOnly,\n })}\n />\n\n {!hideFillLine && (\n <div\n className={clsx(styles['slider-range'], {\n [styles.error]: invalid,\n [styles.warning]: showWarning,\n [styles.active]: isActive,\n [styles['error-active']]: invalid && isActive,\n [styles['warning-active']]: showWarning && isActive,\n [styles.disabled]: disabled,\n [styles.readonly]: readOnly,\n })}\n style={{ [customCssProps.sliderRangeInlineSize]: `${percent}%` }}\n />\n )}\n </div>\n {!!step && tickMarks && (\n <SliderTickMarks\n hideFillLine={hideFillLine}\n disabled={disabled}\n readOnly={readOnly}\n invalid={invalid}\n warning={warning}\n isActive={isActive}\n step={step}\n min={min}\n max={max}\n value={sliderValue}\n />\n )}\n\n <input\n // we need to add this because input[type=range] isn't natively focusable in Safari.\n tabIndex={0}\n aria-label={ariaLabel}\n // aria-labelledby has precedence over aria-label in accessible name calculation.\n // When aria-label is provided for Input, it should override aria-labelledBy from form-field context.\n // If both aria-label and aria-labelledby come from Input props, aria-labelledby will be used in accessible name\n aria-labelledby={ariaLabel && !rest.ariaLabelledby ? undefined : ariaLabelledby}\n // Slider labels, if present and something other than numbers, should be associated to the input with aria-describedby\n aria-describedby={\n valueFormatter ? (ariaDescribedby ? `${labelsId} ${ariaDescribedby}` : labelsId) : ariaDescribedby\n }\n aria-valuetext={getAriaValueText()}\n aria-invalid={invalid ? 'true' : undefined}\n aria-disabled={readOnly && !disabled ? 'true' : undefined}\n id={controlId}\n type=\"range\"\n min={min}\n max={max}\n disabled={disabled}\n onFocus={() => {\n setShowTooltip(true);\n setIsActive(true);\n }}\n onBlur={() => {\n setShowTooltip(false);\n setIsActive(false);\n }}\n onTouchStart={() => {\n setShowTooltip(true);\n setIsActive(true);\n }}\n onTouchEnd={() => {\n setShowTooltip(false);\n setIsActive(false);\n }}\n step={step}\n value={sliderValue}\n onChange={event => {\n if (readOnly) {\n return;\n }\n fireNonCancelableEvent(onChange, { value: Number(event.target.value) });\n }}\n className={clsx(styles.thumb, {\n [styles.error]: invalid,\n [styles.warning]: showWarning,\n [styles.disabled]: disabled,\n [styles.readonly]: readOnly,\n [styles.min]: sliderValue <= min || max < min,\n [styles.max]: sliderValue >= max && min < max,\n })}\n />\n </div>\n\n <SliderLabels\n min={min}\n max={max}\n referenceValues={referenceValues}\n valueFormatter={valueFormatter}\n labelsId={labelsId}\n ariaDescription={ariaDescription}\n />\n </div>\n );\n}\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"resize-active": "awsui_resize-
|
|
5
|
-
"resize-active-with-focus": "awsui_resize-active-with-
|
|
6
|
-
"divider": "
|
|
7
|
-
"divider-disabled": "awsui_divider-
|
|
8
|
-
"divider-active": "awsui_divider-
|
|
9
|
-
"resizer": "
|
|
10
|
-
"has-focus": "awsui_has-
|
|
11
|
-
"tracker": "
|
|
4
|
+
"resize-active": "awsui_resize-active_x7peu_833mk_145",
|
|
5
|
+
"resize-active-with-focus": "awsui_resize-active-with-focus_x7peu_833mk_145",
|
|
6
|
+
"divider": "awsui_divider_x7peu_833mk_150",
|
|
7
|
+
"divider-disabled": "awsui_divider-disabled_x7peu_833mk_164",
|
|
8
|
+
"divider-active": "awsui_divider-active_x7peu_833mk_167",
|
|
9
|
+
"resizer": "awsui_resizer_x7peu_833mk_171",
|
|
10
|
+
"has-focus": "awsui_has-focus_x7peu_833mk_225",
|
|
11
|
+
"tracker": "awsui_tracker_x7peu_833mk_250"
|
|
12
12
|
};
|
|
13
13
|
|
|
@@ -142,13 +142,13 @@
|
|
|
142
142
|
*/
|
|
143
143
|
/* Style used for links in slots/components that are text heavy, to help links stand out among
|
|
144
144
|
surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F73#description */
|
|
145
|
-
.awsui_resize-
|
|
145
|
+
.awsui_resize-active_x7peu_833mk_145:not(#\9):not(.awsui_resize-active-with-focus_x7peu_833mk_145) * {
|
|
146
146
|
cursor: col-resize;
|
|
147
147
|
-webkit-user-select: none;
|
|
148
148
|
user-select: none;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
th:not(#\9):not(:last-child) > .
|
|
151
|
+
th:not(#\9):not(:last-child) > .awsui_divider_x7peu_833mk_150 {
|
|
152
152
|
position: absolute;
|
|
153
153
|
outline: none;
|
|
154
154
|
pointer-events: none;
|
|
@@ -162,14 +162,14 @@ th:not(#\9):not(:last-child) > .awsui_divider_x7peu_qs89i_150 {
|
|
|
162
162
|
border-inline-start: var(--border-item-width-bjacxs, 1px) solid var(--color-border-divider-interactive-default-f75ypy, #687078);
|
|
163
163
|
box-sizing: border-box;
|
|
164
164
|
}
|
|
165
|
-
th:not(#\9):not(:last-child) > .awsui_divider-
|
|
165
|
+
th:not(#\9):not(:last-child) > .awsui_divider-disabled_x7peu_833mk_164 {
|
|
166
166
|
border-inline-start-color: var(--color-border-divider-default-u5ytia, #eaeded);
|
|
167
167
|
}
|
|
168
|
-
th:not(#\9):not(:last-child) > .awsui_divider-
|
|
168
|
+
th:not(#\9):not(:last-child) > .awsui_divider-active_x7peu_833mk_167 {
|
|
169
169
|
border-inline-start: 2px solid var(--color-border-divider-active-kx4xyy, #687078);
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
.
|
|
172
|
+
.awsui_resizer_x7peu_833mk_171:not(#\9) {
|
|
173
173
|
border-collapse: separate;
|
|
174
174
|
border-spacing: 0;
|
|
175
175
|
box-sizing: border-box;
|
|
@@ -206,32 +206,32 @@ th:not(#\9):not(:last-child) > .awsui_divider-active_x7peu_qs89i_167 {
|
|
|
206
206
|
inset-block: 0;
|
|
207
207
|
cursor: col-resize;
|
|
208
208
|
position: absolute;
|
|
209
|
-
inset-inline-end: calc(-1 * var(--space-
|
|
210
|
-
inline-size: var(--space-
|
|
209
|
+
inset-inline-end: calc(-1 * var(--space-xl-vss8pc, 24px) / 2);
|
|
210
|
+
inline-size: var(--space-xl-vss8pc, 24px);
|
|
211
211
|
z-index: 10;
|
|
212
212
|
}
|
|
213
|
-
.
|
|
213
|
+
.awsui_resizer_x7peu_833mk_171:not(#\9):focus {
|
|
214
214
|
outline: none;
|
|
215
215
|
text-decoration: none;
|
|
216
216
|
}
|
|
217
|
-
.awsui_resize-
|
|
217
|
+
.awsui_resize-active_x7peu_833mk_145 .awsui_resizer_x7peu_833mk_171:not(#\9) {
|
|
218
218
|
pointer-events: none;
|
|
219
219
|
}
|
|
220
|
-
th:not(#\9):last-child > .
|
|
221
|
-
inline-size: calc(var(--space-
|
|
220
|
+
th:not(#\9):last-child > .awsui_resizer_x7peu_833mk_171 {
|
|
221
|
+
inline-size: calc(var(--space-xl-vss8pc, 24px) / 2);
|
|
222
222
|
inset-inline-end: 0;
|
|
223
223
|
}
|
|
224
|
-
.
|
|
224
|
+
.awsui_resizer_x7peu_833mk_171:not(#\9):hover + .awsui_divider_x7peu_833mk_150 {
|
|
225
225
|
border-inline-start: 2px solid var(--color-border-divider-active-kx4xyy, #687078);
|
|
226
226
|
}
|
|
227
|
-
body[data-awsui-focus-visible=true] .
|
|
227
|
+
body[data-awsui-focus-visible=true] .awsui_resizer_x7peu_833mk_171.awsui_has-focus_x7peu_833mk_225:not(#\9) {
|
|
228
228
|
position: relative;
|
|
229
229
|
}
|
|
230
|
-
body[data-awsui-focus-visible=true] .
|
|
230
|
+
body[data-awsui-focus-visible=true] .awsui_resizer_x7peu_833mk_171.awsui_has-focus_x7peu_833mk_225:not(#\9) {
|
|
231
231
|
outline: 2px dotted transparent;
|
|
232
232
|
outline-offset: calc(calc(var(--space-table-header-focus-outline-gutter-wak74p, 0px) - 2px) - 1px);
|
|
233
233
|
}
|
|
234
|
-
body[data-awsui-focus-visible=true] .
|
|
234
|
+
body[data-awsui-focus-visible=true] .awsui_resizer_x7peu_833mk_171.awsui_has-focus_x7peu_833mk_225:not(#\9)::before {
|
|
235
235
|
content: " ";
|
|
236
236
|
display: block;
|
|
237
237
|
position: absolute;
|
|
@@ -245,17 +245,17 @@ body[data-awsui-focus-visible=true] .awsui_resizer_x7peu_qs89i_171.awsui_has-foc
|
|
|
245
245
|
border-end-end-radius: var(--border-radius-control-default-focus-ring-vy2hlh, 2px);
|
|
246
246
|
box-shadow: 0 0 0 2px var(--color-border-item-focused-q68bgg, #0073bb);
|
|
247
247
|
}
|
|
248
|
-
body[data-awsui-focus-visible=true] .
|
|
248
|
+
body[data-awsui-focus-visible=true] .awsui_resizer_x7peu_833mk_171.awsui_has-focus_x7peu_833mk_225:not(#\9) {
|
|
249
249
|
position: absolute;
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
.
|
|
252
|
+
.awsui_tracker_x7peu_833mk_250:not(#\9) {
|
|
253
253
|
display: none;
|
|
254
254
|
position: absolute;
|
|
255
255
|
border-inline-start: var(--border-divider-list-width-x6rz7e, 1px) dashed var(--color-border-divider-active-kx4xyy, #687078);
|
|
256
256
|
inline-size: 0;
|
|
257
257
|
inset-block: 0;
|
|
258
258
|
}
|
|
259
|
-
.awsui_resize-
|
|
259
|
+
.awsui_resize-active_x7peu_833mk_145 .awsui_tracker_x7peu_833mk_250:not(#\9) {
|
|
260
260
|
display: block;
|
|
261
261
|
}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"resize-active": "awsui_resize-
|
|
6
|
-
"resize-active-with-focus": "awsui_resize-active-with-
|
|
7
|
-
"divider": "
|
|
8
|
-
"divider-disabled": "awsui_divider-
|
|
9
|
-
"divider-active": "awsui_divider-
|
|
10
|
-
"resizer": "
|
|
11
|
-
"has-focus": "awsui_has-
|
|
12
|
-
"tracker": "
|
|
5
|
+
"resize-active": "awsui_resize-active_x7peu_833mk_145",
|
|
6
|
+
"resize-active-with-focus": "awsui_resize-active-with-focus_x7peu_833mk_145",
|
|
7
|
+
"divider": "awsui_divider_x7peu_833mk_150",
|
|
8
|
+
"divider-disabled": "awsui_divider-disabled_x7peu_833mk_164",
|
|
9
|
+
"divider-active": "awsui_divider-active_x7peu_833mk_167",
|
|
10
|
+
"resizer": "awsui_resizer_x7peu_833mk_171",
|
|
11
|
+
"has-focus": "awsui_has-focus_x7peu_833mk_225",
|
|
12
|
+
"tracker": "awsui_tracker_x7peu_833mk_250"
|
|
13
13
|
};
|
|
14
14
|
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/tooltip/registry.ts"],"names":[],"mappings":"AAGA,KAAK,OAAO,GAAG,MAAM,IAAI,CAAC;AAW1B,eAAO,MAAM,eAAe,YAAa,OAAO,eAU/C,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
let callbacks = [];
|
|
4
|
-
let listenerRegistered = false;
|
|
5
|
-
const onKeyDown = (event) => {
|
|
6
|
-
if (event.key === 'Escape') {
|
|
7
|
-
callbacks.forEach(callback => callback());
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
export const registerTooltip = (onClose) => {
|
|
11
|
-
callbacks.forEach(callback => callback());
|
|
12
|
-
callbacks.push(onClose);
|
|
13
|
-
if (!listenerRegistered) {
|
|
14
|
-
listenerRegistered = true;
|
|
15
|
-
document.addEventListener('keydown', onKeyDown);
|
|
16
|
-
}
|
|
17
|
-
return () => {
|
|
18
|
-
deregisterTooltip(onClose);
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
const deregisterTooltip = (onClose) => {
|
|
22
|
-
callbacks = callbacks.filter(callback => callback !== onClose);
|
|
23
|
-
if (listenerRegistered && callbacks.length === 0) {
|
|
24
|
-
listenerRegistered = false;
|
|
25
|
-
document.removeEventListener('keydown', onKeyDown);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../../../src/internal/components/tooltip/registry.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAItC,IAAI,SAAS,GAAmB,EAAE,CAAC;AACnC,IAAI,kBAAkB,GAAG,KAAK,CAAC;AAE/B,MAAM,SAAS,GAAG,CAAC,KAAoB,EAAE,EAAE;IACzC,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE;QAC1B,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;KAC3C;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAgB,EAAE,EAAE;IAClD,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC1C,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxB,IAAI,CAAC,kBAAkB,EAAE;QACvB,kBAAkB,GAAG,IAAI,CAAC;QAC1B,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;KACjD;IACD,OAAO,GAAG,EAAE;QACV,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,OAAgB,EAAE,EAAE;IAC7C,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;IAC/D,IAAI,kBAAkB,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;QAChD,kBAAkB,GAAG,KAAK,CAAC;QAC3B,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;KACpD;AACH,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\ntype OnClose = () => void;\n\nlet callbacks: Array<OnClose> = [];\nlet listenerRegistered = false;\n\nconst onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n callbacks.forEach(callback => callback());\n }\n};\n\nexport const registerTooltip = (onClose: OnClose) => {\n callbacks.forEach(callback => callback());\n callbacks.push(onClose);\n if (!listenerRegistered) {\n listenerRegistered = true;\n document.addEventListener('keydown', onKeyDown);\n }\n return () => {\n deregisterTooltip(onClose);\n };\n};\n\nconst deregisterTooltip = (onClose: OnClose) => {\n callbacks = callbacks.filter(callback => callback !== onClose);\n if (listenerRegistered && callbacks.length === 0) {\n listenerRegistered = false;\n document.removeEventListener('keydown', onKeyDown);\n }\n};\n"]}
|