@macive/ui 0.0.12 → 0.0.13

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,8 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const InputClassnames = {
4
- "input-prefix": "Input-prefix",
5
- "input-suffix": "Input-suffix",
6
- "input-field": "Input-field"
4
+ "Backdrop-connectedLeft": "Input-connectedLeft",
5
+ "Backdrop-connectedRight": "Input-connectedRight",
6
+ "TextField": "Input-TextField",
7
+ "ClearButton": "Input-ClearButton",
8
+ "multiline": "Input-multiline",
9
+ "Input": "Input-Input",
10
+ "hasValue": "Input-hasValue",
11
+ "focus": "Input-focus",
12
+ "VerticalContent": "Input-VerticalContent",
13
+ "Backdrop": "Input-Backdrop",
14
+ "error": "Input-error",
15
+ "readOnly": "Input-readOnly",
16
+ "disabled": "Input-disabled",
17
+ "Prefix": "Input-Prefix",
18
+ "suggestion": "Input-suggestion",
19
+ "borderless": "Input-borderless",
20
+ "Input-hasClearButton": "Input-hasClearButton",
21
+ "Input-suffixed": "Input-suffixed",
22
+ "Input-alignRight": "Input-alignRight",
23
+ "Input-alignLeft": "Input-alignLeft",
24
+ "Input-alignCenter": "Input-alignCenter",
25
+ "Suffix": "Input-Suffix",
26
+ "CharacterCount": "Input-CharacterCount",
27
+ "AlignFieldBottom": "Input-AlignFieldBottom",
28
+ "Spinner": "Input-Spinner",
29
+ "SpinnerIcon": "Input-SpinnerIcon",
30
+ "Resizer": "Input-Resizer",
31
+ "DummyInput": "Input-DummyInput",
32
+ "Segment": "Input-Segment",
33
+ "monospaced": "Input-monospaced"
7
34
  };
8
35
  exports.default = InputClassnames;
@@ -6,19 +6,36 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Input = void 0;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const react_1 = __importDefault(require("react"));
9
- const css_1 = require("../../utils/css");
10
- const Label_1 = require("../Label");
11
- const Text_1 = require("../Text");
9
+ const css_1 = require("../../utilities/css");
10
+ const unique_id_1 = require("../../utilities/unique-id");
11
+ const Connected_1 = require("../Connected");
12
+ const Labelled_1 = require("../Labelled");
12
13
  const Input_classnames_1 = __importDefault(require("./Input.classnames"));
13
- /**
14
- * A simple input component.
15
- *
16
- * @param props InputProps for the component.
17
- * @returns A React functional component.
18
- */
19
- // const Input: React.FC<InputProps> = (props) => {
20
14
  exports.Input = react_1.default.forwardRef((props, ref) => {
21
- const { className, gap, suffix, preffix, invalid, error, label, ...rest } = props;
22
- return ((0, jsx_runtime_1.jsxs)("div", { className: (0, css_1.classNames)(gap == 'none' && 'mt-4', className), children: [(0, jsx_runtime_1.jsx)("div", { className: 'mb-2', children: (0, jsx_runtime_1.jsx)(Label_1.Label, { id: rest === null || rest === void 0 ? void 0 : rest.name, children: label }) }), (0, jsx_runtime_1.jsxs)("div", { className: (0, css_1.classNames)(' focus-within:border-accent group relative flex w-full items-center rounded border-[0.5px] border-gray-400 focus-within:ring focus-within:ring-gray-200 focus-within:ring-opacity-50 group-hover:!border-red-700 dark:bg-gray-600 dark:text-white md:text-sm ', error && '!border-danger'), children: [preffix && (0, jsx_runtime_1.jsx)("div", { className: Input_classnames_1.default['input-prefix'], children: preffix }), (0, jsx_runtime_1.jsx)("input", { ref: ref, className: (0, css_1.classNames)(Input_classnames_1.default['input-field'], 'focus:shadow-outline ring-ring-brand-yellow focus:ring-brand-yellow focus:border-brand-yellow border-brand-yellow border border-none shadow-none outline-none focus:outline-none focus:ring', invalid ? 'border-red-500' : '', error ? 'border-red-500' : '', suffix ? 'dpr-10 ' : 'pr-4', preffix ? 'pl-1 placeholder:pl-0' : 'pl-4'), ...rest }), suffix && (0, jsx_runtime_1.jsx)("div", { className: Input_classnames_1.default['input-suffix'], children: suffix })] }), error && (0, jsx_runtime_1.jsx)("p", { className: 'capitalize-first text-sm italic !text-red-500', children: error }), (props === null || props === void 0 ? void 0 : props.info) && (0, jsx_runtime_1.jsxs)(Text_1.Text, { color: 'subdued', children: [props === null || props === void 0 ? void 0 : props.info, " "] })] }));
15
+ var _a;
16
+ const { prefix, suffix, verticalContent, placeholder,
17
+ // value = '',
18
+ helpText, label, labelAction, labelHidden, disabled, clearButton, readOnly, autoFocus, focused, error, connectedRight, connectedLeft, type = 'text', name, id: idProp, role, autoComplete, max, maxLength, min, showCharacterCount, requiredIndicator, monospaced, suggestion, onClearButtonClick, borderless, align, ...rest } = props;
19
+ const id = (0, unique_id_1.useUniqueId)('TextField', idProp);
20
+ const className = (0, css_1.classNames)(Input_classnames_1.default.TextField,
21
+ // Boolean(normalizedValue) && styles.hasValue,
22
+ disabled && Input_classnames_1.default.disabled, readOnly && Input_classnames_1.default.readOnly, error && Input_classnames_1.default.error, borderless && Input_classnames_1.default.borderless);
23
+ const inputClassName = (0, css_1.classNames)(Input_classnames_1.default.Input, suffix && Input_classnames_1.default['Input'], clearButton && Input_classnames_1.default['Input-hasClearButton'], monospaced && Input_classnames_1.default.monospaced, suggestion && Input_classnames_1.default.suggestion,
24
+ //@ts-expect-error
25
+ align && Input_classnames_1.default[variationName('Input-align', align)]);
26
+ return ((0, jsx_runtime_1.jsx)(Labelled_1.Labelled, { label: label, id: id, error: error, action: labelAction, labelHidden: labelHidden, helpText: helpText, requiredIndicator: requiredIndicator, children: (0, jsx_runtime_1.jsx)(Connected_1.Connected, { left: connectedLeft, right: connectedRight, children: (0, jsx_runtime_1.jsxs)("div", { className: className, children: [prefix ? ((0, jsx_runtime_1.jsx)("div", { className: Input_classnames_1.default.Prefix, id: `${id}-Prefix`, children: prefix })) : null, (0, jsx_runtime_1.jsx)("input", { ...{
27
+ name,
28
+ id,
29
+ disabled,
30
+ readOnly,
31
+ role,
32
+ autoFocus,
33
+ placeholder,
34
+ autoComplete,
35
+ className: inputClassName,
36
+ min,
37
+ max,
38
+ ...rest,
39
+ }, ref: (_a = rest.ref) !== null && _a !== void 0 ? _a : ref }), suffix ? ((0, jsx_runtime_1.jsx)("div", { className: Input_classnames_1.default.Suffix, id: `${id}-Suffix`, children: suffix })) : null, showCharacterCount ? ((0, jsx_runtime_1.jsx)("div", { id: `${id}-CharacterCounter`, className: Input_classnames_1.default.CharacterCount, "aria-atomic": 'true', children: rest.value })) : null, (0, jsx_runtime_1.jsx)("div", { className: (0, css_1.classNames)(Input_classnames_1.default.Backdrop, connectedLeft && Input_classnames_1.default['Backdrop-connectedLeft'], connectedRight && Input_classnames_1.default['Backdrop-connectedRight']) })] }) }) }));
23
40
  });
24
41
  exports.Input.displayName = 'Input';