@phpsoftbox/react-softbox 0.1.0
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/LICENSE +21 -0
- package/README.md +271 -0
- package/dist/components/Alert/Alert.d.ts +11 -0
- package/dist/components/Alert/Alert.js +15 -0
- package/dist/components/Alert/Alert.js.map +1 -0
- package/dist/components/Alert/Alert.module.css +73 -0
- package/dist/components/Badge/Badge.d.ts +8 -0
- package/dist/components/Badge/Badge.js +15 -0
- package/dist/components/Badge/Badge.js.map +1 -0
- package/dist/components/Badge/Badge.module.css +47 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +24 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +15 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js.map +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.module.css +55 -0
- package/dist/components/Button/Button.d.ts +10 -0
- package/dist/components/Button/Button.js +37 -0
- package/dist/components/Button/Button.js.map +1 -0
- package/dist/components/Button/Button.module.css +130 -0
- package/dist/components/Card/Card.d.ts +15 -0
- package/dist/components/Card/Card.js +26 -0
- package/dist/components/Card/Card.js.map +1 -0
- package/dist/components/Card/Card.module.css +55 -0
- package/dist/components/CollapseButton/CollapseButton.d.ts +9 -0
- package/dist/components/CollapseButton/CollapseButton.js +11 -0
- package/dist/components/CollapseButton/CollapseButton.js.map +1 -0
- package/dist/components/CollapseButton/CollapseButton.module.css +57 -0
- package/dist/components/Drawer/Drawer.d.ts +19 -0
- package/dist/components/Drawer/Drawer.js +42 -0
- package/dist/components/Drawer/Drawer.js.map +1 -0
- package/dist/components/Drawer/Drawer.module.css +104 -0
- package/dist/components/Flex/Flex.module.css +11 -0
- package/dist/components/Flex/Row.d.ts +9 -0
- package/dist/components/Flex/Row.js +14 -0
- package/dist/components/Flex/Row.js.map +1 -0
- package/dist/components/Flex/Stack.d.ts +8 -0
- package/dist/components/Flex/Stack.js +13 -0
- package/dist/components/Flex/Stack.js.map +1 -0
- package/dist/components/Grid/Grid.d.ts +11 -0
- package/dist/components/Grid/Grid.js +16 -0
- package/dist/components/Grid/Grid.js.map +1 -0
- package/dist/components/Grid/Grid.module.css +32 -0
- package/dist/components/Input/DatePicker.d.ts +6 -0
- package/dist/components/Input/DatePicker.js +6 -0
- package/dist/components/Input/DatePicker.js.map +1 -0
- package/dist/components/Input/DateRangePicker.d.ts +16 -0
- package/dist/components/Input/DateRangePicker.js +16 -0
- package/dist/components/Input/DateRangePicker.js.map +1 -0
- package/dist/components/Input/Field.d.ts +5 -0
- package/dist/components/Input/Field.js +25 -0
- package/dist/components/Input/Field.js.map +1 -0
- package/dist/components/Input/FloatLabel/FloatLabel.d.ts +9 -0
- package/dist/components/Input/FloatLabel/FloatLabel.js +22 -0
- package/dist/components/Input/FloatLabel/FloatLabel.js.map +1 -0
- package/dist/components/Input/FloatLabel/FloatLabel.module.css +41 -0
- package/dist/components/Input/FormField/FormField.d.ts +29 -0
- package/dist/components/Input/FormField/FormField.js +60 -0
- package/dist/components/Input/FormField/FormField.js.map +1 -0
- package/dist/components/Input/FormField/FormField.module.css +30 -0
- package/dist/components/Input/Input.d.ts +59 -0
- package/dist/components/Input/Input.js +34 -0
- package/dist/components/Input/Input.js.map +1 -0
- package/dist/components/Input/Input.module.css +31 -0
- package/dist/components/Input/InputGroup.d.ts +11 -0
- package/dist/components/Input/InputGroup.js +25 -0
- package/dist/components/Input/InputGroup.js.map +1 -0
- package/dist/components/Input/InputGroup.module.css +38 -0
- package/dist/components/Input/MaskedInput.d.ts +9 -0
- package/dist/components/Input/MaskedInput.js +82 -0
- package/dist/components/Input/MaskedInput.js.map +1 -0
- package/dist/components/Input/NumberInput.d.ts +10 -0
- package/dist/components/Input/NumberInput.js +44 -0
- package/dist/components/Input/NumberInput.js.map +1 -0
- package/dist/components/Input/Radio/Radio.d.ts +7 -0
- package/dist/components/Input/Radio/Radio.js +9 -0
- package/dist/components/Input/Radio/Radio.js.map +1 -0
- package/dist/components/Input/Radio/Radio.module.css +83 -0
- package/dist/components/Input/Select/Select.d.ts +38 -0
- package/dist/components/Input/Select/Select.js +200 -0
- package/dist/components/Input/Select/Select.js.map +1 -0
- package/dist/components/Input/Select/Select.module.css +194 -0
- package/dist/components/Input/Switch/Switch.d.ts +6 -0
- package/dist/components/Input/Switch/Switch.js +9 -0
- package/dist/components/Input/Switch/Switch.js.map +1 -0
- package/dist/components/Input/Switch/Switch.module.css +62 -0
- package/dist/components/Input/Textarea/Textarea.d.ts +6 -0
- package/dist/components/Input/Textarea/Textarea.js +21 -0
- package/dist/components/Input/Textarea/Textarea.js.map +1 -0
- package/dist/components/Input/Textarea/Textarea.module.css +39 -0
- package/dist/components/Input/TimePicker.d.ts +4 -0
- package/dist/components/Input/TimePicker.js +6 -0
- package/dist/components/Input/TimePicker.js.map +1 -0
- package/dist/components/Menu/Dropdown.d.ts +13 -0
- package/dist/components/Menu/Dropdown.js +58 -0
- package/dist/components/Menu/Dropdown.js.map +1 -0
- package/dist/components/Menu/Menu.d.ts +31 -0
- package/dist/components/Menu/Menu.js +161 -0
- package/dist/components/Menu/Menu.js.map +1 -0
- package/dist/components/Menu/Menu.module.css +240 -0
- package/dist/components/Modal/Modal.d.ts +12 -0
- package/dist/components/Modal/Modal.js +31 -0
- package/dist/components/Modal/Modal.js.map +1 -0
- package/dist/components/Modal/Modal.module.css +90 -0
- package/dist/components/Notifier/Notifier.d.ts +17 -0
- package/dist/components/Notifier/Notifier.js +210 -0
- package/dist/components/Notifier/Notifier.js.map +1 -0
- package/dist/components/Notifier/Notifier.module.css +182 -0
- package/dist/components/Pagination/Pagination.d.ts +28 -0
- package/dist/components/Pagination/Pagination.js +70 -0
- package/dist/components/Pagination/Pagination.js.map +1 -0
- package/dist/components/Pagination/Pagination.module.css +93 -0
- package/dist/components/Progress/Progress.d.ts +16 -0
- package/dist/components/Progress/Progress.js +32 -0
- package/dist/components/Progress/Progress.js.map +1 -0
- package/dist/components/Progress/Progress.module.css +110 -0
- package/dist/components/Tabs/Tabs.d.ts +20 -0
- package/dist/components/Tabs/Tabs.js +115 -0
- package/dist/components/Tabs/Tabs.js.map +1 -0
- package/dist/components/Tabs/Tabs.module.css +101 -0
- package/dist/components/Typography/Heading.d.ts +13 -0
- package/dist/components/Typography/Heading.js +38 -0
- package/dist/components/Typography/Heading.js.map +1 -0
- package/dist/components/Typography/Text.d.ts +20 -0
- package/dist/components/Typography/Text.js +43 -0
- package/dist/components/Typography/Text.js.map +1 -0
- package/dist/components/Typography/Typography.module.css +132 -0
- package/dist/foundations/index.css +3 -0
- package/dist/foundations/layout.css +78 -0
- package/dist/foundations/tokens.css +236 -0
- package/dist/foundations/typography.css +49 -0
- package/dist/hooks/useDropdownPosition.d.ts +14 -0
- package/dist/hooks/useDropdownPosition.js +61 -0
- package/dist/hooks/useDropdownPosition.js.map +1 -0
- package/dist/hooks/useMediaQuery.d.ts +1 -0
- package/dist/hooks/useMediaQuery.js +33 -0
- package/dist/hooks/useMediaQuery.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/theme.d.ts +12 -0
- package/dist/theme.js +133 -0
- package/dist/theme.js.map +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/docs/README.md +40 -0
- package/docs/breadcrumbs.md +47 -0
- package/docs/card.md +18 -0
- package/docs/feedback.md +38 -0
- package/docs/forms.md +166 -0
- package/docs/layout.md +39 -0
- package/docs/navigation.md +80 -0
- package/docs/overlays.md +31 -0
- package/docs/pagination.md +50 -0
- package/docs/progress.md +18 -0
- package/docs/tabs.md +34 -0
- package/docs/theme.md +49 -0
- package/docs/typography.md +26 -0
- package/package.json +49 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type RangeValue = {
|
|
3
|
+
start: string;
|
|
4
|
+
end: string;
|
|
5
|
+
};
|
|
6
|
+
type Props = {
|
|
7
|
+
value?: RangeValue;
|
|
8
|
+
onChange?: (value: RangeValue) => void;
|
|
9
|
+
withTime?: boolean;
|
|
10
|
+
separator?: React.ReactNode;
|
|
11
|
+
className?: string;
|
|
12
|
+
startProps?: React.InputHTMLAttributes<HTMLInputElement>;
|
|
13
|
+
endProps?: React.InputHTMLAttributes<HTMLInputElement>;
|
|
14
|
+
};
|
|
15
|
+
export default function DateRangePicker({ value, onChange, withTime, separator, className, startProps, endProps, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import DatePicker from './DatePicker';
|
|
4
|
+
import { InputGroup, InputAddon } from './InputGroup';
|
|
5
|
+
export default function DateRangePicker({ value, onChange, withTime = false, separator = '—', className, startProps, endProps, }) {
|
|
6
|
+
const [internal, setInternal] = React.useState({ start: '', end: '' });
|
|
7
|
+
const current = value ?? internal;
|
|
8
|
+
const update = (next) => {
|
|
9
|
+
if (!value) {
|
|
10
|
+
setInternal(next);
|
|
11
|
+
}
|
|
12
|
+
onChange?.(next);
|
|
13
|
+
};
|
|
14
|
+
return (_jsxs(InputGroup, { className: className, stretch: true, children: [_jsx(DatePicker, { withTime: withTime, value: current.start, onChange: (event) => update({ ...current, start: event.target.value }), ...startProps }), _jsx(InputAddon, { children: separator }), _jsx(DatePicker, { withTime: withTime, value: current.end, onChange: (event) => update({ ...current, end: event.target.value }), ...endProps })] }));
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=DateRangePicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateRangePicker.js","sourceRoot":"","sources":["../../../src/components/Input/DateRangePicker.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE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x-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styles from './Input.module.css';
|
|
4
|
+
import { useFormFieldContext } from './FormField/FormField';
|
|
5
|
+
const buildIdFromName = (name) => `field-${name.replace(/[^a-zA-Z0-9_-]/g, '-')}`;
|
|
6
|
+
const InputField = React.forwardRef(({ hasError, className, ...props }, ref) => {
|
|
7
|
+
const context = useFormFieldContext();
|
|
8
|
+
const generatedId = React.useId();
|
|
9
|
+
const resolvedId = props.id ?? context?.fieldId ?? (props.name ? buildIdFromName(props.name) : generatedId);
|
|
10
|
+
const autoComplete = props.autoComplete ?? 'off';
|
|
11
|
+
const classes = [styles.input, hasError ? styles.error : null, className].filter(Boolean).join(' ');
|
|
12
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
13
|
+
if (!props.id && !props.name) {
|
|
14
|
+
// eslint-disable-next-line no-console
|
|
15
|
+
console.warn('Input.Field: рекомендуется передавать id или name для связки с label.');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
React.useEffect(() => {
|
|
19
|
+
context?.registerField(resolvedId, props.name);
|
|
20
|
+
}, [context, resolvedId, props.name]);
|
|
21
|
+
return _jsx("input", { ref: ref, id: resolvedId, className: classes, ...props, autoComplete: autoComplete });
|
|
22
|
+
});
|
|
23
|
+
InputField.displayName = 'InputField';
|
|
24
|
+
export default InputField;
|
|
25
|
+
//# sourceMappingURL=Field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Field.js","sourceRoot":"","sources":["../../../src/components/Input/Field.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAM5D,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,EAAE,CAAC;AAE1F,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GAAI,CAAC;AACxG,CAAC,CAAC,CAAC;AAEH,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC;AAEtC,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type Props = {
|
|
3
|
+
label: string;
|
|
4
|
+
hasError?: boolean;
|
|
5
|
+
className?: string;
|
|
6
|
+
children: React.ReactElement;
|
|
7
|
+
};
|
|
8
|
+
export default function FloatLabel({ label, hasError, className, children }: Props): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styles from './FloatLabel.module.css';
|
|
4
|
+
export default function FloatLabel({ label, hasError, className, children }) {
|
|
5
|
+
const inputId = React.useId();
|
|
6
|
+
const wrapperClass = [styles.wrapper, className].filter(Boolean).join(' ');
|
|
7
|
+
const childElement = React.isValidElement(children) ? children : null;
|
|
8
|
+
const supportsFloatLabel = childElement &&
|
|
9
|
+
typeof childElement.type !== 'string' &&
|
|
10
|
+
Boolean(childElement.type.supportsFloatLabel);
|
|
11
|
+
const child = childElement
|
|
12
|
+
? React.cloneElement(childElement, {
|
|
13
|
+
id: childElement.props.id ?? inputId,
|
|
14
|
+
placeholder: childElement.props.placeholder ?? ' ',
|
|
15
|
+
hasError: hasError ?? childElement.props.hasError,
|
|
16
|
+
...(supportsFloatLabel ? { floatLabel: true } : null),
|
|
17
|
+
})
|
|
18
|
+
: children;
|
|
19
|
+
const htmlFor = React.isValidElement(child) ? child.props.id : undefined;
|
|
20
|
+
return (_jsxs("label", { className: wrapperClass, htmlFor: htmlFor, children: [child, _jsx("span", { className: styles.label, children: label })] }));
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=FloatLabel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FloatLabel.js","s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AAS,CAAC;IAEtG,OAAO,CACL,iBAAO,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,aAC7C,KAAK,EACN,eAAM,SAAS,EAAE,MAAM,CAAC,KAAK,YAAG,KAAK,GAAQ,IACvC,CACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
.wrapper {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: block;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.label {
|
|
7
|
+
position: absolute;
|
|
8
|
+
left: 16px;
|
|
9
|
+
top: 12px;
|
|
10
|
+
color: var(--color-muted-2);
|
|
11
|
+
font-size: 13px;
|
|
12
|
+
letter-spacing: 0.02em;
|
|
13
|
+
transition: transform 0.2s ease, color 0.2s ease, opacity 0.2s ease;
|
|
14
|
+
pointer-events: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.wrapper input:focus + .label,
|
|
18
|
+
.wrapper input:not(:placeholder-shown) + .label {
|
|
19
|
+
transform: translateY(-8px);
|
|
20
|
+
color: var(--color-teal);
|
|
21
|
+
opacity: 0.9;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.wrapper textarea:focus + .label,
|
|
25
|
+
.wrapper textarea:not(:placeholder-shown) + .label {
|
|
26
|
+
transform: translateY(-8px);
|
|
27
|
+
color: var(--color-teal);
|
|
28
|
+
opacity: 0.9;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.wrapper [data-float-label="true"][data-float-active="true"] + .label {
|
|
32
|
+
transform: translateY(-8px);
|
|
33
|
+
color: var(--color-teal);
|
|
34
|
+
opacity: 0.9;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.wrapper > input,
|
|
38
|
+
.wrapper > textarea {
|
|
39
|
+
padding-top: 22px;
|
|
40
|
+
padding-bottom: 12px;
|
|
41
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type Layout = 'column' | 'row';
|
|
3
|
+
type Align = 'start' | 'center' | 'end';
|
|
4
|
+
type LabelAlign = 'left' | 'center' | 'right';
|
|
5
|
+
type FormFieldProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
6
|
+
layout?: Layout;
|
|
7
|
+
gap?: number | string;
|
|
8
|
+
labelWidth?: number | string;
|
|
9
|
+
align?: Align;
|
|
10
|
+
labelAlign?: LabelAlign;
|
|
11
|
+
};
|
|
12
|
+
type LabelProps = React.LabelHTMLAttributes<HTMLLabelElement>;
|
|
13
|
+
type ControlProps = React.HTMLAttributes<HTMLDivElement>;
|
|
14
|
+
type ErrorProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
};
|
|
17
|
+
type FormFieldComponent = React.FC<FormFieldProps> & {
|
|
18
|
+
Label: React.FC<LabelProps>;
|
|
19
|
+
Control: React.FC<ControlProps>;
|
|
20
|
+
ErrorBag: React.FC<ErrorProps>;
|
|
21
|
+
};
|
|
22
|
+
type FormFieldContextValue = {
|
|
23
|
+
fieldId?: string;
|
|
24
|
+
fieldName?: string;
|
|
25
|
+
registerField: (id: string, name?: string) => void;
|
|
26
|
+
};
|
|
27
|
+
export declare const useFormFieldContext: () => FormFieldContextValue | null;
|
|
28
|
+
declare const FormField: FormFieldComponent;
|
|
29
|
+
export default FormField;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styles from './FormField.module.css';
|
|
4
|
+
const FormFieldContext = React.createContext(null);
|
|
5
|
+
export const useFormFieldContext = () => React.useContext(FormFieldContext);
|
|
6
|
+
const alignMap = {
|
|
7
|
+
start: 'flex-start',
|
|
8
|
+
center: 'center',
|
|
9
|
+
end: 'flex-end',
|
|
10
|
+
};
|
|
11
|
+
const labelAlignMap = {
|
|
12
|
+
left: 'left',
|
|
13
|
+
center: 'center',
|
|
14
|
+
right: 'right',
|
|
15
|
+
};
|
|
16
|
+
function FormFieldRoot({ layout = 'column', gap = '8px', labelWidth, align = 'start', labelAlign = 'left', className, style, ...props }) {
|
|
17
|
+
const [fieldId, setFieldId] = React.useState(undefined);
|
|
18
|
+
const [fieldName, setFieldName] = React.useState(undefined);
|
|
19
|
+
const registerField = React.useCallback((id, name) => {
|
|
20
|
+
setFieldId(id);
|
|
21
|
+
if (name) {
|
|
22
|
+
setFieldName(name);
|
|
23
|
+
}
|
|
24
|
+
}, []);
|
|
25
|
+
const classes = [styles.field, layout === 'row' ? styles.fieldRow : null, className]
|
|
26
|
+
.filter(Boolean)
|
|
27
|
+
.join(' ');
|
|
28
|
+
const inlineStyle = {
|
|
29
|
+
...style,
|
|
30
|
+
['--ui-field-gap']: typeof gap === 'number' ? `${gap}px` : gap,
|
|
31
|
+
['--ui-label-width']: labelWidth !== undefined ? (typeof labelWidth === 'number' ? `${labelWidth}px` : labelWidth) : undefined,
|
|
32
|
+
['--ui-field-align']: alignMap[align],
|
|
33
|
+
['--ui-label-align']: labelAlignMap[labelAlign],
|
|
34
|
+
};
|
|
35
|
+
return (_jsx(FormFieldContext.Provider, { value: { fieldId, fieldName, registerField }, children: _jsx("div", { className: classes, style: inlineStyle, ...props }) }));
|
|
36
|
+
}
|
|
37
|
+
function FormFieldLabel({ className, ...props }) {
|
|
38
|
+
const context = useFormFieldContext();
|
|
39
|
+
const classes = [styles.label, className].filter(Boolean).join(' ');
|
|
40
|
+
const htmlFor = props.htmlFor ?? context?.fieldId;
|
|
41
|
+
return _jsx("label", { className: classes, ...props, htmlFor: htmlFor });
|
|
42
|
+
}
|
|
43
|
+
function FormFieldControl({ className, ...props }) {
|
|
44
|
+
const classes = [styles.control, className].filter(Boolean).join(' ');
|
|
45
|
+
return _jsx("div", { className: classes, ...props });
|
|
46
|
+
}
|
|
47
|
+
function FormFieldError({ className, children, ...props }) {
|
|
48
|
+
if (!children) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const classes = [styles.error, className].filter(Boolean).join(' ');
|
|
52
|
+
return (_jsx("div", { className: classes, role: "alert", ...props, children: children }));
|
|
53
|
+
}
|
|
54
|
+
const FormField = Object.assign(FormFieldRoot, {
|
|
55
|
+
Label: FormFieldLabel,
|
|
56
|
+
Control: FormFieldControl,
|
|
57
|
+
ErrorBag: FormFieldError,
|
|
58
|
+
});
|
|
59
|
+
export default FormField;
|
|
60
|
+
//# sourceMappingURL=FormField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormField.js","sourceRoot":"","sources":["../../../../src/components/Input/FormField/FormField.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,wBAAwB,CAAC;AAkC5C,MAAM,gBAAgB,GAAG,KAAK,CAAC,aAAa,CAA+B,IAAI,CAAC,CAAC;AAEjF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;AAE5E,MAAM,QAAQ,GAA0B;IACtC,KAAK,EAAE,YAAY;IACnB,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,UAAU;CAChB,CAAC;AAEF,MAAM,aAAa,GAA+B;IAChD,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;CACf,CAAC;AAEF,SAAS,aAAa,CAAC,EACrB,MAAM,GAAG,QAAQ,EACjB,GAAG,GAAG,KAAK,EACX,UAAU,EACV,KAAK,GAAG,OAAO,EACf,UAAU,GAAG,MAAM,EACnB,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACO;IACf,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAqB,SAAS,CAAC,CAAC;IAC5E,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAqB,SAAS,CAAC,CAAC;IAEhF,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|
4
|
+
gap: var(--ui-field-gap, 8px);
|
|
5
|
+
width: 100%;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.fieldRow {
|
|
9
|
+
flex-direction: row;
|
|
10
|
+
align-items: var(--ui-field-align, flex-start);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.label {
|
|
14
|
+
color: var(--color-muted);
|
|
15
|
+
font-size: 13px;
|
|
16
|
+
line-height: 1.4;
|
|
17
|
+
min-width: var(--ui-label-width, 120px);
|
|
18
|
+
text-align: var(--ui-label-align, left);
|
|
19
|
+
padding-top: 6px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.control {
|
|
23
|
+
flex: 1;
|
|
24
|
+
min-width: 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.error {
|
|
28
|
+
font-size: 12px;
|
|
29
|
+
color: var(--badge-danger-color, #ff6b6b);
|
|
30
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import Textarea from './Textarea/Textarea';
|
|
2
|
+
import Select from './Select/Select';
|
|
3
|
+
import FloatLabel from './FloatLabel/FloatLabel';
|
|
4
|
+
import { InputGroup, InputAddon } from './InputGroup';
|
|
5
|
+
import MaskedInput from './MaskedInput';
|
|
6
|
+
import NumberInput from './NumberInput';
|
|
7
|
+
import DatePicker from './DatePicker';
|
|
8
|
+
import TimePicker from './TimePicker';
|
|
9
|
+
import DateRangePicker from './DateRangePicker';
|
|
10
|
+
import Radio from './Radio/Radio';
|
|
11
|
+
import Switch from './Switch/Switch';
|
|
12
|
+
declare const Input: import("react").FC<import("react").HTMLAttributes<HTMLDivElement> & {
|
|
13
|
+
layout?: "row" | "column";
|
|
14
|
+
gap?: number | string;
|
|
15
|
+
labelWidth?: number | string;
|
|
16
|
+
align?: "start" | "center" | "end";
|
|
17
|
+
labelAlign?: "right" | "center" | "left";
|
|
18
|
+
}> & {
|
|
19
|
+
Label: React.FC<import("react").LabelHTMLAttributes<HTMLLabelElement>>;
|
|
20
|
+
Control: React.FC<import("react").HTMLAttributes<HTMLDivElement>>;
|
|
21
|
+
ErrorBag: React.FC<import("react").HTMLAttributes<HTMLDivElement> & {
|
|
22
|
+
children?: React.ReactNode;
|
|
23
|
+
}>;
|
|
24
|
+
} & {
|
|
25
|
+
Label: import("react").FC<import("react").LabelHTMLAttributes<HTMLLabelElement>>;
|
|
26
|
+
Control: import("react").FC<import("react").HTMLAttributes<HTMLDivElement>>;
|
|
27
|
+
ErrorBag: import("react").FC<import("react").HTMLAttributes<HTMLDivElement> & {
|
|
28
|
+
children?: React.ReactNode;
|
|
29
|
+
}>;
|
|
30
|
+
Field: import("react").ForwardRefExoticComponent<import("react").InputHTMLAttributes<HTMLInputElement> & {
|
|
31
|
+
hasError?: boolean;
|
|
32
|
+
} & import("react").RefAttributes<HTMLInputElement>>;
|
|
33
|
+
TextArea: typeof Textarea;
|
|
34
|
+
Select: typeof Select;
|
|
35
|
+
FloatLabel: typeof FloatLabel;
|
|
36
|
+
Group: typeof InputGroup;
|
|
37
|
+
Addon: typeof InputAddon;
|
|
38
|
+
MaskedInput: typeof MaskedInput;
|
|
39
|
+
Number: typeof NumberInput;
|
|
40
|
+
DatePicker: typeof DatePicker;
|
|
41
|
+
TimePicker: typeof TimePicker;
|
|
42
|
+
DateRange: typeof DateRangePicker;
|
|
43
|
+
Radio: typeof Radio;
|
|
44
|
+
Switch: typeof Switch;
|
|
45
|
+
FormField: import("react").FC<import("react").HTMLAttributes<HTMLDivElement> & {
|
|
46
|
+
layout?: "row" | "column";
|
|
47
|
+
gap?: number | string;
|
|
48
|
+
labelWidth?: number | string;
|
|
49
|
+
align?: "start" | "center" | "end";
|
|
50
|
+
labelAlign?: "right" | "center" | "left";
|
|
51
|
+
}> & {
|
|
52
|
+
Label: React.FC<import("react").LabelHTMLAttributes<HTMLLabelElement>>;
|
|
53
|
+
Control: React.FC<import("react").HTMLAttributes<HTMLDivElement>>;
|
|
54
|
+
ErrorBag: React.FC<import("react").HTMLAttributes<HTMLDivElement> & {
|
|
55
|
+
children?: React.ReactNode;
|
|
56
|
+
}>;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export default Input;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import FormField from './FormField/FormField';
|
|
2
|
+
import InputField from './Field';
|
|
3
|
+
import Textarea from './Textarea/Textarea';
|
|
4
|
+
import Select from './Select/Select';
|
|
5
|
+
import FloatLabel from './FloatLabel/FloatLabel';
|
|
6
|
+
import { InputGroup, InputAddon } from './InputGroup';
|
|
7
|
+
import MaskedInput from './MaskedInput';
|
|
8
|
+
import NumberInput from './NumberInput';
|
|
9
|
+
import DatePicker from './DatePicker';
|
|
10
|
+
import TimePicker from './TimePicker';
|
|
11
|
+
import DateRangePicker from './DateRangePicker';
|
|
12
|
+
import Radio from './Radio/Radio';
|
|
13
|
+
import Switch from './Switch/Switch';
|
|
14
|
+
const Input = Object.assign(FormField, {
|
|
15
|
+
Label: FormField.Label,
|
|
16
|
+
Control: FormField.Control,
|
|
17
|
+
ErrorBag: FormField.ErrorBag,
|
|
18
|
+
Field: InputField,
|
|
19
|
+
TextArea: Textarea,
|
|
20
|
+
Select,
|
|
21
|
+
FloatLabel,
|
|
22
|
+
Group: InputGroup,
|
|
23
|
+
Addon: InputAddon,
|
|
24
|
+
MaskedInput,
|
|
25
|
+
Number: NumberInput,
|
|
26
|
+
DatePicker,
|
|
27
|
+
TimePicker,
|
|
28
|
+
DateRange: DateRangePicker,
|
|
29
|
+
Radio,
|
|
30
|
+
Switch,
|
|
31
|
+
FormField,
|
|
32
|
+
});
|
|
33
|
+
export default Input;
|
|
34
|
+
//# sourceMappingURL=Input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../src/components/Input/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,uBAAuB,CAAC;AAC9C,OAAO,UAAU,MAAM,SAAS,CAAC;AACjC,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAC3C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,MAAM,eAAe,CAAC;AAClC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE;IACrC,KAAK,EAAE,SAAS,CAAC,KAAK;IACtB,OAAO,EAAE,SAAS,CAAC,OAAO;IAC1B,QAAQ,EAAE,SAAS,CAAC,QAAQ;IAC5B,KAAK,EAAE,UAAU;IACjB,QAAQ,EAAE,QAAQ;IAClB,MAAM;IACN,UAAU;IACV,KAAK,EAAE,UAAU;IACjB,KAAK,EAAE,UAAU;IACjB,WAAW;IACX,MAAM,EAAE,WAAW;IACnB,UAAU;IACV,UAAU;IACV,SAAS,EAAE,eAAe;IAC1B,KAAK;IACL,MAAM;IACN,SAAS;CACV,CAAC,CAAC;AAEH,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
.input {
|
|
2
|
+
width: 100%;
|
|
3
|
+
padding: 16px 16px;
|
|
4
|
+
border-radius: var(--radius-sm);
|
|
5
|
+
border: 1px solid rgba(30, 99, 233, 0.25);
|
|
6
|
+
background: var(--surface-input);
|
|
7
|
+
color: var(--color-text);
|
|
8
|
+
transition: border-color 0.2s ease, box-shadow 0.2s ease;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.input:focus {
|
|
12
|
+
outline: none;
|
|
13
|
+
border-color: rgba(20, 201, 214, 0.8);
|
|
14
|
+
box-shadow: 0 0 0 3px rgba(20, 201, 214, 0.2);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.input::placeholder {
|
|
18
|
+
color: var(--color-muted-2);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.input:disabled {
|
|
22
|
+
background: var(--surface-input-disabled);
|
|
23
|
+
color: var(--color-muted-2);
|
|
24
|
+
border-color: rgba(30, 51, 85, 0.5);
|
|
25
|
+
cursor: not-allowed;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.error {
|
|
29
|
+
border-color: rgba(255, 94, 126, 0.8);
|
|
30
|
+
box-shadow: 0 0 0 3px rgba(255, 94, 126, 0.2);
|
|
31
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './InputGroup.module.css';
|
|
3
|
+
type GroupProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
4
|
+
stretch?: boolean;
|
|
5
|
+
};
|
|
6
|
+
type AddonProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
7
|
+
as?: React.ElementType;
|
|
8
|
+
};
|
|
9
|
+
export declare function InputGroup({ stretch, className, children, ...props }: GroupProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function InputAddon({ as, className, ...props }: AddonProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import './InputGroup.module.css';
|
|
4
|
+
const GROUP_CLASS = 'rsb-input-group';
|
|
5
|
+
const GROUP_STRETCH_CLASS = 'rsb-input-group--stretch';
|
|
6
|
+
const ITEM_CLASS = 'rsb-group-item';
|
|
7
|
+
const ADDON_CLASS = 'rsb-input-addon';
|
|
8
|
+
export function InputGroup({ stretch = false, className, children, ...props }) {
|
|
9
|
+
const classes = [GROUP_CLASS, stretch ? GROUP_STRETCH_CLASS : null, className].filter(Boolean).join(' ');
|
|
10
|
+
const items = React.Children.map(children, (child) => {
|
|
11
|
+
if (!React.isValidElement(child)) {
|
|
12
|
+
return child;
|
|
13
|
+
}
|
|
14
|
+
const element = child;
|
|
15
|
+
const childClassName = [element.props.className, ITEM_CLASS].filter(Boolean).join(' ');
|
|
16
|
+
return React.cloneElement(element, { className: childClassName });
|
|
17
|
+
});
|
|
18
|
+
return (_jsx("div", { className: classes, ...props, children: items }));
|
|
19
|
+
}
|
|
20
|
+
export function InputAddon({ as = 'div', className, ...props }) {
|
|
21
|
+
const Component = as;
|
|
22
|
+
const classes = [ADDON_CLASS, ITEM_CLASS, className].filter(Boolean).join(' ');
|
|
23
|
+
return _jsx(Component, { className: classes, ...props });
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=InputGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InputGroup.js","sourceRoot":"","sources":["../../../src/components/Input/InputGroup.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,yBAAyB,CAAC;AAEjC,MAAM,WAAW,GAAG,iBAAiB,CAAC;AACtC,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AACvD,MAAM,UAAU,GAAG,gBAAgB,CAAC;AACpC,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAUtC,MAAM,UAAU,UAAU,CAAC,EAAE,OAAO,GAAG,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAc;IACvF,MAAM,OAAO,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEzG,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;QACnD,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;YACjC,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,OAAO,GAAG,KAAmD,CAAC;QACpE,MAAM,cAAc,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACvF,OAAO,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IAEH,OAAO,CACL,cAAK,SAAS,EAAE,OAAO,KAAM,KAAK,YAC/B,KAAK,GACF,CACP,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,EAAE,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,GAAG,KAAK,EAAc;IACxE,MAAM,SAAS,GAAG,EAAuB,CAAC;IAC1C,MAAM,OAAO,GAAG,CAAC,WAAW,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/E,OAAO,KAAC,SAAS,IAAC,SAAS,EAAE,OAAO,KAAM,KAAK,GAAI,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
:global(.rsb-input-group) {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: stretch;
|
|
4
|
+
gap: 0;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
:global(.rsb-input-group--stretch) > :global(.rsb-group-item) {
|
|
8
|
+
flex: 1;
|
|
9
|
+
min-width: 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
:global(.rsb-input-group) > :global(.rsb-group-item) {
|
|
13
|
+
border-radius: 0 !important;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
:global(.rsb-input-group) > :global(.rsb-group-item):first-child {
|
|
17
|
+
border-top-left-radius: var(--radius-sm) !important;
|
|
18
|
+
border-bottom-left-radius: var(--radius-sm) !important;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
:global(.rsb-input-group) > :global(.rsb-group-item):last-child {
|
|
22
|
+
border-top-right-radius: var(--radius-sm) !important;
|
|
23
|
+
border-bottom-right-radius: var(--radius-sm) !important;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
:global(.rsb-input-group) > :global(.rsb-group-item) + :global(.rsb-group-item) {
|
|
27
|
+
margin-left: -1px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
:global(.rsb-input-addon) {
|
|
31
|
+
display: inline-flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
padding: 0 12px;
|
|
34
|
+
border: 1px solid rgba(30, 99, 233, 0.25);
|
|
35
|
+
background: var(--surface-input);
|
|
36
|
+
color: var(--color-muted);
|
|
37
|
+
white-space: nowrap;
|
|
38
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type Props = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange' | 'type'> & {
|
|
3
|
+
mask: string;
|
|
4
|
+
value?: string;
|
|
5
|
+
onChange?: (value: string) => void;
|
|
6
|
+
placeholderChar?: string;
|
|
7
|
+
};
|
|
8
|
+
export default function MaskedInput({ mask, value, onChange, placeholderChar, ...props }: Props): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import InputField from './Field';
|
|
4
|
+
const isDigit = (char) => /\d/.test(char);
|
|
5
|
+
const isLetter = (char) => /[a-zA-Z]/.test(char);
|
|
6
|
+
const isAlphaNum = (char) => /[a-zA-Z0-9]/.test(char);
|
|
7
|
+
const stripRaw = (value) => value.replace(/[^a-zA-Z0-9]/g, '');
|
|
8
|
+
const applyMask = (raw, mask, placeholderChar) => {
|
|
9
|
+
let rawIndex = 0;
|
|
10
|
+
let output = '';
|
|
11
|
+
for (let i = 0; i < mask.length; i += 1) {
|
|
12
|
+
const maskChar = mask[i];
|
|
13
|
+
const rawChar = raw[rawIndex];
|
|
14
|
+
if (maskChar === '9' || maskChar === 'A' || maskChar === '*') {
|
|
15
|
+
if (!rawChar) {
|
|
16
|
+
if (placeholderChar) {
|
|
17
|
+
output += placeholderChar;
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
const matches = (maskChar === '9' && isDigit(rawChar)) ||
|
|
23
|
+
(maskChar === 'A' && isLetter(rawChar)) ||
|
|
24
|
+
(maskChar === '*' && isAlphaNum(rawChar));
|
|
25
|
+
if (matches) {
|
|
26
|
+
output += rawChar;
|
|
27
|
+
rawIndex += 1;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
rawIndex += 1;
|
|
31
|
+
i -= 1;
|
|
32
|
+
}
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
output += maskChar;
|
|
36
|
+
}
|
|
37
|
+
return output;
|
|
38
|
+
};
|
|
39
|
+
const extractRaw = (masked, mask) => {
|
|
40
|
+
let raw = '';
|
|
41
|
+
let maskIndex = 0;
|
|
42
|
+
for (let i = 0; i < masked.length && maskIndex < mask.length; i += 1) {
|
|
43
|
+
const maskChar = mask[maskIndex];
|
|
44
|
+
const char = masked[i];
|
|
45
|
+
if (maskChar === '9' || maskChar === 'A' || maskChar === '*') {
|
|
46
|
+
const matches = (maskChar === '9' && isDigit(char)) ||
|
|
47
|
+
(maskChar === 'A' && isLetter(char)) ||
|
|
48
|
+
(maskChar === '*' && isAlphaNum(char));
|
|
49
|
+
if (matches) {
|
|
50
|
+
raw += char;
|
|
51
|
+
maskIndex += 1;
|
|
52
|
+
}
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (char === maskChar) {
|
|
56
|
+
maskIndex += 1;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
maskIndex += 1;
|
|
60
|
+
i -= 1;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return raw;
|
|
64
|
+
};
|
|
65
|
+
export default function MaskedInput({ mask, value, onChange, placeholderChar, ...props }) {
|
|
66
|
+
const isControlled = value !== undefined;
|
|
67
|
+
const [internal, setInternal] = React.useState('');
|
|
68
|
+
const displayValue = React.useMemo(() => {
|
|
69
|
+
const raw = stripRaw(String(isControlled ? value ?? '' : internal));
|
|
70
|
+
return applyMask(raw, mask, placeholderChar);
|
|
71
|
+
}, [value, internal, mask, placeholderChar, isControlled]);
|
|
72
|
+
const handleChange = (event) => {
|
|
73
|
+
const rawInput = event.target.value;
|
|
74
|
+
const raw = extractRaw(rawInput, mask);
|
|
75
|
+
if (!isControlled) {
|
|
76
|
+
setInternal(raw);
|
|
77
|
+
}
|
|
78
|
+
onChange?.(raw);
|
|
79
|
+
};
|
|
80
|
+
return _jsx(InputField, { ...props, value: displayValue, onChange: handleChange });
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=MaskedInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaskedInput.js","sourceRoot":"","sources":["../../../src/components/Input/MaskedInput.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,UAAU,MAAM,SAAS,CAAC;AASjC,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAClD,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzD,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAE9D,MAAM,QAAQ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AAQ,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEnD,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACtC,MAAM,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;QACpE,OAAO,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC;IAC/C,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAE,YAAY,CAAC,CAAC,CAAC;IAE3D,MAAM,YAAY,GAAG,CAAC,KAA0C,EAAE,EAAE;QAClE,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;QACpC,MAAM,GAAG,GAAG,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAEvC,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;QAED,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;IAClB,CAAC,CAAC;IAEF,OAAO,KAAC,UAAU,OAAK,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,GAAI,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type Props = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange' | 'type'> & {
|
|
3
|
+
value?: string | number;
|
|
4
|
+
onChange?: (value: string) => void;
|
|
5
|
+
allowNegative?: boolean;
|
|
6
|
+
decimalSeparator?: '.' | ',';
|
|
7
|
+
decimalScale?: number;
|
|
8
|
+
};
|
|
9
|
+
export default function NumberInput({ value, onChange, allowNegative, decimalSeparator, decimalScale, ...props }: Props): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|