@trackunit/react-form-components 0.0.128-alpha-b0920fa0dd.0 → 0.0.129

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/index.cjs.js CHANGED
@@ -341,23 +341,6 @@ const cvaCheckbox = cssClassVarianceUtilities.cvaMerge([
341
341
  "group-active:ring-blue-700",
342
342
  ], {
343
343
  variants: {
344
- disabled: {
345
- true: [
346
- "bg-slate-300",
347
- "border-slate-300",
348
- "cursor-not-allowed",
349
- "group-hover:bg-slate-300",
350
- "group-focus:bg-slate-300",
351
- "hover:bg-slate-300",
352
- "focus:bg-slate-300",
353
- "active:bg-slate-300",
354
- "focus:ring-0",
355
- "focus:ring-offset-0",
356
- "group-active:ring-0",
357
- "group-active:ring-offset-0",
358
- ],
359
- false: "",
360
- },
361
344
  invalid: {
362
345
  true: [
363
346
  "border-red-600",
@@ -397,6 +380,23 @@ const cvaCheckbox = cssClassVarianceUtilities.cvaMerge([
397
380
  "group-focus:border-blue-800",
398
381
  ],
399
382
  },
383
+ disabled: {
384
+ true: [
385
+ "bg-slate-300",
386
+ "border-slate-300",
387
+ "cursor-not-allowed",
388
+ "group-hover:bg-slate-300",
389
+ "group-focus:bg-slate-300",
390
+ "hover:bg-slate-300",
391
+ "focus:bg-slate-300",
392
+ "active:bg-slate-300",
393
+ "focus:ring-0",
394
+ "focus:ring-offset-0",
395
+ "group-active:ring-0",
396
+ "group-active:ring-offset-0",
397
+ ],
398
+ false: "",
399
+ },
400
400
  },
401
401
  compoundVariants: [
402
402
  {
@@ -421,7 +421,7 @@ const cvaCheckbox = cssClassVarianceUtilities.cvaMerge([
421
421
  ],
422
422
  defaultVariants: {
423
423
  state: "deselected",
424
- }
424
+ },
425
425
  });
426
426
  const cvaCheckboxContainer = cssClassVarianceUtilities.cvaMerge([
427
427
  "grid",
@@ -3110,7 +3110,9 @@ const EmailField = React.forwardRef((_a, ref) => {
3110
3110
  *
3111
3111
  * NOTE: If shown with a label, please use the `NumberField` component instead.
3112
3112
  */
3113
- const NumberInput = React.forwardRef((props, ref) => (jsxRuntime.jsx(BaseInput, Object.assign({ ref: ref, type: "number" }, props))));
3113
+ const NumberInput = React.forwardRef((props, ref) => {
3114
+ return jsxRuntime.jsx(BaseInput, Object.assign({ ref: ref, type: "number" }, props, { value: props.value }));
3115
+ });
3114
3116
 
3115
3117
  /**
3116
3118
  * The number field component is used for entering numeric values and includes controls for incrementally increasing or decreasing the value.
@@ -14515,7 +14517,7 @@ const CountryCodeSelect = ({ excludedCountries, countryCode, isInvalid, onChange
14515
14517
  * @returns {JSX.Element} - The PhoneInput component.
14516
14518
  */
14517
14519
  const PhoneInput = React.forwardRef((_a, ref) => {
14518
- var { dataTestId, isInvalid, disabled = false, value, defaultValue, fieldSize = "medium", disableAction = false, onChange, onChangeGetSeparateValues, onBlurCountryCode, readOnly, countryCodePlaceholder } = _a, rest = __rest(_a, ["dataTestId", "isInvalid", "disabled", "value", "defaultValue", "fieldSize", "disableAction", "onChange", "onChangeGetSeparateValues", "onBlurCountryCode", "readOnly", "countryCodePlaceholder"]);
14520
+ var { dataTestId, isInvalid, disabled = false, value, defaultValue, fieldSize = "medium", disableAction = false, onChange, onChangeGetSeparateValues, onBlurCountryCode, readOnly, countryCodePlaceholder, onChangeCountryCode } = _a, rest = __rest(_a, ["dataTestId", "isInvalid", "disabled", "value", "defaultValue", "fieldSize", "disableAction", "onChange", "onChangeGetSeparateValues", "onBlurCountryCode", "readOnly", "countryCodePlaceholder", "onChangeCountryCode"]);
14519
14521
  const hiddenInputRef = React.useRef(null);
14520
14522
  const { countryCode, phoneNumber, isCountryCodeInvalid, isPhoneNumberInvalid, handleCountryCodeChange, handlePhoneNumberChange, combinedValue, isCombinedValueInvalid, } = usePhoneInput(!!value ? value : defaultValue);
14521
14523
  React.useEffect(() => {
@@ -14530,7 +14532,10 @@ const PhoneInput = React.forwardRef((_a, ref) => {
14530
14532
  onChangeGetSeparateValues && onChangeGetSeparateValues({ countryCode, phoneNumber });
14531
14533
  }, [countryCode, onChangeGetSeparateValues, phoneNumber]);
14532
14534
  const countryCodePlaceholderValue = countryCodePlaceholder || "+45";
14533
- return (jsxRuntime.jsxs("div", { className: "grid grid-cols-min-fr gap-2", "data-testid": dataTestId && `${dataTestId}-container`, children: [jsxRuntime.jsx("input", { hidden: true, id: "phone-input", "data-testid": dataTestId, value: combinedValue, ref: hiddenInputRef, onChange: onChange, "aria-invalid": isCombinedValueInvalid || isInvalid }), jsxRuntime.jsx(CountryCodeSelect, { dataTestId: dataTestId && `${dataTestId}-countryCodeSelect`, countryCode: countryCode, onChange: handleCountryCodeChange, disabled: disabled, readOnly: readOnly, isInvalid: isCountryCodeInvalid || isInvalid, placeholder: countryCodePlaceholderValue, onBlur: onBlurCountryCode }), jsxRuntime.jsx(BaseInput, Object.assign({ id: "phoneInput-number", dataTestId: dataTestId && `${dataTestId}-phoneNumberInput`, fieldSize: fieldSize, type: "tel", value: phoneNumber, disabled: disabled, readOnly: readOnly, onChange: handlePhoneNumberChange, isInvalid: isPhoneNumberInvalid || isInvalid, actions: !disableAction && (jsxRuntime.jsx(ActionButton, { disabled: disabled || isInvalid || isCountryCodeInvalid || isPhoneNumberInvalid, value: `${countryCode}${phoneNumber}`, type: "PHONE_NUMBER", dataTestId: dataTestId && `${dataTestId}-phoneIcon`, iconSize: fieldSize })) }, rest))] }));
14535
+ return (jsxRuntime.jsxs("div", { className: "grid grid-cols-min-fr gap-2", "data-testid": dataTestId && `${dataTestId}-container`, children: [jsxRuntime.jsx("input", { hidden: true, id: "phone-input", "data-testid": dataTestId, value: combinedValue, ref: hiddenInputRef, onChange: onChange, "aria-invalid": isCombinedValueInvalid || isInvalid }), jsxRuntime.jsx(CountryCodeSelect, { dataTestId: dataTestId && `${dataTestId}-countryCodeSelect`, countryCode: countryCode, onChange: e => {
14536
+ handleCountryCodeChange(e);
14537
+ onChangeCountryCode && onChangeCountryCode(e);
14538
+ }, disabled: disabled, readOnly: readOnly, isInvalid: isCountryCodeInvalid || isInvalid, placeholder: countryCodePlaceholderValue, onBlur: onBlurCountryCode }), jsxRuntime.jsx(BaseInput, Object.assign({ id: "phoneInput-number", dataTestId: dataTestId && `${dataTestId}-phoneNumberInput`, fieldSize: fieldSize, type: "tel", value: phoneNumber, disabled: disabled, readOnly: readOnly, onChange: handlePhoneNumberChange, isInvalid: isPhoneNumberInvalid || isInvalid, actions: !disableAction && (jsxRuntime.jsx(ActionButton, { disabled: disabled || isInvalid || isCountryCodeInvalid || isPhoneNumberInvalid, value: `${countryCode}${phoneNumber}`, type: "PHONE_NUMBER", dataTestId: dataTestId && `${dataTestId}-phoneIcon`, iconSize: fieldSize })) }, rest))] }));
14534
14539
  });
14535
14540
 
14536
14541
  /**
package/index.esm.js CHANGED
@@ -315,23 +315,6 @@ const cvaCheckbox = cvaMerge([
315
315
  "group-active:ring-blue-700",
316
316
  ], {
317
317
  variants: {
318
- disabled: {
319
- true: [
320
- "bg-slate-300",
321
- "border-slate-300",
322
- "cursor-not-allowed",
323
- "group-hover:bg-slate-300",
324
- "group-focus:bg-slate-300",
325
- "hover:bg-slate-300",
326
- "focus:bg-slate-300",
327
- "active:bg-slate-300",
328
- "focus:ring-0",
329
- "focus:ring-offset-0",
330
- "group-active:ring-0",
331
- "group-active:ring-offset-0",
332
- ],
333
- false: "",
334
- },
335
318
  invalid: {
336
319
  true: [
337
320
  "border-red-600",
@@ -371,6 +354,23 @@ const cvaCheckbox = cvaMerge([
371
354
  "group-focus:border-blue-800",
372
355
  ],
373
356
  },
357
+ disabled: {
358
+ true: [
359
+ "bg-slate-300",
360
+ "border-slate-300",
361
+ "cursor-not-allowed",
362
+ "group-hover:bg-slate-300",
363
+ "group-focus:bg-slate-300",
364
+ "hover:bg-slate-300",
365
+ "focus:bg-slate-300",
366
+ "active:bg-slate-300",
367
+ "focus:ring-0",
368
+ "focus:ring-offset-0",
369
+ "group-active:ring-0",
370
+ "group-active:ring-offset-0",
371
+ ],
372
+ false: "",
373
+ },
374
374
  },
375
375
  compoundVariants: [
376
376
  {
@@ -395,7 +395,7 @@ const cvaCheckbox = cvaMerge([
395
395
  ],
396
396
  defaultVariants: {
397
397
  state: "deselected",
398
- }
398
+ },
399
399
  });
400
400
  const cvaCheckboxContainer = cvaMerge([
401
401
  "grid",
@@ -3084,7 +3084,9 @@ const EmailField = forwardRef((_a, ref) => {
3084
3084
  *
3085
3085
  * NOTE: If shown with a label, please use the `NumberField` component instead.
3086
3086
  */
3087
- const NumberInput = forwardRef((props, ref) => (jsx$1(BaseInput, Object.assign({ ref: ref, type: "number" }, props))));
3087
+ const NumberInput = forwardRef((props, ref) => {
3088
+ return jsx$1(BaseInput, Object.assign({ ref: ref, type: "number" }, props, { value: props.value }));
3089
+ });
3088
3090
 
3089
3091
  /**
3090
3092
  * The number field component is used for entering numeric values and includes controls for incrementally increasing or decreasing the value.
@@ -14489,7 +14491,7 @@ const CountryCodeSelect = ({ excludedCountries, countryCode, isInvalid, onChange
14489
14491
  * @returns {JSX.Element} - The PhoneInput component.
14490
14492
  */
14491
14493
  const PhoneInput = forwardRef((_a, ref) => {
14492
- var { dataTestId, isInvalid, disabled = false, value, defaultValue, fieldSize = "medium", disableAction = false, onChange, onChangeGetSeparateValues, onBlurCountryCode, readOnly, countryCodePlaceholder } = _a, rest = __rest(_a, ["dataTestId", "isInvalid", "disabled", "value", "defaultValue", "fieldSize", "disableAction", "onChange", "onChangeGetSeparateValues", "onBlurCountryCode", "readOnly", "countryCodePlaceholder"]);
14494
+ var { dataTestId, isInvalid, disabled = false, value, defaultValue, fieldSize = "medium", disableAction = false, onChange, onChangeGetSeparateValues, onBlurCountryCode, readOnly, countryCodePlaceholder, onChangeCountryCode } = _a, rest = __rest(_a, ["dataTestId", "isInvalid", "disabled", "value", "defaultValue", "fieldSize", "disableAction", "onChange", "onChangeGetSeparateValues", "onBlurCountryCode", "readOnly", "countryCodePlaceholder", "onChangeCountryCode"]);
14493
14495
  const hiddenInputRef = useRef(null);
14494
14496
  const { countryCode, phoneNumber, isCountryCodeInvalid, isPhoneNumberInvalid, handleCountryCodeChange, handlePhoneNumberChange, combinedValue, isCombinedValueInvalid, } = usePhoneInput(!!value ? value : defaultValue);
14495
14497
  useEffect(() => {
@@ -14504,7 +14506,10 @@ const PhoneInput = forwardRef((_a, ref) => {
14504
14506
  onChangeGetSeparateValues && onChangeGetSeparateValues({ countryCode, phoneNumber });
14505
14507
  }, [countryCode, onChangeGetSeparateValues, phoneNumber]);
14506
14508
  const countryCodePlaceholderValue = countryCodePlaceholder || "+45";
14507
- return (jsxs("div", { className: "grid grid-cols-min-fr gap-2", "data-testid": dataTestId && `${dataTestId}-container`, children: [jsx$1("input", { hidden: true, id: "phone-input", "data-testid": dataTestId, value: combinedValue, ref: hiddenInputRef, onChange: onChange, "aria-invalid": isCombinedValueInvalid || isInvalid }), jsx$1(CountryCodeSelect, { dataTestId: dataTestId && `${dataTestId}-countryCodeSelect`, countryCode: countryCode, onChange: handleCountryCodeChange, disabled: disabled, readOnly: readOnly, isInvalid: isCountryCodeInvalid || isInvalid, placeholder: countryCodePlaceholderValue, onBlur: onBlurCountryCode }), jsx$1(BaseInput, Object.assign({ id: "phoneInput-number", dataTestId: dataTestId && `${dataTestId}-phoneNumberInput`, fieldSize: fieldSize, type: "tel", value: phoneNumber, disabled: disabled, readOnly: readOnly, onChange: handlePhoneNumberChange, isInvalid: isPhoneNumberInvalid || isInvalid, actions: !disableAction && (jsx$1(ActionButton, { disabled: disabled || isInvalid || isCountryCodeInvalid || isPhoneNumberInvalid, value: `${countryCode}${phoneNumber}`, type: "PHONE_NUMBER", dataTestId: dataTestId && `${dataTestId}-phoneIcon`, iconSize: fieldSize })) }, rest))] }));
14509
+ return (jsxs("div", { className: "grid grid-cols-min-fr gap-2", "data-testid": dataTestId && `${dataTestId}-container`, children: [jsx$1("input", { hidden: true, id: "phone-input", "data-testid": dataTestId, value: combinedValue, ref: hiddenInputRef, onChange: onChange, "aria-invalid": isCombinedValueInvalid || isInvalid }), jsx$1(CountryCodeSelect, { dataTestId: dataTestId && `${dataTestId}-countryCodeSelect`, countryCode: countryCode, onChange: e => {
14510
+ handleCountryCodeChange(e);
14511
+ onChangeCountryCode && onChangeCountryCode(e);
14512
+ }, disabled: disabled, readOnly: readOnly, isInvalid: isCountryCodeInvalid || isInvalid, placeholder: countryCodePlaceholderValue, onBlur: onBlurCountryCode }), jsx$1(BaseInput, Object.assign({ id: "phoneInput-number", dataTestId: dataTestId && `${dataTestId}-phoneNumberInput`, fieldSize: fieldSize, type: "tel", value: phoneNumber, disabled: disabled, readOnly: readOnly, onChange: handlePhoneNumberChange, isInvalid: isPhoneNumberInvalid || isInvalid, actions: !disableAction && (jsx$1(ActionButton, { disabled: disabled || isInvalid || isCountryCodeInvalid || isPhoneNumberInvalid, value: `${countryCode}${phoneNumber}`, type: "PHONE_NUMBER", dataTestId: dataTestId && `${dataTestId}-phoneIcon`, iconSize: fieldSize })) }, rest))] }));
14508
14513
  });
14509
14514
 
14510
14515
  /**
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@trackunit/react-form-components",
3
- "version": "0.0.128-alpha-b0920fa0dd.0",
3
+ "version": "0.0.129",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
7
7
  "node": ">=18.x"
8
8
  },
9
9
  "dependencies": {
10
- "@trackunit/css-class-variance-utilities": "0.0.13-alpha-b0920fa0dd.0",
11
- "@trackunit/i18n-library-translation": "0.0.73-alpha-b0920fa0dd.0",
12
- "@trackunit/react-components": "0.1.151-alpha-b0920fa0dd.0",
13
- "@trackunit/shared-utils": "0.0.4-alpha-b0920fa0dd.0",
10
+ "@trackunit/css-class-variance-utilities": "0.0.12",
11
+ "@trackunit/i18n-library-translation": "0.0.72",
12
+ "@trackunit/react-components": "0.1.151",
13
+ "@trackunit/shared-utils": "0.0.4",
14
14
  "date-fns": "2.29.3",
15
15
  "libphonenumber-js": "1.10.36",
16
16
  "react": "18.2.0",
@@ -1,7 +1,7 @@
1
1
  export declare const cvaCheckbox: (props?: ({
2
- disabled?: boolean | null | undefined;
3
2
  invalid?: boolean | null | undefined;
4
3
  state?: "selected" | "deselected" | "indeterminate" | null | undefined;
4
+ disabled?: boolean | null | undefined;
5
5
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
6
6
  export declare const cvaCheckboxContainer: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
7
7
  export declare const cvaCheckboxInput: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
@@ -1,5 +1,6 @@
1
1
  import { FocusEventHandler } from "react";
2
2
  import { BaseInputProps } from "../BaseInput";
3
+ import { SingleValue } from "react-select";
3
4
  type BaseInputExposedProps = Omit<BaseInputProps, "actions">;
4
5
  export interface PhoneNumberProps {
5
6
  countryCode: string;
@@ -23,6 +24,13 @@ export interface PhoneInputProps extends BaseInputExposedProps {
23
24
  * On blur handler for country code component.
24
25
  */
25
26
  onBlurCountryCode?: FocusEventHandler<HTMLInputElement> | undefined;
27
+ /**
28
+ * On change handler for country code component.
29
+ */
30
+ onChangeCountryCode?: (value: SingleValue<{
31
+ label: string;
32
+ value: string;
33
+ }>) => void;
26
34
  /**
27
35
  * A placeholder value for country code.
28
36
  */