@atlaskit/react-select 0.0.2
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/CHANGELOG.md +9 -0
- package/LICENSE.md +11 -0
- package/README.md +10 -0
- package/async/package.json +15 -0
- package/base/package.json +15 -0
- package/creatable/package.json +15 -0
- package/dist/cjs/accessibility/helpers.js +34 -0
- package/dist/cjs/accessibility/index.js +74 -0
- package/dist/cjs/async-creatable.js +27 -0
- package/dist/cjs/async.js +30 -0
- package/dist/cjs/builtins.js +18 -0
- package/dist/cjs/components/containers.js +100 -0
- package/dist/cjs/components/control.js +67 -0
- package/dist/cjs/components/group.js +79 -0
- package/dist/cjs/components/index.js +53 -0
- package/dist/cjs/components/indicators.js +214 -0
- package/dist/cjs/components/input.js +93 -0
- package/dist/cjs/components/internal/a11y-text.js +34 -0
- package/dist/cjs/components/internal/dummy-input.js +43 -0
- package/dist/cjs/components/internal/index.js +34 -0
- package/dist/cjs/components/internal/required-input.js +43 -0
- package/dist/cjs/components/internal/scroll-manager.js +57 -0
- package/dist/cjs/components/internal/use-scroll-capture.js +132 -0
- package/dist/cjs/components/internal/use-scroll-lock.js +149 -0
- package/dist/cjs/components/live-region.js +153 -0
- package/dist/cjs/components/menu.js +464 -0
- package/dist/cjs/components/multi-value.js +129 -0
- package/dist/cjs/components/option.js +62 -0
- package/dist/cjs/components/placeholder.js +39 -0
- package/dist/cjs/components/single-value.js +46 -0
- package/dist/cjs/creatable.js +30 -0
- package/dist/cjs/diacritics.js +274 -0
- package/dist/cjs/filters.js +50 -0
- package/dist/cjs/index.js +55 -0
- package/dist/cjs/nonce-provider.js +30 -0
- package/dist/cjs/select.js +1803 -0
- package/dist/cjs/state-manager.js +31 -0
- package/dist/cjs/styles.js +66 -0
- package/dist/cjs/theme.js +42 -0
- package/dist/cjs/types.js +5 -0
- package/dist/cjs/use-async.js +156 -0
- package/dist/cjs/use-creatable.js +114 -0
- package/dist/cjs/use-state-manager.js +83 -0
- package/dist/cjs/utils.js +357 -0
- package/dist/es2019/accessibility/helpers.js +24 -0
- package/dist/es2019/accessibility/index.js +72 -0
- package/dist/es2019/async-creatable.js +17 -0
- package/dist/es2019/async.js +16 -0
- package/dist/es2019/builtins.js +4 -0
- package/dist/es2019/components/containers.js +100 -0
- package/dist/es2019/components/control.js +62 -0
- package/dist/es2019/components/group.js +74 -0
- package/dist/es2019/components/index.js +41 -0
- package/dist/es2019/components/indicators.js +211 -0
- package/dist/es2019/components/input.js +88 -0
- package/dist/es2019/components/internal/a11y-text.js +25 -0
- package/dist/es2019/components/internal/dummy-input.js +36 -0
- package/dist/es2019/components/internal/index.js +4 -0
- package/dist/es2019/components/internal/required-input.js +35 -0
- package/dist/es2019/components/internal/scroll-manager.js +49 -0
- package/dist/es2019/components/internal/use-scroll-capture.js +128 -0
- package/dist/es2019/components/internal/use-scroll-lock.js +143 -0
- package/dist/es2019/components/live-region.js +151 -0
- package/dist/es2019/components/menu.js +466 -0
- package/dist/es2019/components/multi-value.js +134 -0
- package/dist/es2019/components/option.js +57 -0
- package/dist/es2019/components/placeholder.js +34 -0
- package/dist/es2019/components/single-value.js +41 -0
- package/dist/es2019/creatable.js +15 -0
- package/dist/es2019/diacritics.js +264 -0
- package/dist/es2019/filters.js +36 -0
- package/dist/es2019/index.js +8 -0
- package/dist/es2019/nonce-provider.js +19 -0
- package/dist/es2019/select.js +1766 -0
- package/dist/es2019/state-manager.js +22 -0
- package/dist/es2019/styles.js +56 -0
- package/dist/es2019/theme.js +36 -0
- package/dist/es2019/types.js +1 -0
- package/dist/es2019/use-async.js +117 -0
- package/dist/es2019/use-creatable.js +81 -0
- package/dist/es2019/use-state-manager.js +60 -0
- package/dist/es2019/utils.js +309 -0
- package/dist/esm/accessibility/helpers.js +24 -0
- package/dist/esm/accessibility/index.js +68 -0
- package/dist/esm/async-creatable.js +17 -0
- package/dist/esm/async.js +16 -0
- package/dist/esm/builtins.js +12 -0
- package/dist/esm/components/containers.js +96 -0
- package/dist/esm/components/control.js +62 -0
- package/dist/esm/components/group.js +74 -0
- package/dist/esm/components/index.js +43 -0
- package/dist/esm/components/indicators.js +209 -0
- package/dist/esm/components/input.js +88 -0
- package/dist/esm/components/internal/a11y-text.js +27 -0
- package/dist/esm/components/internal/dummy-input.js +37 -0
- package/dist/esm/components/internal/index.js +4 -0
- package/dist/esm/components/internal/required-input.js +36 -0
- package/dist/esm/components/internal/scroll-manager.js +49 -0
- package/dist/esm/components/internal/use-scroll-capture.js +126 -0
- package/dist/esm/components/internal/use-scroll-lock.js +143 -0
- package/dist/esm/components/live-region.js +148 -0
- package/dist/esm/components/menu.js +460 -0
- package/dist/esm/components/multi-value.js +122 -0
- package/dist/esm/components/option.js +57 -0
- package/dist/esm/components/placeholder.js +34 -0
- package/dist/esm/components/single-value.js +41 -0
- package/dist/esm/creatable.js +15 -0
- package/dist/esm/diacritics.js +268 -0
- package/dist/esm/filters.js +43 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/nonce-provider.js +20 -0
- package/dist/esm/select.js +1794 -0
- package/dist/esm/state-manager.js +22 -0
- package/dist/esm/styles.js +58 -0
- package/dist/esm/theme.js +36 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/use-async.js +149 -0
- package/dist/esm/use-creatable.js +107 -0
- package/dist/esm/use-state-manager.js +76 -0
- package/dist/esm/utils.js +328 -0
- package/dist/types/accessibility/helpers.d.ts +5 -0
- package/dist/types/accessibility/index.d.ts +125 -0
- package/dist/types/async-creatable.d.ts +10 -0
- package/dist/types/async.d.ts +9 -0
- package/dist/types/builtins.d.ts +5 -0
- package/dist/types/components/containers.d.ts +50 -0
- package/dist/types/components/control.d.ts +33 -0
- package/dist/types/components/group.d.ts +53 -0
- package/dist/types/components/index.d.ts +73 -0
- package/dist/types/components/indicators.d.ts +72 -0
- package/dist/types/components/input.d.ts +33 -0
- package/dist/types/components/internal/a11y-text.d.ts +8 -0
- package/dist/types/components/internal/dummy-input.d.ts +9 -0
- package/dist/types/components/internal/index.d.ts +4 -0
- package/dist/types/components/internal/required-input.d.ts +10 -0
- package/dist/types/components/internal/scroll-manager.d.ts +17 -0
- package/dist/types/components/internal/use-scroll-capture.d.ts +12 -0
- package/dist/types/components/internal/use-scroll-lock.d.ts +9 -0
- package/dist/types/components/live-region.d.ts +24 -0
- package/dist/types/components/menu.d.ts +130 -0
- package/dist/types/components/multi-value.d.ts +47 -0
- package/dist/types/components/option.d.ts +49 -0
- package/dist/types/components/placeholder.d.ts +22 -0
- package/dist/types/components/single-value.d.ts +28 -0
- package/dist/types/creatable.d.ts +10 -0
- package/dist/types/diacritics.d.ts +1 -0
- package/dist/types/filters.d.ts +15 -0
- package/dist/types/index.d.ts +28 -0
- package/dist/types/nonce-provider.d.ts +8 -0
- package/dist/types/select.d.ts +616 -0
- package/dist/types/state-manager.d.ts +17 -0
- package/dist/types/styles.d.ts +68 -0
- package/dist/types/theme.d.ts +27 -0
- package/dist/types/types.d.ts +134 -0
- package/dist/types/use-async.d.ts +31 -0
- package/dist/types/use-creatable.d.ts +46 -0
- package/dist/types/use-state-manager.d.ts +15 -0
- package/dist/types/utils.d.ts +44 -0
- package/dist/types-ts4.5/accessibility/helpers.d.ts +5 -0
- package/dist/types-ts4.5/accessibility/index.d.ts +125 -0
- package/dist/types-ts4.5/async-creatable.d.ts +10 -0
- package/dist/types-ts4.5/async.d.ts +9 -0
- package/dist/types-ts4.5/builtins.d.ts +5 -0
- package/dist/types-ts4.5/components/containers.d.ts +50 -0
- package/dist/types-ts4.5/components/control.d.ts +33 -0
- package/dist/types-ts4.5/components/group.d.ts +53 -0
- package/dist/types-ts4.5/components/index.d.ts +73 -0
- package/dist/types-ts4.5/components/indicators.d.ts +72 -0
- package/dist/types-ts4.5/components/input.d.ts +33 -0
- package/dist/types-ts4.5/components/internal/a11y-text.d.ts +8 -0
- package/dist/types-ts4.5/components/internal/dummy-input.d.ts +9 -0
- package/dist/types-ts4.5/components/internal/index.d.ts +4 -0
- package/dist/types-ts4.5/components/internal/required-input.d.ts +10 -0
- package/dist/types-ts4.5/components/internal/scroll-manager.d.ts +17 -0
- package/dist/types-ts4.5/components/internal/use-scroll-capture.d.ts +12 -0
- package/dist/types-ts4.5/components/internal/use-scroll-lock.d.ts +9 -0
- package/dist/types-ts4.5/components/live-region.d.ts +24 -0
- package/dist/types-ts4.5/components/menu.d.ts +130 -0
- package/dist/types-ts4.5/components/multi-value.d.ts +47 -0
- package/dist/types-ts4.5/components/option.d.ts +49 -0
- package/dist/types-ts4.5/components/placeholder.d.ts +22 -0
- package/dist/types-ts4.5/components/single-value.d.ts +28 -0
- package/dist/types-ts4.5/creatable.d.ts +10 -0
- package/dist/types-ts4.5/diacritics.d.ts +1 -0
- package/dist/types-ts4.5/filters.d.ts +15 -0
- package/dist/types-ts4.5/index.d.ts +28 -0
- package/dist/types-ts4.5/nonce-provider.d.ts +8 -0
- package/dist/types-ts4.5/select.d.ts +616 -0
- package/dist/types-ts4.5/state-manager.d.ts +17 -0
- package/dist/types-ts4.5/styles.d.ts +68 -0
- package/dist/types-ts4.5/theme.d.ts +27 -0
- package/dist/types-ts4.5/types.d.ts +134 -0
- package/dist/types-ts4.5/use-async.d.ts +31 -0
- package/dist/types-ts4.5/use-creatable.d.ts +46 -0
- package/dist/types-ts4.5/use-state-manager.d.ts +15 -0
- package/dist/types-ts4.5/utils.d.ts +44 -0
- package/package.json +83 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/**
|
|
3
|
+
* @jsxRuntime classic
|
|
4
|
+
* @jsx jsx
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { jsx } from '@emotion/react';
|
|
8
|
+
import { cleanCommonProps, getStyleProps } from '../utils';
|
|
9
|
+
export const groupCSS = ({
|
|
10
|
+
theme: {
|
|
11
|
+
spacing
|
|
12
|
+
}
|
|
13
|
+
}, unstyled) => unstyled ? {} : {
|
|
14
|
+
paddingBottom: spacing.baseUnit * 2,
|
|
15
|
+
paddingTop: spacing.baseUnit * 2
|
|
16
|
+
};
|
|
17
|
+
const Group = props => {
|
|
18
|
+
const {
|
|
19
|
+
children,
|
|
20
|
+
cx,
|
|
21
|
+
getStyles,
|
|
22
|
+
getClassNames,
|
|
23
|
+
Heading,
|
|
24
|
+
headingProps,
|
|
25
|
+
innerProps,
|
|
26
|
+
label,
|
|
27
|
+
theme,
|
|
28
|
+
selectProps
|
|
29
|
+
} = props;
|
|
30
|
+
return jsx("div", _extends({}, getStyleProps(props, 'group', {
|
|
31
|
+
group: true
|
|
32
|
+
}), innerProps), jsx(Heading, _extends({}, headingProps, {
|
|
33
|
+
selectProps: selectProps
|
|
34
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
35
|
+
,
|
|
36
|
+
theme: theme,
|
|
37
|
+
getStyles: getStyles,
|
|
38
|
+
getClassNames: getClassNames,
|
|
39
|
+
cx: cx
|
|
40
|
+
}), label), jsx("div", null, children));
|
|
41
|
+
};
|
|
42
|
+
export const groupHeadingCSS = ({
|
|
43
|
+
theme: {
|
|
44
|
+
colors,
|
|
45
|
+
spacing
|
|
46
|
+
}
|
|
47
|
+
}, unstyled) => ({
|
|
48
|
+
label: 'group',
|
|
49
|
+
cursor: 'default',
|
|
50
|
+
display: 'block',
|
|
51
|
+
...(unstyled ? {} : {
|
|
52
|
+
color: colors.neutral40,
|
|
53
|
+
fontSize: '75%',
|
|
54
|
+
fontWeight: 500,
|
|
55
|
+
marginBottom: '0.25em',
|
|
56
|
+
paddingLeft: spacing.baseUnit * 3,
|
|
57
|
+
paddingRight: spacing.baseUnit * 3,
|
|
58
|
+
textTransform: 'uppercase'
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
63
|
+
export const GroupHeading = props => {
|
|
64
|
+
const {
|
|
65
|
+
data,
|
|
66
|
+
...innerProps
|
|
67
|
+
} = cleanCommonProps(props);
|
|
68
|
+
return jsx("div", _extends({}, getStyleProps(props, 'groupHeading', {
|
|
69
|
+
'group-heading': true
|
|
70
|
+
}), innerProps));
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
74
|
+
export default Group;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { IndicatorsContainer, SelectContainer, ValueContainer } from './containers';
|
|
2
|
+
import Control from './control';
|
|
3
|
+
import Group, { GroupHeading } from './group';
|
|
4
|
+
import { ClearIndicator, CrossIcon, DownChevron, DropdownIndicator, IndicatorSeparator, LoadingIndicator } from './indicators';
|
|
5
|
+
import Input from './input';
|
|
6
|
+
import Menu, { LoadingMessage, MenuList, MenuPortal, NoOptionsMessage } from './menu';
|
|
7
|
+
import MultiValue, { MultiValueContainer, MultiValueLabel, MultiValueRemove } from './multi-value';
|
|
8
|
+
import Option from './option';
|
|
9
|
+
import Placeholder from './placeholder';
|
|
10
|
+
import SingleValue from './single-value';
|
|
11
|
+
export const components = {
|
|
12
|
+
ClearIndicator: ClearIndicator,
|
|
13
|
+
Control: Control,
|
|
14
|
+
DropdownIndicator: DropdownIndicator,
|
|
15
|
+
DownChevron: DownChevron,
|
|
16
|
+
CrossIcon: CrossIcon,
|
|
17
|
+
Group: Group,
|
|
18
|
+
GroupHeading: GroupHeading,
|
|
19
|
+
IndicatorsContainer: IndicatorsContainer,
|
|
20
|
+
IndicatorSeparator: IndicatorSeparator,
|
|
21
|
+
Input: Input,
|
|
22
|
+
LoadingIndicator: LoadingIndicator,
|
|
23
|
+
Menu: Menu,
|
|
24
|
+
MenuList: MenuList,
|
|
25
|
+
MenuPortal: MenuPortal,
|
|
26
|
+
LoadingMessage: LoadingMessage,
|
|
27
|
+
NoOptionsMessage: NoOptionsMessage,
|
|
28
|
+
MultiValue: MultiValue,
|
|
29
|
+
MultiValueContainer: MultiValueContainer,
|
|
30
|
+
MultiValueLabel: MultiValueLabel,
|
|
31
|
+
MultiValueRemove: MultiValueRemove,
|
|
32
|
+
Option: Option,
|
|
33
|
+
Placeholder: Placeholder,
|
|
34
|
+
SelectContainer: SelectContainer,
|
|
35
|
+
SingleValue: SingleValue,
|
|
36
|
+
ValueContainer: ValueContainer
|
|
37
|
+
};
|
|
38
|
+
export const defaultComponents = props => ({
|
|
39
|
+
...components,
|
|
40
|
+
...props.components
|
|
41
|
+
});
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/**
|
|
3
|
+
* @jsxRuntime classic
|
|
4
|
+
* @jsx jsx
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { css, jsx, keyframes } from '@emotion/react';
|
|
8
|
+
import { getStyleProps } from '../utils';
|
|
9
|
+
|
|
10
|
+
// ==============================
|
|
11
|
+
// Dropdown & Clear Icons
|
|
12
|
+
// ==============================
|
|
13
|
+
|
|
14
|
+
const styles = css({
|
|
15
|
+
display: 'inline-block',
|
|
16
|
+
fill: 'currentColor',
|
|
17
|
+
lineHeight: 1,
|
|
18
|
+
stroke: 'currentColor',
|
|
19
|
+
strokeWidth: 0
|
|
20
|
+
});
|
|
21
|
+
const Svg = ({
|
|
22
|
+
size,
|
|
23
|
+
...props
|
|
24
|
+
}) => jsx("svg", _extends({
|
|
25
|
+
height: size,
|
|
26
|
+
width: size,
|
|
27
|
+
viewBox: "0 0 20 20",
|
|
28
|
+
"aria-hidden": "true",
|
|
29
|
+
focusable: "false",
|
|
30
|
+
css: styles
|
|
31
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
32
|
+
}, props));
|
|
33
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
34
|
+
export const CrossIcon = props =>
|
|
35
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
36
|
+
jsx(Svg, _extends({
|
|
37
|
+
size: 20
|
|
38
|
+
}, props), jsx("path", {
|
|
39
|
+
d: "M14.348 14.849c-0.469 0.469-1.229 0.469-1.697 0l-2.651-3.030-2.651 3.029c-0.469 0.469-1.229 0.469-1.697 0-0.469-0.469-0.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-0.469-0.469-0.469-1.228 0-1.697s1.228-0.469 1.697 0l2.652 3.031 2.651-3.031c0.469-0.469 1.228-0.469 1.697 0s0.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c0.469 0.469 0.469 1.229 0 1.698z"
|
|
40
|
+
}));
|
|
41
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
42
|
+
export const DownChevron = props =>
|
|
43
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
44
|
+
jsx(Svg, _extends({
|
|
45
|
+
size: 20
|
|
46
|
+
}, props), jsx("path", {
|
|
47
|
+
d: "M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
// ==============================
|
|
51
|
+
// Dropdown & Clear Buttons
|
|
52
|
+
// ==============================
|
|
53
|
+
|
|
54
|
+
const baseCSS = ({
|
|
55
|
+
isFocused,
|
|
56
|
+
theme: {
|
|
57
|
+
spacing: {
|
|
58
|
+
baseUnit
|
|
59
|
+
},
|
|
60
|
+
colors
|
|
61
|
+
}
|
|
62
|
+
}, unstyled) => ({
|
|
63
|
+
label: 'indicatorContainer',
|
|
64
|
+
display: 'flex',
|
|
65
|
+
transition: 'color 150ms',
|
|
66
|
+
...(unstyled ? {} : {
|
|
67
|
+
color: isFocused ? colors.neutral60 : colors.neutral20,
|
|
68
|
+
padding: baseUnit * 2,
|
|
69
|
+
':hover': {
|
|
70
|
+
color: isFocused ? colors.neutral80 : colors.neutral40
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
});
|
|
74
|
+
export const dropdownIndicatorCSS = baseCSS;
|
|
75
|
+
|
|
76
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
77
|
+
export const DropdownIndicator = props => {
|
|
78
|
+
const {
|
|
79
|
+
children,
|
|
80
|
+
innerProps
|
|
81
|
+
} = props;
|
|
82
|
+
return jsx("div", _extends({}, getStyleProps(props, 'dropdownIndicator', {
|
|
83
|
+
indicator: true,
|
|
84
|
+
'dropdown-indicator': true
|
|
85
|
+
}), innerProps), children || jsx(DownChevron, null));
|
|
86
|
+
};
|
|
87
|
+
export const clearIndicatorCSS = baseCSS;
|
|
88
|
+
|
|
89
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
90
|
+
export const ClearIndicator = props => {
|
|
91
|
+
const {
|
|
92
|
+
children,
|
|
93
|
+
innerProps
|
|
94
|
+
} = props;
|
|
95
|
+
return jsx("div", _extends({}, getStyleProps(props, 'clearIndicator', {
|
|
96
|
+
indicator: true,
|
|
97
|
+
'clear-indicator': true
|
|
98
|
+
}), innerProps), children || jsx(CrossIcon, null));
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// ==============================
|
|
102
|
+
// Separator
|
|
103
|
+
// ==============================
|
|
104
|
+
|
|
105
|
+
export const indicatorSeparatorCSS = ({
|
|
106
|
+
isDisabled,
|
|
107
|
+
theme: {
|
|
108
|
+
spacing: {
|
|
109
|
+
baseUnit
|
|
110
|
+
},
|
|
111
|
+
colors
|
|
112
|
+
}
|
|
113
|
+
}, unstyled) => ({
|
|
114
|
+
label: 'indicatorSeparator',
|
|
115
|
+
alignSelf: 'stretch',
|
|
116
|
+
width: 1,
|
|
117
|
+
...(unstyled ? {} : {
|
|
118
|
+
backgroundColor: isDisabled ? colors.neutral10 : colors.neutral20,
|
|
119
|
+
marginBottom: baseUnit * 2,
|
|
120
|
+
marginTop: baseUnit * 2
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
125
|
+
export const IndicatorSeparator = props => {
|
|
126
|
+
const {
|
|
127
|
+
innerProps
|
|
128
|
+
} = props;
|
|
129
|
+
return jsx("span", _extends({}, innerProps, getStyleProps(props, 'indicatorSeparator', {
|
|
130
|
+
'indicator-separator': true
|
|
131
|
+
})));
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// ==============================
|
|
135
|
+
// Loading
|
|
136
|
+
// ==============================
|
|
137
|
+
|
|
138
|
+
const loadingDotAnimations = keyframes({
|
|
139
|
+
'0%, 80%, 100%': {
|
|
140
|
+
opacity: 0
|
|
141
|
+
},
|
|
142
|
+
'40%': {
|
|
143
|
+
opacity: 1
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
export const loadingIndicatorCSS = ({
|
|
147
|
+
isFocused,
|
|
148
|
+
size,
|
|
149
|
+
theme: {
|
|
150
|
+
colors,
|
|
151
|
+
spacing: {
|
|
152
|
+
baseUnit
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}, unstyled) => ({
|
|
156
|
+
label: 'loadingIndicator',
|
|
157
|
+
display: 'flex',
|
|
158
|
+
transition: 'color 150ms',
|
|
159
|
+
alignSelf: 'center',
|
|
160
|
+
fontSize: size,
|
|
161
|
+
lineHeight: 1,
|
|
162
|
+
marginRight: size,
|
|
163
|
+
textAlign: 'center',
|
|
164
|
+
verticalAlign: 'middle',
|
|
165
|
+
...(unstyled ? {} : {
|
|
166
|
+
color: isFocused ? colors.neutral60 : colors.neutral20,
|
|
167
|
+
padding: baseUnit * 2
|
|
168
|
+
})
|
|
169
|
+
});
|
|
170
|
+
const LoadingDot = ({
|
|
171
|
+
delay,
|
|
172
|
+
offset
|
|
173
|
+
}) => jsx("span", {
|
|
174
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
175
|
+
css: {
|
|
176
|
+
animation: `${loadingDotAnimations} 1s ease-in-out ${delay}ms infinite;`,
|
|
177
|
+
backgroundColor: 'currentColor',
|
|
178
|
+
borderRadius: '1em',
|
|
179
|
+
display: 'inline-block',
|
|
180
|
+
marginLeft: offset ? '1em' : undefined,
|
|
181
|
+
height: '1em',
|
|
182
|
+
verticalAlign: 'top',
|
|
183
|
+
width: '1em'
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
187
|
+
export const LoadingIndicator = ({
|
|
188
|
+
innerProps,
|
|
189
|
+
isRtl,
|
|
190
|
+
size = 4,
|
|
191
|
+
...restProps
|
|
192
|
+
}) => {
|
|
193
|
+
return jsx("div", _extends({}, getStyleProps({
|
|
194
|
+
...restProps,
|
|
195
|
+
innerProps,
|
|
196
|
+
isRtl,
|
|
197
|
+
size
|
|
198
|
+
}, 'loadingIndicator', {
|
|
199
|
+
indicator: true,
|
|
200
|
+
'loading-indicator': true
|
|
201
|
+
}), innerProps), jsx(LoadingDot, {
|
|
202
|
+
delay: 0,
|
|
203
|
+
offset: isRtl
|
|
204
|
+
}), jsx(LoadingDot, {
|
|
205
|
+
delay: 160,
|
|
206
|
+
offset: true
|
|
207
|
+
}), jsx(LoadingDot, {
|
|
208
|
+
delay: 320,
|
|
209
|
+
offset: !isRtl
|
|
210
|
+
}));
|
|
211
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/**
|
|
3
|
+
* @jsxRuntime classic
|
|
4
|
+
* @jsx jsx
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { jsx } from '@emotion/react';
|
|
8
|
+
import { cleanCommonProps, getStyleProps } from '../utils';
|
|
9
|
+
export const inputCSS = ({
|
|
10
|
+
isDisabled,
|
|
11
|
+
value,
|
|
12
|
+
theme: {
|
|
13
|
+
spacing,
|
|
14
|
+
colors
|
|
15
|
+
}
|
|
16
|
+
}, unstyled) => ({
|
|
17
|
+
visibility: isDisabled ? 'hidden' : 'visible',
|
|
18
|
+
// force css to recompute when value change due to @emotion bug.
|
|
19
|
+
// We can remove it whenever the bug is fixed.
|
|
20
|
+
transform: value ? 'translateZ(0)' : '',
|
|
21
|
+
...containerStyle,
|
|
22
|
+
...(unstyled ? {} : {
|
|
23
|
+
margin: spacing.baseUnit / 2,
|
|
24
|
+
paddingBottom: spacing.baseUnit / 2,
|
|
25
|
+
paddingTop: spacing.baseUnit / 2,
|
|
26
|
+
color: colors.neutral80
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
const spacingStyle = {
|
|
30
|
+
gridArea: '1 / 2',
|
|
31
|
+
font: 'inherit',
|
|
32
|
+
minWidth: '2px',
|
|
33
|
+
border: 0,
|
|
34
|
+
margin: 0,
|
|
35
|
+
outline: 0,
|
|
36
|
+
padding: 0
|
|
37
|
+
};
|
|
38
|
+
const containerStyle = {
|
|
39
|
+
flex: '1 1 auto',
|
|
40
|
+
display: 'inline-grid',
|
|
41
|
+
gridArea: '1 / 1 / 2 / 3',
|
|
42
|
+
gridTemplateColumns: '0 min-content',
|
|
43
|
+
'&:after': {
|
|
44
|
+
content: 'attr(data-value) " "',
|
|
45
|
+
visibility: 'hidden',
|
|
46
|
+
whiteSpace: 'pre',
|
|
47
|
+
...spacingStyle
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const inputStyle = isHidden => ({
|
|
51
|
+
label: 'input',
|
|
52
|
+
color: 'inherit',
|
|
53
|
+
background: 0,
|
|
54
|
+
opacity: isHidden ? 0 : 1,
|
|
55
|
+
width: '100%',
|
|
56
|
+
...spacingStyle
|
|
57
|
+
});
|
|
58
|
+
const Input = props => {
|
|
59
|
+
const {
|
|
60
|
+
cx,
|
|
61
|
+
value
|
|
62
|
+
} = props;
|
|
63
|
+
const {
|
|
64
|
+
innerRef,
|
|
65
|
+
isDisabled,
|
|
66
|
+
isHidden,
|
|
67
|
+
inputClassName,
|
|
68
|
+
...innerProps
|
|
69
|
+
} = cleanCommonProps(props);
|
|
70
|
+
return jsx("div", _extends({}, getStyleProps(props, 'input', {
|
|
71
|
+
'input-container': true
|
|
72
|
+
}), {
|
|
73
|
+
"data-value": value || ''
|
|
74
|
+
}), jsx("input", _extends({
|
|
75
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
76
|
+
className: cx({
|
|
77
|
+
input: true
|
|
78
|
+
}, inputClassName),
|
|
79
|
+
ref: innerRef
|
|
80
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
81
|
+
,
|
|
82
|
+
style: inputStyle(isHidden),
|
|
83
|
+
disabled: isDisabled
|
|
84
|
+
}, innerProps)));
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
88
|
+
export default Input;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/**
|
|
3
|
+
* @jsxRuntime classic
|
|
4
|
+
* @jsx jsx
|
|
5
|
+
*/
|
|
6
|
+
import { css, jsx } from '@emotion/react';
|
|
7
|
+
|
|
8
|
+
// Assistive text to describe visual elements. Hidden for sighted users.
|
|
9
|
+
const styles = css({
|
|
10
|
+
width: 1,
|
|
11
|
+
height: 1,
|
|
12
|
+
padding: 0,
|
|
13
|
+
position: 'absolute',
|
|
14
|
+
zIndex: 9999,
|
|
15
|
+
border: 0,
|
|
16
|
+
clip: 'rect(1px, 1px, 1px, 1px)',
|
|
17
|
+
label: 'a11yText',
|
|
18
|
+
overflow: 'hidden',
|
|
19
|
+
whiteSpace: 'nowrap'
|
|
20
|
+
});
|
|
21
|
+
const A11yText = props => jsx("span", _extends({
|
|
22
|
+
css: styles
|
|
23
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
24
|
+
}, props));
|
|
25
|
+
export default A11yText;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/**
|
|
3
|
+
* @jsxRuntime classic
|
|
4
|
+
* @jsx jsx
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { css, jsx } from '@emotion/react';
|
|
8
|
+
import { removeProps } from '../../utils';
|
|
9
|
+
const dummyInputStyles = css({
|
|
10
|
+
width: 1,
|
|
11
|
+
padding: 0,
|
|
12
|
+
position: 'relative',
|
|
13
|
+
background: 0,
|
|
14
|
+
border: 0,
|
|
15
|
+
caretColor: 'transparent',
|
|
16
|
+
color: 'transparent',
|
|
17
|
+
fontSize: 'inherit',
|
|
18
|
+
gridArea: '1 / 1 / 2 / 3',
|
|
19
|
+
insetInlineStart: -100,
|
|
20
|
+
label: 'dummyInput',
|
|
21
|
+
opacity: 0,
|
|
22
|
+
outline: 0,
|
|
23
|
+
transform: 'scale(.01)'
|
|
24
|
+
});
|
|
25
|
+
export default function DummyInput({
|
|
26
|
+
innerRef,
|
|
27
|
+
...props
|
|
28
|
+
}) {
|
|
29
|
+
// Remove animation props not meant for HTML elements
|
|
30
|
+
const filteredProps = removeProps(props, 'onExited', 'in', 'enter', 'exit', 'appear');
|
|
31
|
+
return jsx("input", _extends({
|
|
32
|
+
ref: innerRef
|
|
33
|
+
}, filteredProps, {
|
|
34
|
+
css: dummyInputStyles
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { css, jsx } from '@emotion/react';
|
|
7
|
+
import __noop from '@atlaskit/ds-lib/noop';
|
|
8
|
+
const styles = css({
|
|
9
|
+
width: '100%',
|
|
10
|
+
position: 'absolute',
|
|
11
|
+
insetBlockEnd: 0,
|
|
12
|
+
insetInlineEnd: 0,
|
|
13
|
+
insetInlineStart: 0,
|
|
14
|
+
label: 'requiredInput',
|
|
15
|
+
opacity: 0,
|
|
16
|
+
pointerEvents: 'none'
|
|
17
|
+
});
|
|
18
|
+
const RequiredInput = ({
|
|
19
|
+
name,
|
|
20
|
+
onFocus
|
|
21
|
+
}) => jsx("input", {
|
|
22
|
+
required: true,
|
|
23
|
+
name: name,
|
|
24
|
+
tabIndex: -1,
|
|
25
|
+
"aria-hidden": "true",
|
|
26
|
+
onFocus: onFocus,
|
|
27
|
+
css: styles
|
|
28
|
+
// Prevent `Switching from uncontrolled to controlled` error
|
|
29
|
+
,
|
|
30
|
+
value: "",
|
|
31
|
+
onChange: __noop
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
35
|
+
export default RequiredInput;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import { Fragment } from 'react';
|
|
6
|
+
import { css, jsx } from '@emotion/react';
|
|
7
|
+
import useScrollCapture from './use-scroll-capture';
|
|
8
|
+
import useScrollLock from './use-scroll-lock';
|
|
9
|
+
const styles = css({
|
|
10
|
+
position: 'fixed',
|
|
11
|
+
insetBlockEnd: 0,
|
|
12
|
+
insetBlockStart: 0,
|
|
13
|
+
insetInlineEnd: 0,
|
|
14
|
+
insetInlineStart: 0
|
|
15
|
+
});
|
|
16
|
+
const blurSelectInput = event => {
|
|
17
|
+
const element = event.target;
|
|
18
|
+
return element.ownerDocument.activeElement && element.ownerDocument.activeElement.blur();
|
|
19
|
+
};
|
|
20
|
+
export default function ScrollManager({
|
|
21
|
+
children,
|
|
22
|
+
lockEnabled,
|
|
23
|
+
captureEnabled = true,
|
|
24
|
+
onBottomArrive,
|
|
25
|
+
onBottomLeave,
|
|
26
|
+
onTopArrive,
|
|
27
|
+
onTopLeave
|
|
28
|
+
}) {
|
|
29
|
+
const setScrollCaptureTarget = useScrollCapture({
|
|
30
|
+
isEnabled: captureEnabled,
|
|
31
|
+
onBottomArrive,
|
|
32
|
+
onBottomLeave,
|
|
33
|
+
onTopArrive,
|
|
34
|
+
onTopLeave
|
|
35
|
+
});
|
|
36
|
+
const setScrollLockTarget = useScrollLock({
|
|
37
|
+
isEnabled: lockEnabled
|
|
38
|
+
});
|
|
39
|
+
const targetRef = element => {
|
|
40
|
+
setScrollCaptureTarget(element);
|
|
41
|
+
setScrollLockTarget(element);
|
|
42
|
+
};
|
|
43
|
+
return jsx(Fragment, null, lockEnabled &&
|
|
44
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
45
|
+
jsx("div", {
|
|
46
|
+
onClick: blurSelectInput,
|
|
47
|
+
css: styles
|
|
48
|
+
}), children(targetRef));
|
|
49
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import { supportsPassiveEvents } from '../../utils';
|
|
3
|
+
const cancelScroll = event => {
|
|
4
|
+
if (event.cancelable) {
|
|
5
|
+
event.preventDefault();
|
|
6
|
+
}
|
|
7
|
+
event.stopPropagation();
|
|
8
|
+
};
|
|
9
|
+
// TODO: Fill in the hook {description}.
|
|
10
|
+
/**
|
|
11
|
+
* {description}.
|
|
12
|
+
*/
|
|
13
|
+
export default function useScrollCapture({
|
|
14
|
+
isEnabled,
|
|
15
|
+
onBottomArrive,
|
|
16
|
+
onBottomLeave,
|
|
17
|
+
onTopArrive,
|
|
18
|
+
onTopLeave
|
|
19
|
+
}) {
|
|
20
|
+
const isBottom = useRef(false);
|
|
21
|
+
const isTop = useRef(false);
|
|
22
|
+
const touchStart = useRef(0);
|
|
23
|
+
const scrollTarget = useRef(null);
|
|
24
|
+
const handleEventDelta = useCallback((event, delta) => {
|
|
25
|
+
if (scrollTarget.current === null) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const {
|
|
29
|
+
scrollTop,
|
|
30
|
+
scrollHeight,
|
|
31
|
+
clientHeight
|
|
32
|
+
} = scrollTarget.current;
|
|
33
|
+
const target = scrollTarget.current;
|
|
34
|
+
const isDeltaPositive = delta > 0;
|
|
35
|
+
const availableScroll = scrollHeight - clientHeight - scrollTop;
|
|
36
|
+
let shouldCancelScroll = false;
|
|
37
|
+
|
|
38
|
+
// reset bottom/top flags
|
|
39
|
+
if (availableScroll > delta && isBottom.current) {
|
|
40
|
+
if (onBottomLeave) {
|
|
41
|
+
onBottomLeave(event);
|
|
42
|
+
}
|
|
43
|
+
isBottom.current = false;
|
|
44
|
+
}
|
|
45
|
+
if (isDeltaPositive && isTop.current) {
|
|
46
|
+
if (onTopLeave) {
|
|
47
|
+
onTopLeave(event);
|
|
48
|
+
}
|
|
49
|
+
isTop.current = false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// bottom limit
|
|
53
|
+
if (isDeltaPositive && delta > availableScroll) {
|
|
54
|
+
if (onBottomArrive && !isBottom.current) {
|
|
55
|
+
onBottomArrive(event);
|
|
56
|
+
}
|
|
57
|
+
target.scrollTop = scrollHeight;
|
|
58
|
+
shouldCancelScroll = true;
|
|
59
|
+
isBottom.current = true;
|
|
60
|
+
|
|
61
|
+
// top limit
|
|
62
|
+
} else if (!isDeltaPositive && -delta > scrollTop) {
|
|
63
|
+
if (onTopArrive && !isTop.current) {
|
|
64
|
+
onTopArrive(event);
|
|
65
|
+
}
|
|
66
|
+
target.scrollTop = 0;
|
|
67
|
+
shouldCancelScroll = true;
|
|
68
|
+
isTop.current = true;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// cancel scroll
|
|
72
|
+
if (shouldCancelScroll) {
|
|
73
|
+
cancelScroll(event);
|
|
74
|
+
}
|
|
75
|
+
}, [onBottomArrive, onBottomLeave, onTopArrive, onTopLeave]);
|
|
76
|
+
const onWheel = useCallback(event => {
|
|
77
|
+
handleEventDelta(event, event.deltaY);
|
|
78
|
+
}, [handleEventDelta]);
|
|
79
|
+
const onTouchStart = useCallback(event => {
|
|
80
|
+
// set touch start so we can calculate touchmove delta
|
|
81
|
+
touchStart.current = event.changedTouches[0].clientY;
|
|
82
|
+
}, []);
|
|
83
|
+
const onTouchMove = useCallback(event => {
|
|
84
|
+
const deltaY = touchStart.current - event.changedTouches[0].clientY;
|
|
85
|
+
handleEventDelta(event, deltaY);
|
|
86
|
+
}, [handleEventDelta]);
|
|
87
|
+
const startListening = useCallback(el => {
|
|
88
|
+
// bail early if no element is available to attach to
|
|
89
|
+
if (!el) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const notPassive = supportsPassiveEvents ? {
|
|
93
|
+
passive: false
|
|
94
|
+
} : false;
|
|
95
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
96
|
+
el.addEventListener('wheel', onWheel, notPassive);
|
|
97
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
98
|
+
el.addEventListener('touchstart', onTouchStart, notPassive);
|
|
99
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
100
|
+
el.addEventListener('touchmove', onTouchMove, notPassive);
|
|
101
|
+
}, [onTouchMove, onTouchStart, onWheel]);
|
|
102
|
+
const stopListening = useCallback(el => {
|
|
103
|
+
// bail early if no element is available to detach from
|
|
104
|
+
if (!el) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
109
|
+
el.removeEventListener('wheel', onWheel, false);
|
|
110
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
111
|
+
el.removeEventListener('touchstart', onTouchStart, false);
|
|
112
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
113
|
+
el.removeEventListener('touchmove', onTouchMove, false);
|
|
114
|
+
}, [onTouchMove, onTouchStart, onWheel]);
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
if (!isEnabled) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const element = scrollTarget.current;
|
|
120
|
+
startListening(element);
|
|
121
|
+
return () => {
|
|
122
|
+
stopListening(element);
|
|
123
|
+
};
|
|
124
|
+
}, [isEnabled, startListening, stopListening]);
|
|
125
|
+
return element => {
|
|
126
|
+
scrollTarget.current = element;
|
|
127
|
+
};
|
|
128
|
+
}
|