@paprika/textarea 3.0.2-next.0 → 3.0.4-next.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/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.0.4-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [27e1439]
8
+ - @paprika/tokens@1.1.1-next.0
9
+ - @paprika/stylers@1.1.2-next.0
10
+
11
+ ## 3.0.3
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [3385c1f]
16
+ - Updated dependencies [fd94ddb]
17
+ - @paprika/tokens@1.1.0
18
+ - @paprika/stylers@1.1.1
19
+
20
+ ## 3.0.3-next.0
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies [3385c1f]
25
+ - @paprika/tokens@1.1.0-next.0
26
+ - @paprika/stylers@1.1.1-next.0
27
+
28
+ ## 3.0.2
29
+
30
+ ### Patch Changes
31
+
32
+ - Updated dependencies [ca237ea]
33
+ - @paprika/stylers@1.1.0
34
+
3
35
  ## 3.0.2-next.0
4
36
 
5
37
  ### Patch Changes
package/lib/Textarea.js CHANGED
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
3
+ var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
4
4
 
5
- var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
5
+ var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
6
6
 
7
7
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
8
8
 
9
- var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
9
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
10
10
 
11
- var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
11
+ var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
12
12
 
13
13
  _Object$defineProperty(exports, "__esModule", {
14
14
  value: true
@@ -32,6 +32,8 @@ var _TextareaPropsCollector = _interopRequireDefault(require("./TextareaPropsCol
32
32
 
33
33
  var sc = _interopRequireWildcard(require("./Textarea.styles"));
34
34
 
35
+ var _excluded = ["a11yText", "canExpand", "children", "defaultValue", "hasError", "isDisabled", "onChange", "isReadOnly", "maxHeight", "minHeight", "size", "value"];
36
+
35
37
  function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
36
38
 
37
39
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -49,7 +51,7 @@ var Textarea = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
49
51
  minHeight = props.minHeight,
50
52
  size = props.size,
51
53
  value = props.value,
52
- moreProps = (0, _objectWithoutProperties2["default"])(props, ["a11yText", "canExpand", "children", "defaultValue", "hasError", "isDisabled", "onChange", "isReadOnly", "maxHeight", "minHeight", "size", "value"]);
54
+ moreProps = (0, _objectWithoutProperties2["default"])(props, _excluded);
53
55
  var isControlled = value !== undefined;
54
56
  var containerProps = (0, _helpers.extractChildrenProps)(children, _TextareaPropsCollector["default"]);
55
57
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/Textarea.js"],"names":["Textarea","React","forwardRef","props","ref","a11yText","canExpand","children","defaultValue","hasError","isDisabled","onChange","isReadOnly","maxHeight","minHeight","size","value","moreProps","isControlled","undefined","containerProps","TextareaPropsCollector","_refTextarea","useRef","refTextarea","handleResize","useCallback","current","style","height","scrollHeight","handleChange","useLayoutEffect","window","addEventListener","cleanup","removeEventListener","styleProps","types","constants","defaultSize","propTypes","PropTypes","string","bool","node","oneOfType","number","func","oneOf","SMALL","MEDIUM","LARGE","defaultProps","displayName","Container"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,QAAQ,gBAAGC,kBAAMC,UAAN,CAAiB,UAACC,KAAD,EAAQC,GAAR,EAAgB;AAAA,MAE9CC,QAF8C,GAe5CF,KAf4C,CAE9CE,QAF8C;AAAA,MAG9CC,SAH8C,GAe5CH,KAf4C,CAG9CG,SAH8C;AAAA,MAI9CC,QAJ8C,GAe5CJ,KAf4C,CAI9CI,QAJ8C;AAAA,MAK9CC,YAL8C,GAe5CL,KAf4C,CAK9CK,YAL8C;AAAA,MAM9CC,QAN8C,GAe5CN,KAf4C,CAM9CM,QAN8C;AAAA,MAO9CC,UAP8C,GAe5CP,KAf4C,CAO9CO,UAP8C;AAAA,MAQ9CC,QAR8C,GAe5CR,KAf4C,CAQ9CQ,QAR8C;AAAA,MAS9CC,UAT8C,GAe5CT,KAf4C,CAS9CS,UAT8C;AAAA,MAU9CC,SAV8C,GAe5CV,KAf4C,CAU9CU,SAV8C;AAAA,MAW9CC,SAX8C,GAe5CX,KAf4C,CAW9CW,SAX8C;AAAA,MAY9CC,IAZ8C,GAe5CZ,KAf4C,CAY9CY,IAZ8C;AAAA,MAa9CC,KAb8C,GAe5Cb,KAf4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-types\";\nimport { callAll, extractChildrenProps } from \"@paprika/helpers\";\nimport * as constants from \"@paprika/constants/lib/Constants\";\nimport TextareaPropsCollector from \"./TextareaPropsCollector\";\nimport * as sc from \"./Textarea.styles\";\n\nconst Textarea = React.forwardRef((props, ref) => {\n const {\n a11yText,\n canExpand,\n children,\n defaultValue,\n hasError,\n isDisabled,\n onChange,\n isReadOnly,\n maxHeight,\n minHeight,\n size,\n value,\n ...moreProps\n } = props;\n\n const isControlled = value !== undefined;\n const containerProps = extractChildrenProps(children, TextareaPropsCollector);\n\n const _refTextarea = React.useRef();\n const refTextarea = ref || _refTextarea;\n\n const handleResize = React.useCallback(() => {\n if (refTextarea.current && refTextarea.current.style) {\n refTextarea.current.style.height = 0;\n refTextarea.current.style.height = `${refTextarea.current.scrollHeight + 2}px`;\n }\n }, [refTextarea]);\n\n function handleChange() {\n if (canExpand) {\n handleResize();\n }\n }\n\n React.useLayoutEffect(() => {\n if (canExpand) {\n handleResize();\n window.addEventListener(\"resize\", handleResize);\n }\n\n return function cleanup() {\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [canExpand, handleResize]);\n\n React.useLayoutEffect(() => {\n if (canExpand) {\n handleResize();\n }\n }, [canExpand, minHeight, maxHeight, handleResize]);\n\n const styleProps = {\n hasError,\n isDisabled,\n isReadOnly,\n maxHeight,\n minHeight,\n size,\n };\n\n return (\n <div data-pka-anchor=\"textarea.container\" {...containerProps}>\n <sc.Textarea\n aria-invalid={hasError}\n aria-label={a11yText}\n data-pka-anchor=\"textarea\"\n defaultValue={!isControlled ? defaultValue : undefined}\n disabled={isDisabled}\n onChange={callAll(handleChange, onChange)}\n readOnly={isReadOnly}\n ref={refTextarea}\n value={isControlled ? value : undefined}\n {...styleProps}\n {...moreProps}\n />\n </div>\n );\n});\n\nTextarea.types = {\n size: constants.defaultSize,\n};\n\nTextarea.propTypes = {\n /** Provides a non-visible label for this textarea for assistive technologies. */\n a11yText: PropTypes.string,\n\n /** If true the height will expand automatically to fit content up to the value of maxHeight. */\n canExpand: PropTypes.bool,\n\n /** Optional Textarea.Container to collect props for root DOM element. */\n children: PropTypes.node,\n\n /** Sets the default textarea value for an uncontrolled component. */\n defaultValue: PropTypes.string,\n\n /** If true displays a red border around textarea to indicate an error. */\n hasError: PropTypes.bool,\n\n /** If true it makes the textarea disabled. */\n isDisabled: PropTypes.bool,\n\n /** If true it makes the textarea read only. */\n isReadOnly: PropTypes.bool,\n\n /** The maximum height of the textarea. */\n maxHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n\n /** The minimum / default height of the textarea. */\n minHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n\n /** Callback to be executed when the textarea value is changed. Receives the onChange event as an argument. Required when component is controlled. */\n onChange: PropTypes.func,\n\n /** The size of the textarea input (font size). */\n size: PropTypes.oneOf([Textarea.types.size.SMALL, Textarea.types.size.MEDIUM, Textarea.types.size.LARGE]),\n\n /** The value inside of the textarea input. Defining this prop will make this a controlled component. Do not use in conjunction with defaultValue. */\n value: PropTypes.string,\n};\n\nTextarea.defaultProps = {\n a11yText: null,\n canExpand: true,\n children: null,\n defaultValue: null,\n hasError: false,\n isDisabled: false,\n isReadOnly: false,\n maxHeight: 300,\n minHeight: 80,\n onChange: () => {},\n size: Textarea.types.size.MEDIUM,\n value: undefined,\n};\n\nTextarea.displayName = \"Textarea\";\n\nTextarea.Container = TextareaPropsCollector;\n\nexport default Textarea;\n"],"file":"Textarea.js"}
1
+ {"version":3,"sources":["../src/Textarea.js"],"names":["Textarea","React","forwardRef","props","ref","a11yText","canExpand","children","defaultValue","hasError","isDisabled","onChange","isReadOnly","maxHeight","minHeight","size","value","moreProps","isControlled","undefined","containerProps","TextareaPropsCollector","_refTextarea","useRef","refTextarea","handleResize","useCallback","current","style","height","scrollHeight","handleChange","useLayoutEffect","window","addEventListener","cleanup","removeEventListener","styleProps","types","constants","defaultSize","propTypes","PropTypes","string","bool","node","oneOfType","number","func","oneOf","SMALL","MEDIUM","LARGE","defa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nB;AACApC,EAAAA,KAAK,EAAE0B,sBAAUC;AAnCE,CAArB;AAsCA3C,QAAQ,CAACqD,YAAT,GAAwB;AACtBhD,EAAAA,QAAQ,EAAE,IADY;AAEtBC,EAAAA,SAAS,EAAE,IAFW;AAGtBC,EAAAA,QAAQ,EAAE,IAHY;AAItBC,EAAAA,YAAY,EAAE,IAJQ;AAKtBC,EAAAA,QAAQ,EAAE,KALY;AAMtBC,EAAAA,UAAU,EAAE,KANU;AAOtBE,EAAAA,UAAU,EAAE,KAPU;AAQtBC,EAAAA,SAAS,EAAE,GARW;AAStBC,EAAAA,SAAS,EAAE,EATW;AAUtBH,EAAAA,QAAQ,EAAE,oBAAM,CAAE,CAVI;AAWtBI,EAAAA,IAAI,EAAEf,QAAQ,CAACsC,KAAT,CAAevB,IAAf,CAAoBoC,MAXJ;AAYtBnC,EAAAA,KAAK,EAAEG;AAZe,CAAxB;AAeAnB,QAAQ,CAACsD,WAAT,GAAuB,UAAvB;AAEAtD,QAAQ,CAACuD,SAAT,GAAqBlC,kCAArB;eAEerB,Q","sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport { callAll, extractChildrenProps } from \"@paprika/helpers\";\nimport * as constants from \"@paprika/constants/lib/Constants\";\nimport TextareaPropsCollector from \"./TextareaPropsCollector\";\nimport * as sc from \"./Textarea.styles\";\n\nconst Textarea = React.forwardRef((props, ref) => {\n const {\n a11yText,\n canExpand,\n children,\n defaultValue,\n hasError,\n isDisabled,\n onChange,\n isReadOnly,\n maxHeight,\n minHeight,\n size,\n value,\n ...moreProps\n } = props;\n\n const isControlled = value !== undefined;\n const containerProps = extractChildrenProps(children, TextareaPropsCollector);\n\n const _refTextarea = React.useRef();\n const refTextarea = ref || _refTextarea;\n\n const handleResize = React.useCallback(() => {\n if (refTextarea.current && refTextarea.current.style) {\n refTextarea.current.style.height = 0;\n refTextarea.current.style.height = `${refTextarea.current.scrollHeight + 2}px`;\n }\n }, [refTextarea]);\n\n function handleChange() {\n if (canExpand) {\n handleResize();\n }\n }\n\n React.useLayoutEffect(() => {\n if (canExpand) {\n handleResize();\n window.addEventListener(\"resize\", handleResize);\n }\n\n return function cleanup() {\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [canExpand, handleResize]);\n\n React.useLayoutEffect(() => {\n if (canExpand) {\n handleResize();\n }\n }, [canExpand, minHeight, maxHeight, handleResize]);\n\n const styleProps = {\n hasError,\n isDisabled,\n isReadOnly,\n maxHeight,\n minHeight,\n size,\n };\n\n return (\n <div data-pka-anchor=\"textarea.container\" {...containerProps}>\n <sc.Textarea\n aria-invalid={hasError}\n aria-label={a11yText}\n data-pka-anchor=\"textarea\"\n defaultValue={!isControlled ? defaultValue : undefined}\n disabled={isDisabled}\n onChange={callAll(handleChange, onChange)}\n readOnly={isReadOnly}\n ref={refTextarea}\n value={isControlled ? value : undefined}\n {...styleProps}\n {...moreProps}\n />\n </div>\n );\n});\n\nTextarea.types = {\n size: constants.defaultSize,\n};\n\nTextarea.propTypes = {\n /** Provides a non-visible label for this textarea for assistive technologies. */\n a11yText: PropTypes.string,\n\n /** If true the height will expand automatically to fit content up to the value of maxHeight. */\n canExpand: PropTypes.bool,\n\n /** Optional Textarea.Container to collect props for root DOM element. */\n children: PropTypes.node,\n\n /** Sets the default textarea value for an uncontrolled component. */\n defaultValue: PropTypes.string,\n\n /** If true displays a red border around textarea to indicate an error. */\n hasError: PropTypes.bool,\n\n /** If true it makes the textarea disabled. */\n isDisabled: PropTypes.bool,\n\n /** If true it makes the textarea read only. */\n isReadOnly: PropTypes.bool,\n\n /** The maximum height of the textarea. */\n maxHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n\n /** The minimum / default height of the textarea. */\n minHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n\n /** Callback to be executed when the textarea value is changed. Receives the onChange event as an argument. Required when component is controlled. */\n onChange: PropTypes.func,\n\n /** The size of the textarea input (font size). */\n size: PropTypes.oneOf([Textarea.types.size.SMALL, Textarea.types.size.MEDIUM, Textarea.types.size.LARGE]),\n\n /** The value inside of the textarea input. Defining this prop will make this a controlled component. Do not use in conjunction with defaultValue. */\n value: PropTypes.string,\n};\n\nTextarea.defaultProps = {\n a11yText: null,\n canExpand: true,\n children: null,\n defaultValue: null,\n hasError: false,\n isDisabled: false,\n isReadOnly: false,\n maxHeight: 300,\n minHeight: 80,\n onChange: () => {},\n size: Textarea.types.size.MEDIUM,\n value: undefined,\n};\n\nTextarea.displayName = \"Textarea\";\n\nTextarea.Container = TextareaPropsCollector;\n\nexport default Textarea;\n"],"file":"Textarea.js"}
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
3
+ var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
4
4
 
5
- var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
5
+ var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
6
6
 
7
7
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
8
8
 
9
- var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
9
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
10
10
 
11
- var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
11
+ var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
12
12
 
13
13
  _Object$defineProperty(exports, "__esModule", {
14
14
  value: true
package/lib/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
4
-
5
3
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
6
4
 
5
+ var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
6
+
7
7
  _Object$defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
package/lib/types.js CHANGED
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
 
3
- var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
4
-
5
- var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
6
-
7
3
  var _typeof = require("@babel/runtime-corejs2/helpers/typeof");
8
4
 
9
5
  var _WeakMap = require("@babel/runtime-corejs2/core-js/weak-map");
10
6
 
7
+ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
8
+
9
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
10
+
11
11
  _Object$defineProperty(exports, "__esModule", {
12
12
  value: true
13
13
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paprika/textarea",
3
- "version": "3.0.2-next.0",
3
+ "version": "3.0.4-next.0",
4
4
  "description": "The Textarea component is a standard multiline text input with some enhancements that can be used as a controlled or uncontrolled component.",
5
5
  "author": "@paprika",
6
6
  "main": "lib/index.js",
@@ -18,8 +18,8 @@
18
18
  "@babel/runtime-corejs2": "^7.3.1",
19
19
  "@paprika/constants": "^1.0.0",
20
20
  "@paprika/helpers": "^2.1.3",
21
- "@paprika/stylers": "^1.1.0-next.0",
22
- "@paprika/tokens": "^1.0.0",
21
+ "@paprika/stylers": "^1.1.2-next.0",
22
+ "@paprika/tokens": "^1.1.1-next.0",
23
23
  "prop-types": "^15.7.2"
24
24
  },
25
25
  "peerDependencies": {