@react-fabric/form 1.0.3 → 1.0.4

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/css/_field.css CHANGED
@@ -49,7 +49,7 @@
49
49
  &:has([data-open="true"]) {
50
50
  z-index: 1;
51
51
  background-color: var(--fabric-input-focus);
52
- outline-color: var(--color-primary);
52
+ outline-color: var(--color-primary-200);
53
53
 
54
54
  &:not(:has([aria-readonly="true"]:not([hidden])))::after {
55
55
  inset-inline: 0;
@@ -62,7 +62,7 @@
62
62
 
63
63
  & input,
64
64
  & textarea {
65
- width: 4rem;
65
+ min-width: 4rem;
66
66
  max-width: 100%;
67
67
  line-height: 1.5;
68
68
  }
@@ -166,7 +166,7 @@
166
166
  > * {
167
167
  &,
168
168
  & > .fabric-inputWrapper {
169
- border-radius: var(--radius-cap);
169
+ border-radius: var(--radius-capped);
170
170
  }
171
171
 
172
172
  &:not(:last-child) {
@@ -46,7 +46,7 @@ function Checkbox(_ref) {
46
46
  onChange === null || onChange === void 0 || onChange((_e$target$checked2 = e === null || e === void 0 ? void 0 : e.target.checked) !== null && _e$target$checked2 !== void 0 ? _e$target$checked2 : false);
47
47
  }, [onChange, updateValue]);
48
48
  return /*#__PURE__*/jsxRuntime.jsxs("label", {
49
- className: utilities.cn(invalid ? "ring-danger-500" : "ring-primary-500", disabled ? "opacity-50 cursor-not-allowed" : " opacity-85 hover:opacity-100 cursor-pointer", "inline-flex gap-1 py-1 items-center relative rounded ring-offset-2 has-focus-visible:ring-1"),
49
+ className: utilities.cn(invalid ? "ring-danger-500" : "ring-primary-500", disabled ? "opacity-50 cursor-not-allowed" : " opacity-85 hover:opacity-100 cursor-pointer", "inline-flex gap-1 py-1 items-center relative rounded-capped ring-offset-2 has-focus-visible:ring-1"),
50
50
  style: {
51
51
  width: width
52
52
  },
@@ -170,7 +170,7 @@ function DateInput(props) {
170
170
  style: _objectSpread({
171
171
  zIndex: "var(--z-popover)"
172
172
  }, floatingStyles),
173
- className: "shadow-lg bg-default ring-1 ring-tint-100",
173
+ className: "shadow-lg bg-default border border-soft",
174
174
  "data-ref": "dropdownBody"
175
175
  }, getFloatingProps()), {}, {
176
176
  children: [/*#__PURE__*/jsxRuntime.jsx(date.DatePanel, {
@@ -183,7 +183,7 @@ function DateInput(props) {
183
183
  ref: arrowRef,
184
184
  context: context,
185
185
  strokeWidth: 0.5,
186
- className: "fill-default stroke-muted"
186
+ className: "fill-default stroke-soft"
187
187
  })]
188
188
  }))]
189
189
  }));
@@ -23,7 +23,7 @@ function Field(props) {
23
23
  inline = props.inline;
24
24
  return /*#__PURE__*/jsxRuntime.jsx(FieldWrapper.FieldWrapper, _objectSpread(_objectSpread({}, getProps.getWrapperProps(props)), {}, {
25
25
  children: /*#__PURE__*/jsxRuntime.jsx("div", {
26
- className: utilities.cn("fabric-fieldGroup", !plain && !borderless && "outline focus-within:outline-primary-500 has-aria-invalid:focus-within:outline-danger-500", !plain && "bg-default", plain && "flex-wrap", inline && "flex-1", vertical ? "rounded-capped" : "rounded flex"),
26
+ className: utilities.cn("fabric-fieldGroup", !plain && !borderless && "outline focus-within:outline-primary-500 has-aria-invalid:focus-within:outline-danger-500", !plain && "bg-(--fabric-input) focus-within:bg(--fabric-input-focus)", plain && "flex-wrap", inline && "flex-1", vertical ? "rounded-capped" : "rounded flex"),
27
27
  "data-vertical": !!vertical,
28
28
  children: children
29
29
  })
@@ -42,7 +42,7 @@ function Radio(_ref) {
42
42
  if (e !== null && e !== void 0 && e.target.checked && value) onChange === null || onChange === void 0 || onChange(value);
43
43
  }, [onChange, value]);
44
44
  return /*#__PURE__*/jsxRuntime.jsxs("label", {
45
- className: utilities.cn(invalid ? "ring-danger-500" : "ring-primary-500", disabled ? "opacity-50 cursor-not-allowed" : "hover:opacity-100 cursor-pointer", "inline-flex gap-1 py-1 items-center relative cursor-pointer opacity-85 rounded ring-offset-2 has-focus-visible:ring-1"),
45
+ className: utilities.cn(invalid ? "ring-danger-500" : "ring-primary-500", disabled ? "opacity-50 cursor-not-allowed" : "hover:opacity-100 cursor-pointer", "inline-flex gap-1 py-1 items-center relative cursor-pointer opacity-85 rounded-capped ring-offset-2 has-focus-visible:ring-1"),
46
46
  style: {
47
47
  width: width
48
48
  },
@@ -1,12 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
5
4
  var core = require('@react-fabric/core');
5
+ var utilities = require('@react-fabric/utilities');
6
6
  var react = require('react');
7
7
  var InputWrapper = require('../internal/InputWrapper.js');
8
8
  var eventHandlers = require('../utils/eventHandlers.js');
9
- require('@react-fabric/utilities');
10
9
  var getProps = require('../utils/getProps.js');
11
10
  var jsxRuntime = require('react/jsx-runtime');
12
11
 
@@ -44,12 +43,6 @@ function Textarea(props) {
44
43
  var _useControlledValue = core.useControlledValue(value, defaultValue),
45
44
  currentValue = _useControlledValue.currentValue,
46
45
  updateValue = _useControlledValue.updateValue;
47
- var _useState = react.useState(function () {
48
- return rows;
49
- }),
50
- _useState2 = _slicedToArray(_useState, 2),
51
- fixedRows = _useState2[0],
52
- setFixedRows = _useState2[1];
53
46
  var wrapperRef = react.useRef(null);
54
47
  var handleChange = react.useCallback(function (e) {
55
48
  var _e$target$value;
@@ -57,14 +50,6 @@ function Textarea(props) {
57
50
  updateValue(value);
58
51
  onChange === null || onChange === void 0 || onChange(value);
59
52
  }, [defaultValue, updateValue, onChange]);
60
- react.useEffect(function () {
61
- if (variableRows) {
62
- var _currentValue$split$l;
63
- var lines = (_currentValue$split$l = currentValue === null || currentValue === void 0 ? void 0 : currentValue.split("\n").length) !== null && _currentValue$split$l !== void 0 ? _currentValue$split$l : 1;
64
- // eslint-disable-next-line @eslint-react/set-state-in-effect
65
- setFixedRows(Math.max(rows, Math.min(maxRows, lines)));
66
- }
67
- }, [currentValue, variableRows, rows, maxRows]);
68
53
  var handleEnterPressed = eventHandlers.useHandleEnter(onEnterPressed, {
69
54
  preventDefault: !!onEnterPressed
70
55
  });
@@ -78,14 +63,14 @@ function Textarea(props) {
78
63
  }, getProps.getWrapperProps(props)), {}, {
79
64
  children: /*#__PURE__*/jsxRuntime.jsx("textarea", {
80
65
  id: id,
81
- className: "appearance-none self-stretch bg-transparent py-1 px-4 not-first:ps-2 not-last:pe-2 flex-1 border-none outline-none ring-0 min-h-12 resize-none",
66
+ className: utilities.cn("appearance-none self-stretch bg-transparent py-1 px-4 not-first:ps-2 not-last:pe-2 flex-1 border-none outline-none ring-0 min-h-12 resize-none", variableRows && "field-sizing-content"),
82
67
  "aria-invalid": invalid,
83
68
  "aria-disabled": disabled,
84
69
  "aria-readonly": readOnly,
85
70
  placeholder: placeholder,
86
71
  disabled: disabled,
87
72
  readOnly: readOnly,
88
- rows: fixedRows,
73
+ rows: rows,
89
74
  "data-testid": name,
90
75
  name: name,
91
76
  ref: ref,
@@ -95,7 +80,10 @@ function Textarea(props) {
95
80
  onBlur: onBlur,
96
81
  onFocus: onFocus,
97
82
  onChange: handleChange,
98
- onKeyDown: handleEnterPressed
83
+ onKeyDown: handleEnterPressed,
84
+ style: {
85
+ maxHeight: "calc(".concat(maxRows, " * 1.25rem)")
86
+ }
99
87
  })
100
88
  }));
101
89
  }
@@ -66,7 +66,7 @@ function InputWrapper(props) {
66
66
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
67
67
  role: "none",
68
68
  ref: utilities.mergeRefs(ref, wrapperRef),
69
- className: utilities.cn("fabric-inputWrapper", invalid && "fabric-invalidWrapper", !borderless && "outline", textarea ? "rounded-capped" : "rounded", className, "flex flex-1 flex-nowrap items-center bg-(--fabric-input)", isExpanded ? "fixed inset-4 z-99" : floatingExpand ? "absolute inset-x-0" : "relative", focusRing ? "focus-within:ring ring-primary-500" : "after:absolute after:bottom-0 after:h-px after:bg-primary-500 after:mx-auto", isOpen && "outline-primary-500"),
69
+ className: utilities.cn("fabric-inputWrapper", invalid && "fabric-invalidWrapper", !borderless && "outline transition-colors duration-500", textarea ? "rounded-capped" : "rounded", className, "flex flex-1 flex-nowrap items-center bg-(--fabric-input) overflow-hidden", isExpanded ? "fixed inset-4 z-99" : floatingExpand ? "absolute inset-x-0" : "relative", focusRing ? "focus-within:ring ring-primary-500" : "after:absolute after:bottom-0 after:h-px after:bg-primary-500 after:mx-auto", isOpen && "outline-primary-500"),
70
70
  onKeyDown: function onKeyDown(e) {
71
71
  return e.key === "Escape" && isExpanded && (setIsExpanded(false), e.stopPropagation());
72
72
  },
@@ -46,7 +46,7 @@ function Checkbox(_ref) {
46
46
  onChange === null || onChange === void 0 || onChange((_e$target$checked2 = e === null || e === void 0 ? void 0 : e.target.checked) !== null && _e$target$checked2 !== void 0 ? _e$target$checked2 : false);
47
47
  }, [onChange, updateValue]);
48
48
  return /*#__PURE__*/jsxs("label", {
49
- className: cn(invalid ? "ring-danger-500" : "ring-primary-500", disabled ? "opacity-50 cursor-not-allowed" : " opacity-85 hover:opacity-100 cursor-pointer", "inline-flex gap-1 py-1 items-center relative rounded ring-offset-2 has-focus-visible:ring-1"),
49
+ className: cn(invalid ? "ring-danger-500" : "ring-primary-500", disabled ? "opacity-50 cursor-not-allowed" : " opacity-85 hover:opacity-100 cursor-pointer", "inline-flex gap-1 py-1 items-center relative rounded-capped ring-offset-2 has-focus-visible:ring-1"),
50
50
  style: {
51
51
  width: width
52
52
  },
@@ -170,7 +170,7 @@ function DateInput(props) {
170
170
  style: _objectSpread({
171
171
  zIndex: "var(--z-popover)"
172
172
  }, floatingStyles),
173
- className: "shadow-lg bg-default ring-1 ring-tint-100",
173
+ className: "shadow-lg bg-default border border-soft",
174
174
  "data-ref": "dropdownBody"
175
175
  }, getFloatingProps()), {}, {
176
176
  children: [/*#__PURE__*/jsx(DatePanel, {
@@ -183,7 +183,7 @@ function DateInput(props) {
183
183
  ref: arrowRef,
184
184
  context: context,
185
185
  strokeWidth: 0.5,
186
- className: "fill-default stroke-muted"
186
+ className: "fill-default stroke-soft"
187
187
  })]
188
188
  }))]
189
189
  }));
@@ -23,7 +23,7 @@ function Field(props) {
23
23
  inline = props.inline;
24
24
  return /*#__PURE__*/jsx(FieldWrapper, _objectSpread(_objectSpread({}, getWrapperProps(props)), {}, {
25
25
  children: /*#__PURE__*/jsx("div", {
26
- className: cn("fabric-fieldGroup", !plain && !borderless && "outline focus-within:outline-primary-500 has-aria-invalid:focus-within:outline-danger-500", !plain && "bg-default", plain && "flex-wrap", inline && "flex-1", vertical ? "rounded-capped" : "rounded flex"),
26
+ className: cn("fabric-fieldGroup", !plain && !borderless && "outline focus-within:outline-primary-500 has-aria-invalid:focus-within:outline-danger-500", !plain && "bg-(--fabric-input) focus-within:bg(--fabric-input-focus)", plain && "flex-wrap", inline && "flex-1", vertical ? "rounded-capped" : "rounded flex"),
27
27
  "data-vertical": !!vertical,
28
28
  children: children
29
29
  })
@@ -42,7 +42,7 @@ function Radio(_ref) {
42
42
  if (e !== null && e !== void 0 && e.target.checked && value) onChange === null || onChange === void 0 || onChange(value);
43
43
  }, [onChange, value]);
44
44
  return /*#__PURE__*/jsxs("label", {
45
- className: cn(invalid ? "ring-danger-500" : "ring-primary-500", disabled ? "opacity-50 cursor-not-allowed" : "hover:opacity-100 cursor-pointer", "inline-flex gap-1 py-1 items-center relative cursor-pointer opacity-85 rounded ring-offset-2 has-focus-visible:ring-1"),
45
+ className: cn(invalid ? "ring-danger-500" : "ring-primary-500", disabled ? "opacity-50 cursor-not-allowed" : "hover:opacity-100 cursor-pointer", "inline-flex gap-1 py-1 items-center relative cursor-pointer opacity-85 rounded-capped ring-offset-2 has-focus-visible:ring-1"),
46
46
  style: {
47
47
  width: width
48
48
  },
@@ -1,12 +1,11 @@
1
1
  'use client';
2
2
 
3
3
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
5
4
  import { useControlledValue } from '@react-fabric/core';
6
- import { useId, useState, useRef, useCallback, useEffect } from 'react';
5
+ import { cn } from '@react-fabric/utilities';
6
+ import { useId, useRef, useCallback } from 'react';
7
7
  import { InputWrapper } from '../internal/InputWrapper.js';
8
8
  import { useHandleEnter } from '../utils/eventHandlers.js';
9
- import '@react-fabric/utilities';
10
9
  import { getWrapperProps } from '../utils/getProps.js';
11
10
  import { jsx } from 'react/jsx-runtime';
12
11
 
@@ -44,12 +43,6 @@ function Textarea(props) {
44
43
  var _useControlledValue = useControlledValue(value, defaultValue),
45
44
  currentValue = _useControlledValue.currentValue,
46
45
  updateValue = _useControlledValue.updateValue;
47
- var _useState = useState(function () {
48
- return rows;
49
- }),
50
- _useState2 = _slicedToArray(_useState, 2),
51
- fixedRows = _useState2[0],
52
- setFixedRows = _useState2[1];
53
46
  var wrapperRef = useRef(null);
54
47
  var handleChange = useCallback(function (e) {
55
48
  var _e$target$value;
@@ -57,14 +50,6 @@ function Textarea(props) {
57
50
  updateValue(value);
58
51
  onChange === null || onChange === void 0 || onChange(value);
59
52
  }, [defaultValue, updateValue, onChange]);
60
- useEffect(function () {
61
- if (variableRows) {
62
- var _currentValue$split$l;
63
- var lines = (_currentValue$split$l = currentValue === null || currentValue === void 0 ? void 0 : currentValue.split("\n").length) !== null && _currentValue$split$l !== void 0 ? _currentValue$split$l : 1;
64
- // eslint-disable-next-line @eslint-react/set-state-in-effect
65
- setFixedRows(Math.max(rows, Math.min(maxRows, lines)));
66
- }
67
- }, [currentValue, variableRows, rows, maxRows]);
68
53
  var handleEnterPressed = useHandleEnter(onEnterPressed, {
69
54
  preventDefault: !!onEnterPressed
70
55
  });
@@ -78,14 +63,14 @@ function Textarea(props) {
78
63
  }, getWrapperProps(props)), {}, {
79
64
  children: /*#__PURE__*/jsx("textarea", {
80
65
  id: id,
81
- className: "appearance-none self-stretch bg-transparent py-1 px-4 not-first:ps-2 not-last:pe-2 flex-1 border-none outline-none ring-0 min-h-12 resize-none",
66
+ className: cn("appearance-none self-stretch bg-transparent py-1 px-4 not-first:ps-2 not-last:pe-2 flex-1 border-none outline-none ring-0 min-h-12 resize-none", variableRows && "field-sizing-content"),
82
67
  "aria-invalid": invalid,
83
68
  "aria-disabled": disabled,
84
69
  "aria-readonly": readOnly,
85
70
  placeholder: placeholder,
86
71
  disabled: disabled,
87
72
  readOnly: readOnly,
88
- rows: fixedRows,
73
+ rows: rows,
89
74
  "data-testid": name,
90
75
  name: name,
91
76
  ref: ref,
@@ -95,7 +80,10 @@ function Textarea(props) {
95
80
  onBlur: onBlur,
96
81
  onFocus: onFocus,
97
82
  onChange: handleChange,
98
- onKeyDown: handleEnterPressed
83
+ onKeyDown: handleEnterPressed,
84
+ style: {
85
+ maxHeight: "calc(".concat(maxRows, " * 1.25rem)")
86
+ }
99
87
  })
100
88
  }));
101
89
  }
@@ -66,7 +66,7 @@ function InputWrapper(props) {
66
66
  children: /*#__PURE__*/jsxs("div", {
67
67
  role: "none",
68
68
  ref: mergeRefs(ref, wrapperRef),
69
- className: cn("fabric-inputWrapper", invalid && "fabric-invalidWrapper", !borderless && "outline", textarea ? "rounded-capped" : "rounded", className, "flex flex-1 flex-nowrap items-center bg-(--fabric-input)", isExpanded ? "fixed inset-4 z-99" : floatingExpand ? "absolute inset-x-0" : "relative", focusRing ? "focus-within:ring ring-primary-500" : "after:absolute after:bottom-0 after:h-px after:bg-primary-500 after:mx-auto", isOpen && "outline-primary-500"),
69
+ className: cn("fabric-inputWrapper", invalid && "fabric-invalidWrapper", !borderless && "outline transition-colors duration-500", textarea ? "rounded-capped" : "rounded", className, "flex flex-1 flex-nowrap items-center bg-(--fabric-input) overflow-hidden", isExpanded ? "fixed inset-4 z-99" : floatingExpand ? "absolute inset-x-0" : "relative", focusRing ? "focus-within:ring ring-primary-500" : "after:absolute after:bottom-0 after:h-px after:bg-primary-500 after:mx-auto", isOpen && "outline-primary-500"),
70
70
  onKeyDown: function onKeyDown(e) {
71
71
  return e.key === "Escape" && isExpanded && (setIsExpanded(false), e.stopPropagation());
72
72
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-fabric/form",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "RUF: Form package",
5
5
  "author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
6
6
  "license": "MIT",
@@ -38,8 +38,8 @@
38
38
  "@faker-js/faker": "10.6.0",
39
39
  "@floating-ui/react": "~0.27.20",
40
40
  "@hookform/resolvers": "~5.9.1",
41
- "@react-fabric/core": "^1.0.3",
42
- "@react-fabric/date": "^1.0.3",
41
+ "@react-fabric/core": "^1.0.4",
42
+ "@react-fabric/date": "^1.0.4",
43
43
  "@react-fabric/utilities": "^1.0.2",
44
44
  "@tanstack/react-form": "~1.33.3",
45
45
  "chroma-js": "~3.2.0",
@@ -60,5 +60,5 @@
60
60
  "node": ">=24.0.0",
61
61
  "npm": ">=11.0.0"
62
62
  },
63
- "gitHead": "eac6cb8a2c63dce6447eb7136a0524a094e8c1f1"
63
+ "gitHead": "25a840f083aeaf1ee4eee82130e80c151b4f76f6"
64
64
  }
@@ -76,20 +76,7 @@ interface CheckboxProps extends RefProp<HTMLInputElement> {
76
76
  * The component uses a deferred value to manage the checked state, ensuring smooth updates.
77
77
  * It also provides an error icon to indicate validation errors.
78
78
  */
79
- export function Checkbox({
80
- ref,
81
- label,
82
- name,
83
- checked,
84
- invalid,
85
- disabled,
86
- error,
87
- width,
88
- icon,
89
- iconChecked,
90
- onChange,
91
- ...rest
92
- }: CheckboxProps) {
79
+ export function Checkbox({ ref, label, name, checked, invalid, disabled, error, width, icon, iconChecked, onChange, ...rest }: CheckboxProps) {
93
80
  const { currentValue, updateValue } = useControlledValue(!!checked, false);
94
81
 
95
82
  const iconOn = useMemo(() => iconChecked ?? icon ?? "icon-[mdi--checkbox-marked]", [icon, iconChecked]);
@@ -108,7 +95,7 @@ export function Checkbox({
108
95
  className={cn(
109
96
  invalid ? "ring-danger-500" : "ring-primary-500",
110
97
  disabled ? "opacity-50 cursor-not-allowed" : " opacity-85 hover:opacity-100 cursor-pointer",
111
- "inline-flex gap-1 py-1 items-center relative rounded ring-offset-2 has-focus-visible:ring-1",
98
+ "inline-flex gap-1 py-1 items-center relative rounded-capped ring-offset-2 has-focus-visible:ring-1",
112
99
  )}
113
100
  style={{ width }}
114
101
  >
@@ -21,19 +21,7 @@
21
21
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  */
23
23
 
24
- import {
25
- arrow,
26
- autoUpdate,
27
- flip,
28
- FloatingArrow,
29
- offset,
30
- shift,
31
- useClick,
32
- useDismiss,
33
- useFloating,
34
- useFocus,
35
- useInteractions,
36
- } from "@floating-ui/react";
24
+ import { FloatingArrow, arrow, autoUpdate, flip, offset, shift, useClick, useDismiss, useFloating, useFocus, useInteractions } from "@floating-ui/react";
37
25
  import { useControlledValue } from "@react-fabric/core";
38
26
  import type { RefProp } from "@react-fabric/core/dist/types/types";
39
27
  import type { DateLike } from "@react-fabric/date";
@@ -164,12 +152,7 @@ export function DateInput(props: DateProps) {
164
152
  const { getReferenceProps, getFloatingProps } = useInteractions([dismiss, click, focus]);
165
153
 
166
154
  return (
167
- <InputWrapper
168
- id={id}
169
- showClear={allowClear && !!currentValue && !disabled && !readOnly}
170
- onClear={handleChange}
171
- {...getWrapperProps(props)}
172
- >
155
+ <InputWrapper id={id} showClear={allowClear && !!currentValue && !disabled && !readOnly} onClear={handleChange} {...getWrapperProps(props)}>
173
156
  <input
174
157
  id={id}
175
158
  className={cn(
@@ -206,18 +189,12 @@ export function DateInput(props: DateProps) {
206
189
  zIndex: "var(--z-popover)",
207
190
  ...floatingStyles,
208
191
  }}
209
- className="shadow-lg bg-default ring-1 ring-tint-100"
192
+ className="shadow-lg bg-default border border-soft"
210
193
  data-ref="dropdownBody"
211
194
  {...getFloatingProps()}
212
195
  >
213
- <DatePanel
214
- withTime={type === "datetime"}
215
- value={currentValue ?? ""}
216
- max={max}
217
- min={min}
218
- onChange={handleDateChange}
219
- />
220
- <FloatingArrow ref={arrowRef} context={context} strokeWidth={0.5} className="fill-default stroke-muted" />
196
+ <DatePanel withTime={type === "datetime"} value={currentValue ?? ""} max={max} min={min} onChange={handleDateChange} />
197
+ <FloatingArrow ref={arrowRef} context={context} strokeWidth={0.5} className="fill-default stroke-soft" />
221
198
  </div>
222
199
  )}
223
200
  </InputWrapper>
@@ -48,7 +48,7 @@ export function Field(props: FieldProps) {
48
48
  className={cn(
49
49
  "fabric-fieldGroup",
50
50
  !plain && !borderless && "outline focus-within:outline-primary-500 has-aria-invalid:focus-within:outline-danger-500",
51
- !plain && "bg-default",
51
+ !plain && "bg-(--fabric-input) focus-within:bg(--fabric-input-focus)",
52
52
  plain && "flex-wrap",
53
53
  inline && "flex-1",
54
54
  vertical ? "rounded-capped" : "rounded flex",
@@ -76,20 +76,7 @@ export interface RadioProps extends RefProp<HTMLInputElement> {
76
76
  * This component renders a radio button with an optional label and custom icons for checked and unchecked states.
77
77
  * It supports disabled and invalid states, and allows for custom width.
78
78
  */
79
- export function Radio({
80
- ref,
81
- name,
82
- label,
83
- value,
84
- invalid,
85
- disabled,
86
- width,
87
- icon,
88
- error,
89
- iconChecked,
90
- onChange,
91
- ...rest
92
- }: RadioProps) {
79
+ export function Radio({ ref, name, label, value, invalid, disabled, width, icon, error, iconChecked, onChange, ...rest }: RadioProps) {
93
80
  const iconOn = useMemo(() => iconChecked ?? icon ?? "icon-[mdi--radiobox-marked]", [icon, iconChecked]);
94
81
  const iconOff = useMemo(() => icon ?? "icon-[mdi--radiobox-blank]", [icon]);
95
82
 
@@ -106,7 +93,7 @@ export function Radio({
106
93
  className={cn(
107
94
  invalid ? "ring-danger-500" : "ring-primary-500",
108
95
  disabled ? "opacity-50 cursor-not-allowed" : "hover:opacity-100 cursor-pointer",
109
- "inline-flex gap-1 py-1 items-center relative cursor-pointer opacity-85 rounded ring-offset-2 has-focus-visible:ring-1",
96
+ "inline-flex gap-1 py-1 items-center relative cursor-pointer opacity-85 rounded-capped ring-offset-2 has-focus-visible:ring-1",
110
97
  )}
111
98
  style={{ width }}
112
99
  >
@@ -23,8 +23,9 @@
23
23
 
24
24
  import { useControlledValue } from "@react-fabric/core";
25
25
  import type { RefProp } from "@react-fabric/core/dist/types/types";
26
+ import { cn } from "@react-fabric/utilities";
26
27
  import type { KeyboardEventHandler } from "react";
27
- import { useCallback, useEffect, useId, useRef, useState } from "react";
28
+ import { useCallback, useId, useRef } from "react";
28
29
  import { InputWrapper } from "../internal/InputWrapper";
29
30
  import type { InputProps, WrapperProps } from "../types";
30
31
  import { getWrapperProps, useHandleEnter } from "../utils";
@@ -80,7 +81,6 @@ export function Textarea(props: TextareaProps) {
80
81
  const id = useId();
81
82
  const { currentValue, updateValue } = useControlledValue(value, defaultValue);
82
83
 
83
- const [fixedRows, setFixedRows] = useState(() => rows);
84
84
  const wrapperRef = useRef<HTMLDivElement>(null);
85
85
 
86
86
  const handleChange = useCallback(
@@ -92,20 +92,9 @@ export function Textarea(props: TextareaProps) {
92
92
  [defaultValue, updateValue, onChange],
93
93
  );
94
94
 
95
- useEffect(() => {
96
- if (variableRows) {
97
- const lines = currentValue?.split("\n").length ?? 1;
98
- // eslint-disable-next-line @eslint-react/set-state-in-effect
99
- setFixedRows(Math.max(rows, Math.min(maxRows, lines)));
100
- }
101
- }, [currentValue, variableRows, rows, maxRows]);
102
-
103
- const handleEnterPressed = useHandleEnter<HTMLTextAreaElement>(
104
- onEnterPressed as unknown as KeyboardEventHandler<HTMLTextAreaElement>,
105
- {
106
- preventDefault: !!onEnterPressed,
107
- },
108
- );
95
+ const handleEnterPressed = useHandleEnter<HTMLTextAreaElement>(onEnterPressed as unknown as KeyboardEventHandler<HTMLTextAreaElement>, {
96
+ preventDefault: !!onEnterPressed,
97
+ });
109
98
 
110
99
  return (
111
100
  <InputWrapper
@@ -119,14 +108,17 @@ export function Textarea(props: TextareaProps) {
119
108
  >
120
109
  <textarea
121
110
  id={id}
122
- className="appearance-none self-stretch bg-transparent py-1 px-4 not-first:ps-2 not-last:pe-2 flex-1 border-none outline-none ring-0 min-h-12 resize-none"
111
+ className={cn(
112
+ "appearance-none self-stretch bg-transparent py-1 px-4 not-first:ps-2 not-last:pe-2 flex-1 border-none outline-none ring-0 min-h-12 resize-none",
113
+ variableRows && "field-sizing-content",
114
+ )}
123
115
  aria-invalid={invalid}
124
116
  aria-disabled={disabled}
125
117
  aria-readonly={readOnly}
126
118
  placeholder={placeholder}
127
119
  disabled={disabled}
128
120
  readOnly={readOnly}
129
- rows={fixedRows}
121
+ rows={rows}
130
122
  data-testid={name}
131
123
  name={name}
132
124
  ref={ref}
@@ -137,6 +129,9 @@ export function Textarea(props: TextareaProps) {
137
129
  onFocus={onFocus}
138
130
  onChange={handleChange}
139
131
  onKeyDown={handleEnterPressed}
132
+ style={{
133
+ maxHeight: `calc(${maxRows} * 1.25rem)`,
134
+ }}
140
135
  />
141
136
  </InputWrapper>
142
137
  );
@@ -105,38 +105,26 @@ export function InputWrapper(props: InputWrapperProps) {
105
105
  className={cn(
106
106
  "fabric-inputWrapper",
107
107
  invalid && "fabric-invalidWrapper",
108
- !borderless && "outline",
108
+ !borderless && "outline transition-colors duration-500",
109
109
  textarea ? "rounded-capped" : "rounded",
110
110
  className,
111
- "flex flex-1 flex-nowrap items-center bg-(--fabric-input)",
111
+ "flex flex-1 flex-nowrap items-center bg-(--fabric-input) overflow-hidden",
112
112
  isExpanded ? "fixed inset-4 z-99" : floatingExpand ? "absolute inset-x-0" : "relative",
113
- focusRing
114
- ? "focus-within:ring ring-primary-500"
115
- : "after:absolute after:bottom-0 after:h-px after:bg-primary-500 after:mx-auto",
113
+ focusRing ? "focus-within:ring ring-primary-500" : "after:absolute after:bottom-0 after:h-px after:bg-primary-500 after:mx-auto",
116
114
  isOpen && "outline-primary-500",
117
115
  )}
118
116
  onKeyDown={(e) => e.key === "Escape" && isExpanded && (setIsExpanded(false), e.stopPropagation())}
119
117
  >
120
118
  {decorateStart && (
121
- <div
122
- onClickCapture={doFocus}
123
- className={cn("fabric-decorate", "text-muted leading-none flex-content", isString(decorateStart) && "px-1")}
124
- >
119
+ <div onClickCapture={doFocus} className={cn("fabric-decorate", "text-muted leading-none flex-content", isString(decorateStart) && "px-1")}>
125
120
  {decorateStart}
126
121
  </div>
127
122
  )}
128
123
  <ErrorIcon invalid={invalid} error={error} />
129
124
  {children}
130
125
  {showClear && (
131
- <button
132
- type="button"
133
- className={cn("size-fit leading-0 cursor-pointer", hasStepper && "relative -ms-12")}
134
- onClick={handleClear}
135
- >
136
- <Icon
137
- icon="icon-[mdi--close]"
138
- className={cn("text-tint-500 hover:text-tint-700 p-1 z-1 flex-content", "fabric-inputClear")}
139
- />
126
+ <button type="button" className={cn("size-fit leading-0 cursor-pointer", hasStepper && "relative -ms-12")} onClick={handleClear}>
127
+ <Icon icon="icon-[mdi--close]" className={cn("text-tint-500 hover:text-tint-700 p-1 z-1 flex-content", "fabric-inputClear")} />
140
128
  </button>
141
129
  )}
142
130
  {decorateEnd && (
@@ -159,11 +147,7 @@ export function InputWrapper(props: InputWrapperProps) {
159
147
  </div>
160
148
  )}
161
149
  {textareaExpandable && (
162
- <button
163
- type="button"
164
- className="size-fit cursor-pointer leading-0 absolute top-0 inset-e-0"
165
- onClick={() => setIsExpanded(!isExpanded)}
166
- >
150
+ <button type="button" className="size-fit cursor-pointer leading-0 absolute top-0 inset-e-0" onClick={() => setIsExpanded(!isExpanded)}>
167
151
  <Icon
168
152
  icon={isExpanded ? "icon-[mdi--arrow-collapse]" : "icon-[mdi--arrow-expand]"}
169
153
  className="hidden group-hover:block bg-default hover:bg-tint-200 p-1 opacity-65 rounded-capped"