@autoguru/overdrive 4.22.0 → 4.23.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/EditableText/EditableText.css.d.ts +3 -0
- package/dist/components/EditableText/EditableText.css.d.ts.map +1 -0
- package/dist/components/EditableText/EditableText.css.js +17 -0
- package/dist/components/EditableText/EditableText.d.ts +12 -0
- package/dist/components/EditableText/EditableText.d.ts.map +1 -0
- package/dist/components/EditableText/EditableText.js +69 -0
- package/dist/components/EditableText/index.d.ts +2 -0
- package/dist/components/EditableText/index.d.ts.map +1 -0
- package/dist/components/EditableText/index.js +3 -0
- package/dist/components/EditableText/stories.js +52 -0
- package/dist/components/Text/Text.d.ts +2 -1
- package/dist/components/Text/Text.d.ts.map +1 -1
- package/dist/components/Text/Text.js +3 -1
- package/package.json +1 -1
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import * as __vanilla_filescope__ from '@vanilla-extract/css/fileScope';
|
|
4
|
+
__vanilla_filescope__.setFileScope("lib/components/EditableText/EditableText.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
|
+
transitionDelay: '0s',
|
|
9
|
+
transitionTimingFunction: 'cubic-bezier(0, 0, 0.2, 1)',
|
|
10
|
+
transitionDuration: '0.2s',
|
|
11
|
+
transitionProperty: 'box-shadow',
|
|
12
|
+
boxShadow: "inset 0 -1px 0 0 ".concat(vars.typography.colour.muted)
|
|
13
|
+
}, "root");
|
|
14
|
+
export const text = style({
|
|
15
|
+
cursor: 'pointer'
|
|
16
|
+
}, "text");
|
|
17
|
+
__vanilla_filescope__.endFileScope();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentProps, InputHTMLAttributes } from 'react';
|
|
3
|
+
import { Text } from '../Text';
|
|
4
|
+
type BoxProps = Pick<ComponentProps<typeof Text>, 'display'>;
|
|
5
|
+
type TextProps = Pick<ComponentProps<typeof Text>, 'is' | 'colour' | 'size' | 'display' | 'children' | 'noWrap'>;
|
|
6
|
+
type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'style' | 'is' | 'autoFocus' | 'width' | 'height' | keyof TextProps | keyof BoxProps>;
|
|
7
|
+
export interface Props extends TextProps, InputProps, BoxProps {
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const EditableText: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLAnchorElement>>;
|
|
11
|
+
export default EditableText;
|
|
12
|
+
//# sourceMappingURL=EditableText.d.ts.map
|
|
@@ -0,0 +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,EAAY,MAAM,OAAO,CAAC;AAGlF,OAAO,EAAE,IAAI,EAAiB,MAAM,SAAS,CAAC;AAI9C,KAAK,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;AAC7D,KAAK,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,EAAE,IAAI,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC,CAAC;AACjH,KAAK,UAAU,GAAG,IAAI,CACrB,mBAAmB,CAAC,gBAAgB,CAAC,EACpC,OAAO,GAAG,IAAI,GAAG,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,SAAS,GAAG,MAAM,QAAQ,CACrF,CAAC;AAEF,MAAM,WAAW,KAAM,SAAQ,SAAS,EAAE,UAAU,EAAE,QAAQ;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,YAAY,iFA6DxB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
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 = ["is", "colour", "size", "display", "value"];
|
|
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 clsx from 'clsx';
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import { forwardRef, useState } from 'react';
|
|
11
|
+
import { Box } from "../Box/index.js";
|
|
12
|
+
import { Text, useTextStyles } from "../Text/index.js";
|
|
13
|
+
import * as inputStyles from "../private/InputBase/withEnhancedInput.css.js";
|
|
14
|
+
import * as styles from "./EditableText.css.js";
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
export const EditableText = forwardRef((_ref, ref) => {
|
|
17
|
+
let {
|
|
18
|
+
is,
|
|
19
|
+
colour = 'muted',
|
|
20
|
+
size,
|
|
21
|
+
display = 'inlineBlock',
|
|
22
|
+
value
|
|
23
|
+
} = _ref,
|
|
24
|
+
inputProps = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
26
|
+
const onRequestEdit = () => setIsEditing(true);
|
|
27
|
+
const textStyles = useTextStyles({
|
|
28
|
+
is,
|
|
29
|
+
colour,
|
|
30
|
+
size
|
|
31
|
+
});
|
|
32
|
+
const width = value ? "".concat(value.toString().length, "ch") : void 0;
|
|
33
|
+
return _jsx(Box, {
|
|
34
|
+
ref: ref,
|
|
35
|
+
display: display,
|
|
36
|
+
className: styles.root,
|
|
37
|
+
style: {
|
|
38
|
+
maxWidth: width
|
|
39
|
+
},
|
|
40
|
+
onClick: onRequestEdit,
|
|
41
|
+
onFocus: onRequestEdit,
|
|
42
|
+
onBlur: () => setIsEditing(false),
|
|
43
|
+
onKeyDown: e => {
|
|
44
|
+
if (e.key === 'Enter' || e.key === 'Escape') {
|
|
45
|
+
setIsEditing(false);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
children: isEditing ? _jsx(Box, _objectSpread(_objectSpread({
|
|
49
|
+
is: "input"
|
|
50
|
+
}, inputProps), {}, {
|
|
51
|
+
autoFocus: true,
|
|
52
|
+
value: value,
|
|
53
|
+
className: clsx(textStyles, inputStyles.input.itself.root),
|
|
54
|
+
style: {
|
|
55
|
+
width
|
|
56
|
+
}
|
|
57
|
+
})) : _jsx(Text, {
|
|
58
|
+
noWrap: true,
|
|
59
|
+
is: is,
|
|
60
|
+
colour: colour,
|
|
61
|
+
className: clsx(textStyles, styles.text),
|
|
62
|
+
style: {
|
|
63
|
+
maxWidth: width
|
|
64
|
+
},
|
|
65
|
+
children: value
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
export default EditableText;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/EditableText/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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 isChromatic from 'chromatic';
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import { EditableText } from "./index.js";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
export default {
|
|
11
|
+
title: 'Components/Inputs/EditableText',
|
|
12
|
+
component: EditableText,
|
|
13
|
+
argTypes: {
|
|
14
|
+
colour: {
|
|
15
|
+
options: ['muted', 'primary', 'secondary'],
|
|
16
|
+
defaultValue: 'primary',
|
|
17
|
+
control: {
|
|
18
|
+
type: 'select'
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const template = args => _jsx(EditableText, _objectSpread({}, args));
|
|
24
|
+
const textProps = {
|
|
25
|
+
colour: 'muted',
|
|
26
|
+
value: 'Hello World',
|
|
27
|
+
type: 'text'
|
|
28
|
+
};
|
|
29
|
+
const numberProps = {
|
|
30
|
+
colour: 'muted',
|
|
31
|
+
value: '20',
|
|
32
|
+
type: 'number'
|
|
33
|
+
};
|
|
34
|
+
const formatDate = function () {
|
|
35
|
+
let date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
|
|
36
|
+
const year = date.getFullYear();
|
|
37
|
+
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
|
38
|
+
const day = date.getDate().toString().padStart(2, '0');
|
|
39
|
+
return "".concat(year, "-").concat(month, "-").concat(day);
|
|
40
|
+
};
|
|
41
|
+
const todayStr = formatDate(isChromatic() ? new Date(2019, 5, 1) : new Date());
|
|
42
|
+
const dateProps = {
|
|
43
|
+
colour: 'muted',
|
|
44
|
+
value: todayStr,
|
|
45
|
+
type: 'date'
|
|
46
|
+
};
|
|
47
|
+
export const text = template.bind(textProps);
|
|
48
|
+
export const number = template.bind(numberProps);
|
|
49
|
+
export const date = template.bind(dateProps);
|
|
50
|
+
text.args = textProps;
|
|
51
|
+
number.args = numberProps;
|
|
52
|
+
date.args = dateProps;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FunctionComponent, ReactNode } from 'react';
|
|
1
|
+
import type { FunctionComponent, ReactNode, CSSProperties } from 'react';
|
|
2
2
|
import type { BoxStyleProps } from '../Box';
|
|
3
3
|
import { TextStyleProps } from './useTextStyles';
|
|
4
4
|
export interface Props extends TextStyleProps {
|
|
@@ -7,6 +7,7 @@ export interface Props extends TextStyleProps {
|
|
|
7
7
|
strong?: boolean;
|
|
8
8
|
children?: ReactNode;
|
|
9
9
|
display?: Extract<BoxStyleProps['display'], 'inline' | 'inlineBlock' | 'block'>;
|
|
10
|
+
style?: CSSProperties;
|
|
10
11
|
}
|
|
11
12
|
export declare const Text: FunctionComponent<Props>;
|
|
12
13
|
export default Text;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../lib/components/Text/Text.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../lib/components/Text/Text.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAG5C,OAAO,EAAE,cAAc,EAAiB,MAAM,iBAAiB,CAAC;AAEhE,MAAM,WAAW,KAAM,SAAQ,cAAc;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAChB,aAAa,CAAC,SAAS,CAAC,EACxB,QAAQ,GAAG,aAAa,GAAG,OAAO,CAClC,CAAC;IACF,KAAK,CAAC,EAAE,aAAa,CAAC;CACtB;AAED,eAAO,MAAM,IAAI,EAAE,iBAAiB,CAAC,KAAK,CAmCzC,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -17,7 +17,8 @@ export const Text = _ref => {
|
|
|
17
17
|
breakWord,
|
|
18
18
|
noWrap,
|
|
19
19
|
size = '4',
|
|
20
|
-
strong = false
|
|
20
|
+
strong = false,
|
|
21
|
+
style
|
|
21
22
|
} = _ref;
|
|
22
23
|
return _jsx(Box, {
|
|
23
24
|
is: Component,
|
|
@@ -32,6 +33,7 @@ export const Text = _ref => {
|
|
|
32
33
|
noWrap,
|
|
33
34
|
breakWord
|
|
34
35
|
}), className],
|
|
36
|
+
style: style,
|
|
35
37
|
children: children
|
|
36
38
|
});
|
|
37
39
|
};
|