@geneui/components 3.0.0-next-a255969-03032026 → 3.0.0-next-e1bd79a-05032026

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/TextField.js CHANGED
@@ -65,26 +65,33 @@ var SvgEyeOff = function SvgEyeOff(_ref) {
65
65
  var css_248z = ".textField{align-items:flex-start;display:flex;flex-direction:column;gap:var(--guit-ref-spacing-3xsmall)}.textField__wrapper{align-items:center;border-color:var(--guit-sem-color-border-neutral-2);border-style:var(--guit-ref-border-style-solid);border-width:var(--guit-ref-border-width-thin);display:flex;overflow:hidden;width:100%}.textField__wrapper_size_large .textField__input,.textField__wrapper_size_medium .textField__input{font-family:var(--guit-sem-font-body-medium-default-medium-font-family);font-size:var(--guit-sem-font-body-medium-default-medium-font-size);font-weight:var(--guit-sem-font-body-medium-default-medium-font-weight);line-height:var(--guit-sem-font-body-medium-default-medium-line-height)}.textField__wrapper_size_large{border-radius:var(--guit-ref-radius-2xsmall);gap:var(--guit-ref-spacing-xsmall);height:var(--guit-sem-dimension-height-large)}.textField__wrapper_size_large:not(.textField__wrapper_iconBefore,.textField__wrapper_size_large.textField__wrapper_iconAfter,.textField__wrapper_size_large.textField__wrapper_withIcons) .textField__input{padding:var(--guit-ref-spacing-small) var(--guit-ref-spacing-large)}.textField__wrapper_size_large.textField__wrapper_iconBefore{-webkit-padding-start:var(--guit-ref-spacing-medium);padding-inline-start:var(--guit-ref-spacing-medium)}.textField__wrapper_size_large.textField__wrapper_iconBefore .textField__input{-webkit-padding-end:var(--guit-ref-spacing-large);padding-block:var(--guit-ref-spacing-small);padding-inline-end:var(--guit-ref-spacing-large)}.textField__wrapper_size_large.textField__wrapper_iconAfter{-webkit-padding-end:var(--guit-ref-spacing-medium);padding-inline-end:var(--guit-ref-spacing-medium)}.textField__wrapper_size_large.textField__wrapper_iconAfter .textField__input{-webkit-padding-start:var(--guit-ref-spacing-large);padding-block:var(--guit-ref-spacing-xsmall);padding-inline-start:var(--guit-ref-spacing-large)}.textField__wrapper_size_large.textField__wrapper_withIcons{padding-inline:var(--guit-ref-spacing-medium)}.textField__wrapper_size_large.textField__wrapper_withIcons .textField__input{padding-block:var(--guit-ref-spacing-xsmall)}.textField__wrapper_size_medium{border-radius:var(--guit-ref-radius-3xsmall);gap:var(--guit-ref-spacing-xsmall);height:var(--guit-sem-dimension-height-medium)}.textField__wrapper_size_medium:not(.textField__wrapper_iconBefore,.textField__wrapper_size_medium.textField__wrapper_iconAfter,.textField__wrapper_size_medium.textField__wrapper_withIcons) .textField__input{padding:var(--guit-ref-spacing-2xsmall) var(--guit-ref-spacing-medium)}.textField__wrapper_size_medium.textField__wrapper_iconBefore{-webkit-padding-start:var(--guit-ref-spacing-xsmall);padding-inline-start:var(--guit-ref-spacing-xsmall)}.textField__wrapper_size_medium.textField__wrapper_iconBefore .textField__input{-webkit-padding-end:var(--guit-ref-spacing-medium);padding-block:var(--guit-ref-spacing-2xsmall);padding-inline-end:var(--guit-ref-spacing-medium)}.textField__wrapper_size_medium.textField__wrapper_iconAfter{-webkit-padding-end:var(--guit-ref-spacing-xsmall);padding-inline-end:var(--guit-ref-spacing-xsmall)}.textField__wrapper_size_medium.textField__wrapper_iconAfter .textField__input{-webkit-padding-start:var(--guit-ref-spacing-medium);padding-block:var(--guit-ref-spacing-3xsmall);padding-inline-start:var(--guit-ref-spacing-medium)}.textField__wrapper_size_medium.textField__wrapper_withIcons{padding-inline:var(--guit-ref-spacing-xsmall)}.textField__wrapper_size_medium.textField__wrapper_withIcons .textField__input{padding-block:var(--guit-ref-spacing-3xsmall)}.textField__wrapper_size_small{border-radius:var(--guit-ref-radius-3xsmall);gap:var(--guit-ref-spacing-2xsmall);height:var(--guit-sem-dimension-height-small)}.textField__wrapper_size_small:not(.textField__wrapper_iconBefore,.textField__wrapper_size_small.textField__wrapper_iconAfter,.textField__wrapper_size_small.textField__wrapper_withIcons) .textField__input{padding:var(--guit-ref-radius-3xsmall) var(--guit-ref-spacing-medium)}.textField__wrapper_size_small.textField__wrapper_iconBefore{-webkit-padding-start:var(--guit-ref-spacing-xsmall);padding-inline-start:var(--guit-ref-spacing-xsmall)}.textField__wrapper_size_small.textField__wrapper_iconBefore .textField__input{-webkit-padding-end:var(--guit-ref-spacing-medium);padding-block:var(--guit-ref-radius-3xsmall);padding-inline-end:var(--guit-ref-spacing-medium)}.textField__wrapper_size_small.textField__wrapper_iconAfter{-webkit-padding-end:var(--guit-ref-spacing-xsmall);padding-inline-end:var(--guit-ref-spacing-xsmall)}.textField__wrapper_size_small.textField__wrapper_iconAfter .textField__input{-webkit-padding-start:var(--guit-ref-spacing-medium);padding-block:var(--guit-ref-spacing-4xsmall);padding-inline-start:var(--guit-ref-spacing-medium)}.textField__wrapper_size_small.textField__wrapper_withIcons{padding-inline:var(--guit-ref-spacing-xsmall)}.textField__wrapper_size_small.textField__wrapper_withIcons .textField__input{padding-block:var(--guit-ref-spacing-4xsmall)}.textField__wrapper_size_small .textField__input{font-family:var(--guit-sem-font-caption-large-medium-font-family);font-size:var(--guit-sem-font-caption-large-medium-font-size);font-weight:var(--guit-sem-font-caption-large-medium-font-weight);letter-spacing:var(--guit-sem-font-caption-large-medium-letter-spacing);line-height:var(--guit-sem-font-caption-large-medium-line-height)}.textField__wrapper_readOnly{background-color:var(--guit-sem-color-background-neutral-3);border-color:#0000}.textField__wrapper_error{border-color:var(--guit-sem-color-border-error)}.textField__wrapper_error .textField__input,.textField__wrapper_warning .textField__input{color:var(--guit-sem-color-foreground-neutral-2)}.textField__wrapper_disabled{border-color:var(--guit-sem-color-border-disabled-1);pointer-events:none;-webkit-user-select:none;user-select:none}.textField__wrapper_disabled .textField__icon,.textField__wrapper_disabled .textField__input{color:var(--guit-sem-color-foreground-disabled)}.textField__wrapper:hover{background-color:var(--guit-sem-color-background-neutral-1-hover)}.textField__wrapper:not(.textField__wrapper.textField__wrapper_disabled):focus-within{outline:var(--guit-ref-border-width-thin) var(--guit-ref-border-style-solid) var(--guit-sem-color-border-focus);outline-offset:var(--guit-ref-border-width-thin)}.textField__wrapper:not(.textField__wrapper.textField__wrapper_disabled):focus-within .textField__input{color:var(--guit-sem-color-foreground-neutral-2)}.textField__icon{align-items:center;color:var(--guit-sem-color-foreground-neutral-1);display:flex;flex:0 0 auto;justify-content:center}.textField__input{background-color:initial;border:none;color:var(--guit-sem-color-foreground-neutral-2);height:100%;outline:none;width:100%}.textField__input::placeholder{color:var(--guit-sem-color-foreground-neutral-1)}.textField__actions{align-items:center;display:flex;flex:0 0 auto;gap:var(--guit-ref-spacing-3xsmall)}.textField__info{align-items:center;display:flex;justify-content:space-between;width:100%}.textField__characterLimit{-webkit-margin-start:auto;color:var(--guit-sem-color-foreground-neutral-2);margin-inline-start:auto;white-space:nowrap}.textField__characterLimit_size_medium{font-size:var(--guit-sem-font-body-medium-default-medium-font-size)}.textField__characterLimit_size_small{font-size:var(--guit-sem-font-caption-large-medium-font-size)}.textField__characterLimit_disabled{color:var(--guit-sem-color-foreground-disabled)}";
66
66
  styleInject(css_248z);
67
67
 
68
- // Size mapping objects for Label and HelperText components
69
- const labelSizeMap = {
68
+ // Size mapping objects for Label, Button, IconBefore/IconAfter and HelperText components
69
+ const textSizeMap = {
70
70
  large: "medium",
71
71
  medium: "medium",
72
72
  small: "small"
73
73
  };
74
- const helperTextSizeMap = {
75
- large: "medium",
76
- medium: "medium",
77
- small: "small"
74
+ const labelSizeMap = textSizeMap;
75
+ const helperTextSizeMap = textSizeMap;
76
+ const iconSizeMap = {
77
+ large: 24,
78
+ medium: 24,
79
+ small: 20
78
80
  };
81
+ const actionButtonSizeMap = {
82
+ large: "small",
83
+ medium: "small",
84
+ small: "smallNudge"
85
+ };
86
+
79
87
  /**
80
88
  * Text field is an input element in a user interface where users can enter and edit text. Text fields are commonly used in forms for collecting user data such as names, email addresses, and messages.
81
89
  */
82
- const TextField = forwardRef(({ id, name, type = "text", size = "large", defaultValue, value, placeholder, IconBefore, onChange, onFocus, onBlur, readOnly, disabled, required, label, infoText, clearable, characterLimit, className, autoComplete = "on", autoFocus, helperText, status = "rest", onClear, inputMode = "text" }, ref) => {
90
+ const TextField = forwardRef(({ id, name, type = "text", size = "medium", defaultValue, value, placeholder, IconBefore, IconAfter, onChange, onFocus, onBlur, readOnly, disabled, required, label, infoText, clearable, characterLimit, className, autoComplete = "on", autoFocus, helperText, status = "rest", onClear, inputMode = "text" }, ref) => {
83
91
  const isControlled = value !== undefined;
84
92
  const inputRef = useRef(null);
85
93
  const [internalValue, setInternalValue] = useState("");
86
94
  const [isPasswordVisible, setIsPasswordVisible] = useState(false);
87
- const [paddingClassesForIcon, setPaddingClassesForIcon] = useState("");
88
95
  const inputValue = isControlled ? value.toString() : internalValue;
89
96
  const generatedId = useMemo(() => id || `default-id-${nanoid()}`, [id]);
90
97
  const labelSize = labelSizeMap[size] || "medium";
@@ -124,39 +131,34 @@ const TextField = forwardRef(({ id, name, type = "text", size = "large", default
124
131
  return;
125
132
  setInternalValue(defaultValue.toString());
126
133
  }, []);
127
- useEffect(() => {
128
- const iconAfter = type === "password" || (clearable && inputValue.length > 0 && !disabled && !readOnly);
129
- if (IconBefore && iconAfter) {
130
- setPaddingClassesForIcon("textField__wrapper_withIcons");
131
- }
132
- else if (IconBefore) {
133
- setPaddingClassesForIcon("textField__wrapper_iconBefore");
134
- }
135
- else if (iconAfter) {
136
- setPaddingClassesForIcon("textField__wrapper_iconAfter");
137
- }
138
- }, [IconBefore, type, clearable, inputValue, disabled, readOnly]);
139
134
  const isClearable = clearable && inputValue.length > 0 && !disabled && !readOnly;
140
135
  const isPassword = type === "password" && inputValue.length > 0 && !readOnly && !disabled;
136
+ const iconAfter = isPassword || isClearable || IconAfter;
141
137
  const inputConditionalProps = {
142
138
  placeholder,
143
139
  autoFocus,
144
140
  inputMode: type === "number" ? "numeric" : inputMode,
145
141
  type: isPasswordVisible || type === "number" ? "text" : type
146
142
  };
143
+ const paddedClassesForIcon = {
144
+ textField__wrapper_readOnly: readOnly && !disabled,
145
+ textField__wrapper_disabled: disabled,
146
+ textField__wrapper_error: status === "error",
147
+ textField__wrapper_withIcons: IconBefore && iconAfter,
148
+ textField__wrapper_iconBefore: IconBefore && !iconAfter,
149
+ textField__wrapper_iconAfter: iconAfter && !IconBefore
150
+ };
147
151
  return (React__default.createElement("div", { className: classNames("textField", className) },
148
152
  React__default.createElement(Label, { text: label, required: required, className: "textField__label", disabled: disabled, infoText: infoText, readOnly: readOnly, labelFor: generatedId, size: labelSize }),
149
- React__default.createElement("div", { className: classNames(`textField__wrapper textField__wrapper_size_${size}`, paddingClassesForIcon, {
150
- textField__wrapper_readOnly: readOnly && !disabled,
151
- textField__wrapper_disabled: disabled,
152
- textField__wrapper_error: status === "error"
153
- }) },
153
+ React__default.createElement("div", { className: classNames(`textField__wrapper textField__wrapper_size_${size}`, paddedClassesForIcon) },
154
154
  IconBefore && (React__default.createElement("span", { className: "textField__icon" },
155
- React__default.createElement(IconBefore, { size: size === "small" ? 20 : 24 }))),
155
+ React__default.createElement(IconBefore, { size: iconSizeMap[size] }))),
156
156
  React__default.createElement("input", Object.assign({ id: generatedId, autoComplete: autoComplete, name: name || type, ref: inputRef, className: "textField__input", required: required, disabled: disabled, readOnly: readOnly, value: inputValue, onChange: handleChange, onBlur: onBlur, onFocus: onInputFocus, "aria-invalid": status === "error", "aria-required": required }, inputConditionalProps)),
157
157
  (isClearable || isPassword) && (React__default.createElement("span", { className: "textField__actions" },
158
- isClearable && (React__default.createElement(Button, { Icon: SvgX, appearance: "secondary", size: size === "small" ? "smallNudge" : "small", layout: "text", disabled: disabled, onClick: handleClear })),
159
- isPassword && (React__default.createElement(Button, { Icon: isPasswordVisible ? SvgEye : SvgEyeOff, appearance: "secondary", size: size === "small" ? "smallNudge" : "small", layout: "text", disabled: disabled, onClick: showPasswordToggle }))))),
158
+ isClearable && (React__default.createElement(Button, { Icon: SvgX, appearance: "secondary", size: actionButtonSizeMap[size], layout: "text", disabled: disabled, onClick: handleClear })),
159
+ isPassword && (React__default.createElement(Button, { Icon: isPasswordVisible ? SvgEye : SvgEyeOff, appearance: "secondary", size: actionButtonSizeMap[size], layout: "text", disabled: disabled, onClick: showPasswordToggle })))),
160
+ IconAfter && (React__default.createElement("span", { className: "textField__icon" },
161
+ React__default.createElement(IconAfter, { size: iconSizeMap[size] })))),
160
162
  (helperText || characterLimit) && (React__default.createElement("div", { className: "textField__info" },
161
163
  helperText && (React__default.createElement(HelperText, { text: helperText, disabled: disabled, status: status, size: helperTextSize })),
162
164
  characterLimit && (React__default.createElement(Text, { as: "span", className: classNames(`textField__characterLimit textField__characterLimit_size_${helperTextSize}`, {
@@ -94,9 +94,15 @@ interface ITextFieldProps {
94
94
  */
95
95
  onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
96
96
  /**
97
- * The `IconBefore` prop accepts a React Functional Component that will be displayed alongside the `TextField`.
97
+ * Icon component rendered before the TextField content.
98
+ * Must be a React component that accepts this library's `IconProps`.
98
99
  */
99
100
  IconBefore?: FC<IconProps>;
101
+ /**
102
+ * Icon component rendered after the TextField content.
103
+ * Must be a React component that accepts this library's `IconProps`.
104
+ */
105
+ IconAfter?: FC<IconProps>;
100
106
  /**
101
107
  * When `true`, shows a `clear button` to reset the `input` value.
102
108
  * default value is `false`
@@ -0,0 +1,21 @@
1
+ declare const labelSizeMap: {
2
+ readonly large: "medium";
3
+ readonly medium: "medium";
4
+ readonly small: "small";
5
+ };
6
+ declare const helperTextSizeMap: {
7
+ readonly large: "medium";
8
+ readonly medium: "medium";
9
+ readonly small: "small";
10
+ };
11
+ declare const iconSizeMap: {
12
+ readonly large: 24;
13
+ readonly medium: 24;
14
+ readonly small: 20;
15
+ };
16
+ declare const actionButtonSizeMap: {
17
+ readonly large: "small";
18
+ readonly medium: "small";
19
+ readonly small: "smallNudge";
20
+ };
21
+ export { labelSizeMap, helperTextSizeMap, iconSizeMap, actionButtonSizeMap };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@geneui/components",
3
3
  "description": "The Gene UI components library designed for BI tools",
4
- "version": "3.0.0-next-a255969-03032026",
4
+ "version": "3.0.0-next-e1bd79a-05032026",
5
5
  "author": "SoftConstruct",
6
6
  "homepage": "https://github.com/softconstruct/gene-ui-components#readme",
7
7
  "repository": {