@autoguru/overdrive 4.23.5 → 4.24.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.
@@ -2,12 +2,14 @@ import * as React from 'react';
2
2
  import { ComponentProps, InputHTMLAttributes } from 'react';
3
3
  import { Box } from '../Box';
4
4
  import { Text } from '../Text';
5
- type BoxProps = Pick<ComponentProps<typeof Box>, 'display' | 'onFocus' | 'onBlur'>;
5
+ type BoxProps = Pick<ComponentProps<typeof Box>, 'display' | 'onFocus' | 'onBlur' | 'onKeyDown'>;
6
6
  type TextProps = Pick<ComponentProps<typeof Text>, 'is' | 'colour' | 'size' | 'children' | 'noWrap'>;
7
- type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'style' | 'is' | 'autoFocus' | 'width' | 'height' | 'onFocus' | 'onBlur' | keyof TextProps | keyof BoxProps>;
7
+ type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'style' | 'is' | 'autoFocus' | 'width' | 'height' | 'onFocus' | 'onBlur' | 'onKeyDown' | keyof TextProps | keyof BoxProps>;
8
8
  export interface Props extends TextProps, InputProps, BoxProps {
9
9
  className?: string;
10
+ onModeChange?: (mode: InputMode) => void;
10
11
  }
12
+ type InputMode = 'TEXT' | 'INPUT';
11
13
  export declare const EditableText: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLAnchorElement>>;
12
14
  export default EditableText;
13
15
  //# sourceMappingURL=EditableText.d.ts.map
@@ -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,EAAE,cAAc,EAAc,mBAAmB,EAA+B,MAAM,OAAO,CAAC;AAErG,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAiB,MAAM,SAAS,CAAC;AAK9C,KAAK,QA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,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,iFAwFxB,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"];
5
+ const _excluded = ["is", "colour", "size", "display", "value", "onFocus", "onBlur", "onKeyDown", "onModeChange"];
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';
@@ -22,12 +22,19 @@ export const EditableText = forwardRef((_ref, ref) => {
22
22
  display = 'inlineBlock',
23
23
  value,
24
24
  onFocus,
25
- onBlur
25
+ onBlur,
26
+ onKeyDown,
27
+ onModeChange
26
28
  } = _ref,
27
29
  inputProps = _objectWithoutProperties(_ref, _excluded);
28
30
  const textRef = useRef(null);
29
- const [isEditing, setIsEditing] = useState(false);
30
- const onRequestEdit = () => setIsEditing(true);
31
+ const [mode, setMode] = useState('TEXT');
32
+ const onRequestModeChange = newMode => {
33
+ setMode(newMode);
34
+ if (typeof onModeChange === 'function') {
35
+ onModeChange(newMode);
36
+ }
37
+ };
31
38
  const textStyles = useTextStyles({
32
39
  is,
33
40
  colour,
@@ -44,21 +51,22 @@ export const EditableText = forwardRef((_ref, ref) => {
44
51
  display: display,
45
52
  position: "relative",
46
53
  className: styles.root,
47
- onClick: onRequestEdit,
54
+ onClick: () => onRequestModeChange('INPUT'),
48
55
  onFocus: e => {
49
- onRequestEdit();
50
56
  if (typeof onFocus === 'function') onFocus(e);
57
+ onRequestModeChange('INPUT');
51
58
  },
52
59
  onBlur: e => {
53
- setIsEditing(false);
54
60
  if (typeof onBlur === 'function') onBlur(e);
61
+ onRequestModeChange('TEXT');
55
62
  },
56
63
  onKeyDown: e => {
64
+ if (typeof onKeyDown === 'function') onKeyDown(e);
57
65
  if (e.key === 'Enter' || e.key === 'Escape') {
58
- setIsEditing(false);
66
+ onRequestModeChange('TEXT');
59
67
  }
60
68
  },
61
- children: [isEditing && _jsx(Box, _objectSpread(_objectSpread({
69
+ children: [mode === 'INPUT' && _jsx(Box, _objectSpread(_objectSpread({
62
70
  is: "input"
63
71
  }, inputProps), {}, {
64
72
  autoFocus: true,
@@ -74,7 +82,7 @@ export const EditableText = forwardRef((_ref, ref) => {
74
82
  colour: colour,
75
83
  size: size,
76
84
  className: clsx(textStyles, styles.text, {
77
- [styles.textHidden]: isEditing
85
+ [styles.textHidden]: mode === 'INPUT'
78
86
  }),
79
87
  children: value
80
88
  })]
@@ -1 +1 @@
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,CA8EjD,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"MinimalModal.d.ts","sourceRoot":"","sources":["../../../lib/components/MinimalModal/MinimalModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAqB,MAAM,OAAO,CAAC;AAElF,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,CA0EjD,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,5 +1,10 @@
1
1
  "use strict";
2
2
 
3
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
+ const _excluded = ["isOpen", "alignItems", "className", "children", "onRequestClose"];
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; }
3
8
  import * as React from 'react';
4
9
  import { useLayoutEffect, useRef } from 'react';
5
10
  import { isBrowser, useEventCallback, useId } from "../../utils/index.js";
@@ -9,15 +14,13 @@ import * as styles from "./MinimalModal.css.js";
9
14
  import { jsx as _jsx } from "react/jsx-runtime";
10
15
  export const MinimalModal = _ref => {
11
16
  let {
12
- isOpen,
13
- alignItems = 'center',
14
- className = '',
15
- container,
16
- noThemedWrapper,
17
- ref,
18
- onRequestClose,
19
- children
20
- } = _ref;
17
+ isOpen,
18
+ alignItems = 'center',
19
+ className = '',
20
+ children,
21
+ onRequestClose
22
+ } = _ref,
23
+ modalProps = _objectWithoutProperties(_ref, _excluded);
21
24
  const titleId = useId();
22
25
  const locked = useRef(true);
23
26
  const unlockModal = useEventCallback(event => {
@@ -35,12 +38,10 @@ export const MinimalModal = _ref => {
35
38
  };
36
39
  }, [isOpen]);
37
40
  }
38
- return _jsx(Modal, {
41
+ return _jsx(Modal, _objectSpread(_objectSpread({
39
42
  isOpen: isOpen,
40
- onRequestClose: onRequestClose,
41
- ref: ref,
42
- noThemedWrapper: noThemedWrapper,
43
- container: container,
43
+ onRequestClose: onRequestClose
44
+ }, modalProps), {}, {
44
45
  children: _jsx(Box, {
45
46
  className: [styles.container, className],
46
47
  height: "full",
@@ -69,6 +70,6 @@ export const MinimalModal = _ref => {
69
70
  })
70
71
  })
71
72
  })
72
- });
73
+ }));
73
74
  };
74
75
  export default MinimalModal;
@@ -4,6 +4,7 @@ import { Portal } from '../Portal';
4
4
  export interface Props extends ComponentProps<typeof Portal> {
5
5
  isOpen: boolean;
6
6
  hideBackdrop?: boolean;
7
+ disableBackdropClick?: boolean;
7
8
  children?: ReactNode;
8
9
  onRequestClose?(e: 'backdrop' | 'escapeKeyDown' | string): void;
9
10
  }
@@ -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,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,CA8E1C,CAAC;AAEF,eAAO,MAAM,SAAS,wIAmBpB,CAAC;AAEH,eAAe,KAAK,CAAC"}
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,CA+E1C,CAAC;AAEF,eAAO,MAAM,SAAS,wIAmBpB,CAAC;AAEH,eAAe,KAAK,CAAC"}
@@ -65,6 +65,7 @@ export const Modal = _ref => {
65
65
  let {
66
66
  isOpen,
67
67
  hideBackdrop = false,
68
+ disableBackdropClick = false,
68
69
  ref,
69
70
  noThemedWrapper,
70
71
  container,
@@ -101,7 +102,7 @@ export const Modal = _ref => {
101
102
  children: [_jsx(Box, {
102
103
  "aria-hidden": "true",
103
104
  position: "fixed",
104
- pointerEvents: state === 'CLOSING' ? 'none' : undefined,
105
+ pointerEvents: disableBackdropClick || state === 'CLOSING' ? 'none' : undefined,
105
106
  opacity: state === 'OPEN' ? undefined : 0,
106
107
  backgroundColour: hideBackdrop ? 'transparent' : 'neutral',
107
108
  className: [styles.backdrop.root, styles.transition, hideBackdrop && styles.backdrop.invisible],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autoguru/overdrive",
3
- "version": "4.23.5",
3
+ "version": "4.24.0",
4
4
  "description": "Overdrive is a product component library, and design system for AutoGuru.",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",