nucleus-core-ts 0.10.213 → 0.10.214

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/dist/.build-ok CHANGED
@@ -1 +1 @@
1
- 0.10.213
1
+ 0.10.214
@@ -1,2 +1,2 @@
1
1
  import type { FormBuilderProps } from '../types';
2
- export declare function FormBuilder<T extends Record<string, unknown>>({ columns, mode, initialValues, onSubmit, onCancel, validate, fieldConfigs, excludeFields, includeFields, layout, size, columns_grid, gap, submitText, cancelText, loading, disabled, showRequiredIndicator: _showRequiredIndicator, locale, labels, className, formClassName, fieldsClassName, actionsClassName, renderHeader, renderFooter, renderField, }: FormBuilderProps<T>): import("react/jsx-runtime").JSX.Element;
2
+ export declare function FormBuilder<T extends Record<string, unknown>>({ columns, mode, initialValues, onSubmit, onCancel, validate, fieldConfigs, excludeFields, includeFields, layout, size, columns_grid, gap, submitText, cancelText, loading, disabled, showRequiredIndicator: _showRequiredIndicator, locale, labelPlacement, labels, className, formClassName, fieldsClassName, actionsClassName, renderHeader, renderFooter, renderField, }: FormBuilderProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -12,7 +12,7 @@ import { cn } from '../utils/cn';
12
12
  import { shouldExcludeField } from '../utils/fieldMapping';
13
13
  import { FormField } from './FormField';
14
14
  gsap.registerPlugin(useGSAP);
15
- export function FormBuilder({ columns, mode, initialValues, onSubmit, onCancel, validate, fieldConfigs, excludeFields = [], includeFields, layout = 'vertical', size = 'md', columns_grid = 1, gap = 'md', submitText, cancelText, loading = false, disabled = false, showRequiredIndicator: _showRequiredIndicator = true, locale, labels, className, formClassName, fieldsClassName, actionsClassName, renderHeader, renderFooter, renderField }) {
15
+ export function FormBuilder({ columns, mode, initialValues, onSubmit, onCancel, validate, fieldConfigs, excludeFields = [], includeFields, layout = 'vertical', size = 'md', columns_grid = 1, gap = 'md', submitText, cancelText, loading = false, disabled = false, showRequiredIndicator: _showRequiredIndicator = true, locale, labelPlacement, labels, className, formClassName, fieldsClassName, actionsClassName, renderHeader, renderFooter, renderField }) {
16
16
  const theme = formBuilderTheme;
17
17
  const formRef = useRef(null);
18
18
  const fieldsRef = useRef(null);
@@ -119,6 +119,7 @@ export function FormBuilder({ columns, mode, initialValues, onSubmit, onCancel,
119
119
  error: fieldProps.error,
120
120
  size: size,
121
121
  locale: activeLocale,
122
+ labelPlacement: labelPlacement,
122
123
  labels: say,
123
124
  disabled: isFormDisabled
124
125
  })
@@ -1,2 +1,2 @@
1
1
  import type { FormFieldProps } from '../types';
2
- export declare function FormField<T>({ column, config, value, onChange, error, size, locale, labels, disabled, readOnly, }: FormFieldProps<T>): string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | null | undefined;
2
+ export declare function FormField<T>({ column, config, value, onChange, error, size, locale, labelPlacement, labels, disabled, readOnly, }: FormFieldProps<T>): string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | null | undefined;
@@ -12,8 +12,9 @@ import { DEFAULT_FORM_BUILDER_LABELS } from '../labels';
12
12
  import { formBuilderTheme } from '../theme';
13
13
  import { cn } from '../utils/cn';
14
14
  import { getFieldMapping } from '../utils/fieldMapping';
15
+ import { NumberField } from './NumberField';
15
16
  gsap.registerPlugin(useGSAP);
16
- export function FormField({ column, config, value, onChange, error, size = 'md', locale, labels, disabled = false, readOnly = false }) {
17
+ export function FormField({ column, config, value, onChange, error, size = 'md', locale, labelPlacement, labels, disabled = false, readOnly = false }) {
17
18
  const theme = formBuilderTheme.field;
18
19
  const containerRef = useRef(null);
19
20
  const errorRef = useRef(null);
@@ -111,21 +112,19 @@ export function FormField({ column, config, value, onChange, error, size = 'md',
111
112
  required: isRequired
112
113
  });
113
114
  case 'number':
114
- return /*#__PURE__*/ _jsx(NucleusTextInput, {
115
- type: "number",
116
- value: value !== null && value !== undefined ? String(value) : '',
117
- onChange: (val)=>{
118
- const num = val === '' ? null : Number(val);
119
- onChange(num);
120
- },
115
+ return /*#__PURE__*/ _jsx(NumberField, {
116
+ value: typeof value === 'number' ? value : null,
117
+ onChange: (num)=>onChange(num),
118
+ locale: activeLocale,
121
119
  placeholder: placeholder,
122
120
  label: label,
121
+ labelPlacement: labelPlacement,
123
122
  size: size,
124
123
  disabled: isDisabled,
125
124
  readOnly: isReadOnly,
126
125
  errorMessage: error,
127
126
  helperText: config.helperText,
128
- "data-tutorial": inputTutorial
127
+ dataTutorial: inputTutorial
129
128
  });
130
129
  case 'textarea':
131
130
  return /*#__PURE__*/ _jsx(NucleusTextInput, {
@@ -134,6 +133,7 @@ export function FormField({ column, config, value, onChange, error, size = 'md',
134
133
  onChange: (val)=>onChange(val),
135
134
  placeholder: placeholder,
136
135
  label: label,
136
+ labelPlacement: labelPlacement,
137
137
  size: size,
138
138
  disabled: isDisabled,
139
139
  readOnly: isReadOnly,
@@ -160,6 +160,7 @@ export function FormField({ column, config, value, onChange, error, size = 'md',
160
160
  },
161
161
  placeholder: placeholder,
162
162
  label: label,
163
+ labelPlacement: labelPlacement,
163
164
  size: size,
164
165
  disabled: isDisabled,
165
166
  readOnly: isReadOnly,
@@ -181,6 +182,7 @@ export function FormField({ column, config, value, onChange, error, size = 'md',
181
182
  onChange: (val)=>onChange(val),
182
183
  placeholder: placeholder,
183
184
  label: label,
185
+ labelPlacement: labelPlacement,
184
186
  size: size,
185
187
  disabled: isDisabled,
186
188
  readOnly: isReadOnly,
@@ -0,0 +1,23 @@
1
+ import type { LabelPlacement } from '../../NucleusTextInput/types';
2
+ import type { LocaleKey } from '../../DatePicker/types';
3
+ export interface NumberFieldProps {
4
+ value: number | null | undefined;
5
+ onChange: (value: number | null) => void;
6
+ locale: LocaleKey;
7
+ label?: string;
8
+ labelPlacement?: LabelPlacement;
9
+ placeholder?: string;
10
+ helperText?: string;
11
+ errorMessage?: string;
12
+ size?: 'sm' | 'md' | 'lg';
13
+ disabled?: boolean;
14
+ readOnly?: boolean;
15
+ dataTutorial?: string;
16
+ }
17
+ /**
18
+ * A number field that speaks the viewer's language. Chrome draws `type="number"` in the browser's
19
+ * own language, so an English page showed `0,1` on a Turkish browser. This is a text input with
20
+ * the decimal keypad that accepts `,` and `.`, shows the value in the `locale`'s mark, and keeps
21
+ * what the person typed while the field is focused (so `0,` does not collapse to `0`).
22
+ */
23
+ export declare function NumberField({ value, onChange, locale, dataTutorial, ...field }: NumberFieldProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,33 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useState } from 'react';
4
+ import { NucleusTextInput } from '../../NucleusTextInput';
5
+ import { formatLocaleNumber, isPartialNumber, parseLocaleNumber } from '../utils/localeNumber';
6
+ /**
7
+ * A number field that speaks the viewer's language. Chrome draws `type="number"` in the browser's
8
+ * own language, so an English page showed `0,1` on a Turkish browser. This is a text input with
9
+ * the decimal keypad that accepts `,` and `.`, shows the value in the `locale`'s mark, and keeps
10
+ * what the person typed while the field is focused (so `0,` does not collapse to `0`).
11
+ */ export function NumberField({ value, onChange, locale, dataTutorial, ...field }) {
12
+ const [draft, setDraft] = useState(null);
13
+ const draftValue = draft === null ? null : parseLocaleNumber(draft);
14
+ const keepDraft = draft !== null && (draftValue === (value ?? null) || draftValue === null && isPartialNumber(draft));
15
+ const shown = keepDraft ? draft : formatLocaleNumber(value, locale);
16
+ return /*#__PURE__*/ _jsx(NucleusTextInput, {
17
+ ...field,
18
+ type: "text",
19
+ inputMode: "decimal",
20
+ autoComplete: "off",
21
+ enableValidation: false,
22
+ value: shown,
23
+ onChange: (text)=>{
24
+ const parsed = parseLocaleNumber(text);
25
+ // Text that is neither a number nor the start of one ('abc') is refused, as a native number field does.
26
+ if (parsed === null && text.trim() !== '' && !isPartialNumber(text)) return;
27
+ setDraft(text);
28
+ onChange(parsed);
29
+ },
30
+ onBlur: ()=>setDraft(null),
31
+ "data-tutorial": dataTutorial
32
+ });
33
+ }
@@ -2,5 +2,6 @@ export { FormBuilder } from './components/FormBuilder';
2
2
  export { FormField } from './components/FormField';
3
3
  export { useFormBuilder } from './hooks/useFormBuilder';
4
4
  export { DEFAULT_FORM_BUILDER_LABELS, type FormBuilderLabels, resolveFormBuilderLabels, } from './labels';
5
+ export { formatLocaleNumber, isPartialNumber, parseLocaleNumber } from './utils/localeNumber';
5
6
  export { formBuilderTheme } from './theme';
6
7
  export type { ColumnEnum, ColumnReference, ColumnType, ColumnValidation, FormBuilderProps, FormFieldConfig, FormFieldProps, FormFieldRenderProps, FormFooterRenderProps, FormLayout, FormMode, FormSize, FormState, NucleusColumn, UseFormBuilderOptions, UseFormBuilderReturn, ValidationFormat, } from './types';
@@ -2,4 +2,5 @@ export { FormBuilder } from './components/FormBuilder';
2
2
  export { FormField } from './components/FormField';
3
3
  export { useFormBuilder } from './hooks/useFormBuilder';
4
4
  export { DEFAULT_FORM_BUILDER_LABELS, resolveFormBuilderLabels } from './labels';
5
+ export { formatLocaleNumber, isPartialNumber, parseLocaleNumber } from './utils/localeNumber';
5
6
  export { formBuilderTheme } from './theme';
@@ -1,4 +1,5 @@
1
1
  import type { ReactNode } from 'react';
2
+ import type { LabelPlacement } from '../../NucleusTextInput/types';
2
3
  import type { LocaleKey } from '../../DatePicker/types';
3
4
  import type { SelectOption } from '../../SelectBox/types';
4
5
  import type { FormBuilderLabels } from '../labels';
@@ -103,6 +104,11 @@ export interface FormBuilderProps<T extends Record<string, unknown>> {
103
104
  disabled?: boolean;
104
105
  showRequiredIndicator?: boolean;
105
106
  locale?: LocaleKey;
107
+ /**
108
+ * Where text-field labels sit: `floating` (default) rests inside the field, `above` is a static
109
+ * label over it, like the select box, so a form of text fields and selects aligns.
110
+ */
111
+ labelPlacement?: LabelPlacement;
106
112
  /**
107
113
  * Every word the form says that the caller did not pass in itself — the two
108
114
  * buttons, the derived field names and placeholders, the dropdown values and
@@ -133,6 +139,8 @@ export interface FormFieldProps<T = unknown> {
133
139
  error?: string;
134
140
  size?: FormSize;
135
141
  locale?: LocaleKey;
142
+ /** `floating` (default) or `above`; see `FormBuilderProps.labelPlacement`. */
143
+ labelPlacement?: LabelPlacement;
136
144
  /** The same contract the form uses; `FormField` is exported on its own too. */
137
145
  labels?: Partial<FormBuilderLabels>;
138
146
  disabled?: boolean;
@@ -0,0 +1,14 @@
1
+ import type { LocaleKey } from '../../DatePicker/types';
2
+ /**
3
+ * A number typed by a person, in either decimal mark. `0,1` and `0.1` are both 0.1.
4
+ *
5
+ * With both marks present the last one is the decimal mark and the other groups digits (`1.234,5`,
6
+ * `1,234.5`). A single mark is always a decimal mark, so `1.234` is 1.234, not 1234: these fields
7
+ * hold quantities, rates and prices typed without grouping. Spaces are ignored. Empty or
8
+ * unreadable text is `null`.
9
+ */
10
+ export declare function parseLocaleNumber(text: string): number | null;
11
+ /** Text a person is still typing that is not a number yet: `-`, `,` or `-.`. */
12
+ export declare function isPartialNumber(text: string): boolean;
13
+ /** A number in the viewer's own decimal mark, without digit grouping: 0.1 is `0,1` in `tr-TR`. */
14
+ export declare function formatLocaleNumber(value: number | null | undefined, locale: LocaleKey): string;
@@ -0,0 +1,31 @@
1
+ const NUMBER_PATTERN = /^-?(\d+\.?\d*|\.\d+)$/;
2
+ const PARTIAL_PATTERN = /^-?[.,]?$/;
3
+ /**
4
+ * A number typed by a person, in either decimal mark. `0,1` and `0.1` are both 0.1.
5
+ *
6
+ * With both marks present the last one is the decimal mark and the other groups digits (`1.234,5`,
7
+ * `1,234.5`). A single mark is always a decimal mark, so `1.234` is 1.234, not 1234: these fields
8
+ * hold quantities, rates and prices typed without grouping. Spaces are ignored. Empty or
9
+ * unreadable text is `null`.
10
+ */ export function parseLocaleNumber(text) {
11
+ const compact = text.replace(/[\s  ']/g, '');
12
+ if (compact === '') return null;
13
+ const lastComma = compact.lastIndexOf(',');
14
+ const lastDot = compact.lastIndexOf('.');
15
+ const mark = lastComma > lastDot ? ',' : '.';
16
+ const other = mark === ',' ? '.' : ',';
17
+ const normalised = compact.split(other).join('').replace(mark, '.');
18
+ if (!NUMBER_PATTERN.test(normalised)) return null;
19
+ const value = Number(normalised);
20
+ return Number.isFinite(value) ? value : null;
21
+ }
22
+ /** Text a person is still typing that is not a number yet: `-`, `,` or `-.`. */ export function isPartialNumber(text) {
23
+ return PARTIAL_PATTERN.test(text.trim());
24
+ }
25
+ /** A number in the viewer's own decimal mark, without digit grouping: 0.1 is `0,1` in `tr-TR`. */ export function formatLocaleNumber(value, locale) {
26
+ if (value === null || value === undefined || !Number.isFinite(value)) return '';
27
+ return new Intl.NumberFormat(locale, {
28
+ useGrouping: false,
29
+ maximumFractionDigits: 20
30
+ }).format(value);
31
+ }
@@ -1,2 +1,2 @@
1
1
  import type { NucleusTextInputProps } from '../types';
2
- export declare function NucleusTextInput({ value, onChange, type, label, placeholder, helperText, errorMessage, disabled, readOnly, leftIcon, rightIcon, size, fullWidth, className, inputClassName, labelClassName, wrapperClassName, showTypewriterError, showTypeIcon, showValidationIcon, enableValidation, validateOnBlur, validateOnChange, validationConfig, customValidator, onValidationChange, unit, unitPosition, formatNumber, thousandSeparator, phoneFormat, isNewPassword, maxInputLength, confirmValue, onConfirmChange, showPasswordStrength, passwordStrengthWords, labels, preventCopy, preventPaste, preventContextMenu, trimOnBlur, onFocus, onBlur, ...restProps }: NucleusTextInputProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function NucleusTextInput({ value, onChange, type, label, labelPlacement, placeholder, helperText, errorMessage, disabled, readOnly, leftIcon, rightIcon, size, fullWidth, className, inputClassName, labelClassName, wrapperClassName, showTypewriterError, showTypeIcon, showValidationIcon, enableValidation, validateOnBlur, validateOnChange, validationConfig, customValidator, onValidationChange, unit, unitPosition, formatNumber, thousandSeparator, phoneFormat, isNewPassword, maxInputLength, confirmValue, onConfirmChange, showPasswordStrength, passwordStrengthWords, labels, preventCopy, preventPaste, preventContextMenu, trimOnBlur, onFocus, onBlur, ...restProps }: NucleusTextInputProps): import("react/jsx-runtime").JSX.Element;
@@ -17,7 +17,7 @@ import { getDisplayValue } from '../utils/valueView';
17
17
  import { PasswordStrengthIndicator } from './PasswordStrengthIndicator';
18
18
  import { TextInputField } from './TextInputField';
19
19
  gsap.registerPlugin(useGSAP);
20
- export function NucleusTextInput({ value = '', onChange, type = 'text', label, placeholder, helperText, errorMessage, disabled = false, readOnly = false, leftIcon, rightIcon, size = 'md', fullWidth = true, className, inputClassName, labelClassName, wrapperClassName, showTypewriterError = false, showTypeIcon = true, showValidationIcon = true, enableValidation = true, validateOnBlur = true, validateOnChange = false, validationConfig, customValidator, onValidationChange, unit, unitPosition = 'suffix', formatNumber = false, thousandSeparator = ' ', phoneFormat = 'tr', isNewPassword = false, maxInputLength, confirmValue, onConfirmChange, showPasswordStrength = false, passwordStrengthWords, labels, preventCopy = false, preventPaste = false, preventContextMenu = false, trimOnBlur = false, onFocus, onBlur, ...restProps }) {
20
+ export function NucleusTextInput({ value = '', onChange, type = 'text', label, labelPlacement = 'floating', placeholder, helperText, errorMessage, disabled = false, readOnly = false, leftIcon, rightIcon, size = 'md', fullWidth = true, className, inputClassName, labelClassName, wrapperClassName, showTypewriterError = false, showTypeIcon = true, showValidationIcon = true, enableValidation = true, validateOnBlur = true, validateOnChange = false, validationConfig, customValidator, onValidationChange, unit, unitPosition = 'suffix', formatNumber = false, thousandSeparator = ' ', phoneFormat = 'tr', isNewPassword = false, maxInputLength, confirmValue, onConfirmChange, showPasswordStrength = false, passwordStrengthWords, labels, preventCopy = false, preventPaste = false, preventContextMenu = false, trimOnBlur = false, onFocus, onBlur, ...restProps }) {
21
21
  const inputRef = useRef(null);
22
22
  const wrapperRef = useRef(null);
23
23
  const inputId = useId();
@@ -99,6 +99,7 @@ export function NucleusTextInput({ value = '', onChange, type = 'text', label, p
99
99
  inputClassName: inputClassName,
100
100
  labelClassName: labelClassName,
101
101
  label: label,
102
+ labelPlacement: labelPlacement,
102
103
  helperText: helperText,
103
104
  displayError: displayError,
104
105
  hasError: hasError,
@@ -127,7 +128,7 @@ export function NucleusTextInput({ value = '', onChange, type = 'text', label, p
127
128
  ...inputHandlers,
128
129
  disabled,
129
130
  readOnly,
130
- placeholder: isFloated ? placeholder : ''
131
+ placeholder: isFloated || labelPlacement === 'above' ? placeholder : ''
131
132
  },
132
133
  restProps: restProps
133
134
  }),
@@ -1,5 +1,6 @@
1
1
  import type { InputHTMLAttributes, ReactNode, RefObject } from 'react';
2
2
  import type { NucleusTextInputTheme } from '../theme';
3
+ import type { LabelPlacement } from '../types';
3
4
  export interface TextInputFieldProps {
4
5
  theme: NucleusTextInputTheme;
5
6
  inputId: string;
@@ -10,6 +11,7 @@ export interface TextInputFieldProps {
10
11
  inputClassName?: string;
11
12
  labelClassName?: string;
12
13
  label?: string;
14
+ labelPlacement: LabelPlacement;
13
15
  helperText?: string;
14
16
  displayError: string | undefined;
15
17
  hasError: boolean;
@@ -30,4 +32,4 @@ export interface TextInputFieldProps {
30
32
  restProps: InputHTMLAttributes<HTMLInputElement>;
31
33
  }
32
34
  /** The bordered field (icons, floating label, unit, native input) and the message line below it. */
33
- export declare function TextInputField({ theme, inputId, wrapperRef, inputRef, size, wrapperClassName, inputClassName, labelClassName, label, helperText, displayError, hasError, showTypewriterError, isFocused, isHovered, isFloated, disabled, leadingIcon, trailingIcon, unit, unitPosition, onMouseEnter, onMouseLeave, inputProps, restProps, }: TextInputFieldProps): import("react/jsx-runtime").JSX.Element;
35
+ export declare function TextInputField({ theme, inputId, wrapperRef, inputRef, size, wrapperClassName, inputClassName, labelClassName, label, labelPlacement, helperText, displayError, hasError, showTypewriterError, isFocused, isHovered, isFloated, disabled, leadingIcon, trailingIcon, unit, unitPosition, onMouseEnter, onMouseLeave, inputProps, restProps, }: TextInputFieldProps): import("react/jsx-runtime").JSX.Element;
@@ -4,15 +4,21 @@ import { cn } from '../utils/cn';
4
4
  import { FloatingLabel } from './FloatingLabel';
5
5
  import { InputAdornment } from './InputAdornment';
6
6
  import { InputMessage } from './InputMessage';
7
- /** The bordered field (icons, floating label, unit, native input) and the message line below it. */ export function TextInputField({ theme, inputId, wrapperRef, inputRef, size, wrapperClassName, inputClassName, labelClassName, label, helperText, displayError, hasError, showTypewriterError, isFocused, isHovered, isFloated, disabled, leadingIcon, trailingIcon, unit, unitPosition, onMouseEnter, onMouseLeave, inputProps, restProps }) {
7
+ /** The bordered field (icons, floating label, unit, native input) and the message line below it. */ export function TextInputField({ theme, inputId, wrapperRef, inputRef, size, wrapperClassName, inputClassName, labelClassName, label, labelPlacement, helperText, displayError, hasError, showTypewriterError, isFocused, isHovered, isFloated, disabled, leadingIcon, trailingIcon, unit, unitPosition, onMouseEnter, onMouseLeave, inputProps, restProps }) {
8
8
  const adornmentState = {
9
9
  theme,
10
10
  isFocused,
11
11
  hasError,
12
12
  disabled
13
13
  };
14
+ const labelAbove = labelPlacement === 'above' && Boolean(label);
14
15
  return /*#__PURE__*/ _jsxs(_Fragment, {
15
16
  children: [
17
+ labelAbove && /*#__PURE__*/ _jsx("label", {
18
+ htmlFor: inputId,
19
+ className: cn(theme.aboveLabel.base, disabled ? theme.aboveLabel.disabled : hasError ? theme.aboveLabel.error : theme.aboveLabel.color, labelClassName),
20
+ children: label
21
+ }),
16
22
  /*#__PURE__*/ _jsxs("label", {
17
23
  ref: wrapperRef,
18
24
  htmlFor: inputId,
@@ -39,7 +45,7 @@ import { InputMessage } from './InputMessage';
39
45
  ...adornmentState,
40
46
  children: leadingIcon
41
47
  }),
42
- label && /*#__PURE__*/ _jsx(FloatingLabel, {
48
+ label && !labelAbove && /*#__PURE__*/ _jsx(FloatingLabel, {
43
49
  label: label,
44
50
  isFloated: isFloated,
45
51
  isFocused: isFocused,
@@ -6,6 +6,6 @@ export { TypewriterText } from './components/TypewriterText';
6
6
  export { DEFAULT_TEXT_INPUT_LABELS, type NucleusTextInputLabels } from './labels';
7
7
  export type { NucleusTextInputTheme } from './theme';
8
8
  export { extendNucleusTextInputTheme, nucleusTextInputTheme } from './theme';
9
- export type { FloatingLabelProps, InputState, InputType, NucleusTextInputProps, PhoneFormat, TypewriterTextProps, ValidationConfig, ValidationResult, } from './types';
9
+ export type { FloatingLabelProps, InputState, InputType, LabelPlacement, NucleusTextInputProps, PhoneFormat, TypewriterTextProps, ValidationConfig, ValidationResult, } from './types';
10
10
  export { formatNumberWithSeparator, formatPhoneNumber, parseFormattedNumber, unformatNumber, unformatPhone, } from './utils/format';
11
11
  export { defaultValidators, getAutoCompleteForType, getInputModeForType, validateWithConfig, } from './utils/validation';
@@ -56,6 +56,12 @@ export declare const nucleusTextInputTheme: {
56
56
  };
57
57
  };
58
58
  };
59
+ readonly aboveLabel: {
60
+ readonly base: "block mb-1.5 text-sm font-medium";
61
+ readonly color: "text-zinc-700 dark:text-zinc-300";
62
+ readonly error: "text-red-600 dark:text-red-400";
63
+ readonly disabled: "text-gray-400 dark:text-gray-500";
64
+ };
59
65
  readonly helperText: {
60
66
  readonly base: "mt-1.5 ml-1";
61
67
  readonly text: "text-xs";
@@ -56,6 +56,12 @@ export const nucleusTextInputTheme = {
56
56
  }
57
57
  }
58
58
  },
59
+ aboveLabel: {
60
+ base: 'block mb-1.5 text-sm font-medium',
61
+ color: 'text-zinc-700 dark:text-zinc-300',
62
+ error: 'text-red-600 dark:text-red-400',
63
+ disabled: 'text-gray-400 dark:text-gray-500'
64
+ },
59
65
  helperText: {
60
66
  base: 'mt-1.5 ml-1',
61
67
  text: 'text-xs',
@@ -3,12 +3,20 @@ import type { PhoneFormat } from '../utils/format';
3
3
  import type { InputType, ValidationConfig, ValidationResult } from '../utils/validation';
4
4
  export type { PhoneFormat };
5
5
  export type InputState = 'inactive' | 'hover' | 'focused' | 'error' | 'disabled';
6
+ /**
7
+ * Where the label sits. `floating` (default) rests inside the field and floats onto the border;
8
+ * `above` is a static label over the field, the placement `SelectBox` always uses, so a form that
9
+ * mixes text fields and selects reads as one column of labels.
10
+ */
11
+ export type LabelPlacement = 'floating' | 'above';
6
12
  export type { InputType, ValidationConfig, ValidationResult };
7
13
  export interface NucleusTextInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'value' | 'size' | 'type'> {
8
14
  value?: string;
9
15
  onChange?: (value: string) => void;
10
16
  type?: InputType;
11
17
  label?: string;
18
+ /** `floating` (default) or `above`: see `LabelPlacement`. */
19
+ labelPlacement?: LabelPlacement;
12
20
  placeholder?: string;
13
21
  helperText?: string;
14
22
  errorMessage?: string;
@@ -27,7 +27,7 @@ export * from './components/FieldSchema';
27
27
  export type { ForgotPasswordAction, ForgotPasswordFormProps, ForgotPasswordHeaderProps, ForgotPasswordPageConfig, ForgotPasswordStep, } from './components/ForgotPasswordPage';
28
28
  export { DEFAULT_FORGOT_PASSWORD_LABELS, extendForgotPasswordPageTheme, ForgotPasswordPage, type ForgotPasswordPageTheme, forgotPasswordPageTheme, useForgotPasswordStore, } from './components/ForgotPasswordPage';
29
29
  export type { FormBuilderProps, FormFieldConfig, FormFieldProps, FormFieldRenderProps, FormFooterRenderProps, FormLayout, FormMode, FormSize, FormState, UseFormBuilderOptions, UseFormBuilderReturn, } from './components/FormBuilder';
30
- export { FormBuilder, FormField, formBuilderTheme, useFormBuilder, } from './components/FormBuilder';
30
+ export { FormBuilder, FormField, formatLocaleNumber, formBuilderTheme, parseLocaleNumber, useFormBuilder, } from './components/FormBuilder';
31
31
  export { DEFAULT_FORM_BUILDER_LABELS, type FormBuilderLabels, } from './components/FormBuilder/labels';
32
32
  export { defaultIntegrationsLabels, extendIntegrationsTheme, IntegrationsPage, integrationsPageTheme, resolveIntegrationsLabels, useIntegrationsStore, } from './components/IntegrationsPage';
33
33
  export type { ConnectionTab } from './components/IntegrationsPage/store/state';
@@ -45,7 +45,7 @@ export { extendNotificationCenterTheme, NotificationBell, NotificationCenter, no
45
45
  export { DEFAULT_NOTIFICATION_CENTER_LABELS, type NotificationCenterLabels, } from './components/NotificationCenter/labels';
46
46
  export { NucleusEntityShowcase } from './components/NucleusEntityShowcase';
47
47
  export { DEFAULT_ENTITY_SHOWCASE_LABELS, type NucleusEntityShowcaseLabels, } from './components/NucleusEntityShowcase.labels';
48
- export { DEFAULT_TEXT_INPUT_LABELS, NucleusTextInput, type NucleusTextInputLabels, } from './components/NucleusTextInput';
48
+ export { DEFAULT_TEXT_INPUT_LABELS, type LabelPlacement, NucleusTextInput, type NucleusTextInputLabels, } from './components/NucleusTextInput';
49
49
  export type { AddressCardProps, AddressInfo, FileInfo, MeResponseData, PhoneCardProps, PhoneInfo, ProfileHeaderProps, ProfileInfo, ProfilePageConfig, ProfilePageProps, ProfilePageVariant, ProfileState, UserInfo, } from './components/ProfilePage';
50
50
  export { AddressCard, PhoneCard, ProfileHeader, ProfilePage, useProfileStore, } from './components/ProfilePage';
51
51
  export { DEFAULT_PROFILE_PAGE_LABELS, type ProfilePageLabels, } from './components/ProfilePage/labels';
package/dist/fe/index.js CHANGED
@@ -21,7 +21,7 @@ export { DeviceCard, DevicesHeader, DevicesPage, useDevicesStore } from './compo
21
21
  export { DEFAULT_DEVICES_PAGE_LABELS } from './components/DevicesPage/labels';
22
22
  export * from './components/FieldSchema';
23
23
  export { DEFAULT_FORGOT_PASSWORD_LABELS, extendForgotPasswordPageTheme, ForgotPasswordPage, forgotPasswordPageTheme, useForgotPasswordStore } from './components/ForgotPasswordPage';
24
- export { FormBuilder, FormField, formBuilderTheme, useFormBuilder } from './components/FormBuilder';
24
+ export { FormBuilder, FormField, formatLocaleNumber, formBuilderTheme, parseLocaleNumber, useFormBuilder } from './components/FormBuilder';
25
25
  export { DEFAULT_FORM_BUILDER_LABELS } from './components/FormBuilder/labels';
26
26
  export { defaultIntegrationsLabels, extendIntegrationsTheme, IntegrationsPage, integrationsPageTheme, resolveIntegrationsLabels, useIntegrationsStore } from './components/IntegrationsPage';
27
27
  export { LoginPage, useLoginStore } from './components/LoginPage';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nucleus-core-ts",
3
- "version": "0.10.213",
3
+ "version": "0.10.214",
4
4
  "description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
5
5
  "author": "Hidayet Can Özcan <hidayetcan@gmail.com>",
6
6
  "license": "SEE LICENSE IN LICENSE",