@ftdata/ui 0.0.15 → 0.0.17
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/components/Collapse/styles.js +2 -0
- package/dist/components/IconButton/index.d.ts +15 -0
- package/dist/components/IconButton/index.js +37 -0
- package/dist/components/IconButton/modifiers/color.d.ts +36 -0
- package/dist/components/IconButton/modifiers/color.js +38 -0
- package/dist/components/IconButton/styles.d.ts +10 -0
- package/dist/components/IconButton/styles.js +32 -0
- package/dist/components/Menu/constants/icons.d.ts +2 -16
- package/dist/components/Menu/constants/icons.js +13 -58
- package/dist/components/Menu/helpers/createMenus.js +13 -6
- package/dist/components/Menu/helpers/createSubMenus.d.ts +1 -1
- package/dist/components/Menu/helpers/createSubMenus.js +1 -1
- package/dist/components/Menu/helpers/generateColorScale.js +2 -2
- package/dist/components/Menu/helpers/getLuminance.d.ts +1 -1
- package/dist/components/Menu/helpers/getLuminance.js +2 -2
- package/dist/components/Menu/index.d.ts +1 -1
- package/dist/components/Menu/index.js +18 -31
- package/dist/components/Menu/styles.d.ts +0 -1
- package/dist/components/Menu/styles.js +29 -45
- package/dist/components/Menu/types/IconKeysType.d.ts +1 -1
- package/dist/components/Menu/types/MenuItem.d.ts +3 -2
- package/dist/components/Modal/index.d.ts +25 -0
- package/dist/components/Modal/index.js +69 -0
- package/dist/components/Modal/styles.d.ts +8 -0
- package/dist/components/Modal/styles.js +81 -0
- package/dist/components/MultiSelect/components/Badge/index.d.ts +2 -1
- package/dist/components/MultiSelect/components/Badge/index.js +5 -2
- package/dist/components/MultiSelect/components/Badge/styles.d.ts +5 -1
- package/dist/components/MultiSelect/components/Badge/styles.js +2 -1
- package/dist/components/MultiSelect/components/MultiSelectList/Row/index.d.ts +3 -2
- package/dist/components/MultiSelect/components/MultiSelectList/Row/index.js +21 -10
- package/dist/components/MultiSelect/components/MultiSelectList/Row/style.js +0 -1
- package/dist/components/MultiSelect/components/MultiSelectList/index.d.ts +3 -3
- package/dist/components/MultiSelect/components/MultiSelectList/index.js +8 -11
- package/dist/components/MultiSelect/components/MultiSelectList/style.d.ts +1 -1
- package/dist/components/MultiSelect/components/MultiSelectList/style.js +21 -3
- package/dist/components/MultiSelect/helpers/addOption.d.ts +3 -3
- package/dist/components/MultiSelect/helpers/computeUnselected.d.ts +1 -1
- package/dist/components/MultiSelect/helpers/computeUnselected.js +1 -1
- package/dist/components/MultiSelect/helpers/feedbackText.d.ts +1 -1
- package/dist/components/MultiSelect/helpers/feedbackText.js +9 -9
- package/dist/components/MultiSelect/helpers/filterOptions.d.ts +1 -1
- package/dist/components/MultiSelect/helpers/removeOptions.d.ts +3 -3
- package/dist/components/MultiSelect/index.d.ts +37 -19
- package/dist/components/MultiSelect/index.js +92 -135
- package/dist/components/MultiSelect/styles.js +8 -23
- package/dist/components/Texts/paragraphs.d.ts +12 -0
- package/dist/components/Texts/paragraphs.js +14 -0
- package/dist/components/Texts/text.d.ts +17 -0
- package/dist/components/Texts/text.js +21 -0
- package/dist/components/Texts/titles.d.ts +7 -0
- package/dist/components/Texts/titles.js +37 -0
- package/dist/components/fields/modifiers/selectColorModifier.d.ts +1 -1
- package/dist/components/fields/modifiers/selectColorModifier.js +7 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +4 -2
- package/package.json +3 -3
- package/dist/components/Collapse/Colapse.stories.d.ts +0 -10
- package/dist/components/Collapse/Colapse.stories.js +0 -108
- package/dist/components/Menu/Menu.stories.d.ts +0 -6
- package/dist/components/Menu/Menu.stories.js +0 -116
- package/dist/components/MultiSelect/helpers/arraysEqual.d.ts +0 -2
- package/dist/components/MultiSelect/helpers/arraysEqual.js +0 -5
- package/dist/components/MultiSelect/helpers/computeSelected.d.ts +0 -2
- package/dist/components/MultiSelect/helpers/computeSelected.js +0 -2
- package/dist/components/MultiSelect/helpers/getChangedFieds.d.ts +0 -2
- package/dist/components/MultiSelect/helpers/getChangedFieds.js +0 -17
- package/dist/components/MultiSelect/hooks/useMultiSelect.d.ts +0 -10
- package/dist/components/MultiSelect/hooks/useMultiSelect.js +0 -44
- package/dist/components/MultiSelect/interfaces/actions.d.ts +0 -4
- package/dist/components/MultiSelect/interfaces/actions.js +0 -0
- package/dist/components/MultiSelect/interfaces/config.d.ts +0 -17
- package/dist/components/MultiSelect/interfaces/config.js +0 -0
- package/dist/components/MultiSelect/interfaces/state.d.ts +0 -10
- package/dist/components/MultiSelect/interfaces/state.js +0 -0
- package/dist/components/MultiSelect/reducers/stateReducer.d.ts +0 -21
- package/dist/components/MultiSelect/reducers/stateReducer.js +0 -44
- package/dist/components/Text/Paragraph/Paragraph.stories.d.ts +0 -29
- package/dist/components/Text/Paragraph/Paragraph.stories.js +0 -124
- package/dist/components/Text/Title/Title.stories.d.ts +0 -41
- package/dist/components/Text/Title/Title.stories.js +0 -106
|
@@ -1,152 +1,111 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { BadgesContainer, LabelContainer, MaxItemsIndicator, MultiSelectContainer, MultiSelectWrapper, ResizableInput } from "./styles.js";
|
|
4
|
+
import Badge from "./components/Badge/index.js";
|
|
5
|
+
import MultiSelectList from "./components/MultiSelectList/index.js";
|
|
6
|
+
import HelpText from "../fields/components/HelpText/index.js";
|
|
4
7
|
import Label from "../fields/components/Label/index.js";
|
|
5
|
-
import { getHelpTextFeedbackType } from "../fields/helpers/getFeedbackType.js";
|
|
6
8
|
import { Icon } from "@ftdata/f-icons";
|
|
7
|
-
import HelpText from "../fields/components/HelpText/index.js";
|
|
8
|
-
import MultiSelectList from "./components/MultiSelectList/index.js";
|
|
9
|
-
import Badge from "./components/Badge/index.js";
|
|
10
|
-
import { addOption } from "./helpers/addOption.js";
|
|
11
|
-
import { removeOption } from "./helpers/removeOptions.js";
|
|
12
|
-
import { computeUnselected } from "./helpers/computeUnselected.js";
|
|
13
|
-
import { filterOptions } from "./helpers/filterOptions.js";
|
|
14
9
|
import { feedbackText } from "./helpers/feedbackText.js";
|
|
15
|
-
import {
|
|
16
|
-
import RotateButton from "../fields/components/RotateButton/index.js";
|
|
10
|
+
import { filterOptions } from "./helpers/filterOptions.js";
|
|
17
11
|
import calcTextSize from "./helpers/calcTextSize.js";
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
import RotateButton from "../fields/components/RotateButton/index.js";
|
|
13
|
+
import { COLOR_NEUTRAL_MEDIUM } from "@ftdata/f-tokens";
|
|
14
|
+
function MultiSelect({ label, sublabel, helpText, helpIcon, feedback, disabled, maxItems, selectAll, isLoading, options, selected, onChangeSelected, translation, onSearch, onLoadMore, placeholder, required, name, icon, listPosition, toggle, variant = "default" }) {
|
|
20
15
|
const [query, setQuery] = useState("");
|
|
16
|
+
const [showList, setShowList] = useState(false);
|
|
21
17
|
const [inputSize, setInputSize] = useState(0);
|
|
22
18
|
const inputRef = useRef(null);
|
|
23
19
|
const containerRef = useRef(null);
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
const unselected = useMemo(()=>options.filter((o)=>!selected.some((s)=>s.value === o.value)), [
|
|
21
|
+
options,
|
|
22
|
+
selected
|
|
23
|
+
]);
|
|
24
|
+
const canShowSelectAll = useMemo(()=>{
|
|
25
|
+
if (!selectAll) return false;
|
|
26
|
+
if (disabled) return false;
|
|
27
|
+
if (selected.length === options.length) return false;
|
|
28
|
+
if (query) return false;
|
|
29
|
+
if (maxItems && selected.length >= maxItems) return false;
|
|
30
|
+
return true;
|
|
31
|
+
}, [
|
|
32
|
+
selectAll,
|
|
33
|
+
selected,
|
|
34
|
+
options,
|
|
35
|
+
query,
|
|
36
|
+
maxItems,
|
|
37
|
+
disabled
|
|
38
|
+
]);
|
|
39
|
+
const filtered = useMemo(()=>{
|
|
40
|
+
if (!query) return unselected;
|
|
41
|
+
return filterOptions(unselected, query);
|
|
42
|
+
}, [
|
|
43
|
+
query,
|
|
44
|
+
unselected
|
|
45
|
+
]);
|
|
46
|
+
const addOption = (option)=>{
|
|
47
|
+
if ("__feedback" === option.value || disabled) return;
|
|
48
|
+
if (maxItems && selected.length >= maxItems) return;
|
|
49
|
+
onChangeSelected([
|
|
50
|
+
...selected,
|
|
51
|
+
option
|
|
52
|
+
]);
|
|
28
53
|
setQuery("");
|
|
29
|
-
setInputSize(1);
|
|
30
|
-
updateState({
|
|
31
|
-
...result,
|
|
32
|
-
filtered: []
|
|
33
|
-
});
|
|
34
|
-
inputRef.current?.focus();
|
|
35
54
|
};
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
55
|
+
const toggleList = (event)=>{
|
|
56
|
+
event.stopPropagation();
|
|
57
|
+
setShowList((prev)=>!prev);
|
|
58
|
+
};
|
|
59
|
+
const removeOption = (option)=>{
|
|
60
|
+
if (disabled) return;
|
|
61
|
+
onChangeSelected(selected.filter((o)=>o.value !== option.value));
|
|
42
62
|
};
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
63
|
+
const clearAll = ()=>onChangeSelected([]);
|
|
64
|
+
const handleAddAll = ()=>{
|
|
65
|
+
maxItems ? onChangeSelected(options.slice(0, maxItems)) : onChangeSelected(options);
|
|
66
|
+
};
|
|
67
|
+
const handleClickContainer = ()=>{
|
|
68
|
+
if (!disabled) {
|
|
69
|
+
if (inputRef.current) inputRef.current.focus();
|
|
70
|
+
setShowList(true);
|
|
71
|
+
}
|
|
46
72
|
};
|
|
47
73
|
const handleChange = (event)=>{
|
|
48
74
|
const value = event.target.value;
|
|
49
75
|
setQuery(value);
|
|
50
76
|
const textStyle = "500 14px Inter";
|
|
51
|
-
const
|
|
52
|
-
if (
|
|
53
|
-
if (
|
|
54
|
-
filtered: []
|
|
55
|
-
});
|
|
56
|
-
if (actions?.search) return void actions.search(value);
|
|
57
|
-
updateState({
|
|
58
|
-
filtered: filterOptions(computeUnselected(options, selected), value)
|
|
59
|
-
});
|
|
77
|
+
const newSize = calcTextSize(value, textStyle, "rem");
|
|
78
|
+
if (newSize) setInputSize(newSize);
|
|
79
|
+
if (onSearch) onSearch(value);
|
|
60
80
|
};
|
|
61
81
|
const handleKeyDown = (event)=>{
|
|
62
|
-
|
|
63
|
-
if ("
|
|
64
|
-
|
|
65
|
-
if (available[0]) handleAddOption(available[0]);
|
|
66
|
-
}
|
|
82
|
+
event.stopPropagation();
|
|
83
|
+
if ("Backspace" === event.key && !query && selected.length) removeOption(selected[selected.length - 1]);
|
|
84
|
+
if ("Enter" === event.key && filtered[0]) addOption(filtered[0]);
|
|
67
85
|
};
|
|
68
86
|
const currentDataOptions = useMemo(()=>{
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
87
|
+
const fb = feedbackText(translation, options, filtered, selected, query, maxItems);
|
|
88
|
+
if (fb.length) return fb;
|
|
71
89
|
if (filtered.length) return filtered;
|
|
72
|
-
return
|
|
90
|
+
return unselected;
|
|
73
91
|
}, [
|
|
74
|
-
query,
|
|
75
92
|
filtered,
|
|
76
93
|
selected,
|
|
77
|
-
options,
|
|
78
|
-
max
|
|
79
|
-
]);
|
|
80
|
-
const handleClickOutside = (event)=>{
|
|
81
|
-
if (containerRef.current && !containerRef.current.contains(event.target)) setShowList(false);
|
|
82
|
-
};
|
|
83
|
-
const clearSelected = ()=>updateState({
|
|
84
|
-
selected: []
|
|
85
|
-
});
|
|
86
|
-
const handleAddAll = (event)=>{
|
|
87
|
-
event.preventDefault();
|
|
88
|
-
if (max) {
|
|
89
|
-
if (selected.length) {
|
|
90
|
-
const index = selected.length - max;
|
|
91
|
-
const toAdd = unselected.slice(0, index);
|
|
92
|
-
updateState({
|
|
93
|
-
selected: [
|
|
94
|
-
...selected,
|
|
95
|
-
...toAdd
|
|
96
|
-
],
|
|
97
|
-
unselected: []
|
|
98
|
-
});
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
updateState({
|
|
102
|
-
selected: options.slice(0, max),
|
|
103
|
-
unselected: []
|
|
104
|
-
});
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
updateState({
|
|
108
|
-
selected: options,
|
|
109
|
-
unselected: []
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
const canShowSelectAll = useMemo(()=>{
|
|
113
|
-
if (!selectAll) return;
|
|
114
|
-
if (selected.length === total || selected.length === options.length) return;
|
|
115
|
-
if (query) return;
|
|
116
|
-
if (max && max === selected.length) return;
|
|
117
|
-
return handleAddAll;
|
|
118
|
-
}, [
|
|
119
94
|
query,
|
|
120
|
-
filtered,
|
|
121
|
-
selected,
|
|
122
95
|
options,
|
|
123
|
-
|
|
96
|
+
maxItems
|
|
124
97
|
]);
|
|
125
98
|
useEffect(()=>{
|
|
99
|
+
if (toggle) toggle(showList);
|
|
100
|
+
const handleClickOutside = (e)=>{
|
|
101
|
+
if (containerRef.current && !containerRef.current.contains(e.target)) setShowList(false);
|
|
102
|
+
};
|
|
126
103
|
if (showList) document.addEventListener("mousedown", handleClickOutside);
|
|
127
104
|
return ()=>document.removeEventListener("mousedown", handleClickOutside);
|
|
128
105
|
}, [
|
|
129
106
|
showList
|
|
130
107
|
]);
|
|
131
|
-
const feedBackHelpText = getHelpTextFeedbackType(feedback, disabled);
|
|
132
|
-
const toggleList = (event)=>{
|
|
133
|
-
event.stopPropagation();
|
|
134
|
-
if (disabled) return;
|
|
135
|
-
setShowList((prev)=>!prev);
|
|
136
|
-
};
|
|
137
|
-
const handleClickContainer = (event)=>{
|
|
138
|
-
event.stopPropagation();
|
|
139
|
-
if (disabled) return;
|
|
140
|
-
if (!showList) setShowList(true);
|
|
141
|
-
inputRef.current?.focus();
|
|
142
|
-
};
|
|
143
|
-
useEffect(()=>{
|
|
144
|
-
if (toggle) toggle(showList);
|
|
145
|
-
}, [
|
|
146
|
-
showList
|
|
147
|
-
]);
|
|
148
108
|
return /*#__PURE__*/ jsxs(MultiSelectWrapper, {
|
|
149
|
-
...rest,
|
|
150
109
|
children: [
|
|
151
110
|
/*#__PURE__*/ jsxs(LabelContainer, {
|
|
152
111
|
children: [
|
|
@@ -156,8 +115,9 @@ function MultiSelect({ helpText, label, sublabel, required, disabled, feedback,
|
|
|
156
115
|
required: required,
|
|
157
116
|
htmlFor: name
|
|
158
117
|
}),
|
|
159
|
-
selected.length > 0 && /*#__PURE__*/ jsx("button", {
|
|
160
|
-
|
|
118
|
+
selected.length > 0 && !disabled && /*#__PURE__*/ jsx("button", {
|
|
119
|
+
type: "button",
|
|
120
|
+
onClick: clearAll,
|
|
161
121
|
children: translation("remove_all")
|
|
162
122
|
})
|
|
163
123
|
]
|
|
@@ -169,61 +129,58 @@ function MultiSelect({ helpText, label, sublabel, required, disabled, feedback,
|
|
|
169
129
|
disabled: disabled,
|
|
170
130
|
$active: showList,
|
|
171
131
|
children: [
|
|
172
|
-
"string" == typeof icon ? /*#__PURE__*/ jsx(Icon, {
|
|
132
|
+
icon && ("string" == typeof icon ? /*#__PURE__*/ jsx(Icon, {
|
|
173
133
|
name: icon,
|
|
174
|
-
color:
|
|
175
|
-
}) : icon,
|
|
134
|
+
color: COLOR_NEUTRAL_MEDIUM
|
|
135
|
+
}) : icon),
|
|
176
136
|
/*#__PURE__*/ jsxs(BadgesContainer, {
|
|
177
137
|
children: [
|
|
178
138
|
selected.map((option)=>/*#__PURE__*/ jsx(Badge, {
|
|
179
139
|
text: option.label,
|
|
180
|
-
remove: ()=>
|
|
140
|
+
remove: ()=>removeOption(option),
|
|
141
|
+
disabled: disabled
|
|
181
142
|
}, option.value)),
|
|
182
143
|
/*#__PURE__*/ jsx(ResizableInput, {
|
|
183
144
|
type: "text",
|
|
184
|
-
name: name,
|
|
185
145
|
placeholder: selected.length ? "" : placeholder,
|
|
186
146
|
ref: inputRef,
|
|
187
147
|
value: query,
|
|
188
148
|
onKeyDown: handleKeyDown,
|
|
189
149
|
onChange: handleChange,
|
|
190
|
-
disabled: disabled,
|
|
191
150
|
size: inputSize,
|
|
192
|
-
wide: 0 === selected.length
|
|
151
|
+
wide: 0 === selected.length,
|
|
152
|
+
disabled: disabled,
|
|
153
|
+
name: name
|
|
193
154
|
})
|
|
194
155
|
]
|
|
195
156
|
}),
|
|
196
|
-
/*#__PURE__*/ jsx(RotateButton, {
|
|
157
|
+
"alt" === variant && /*#__PURE__*/ jsx(RotateButton, {
|
|
197
158
|
rotate: showList,
|
|
198
|
-
onClick: toggleList
|
|
199
|
-
disabled: disabled,
|
|
200
|
-
style: {
|
|
201
|
-
cursor: disabled ? "not-allowed" : "pointer"
|
|
202
|
-
}
|
|
159
|
+
onClick: toggleList
|
|
203
160
|
}),
|
|
204
|
-
|
|
161
|
+
maxItems && /*#__PURE__*/ jsx(MaxItemsIndicator, {
|
|
205
162
|
children: /*#__PURE__*/ jsxs("span", {
|
|
206
163
|
children: [
|
|
207
164
|
selected.length,
|
|
208
165
|
"/",
|
|
209
|
-
|
|
166
|
+
maxItems
|
|
210
167
|
]
|
|
211
168
|
})
|
|
212
169
|
}),
|
|
213
170
|
showList && /*#__PURE__*/ jsx(MultiSelectList, {
|
|
214
171
|
options: currentDataOptions,
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
addAll: canShowSelectAll,
|
|
172
|
+
onClickOption: (_, option)=>addOption(option),
|
|
173
|
+
loading: isLoading,
|
|
174
|
+
addAll: canShowSelectAll ? handleAddAll : void 0,
|
|
219
175
|
onLoadMore: onLoadMore,
|
|
220
|
-
|
|
176
|
+
translation: translation,
|
|
177
|
+
listPosition: listPosition
|
|
221
178
|
})
|
|
222
179
|
]
|
|
223
180
|
}),
|
|
224
181
|
helpText && /*#__PURE__*/ jsx(HelpText, {
|
|
225
182
|
text: helpText,
|
|
226
|
-
feedback:
|
|
183
|
+
feedback: feedback,
|
|
227
184
|
icon: helpIcon
|
|
228
185
|
})
|
|
229
186
|
]
|
|
@@ -10,7 +10,7 @@ const MultiSelectWrapper = styled_components.div`
|
|
|
10
10
|
const showButton = keyframes`
|
|
11
11
|
from {
|
|
12
12
|
opacity: 0.8;
|
|
13
|
-
transform: translateY(
|
|
13
|
+
transform: translateY(0.125rem);
|
|
14
14
|
}
|
|
15
15
|
to {
|
|
16
16
|
opacity: 1;
|
|
@@ -31,7 +31,7 @@ const LabelContainer = styled_components.div`
|
|
|
31
31
|
font-weight: ${FONT_WEIGHT_BOLD};
|
|
32
32
|
line-height: 1rem;
|
|
33
33
|
animation: ${showButton} 0.15s ease-in forwards;
|
|
34
|
-
height:
|
|
34
|
+
height: 1.5rem;
|
|
35
35
|
|
|
36
36
|
&:hover {
|
|
37
37
|
color: ${COLOR_ACCENT_DARK};
|
|
@@ -50,45 +50,35 @@ const MultiSelectContainer = styled_components.div`
|
|
|
50
50
|
${({ $active })=>$active ? "2px" : "1px"}${COLOR_NEUTRAL_MEDIUM};
|
|
51
51
|
position: relative;
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
box-shadow: 0px 0px 0px 2px ${COLOR_NEUTRAL_MEDIUM};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
${({ disabled, feedback, $active })=>disabled ? `
|
|
58
|
-
background-color: ${COLOR_NEUTRAL_LIGHTER};
|
|
59
|
-
box-shadow: 0 0 0 1px ${COLOR_NEUTRAL_MEDIUM};
|
|
60
|
-
cursor: not-allowed;
|
|
61
|
-
` : selectColorModifier(feedback, $active)}
|
|
53
|
+
${({ disabled, feedback, $active })=>selectColorModifier(feedback, $active, disabled)}
|
|
62
54
|
`;
|
|
63
55
|
const BadgesContainer = styled_components.div`
|
|
64
|
-
background-color: ${COLOR_NEUTRAL_DAY};
|
|
65
56
|
display: flex;
|
|
66
57
|
flex-wrap: wrap;
|
|
67
58
|
gap: 0.5rem;
|
|
68
59
|
flex: 1;
|
|
69
|
-
max-height:
|
|
60
|
+
max-height: 10rem;
|
|
70
61
|
overflow-y: auto;
|
|
71
62
|
|
|
72
63
|
&::-webkit-scrollbar-track {
|
|
73
|
-
background-color:
|
|
64
|
+
background-color: ${COLOR_NEUTRAL_LIGHTER};
|
|
74
65
|
border-radius: 0 0.25rem 0.25rem 0;
|
|
75
66
|
}
|
|
76
67
|
|
|
77
68
|
&::-webkit-scrollbar {
|
|
78
|
-
width:
|
|
79
|
-
background:
|
|
69
|
+
width: 0.5rem;
|
|
70
|
+
background: ${COLOR_NEUTRAL_LIGHTER};
|
|
80
71
|
border-radius: 0 0.25rem 0.25rem 0;
|
|
81
72
|
}
|
|
82
73
|
|
|
83
74
|
&::-webkit-scrollbar-thumb {
|
|
84
|
-
border-radius:
|
|
75
|
+
border-radius: 8px;
|
|
85
76
|
background: #d5d8da;
|
|
86
77
|
}
|
|
87
78
|
`;
|
|
88
79
|
const ResizableInput = styled_components.input`
|
|
89
80
|
outline: none;
|
|
90
81
|
border: none;
|
|
91
|
-
background-color: transparent;
|
|
92
82
|
color: ${COLOR_NEUTRAL_DUSK};
|
|
93
83
|
font-size: 0.875rem;
|
|
94
84
|
line-height: 1rem;
|
|
@@ -103,11 +93,6 @@ const ResizableInput = styled_components.input`
|
|
|
103
93
|
font-weight: ${FONT_WEIGHT_MEDIUM};
|
|
104
94
|
line-height: 1.5rem;
|
|
105
95
|
}
|
|
106
|
-
|
|
107
|
-
&:disabled {
|
|
108
|
-
background-color: ${COLOR_NEUTRAL_LIGHTER};
|
|
109
|
-
cursor: not-allowed;
|
|
110
|
-
}
|
|
111
96
|
`;
|
|
112
97
|
const MaxItemsIndicator = styled_components.div`
|
|
113
98
|
display: flex;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare const PARAGRAPH_SIZES: {
|
|
2
|
+
readonly body: "1rem";
|
|
3
|
+
readonly small: "0.875rem";
|
|
4
|
+
readonly caption: "0.75rem";
|
|
5
|
+
};
|
|
6
|
+
type ParagraphSize = keyof typeof PARAGRAPH_SIZES;
|
|
7
|
+
interface ParagraphProps {
|
|
8
|
+
size?: ParagraphSize;
|
|
9
|
+
color?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const Paragraph: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, ParagraphProps>> & string;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import styled_components from "styled-components";
|
|
2
|
+
import { COLOR_NEUTRAL_DUSK } from "@ftdata/f-tokens";
|
|
3
|
+
const PARAGRAPH_SIZES = {
|
|
4
|
+
body: '1rem',
|
|
5
|
+
small: '0.875rem',
|
|
6
|
+
caption: '0.75rem'
|
|
7
|
+
};
|
|
8
|
+
const Paragraph = styled_components.span`
|
|
9
|
+
color: ${({ color })=>color ?? COLOR_NEUTRAL_DUSK};
|
|
10
|
+
line-height: 1.5;
|
|
11
|
+
font-weight: 500;
|
|
12
|
+
font-size: ${({ size = 'body' })=>PARAGRAPH_SIZES[size]};
|
|
13
|
+
`;
|
|
14
|
+
export { Paragraph };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare const FONT_SIZES: {
|
|
2
|
+
readonly xxs: string;
|
|
3
|
+
readonly xs: string;
|
|
4
|
+
readonly sm: string;
|
|
5
|
+
readonly md: string;
|
|
6
|
+
readonly lg: string;
|
|
7
|
+
readonly xl: string;
|
|
8
|
+
readonly xxl: string;
|
|
9
|
+
readonly xxxl: string;
|
|
10
|
+
readonly megadisplay: string;
|
|
11
|
+
};
|
|
12
|
+
type TextSize = keyof typeof FONT_SIZES;
|
|
13
|
+
interface TextProps {
|
|
14
|
+
size?: TextSize;
|
|
15
|
+
}
|
|
16
|
+
export declare const Text: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, TextProps>> & string;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import styled_components from "styled-components";
|
|
2
|
+
import { COLOR_NEUTRAL_DUSK, FONT_RELATIVE_SIZE_LG, FONT_RELATIVE_SIZE_MD, FONT_RELATIVE_SIZE_MEGADISPLAY, FONT_RELATIVE_SIZE_SM, FONT_RELATIVE_SIZE_XL, FONT_RELATIVE_SIZE_XS, FONT_RELATIVE_SIZE_XXL, FONT_RELATIVE_SIZE_XXS, FONT_RELATIVE_SIZE_XXXL } from "@ftdata/f-tokens";
|
|
3
|
+
const FONT_SIZES = {
|
|
4
|
+
xxs: FONT_RELATIVE_SIZE_XXS,
|
|
5
|
+
xs: FONT_RELATIVE_SIZE_XS,
|
|
6
|
+
sm: FONT_RELATIVE_SIZE_SM,
|
|
7
|
+
md: FONT_RELATIVE_SIZE_MD,
|
|
8
|
+
lg: FONT_RELATIVE_SIZE_LG,
|
|
9
|
+
xl: FONT_RELATIVE_SIZE_XL,
|
|
10
|
+
xxl: FONT_RELATIVE_SIZE_XXL,
|
|
11
|
+
xxxl: FONT_RELATIVE_SIZE_XXXL,
|
|
12
|
+
megadisplay: FONT_RELATIVE_SIZE_MEGADISPLAY
|
|
13
|
+
};
|
|
14
|
+
const Text = styled_components.span`
|
|
15
|
+
color: ${({ color })=>color ?? COLOR_NEUTRAL_DUSK};
|
|
16
|
+
line-height: 1.2;
|
|
17
|
+
font-weight: 600;
|
|
18
|
+
|
|
19
|
+
font-size: ${({ size = 'md' })=>FONT_SIZES[size]};
|
|
20
|
+
`;
|
|
21
|
+
export { Text };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type TitleVariant = 'huge' | 'standard' | 'section' | 'heading' | 'smallHeading' | 'subheading';
|
|
2
|
+
interface TitleProps {
|
|
3
|
+
size?: TitleVariant;
|
|
4
|
+
color?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const Title: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, TitleProps>> & string;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import styled_components from "styled-components";
|
|
2
|
+
import { COLOR_NEUTRAL_DUSK } from "@ftdata/f-tokens";
|
|
3
|
+
const TITLE_VARIANTS = {
|
|
4
|
+
huge: {
|
|
5
|
+
size: '1.875rem',
|
|
6
|
+
spacing: '-0.03em'
|
|
7
|
+
},
|
|
8
|
+
standard: {
|
|
9
|
+
size: '1.5rem',
|
|
10
|
+
spacing: '-0.03em'
|
|
11
|
+
},
|
|
12
|
+
section: {
|
|
13
|
+
size: '1.25rem',
|
|
14
|
+
spacing: '-0.03em',
|
|
15
|
+
weight: 500
|
|
16
|
+
},
|
|
17
|
+
heading: {
|
|
18
|
+
size: '1rem'
|
|
19
|
+
},
|
|
20
|
+
smallHeading: {
|
|
21
|
+
size: '0.875rem'
|
|
22
|
+
},
|
|
23
|
+
subheading: {
|
|
24
|
+
size: '0.75rem',
|
|
25
|
+
spacing: '0.06em'
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const Title = styled_components.span`
|
|
29
|
+
color: ${({ color })=>color ?? COLOR_NEUTRAL_DUSK};
|
|
30
|
+
line-height: 1.2;
|
|
31
|
+
font-weight: 600;
|
|
32
|
+
|
|
33
|
+
font-size: ${({ size = 'standard' })=>TITLE_VARIANTS[size].size};
|
|
34
|
+
letter-spacing: ${({ size = 'standard' })=>TITLE_VARIANTS[size].spacing ?? '0'};
|
|
35
|
+
font-weight: ${({ size = 'standard' })=>TITLE_VARIANTS[size].weight ?? 600};
|
|
36
|
+
`;
|
|
37
|
+
export { Title };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { FieldFeedbackType } from "../../../types/feedback";
|
|
2
|
-
export declare function selectColorModifier(feedback?: FieldFeedbackType, active?: boolean): "" | import("styled-components").RuleSet<object>;
|
|
2
|
+
export declare function selectColorModifier(feedback?: FieldFeedbackType, active?: boolean, disabled?: boolean): "" | import("styled-components").RuleSet<object>;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { css } from "styled-components";
|
|
2
2
|
import { FEEDBACK_COLORS } from "./color_modifiers.js";
|
|
3
|
-
|
|
3
|
+
import { COLOR_NEUTRAL_LIGHT, COLOR_NEUTRAL_LIGHTER } from "@ftdata/f-tokens";
|
|
4
|
+
function selectColorModifier(feedback, active, disabled) {
|
|
5
|
+
if (disabled) return css`
|
|
6
|
+
background-color: ${COLOR_NEUTRAL_LIGHTER};
|
|
7
|
+
box-shadow: 0 0 0 1px ${COLOR_NEUTRAL_LIGHT};
|
|
8
|
+
cursor: not-allowed;
|
|
9
|
+
`;
|
|
4
10
|
if (!feedback) return "";
|
|
5
11
|
const color = FEEDBACK_COLORS[feedback];
|
|
6
12
|
return css`
|
package/dist/index.d.ts
CHANGED
|
@@ -17,12 +17,12 @@ export type { ISelectOption } from "./components/Select";
|
|
|
17
17
|
export type { SelectProps } from "./components/Select";
|
|
18
18
|
export { default as StateAlert } from "./components/StateAlert";
|
|
19
19
|
export { default as MultiSelect } from "./components/MultiSelect";
|
|
20
|
-
export {
|
|
21
|
-
export type { MultiSelectProps } from "./components/MultiSelect";
|
|
22
|
-
export type { IMultiSelectActions } from "./components/MultiSelect/interfaces/actions";
|
|
23
|
-
export type { IMultiSelectOption, IMultiSelectState, } from "./components/MultiSelect/interfaces/state";
|
|
24
|
-
export type { IMultiSelectConfig, IMultiSelectConfigActions, IMultiSelectConfigFields, } from "./components/MultiSelect/interfaces/config";
|
|
20
|
+
export type { MultiSelectProps, IMultiSelectOption, } from "./components/MultiSelect";
|
|
25
21
|
export { default as DoubleList } from "./components/DoubleList";
|
|
26
22
|
export { default as Menu } from "./components/Menu";
|
|
27
23
|
export type { MenuItem, MenuItemData, SubMenu, SubMenuData, } from "./components/Menu/types/MenuItem";
|
|
28
24
|
export { Input } from "./components/Input";
|
|
25
|
+
export { default as IconButton } from "./components/IconButton";
|
|
26
|
+
export { default as Modal } from "./components/Modal";
|
|
27
|
+
export { ModalOverlay } from "./components/Modal/styles";
|
|
28
|
+
export type { ModalAction, ModalActions, ModalProps, ModalSizeCustom, ModalSizes, } from "./components/Modal";
|
package/dist/index.js
CHANGED
|
@@ -13,10 +13,12 @@ import UserMenu from "./components/UserMenu/index.js";
|
|
|
13
13
|
import Select from "./components/Select/index.js";
|
|
14
14
|
import StateAlert from "./components/StateAlert/index.js";
|
|
15
15
|
import MultiSelect from "./components/MultiSelect/index.js";
|
|
16
|
-
import { useMultiSelect } from "./components/MultiSelect/hooks/useMultiSelect.js";
|
|
17
16
|
import DoubleList from "./components/DoubleList/index.js";
|
|
18
17
|
import Menu from "./components/Menu/index.js";
|
|
19
18
|
import { Input } from "./components/Input/index.js";
|
|
19
|
+
import IconButton from "./components/IconButton/index.js";
|
|
20
|
+
import Modal from "./components/Modal/index.js";
|
|
21
|
+
import { ModalOverlay } from "./components/Modal/styles.js";
|
|
20
22
|
export * from "./components/Grid/index.js";
|
|
21
23
|
export * from "./components/Text/index.js";
|
|
22
|
-
export { Avatar, Breadcrumb, Button, Checkbox, Collapse, DoubleList, EmptyState, Input, Loading, Menu, MultiSelect, Radio, Select, StateAlert, Switch, TextArea, Tooltips, UserMenu, useLoading
|
|
24
|
+
export { Avatar, Breadcrumb, Button, Checkbox, Collapse, DoubleList, EmptyState, IconButton, Input, Loading, Menu, Modal, ModalOverlay, MultiSelect, Radio, Select, StateAlert, Switch, TextArea, Tooltips, UserMenu, useLoading };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ftdata/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"react-input-mask-next": "3.0.0-alpha.12",
|
|
32
32
|
"react-select": "^5.10.2",
|
|
33
33
|
"react-window": "^2.0.2",
|
|
34
|
-
"@ftdata/f-
|
|
35
|
-
"@ftdata/f-
|
|
34
|
+
"@ftdata/f-tokens": "0.0.1",
|
|
35
|
+
"@ftdata/f-icons": "0.0.6"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import Collapse from ".";
|
|
3
|
-
/**
|
|
4
|
-
* Collapses são usados para permitir que usuários ocultem ou mostrem o conteúdo dinamicamente.
|
|
5
|
-
* Usado normalmente para economizar espaço e manter a ui concisa.
|
|
6
|
-
*/
|
|
7
|
-
declare const meta: Meta<typeof Collapse>;
|
|
8
|
-
export default meta;
|
|
9
|
-
type Story = StoryObj<typeof meta>;
|
|
10
|
-
export declare const Default: Story;
|