@bigbinary/neeto-molecules 1.15.16-beta → 1.15.17

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,94 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var defineProperty = require('./defineProperty-886ed289.js');
6
- var _extends = require('./extends-1b35a664.js');
7
- var objectWithoutProperties = require('./objectWithoutProperties-2fed2d7d.js');
8
- var React = require('react');
9
- var classnames = require('classnames');
10
- var neetoui = require('@bigbinary/neetoui');
11
- var injectCss = require('./inject-css-80a5faa3.js');
12
- var slicedToArray = require('./slicedToArray-f320d9e7.js');
13
- var formik = require('formik');
14
-
15
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
-
17
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
18
- var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
19
-
20
- var css = ".neeto-molecules-adaptive-input textarea{resize:none}.neeto-molecules-adaptive-input .neeto-ui-input.neeto-ui-input--small{--neeto-ui-textarea-padding-x:8px;--neeto-ui-textarea-padding-y:4px}.neeto-molecules-adaptive-input .neeto-ui-input.neeto-ui-input--medium{--neeto-ui-textarea-padding-x:8px;--neeto-ui-textarea-padding-y:5px}.neeto-molecules-adaptive-input .neeto-ui-input.neeto-ui-input--large{--neeto-ui-textarea-padding-x:12px;--neeto-ui-textarea-padding-y:8px}.neeto-molecules-adaptive-input__suffix{bottom:0;position:absolute;right:0}";
21
- injectCss.n(css,{});
22
-
23
- var _excluded$1 = ["label", "className", "size", "required", "disabled", "suffix"];
24
-
25
- // eslint-disable-next-line @bigbinary/neeto/no-dangling-constants
26
- var SIZES = {
27
- small: "small",
28
- medium: "medium",
29
- large: "large"
30
- };
31
- var AdaptiveInput = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
32
- var _ref$label = _ref.label,
33
- label = _ref$label === void 0 ? "" : _ref$label,
34
- _ref$className = _ref.className,
35
- className = _ref$className === void 0 ? "" : _ref$className,
36
- _ref$size = _ref.size,
37
- size = _ref$size === void 0 ? SIZES.medium : _ref$size,
38
- _ref$required = _ref.required,
39
- required = _ref$required === void 0 ? false : _ref$required,
40
- _ref$disabled = _ref.disabled,
41
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
42
- _ref$suffix = _ref.suffix,
43
- suffix = _ref$suffix === void 0 ? null : _ref$suffix,
44
- otherProps = objectWithoutProperties._objectWithoutProperties(_ref, _excluded$1);
45
- var handleFocus = function handleFocus(element) {
46
- var end = element.value.length;
47
- element.setSelectionRange(end, end);
48
- };
49
- var handleKeyDown = function handleKeyDown(event) {
50
- var _otherProps$onSubmit;
51
- if (event.key !== "Enter") return;
52
- event.preventDefault();
53
- (_otherProps$onSubmit = otherProps.onSubmit) === null || _otherProps$onSubmit === void 0 ? void 0 : _otherProps$onSubmit.call(otherProps);
54
- };
55
- return /*#__PURE__*/React__default["default"].createElement("div", {
56
- className: "relative w-full"
57
- }, /*#__PURE__*/React__default["default"].createElement(neetoui.Textarea, _extends._extends(defineProperty._defineProperty(defineProperty._defineProperty(defineProperty._defineProperty({
58
- disabled: disabled,
59
- label: label,
60
- ref: ref,
61
- required: required,
62
- size: size,
63
- "data-cy": "neeto-molecules-adaptive-input",
64
- "data-testid": "neeto-molecules-adaptive-input",
65
- rows: 1
66
- }, "size", "small"), "className", classnames__default["default"]("neeto-molecules-adaptive-input", {
67
- "neeto-ui-input--disabled": !!disabled
68
- }, className)), "onKeyDown", handleKeyDown), otherProps, {
69
- onFocus: function onFocus(_ref2) {
70
- var target = _ref2.target;
71
- return handleFocus(target);
72
- }
73
- })), suffix && /*#__PURE__*/React__default["default"].createElement("div", {
74
- className: "neeto-molecules-adaptive-input__suffix"
75
- }, suffix));
76
- });
77
- AdaptiveInput.displayName = "AdaptiveInput";
78
-
79
- var _excluded = ["name"];
80
- var FormikAdaptiveInput = function FormikAdaptiveInput(_ref) {
81
- var name = _ref.name,
82
- props = objectWithoutProperties._objectWithoutProperties(_ref, _excluded);
83
- var _useField = formik.useField(name),
84
- _useField2 = slicedToArray._slicedToArray(_useField, 2),
85
- field = _useField2[0],
86
- meta = _useField2[1];
87
- return /*#__PURE__*/React__default["default"].createElement(AdaptiveInput, _extends._extends({}, field, {
88
- error: meta.touched ? meta.error : ""
89
- }, props));
90
- };
91
-
92
- exports.AdaptiveInput = AdaptiveInput;
93
- exports.FormikAdaptiveInput = FormikAdaptiveInput;
94
- //# sourceMappingURL=AdaptiveInput.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AdaptiveInput.js","sources":["../../src/components/AdaptiveInput/AdaptiveInput.jsx","../../src/components/AdaptiveInput/FormikAdaptiveInput.jsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\n\nimport classnames from \"classnames\";\nimport { Textarea } from \"neetoui\";\nimport PropTypes from \"prop-types\";\n\nimport \"./adaptiveInput.scss\";\n\n// eslint-disable-next-line @bigbinary/neeto/no-dangling-constants\nconst SIZES = { small: \"small\", medium: \"medium\", large: \"large\" };\n\nconst AdaptiveInput = forwardRef(\n (\n {\n label = \"\",\n className = \"\",\n size = SIZES.medium,\n required = false,\n disabled = false,\n suffix = null,\n ...otherProps\n },\n ref\n ) => {\n const handleFocus = element => {\n const end = element.value.length;\n element.setSelectionRange(end, end);\n };\n\n const handleKeyDown = event => {\n if (event.key !== \"Enter\") return;\n\n event.preventDefault();\n otherProps.onSubmit?.();\n };\n\n return (\n <div className=\"relative w-full\">\n <Textarea\n {...{ disabled, label, ref, required, size }}\n data-cy=\"neeto-molecules-adaptive-input\"\n data-testid=\"neeto-molecules-adaptive-input\"\n rows={1}\n size=\"small\"\n className={classnames(\n \"neeto-molecules-adaptive-input\",\n { \"neeto-ui-input--disabled\": !!disabled },\n className\n )}\n onKeyDown={handleKeyDown}\n {...otherProps}\n onFocus={({ target }) => handleFocus(target)}\n />\n {suffix && (\n <div className=\"neeto-molecules-adaptive-input__suffix\">{suffix}</div>\n )}\n </div>\n );\n }\n);\n\nAdaptiveInput.displayName = \"AdaptiveInput\";\n\nAdaptiveInput.propTypes = {\n /**\n * To provide additional classes to the component.\n */\n className: PropTypes.string,\n /**\n * To specify the text to be displayed above the input.\n */\n label: PropTypes.string,\n /**\n * To specify the size of the input field\n */\n size: PropTypes.oneOf(Object.values(SIZES)),\n /**\n * To specify whether the input field is required or not.\n */\n required: PropTypes.bool,\n /**\n * To specify whether the input field is disabled or not.\n */\n disabled: PropTypes.bool,\n /**\n * To specify the content to be added at the end of the input field.\n */\n suffix: PropTypes.node,\n};\n\nexport default AdaptiveInput;\n","import React from \"react\";\n\nimport { useField } from \"formik\";\n\nimport AdaptiveInput from \"./AdaptiveInput\";\n\nconst FormikAdaptiveInput = ({ name, ...props }) => {\n const [field, meta] = useField(name);\n\n return (\n <AdaptiveInput\n {...field}\n error={meta.touched ? meta.error : \"\"}\n {...props}\n />\n );\n};\n\nexport default FormikAdaptiveInput;\n"],"names":["SIZES","small","medium","large","AdaptiveInput","forwardRef","_ref","ref","_ref$label","label","_ref$className","className","_ref$size","size","_ref$required","required","_ref$disabled","disabled","_ref$suffix","suffix","otherProps","_objectWithoutProperties","_excluded","handleFocus","element","end","value","length","setSelectionRange","handleKeyDown","event","_otherProps$onSubmit","key","preventDefault","onSubmit","call","React","createElement","Textarea","_extends","_defineProperty","rows","classnames","onFocus","_ref2","target","displayName","FormikAdaptiveInput","name","props","_useField","useField","_useField2","_slicedToArray","field","meta","error","touched"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAQA;AACA,IAAMA,KAAK,GAAG;AAAEC,EAAAA,KAAK,EAAE,OAAO;AAAEC,EAAAA,MAAM,EAAE,QAAQ;AAAEC,EAAAA,KAAK,EAAE,OAAA;AAAQ,CAAC,CAAA;AAE5DC,IAAAA,aAAa,gBAAGC,gBAAU,CAC9B,UAAAC,IAAA,EAUEC,GAAG,EACA;AAAA,EAAA,IAAAC,UAAA,GAAAF,IAAA,CATDG,K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AtBA,mBAAmBA,CAAAzC,IAAA,EAA2B;AAAA,EAAA,IAArB0C,IAAI,GAAA1C,IAAA,CAAJ0C,IAAI;AAAKC,IAAAA,KAAK,GAAA5B,gDAAA,CAAAf,IAAA,EAAAgB,SAAA,CAAA,CAAA;AAC3C,EAAA,IAAA4B,SAAA,GAAsBC,eAAQ,CAACH,IAAI,CAAC;IAAAI,UAAA,GAAAC,4BAAA,CAAAH,SAAA,EAAA,CAAA,CAAA;AAA7BI,IAAAA,KAAK,GAAAF,UAAA,CAAA,CAAA,CAAA;AAAEG,IAAAA,IAAI,GAAAH,UAAA,CAAA,CAAA,CAAA,CAAA;EAElB,oBACEhB,yBAAA,CAAAC,aAAA,CAACjC,aAAa,EAAAmC,iBAAA,KACRe,KAAK,EAAA;IACTE,KAAK,EAAED,IAAI,CAACE,OAAO,GAAGF,IAAI,CAACC,KAAK,GAAG,EAAA;GAC/BP,EAAAA,KAAK,CACV,CAAC,CAAA;AAEN;;;;;"}
@@ -1,51 +0,0 @@
1
- import React from "react";
2
- import { TextareaProps } from "@bigbinary/neetoui";
3
- export interface AdaptiveInputProps extends TextareaProps {
4
- label: string;
5
- className?: string;
6
- size: "small" | "medium" | "large";
7
- required?: boolean;
8
- disabled?: boolean;
9
- suffix?: React.ReactNode;
10
- }
11
- export interface FormikAdaptiveInputProps extends AdaptiveInputProps {
12
- name: string;
13
- }
14
- export
15
- /**
16
- *
17
- * An input component that dynamically adjusts between single-line and multi-line
18
- *
19
- * input based on content length.
20
- *
21
- * @example
22
- *
23
- * import { AdaptiveInput } from "@bigbinary/neeto-molecules/AdaptiveInput";
24
- *
25
- * const Description = () => (
26
- * <div className="flex-grow">
27
- * <AdaptiveInput required label="Description" />
28
- * </div>
29
- * );
30
- * @endexample
31
- * The AdaptiveInput component wrapped in Formik.
32
- *
33
- * @example
34
- *
35
- * import { FormikAdaptiveInput } from "@bigbinary/neeto-molecules/AdaptiveInput";
36
- * import { Form } from "@bigbinary/neetoui/formik";
37
- *
38
- * const App = () => (
39
- * <Form
40
- * formikProps={{
41
- * initialValues: { description: "Sample description" },
42
- * validationSchema: yup.string().required(),
43
- * }}
44
- * >
45
- * <FormikAdaptiveInput required name="description" />
46
- * </Form>
47
- * );
48
- * @endexample
49
- */
50
- const AdaptiveInput: React.ForwardRefExoticComponent<AdaptiveInputProps>;
51
- export const FormikAdaptiveInput: React.ForwardRefExoticComponent<FormikAdaptiveInputProps>;