@jobber/components 4.24.0 → 4.24.1-JOB-73446.18

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/.eslintrc.js ADDED
@@ -0,0 +1,10 @@
1
+ module.exports = {
2
+ rules: {
3
+ "import/no-internal-modules": [
4
+ "error",
5
+ {
6
+ allow: ["**"],
7
+ },
8
+ ],
9
+ },
10
+ };
@@ -1,9 +1,15 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  import { XOR } from "ts-xor";
3
3
  import { GroupOption, Option } from "./Option";
4
+ import { InputTextRef } from "../InputText";
4
5
  import { FormFieldProps } from "../FormField";
5
6
  type OptionCollection = XOR<Option[], GroupOption[]>;
6
- interface AutocompleteProps extends Pick<FormFieldProps, "inputRef" | "invalid" | "name" | "onBlur" | "onFocus" | "prefix" | "size" | "suffix" | "validations"> {
7
+ interface AutocompleteProps extends Pick<FormFieldProps, "invalid" | "name" | "onBlur" | "onFocus" | "prefix" | "size" | "suffix" | "validations"> {
8
+ /**
9
+ * @deprecated
10
+ * Use `ref` instead.
11
+ */
12
+ readonly inputRef?: FormFieldProps["inputRef"];
7
13
  /**
8
14
  * Initial options to show when user first focuses the Autocomplete
9
15
  */
@@ -40,5 +46,5 @@ interface AutocompleteProps extends Pick<FormFieldProps, "inputRef" | "invalid"
40
46
  */
41
47
  readonly placeholder: string;
42
48
  }
43
- export declare function Autocomplete({ initialOptions, value, allowFreeForm, size, debounce: debounceRate, onChange, getOptions, placeholder, onBlur, onFocus, validations, ...inputProps }: AutocompleteProps): JSX.Element;
49
+ export declare const Autocomplete: React.ForwardRefExoticComponent<AutocompleteProps & React.RefAttributes<InputTextRef>>;
44
50
  export {};
@@ -13,7 +13,7 @@ var reactPopper = require('react-popper');
13
13
  var Text = require('../Text-e7ed0974.js');
14
14
  var Icon = require('../Icon-405a216c.js');
15
15
  var Heading = require('../Heading-a1191b15.js');
16
- var InputText = require('../InputText-e9b345ff.js');
16
+ var InputText = require('../InputText-c66e199a.js');
17
17
  require('../Typography-fd6f932a.js');
18
18
  require('@jobber/design');
19
19
  require('../FormField-090113ec.js');
@@ -147,7 +147,7 @@ function useRepositionMenu(attachTo, visible = false) {
147
147
 
148
148
  // Max statements increased to make room for the debounce functions
149
149
  /* eslint max-statements: ["error", 14] */
150
- function Autocomplete(_a) {
150
+ function AutocompleteInternal(_a, ref) {
151
151
  var _b;
152
152
  var { initialOptions = [], value, allowFreeForm = true, size = undefined, debounce: debounceRate = 300, onChange, getOptions, placeholder, onBlur, onFocus, validations } = _a, inputProps = tslib_es6.__rest(_a, ["initialOptions", "value", "allowFreeForm", "size", "debounce", "onChange", "getOptions", "placeholder", "onBlur", "onFocus", "validations"]);
153
153
  const [options, setOptions] = React.useState(initialOptions);
@@ -164,7 +164,7 @@ function Autocomplete(_a) {
164
164
  updateInput((_a = value === null || value === void 0 ? void 0 : value.label) !== null && _a !== void 0 ? _a : "");
165
165
  }, [value]);
166
166
  return (React__default["default"].createElement("div", { className: styles.autocomplete, ref: autocompleteRef },
167
- React__default["default"].createElement(InputText.InputText, Object.assign({ autocomplete: false, size: size, value: inputText, onChange: handleInputChange, placeholder: placeholder, onFocus: handleInputFocus, onBlur: handleInputBlur, validations: validations }, inputProps)),
167
+ React__default["default"].createElement(InputText.InputText, Object.assign({ ref: ref, autocomplete: false, size: size, value: inputText, onChange: handleInputChange, placeholder: placeholder, onFocus: handleInputFocus, onBlur: handleInputBlur, validations: validations }, inputProps)),
168
168
  menuVisible && (React__default["default"].createElement(Menu, { attachTo: autocompleteRef, visible: menuVisible && options.length > 0, options: options, selectedOption: value, onOptionSelect: handleMenuChange }))));
169
169
  function updateInput(newText) {
170
170
  setInputText(newText);
@@ -214,5 +214,6 @@ function mapToOptions(items) {
214
214
  return result;
215
215
  }, []);
216
216
  }
217
+ const Autocomplete = React.forwardRef(AutocompleteInternal);
217
218
 
218
219
  exports.Autocomplete = Autocomplete;
@@ -1,4 +1,5 @@
1
1
  import { ReactNode } from "react";
2
+ import { IconNames } from "@jobber/design";
2
3
  import { ButtonProps } from "../Button";
3
4
  export type BannerType = "notice" | "success" | "warning" | "error";
4
5
  interface BannerProps {
@@ -13,7 +14,11 @@ interface BannerProps {
13
14
  * @default true
14
15
  */
15
16
  readonly dismissible?: boolean;
17
+ /**
18
+ * Adds an icon to the left of the banner content
19
+ */
20
+ readonly icon?: IconNames;
16
21
  onDismiss?(): void;
17
22
  }
18
- export declare function Banner({ children, type, primaryAction, dismissible, onDismiss, }: BannerProps): JSX.Element;
23
+ export declare function Banner({ children, type, primaryAction, dismissible, icon, onDismiss, }: BannerProps): JSX.Element;
19
24
  export {};
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { IconNames } from "@jobber/design";
3
+ export interface BannerIconProps {
4
+ icon: IconNames;
5
+ }
6
+ export declare function BannerIcon({ icon }: BannerIconProps): JSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./BannerIcon";
@@ -18,7 +18,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
18
18
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
19
19
  var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
20
20
 
21
- var css_248z$1 = ".meuT8gYQPJU- {\n display: -ms-flexbox;\n display: flex;\n position: relative;\n box-shadow: 0px calc(16px / 16) calc(16px / 4) 0px\n rgba(0, 0, 0, 0.1),\n 0px calc(16px / 4) 12px 0px rgba(0, 0, 0, 0.05);\n box-shadow: var(--shadow-base);\n padding: calc(16px * 1);\n padding: var(--space-base);\n color: rgb(66, 78, 86);\n color: var(--color-text);\n background-color: rgb(244, 244, 244);\n background-color: var(--color-surface--background);\n gap: calc(16px / 2);\n gap: var(--space-small);\n -ms-flex-align: center;\n align-items: center;\n}\n\n.y4BapyZr-fo- > a {\n color: rgb(66, 78, 86);\n color: var(--color-text);\n}\n\n.y4BapyZr-fo- > a:hover {\n color: rgb(1, 41, 57);\n color: var(--color-blue);\n}\n\n._6v1woNSLEvc- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n gap: calc(16px / 2);\n gap: var(--space-small);\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n -ms-flex-pack: justify;\n justify-content: space-between;\n -ms-flex-align: start;\n align-items: flex-start;\n}\n\n.y4BapyZr-fo- {\n -ms-flex-item-align: center;\n align-self: center;\n}\n\n._6v1woNSLEvc- > *:last-child {\n margin-bottom: 0;\n}\n\n.bocgLmEhcTU- .y4BapyZr-fo- {\n -ms-flex: 1;\n flex: 1;\n}\n\n.rtNjEzmABX4- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex: 0 0 auto;\n flex: 0 0 auto;\n}\n\n.lunQ5SOfyLg- {\n margin: calc((16px / 8) * -1) 0;\n margin: calc(calc(16px / 8) * -1) 0;\n margin: calc(var(--space-smallest) * -1) 0;\n padding: calc(16px / 8);\n padding: var(--space-smallest);\n border: none;\n background-color: transparent;\n cursor: pointer;\n -webkit-appearance: none;\n appearance: none;\n -ms-flex: 0;\n flex: 0;\n -ms-flex-item-align: start;\n align-self: flex-start;\n}\n\n.lunQ5SOfyLg-:hover {\n background: rgba(0, 0, 0, 0.025);\n}\n\n.lunQ5SOfyLg-:focus {\n box-shadow: 0px 0px calc(16px / 4) calc(16px / 8)\n rgb(231, 213, 87);\n box-shadow: var(--shadow-focus);\n outline: none;\n background: rgba(0, 0, 0, 0.05);\n}\n";
21
+ var css_248z$1 = ".meuT8gYQPJU- {\n display: -ms-flexbox;\n display: flex;\n position: relative;\n box-shadow: 0px calc(16px / 16) calc(16px / 4) 0px\n rgba(0, 0, 0, 0.1),\n 0px calc(16px / 4) 12px 0px rgba(0, 0, 0, 0.05);\n box-shadow: var(--shadow-base);\n padding: calc(16px * 1);\n padding: var(--space-base);\n color: rgb(66, 78, 86);\n color: var(--color-text);\n background-color: rgb(244, 244, 244);\n background-color: var(--color-surface--background);\n gap: calc(16px / 2);\n gap: var(--space-small);\n -ms-flex-align: center;\n align-items: center;\n}\n\n.y4BapyZr-fo- > a {\n color: rgb(66, 78, 86);\n color: var(--color-text);\n}\n\n.y4BapyZr-fo- > a:hover {\n color: rgb(1, 41, 57);\n color: var(--color-blue);\n}\n\n._6v1woNSLEvc- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n gap: calc(16px / 2);\n gap: var(--space-small);\n -ms-flex-wrap: nowrap;\n flex-wrap: nowrap;\n -ms-flex-pack: justify;\n justify-content: space-between;\n -ms-flex-align: start;\n align-items: flex-start;\n}\n\n@media (max-width: 489.98px) {\n\n._6v1woNSLEvc- {\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n}\n }\n\n@media (--small-screens-and-below) {\n\n._6v1woNSLEvc- {\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n}\n }\n\n.y4BapyZr-fo- {\n -ms-flex: 1;\n flex: 1;\n -ms-flex-item-align: center;\n align-self: center;\n}\n\n._6v1woNSLEvc- > *:last-child {\n margin-bottom: 0;\n}\n\n.bocgLmEhcTU- .y4BapyZr-fo- {\n -ms-flex: 1;\n flex: 1;\n}\n\n.rtNjEzmABX4- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex: 0 0 auto;\n flex: 0 0 auto;\n}\n\n@media (max-width: 489.98px) {\n\n.rtNjEzmABX4- {\n width: 100%;\n margin-top: calc(16px / 2);\n margin-top: var(--space-small);\n}\n }\n\n@media (--small-screens-and-below) {\n\n.rtNjEzmABX4- {\n width: 100%;\n margin-top: calc(16px / 2);\n margin-top: var(--space-small);\n}\n }\n\n.lunQ5SOfyLg- {\n margin: calc((16px / 8) * -1) 0;\n margin: calc(calc(16px / 8) * -1) 0;\n margin: calc(var(--space-smallest) * -1) 0;\n padding: calc(16px / 8);\n padding: var(--space-smallest);\n border: none;\n background-color: transparent;\n cursor: pointer;\n -webkit-appearance: none;\n appearance: none;\n -ms-flex: 0;\n flex: 0;\n -ms-flex-item-align: start;\n align-self: flex-start;\n}\n\n.lunQ5SOfyLg-:hover {\n background: rgba(0, 0, 0, 0.025);\n}\n\n.lunQ5SOfyLg-:focus {\n box-shadow: 0px 0px calc(16px / 4) calc(16px / 8)\n rgb(231, 213, 87);\n box-shadow: var(--shadow-focus);\n outline: none;\n background: rgba(0, 0, 0, 0.05);\n}\n";
22
22
  var styles = {"banner":"meuT8gYQPJU-","bannerChildren":"y4BapyZr-fo-","bannerContent":"_6v1woNSLEvc-","medium":"bocgLmEhcTU-","bannerAction":"rtNjEzmABX4-","closeButton":"lunQ5SOfyLg-"};
23
23
  styleInject_es.styleInject(css_248z$1);
24
24
 
@@ -26,7 +26,11 @@ var css_248z = ".wWW-2T7rCV0- {\n background-color: rgb(226, 241, 250);\n back
26
26
  var types = {"notice":"wWW-2T7rCV0-","success":"_7h8FUHIkVjg-","warning":"d5fXcE1L0lc-","error":"oYaw-T3c0IU-"};
27
27
  styleInject_es.styleInject(css_248z);
28
28
 
29
- function Banner({ children, type, primaryAction, dismissible = true, onDismiss, }) {
29
+ function BannerIcon({ icon }) {
30
+ return React__default["default"].createElement(Icon.Icon, { name: icon, customColor: "greyBlue" });
31
+ }
32
+
33
+ function Banner({ children, type, primaryAction, dismissible = true, icon, onDismiss, }) {
30
34
  const [showBanner, setShowBanner] = React.useState(true);
31
35
  const bannerWidths = {
32
36
  small: 320,
@@ -53,6 +57,7 @@ function Banner({ children, type, primaryAction, dismissible = true, onDismiss,
53
57
  });
54
58
  return (React__default["default"].createElement(React__default["default"].Fragment, null, showBanner && (React__default["default"].createElement("div", { className: bannerClassNames, ref: bannerRef, role: type === "error" ? "alert" : "status" },
55
59
  React__default["default"].createElement("div", { className: styles.bannerContent },
60
+ icon && React__default["default"].createElement(BannerIcon, { icon: icon }),
56
61
  React__default["default"].createElement("div", { className: styles.bannerChildren },
57
62
  React__default["default"].createElement(BannerChildren, null, children)),
58
63
  primaryAction && (React__default["default"].createElement("div", { className: styles.bannerAction },
@@ -7,6 +7,7 @@ export interface InputTextRef {
7
7
  insert(text: string): void;
8
8
  blur(): void;
9
9
  focus(): void;
10
+ scrollIntoView(arg?: boolean | ScrollIntoViewOptions): void;
10
11
  }
11
12
  export declare const InputText: React.ForwardRefExoticComponent<({
12
13
  readonly multiline: true;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var InputText = require('../InputText-e9b345ff.js');
5
+ var InputText = require('../InputText-c66e199a.js');
6
6
  require('react');
7
7
  require('../FormField-090113ec.js');
8
8
  require('../tslib.es6-5b8768b7.js');
@@ -8,8 +8,8 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
8
8
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
9
9
 
10
10
  function InputTextInternal(props, ref) {
11
- const inputRef = React.createRef();
12
- const actionsRef = React.createRef();
11
+ const inputRef = React.useRef(null);
12
+ const actionsRef = React.useRef(null);
13
13
  const rowRange = getRowRange();
14
14
  React.useImperativeHandle(ref, () => ({
15
15
  insert: (text) => {
@@ -27,6 +27,12 @@ function InputTextInternal(props, ref) {
27
27
  input.focus();
28
28
  }
29
29
  },
30
+ scrollIntoView: arg => {
31
+ const input = inputRef.current;
32
+ if (input) {
33
+ input.scrollIntoView(arg);
34
+ }
35
+ },
30
36
  }));
31
37
  React.useLayoutEffect(() => {
32
38
  if (inputRef && inputRef.current instanceof HTMLTextAreaElement) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "4.24.0",
3
+ "version": "4.24.1-JOB-73446.18+8d79ecb0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "dependencies": {
22
22
  "@jobber/design": "^0.44.4",
23
- "@jobber/formatters": "*",
23
+ "@jobber/formatters": "^0.2.2",
24
24
  "@jobber/hooks": "^2.1.5",
25
25
  "@popperjs/core": "^2.0.6",
26
26
  "@std-proposal/temporal": "0.0.1",
@@ -83,5 +83,5 @@
83
83
  "> 1%",
84
84
  "IE 10"
85
85
  ],
86
- "gitHead": "9fd0b22b3c6f4f50847e35ee070f9c8ff562927c"
86
+ "gitHead": "8d79ecb06179867364568a12ca5496fbd7d58ed2"
87
87
  }