@autoguru/overdrive 4.24.0 → 4.25.0
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/dist/components/DropDown/DropDown.d.ts +23 -0
- package/dist/components/DropDown/DropDown.d.ts.map +1 -0
- package/dist/components/DropDown/DropDown.js +56 -0
- package/dist/components/DropDown/DropDownOption.css.d.ts +3 -0
- package/dist/components/DropDown/DropDownOption.css.d.ts.map +1 -0
- package/dist/components/DropDown/DropDownOption.css.js +26 -0
- package/dist/components/DropDown/DropDownOption.d.ts +12 -0
- package/dist/components/DropDown/DropDownOption.d.ts.map +1 -0
- package/dist/components/DropDown/DropDownOption.js +49 -0
- package/dist/components/DropDown/DropDownOptionsList.css.d.ts +3 -0
- package/dist/components/DropDown/DropDownOptionsList.css.d.ts.map +1 -0
- package/dist/components/DropDown/DropDownOptionsList.css.js +12 -0
- package/dist/components/DropDown/DropDownOptionsList.d.ts +8 -0
- package/dist/components/DropDown/DropDownOptionsList.d.ts.map +1 -0
- package/dist/components/DropDown/DropDownOptionsList.js +29 -0
- package/dist/components/DropDown/index.d.ts +3 -0
- package/dist/components/DropDown/index.d.ts.map +1 -0
- package/dist/components/DropDown/index.js +4 -0
- package/dist/components/DropDown/stories.js +79 -0
- package/dist/components/EditableText/EditableText.d.ts.map +1 -1
- package/dist/components/EditableText/EditableText.js +4 -2
- package/dist/components/MinimalModal/MinimalModal.d.ts.map +1 -1
- package/dist/components/Modal/Modal.d.ts.map +1 -1
- package/dist/components/NumberInput/NumberInput.d.ts +5 -1
- package/dist/components/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/components/NumberInput/NumberInput.js +27 -31
- package/dist/components/NumberInput/stories.js +18 -1
- package/dist/components/NumberInput/useNumberInputBehaviours.d.ts +20 -0
- package/dist/components/NumberInput/useNumberInputBehaviours.d.ts.map +1 -0
- package/dist/components/NumberInput/useNumberInputBehaviours.js +64 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -1
- package/dist/utils/refs.d.ts +2 -0
- package/dist/utils/refs.d.ts.map +1 -0
- package/dist/utils/refs.js +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IconType } from '@autoguru/icons';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { ComponentProps, ReactNode } from 'react';
|
|
4
|
+
import { Button } from '../Button';
|
|
5
|
+
import { Flyout } from '../Flyout';
|
|
6
|
+
import { EPositionerAlignment } from '../Positioner';
|
|
7
|
+
type ButtonProps = Omit<ComponentProps<typeof Button>, 'is' | 'children'>;
|
|
8
|
+
type FlyoutProps = Pick<ComponentProps<typeof Flyout>, 'alignment'>;
|
|
9
|
+
export interface Props extends ButtonProps, FlyoutProps {
|
|
10
|
+
options: ReactNode[];
|
|
11
|
+
label: string;
|
|
12
|
+
icon?: IconType;
|
|
13
|
+
}
|
|
14
|
+
export declare const DropDown: ({ options, label, icon, alignment, onClick: incomingOnClick, ...buttonProps }: {
|
|
15
|
+
[x: string]: any;
|
|
16
|
+
options: any;
|
|
17
|
+
label: any;
|
|
18
|
+
icon?: React.ReactElement<React.SVGAttributes<SVGElement>, "svg"> | undefined;
|
|
19
|
+
alignment?: EPositionerAlignment | undefined;
|
|
20
|
+
onClick: any;
|
|
21
|
+
}) => JSX.Element;
|
|
22
|
+
export default DropDown;
|
|
23
|
+
//# sourceMappingURL=DropDown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropDown.d.ts","sourceRoot":"","sources":["../../../lib/components/DropDown/DropDown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmB,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACN,cAAc,EAEd,SAAS,EAIT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAIrD,KAAK,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,EAAE,IAAI,GAAG,UAAU,CAAC,CAAC;AAC1E,KAAK,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;AAEpE,MAAM,WAAW,KAAM,SAAQ,WAAW,EAAE,WAAW;IACtD,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,QAAQ,CAAC;CAChB;AAED,eAAO,MAAM,QAAQ;;;;;;;iBAmCpB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
+
const _excluded = ["options", "label", "icon", "alignment", "onClick"];
|
|
6
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
|
+
import { ChevronDownIcon } from '@autoguru/icons';
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import { useCallback, useRef, useState } from 'react';
|
|
11
|
+
import { Button } from "../Button/index.js";
|
|
12
|
+
import { Flyout } from "../Flyout/index.js";
|
|
13
|
+
import { Icon } from "../Icon/index.js";
|
|
14
|
+
import { useOutsideClick } from "../OutsideClick/index.js";
|
|
15
|
+
import { EPositionerAlignment } from "../Positioner/index.js";
|
|
16
|
+
import { DropDownOptionsList } from "./DropDownOptionsList.js";
|
|
17
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
20
|
+
export const DropDown = _ref => {
|
|
21
|
+
let {
|
|
22
|
+
options,
|
|
23
|
+
label,
|
|
24
|
+
icon = ChevronDownIcon,
|
|
25
|
+
alignment = EPositionerAlignment.BOTTOM_LEFT,
|
|
26
|
+
onClick: incomingOnClick
|
|
27
|
+
} = _ref,
|
|
28
|
+
buttonProps = _objectWithoutProperties(_ref, _excluded);
|
|
29
|
+
const buttonRef = useRef(null);
|
|
30
|
+
const menuRef = useRef(null);
|
|
31
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
32
|
+
const onMenuClick = useCallback(event => {
|
|
33
|
+
if (typeof incomingOnClick === 'function') incomingOnClick(event);
|
|
34
|
+
setIsOpen(!isOpen);
|
|
35
|
+
}, [isOpen, incomingOnClick]);
|
|
36
|
+
useOutsideClick([menuRef], () => setIsOpen(false));
|
|
37
|
+
return _jsxs(_Fragment, {
|
|
38
|
+
children: [_jsxs(Button, _objectSpread(_objectSpread({
|
|
39
|
+
ref: buttonRef,
|
|
40
|
+
onClick: onMenuClick
|
|
41
|
+
}, buttonProps), {}, {
|
|
42
|
+
children: [label, _jsx(Icon, {
|
|
43
|
+
icon: icon
|
|
44
|
+
})]
|
|
45
|
+
})), _jsx(Flyout, {
|
|
46
|
+
triggerRef: buttonRef,
|
|
47
|
+
isOpen: isOpen,
|
|
48
|
+
alignment: alignment,
|
|
49
|
+
children: _jsx(DropDownOptionsList, {
|
|
50
|
+
ref: menuRef,
|
|
51
|
+
options: options
|
|
52
|
+
})
|
|
53
|
+
})]
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
export default DropDown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropDownOption.css.d.ts","sourceRoot":"","sources":["../../../lib/components/DropDown/DropDownOption.css.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,IAAI,QAOf,CAAC;AAEH,eAAO,MAAM,MAAM,QAWjB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import * as __vanilla_filescope__ from '@vanilla-extract/css/fileScope';
|
|
4
|
+
__vanilla_filescope__.setFileScope("lib/components/DropDown/DropDownOption.css.ts", "@autoguru/overdrive");
|
|
5
|
+
import { style } from '@vanilla-extract/css';
|
|
6
|
+
import { themeContractVars as vars } from "../../themes/theme.css.js";
|
|
7
|
+
export const root = style({
|
|
8
|
+
transition: 'background-color 0.2s cubic-bezier(0, 0, 0.2, 1) 0s',
|
|
9
|
+
cursor: 'pointer',
|
|
10
|
+
':hover': {
|
|
11
|
+
backgroundColor: vars.colours.background.light
|
|
12
|
+
}
|
|
13
|
+
}, "root");
|
|
14
|
+
export const action = style({
|
|
15
|
+
transition: "opacity 0.3s ".concat(vars.animation.easing.standard, " 0.1s"),
|
|
16
|
+
willChange: 'transform',
|
|
17
|
+
pointerEvents: 'none',
|
|
18
|
+
opacity: 0,
|
|
19
|
+
selectors: {
|
|
20
|
+
["".concat(root, ":hover &")]: {
|
|
21
|
+
opacity: '1',
|
|
22
|
+
pointerEvents: 'initial'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}, "action");
|
|
26
|
+
__vanilla_filescope__.endFileScope();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IconType } from '@autoguru/icons';
|
|
2
|
+
import { ComponentProps, FunctionComponent } from 'react';
|
|
3
|
+
import { Box } from '../Box';
|
|
4
|
+
import { Text } from '../Text';
|
|
5
|
+
interface Props extends Omit<ComponentProps<typeof Box>, 'paddingX' | 'paddingY'> {
|
|
6
|
+
icon?: IconType;
|
|
7
|
+
label: string;
|
|
8
|
+
iconColour?: ComponentProps<typeof Text>['colour'];
|
|
9
|
+
}
|
|
10
|
+
export declare const DropDownOption: FunctionComponent<Props>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=DropDownOption.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropDownOption.d.ts","sourceRoot":"","sources":["../../../lib/components/DropDown/DropDownOption.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG1D,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAG7B,OAAO,EAAE,IAAI,EAAiB,MAAM,SAAS,CAAC;AAI9C,UAAU,KACT,SAAQ,IAAI,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IACjE,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,cAAc,CAAC,OAAO,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC;CACnD;AAED,eAAO,MAAM,cAAc,EAAE,iBAAiB,CAAC,KAAK,CA+BnD,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
+
const _excluded = ["label", "icon", "className", "iconColour"];
|
|
6
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
import { Box } from "../Box/index.js";
|
|
10
|
+
import { Icon } from "../Icon/index.js";
|
|
11
|
+
import { Inline } from "../Inline/index.js";
|
|
12
|
+
import { Text, useTextStyles } from "../Text/index.js";
|
|
13
|
+
import * as styles from "./DropDownOption.css.js";
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
+
export const DropDownOption = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
label,
|
|
19
|
+
icon,
|
|
20
|
+
className,
|
|
21
|
+
iconColour = 'dark'
|
|
22
|
+
} = _ref,
|
|
23
|
+
boxProps = _objectWithoutProperties(_ref, _excluded);
|
|
24
|
+
const colourStyles = useTextStyles({
|
|
25
|
+
colour: iconColour
|
|
26
|
+
});
|
|
27
|
+
return _jsx(Box, _objectSpread(_objectSpread({
|
|
28
|
+
className: [styles.root, className]
|
|
29
|
+
}, boxProps), {}, {
|
|
30
|
+
paddingX: "3",
|
|
31
|
+
paddingY: "2",
|
|
32
|
+
children: _jsxs(Inline, {
|
|
33
|
+
noWrap: true,
|
|
34
|
+
space: "2",
|
|
35
|
+
width: "full",
|
|
36
|
+
alignX: "spaceBetween",
|
|
37
|
+
alignY: "center",
|
|
38
|
+
children: [_jsx(Text, {
|
|
39
|
+
is: "p",
|
|
40
|
+
size: "3",
|
|
41
|
+
children: label
|
|
42
|
+
}), icon ? _jsx(Icon, {
|
|
43
|
+
className: colourStyles,
|
|
44
|
+
size: "medium",
|
|
45
|
+
icon: icon
|
|
46
|
+
}) : null]
|
|
47
|
+
})
|
|
48
|
+
}));
|
|
49
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropDownOptionsList.css.d.ts","sourceRoot":"","sources":["../../../lib/components/DropDown/DropDownOptionsList.css.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,QAEf,CAAC;AACH,eAAO,MAAM,IAAI,QAEf,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import * as __vanilla_filescope__ from '@vanilla-extract/css/fileScope';
|
|
4
|
+
__vanilla_filescope__.setFileScope("lib/components/DropDown/DropDownOptionsList.css.ts", "@autoguru/overdrive");
|
|
5
|
+
import { style } from '@vanilla-extract/css';
|
|
6
|
+
export const root = style({
|
|
7
|
+
minWidth: 250
|
|
8
|
+
}, "root");
|
|
9
|
+
export const list = style({
|
|
10
|
+
maxHeight: 300
|
|
11
|
+
}, "list");
|
|
12
|
+
__vanilla_filescope__.endFileScope();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
interface Props {
|
|
4
|
+
options: ReactNode[];
|
|
5
|
+
}
|
|
6
|
+
export declare const DropDownOptionsList: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=DropDownOptionsList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropDownOptionsList.d.ts","sourceRoot":"","sources":["../../../lib/components/DropDown/DropDownOptionsList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAwB,SAAS,EAAE,MAAM,OAAO,CAAC;AAOxD,UAAU,KAAK;IACd,OAAO,EAAE,SAAS,EAAE,CAAC;CACrB;AAED,eAAO,MAAM,mBAAmB,8EAY/B,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { forwardRef, Fragment } from 'react';
|
|
5
|
+
import { Box } from "../Box/index.js";
|
|
6
|
+
import { Stack } from "../Stack/index.js";
|
|
7
|
+
import * as styles from "./DropDownOptionsList.css.js";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
export const DropDownOptionsList = forwardRef((_ref, ref) => {
|
|
10
|
+
let {
|
|
11
|
+
options
|
|
12
|
+
} = _ref;
|
|
13
|
+
return _jsx(Box, {
|
|
14
|
+
ref: ref,
|
|
15
|
+
className: styles.root,
|
|
16
|
+
children: _jsx(Box, {
|
|
17
|
+
className: styles.list,
|
|
18
|
+
overflow: "auto",
|
|
19
|
+
children: _jsx(Stack, {
|
|
20
|
+
dividers: true,
|
|
21
|
+
width: "full",
|
|
22
|
+
space: "none",
|
|
23
|
+
children: options.map((option, index) => _jsx(Fragment, {
|
|
24
|
+
children: option
|
|
25
|
+
}, index))
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/DropDown/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
import { DownloadIcon, TrashCanOutlineIcon } from '@autoguru/icons';
|
|
7
|
+
import { action } from '@storybook/addon-actions';
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
import { Box } from "../Box/index.js";
|
|
10
|
+
import { DropDown, DropDownOption } from "./index.js";
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
const onClick = action('onClick');
|
|
13
|
+
export default {
|
|
14
|
+
title: 'Components/DropDown',
|
|
15
|
+
component: DropDown,
|
|
16
|
+
decorators: [story => _jsx("div", {
|
|
17
|
+
style: {
|
|
18
|
+
display: 'grid',
|
|
19
|
+
gridGap: '12px',
|
|
20
|
+
gridAutoFlow: 'row dense'
|
|
21
|
+
},
|
|
22
|
+
children: story()
|
|
23
|
+
})],
|
|
24
|
+
argTypes: {
|
|
25
|
+
size: {
|
|
26
|
+
options: ['small', 'medium'],
|
|
27
|
+
defaultValue: 'medium',
|
|
28
|
+
control: {
|
|
29
|
+
type: 'select'
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
variant: {
|
|
33
|
+
options: ['primary', 'secondary', 'danger', 'information', 'warning', 'danger'],
|
|
34
|
+
defaultValue: 'primary',
|
|
35
|
+
control: {
|
|
36
|
+
type: 'select'
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const Template = args => _jsx(Box, {
|
|
42
|
+
style: {
|
|
43
|
+
height: '100vh',
|
|
44
|
+
width: '100vw',
|
|
45
|
+
maxHeight: '350px'
|
|
46
|
+
},
|
|
47
|
+
display: "flex",
|
|
48
|
+
alignItems: "center",
|
|
49
|
+
justifyContent: "center",
|
|
50
|
+
children: _jsx(DropDown, _objectSpread({}, args))
|
|
51
|
+
});
|
|
52
|
+
const option1 = _jsx(DropDownOption, {
|
|
53
|
+
label: "Download",
|
|
54
|
+
icon: DownloadIcon
|
|
55
|
+
});
|
|
56
|
+
const option2 = _jsx(DropDownOption, {
|
|
57
|
+
label: "Delete",
|
|
58
|
+
icon: TrashCanOutlineIcon
|
|
59
|
+
});
|
|
60
|
+
const standardProps = {
|
|
61
|
+
label: 'Attachment',
|
|
62
|
+
options: [option1, option2],
|
|
63
|
+
onClick
|
|
64
|
+
};
|
|
65
|
+
export const standard = Template.bind(standardProps);
|
|
66
|
+
standard.args = standardProps;
|
|
67
|
+
const primaryProps = _objectSpread(_objectSpread({}, standardProps), {}, {
|
|
68
|
+
variant: 'primary',
|
|
69
|
+
options: [option1, option2]
|
|
70
|
+
});
|
|
71
|
+
export const primary = Template.bind(primaryProps);
|
|
72
|
+
primary.args = primaryProps;
|
|
73
|
+
const withManyOptionsProps = _objectSpread(_objectSpread({}, standardProps), {}, {
|
|
74
|
+
options: Array.from({
|
|
75
|
+
length: 99
|
|
76
|
+
}).map((_, index) => index % 2 == 0 ? option1 : option2)
|
|
77
|
+
});
|
|
78
|
+
export const withManyOptions = Template.bind(withManyOptionsProps);
|
|
79
|
+
withManyOptions.args = withManyOptionsProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditableText.d.ts","sourceRoot":"","sources":["../../../lib/components/EditableText/EditableText.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,
|
|
1
|
+
{"version":3,"file":"EditableText.d.ts","sourceRoot":"","sources":["../../../lib/components/EditableText/EditableText.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACN,cAAc,EAEd,mBAAmB,EAInB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAiB,MAAM,SAAS,CAAC;AAK9C,KAAK,QAAQ,GAAG,IAAI,CACnB,cAAc,CAAC,OAAO,GAAG,CAAC,EAC1B,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAC9C,CAAC;AACF,KAAK,SAAS,GAAG,IAAI,CACpB,cAAc,CAAC,OAAO,IAAI,CAAC,EAC3B,IAAI,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,CAChD,CAAC;AACF,KAAK,UAAU,GAAG,IAAI,CACrB,mBAAmB,CAAC,gBAAgB,CAAC,EACnC,OAAO,GACP,IAAI,GACJ,WAAW,GACX,OAAO,GACP,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,WAAW,GACX,MAAM,SAAS,GACf,MAAM,QAAQ,CAChB,CAAC;AAEF,MAAM,WAAW,KAAM,SAAQ,SAAS,EAAE,UAAU,EAAE,QAAQ;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACzC;AAED,KAAK,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAClC,eAAO,MAAM,YAAY,iFAuFxB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
-
const _excluded = ["is", "colour", "size", "display", "value", "onFocus", "onBlur", "onKeyDown", "onModeChange"];
|
|
5
|
+
const _excluded = ["is", "colour", "size", "display", "value", "onFocus", "onBlur", "onKeyDown", "onModeChange", "tabIndex"];
|
|
6
6
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7
7
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
8
|
import clsx from 'clsx';
|
|
@@ -24,7 +24,8 @@ export const EditableText = forwardRef((_ref, ref) => {
|
|
|
24
24
|
onFocus,
|
|
25
25
|
onBlur,
|
|
26
26
|
onKeyDown,
|
|
27
|
-
onModeChange
|
|
27
|
+
onModeChange,
|
|
28
|
+
tabIndex = 0
|
|
28
29
|
} = _ref,
|
|
29
30
|
inputProps = _objectWithoutProperties(_ref, _excluded);
|
|
30
31
|
const textRef = useRef(null);
|
|
@@ -49,6 +50,7 @@ export const EditableText = forwardRef((_ref, ref) => {
|
|
|
49
50
|
return _jsxs(Box, {
|
|
50
51
|
ref: ref,
|
|
51
52
|
display: display,
|
|
53
|
+
tabIndex: tabIndex,
|
|
52
54
|
position: "relative",
|
|
53
55
|
className: styles.root,
|
|
54
56
|
onClick: () => onRequestModeChange('INPUT'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MinimalModal.d.ts","sourceRoot":"","sources":["../../../lib/components/MinimalModal/MinimalModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"MinimalModal.d.ts","sourceRoot":"","sources":["../../../lib/components/MinimalModal/MinimalModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,cAAc,EACd,iBAAiB,EAEjB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,SAAS,EAA2B,MAAM,OAAO,CAAC;AAG3D,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAIjC,MAAM,WAAW,KAChB,SAAQ,cAAc,CAAC,OAAO,KAAK,CAAC,EACnC,IAAI,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,EAAE,YAAY,CAAC;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,YAAY,EAAE,iBAAiB,CAAC,KAAK,CAsEjD,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../lib/components/Modal/Modal.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,cAAc,EACd,aAAa,EACb,iBAAiB,EAEjB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,SAAS,EAAyB,MAAM,OAAO,CAAC;AAKzD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAInC,MAAM,WAAW,KAAM,SAAQ,cAAc,CAAC,OAAO,MAAM,CAAC;IAC3D,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB,cAAc,CAAC,CAAC,CAAC,EAAE,UAAU,GAAG,eAAe,GAAG,MAAM,GAAG,IAAI,CAAC;CAChE;AAqDD,eAAO,MAAM,KAAK,EAAE,iBAAiB,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../lib/components/Modal/Modal.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,cAAc,EACd,aAAa,EACb,iBAAiB,EAEjB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,SAAS,EAAyB,MAAM,OAAO,CAAC;AAKzD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAInC,MAAM,WAAW,KAAM,SAAQ,cAAc,CAAC,OAAO,MAAM,CAAC;IAC3D,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB,cAAc,CAAC,CAAC,CAAC,EAAE,UAAU,GAAG,eAAe,GAAG,MAAM,GAAG,IAAI,CAAC;CAChE;AAqDD,eAAO,MAAM,KAAK,EAAE,iBAAiB,CAAC,KAAK,CAmF1C,CAAC;AAEF,eAAO,MAAM,SAAS,wIAmBpB,CAAC;AAEH,eAAe,KAAK,CAAC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
2
|
+
import { FocusEventHandler, FormEventHandler } from 'react';
|
|
3
|
+
interface Props extends Partial<Pick<HTMLInputElement, 'min' | 'max' | 'step'>>, Pick<HTMLInputElement, 'value'> {
|
|
3
4
|
preventMouseWheel?: boolean;
|
|
5
|
+
onChange?: FormEventHandler<HTMLInputElement>;
|
|
6
|
+
onFocus?: FocusEventHandler<HTMLInputElement>;
|
|
7
|
+
onBlur?: FocusEventHandler<HTMLInputElement>;
|
|
4
8
|
}
|
|
5
9
|
export declare const NumberInput: React.ForwardRefExoticComponent<Props & import("../private/InputBase/withEnhancedInput").EnhanceInputPrimitiveProps & import("../private/InputBase/withEnhancedInput").EventHandlers<HTMLInputElement> & import("../private/InputBase/withEnhancedInput").ValidationProps & React.RefAttributes<HTMLInputElement>>;
|
|
6
10
|
export default NumberInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberInput.d.ts","sourceRoot":"","sources":["../../../lib/components/NumberInput/NumberInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"NumberInput.d.ts","sourceRoot":"","sources":["../../../lib/components/NumberInput/NumberInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAY5D,UAAU,KACT,SAAQ,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC,CAAC,EAC9D,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC;IAChC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IAC9C,OAAO,CAAC,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAC9C,MAAM,CAAC,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;CAC7C;AAED,eAAO,MAAM,WAAW,oTA4CvB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
5
|
const _excluded = ["ref"],
|
|
6
|
-
_excluded2 = ["field", "eventHandlers", "validation", "isLoading", "suffixed", "prefixed", "preventMouseWheel", "size"];
|
|
6
|
+
_excluded2 = ["field", "eventHandlers", "validation", "isLoading", "suffixed", "prefixed", "preventMouseWheel", "size", "onChange", "onFocus", "onBlur"];
|
|
7
7
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
8
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
9
9
|
import * as React from 'react';
|
|
10
|
-
import { useCallback, useEffect, useRef } from 'react';
|
|
11
10
|
import { Box } from "../Box/index.js";
|
|
12
11
|
import { withEnhancedInput } from "../private/InputBase/index.js";
|
|
12
|
+
import { useNumberInputBehaviours } from "./useNumberInputBehaviours.js";
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
const isEdge = typeof navigator !== 'undefined' && /edge/i.test(navigator.userAgent);
|
|
15
15
|
const type = isEdge ? 'text' : 'number';
|
|
@@ -24,42 +24,38 @@ export const NumberInput = withEnhancedInput(_ref => {
|
|
|
24
24
|
suffixed,
|
|
25
25
|
prefixed,
|
|
26
26
|
preventMouseWheel = false,
|
|
27
|
-
size
|
|
27
|
+
size,
|
|
28
|
+
onChange: incomingOnChange,
|
|
29
|
+
onFocus: incomingOnFocus,
|
|
30
|
+
onBlur: incomingOnBlur
|
|
28
31
|
} = _ref,
|
|
29
32
|
incomingFieldProps = _objectWithoutProperties(_ref.field, _excluded),
|
|
30
33
|
rest = _objectWithoutProperties(_ref, _excluded2);
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
passive: false
|
|
46
|
-
});
|
|
47
|
-
wheelListener = inputRef.current.addEventListener('wheel', preventWheel, {
|
|
48
|
-
passive: false
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
return () => {
|
|
52
|
-
if (mouseWheelListener) inputRef.current.removeEventListener('mousewheel', mouseWheelListener);
|
|
53
|
-
if (onWheelListener) inputRef.current.removeEventListener('onwheel', onWheelListener);
|
|
54
|
-
if (wheelListener) inputRef.current.removeEventListener('wheel', wheelListener);
|
|
55
|
-
};
|
|
56
|
-
}, [preventMouseWheel, inputRef.current]);
|
|
34
|
+
const {
|
|
35
|
+
value,
|
|
36
|
+
inputRef,
|
|
37
|
+
onFocus,
|
|
38
|
+
onBlur,
|
|
39
|
+
onChange
|
|
40
|
+
} = useNumberInputBehaviours({
|
|
41
|
+
ref,
|
|
42
|
+
preventMouseWheel,
|
|
43
|
+
onFocus: eventHandlers.onFocus,
|
|
44
|
+
onBlur: eventHandlers.onBlur,
|
|
45
|
+
onChange: eventHandlers.onChange,
|
|
46
|
+
value: incomingFieldProps.value
|
|
47
|
+
});
|
|
57
48
|
return _jsx(Box, _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
58
49
|
is: "input",
|
|
59
50
|
ref: inputRef
|
|
60
|
-
}, eventHandlers),
|
|
51
|
+
}, eventHandlers), {}, {
|
|
52
|
+
onFocus: onFocus,
|
|
53
|
+
onBlur: onBlur,
|
|
54
|
+
onChange: onChange
|
|
55
|
+
}, incomingFieldProps), rest), {}, {
|
|
61
56
|
autoComplete: "off",
|
|
62
|
-
type: type
|
|
57
|
+
type: type,
|
|
58
|
+
value: value
|
|
63
59
|
}));
|
|
64
60
|
}, {
|
|
65
61
|
primitiveType: type
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
+
const _excluded = ["value", "onChange"];
|
|
4
6
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
7
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
8
|
import { AccountEditIcon, AlertCircleIcon, CalendarIcon, CarIcon, CarMultipleIcon, CheckIcon, CurrencyUsdIcon, PlusIcon, StarIcon } from '@autoguru/icons';
|
|
@@ -63,7 +65,21 @@ const argTypes = {
|
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
};
|
|
66
|
-
const Template =
|
|
68
|
+
const Template = _ref => {
|
|
69
|
+
let {
|
|
70
|
+
value: initialValue,
|
|
71
|
+
onChange: incomingOnChange
|
|
72
|
+
} = _ref,
|
|
73
|
+
args = _objectWithoutProperties(_ref, _excluded);
|
|
74
|
+
const [value, setValue] = React.useState(initialValue);
|
|
75
|
+
return _jsx(NumberInput, _objectSpread(_objectSpread({}, args), {}, {
|
|
76
|
+
value: value,
|
|
77
|
+
onChange: e => {
|
|
78
|
+
setValue(e.currentTarget.value);
|
|
79
|
+
incomingOnChange(e);
|
|
80
|
+
}
|
|
81
|
+
}));
|
|
82
|
+
};
|
|
67
83
|
const sharedProps = {
|
|
68
84
|
disabled: false,
|
|
69
85
|
name: 'number',
|
|
@@ -75,6 +91,7 @@ const sharedProps = {
|
|
|
75
91
|
reserveHintSpace: false,
|
|
76
92
|
hintText: '',
|
|
77
93
|
notch: true,
|
|
94
|
+
preventMouseWheel: true,
|
|
78
95
|
prefixIcon: null,
|
|
79
96
|
onChange: action('onChange'),
|
|
80
97
|
onFocus: action('onFocus'),
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FocusEventHandler, FormEventHandler, RefObject } from 'react';
|
|
2
|
+
import { EnhanceInputPrimitiveProps } from '../private/InputBase/withEnhancedInput';
|
|
3
|
+
interface Props {
|
|
4
|
+
value: EnhanceInputPrimitiveProps['value'];
|
|
5
|
+
ref: RefObject<HTMLInputElement>;
|
|
6
|
+
preventMouseWheel: boolean;
|
|
7
|
+
onFocus?: FocusEventHandler<HTMLInputElement>;
|
|
8
|
+
onBlur?: FocusEventHandler<HTMLInputElement>;
|
|
9
|
+
onChange?: FormEventHandler<HTMLInputElement>;
|
|
10
|
+
}
|
|
11
|
+
interface Returns {
|
|
12
|
+
value: EnhanceInputPrimitiveProps['value'];
|
|
13
|
+
inputRef: RefObject<HTMLInputElement>;
|
|
14
|
+
onFocus: FocusEventHandler<HTMLInputElement>;
|
|
15
|
+
onBlur: FocusEventHandler<HTMLInputElement>;
|
|
16
|
+
onChange: FormEventHandler<HTMLInputElement>;
|
|
17
|
+
}
|
|
18
|
+
export declare const useNumberInputBehaviours: ({ ref, preventMouseWheel, onBlur: incomingOnBlur, onFocus: incomingOnFocus, onChange: incomingOnChange, value, }: Props) => Returns;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=useNumberInputBehaviours.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNumberInputBehaviours.d.ts","sourceRoot":"","sources":["../../../lib/components/NumberInput/useNumberInputBehaviours.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,gBAAgB,EAChB,SAAS,EAKT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AAEpF,UAAU,KAAK;IACd,KAAK,EAAE,0BAA0B,CAAC,OAAO,CAAC,CAAC;IAC3C,GAAG,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACjC,iBAAiB,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAC9C,MAAM,CAAC,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAC7C,QAAQ,CAAC,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CAC9C;AAED,UAAU,OAAO;IAChB,KAAK,EAAE,0BAA0B,CAAC,OAAO,CAAC,CAAC;IAC3C,QAAQ,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACtC,OAAO,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAC7C,MAAM,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAC5C,QAAQ,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CAC7C;AAED,eAAO,MAAM,wBAAwB,qHAOlC,KAAK,KAAG,OAqFV,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
+
export const useNumberInputBehaviours = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
ref,
|
|
7
|
+
preventMouseWheel,
|
|
8
|
+
onBlur: incomingOnBlur,
|
|
9
|
+
onFocus: incomingOnFocus,
|
|
10
|
+
onChange: incomingOnChange,
|
|
11
|
+
value
|
|
12
|
+
} = _ref;
|
|
13
|
+
const inputRef = useRef(ref === null || ref === void 0 ? void 0 : ref.current);
|
|
14
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
15
|
+
const [displayValue, setDisplayValue] = useState(value);
|
|
16
|
+
const onBlur = useCallback(e => {
|
|
17
|
+
if (typeof incomingOnBlur === 'function') incomingOnBlur(e);
|
|
18
|
+
setIsFocused(false);
|
|
19
|
+
setDisplayValue(void 0);
|
|
20
|
+
}, [incomingOnBlur]);
|
|
21
|
+
const onFocus = useCallback(e => {
|
|
22
|
+
if (typeof incomingOnFocus === 'function') incomingOnFocus(e);
|
|
23
|
+
if (typeof value === 'string' && displayValue !== value) setDisplayValue(value);
|
|
24
|
+
setIsFocused(true);
|
|
25
|
+
}, [incomingOnFocus, value, displayValue]);
|
|
26
|
+
const onChange = useCallback(e => {
|
|
27
|
+
if (isFocused) {
|
|
28
|
+
setDisplayValue(e.currentTarget.value);
|
|
29
|
+
}
|
|
30
|
+
if (typeof incomingOnChange === 'function') incomingOnChange(e);
|
|
31
|
+
}, [incomingOnChange, isFocused, value, displayValue]);
|
|
32
|
+
const preventWheel = useCallback(e => {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
e.stopPropagation();
|
|
35
|
+
}, []);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
let mouseWheelListener;
|
|
38
|
+
let onWheelListener;
|
|
39
|
+
let wheelListener;
|
|
40
|
+
if (preventMouseWheel && inputRef !== null && inputRef !== void 0 && inputRef.current) {
|
|
41
|
+
mouseWheelListener = inputRef.current.addEventListener('mousewheel', preventWheel, {
|
|
42
|
+
passive: false
|
|
43
|
+
});
|
|
44
|
+
onWheelListener = inputRef.current.addEventListener('onwheel', preventWheel, {
|
|
45
|
+
passive: false
|
|
46
|
+
});
|
|
47
|
+
wheelListener = inputRef.current.addEventListener('wheel', preventWheel, {
|
|
48
|
+
passive: false
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return () => {
|
|
52
|
+
if (mouseWheelListener && inputRef.current) inputRef.current.removeEventListener('mousewheel', mouseWheelListener);
|
|
53
|
+
if (onWheelListener && inputRef.current) inputRef.current.removeEventListener('onwheel', onWheelListener);
|
|
54
|
+
if (wheelListener && inputRef.current) inputRef.current.removeEventListener('wheel', wheelListener);
|
|
55
|
+
};
|
|
56
|
+
}, [preventMouseWheel, inputRef.current]);
|
|
57
|
+
return {
|
|
58
|
+
inputRef,
|
|
59
|
+
onBlur,
|
|
60
|
+
onFocus,
|
|
61
|
+
onChange,
|
|
62
|
+
value: typeof displayValue === 'string' ? displayValue : value
|
|
63
|
+
};
|
|
64
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAEhC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAEhC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -63,4 +63,5 @@ export * from "./FillHeightBox/index.js";
|
|
|
63
63
|
export * from "./StickyBox/index.js";
|
|
64
64
|
export * from "./ScrollPane/index.js";
|
|
65
65
|
export * from "./IntentStripe/index.js";
|
|
66
|
-
export * from "./EditableText/index.js";
|
|
66
|
+
export * from "./EditableText/index.js";
|
|
67
|
+
export * from "./DropDown/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../lib/utils/refs.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,eACR,MAAM,GAAG,CAAC,sBAKtB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export const mergeRefs = function () {
|
|
4
|
+
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
5
|
+
refs[_key] = arguments[_key];
|
|
6
|
+
}
|
|
7
|
+
return node => {
|
|
8
|
+
for (const ref of refs.filter(Boolean)) {
|
|
9
|
+
ref.current = node;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
};
|