@jobber/components 4.24.1-autocomple.1 → 4.24.2-JOB-69677.2

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,7 +1,6 @@
1
- import React from "react";
1
+ /// <reference types="react" />
2
2
  import { XOR } from "ts-xor";
3
3
  import { GroupOption, Option } from "./Option";
4
- import { InputTextRef } from "../InputText";
5
4
  import { FormFieldProps } from "../FormField";
6
5
  type OptionCollection = XOR<Option[], GroupOption[]>;
7
6
  interface AutocompleteProps extends Pick<FormFieldProps, "inputRef" | "invalid" | "name" | "onBlur" | "onFocus" | "prefix" | "size" | "suffix" | "validations"> {
@@ -41,5 +40,5 @@ interface AutocompleteProps extends Pick<FormFieldProps, "inputRef" | "invalid"
41
40
  */
42
41
  readonly placeholder: string;
43
42
  }
44
- export declare const Autocomplete: React.ForwardRefExoticComponent<AutocompleteProps & React.RefAttributes<InputTextRef>>;
43
+ export declare function Autocomplete({ initialOptions, value, allowFreeForm, size, debounce: debounceRate, onChange, getOptions, placeholder, onBlur, onFocus, validations, ...inputProps }: AutocompleteProps): JSX.Element;
45
44
  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-c2a7f236.js');
16
+ var InputText = require('../InputText-e9b345ff.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 AutocompleteInternal(_a, ref) {
150
+ function Autocomplete(_a) {
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 AutocompleteInternal(_a, ref) {
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({ ref: ref, 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({ 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,6 +214,5 @@ function mapToOptions(items) {
214
214
  return result;
215
215
  }, []);
216
216
  }
217
- const Autocomplete = React.forwardRef(AutocompleteInternal);
218
217
 
219
218
  exports.Autocomplete = Autocomplete;
@@ -7,11 +7,6 @@ export interface InputTextRef {
7
7
  insert(text: string): void;
8
8
  blur(): void;
9
9
  focus(): void;
10
- scrollIntoView({ behavior, block, inline, }: {
11
- behavior?: ScrollBehavior;
12
- block?: ScrollLogicalPosition;
13
- inline?: ScrollLogicalPosition;
14
- }): void;
15
10
  }
16
11
  export declare const InputText: React.ForwardRefExoticComponent<({
17
12
  readonly multiline: true;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var InputText = require('../InputText-c2a7f236.js');
5
+ var InputText = require('../InputText-e9b345ff.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.useRef(null);
12
- const actionsRef = React.useRef(null);
11
+ const inputRef = React.createRef();
12
+ const actionsRef = React.createRef();
13
13
  const rowRange = getRowRange();
14
14
  React.useImperativeHandle(ref, () => ({
15
15
  insert: (text) => {
@@ -27,12 +27,6 @@ function InputTextInternal(props, ref) {
27
27
  input.focus();
28
28
  }
29
29
  },
30
- scrollIntoView: ({ behavior, block, inline }) => {
31
- const input = inputRef.current;
32
- if (input) {
33
- input.scrollIntoView({ behavior, block, inline });
34
- }
35
- },
36
30
  }));
37
31
  React.useLayoutEffect(() => {
38
32
  if (inputRef && inputRef.current instanceof HTMLTextAreaElement) {
@@ -1,34 +1,48 @@
1
- import { PropsWithChildren } from "react";
1
+ import { ReactNode } from "react";
2
2
  import { XOR } from "ts-xor";
3
- interface BaseRadioOptions {
3
+ interface BaseRadioOptionProps {
4
+ /**
5
+ * The value of the radio button.
6
+ */
4
7
  readonly value: string | number;
8
+ /**
9
+ * Disables the radio button.
10
+ */
5
11
  readonly disabled?: boolean;
6
- }
7
- interface RadioOptionsWithDescription extends BaseRadioOptions {
12
+ /**
13
+ * Further description of the label.
14
+ */
15
+ readonly description?: string;
8
16
  /**
9
17
  * The label to appear beside the radio button.
10
18
  */
11
- label: string;
19
+ readonly label?: string;
12
20
  /**
13
- * Further description of the label.
21
+ * Provide children elements to render a custom label component if `label` is
22
+ * not provided, or associated additional content with the radio button if
23
+ * `label` is provided.
24
+ *
25
+ * Prefer using `label` and `description` over adding child elements if the
26
+ * content of either would be text.
14
27
  */
15
- description?: string;
28
+ readonly children?: ReactNode;
16
29
  }
17
- type RadioOptionProps = XOR<RadioOptionsWithDescription, PropsWithChildren<BaseRadioOptions>>;
30
+ interface WithRequiredChildren extends BaseRadioOptionProps {
31
+ readonly children: ReactNode;
32
+ }
33
+ interface WithRequiredLabel extends BaseRadioOptionProps {
34
+ readonly label: string;
35
+ }
36
+ type RadioOptionProps = XOR<WithRequiredChildren, WithRequiredLabel>;
18
37
  /**
19
38
  * For rendering props only. To make updates to
20
39
  * the real RadioOption, look at InternalRadioOption
21
40
  */
22
- export declare function RadioOption({ children }: PropsWithChildren<RadioOptionProps>): JSX.Element;
23
- interface BaseInternalRadioOptions extends BaseRadioOptions {
41
+ export declare function RadioOption({ children }: RadioOptionProps): JSX.Element;
42
+ interface InternalRadioOptionProps extends BaseRadioOptionProps {
24
43
  readonly name: string;
25
44
  readonly checked: boolean;
26
45
  onChange(newValue: string | number): void;
27
46
  }
28
- interface InternalRadioOptionsWithDescription extends BaseInternalRadioOptions {
29
- label: string;
30
- description?: string;
31
- }
32
- type InternalRadioOptionProps = XOR<InternalRadioOptionsWithDescription, PropsWithChildren<BaseInternalRadioOptions>>;
33
- export declare function InternalRadioOption({ value, name, label, description, disabled, checked, children, onChange, }: PropsWithChildren<InternalRadioOptionProps>): JSX.Element;
47
+ export declare function InternalRadioOption({ value, name, label, description, disabled, checked, children, onChange, }: InternalRadioOptionProps): JSX.Element;
34
48
  export {};
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var RadioGroup = require('../RadioGroup-67a5f560.js');
5
+ var RadioGroup = require('../RadioGroup-8e76d20b.js');
6
6
  require('react');
7
7
  require('uuid');
8
8
  require('../style-inject.es-9d2f5f4e.js');
@@ -9,8 +9,8 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
9
9
 
10
10
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
11
11
 
12
- var css_248z = "._5P8wEHDUdKY- {\n display: -ms-inline-flexbox;\n display: inline-flex;\n -ms-flex-direction: column;\n flex-direction: column;\n}\n\n._08ZPdlE98Ko- {\n /* Hide checkbox on UI but not screen readers and still allow focus state */\n position: absolute;\n left: -999vw;\n}\n\n.-PUoLXltVlQ- {\n display: -ms-inline-flexbox;\n display: inline-flex;\n font-size: calc((16px * 1) * 0.875);\n font-size: calc(calc(16px * 1) * 0.875);\n font-size: var(--typography--fontSize-base);\n cursor: pointer;\n -ms-flex-align: start;\n align-items: flex-start;\n}\n\n._08ZPdlE98Ko- + .-PUoLXltVlQ-::before {\n content: \"\";\n display: block;\n width: calc(16px * 1);\n width: var(--space-base);\n height: calc(16px * 1);\n height: var(--space-base);\n box-sizing: border-box;\n margin: calc(16px / 8) calc(16px / 2) 0 0;\n margin: var(--space-smallest) var(--space-small) 0 0;\n border: calc(16px / 8) solid rgb(125, 176, 14);\n border: var(--border-thick) solid var(--color-interactive);\n border-radius: 100%;\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n transition: all 200ms;\n transition: all var(--timing-base);\n -ms-flex-negative: 0;\n flex-shrink: 0;\n}\n\n._08ZPdlE98Ko-:focus + .-PUoLXltVlQ-:before {\n box-shadow: 0px 0px calc(16px / 4) calc(16px / 8)\n rgb(231, 213, 87);\n box-shadow: var(--shadow-focus);\n}\n\n._08ZPdlE98Ko-:focus:checked + .-PUoLXltVlQ-:before {\n box-shadow: 0px 0px 0px calc(16px / 16) rgb(81, 114, 9),\n 0px 0px calc(16px / 4) calc(16px / 8)\n rgb(231, 213, 87);\n box-shadow: 0px 0px 0px var(--space-minuscule) var(--color-interactive--hover),\n var(--shadow-focus);\n}\n\n._08ZPdlE98Ko-:checked + .-PUoLXltVlQ-::before {\n box-shadow: 0px 0px 0px calc(16px / 16) rgb(81, 114, 9);\n box-shadow: 0px 0px 0px var(--space-minuscule) var(--color-interactive--hover);\n border-color: rgb(81, 114, 9);\n border-color: var(--color-interactive--hover);\n border-width: calc(16px / 4);\n border-width: var(--border-thicker);\n background-color: rgb(125, 176, 14);\n background-color: var(--color-interactive);\n}\n\n._08ZPdlE98Ko-[disabled] + .-PUoLXltVlQ- {\n color: rgb(181, 181, 181);\n color: var(--color-disabled);\n cursor: not-allowed;\n}\n\n._08ZPdlE98Ko-[disabled] + .-PUoLXltVlQ-::before {\n border-color: rgb(225, 225, 225);\n border-color: var(--color-disabled--secondary);\n}\n\n._08ZPdlE98Ko-[disabled]:checked + .-PUoLXltVlQ-::before {\n box-shadow: 0px 0px 0px calc(16px / 16) rgb(181, 181, 181);\n box-shadow: 0px 0px 0px var(--space-minuscule) var(--color-disabled);\n border-color: rgb(181, 181, 181);\n border-color: var(--color-grey);\n background-color: rgb(225, 225, 225);\n background-color: var(--color-disabled--secondary);\n}\n\n._8r6qT-6S9EI- {\n margin-bottom: calc(16px / 2);\n margin-bottom: var(--space-small);\n padding-left: calc(16px * 1.5);\n padding-left: var(--space-large);\n}\n\n._08ZPdlE98Ko-[disabled] + .-PUoLXltVlQ- + ._8r6qT-6S9EI- > p {\n color: rgb(181, 181, 181);\n color: var(--color-disabled);\n}\n";
13
- var styles = {"radioGroup":"_5P8wEHDUdKY-","input":"_08ZPdlE98Ko-","label":"-PUoLXltVlQ-","description":"_8r6qT-6S9EI-"};
12
+ var css_248z = "._5P8wEHDUdKY- {\n display: -ms-inline-flexbox;\n display: inline-flex;\n -ms-flex-direction: column;\n flex-direction: column;\n}\n\n._08ZPdlE98Ko- {\n /* Hide checkbox on UI but not screen readers and still allow focus state */\n position: absolute;\n left: -999vw;\n}\n\n.-PUoLXltVlQ- {\n display: -ms-inline-flexbox;\n display: inline-flex;\n font-size: calc((16px * 1) * 0.875);\n font-size: calc(calc(16px * 1) * 0.875);\n font-size: var(--typography--fontSize-base);\n cursor: pointer;\n -ms-flex-align: start;\n align-items: flex-start;\n}\n\n._08ZPdlE98Ko- + .-PUoLXltVlQ-::before {\n content: \"\";\n display: block;\n width: calc(16px * 1);\n width: var(--space-base);\n height: calc(16px * 1);\n height: var(--space-base);\n box-sizing: border-box;\n margin: calc(16px / 8) calc(16px / 2) 0 0;\n margin: var(--space-smallest) var(--space-small) 0 0;\n border: calc(16px / 8) solid rgb(125, 176, 14);\n border: var(--border-thick) solid var(--color-interactive);\n border-radius: 100%;\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n transition: all 200ms;\n transition: all var(--timing-base);\n -ms-flex-negative: 0;\n flex-shrink: 0;\n}\n\n._08ZPdlE98Ko-:focus + .-PUoLXltVlQ-:before {\n box-shadow: 0px 0px calc(16px / 4) calc(16px / 8)\n rgb(231, 213, 87);\n box-shadow: var(--shadow-focus);\n}\n\n._08ZPdlE98Ko-:focus:checked + .-PUoLXltVlQ-:before {\n box-shadow: 0px 0px 0px calc(16px / 16) rgb(81, 114, 9),\n 0px 0px calc(16px / 4) calc(16px / 8)\n rgb(231, 213, 87);\n box-shadow: 0px 0px 0px var(--space-minuscule) var(--color-interactive--hover),\n var(--shadow-focus);\n}\n\n._08ZPdlE98Ko-:checked + .-PUoLXltVlQ-::before {\n box-shadow: 0px 0px 0px calc(16px / 16) rgb(81, 114, 9);\n box-shadow: 0px 0px 0px var(--space-minuscule) var(--color-interactive--hover);\n border-color: rgb(81, 114, 9);\n border-color: var(--color-interactive--hover);\n border-width: calc(16px / 4);\n border-width: var(--border-thicker);\n background-color: rgb(125, 176, 14);\n background-color: var(--color-interactive);\n}\n\n._08ZPdlE98Ko-[disabled] + .-PUoLXltVlQ- {\n color: rgb(181, 181, 181);\n color: var(--color-disabled);\n cursor: not-allowed;\n}\n\n._08ZPdlE98Ko-[disabled] + .-PUoLXltVlQ-::before {\n border-color: rgb(225, 225, 225);\n border-color: var(--color-disabled--secondary);\n}\n\n._08ZPdlE98Ko-[disabled]:checked + .-PUoLXltVlQ-::before {\n box-shadow: 0px 0px 0px calc(16px / 16) rgb(181, 181, 181);\n box-shadow: 0px 0px 0px var(--space-minuscule) var(--color-disabled);\n border-color: rgb(181, 181, 181);\n border-color: var(--color-grey);\n background-color: rgb(225, 225, 225);\n background-color: var(--color-disabled--secondary);\n}\n\n._8r6qT-6S9EI-,\n.C5SzbO1epLk- {\n margin-bottom: calc(16px / 2);\n margin-bottom: var(--space-small);\n padding-left: calc(16px * 1.5);\n padding-left: var(--space-large);\n}\n\n._08ZPdlE98Ko-[disabled] + .-PUoLXltVlQ- + ._8r6qT-6S9EI- > p {\n color: rgb(181, 181, 181);\n color: var(--color-disabled);\n}\n";
13
+ var styles = {"radioGroup":"_5P8wEHDUdKY-","input":"_08ZPdlE98Ko-","label":"-PUoLXltVlQ-","description":"_8r6qT-6S9EI-","children":"C5SzbO1epLk-"};
14
14
  styleInject_es.styleInject(css_248z);
15
15
 
16
16
  /**
@@ -22,11 +22,13 @@ function RadioOption({ children }) {
22
22
  }
23
23
  function InternalRadioOption({ value, name, label, description, disabled, checked, children, onChange, }) {
24
24
  const inputId = `${value.toString()}_${uuid.v1()}`;
25
+ const shouldRenderIndependentChildren = label && children;
25
26
  return (React__default["default"].createElement("div", null,
26
27
  React__default["default"].createElement("input", { onChange: handleChange, type: "radio", name: name, value: value, disabled: disabled, checked: checked, id: inputId, className: styles.input, "aria-describedby": description ? `${inputId}_description` : undefined }),
27
28
  React__default["default"].createElement("label", { className: styles.label, htmlFor: inputId }, label ? label : children),
28
29
  description && (React__default["default"].createElement("div", { className: styles.description, id: `${inputId}_description` },
29
- React__default["default"].createElement(Text.Text, { variation: "subdued", size: "small" }, description)))));
30
+ React__default["default"].createElement(Text.Text, { variation: "subdued", size: "small" }, description))),
31
+ shouldRenderIndependentChildren && (React__default["default"].createElement("div", { className: styles.children, id: `${inputId}_children` }, children))));
30
32
  function handleChange() {
31
33
  onChange(value);
32
34
  }
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var React = require('react');
6
6
  var uuid = require('uuid');
7
7
  var styleInject_es = require('../style-inject.es-9d2f5f4e.js');
8
- var RadioGroup = require('../RadioGroup-67a5f560.js');
8
+ var RadioGroup = require('../RadioGroup-8e76d20b.js');
9
9
  var Text = require('../Text-e7ed0974.js');
10
10
  require('classnames');
11
11
  require('../Typography-fd6f932a.js');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "4.24.1-autocomple.1+06412fec",
3
+ "version": "4.24.2-JOB-69677.2+f23c24af",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -83,5 +83,5 @@
83
83
  "> 1%",
84
84
  "IE 10"
85
85
  ],
86
- "gitHead": "06412fec17ffca111043706527b356b04cacdb66"
86
+ "gitHead": "f23c24afea608b7502bcd1f8ca1c53aaa5ea3a33"
87
87
  }