@autoguru/overdrive 4.23.2 → 4.23.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
1
  export declare const root: string;
2
2
  export declare const text: string;
3
+ export declare const textHidden: string;
3
4
  //# sourceMappingURL=EditableText.css.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EditableText.css.d.ts","sourceRoot":"","sources":["../../../lib/components/EditableText/EditableText.css.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,IAAI,QAMf,CAAC;AAEH,eAAO,MAAM,IAAI,QAEf,CAAC"}
1
+ {"version":3,"file":"EditableText.css.d.ts","sourceRoot":"","sources":["../../../lib/components/EditableText/EditableText.css.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,IAAI,QAMf,CAAC;AAEH,eAAO,MAAM,IAAI,QAEf,CAAC;AAEH,eAAO,MAAM,UAAU,QAGrB,CAAC"}
@@ -14,4 +14,8 @@ export const root = style({
14
14
  export const text = style({
15
15
  cursor: 'pointer'
16
16
  }, "text");
17
+ export const textHidden = style({
18
+ position: 'absolute',
19
+ visibility: 'hidden'
20
+ }, "textHidden");
17
21
  __vanilla_filescope__.endFileScope();
@@ -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,EACN,cAAc,EAEd,mBAAmB,EAGnB,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,IAAI,EAAiB,MAAM,SAAS,CAAC;AAK9C,KAAK,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;AAC7D,KAAK,SAAS,GAAG,IAAI,CACpB,cAAc,CAAC,OAAO,IAAI,CAAC,EAC3B,IAAI,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAC5D,CAAC;AACF,KAAK,UAAU,GAAG,IAAI,CACrB,mBAAmB,CAAC,gBAAgB,CAAC,EACnC,OAAO,GACP,IAAI,GACJ,WAAW,GACX,OAAO,GACP,QAAQ,GACR,MAAM,SAAS,GACf,MAAM,QAAQ,CAChB,CAAC;AAEF,MAAM,WAAW,KAAM,SAAQ,SAAS,EAAE,UAAU,EAAE,QAAQ;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,YAAY,iFAiExB,CAAC;AAEF,eAAe,YAAY,CAAC"}
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;AAGf,OAAO,EAAE,IAAI,EAAiB,MAAM,SAAS,CAAC;AAK9C,KAAK,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;AAC7D,KAAK,SAAS,GAAG,IAAI,CACpB,cAAc,CAAC,OAAO,IAAI,CAAC,EAC3B,IAAI,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAC5D,CAAC;AACF,KAAK,UAAU,GAAG,IAAI,CACrB,mBAAmB,CAAC,gBAAgB,CAAC,EACnC,OAAO,GACP,IAAI,GACJ,WAAW,GACX,OAAO,GACP,QAAQ,GACR,MAAM,SAAS,GACf,MAAM,QAAQ,CAChB,CAAC;AAEF,MAAM,WAAW,KAAM,SAAQ,SAAS,EAAE,UAAU,EAAE,QAAQ;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,YAAY,iFAqExB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -7,15 +7,14 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
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';
9
9
  import * as React from 'react';
10
- import { forwardRef, useRef, useState } from 'react';
11
- import { Box, useBoxStyles } from "../Box/index.js";
10
+ import { forwardRef, useEffect, useRef, useState } from 'react';
11
+ import { Box } from "../Box/index.js";
12
12
  import { Text, useTextStyles } from "../Text/index.js";
13
13
  import * as inputStyles from "../private/InputBase/withEnhancedInput.css.js";
14
14
  import * as styles from "./EditableText.css.js";
15
15
  import { jsx as _jsx } from "react/jsx-runtime";
16
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
17
17
  export const EditableText = forwardRef((_ref, ref) => {
18
- var _textRef$current;
19
18
  let {
20
19
  is,
21
20
  colour = 'muted',
@@ -32,9 +31,16 @@ export const EditableText = forwardRef((_ref, ref) => {
32
31
  colour,
33
32
  size
34
33
  });
34
+ const [width, setWidth] = useState(undefined);
35
+ useEffect(() => {
36
+ if (textRef.current) {
37
+ setWidth(textRef.current.clientWidth);
38
+ }
39
+ }, [textRef.current, value]);
35
40
  return _jsxs(Box, {
36
41
  ref: ref,
37
42
  display: display,
43
+ position: "relative",
38
44
  className: styles.root,
39
45
  onClick: onRequestEdit,
40
46
  onFocus: onRequestEdit,
@@ -51,16 +57,17 @@ export const EditableText = forwardRef((_ref, ref) => {
51
57
  value: value,
52
58
  className: clsx(textStyles, inputStyles.input.itself.root),
53
59
  style: {
54
- width: (_textRef$current = textRef.current) === null || _textRef$current === void 0 ? void 0 : _textRef$current.offsetWidth
60
+ width
55
61
  }
56
62
  })), _jsx(Text, {
57
63
  noWrap: true,
58
64
  ref: textRef,
59
65
  is: is,
60
66
  colour: colour,
61
- className: clsx(textStyles, styles.text, useBoxStyles({
62
- display: isEditing ? 'none' : display
63
- })),
67
+ size: size,
68
+ className: clsx(textStyles, styles.text, {
69
+ [styles.textHidden]: isEditing
70
+ }),
64
71
  children: value
65
72
  })]
66
73
  });
@@ -1,10 +1,13 @@
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 = ["onChange", "value"];
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 isChromatic from 'chromatic';
7
9
  import * as React from 'react';
10
+ import { useState } from 'react';
8
11
  import { EditableText } from "./index.js";
9
12
  import { jsx as _jsx } from "react/jsx-runtime";
10
13
  export default {
@@ -20,7 +23,21 @@ export default {
20
23
  }
21
24
  }
22
25
  };
23
- const template = args => _jsx(EditableText, _objectSpread({}, args));
26
+ const template = _ref => {
27
+ let {
28
+ onChange: incomingOnChange,
29
+ value: incomingValue
30
+ } = _ref,
31
+ args = _objectWithoutProperties(_ref, _excluded);
32
+ const [value, setValue] = useState(incomingValue);
33
+ return _jsx(EditableText, _objectSpread({
34
+ onChange: e => {
35
+ setValue(e.currentTarget.value);
36
+ typeof incomingOnChange === 'function' && incomingOnChange(e.currentTarget.value);
37
+ },
38
+ value: value
39
+ }, args));
40
+ };
24
41
  const textProps = {
25
42
  colour: 'muted',
26
43
  value: 'Hello World',
@@ -49,11 +66,19 @@ const narrowCharactersProps = {
49
66
  value: 'Price is $111.01',
50
67
  type: 'text'
51
68
  };
69
+ const customSizeProps = {
70
+ colour: 'warning',
71
+ value: '$999.99',
72
+ type: 'text',
73
+ size: '6'
74
+ };
52
75
  export const text = template.bind(textProps);
53
76
  export const number = template.bind(numberProps);
54
77
  export const date = template.bind(dateProps);
55
78
  export const narrowCharacters = template.bind(narrowCharactersProps);
79
+ export const customSize = template.bind(customSizeProps);
56
80
  text.args = textProps;
57
81
  number.args = numberProps;
58
82
  date.args = dateProps;
59
- narrowCharacters.args = narrowCharactersProps;
83
+ narrowCharacters.args = narrowCharactersProps;
84
+ customSize.args = customSizeProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autoguru/overdrive",
3
- "version": "4.23.2",
3
+ "version": "4.23.4",
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",