@7shifts/sous-chef 1.5.6 → 1.5.7

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,24 +1,27 @@
1
1
  import React from 'react';
2
2
  declare type AutoCompleteType = 'off' | 'on';
3
3
  declare type Props = {
4
- name: string;
4
+ autoComplete?: AutoCompleteType;
5
+ autoFocus?: boolean;
6
+ caption?: React.ReactNode;
7
+ defaultValue?: string;
8
+ disabled?: boolean;
9
+ error?: string;
5
10
  /** If not provided it will generate a random id so the label links properly with the text input */
6
11
  id?: string;
7
- value?: string;
8
- onChange?: (e: string) => void;
9
- onBlur?: (e: string) => void;
10
12
  label?: React.ReactNode;
11
- caption?: React.ReactNode;
12
- error?: string;
13
+ maxLength?: number;
14
+ name: string;
15
+ onBlur?: (value: string) => void;
16
+ onChange?: (value: string) => void;
17
+ onFocus?: (value: string) => void;
18
+ onKeyDown?: (key: string) => void;
13
19
  placeholder?: string;
14
- disabled?: boolean;
15
20
  /** Use a prefix for things like currency symbols (“$”, “¥”, “£”) or icons. */
16
21
  prefix?: React.ReactNode;
17
22
  /** Use suffix for things like units of measure (“in”, “cm”, ”hours”) or icons. */
18
23
  suffix?: React.ReactNode;
19
- defaultValue?: string;
20
- autoFocus?: boolean;
21
- autoComplete?: AutoCompleteType;
24
+ value?: string;
22
25
  };
23
26
  declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLInputElement>>;
24
27
  export default _default;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  declare type InputElement = HTMLInputElement | HTMLTextAreaElement;
3
3
  declare type FieldControls = {
4
4
  id: string;
@@ -6,15 +6,19 @@ declare type FieldControls = {
6
6
  value?: string;
7
7
  onChange: (e: React.ChangeEvent<InputElement>) => void;
8
8
  onBlur: (e: React.ChangeEvent<InputElement>) => void;
9
+ onFocus: (e: React.FocusEvent<InputElement>) => void;
10
+ onKeyDown: (e: React.KeyboardEvent<InputElement>) => void;
9
11
  };
10
12
  declare type Props = {
11
13
  name: string;
12
14
  id?: string;
13
15
  value?: string;
14
- onChange?: (e: string) => void;
15
- onBlur?: (e: string) => void;
16
+ onChange?: (value: string) => void;
17
+ onBlur?: (value: string) => void;
18
+ onFocus?: (value: string) => void;
19
+ onKeyDown?: (key: string) => void;
16
20
  error?: string;
17
21
  type?: 'text' | 'currency';
18
22
  };
19
- export declare const useFieldControllers: ({ name, id: inputId, value, onChange, onBlur, error, type }: Props) => FieldControls;
23
+ export declare const useFieldControllers: ({ name, id: inputId, value, onChange, onBlur, onFocus, onKeyDown, error, type }: Props) => FieldControls;
20
24
  export {};
package/dist/index.js CHANGED
@@ -1652,6 +1652,8 @@ var useFieldControllers = function useFieldControllers(_ref) {
1652
1652
  value = _ref.value,
1653
1653
  _onChange = _ref.onChange,
1654
1654
  _onBlur = _ref.onBlur,
1655
+ _onFocus = _ref.onFocus,
1656
+ _onKeyDown = _ref.onKeyDown,
1655
1657
  error = _ref.error,
1656
1658
  _ref$type = _ref.type,
1657
1659
  type = _ref$type === void 0 ? 'text' : _ref$type;
@@ -1672,6 +1674,12 @@ var useFieldControllers = function useFieldControllers(_ref) {
1672
1674
  },
1673
1675
  onBlur: function onBlur(e) {
1674
1676
  return _onBlur && _onBlur(e.target.value);
1677
+ },
1678
+ onFocus: function onFocus(e) {
1679
+ return _onFocus && _onFocus(e.target.value);
1680
+ },
1681
+ onKeyDown: function onKeyDown(e) {
1682
+ return _onKeyDown && _onKeyDown(e.key);
1675
1683
  }
1676
1684
  };
1677
1685
  var formikState = getFormikState(name, formik);
@@ -2080,58 +2088,66 @@ var styles$k = {"text-field":"_20YOA","text-field--invalid":"_3kUSh","text-field
2080
2088
  var TextField = function TextField(_ref, ref) {
2081
2089
  var _classnames;
2082
2090
 
2083
- var name = _ref.name,
2084
- inputId = _ref.id,
2085
- value = _ref.value,
2086
- onChange = _ref.onChange,
2087
- onBlur = _ref.onBlur,
2088
- label = _ref.label,
2091
+ var autoComplete = _ref.autoComplete,
2092
+ autoFocus = _ref.autoFocus,
2089
2093
  caption = _ref.caption,
2094
+ defaultValue = _ref.defaultValue,
2095
+ disabled = _ref.disabled,
2090
2096
  error = _ref.error,
2097
+ inputId = _ref.id,
2098
+ label = _ref.label,
2099
+ maxLength = _ref.maxLength,
2100
+ name = _ref.name,
2101
+ onBlur = _ref.onBlur,
2102
+ onChange = _ref.onChange,
2103
+ onFocus = _ref.onFocus,
2104
+ onKeyDown = _ref.onKeyDown,
2091
2105
  placeholder = _ref.placeholder,
2092
- disabled = _ref.disabled,
2093
2106
  prefix = _ref.prefix,
2094
2107
  suffix = _ref.suffix,
2095
- defaultValue = _ref.defaultValue,
2096
- autoFocus = _ref.autoFocus,
2097
- autoComplete = _ref.autoComplete;
2108
+ value = _ref.value;
2098
2109
  var controllers = useFieldControllers({
2099
- name: name,
2110
+ error: error,
2100
2111
  id: inputId,
2101
- value: value,
2112
+ name: name,
2102
2113
  onChange: onChange,
2103
2114
  onBlur: onBlur,
2104
- error: error
2115
+ onFocus: onFocus,
2116
+ onKeyDown: onKeyDown,
2117
+ value: value
2105
2118
  });
2106
2119
  var hasError = !!controllers.error;
2107
2120
  var fieldProps = {
2108
- name: name,
2109
- id: controllers.id,
2110
- label: label,
2111
2121
  caption: caption,
2112
- error: controllers.error
2122
+ error: controllers.error,
2123
+ label: label,
2124
+ id: controllers.id,
2125
+ name: name
2113
2126
  };
2114
2127
  return React__default.createElement(Field, Object.assign({}, fieldProps), React__default.createElement(AffixContainer, {
2115
2128
  prefix: prefix,
2116
2129
  suffix: suffix
2117
2130
  }, React__default.createElement("input", {
2118
- name: name,
2119
- id: controllers.id,
2120
- className: classnames(styles$k['text-field'], (_classnames = {}, _classnames[styles$k['text-field--invalid']] = hasError, _classnames)),
2121
- type: "text",
2122
- "data-testid": "text-field-" + name,
2123
2131
  "aria-describedby": hasError ? controllers.id + "-error-message" : controllers.id + "-describer",
2124
2132
  "aria-invalid": hasError,
2133
+ autoComplete: autoComplete,
2134
+ autoFocus: autoFocus,
2135
+ className: classnames(styles$k['text-field'], (_classnames = {}, _classnames[styles$k['text-field--invalid']] = hasError, _classnames)),
2136
+ "data-testid": "text-field-" + name,
2125
2137
  disabled: disabled,
2126
- placeholder: placeholder,
2127
2138
  defaultValue: defaultValue,
2128
- value: controllers.value,
2129
- onChange: controllers.onChange,
2139
+ id: controllers.id,
2140
+ maxLength: maxLength,
2141
+ name: name,
2130
2142
  onBlur: controllers.onBlur,
2131
- size: 1,
2143
+ onChange: controllers.onChange,
2144
+ onFocus: controllers.onFocus,
2145
+ onKeyDown: controllers.onKeyDown,
2146
+ placeholder: placeholder,
2132
2147
  ref: ref,
2133
- autoFocus: autoFocus,
2134
- autoComplete: autoComplete
2148
+ size: 1,
2149
+ type: "text",
2150
+ value: controllers.value
2135
2151
  })));
2136
2152
  };
2137
2153