@synerise/ds-subtle-form 1.1.57 → 1.1.59
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/CHANGELOG.md +8 -0
- package/README.md +69 -2
- package/dist/Elements/DatePicker/DatePicker.d.ts +2 -2
- package/dist/Elements/DatePicker/DatePicker.js +64 -95
- package/dist/Elements/DatePicker/DatePicker.styles.d.ts +2 -2
- package/dist/Elements/DatePicker/DatePicker.styles.js +9 -11
- package/dist/Elements/DatePicker/DatePicker.types.d.ts +3 -3
- package/dist/Elements/DatePicker/DatePicker.types.js +1 -1
- package/dist/Elements/DatePicker/utils.js +9 -5
- package/dist/Elements/Field/Field.d.ts +2 -2
- package/dist/Elements/Field/Field.js +41 -65
- package/dist/Elements/Input/Input.d.ts +2 -2
- package/dist/Elements/Input/Input.js +44 -73
- package/dist/Elements/Input/Input.types.d.ts +2 -2
- package/dist/Elements/Input/Input.types.js +1 -1
- package/dist/Elements/Select/Select.d.ts +2 -2
- package/dist/Elements/Select/Select.js +40 -77
- package/dist/Elements/Select/Select.styles.d.ts +1 -1
- package/dist/Elements/Select/Select.styles.js +6 -5
- package/dist/Elements/Select/Select.types.d.ts +2 -2
- package/dist/Elements/Select/Select.types.js +1 -1
- package/dist/Elements/TextArea/TextArea.d.ts +2 -2
- package/dist/Elements/TextArea/TextArea.js +68 -108
- package/dist/Elements/TextArea/TextArea.types.d.ts +2 -2
- package/dist/Elements/TextArea/TextArea.types.js +1 -1
- package/dist/SubtleForm.d.ts +5 -5
- package/dist/SubtleForm.js +9 -7
- package/dist/SubtleForm.styles.d.ts +8 -8
- package/dist/SubtleForm.styles.js +34 -51
- package/dist/SubtleForm.types.d.ts +2 -2
- package/dist/SubtleForm.types.js +1 -1
- package/dist/index.js +4 -1
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.1.59](https://github.com/Synerise/synerise-design/compare/@synerise/ds-subtle-form@1.1.58...@synerise/ds-subtle-form@1.1.59) (2026-03-24)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-subtle-form
|
|
9
|
+
|
|
10
|
+
## [1.1.58](https://github.com/Synerise/synerise-design/compare/@synerise/ds-subtle-form@1.1.57...@synerise/ds-subtle-form@1.1.58) (2026-03-20)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @synerise/ds-subtle-form
|
|
13
|
+
|
|
6
14
|
## [1.1.57](https://github.com/Synerise/synerise-design/compare/@synerise/ds-subtle-form@1.1.56...@synerise/ds-subtle-form@1.1.57) (2026-03-09)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @synerise/ds-subtle-form
|
package/README.md
CHANGED
|
@@ -46,10 +46,77 @@ const [value, setValue] = React.useState('');
|
|
|
46
46
|
| disabled | Disables hover effects and value editing | boolean | false |
|
|
47
47
|
| label | Label text displayed above the textarea | string / React.ReactNode | --- |
|
|
48
48
|
| labelTooltip | Tooltip displayed on label hover | string / React.ReactNode | --- |
|
|
49
|
-
| maxRows | Maximum rows to be displayed | number |
|
|
49
|
+
| maxRows | Maximum rows to be displayed | number | - |
|
|
50
50
|
| minRows | Minimum rows to be displayed | number | 1 |
|
|
51
51
|
| onChange | Callback execute after input change | (value: string) => void | --- |
|
|
52
52
|
| value | Value displayed in the input | string | --- |
|
|
53
53
|
| placeholder | Placeholder displayed in the input | string | --- |
|
|
54
54
|
| suffix | Suffix element rendered on the right-hand side | React.ReactNode | --- |
|
|
55
|
-
| suffixTooltip | Suffix tooltip
|
|
55
|
+
| suffixTooltip | Suffix tooltip displayed on hover | React.ReactNode | --- |
|
|
56
|
+
| error | Error state; forces the textarea into edit mode | boolean | --- |
|
|
57
|
+
| errorText | Error message displayed below the field | React.ReactNode | --- |
|
|
58
|
+
| textAreaProps | Props forwarded to the underlying TextArea | TextAreaProps | --- |
|
|
59
|
+
|
|
60
|
+
### Input
|
|
61
|
+
|
|
62
|
+
| Property | Description | Type | Default |
|
|
63
|
+
| ------------- | ---------------------------------------------- | ------------------------ | ------- |
|
|
64
|
+
| disabled | Disables hover effects and value editing | boolean | false |
|
|
65
|
+
| label | Label text displayed above the input | string / React.ReactNode | --- |
|
|
66
|
+
| labelTooltip | Tooltip displayed on label hover | string / React.ReactNode | --- |
|
|
67
|
+
| value | Value displayed in the input | string | --- |
|
|
68
|
+
| onChange | Callback executed after input change | (value: string) => void | --- |
|
|
69
|
+
| placeholder | Placeholder displayed in the input | string | --- |
|
|
70
|
+
| suffix | Suffix element rendered on the right-hand side | React.ReactNode | --- |
|
|
71
|
+
| suffixTooltip | Suffix tooltip displayed on hover | React.ReactNode | --- |
|
|
72
|
+
| error | Error state; forces the input into edit mode | boolean | --- |
|
|
73
|
+
| errorText | Error message displayed below the field | React.ReactNode | --- |
|
|
74
|
+
| inputProps | Props forwarded to the underlying Input | InputProps | --- |
|
|
75
|
+
|
|
76
|
+
### Select
|
|
77
|
+
|
|
78
|
+
| Property | Description | Type | Default |
|
|
79
|
+
| ------------- | ---------------------------------------------- | ------------------------ | ------- |
|
|
80
|
+
| disabled | Disables hover effects and value editing | boolean | false |
|
|
81
|
+
| label | Label text displayed above the select | string / React.ReactNode | --- |
|
|
82
|
+
| labelTooltip | Tooltip displayed on label hover | string / React.ReactNode | --- |
|
|
83
|
+
| value | Selected value | SelectValue | --- |
|
|
84
|
+
| placeholder | Placeholder displayed when no value | string | --- |
|
|
85
|
+
| suffix | Suffix element rendered on the right-hand side | React.ReactNode | --- |
|
|
86
|
+
| suffixTooltip | Suffix tooltip displayed on hover | React.ReactNode | --- |
|
|
87
|
+
| error | Error state; forces the select into edit mode | boolean | --- |
|
|
88
|
+
| errorText | Error message displayed below the field | React.ReactNode | --- |
|
|
89
|
+
| children | `Select.Option` children | React.ReactNode | --- |
|
|
90
|
+
|
|
91
|
+
### DatePicker
|
|
92
|
+
|
|
93
|
+
| Property | Description | Type | Default |
|
|
94
|
+
| ----------------------- | -------------------------------------------------- | ------------------------ | ---------------- |
|
|
95
|
+
| disabled | Disables hover effects and value editing | boolean | false |
|
|
96
|
+
| label | Label text displayed above the date picker | string / React.ReactNode | --- |
|
|
97
|
+
| labelTooltip | Tooltip displayed on label hover | string / React.ReactNode | --- |
|
|
98
|
+
| value | Selected date | Date | --- |
|
|
99
|
+
| onApply | Called when date is confirmed; also deactivates | (date: Date) => void | --- |
|
|
100
|
+
| onClear | Called when cleared; also deactivates | () => void | --- |
|
|
101
|
+
| format | Date format string | string | `'dd-MM-yyyy'` |
|
|
102
|
+
| placeholder | Placeholder displayed when no value | string | --- |
|
|
103
|
+
| suffix | Suffix element rendered on the right-hand side | React.ReactNode | --- |
|
|
104
|
+
| suffixTooltip | Suffix tooltip displayed on hover | React.ReactNode | --- |
|
|
105
|
+
| error | Error state; forces the picker into display mode | boolean | --- |
|
|
106
|
+
| errorText | Error message displayed below the field | React.ReactNode | --- |
|
|
107
|
+
|
|
108
|
+
### Field
|
|
109
|
+
|
|
110
|
+
| Property | Description | Type | Default |
|
|
111
|
+
| -------------- | ---------------------------------------------------- | ------------------------ | ------- |
|
|
112
|
+
| disabled | Disables hover effects and interactions | boolean | false |
|
|
113
|
+
| label | Label text displayed above the field | string / React.ReactNode | --- |
|
|
114
|
+
| labelTooltip | Tooltip displayed on label hover | string / React.ReactNode | --- |
|
|
115
|
+
| active | Controlled active (edit) state | boolean | --- |
|
|
116
|
+
| activeElement | Render function for the edit state | () => ReactElement | --- |
|
|
117
|
+
| inactiveElement| Render function for the display state | () => ReactElement | --- |
|
|
118
|
+
| suffix | Suffix element rendered on the right-hand side | React.ReactNode | --- |
|
|
119
|
+
| suffixTooltip | Suffix tooltip displayed on hover | React.ReactNode | --- |
|
|
120
|
+
| errorText | Error message; forces the field into edit mode | React.ReactNode | --- |
|
|
121
|
+
| mask | Mask string shown below inactive content | string | --- |
|
|
122
|
+
| maskVisible | Whether to show the mask | boolean | --- |
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { SubtleDatePickerProps } from './DatePicker.types';
|
|
3
3
|
declare const SubtleDatePicker: {
|
|
4
4
|
({ value, suffix, suffixTooltip, format: dateFormat, label, children, labelTooltip, placeholder, onApply, onClear, errorText, error, activeProp, onDropdownVisibleChange, disabled, ...rest }: SubtleDatePickerProps): React.JSX.Element;
|
|
5
5
|
displayName: string;
|
|
@@ -1,113 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var showTime = rest.showTime;
|
|
40
|
-
var dateFormattingString = useMemo(function () {
|
|
41
|
-
return getFormattingString(dateFormat, showTime);
|
|
42
|
-
}, [dateFormat, showTime]);
|
|
43
|
-
var formatValue = useCallback(function (val) {
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useMemo, useCallback, useEffect } from "react";
|
|
3
|
+
import { useTheme } from "@synerise/ds-core";
|
|
4
|
+
import DatePicker from "@synerise/ds-date-picker";
|
|
5
|
+
import format from "@synerise/ds-date-picker/dist/format";
|
|
6
|
+
import Icon, { CalendarM } from "@synerise/ds-icon";
|
|
7
|
+
import Tooltip from "@synerise/ds-tooltip";
|
|
8
|
+
import { Subtle, SubtleFormField, Inactive, MainContent, Suffix } from "../../SubtleForm.styles.js";
|
|
9
|
+
import { SelectContainer, MaskedDatePlaceholder } from "./DatePicker.styles.js";
|
|
10
|
+
import { getFormattingString, replaceLettersWithUnderscore } from "./utils.js";
|
|
11
|
+
const SubtleDatePicker = ({
|
|
12
|
+
value,
|
|
13
|
+
suffix,
|
|
14
|
+
suffixTooltip,
|
|
15
|
+
format: dateFormat,
|
|
16
|
+
label,
|
|
17
|
+
children,
|
|
18
|
+
labelTooltip,
|
|
19
|
+
placeholder,
|
|
20
|
+
onApply,
|
|
21
|
+
onClear,
|
|
22
|
+
errorText,
|
|
23
|
+
error,
|
|
24
|
+
activeProp,
|
|
25
|
+
onDropdownVisibleChange,
|
|
26
|
+
disabled,
|
|
27
|
+
...rest
|
|
28
|
+
}) => {
|
|
29
|
+
const [active, setActive] = useState(false);
|
|
30
|
+
const [blurred, setBlurred] = useState(false);
|
|
31
|
+
const containerRef = useRef(null);
|
|
32
|
+
const theme = useTheme();
|
|
33
|
+
const hasError = error || !!errorText;
|
|
34
|
+
const {
|
|
35
|
+
showTime
|
|
36
|
+
} = rest;
|
|
37
|
+
const dateFormattingString = useMemo(() => getFormattingString(dateFormat, showTime), [dateFormat, showTime]);
|
|
38
|
+
const formatValue = useCallback((val) => {
|
|
44
39
|
if (!val) {
|
|
45
|
-
return
|
|
40
|
+
return "";
|
|
46
41
|
}
|
|
47
42
|
return format(val, dateFormattingString);
|
|
48
43
|
}, [dateFormattingString]);
|
|
49
|
-
|
|
44
|
+
const getDisplayText = useCallback(() => {
|
|
50
45
|
return value && !!String(value).trim() ? formatValue(value) : placeholder;
|
|
51
46
|
}, [value, placeholder, formatValue]);
|
|
52
|
-
useEffect(
|
|
47
|
+
useEffect(() => {
|
|
53
48
|
if (error) {
|
|
54
49
|
setActive(false);
|
|
55
50
|
setBlurred(true);
|
|
56
51
|
}
|
|
57
52
|
}, [error, errorText]);
|
|
58
|
-
|
|
53
|
+
const handleActivate = useCallback(() => {
|
|
59
54
|
setActive(true);
|
|
60
55
|
setBlurred(false);
|
|
61
56
|
}, []);
|
|
62
|
-
|
|
57
|
+
const handleDeactivate = useCallback(() => {
|
|
63
58
|
setActive(false);
|
|
64
59
|
setBlurred(true);
|
|
65
60
|
}, []);
|
|
66
|
-
return
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
error: error,
|
|
88
|
-
errorText: errorText,
|
|
89
|
-
autoFocus: !hasError,
|
|
90
|
-
format: dateFormat,
|
|
91
|
-
onDropdownVisibleChange: function onDropdownVisibleChange(visible) {
|
|
92
|
-
setActive(visible);
|
|
93
|
-
setBlurred(!visible);
|
|
94
|
-
_onDropdownVisibleChange && _onDropdownVisibleChange(visible);
|
|
95
|
-
}
|
|
96
|
-
})) : /*#__PURE__*/React.createElement(S.Inactive, {
|
|
97
|
-
disabled: disabled,
|
|
98
|
-
onClick: !disabled ? handleActivate : undefined,
|
|
99
|
-
blurred: blurred,
|
|
100
|
-
mask: !value
|
|
101
|
-
}, /*#__PURE__*/React.createElement(S.MainContent, {
|
|
102
|
-
hasMargin: true
|
|
103
|
-
}, getDisplayText(), !disabled && /*#__PURE__*/React.createElement(MaskedDatePlaceholder, null, replaceLettersWithUnderscore(dateFormattingString))), !active && /*#__PURE__*/React.createElement(S.Suffix, {
|
|
104
|
-
select: true
|
|
105
|
-
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
106
|
-
title: suffixTooltip
|
|
107
|
-
}, suffix != null ? suffix : /*#__PURE__*/React.createElement(Icon, {
|
|
108
|
-
component: /*#__PURE__*/React.createElement(CalendarM, null),
|
|
109
|
-
color: theme.palette['grey-600']
|
|
110
|
-
})))))));
|
|
61
|
+
return /* @__PURE__ */ jsx(Subtle, { className: "ds-subtle-form", children: /* @__PURE__ */ jsx(SubtleFormField, { active: active || hasError, label, tooltip: labelTooltip, children: /* @__PURE__ */ jsx(SelectContainer, { disabled: !!disabled, ref: containerRef, className: "ds-subtle-date-picker", active: active || hasError, children: active && !blurred || hasError ? /* @__PURE__ */ jsx(DatePicker, { ...rest, value, onApply: (date) => {
|
|
62
|
+
handleDeactivate();
|
|
63
|
+
onApply && onApply(date);
|
|
64
|
+
}, onClear: !disabled ? () => {
|
|
65
|
+
handleDeactivate();
|
|
66
|
+
onClear && onClear();
|
|
67
|
+
} : void 0, error, errorText, autoFocus: !hasError, format: dateFormat, onDropdownVisibleChange: (visible) => {
|
|
68
|
+
setActive(visible);
|
|
69
|
+
setBlurred(!visible);
|
|
70
|
+
onDropdownVisibleChange && onDropdownVisibleChange(visible);
|
|
71
|
+
} }) : /* @__PURE__ */ jsxs(Inactive, { disabled, onClick: !disabled ? handleActivate : void 0, blurred, mask: !value, children: [
|
|
72
|
+
/* @__PURE__ */ jsxs(MainContent, { hasMargin: true, children: [
|
|
73
|
+
getDisplayText(),
|
|
74
|
+
!disabled && /* @__PURE__ */ jsx(MaskedDatePlaceholder, { children: replaceLettersWithUnderscore(dateFormattingString) })
|
|
75
|
+
] }),
|
|
76
|
+
!active && /* @__PURE__ */ jsx(Suffix, { select: true, children: /* @__PURE__ */ jsx(Tooltip, { title: suffixTooltip, children: suffix ?? /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(CalendarM, {}), color: theme.palette["grey-600"] }) }) })
|
|
77
|
+
] }) }) }) });
|
|
78
|
+
};
|
|
79
|
+
SubtleDatePicker.displayName = "SubtleDatePicker";
|
|
80
|
+
export {
|
|
81
|
+
SubtleDatePicker as default
|
|
111
82
|
};
|
|
112
|
-
SubtleDatePicker.displayName = 'SubtleDatePicker';
|
|
113
|
-
export default SubtleDatePicker;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export declare const SelectContainer: import(
|
|
1
|
+
export declare const SelectContainer: import('styled-components').StyledComponent<"div", any, {
|
|
2
2
|
active: boolean;
|
|
3
3
|
disabled: boolean;
|
|
4
4
|
}, never>;
|
|
5
|
-
export declare const MaskedDatePlaceholder: import(
|
|
5
|
+
export declare const MaskedDatePlaceholder: import('styled-components').StyledComponent<"div", any, {
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
}, never>;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import styled, { css } from
|
|
2
|
-
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
const SelectContainer = /* @__PURE__ */ styled.div.withConfig({
|
|
3
3
|
displayName: "DatePickerstyles__SelectContainer",
|
|
4
4
|
componentId: "sc-xiwxgz-0"
|
|
5
|
-
})(["position:relative;min-height:32px;width:100%;", " > div{margin:0;}", ""],
|
|
6
|
-
|
|
7
|
-
}, function (props) {
|
|
8
|
-
return !!props.disabled && css(["&&{cursor:not-allowed;}"]);
|
|
9
|
-
});
|
|
10
|
-
export var MaskedDatePlaceholder = styled.div.withConfig({
|
|
5
|
+
})(["position:relative;min-height:32px;width:100%;", " > div{margin:0;}", ""], (props) => props.active && css(["margin:-2px 0 0 -1px;"]), (props) => !!props.disabled && css(["&&{cursor:not-allowed;}"]));
|
|
6
|
+
const MaskedDatePlaceholder = /* @__PURE__ */ styled.div.withConfig({
|
|
11
7
|
displayName: "DatePickerstyles__MaskedDatePlaceholder",
|
|
12
8
|
componentId: "sc-xiwxgz-1"
|
|
13
|
-
})(["font-size:13px;color:transparent;position:absolute;left:0;top:8px;transition:", ";"],
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
})(["font-size:13px;color:transparent;position:absolute;left:0;top:8px;transition:", ";"], (props) => props.disabled ? "none" : "left 0.1s ease-in 0.2s, color 0.1s ease-in 0.2s");
|
|
10
|
+
export {
|
|
11
|
+
MaskedDatePlaceholder,
|
|
12
|
+
SelectContainer
|
|
13
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { DatePickerProps as DsDatePickerProps } from '@synerise/ds-date-picker';
|
|
3
|
+
import { SubtleFieldProps } from '../../SubtleForm.types';
|
|
4
4
|
export type SubtleDatePickerProps = {
|
|
5
5
|
activeProp?: boolean;
|
|
6
6
|
placeholder?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
return input.replace(/[a-zA-Z]/g,
|
|
1
|
+
const replaceLettersWithUnderscore = (input) => {
|
|
2
|
+
return input.replace(/[a-zA-Z]/g, "_ ");
|
|
3
3
|
};
|
|
4
|
-
|
|
4
|
+
const getFormattingString = (formatProp, showTime) => {
|
|
5
5
|
if (!formatProp) {
|
|
6
|
-
return showTime ?
|
|
6
|
+
return showTime ? "dd-MM-yyyy, HH:mm" : "dd-MM-yyyy";
|
|
7
7
|
}
|
|
8
8
|
return formatProp;
|
|
9
|
-
};
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
getFormattingString,
|
|
12
|
+
replaceLettersWithUnderscore
|
|
13
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { SubtleFieldProps } from '../../SubtleForm.types';
|
|
3
3
|
declare const SubtleField: {
|
|
4
4
|
({ disabled, suffix, suffixTooltip, label, labelTooltip, activeElement, inactiveElement, mask, maskVisible, errorText, active: activeProp, }: SubtleFieldProps): React.JSX.Element;
|
|
5
5
|
displayName: string;
|
|
@@ -1,74 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var containerRef = useRef(null);
|
|
27
|
-
var handleDeactivate = useCallback(function () {
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useCallback, useEffect } from "react";
|
|
3
|
+
import { useTheme } from "@synerise/ds-core";
|
|
4
|
+
import Icon, { EditS } from "@synerise/ds-icon";
|
|
5
|
+
import Tooltip from "@synerise/ds-tooltip";
|
|
6
|
+
import { useOnClickOutside } from "@synerise/ds-utils";
|
|
7
|
+
import { Subtle, SubtleFormField, Container, Inactive, MainContent, Suffix } from "../../SubtleForm.styles.js";
|
|
8
|
+
import { MaskedDatePlaceholder } from "../DatePicker/DatePicker.styles.js";
|
|
9
|
+
const SubtleField = ({
|
|
10
|
+
disabled,
|
|
11
|
+
suffix,
|
|
12
|
+
suffixTooltip,
|
|
13
|
+
label,
|
|
14
|
+
labelTooltip,
|
|
15
|
+
activeElement,
|
|
16
|
+
inactiveElement,
|
|
17
|
+
mask,
|
|
18
|
+
maskVisible,
|
|
19
|
+
errorText,
|
|
20
|
+
active: activeProp
|
|
21
|
+
}) => {
|
|
22
|
+
const [active, setActive] = useState(activeProp);
|
|
23
|
+
const [blurred, setBlurred] = useState(false);
|
|
24
|
+
const containerRef = useRef(null);
|
|
25
|
+
const handleDeactivate = useCallback(() => {
|
|
28
26
|
setActive(false);
|
|
29
27
|
setBlurred(true);
|
|
30
28
|
}, []);
|
|
31
|
-
|
|
29
|
+
const handleActivate = useCallback(() => {
|
|
32
30
|
setActive(true);
|
|
33
31
|
setBlurred(false);
|
|
34
32
|
}, []);
|
|
35
|
-
|
|
36
|
-
useEffect(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var isActive = Boolean(errorText || active && !blurred && !!activeElement);
|
|
40
|
-
useOnClickOutside(containerRef, function () {
|
|
33
|
+
const theme = useTheme();
|
|
34
|
+
useEffect(() => setActive(activeProp), [activeProp]);
|
|
35
|
+
const isActive = Boolean(errorText || active && !blurred && !!activeElement);
|
|
36
|
+
useOnClickOutside(containerRef, () => {
|
|
41
37
|
handleDeactivate();
|
|
42
38
|
});
|
|
43
|
-
return
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}, isActive && activeElement ? activeElement() : /*#__PURE__*/React.createElement(S.Inactive, {
|
|
55
|
-
tabIndex: 0,
|
|
56
|
-
onFocus: !disabled ? handleActivate : undefined,
|
|
57
|
-
onClick: !disabled ? handleActivate : undefined,
|
|
58
|
-
onBlur: handleDeactivate,
|
|
59
|
-
blurred: blurred,
|
|
60
|
-
disabled: disabled,
|
|
61
|
-
mask: maskVisible
|
|
62
|
-
}, /*#__PURE__*/React.createElement(S.MainContent, {
|
|
63
|
-
hasMargin: true
|
|
64
|
-
}, inactiveElement && inactiveElement(), !disabled && maskVisible && /*#__PURE__*/React.createElement(MaskedDatePlaceholder, null, mask)), !active && !disabled && /*#__PURE__*/React.createElement(S.Suffix, {
|
|
65
|
-
select: true
|
|
66
|
-
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
67
|
-
title: suffixTooltip
|
|
68
|
-
}, suffix != null ? suffix : /*#__PURE__*/React.createElement(Icon, {
|
|
69
|
-
component: /*#__PURE__*/React.createElement(EditS, null),
|
|
70
|
-
color: theme.palette['grey-600']
|
|
71
|
-
})))))));
|
|
39
|
+
return /* @__PURE__ */ jsx(Subtle, { className: "ds-subtle-form", disabled, children: /* @__PURE__ */ jsx(SubtleFormField, { active: isActive, label, tooltip: labelTooltip, children: /* @__PURE__ */ jsx(Container, { ref: containerRef, className: "ds-subtle-field", active, children: isActive && activeElement ? activeElement() : /* @__PURE__ */ jsxs(Inactive, { tabIndex: 0, onFocus: !disabled ? handleActivate : void 0, onClick: !disabled ? handleActivate : void 0, onBlur: handleDeactivate, blurred, disabled, mask: maskVisible, children: [
|
|
40
|
+
/* @__PURE__ */ jsxs(MainContent, { hasMargin: true, children: [
|
|
41
|
+
inactiveElement && inactiveElement(),
|
|
42
|
+
!disabled && maskVisible && /* @__PURE__ */ jsx(MaskedDatePlaceholder, { children: mask })
|
|
43
|
+
] }),
|
|
44
|
+
!active && !disabled && /* @__PURE__ */ jsx(Suffix, { select: true, children: /* @__PURE__ */ jsx(Tooltip, { title: suffixTooltip, children: suffix ?? /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(EditS, {}), color: theme.palette["grey-600"] }) }) })
|
|
45
|
+
] }) }) }) });
|
|
46
|
+
};
|
|
47
|
+
SubtleField.displayName = "SubtleField";
|
|
48
|
+
export {
|
|
49
|
+
SubtleField as default
|
|
72
50
|
};
|
|
73
|
-
SubtleField.displayName = 'SubtleField';
|
|
74
|
-
export default SubtleField;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { SubtleInputProps } from './Input.types';
|
|
3
3
|
declare const SubtleInput: {
|
|
4
4
|
({ disabled, value, onChange, placeholder, label, labelTooltip, suffixTooltip, suffix, error, errorText, inputProps, ...rest }: SubtleInputProps): React.JSX.Element;
|
|
5
5
|
displayName: string;
|
|
@@ -1,83 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
blurred = _useState2[0],
|
|
29
|
-
setBlurred = _useState2[1];
|
|
30
|
-
var containerRef = useRef(null);
|
|
31
|
-
var theme = useTheme();
|
|
32
|
-
var hasError = error || !!errorText;
|
|
33
|
-
var handleDeactivate = useCallback(function (event) {
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useCallback } from "react";
|
|
3
|
+
import { useTheme } from "@synerise/ds-core";
|
|
4
|
+
import Icon, { EditS } from "@synerise/ds-icon";
|
|
5
|
+
import { Input } from "@synerise/ds-input";
|
|
6
|
+
import Tooltip from "@synerise/ds-tooltip";
|
|
7
|
+
import { Subtle, SubtleFormField, Container, focusPadding, Inactive, MainContent, Suffix } from "../../SubtleForm.styles.js";
|
|
8
|
+
const SubtleInput = ({
|
|
9
|
+
disabled,
|
|
10
|
+
value,
|
|
11
|
+
onChange,
|
|
12
|
+
placeholder,
|
|
13
|
+
label,
|
|
14
|
+
labelTooltip,
|
|
15
|
+
suffixTooltip,
|
|
16
|
+
suffix,
|
|
17
|
+
error,
|
|
18
|
+
errorText,
|
|
19
|
+
inputProps,
|
|
20
|
+
...rest
|
|
21
|
+
}) => {
|
|
22
|
+
const [active, setActive] = useState(false);
|
|
23
|
+
const [blurred, setBlurred] = useState(false);
|
|
24
|
+
const containerRef = useRef(null);
|
|
25
|
+
const theme = useTheme();
|
|
26
|
+
const hasError = error || !!errorText;
|
|
27
|
+
const handleDeactivate = useCallback((event) => {
|
|
34
28
|
if (inputProps) {
|
|
35
|
-
|
|
29
|
+
const {
|
|
30
|
+
onBlur
|
|
31
|
+
} = inputProps;
|
|
36
32
|
onBlur && onBlur(event);
|
|
37
33
|
}
|
|
38
34
|
setActive(false);
|
|
39
35
|
setBlurred(true);
|
|
40
36
|
}, [inputProps]);
|
|
41
|
-
|
|
37
|
+
const handleActivate = useCallback(() => {
|
|
42
38
|
setActive(true);
|
|
43
39
|
setBlurred(false);
|
|
44
40
|
}, []);
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
disabled: disabled,
|
|
59
|
-
onChange: function onChange(event) {
|
|
60
|
-
_onChange && _onChange(event.currentTarget.value);
|
|
61
|
-
},
|
|
62
|
-
onBlur: !disabled ? handleDeactivate : undefined,
|
|
63
|
-
value: value,
|
|
64
|
-
style: {
|
|
65
|
-
margin: 0,
|
|
66
|
-
padding: focusPadding
|
|
67
|
-
},
|
|
68
|
-
placeholder: placeholder,
|
|
69
|
-
error: error,
|
|
70
|
-
errorText: errorText
|
|
71
|
-
}, rest, inputProps)) : /*#__PURE__*/React.createElement(S.Inactive, {
|
|
72
|
-
onClick: !disabled ? handleActivate : undefined,
|
|
73
|
-
blurred: blurred,
|
|
74
|
-
disabled: disabled
|
|
75
|
-
}, /*#__PURE__*/React.createElement(S.MainContent, null, value && !!value.trim() ? value : placeholder), /*#__PURE__*/React.createElement(S.Suffix, null, /*#__PURE__*/React.createElement(Tooltip, {
|
|
76
|
-
title: suffixTooltip
|
|
77
|
-
}, suffix != null ? suffix : /*#__PURE__*/React.createElement(Icon, {
|
|
78
|
-
component: /*#__PURE__*/React.createElement(EditS, null),
|
|
79
|
-
color: theme.palette['grey-600']
|
|
80
|
-
})))))));
|
|
41
|
+
return /* @__PURE__ */ jsx(Subtle, { className: "ds-subtle-form", children: /* @__PURE__ */ jsx(SubtleFormField, { active, label, tooltip: labelTooltip, children: /* @__PURE__ */ jsx(Container, { ref: containerRef, className: "ds-subtle-input", active, disabled, children: (active || hasError) && !disabled ? /* @__PURE__ */ jsx(Input, { autoFocus: !hasError && !disabled, disabled, onChange: (event) => {
|
|
42
|
+
onChange && onChange(event.currentTarget.value);
|
|
43
|
+
}, onBlur: !disabled ? handleDeactivate : void 0, value, style: {
|
|
44
|
+
margin: 0,
|
|
45
|
+
padding: focusPadding
|
|
46
|
+
}, placeholder, error, errorText, ...rest, ...inputProps }) : /* @__PURE__ */ jsxs(Inactive, { onClick: !disabled ? handleActivate : void 0, blurred, disabled, children: [
|
|
47
|
+
/* @__PURE__ */ jsx(MainContent, { children: value && !!value.trim() ? value : placeholder }),
|
|
48
|
+
/* @__PURE__ */ jsx(Suffix, { children: /* @__PURE__ */ jsx(Tooltip, { title: suffixTooltip, children: suffix ?? /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(EditS, {}), color: theme.palette["grey-600"] }) }) })
|
|
49
|
+
] }) }) }) });
|
|
50
|
+
};
|
|
51
|
+
SubtleInput.displayName = "SubtleInput";
|
|
52
|
+
export {
|
|
53
|
+
SubtleInput as default
|
|
81
54
|
};
|
|
82
|
-
SubtleInput.displayName = 'SubtleInput';
|
|
83
|
-
export default SubtleInput;
|