@monolith-forensics/monolith-ui 1.8.1-dev.4 → 1.9.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/dist/Button/Button.js +58 -9
- package/dist/Calendar/Calendar.d.ts +2 -7
- package/dist/Calendar/Calendar.js +49 -226
- package/dist/Calendar/CalendarStyles.d.ts +2 -6
- package/dist/Calendar/CalendarStyles.js +33 -153
- package/dist/Calendar/calendarHelpers.d.ts +2 -6
- package/dist/Calendar/calendarHelpers.js +5 -13
- package/dist/CheckBox/CheckBox.js +19 -36
- package/dist/DateInput/DateInput.js +143 -198
- package/dist/DropDownMenu/DropDownMenu.js +15 -25
- package/dist/DropDownMenu/components/MenuComponent.js +2 -8
- package/dist/DropDownMenu/components/MenuItem.d.ts +0 -2
- package/dist/DropDownMenu/components/MenuItem.js +21 -25
- package/dist/DropDownMenu/components/MenuItemList.d.ts +0 -3
- package/dist/DropDownMenu/components/MenuItemList.js +86 -192
- package/dist/DropDownMenu/components/StyledContent.js +2 -1
- package/dist/DropDownMenu/components/StyledFloatContainer.js +1 -1
- package/dist/DropDownMenu/types.d.ts +0 -3
- package/dist/FieldLabel/FieldLabel.js +12 -4
- package/dist/FileInputField/FileInputField.js +23 -4
- package/dist/FileViewer/viewers/ImageViewer.js +18 -75
- package/dist/FormSection/FormSection.js +25 -5
- package/dist/IconButton/IconButton.js +16 -2
- package/dist/Input/Input.js +56 -7
- package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +0 -1
- package/dist/Pill/Pill.js +79 -8
- package/dist/Popover/Popover.context.d.ts +1 -2
- package/dist/Popover/Popover.js +2 -5
- package/dist/Popover/Popover.styles.d.ts +6 -1
- package/dist/Popover/Popover.styles.js +28 -11
- package/dist/Popover/Popover.transitions.d.ts +2 -4
- package/dist/Popover/Popover.transitions.js +49 -23
- package/dist/Popover/PopoverDropdown.js +8 -6
- package/dist/Popover/PopoverTarget.js +3 -6
- package/dist/QueryFilter/DefaultOperators.d.ts +76 -0
- package/dist/QueryFilter/DefaultOperators.js +21 -0
- package/dist/QueryFilter/QueryFilter.d.ts +1 -1
- package/dist/QueryFilter/QueryFilter.js +303 -3
- package/dist/QueryFilter/index.d.ts +2 -3
- package/dist/QueryFilter/index.js +2 -3
- package/dist/QueryFilter/{QueryFilter.types.d.ts → types.d.ts} +2 -11
- package/dist/QueryFilter/useQueryFilter.d.ts +1 -1
- package/dist/QueryFilter/useQueryFilter.js +19 -23
- package/dist/RichTextEditor/Extensions/getTiptapExtensions.js +15 -5
- package/dist/RichTextEditor/Plugins/UploadImagesPlugin.d.ts +0 -15
- package/dist/RichTextEditor/Plugins/UploadImagesPlugin.js +51 -115
- package/dist/RichTextEditor/Plugins/index.d.ts +0 -1
- package/dist/RichTextEditor/Plugins/index.js +0 -1
- package/dist/RichTextEditor/RichTextEditor.d.ts +2 -3
- package/dist/RichTextEditor/RichTextEditor.js +35 -309
- package/dist/RichTextEditor/Toolbar/Toolbar.js +2 -14
- package/dist/SegmentedControl/SegmentedControl.utils.d.ts +2 -2
- package/dist/SegmentedControl/SegmentedControl.utils.js +30 -3
- package/dist/SelectBox/SelectBox.js +5 -5
- package/dist/SelectBox/select-box.styled-components.d.ts +1 -4
- package/dist/SelectBox/select-box.styled-components.js +48 -11
- package/dist/SelectBox/types.d.ts +0 -1
- package/dist/Switch/Switch.d.ts +2 -2
- package/dist/Switch/Switch.js +83 -18
- package/dist/Table/ColumnResizer.d.ts +9 -6
- package/dist/Table/ColumnResizer.js +10 -30
- package/dist/Table/StateStorage.d.ts +0 -4
- package/dist/Table/StateStorage.js +0 -13
- package/dist/Table/Table.js +12 -160
- package/dist/Table/TableComponents.d.ts +0 -10
- package/dist/Table/TableComponents.js +10 -71
- package/dist/Table/TableDefaults.d.ts +0 -7
- package/dist/Table/TableDefaults.js +0 -7
- package/dist/Table/TableHeader.js +16 -31
- package/dist/Table/TableMenu/TableMenu.js +1 -1
- package/dist/Table/TableProvider.js +75 -354
- package/dist/Table/TableRow.js +16 -28
- package/dist/Table/Utils/index.d.ts +1 -0
- package/dist/Table/Utils/index.js +1 -0
- package/dist/Table/Utils/resizeHandler.d.ts +3 -0
- package/dist/Table/Utils/resizeHandler.js +84 -0
- package/dist/Table/types.d.ts +19 -70
- package/dist/Tabs/Tab.js +0 -8
- package/dist/TagBox/TagBox.d.ts +1 -1
- package/dist/TagBox/TagBox.js +208 -50
- package/dist/TagBox/types.d.ts +13 -1
- package/dist/TextArea/TextArea.js +23 -9
- package/dist/TextInput/TextInput.js +6 -12
- package/dist/Utilities/parseTimestamp.js +6 -11
- package/dist/core/ArrowButton.d.ts +0 -2
- package/dist/core/ArrowButton.js +3 -7
- package/dist/core/ClearButton.d.ts +0 -2
- package/dist/core/ClearButton.js +3 -7
- package/dist/core/controlSizes.d.ts +0 -26
- package/dist/core/controlSizes.js +0 -156
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -2
- package/dist/theme/variants.js +0 -2
- package/package.json +18 -26
- package/dist/Charts/BarChart/BarChart.d.ts +0 -5
- package/dist/Charts/BarChart/BarChart.js +0 -549
- package/dist/Charts/BarChart/BarChart.lib.d.ts +0 -31
- package/dist/Charts/BarChart/BarChart.lib.js +0 -136
- package/dist/Charts/BarChart/BarChart.styled.d.ts +0 -51
- package/dist/Charts/BarChart/BarChart.styled.js +0 -115
- package/dist/Charts/BarChart/BarChart.types.d.ts +0 -171
- package/dist/Charts/BarChart/index.d.ts +0 -3
- package/dist/Charts/BarChart/index.js +0 -2
- package/dist/Charts/ChartPrimitives/ChartExportControl.d.ts +0 -11
- package/dist/Charts/ChartPrimitives/ChartExportControl.js +0 -29
- package/dist/Charts/ChartPrimitives/chartActions.styled.d.ts +0 -1
- package/dist/Charts/ChartPrimitives/chartActions.styled.js +0 -8
- package/dist/Charts/ChartPrimitives/chartLegend.styled.d.ts +0 -12
- package/dist/Charts/ChartPrimitives/chartLegend.styled.js +0 -52
- package/dist/Charts/ChartPrimitives/chartTooltip.styled.d.ts +0 -19
- package/dist/Charts/ChartPrimitives/chartTooltip.styled.js +0 -61
- package/dist/Charts/ChartPrimitives/index.d.ts +0 -4
- package/dist/Charts/ChartPrimitives/index.js +0 -4
- package/dist/Charts/ChartUtils/chartColors.d.ts +0 -8
- package/dist/Charts/ChartUtils/chartColors.js +0 -65
- package/dist/Charts/ChartUtils/chartExport.d.ts +0 -47
- package/dist/Charts/ChartUtils/chartExport.js +0 -311
- package/dist/Charts/ChartUtils/chartMath.d.ts +0 -3
- package/dist/Charts/ChartUtils/chartMath.js +0 -3
- package/dist/Charts/ChartUtils/index.d.ts +0 -3
- package/dist/Charts/ChartUtils/index.js +0 -3
- package/dist/Charts/HeatMap/HeatMap.d.ts +0 -5
- package/dist/Charts/HeatMap/HeatMap.js +0 -212
- package/dist/Charts/HeatMap/HeatMap.lib.d.ts +0 -30
- package/dist/Charts/HeatMap/HeatMap.lib.js +0 -115
- package/dist/Charts/HeatMap/HeatMap.styled.d.ts +0 -37
- package/dist/Charts/HeatMap/HeatMap.styled.js +0 -91
- package/dist/Charts/HeatMap/HeatMap.types.d.ts +0 -80
- package/dist/Charts/HeatMap/HeatMap.types.js +0 -1
- package/dist/Charts/HeatMap/index.d.ts +0 -3
- package/dist/Charts/HeatMap/index.js +0 -2
- package/dist/Charts/LineChart/LineChart.d.ts +0 -5
- package/dist/Charts/LineChart/LineChart.js +0 -529
- package/dist/Charts/LineChart/LineChart.lib.d.ts +0 -24
- package/dist/Charts/LineChart/LineChart.lib.js +0 -132
- package/dist/Charts/LineChart/LineChart.styled.d.ts +0 -59
- package/dist/Charts/LineChart/LineChart.styled.js +0 -147
- package/dist/Charts/LineChart/LineChart.types.d.ts +0 -193
- package/dist/Charts/LineChart/LineChart.types.js +0 -1
- package/dist/Charts/LineChart/index.d.ts +0 -3
- package/dist/Charts/LineChart/index.js +0 -2
- package/dist/Charts/PieChart/PieChart.d.ts +0 -4
- package/dist/Charts/PieChart/PieChart.js +0 -199
- package/dist/Charts/PieChart/PieChart.lib.d.ts +0 -5
- package/dist/Charts/PieChart/PieChart.lib.js +0 -19
- package/dist/Charts/PieChart/PieChart.styled.d.ts +0 -51
- package/dist/Charts/PieChart/PieChart.styled.js +0 -163
- package/dist/Charts/PieChart/PieChart.types.d.ts +0 -100
- package/dist/Charts/PieChart/PieChart.types.js +0 -1
- package/dist/Charts/PieChart/index.d.ts +0 -2
- package/dist/Charts/PieChart/index.js +0 -1
- package/dist/Charts/index.d.ts +0 -5
- package/dist/Charts/index.js +0 -4
- package/dist/QueryFilter/QueryFilter.constants.d.ts +0 -134
- package/dist/QueryFilter/QueryFilter.constants.js +0 -39
- package/dist/QueryFilter/QueryFilter.lib.d.ts +0 -14
- package/dist/QueryFilter/QueryFilter.lib.js +0 -84
- package/dist/QueryFilter/QueryFilter.styled.d.ts +0 -89
- package/dist/QueryFilter/QueryFilter.styled.js +0 -184
- package/dist/QueryFilter/QueryFilter.types.js +0 -1
- package/dist/QueryFilter/components/MultiSelectEditor.d.ts +0 -7
- package/dist/QueryFilter/components/MultiSelectEditor.js +0 -44
- package/dist/QueryFilter/components/RuleChip.d.ts +0 -8
- package/dist/QueryFilter/components/RuleChip.js +0 -37
- package/dist/QueryFilter/components/Rules.d.ts +0 -11
- package/dist/QueryFilter/components/Rules.js +0 -41
- package/dist/QueryFilter/components/UnavailableRuleChip.d.ts +0 -5
- package/dist/QueryFilter/components/UnavailableRuleChip.js +0 -7
- package/dist/QueryFilter/components/ValueEditor.d.ts +0 -7
- package/dist/QueryFilter/components/ValueEditor.js +0 -45
- package/dist/QueryFilter/components/ValueSelector.d.ts +0 -7
- package/dist/QueryFilter/components/ValueSelector.js +0 -34
- package/dist/QueryFilter/components/index.d.ts +0 -6
- package/dist/QueryFilter/components/index.js +0 -6
- package/dist/RichTextEditor/Plugins/ImageActionsPlugin.d.ts +0 -3
- package/dist/RichTextEditor/Plugins/ImageActionsPlugin.js +0 -241
- package/dist/SuperDatePicker/SuperDatePicker.constants.d.ts +0 -24
- package/dist/SuperDatePicker/SuperDatePicker.constants.js +0 -30
- package/dist/SuperDatePicker/SuperDatePicker.d.ts +0 -3
- package/dist/SuperDatePicker/SuperDatePicker.js +0 -31
- package/dist/SuperDatePicker/SuperDatePicker.lib.d.ts +0 -17
- package/dist/SuperDatePicker/SuperDatePicker.lib.js +0 -206
- package/dist/SuperDatePicker/SuperDatePicker.styled.d.ts +0 -60
- package/dist/SuperDatePicker/SuperDatePicker.styled.js +0 -256
- package/dist/SuperDatePicker/SuperDatePicker.types.d.ts +0 -48
- package/dist/SuperDatePicker/SuperDatePicker.types.js +0 -1
- package/dist/SuperDatePicker/components/CommonPresetGroups.d.ts +0 -7
- package/dist/SuperDatePicker/components/CommonPresetGroups.js +0 -6
- package/dist/SuperDatePicker/components/EndpointCalendarDropdown.d.ts +0 -10
- package/dist/SuperDatePicker/components/EndpointCalendarDropdown.js +0 -9
- package/dist/SuperDatePicker/components/EndpointDateInput.d.ts +0 -16
- package/dist/SuperDatePicker/components/EndpointDateInput.js +0 -26
- package/dist/SuperDatePicker/components/EndpointPopover.d.ts +0 -18
- package/dist/SuperDatePicker/components/EndpointPopover.js +0 -11
- package/dist/SuperDatePicker/components/QuickRangeDropdown.d.ts +0 -14
- package/dist/SuperDatePicker/components/QuickRangeDropdown.js +0 -19
- package/dist/SuperDatePicker/components/QuickRangePopover.d.ts +0 -18
- package/dist/SuperDatePicker/components/QuickRangePopover.js +0 -12
- package/dist/SuperDatePicker/components/index.d.ts +0 -6
- package/dist/SuperDatePicker/components/index.js +0 -6
- package/dist/SuperDatePicker/index.d.ts +0 -3
- package/dist/SuperDatePicker/index.js +0 -3
- package/dist/SuperDatePicker/useSuperDatePicker.d.ts +0 -32
- package/dist/SuperDatePicker/useSuperDatePicker.js +0 -125
- /package/dist/{Charts/BarChart/BarChart.types.js → QueryFilter/types.js} +0 -0
package/dist/TagBox/TagBox.js
CHANGED
|
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
13
|
import styled from "styled-components";
|
|
14
14
|
import { useFloating, flip, offset, autoUpdate, FloatingPortal, } from "@floating-ui/react";
|
|
15
|
-
import { useCallback, useEffect, useRef, useState, } from "react";
|
|
15
|
+
import { useCallback, useEffect, useMemo, useRef, useState, } from "react";
|
|
16
16
|
import { Input, Tooltip, FieldLabel, Pill, Loader } from "..";
|
|
17
17
|
import { ArrowButton, ClearButton, StyledFloatContainer, StyledContent, getControlSizeTokens, } from "../core";
|
|
18
18
|
const StyledInputContainer = styled.div `
|
|
@@ -29,7 +29,17 @@ const StyledInputContainer = styled.div `
|
|
|
29
29
|
pointer-events: all;
|
|
30
30
|
outline: none;
|
|
31
31
|
|
|
32
|
-
padding: ${({ size }) =>
|
|
32
|
+
padding: ${({ size }) => size === "xs"
|
|
33
|
+
? "2px 8px"
|
|
34
|
+
: size === "sm"
|
|
35
|
+
? "4px 10px"
|
|
36
|
+
: size === "md"
|
|
37
|
+
? "6px 12px"
|
|
38
|
+
: size === "lg"
|
|
39
|
+
? "7px 14px"
|
|
40
|
+
: size === "xl"
|
|
41
|
+
? "8px 16px"
|
|
42
|
+
: "4px 10px"};
|
|
33
43
|
|
|
34
44
|
border-radius: 5px;
|
|
35
45
|
transition: border 0.1s ease-in-out;
|
|
@@ -48,13 +58,33 @@ const StyledInputContainer = styled.div `
|
|
|
48
58
|
}};
|
|
49
59
|
font-weight: 500;
|
|
50
60
|
color: ${(props) => props.theme.palette.text.primary};
|
|
51
|
-
font-size: ${({ size }) =>
|
|
61
|
+
font-size: ${({ size }) => size === "xs"
|
|
62
|
+
? "12px"
|
|
63
|
+
: size === "sm"
|
|
64
|
+
? "14px"
|
|
65
|
+
: size === "md"
|
|
66
|
+
? "16px"
|
|
67
|
+
: size === "lg"
|
|
68
|
+
? "18px"
|
|
69
|
+
: size === "xl"
|
|
70
|
+
? "20px"
|
|
71
|
+
: "12px"};
|
|
52
72
|
|
|
53
73
|
width: 100%;
|
|
54
|
-
min-height: ${({ size }) =>
|
|
74
|
+
min-height: ${({ size }) => size === "xs"
|
|
75
|
+
? "26px"
|
|
76
|
+
: size === "sm"
|
|
77
|
+
? "30px"
|
|
78
|
+
: size === "md"
|
|
79
|
+
? "36px"
|
|
80
|
+
: size === "lg"
|
|
81
|
+
? "42px"
|
|
82
|
+
: size === "xl"
|
|
83
|
+
? "50px"
|
|
84
|
+
: "26px"};
|
|
55
85
|
|
|
56
86
|
&[data-button-right="true"] {
|
|
57
|
-
padding-right:
|
|
87
|
+
padding-right: 36px;
|
|
58
88
|
}
|
|
59
89
|
|
|
60
90
|
background-color: ${({ theme, variant }) => {
|
|
@@ -169,8 +199,17 @@ const GroupTitle = styled((_a) => {
|
|
|
169
199
|
|
|
170
200
|
color: ${(props) => props.theme.palette.text.secondary};
|
|
171
201
|
|
|
172
|
-
|
|
173
|
-
|
|
202
|
+
padding: ${({ size }) => size === "xs"
|
|
203
|
+
? "2px 8px"
|
|
204
|
+
: size === "sm"
|
|
205
|
+
? "4px 10px"
|
|
206
|
+
: size === "md"
|
|
207
|
+
? "4px 12px"
|
|
208
|
+
: size === "lg"
|
|
209
|
+
? "5px 14px"
|
|
210
|
+
: size === "xl"
|
|
211
|
+
? "6px 16px"
|
|
212
|
+
: "2px 8px"};
|
|
174
213
|
|
|
175
214
|
.group-label {
|
|
176
215
|
white-space: nowrap;
|
|
@@ -181,7 +220,17 @@ const GroupTitle = styled((_a) => {
|
|
|
181
220
|
|
|
182
221
|
font-weight: 500;
|
|
183
222
|
|
|
184
|
-
font-size: ${({ size }) =>
|
|
223
|
+
font-size: ${({ size }) => size === "xs"
|
|
224
|
+
? "11px"
|
|
225
|
+
: size === "sm"
|
|
226
|
+
? "13px"
|
|
227
|
+
: size === "md"
|
|
228
|
+
? "15px"
|
|
229
|
+
: size === "lg"
|
|
230
|
+
? "17px"
|
|
231
|
+
: size === "xl"
|
|
232
|
+
? "19px"
|
|
233
|
+
: "11px"};
|
|
185
234
|
}
|
|
186
235
|
|
|
187
236
|
.group-line {
|
|
@@ -192,7 +241,7 @@ const GroupTitle = styled((_a) => {
|
|
|
192
241
|
const PillContainer = styled.div `
|
|
193
242
|
display: flex;
|
|
194
243
|
align-items: center;
|
|
195
|
-
gap:
|
|
244
|
+
gap: 5px;
|
|
196
245
|
flex-wrap: wrap;
|
|
197
246
|
flex-grow: 1;
|
|
198
247
|
|
|
@@ -206,27 +255,35 @@ const StyledInnerContainer = styled.div `
|
|
|
206
255
|
width: 100%;
|
|
207
256
|
|
|
208
257
|
&[data-button-right="true"] {
|
|
209
|
-
padding-right:
|
|
258
|
+
padding-right: 30px;
|
|
210
259
|
}
|
|
211
260
|
`;
|
|
212
261
|
const StyledItem = styled.div `
|
|
213
262
|
line-height: 1;
|
|
214
263
|
color: ${(props) => props.theme.palette.text.primary};
|
|
215
264
|
border-radius: 3px;
|
|
216
|
-
box-sizing: border-box;
|
|
217
265
|
display: flex;
|
|
218
266
|
align-items: center;
|
|
219
|
-
min-height:
|
|
220
|
-
|
|
267
|
+
min-height: 25px;
|
|
268
|
+
padding: 7px 10px;
|
|
221
269
|
position: relative;
|
|
222
270
|
user-select: none;
|
|
223
271
|
outline: none;
|
|
224
272
|
|
|
225
273
|
cursor: pointer;
|
|
226
274
|
|
|
227
|
-
font-family:
|
|
228
|
-
font-size: ${({ size }) =>
|
|
229
|
-
|
|
275
|
+
font-family: "Arial", sans-serif;
|
|
276
|
+
font-size: ${({ size }) => size === "xs"
|
|
277
|
+
? "11px"
|
|
278
|
+
: size === "sm"
|
|
279
|
+
? "13px"
|
|
280
|
+
: size === "md"
|
|
281
|
+
? "15px"
|
|
282
|
+
: size === "lg"
|
|
283
|
+
? "17px"
|
|
284
|
+
: size === "xl"
|
|
285
|
+
? "19px"
|
|
286
|
+
: "11px"};
|
|
230
287
|
|
|
231
288
|
&:hover {
|
|
232
289
|
background-color: ${(props) => props.theme.palette.action.hover};
|
|
@@ -249,6 +306,43 @@ const StyledItem = styled.div `
|
|
|
249
306
|
pointer-events: none;
|
|
250
307
|
}
|
|
251
308
|
`;
|
|
309
|
+
const SelectAllItem = styled.button `
|
|
310
|
+
position: sticky;
|
|
311
|
+
top: 0;
|
|
312
|
+
z-index: 1;
|
|
313
|
+
|
|
314
|
+
display: flex;
|
|
315
|
+
align-items: center;
|
|
316
|
+
width: 100%;
|
|
317
|
+
cursor: pointer;
|
|
318
|
+
user-select: none;
|
|
319
|
+
box-sizing: border-box;
|
|
320
|
+
min-height: ${({ size }) => `${getControlSizeTokens(size).menuRowHeight + 4}px`};
|
|
321
|
+
padding: 0 ${({ size }) => `${getControlSizeTokens(size).menuItemPaddingX}px`};
|
|
322
|
+
margin-bottom: 4px;
|
|
323
|
+
border: 0;
|
|
324
|
+
border-bottom: 1px solid ${(props) => props.theme.palette.divider};
|
|
325
|
+
background-color: ${(props) => props.theme.palette.input.background};
|
|
326
|
+
font-family: ${({ theme }) => theme.typography.fontFamily};
|
|
327
|
+
font-size: ${({ size }) => `${getControlSizeTokens(size).fontSize}px`};
|
|
328
|
+
color: ${(props) => props.theme.palette.text.primary};
|
|
329
|
+
text-align: left;
|
|
330
|
+
appearance: none;
|
|
331
|
+
|
|
332
|
+
&:hover {
|
|
333
|
+
background-color: ${(props) => props.theme.palette.action.hover};
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
&:focus {
|
|
337
|
+
outline: none;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
&:focus-visible {
|
|
341
|
+
background-color: ${(props) => props.theme.palette.action.hover};
|
|
342
|
+
outline: 2px solid ${(props) => props.theme.palette.primary.main};
|
|
343
|
+
outline-offset: -2px;
|
|
344
|
+
}
|
|
345
|
+
`;
|
|
252
346
|
const EmptyComponent = styled.div `
|
|
253
347
|
display: flex;
|
|
254
348
|
align-items: center;
|
|
@@ -284,7 +378,7 @@ const resolveValues = (value, data) => {
|
|
|
284
378
|
}
|
|
285
379
|
return resolvedValues;
|
|
286
380
|
};
|
|
287
|
-
const TagBox = styled(({ className, data = [], placeholder = "Select tags", arrow = true, defaultValue, value, grouped, searchFn, onChange, onScroll, onSearch, onItemAdded, size = "sm", variant = "outlined", width = "100%", allowCustomValue = false, searchable = false, clearable = false, openOnFocus = true, label, description, required = false, error, loading = false, sort = false, disabled = false,
|
|
381
|
+
const TagBox = styled(({ className, data = [], placeholder = "Select tags", arrow = true, defaultValue, value, grouped, searchFn, onChange, onScroll, onSearch, onItemAdded, size = "sm", variant = "outlined", width = "100%", allowCustomValue = false, searchable = false, clearable = false, enableSelectAll = false, maxDisplayed, openOnFocus = true, label, description, required = false, error, loading = false, sort = false, disabled = false, renderOption, renderTag, OptionTooltip, DropDownProps = {}, }) => {
|
|
288
382
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
289
383
|
const isObjectArray = (_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.hasOwnProperty("label");
|
|
290
384
|
const isControlled = value !== undefined;
|
|
@@ -292,15 +386,19 @@ const TagBox = styled(({ className, data = [], placeholder = "Select tags", arro
|
|
|
292
386
|
* Resolve the options to a consistent format
|
|
293
387
|
* also remove duplicates
|
|
294
388
|
*/
|
|
295
|
-
const resolvedOptions = Array.from(new Map(data
|
|
389
|
+
const resolvedOptions = useMemo(() => Array.from(new Map(data
|
|
296
390
|
.map((item) => ({
|
|
297
|
-
value: isObjectArray
|
|
298
|
-
|
|
391
|
+
value: isObjectArray
|
|
392
|
+
? item.value
|
|
393
|
+
: item,
|
|
394
|
+
label: isObjectArray
|
|
395
|
+
? item.label
|
|
396
|
+
: item,
|
|
299
397
|
group: isObjectArray ? item.group : undefined,
|
|
300
398
|
disabled: isObjectArray ? item.disabled : undefined,
|
|
301
399
|
data: isObjectArray ? item.data : undefined,
|
|
302
400
|
}))
|
|
303
|
-
.map((item) => [item.value, item])).values());
|
|
401
|
+
.map((item) => [item.value, item])).values()), [data, isObjectArray]);
|
|
304
402
|
/**
|
|
305
403
|
* Get the correct option if the default value is a string
|
|
306
404
|
* otherwise, use the default value as is
|
|
@@ -374,6 +472,36 @@ const TagBox = styled(({ className, data = [], placeholder = "Select tags", arro
|
|
|
374
472
|
}))
|
|
375
473
|
.sort((a, b) => a.label.localeCompare(b.label))
|
|
376
474
|
: [];
|
|
475
|
+
const selectableMatchingItems = useMemo(() => resolvedOptions
|
|
476
|
+
.concat(customItems)
|
|
477
|
+
.filter((item) => !item.disabled)
|
|
478
|
+
.filter((item) => item.label.toLowerCase().includes(searchValue.toLowerCase())), [resolvedOptions, customItems, searchValue]);
|
|
479
|
+
const selectedValueKeys = useMemo(() => new Set(_value.map((v) => v.value)), [_value]);
|
|
480
|
+
const selectedMatchingCount = selectableMatchingItems.filter((item) => selectedValueKeys.has(item.value)).length;
|
|
481
|
+
const allMatchingSelected = selectableMatchingItems.length > 0 &&
|
|
482
|
+
selectedMatchingCount === selectableMatchingItems.length;
|
|
483
|
+
const handleToggleSelectAll = useCallback(() => {
|
|
484
|
+
if (selectableMatchingItems.length === 0)
|
|
485
|
+
return;
|
|
486
|
+
if (allMatchingSelected) {
|
|
487
|
+
const matchingKeys = new Set(selectableMatchingItems.map((i) => i.value));
|
|
488
|
+
const next = _value.filter((v) => !matchingKeys.has(v.value));
|
|
489
|
+
!isControlled && setValueState(next);
|
|
490
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(next.map((v) => v.value), next);
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
const toAdd = selectableMatchingItems.filter((item) => !selectedValueKeys.has(item.value));
|
|
494
|
+
const next = [..._value, ...toAdd];
|
|
495
|
+
!isControlled && setValueState(next);
|
|
496
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(next.map((v) => v.value), next);
|
|
497
|
+
}, [
|
|
498
|
+
selectableMatchingItems,
|
|
499
|
+
allMatchingSelected,
|
|
500
|
+
selectedValueKeys,
|
|
501
|
+
_value,
|
|
502
|
+
isControlled,
|
|
503
|
+
onChange,
|
|
504
|
+
]);
|
|
377
505
|
const { refs, floatingStyles, update } = useFloating({
|
|
378
506
|
open: isOpen,
|
|
379
507
|
onOpenChange: setIsOpen,
|
|
@@ -396,7 +524,7 @@ const TagBox = styled(({ className, data = [], placeholder = "Select tags", arro
|
|
|
396
524
|
});
|
|
397
525
|
};
|
|
398
526
|
const handleClear = (e) => {
|
|
399
|
-
e.preventDefault();
|
|
527
|
+
e === null || e === void 0 ? void 0 : e.preventDefault();
|
|
400
528
|
if (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current)
|
|
401
529
|
inputRef.current.value = "";
|
|
402
530
|
onChange === null || onChange === void 0 ? void 0 : onChange([]);
|
|
@@ -462,18 +590,24 @@ const TagBox = styled(({ className, data = [], placeholder = "Select tags", arro
|
|
|
462
590
|
customItems,
|
|
463
591
|
]);
|
|
464
592
|
const handleKeyDown = (e) => {
|
|
465
|
-
var _a, _b;
|
|
593
|
+
var _a, _b, _c;
|
|
466
594
|
const currentInputValue = (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.value;
|
|
595
|
+
// When focus is inside the floating dropdown (e.g., on the Select All
|
|
596
|
+
// button), let that element handle its own activation rather than the
|
|
597
|
+
// container-level routing meant for the input.
|
|
598
|
+
const target = e.target;
|
|
599
|
+
const floatingElement = (_b = refs === null || refs === void 0 ? void 0 : refs.floating) === null || _b === void 0 ? void 0 : _b.current;
|
|
600
|
+
const focusInsideDropdown = !!floatingElement && floatingElement.contains(target);
|
|
467
601
|
// Escape key
|
|
468
602
|
if (e.key === "Escape") {
|
|
469
|
-
const reference = (
|
|
603
|
+
const reference = (_c = refs === null || refs === void 0 ? void 0 : refs.reference) === null || _c === void 0 ? void 0 : _c.current;
|
|
470
604
|
reference === null || reference === void 0 ? void 0 : reference.blur();
|
|
471
605
|
setSearchValue("");
|
|
472
606
|
update();
|
|
473
607
|
setIsOpen(false);
|
|
474
608
|
}
|
|
475
609
|
// Enter key
|
|
476
|
-
if (e.key === "Enter") {
|
|
610
|
+
if (e.key === "Enter" && !focusInsideDropdown) {
|
|
477
611
|
if (preSelected) {
|
|
478
612
|
handleItemClick(preSelected);
|
|
479
613
|
setPreSelected(undefined);
|
|
@@ -497,13 +631,15 @@ const TagBox = styled(({ className, data = [], placeholder = "Select tags", arro
|
|
|
497
631
|
// setIsOpen(false);
|
|
498
632
|
}
|
|
499
633
|
// Backspace key
|
|
500
|
-
if (e.key === "Backspace" &&
|
|
634
|
+
if (e.key === "Backspace" &&
|
|
635
|
+
currentInputValue === "" &&
|
|
636
|
+
!focusInsideDropdown) {
|
|
501
637
|
const newItems = _value === null || _value === void 0 ? void 0 : _value.slice(0, _value.length - 1);
|
|
502
638
|
!isControlled && setValueState(newItems);
|
|
503
639
|
onChange === null || onChange === void 0 ? void 0 : onChange(newItems.map((v) => v.value), newItems);
|
|
504
640
|
}
|
|
505
641
|
// Arrow down
|
|
506
|
-
if (e.key === "ArrowDown") {
|
|
642
|
+
if (e.key === "ArrowDown" && !focusInsideDropdown) {
|
|
507
643
|
e.preventDefault();
|
|
508
644
|
setPreSelected((prev) => {
|
|
509
645
|
let newItem = filteredItems[0]; // Loop back to the first item
|
|
@@ -521,7 +657,7 @@ const TagBox = styled(({ className, data = [], placeholder = "Select tags", arro
|
|
|
521
657
|
});
|
|
522
658
|
}
|
|
523
659
|
// Arrow up
|
|
524
|
-
if (e.key === "ArrowUp") {
|
|
660
|
+
if (e.key === "ArrowUp" && !focusInsideDropdown) {
|
|
525
661
|
e.preventDefault();
|
|
526
662
|
setPreSelected((prev) => {
|
|
527
663
|
let newItem = filteredItems[filteredItems.length - 1]; // Loop back to the last item
|
|
@@ -541,9 +677,15 @@ const TagBox = styled(({ className, data = [], placeholder = "Select tags", arro
|
|
|
541
677
|
return newItem;
|
|
542
678
|
});
|
|
543
679
|
}
|
|
544
|
-
// Tab key
|
|
680
|
+
// Tab key — close when the user is tabbing out of the dropdown itself,
|
|
681
|
+
// or when no focusable element exists inside it. Otherwise leave it open
|
|
682
|
+
// so FloatingPortal's preserveTabOrder can route focus to the Select All
|
|
683
|
+
// button.
|
|
545
684
|
if (e.key === "Tab") {
|
|
546
|
-
|
|
685
|
+
const hasFocusableContent = enableSelectAll && selectableMatchingItems.length > 0;
|
|
686
|
+
if (focusInsideDropdown || !hasFocusableContent) {
|
|
687
|
+
setIsOpen(false);
|
|
688
|
+
}
|
|
547
689
|
}
|
|
548
690
|
};
|
|
549
691
|
// handle scroll item into view
|
|
@@ -585,7 +727,14 @@ const TagBox = styled(({ className, data = [], placeholder = "Select tags", arro
|
|
|
585
727
|
return (_jsxs("div", { className: className + " mfTagBox", children: [label && (_jsx(FieldLabel, { error: error, asterisk: required, size: size, description: description, children: label })), _jsxs(StyledInputContainer, { className: "styledInputContainer", ref: refs.setReference, onMouseDown: () => {
|
|
586
728
|
setIsOpen(true);
|
|
587
729
|
handleFocus();
|
|
588
|
-
}, onFocus: handleFocus, size: size, variant: variant, onKeyDown: handleKeyDown, "data-open": isOpen, "data-disabled": disabled, tabIndex: 0, children: [_jsx(StyledInnerContainer, { size: size, "data-button-right": arrow || clearable, children: _jsxs(PillContainer, { size: size, children: [
|
|
730
|
+
}, onFocus: handleFocus, size: size, variant: variant, onKeyDown: handleKeyDown, "data-open": isOpen, "data-disabled": disabled, tabIndex: 0, children: [_jsx(StyledInnerContainer, { size: size, "data-button-right": arrow || clearable, children: _jsxs(PillContainer, { size: size, children: [(() => {
|
|
731
|
+
const shouldTruncate = maxDisplayed != null && _value.length > maxDisplayed;
|
|
732
|
+
const displayedItems = shouldTruncate
|
|
733
|
+
? _value.slice(0, maxDisplayed)
|
|
734
|
+
: _value;
|
|
735
|
+
const overflowCount = _value.length - displayedItems.length;
|
|
736
|
+
return (_jsxs(_Fragment, { children: [displayedItems.map((item, index) => (_jsx(Pill, { size: "xs", onRemove: () => handleRemoveItem(item), children: (renderTag === null || renderTag === void 0 ? void 0 : renderTag(item)) || _jsx(_Fragment, { children: item === null || item === void 0 ? void 0 : item.label }) }, index))), overflowCount > 0 && (_jsxs(Pill, { size: "xs", showRemoveIcon: false, children: ["+", overflowCount, " more..."] }))] }));
|
|
737
|
+
})(), (searchable || allowCustomValue || (_value === null || _value === void 0 ? void 0 : _value.length) === 0) && (_jsx(StyledInput, { inputRef: inputRef, onChange: (e) => {
|
|
589
738
|
if (searchFn !== undefined) {
|
|
590
739
|
searchFn === null || searchFn === void 0 ? void 0 : searchFn(e.target.value);
|
|
591
740
|
}
|
|
@@ -594,10 +743,10 @@ const TagBox = styled(({ className, data = [], placeholder = "Select tags", arro
|
|
|
594
743
|
}
|
|
595
744
|
update();
|
|
596
745
|
}, placeholder: placeholder, size: size, readOnly: !(searchable || allowCustomValue), "data-disabled": disabled }))] }) }), clearable &&
|
|
597
|
-
(((_f = _value === null || _value === void 0 ? void 0 : _value.length) !== null && _f !== void 0 ? _f : 0) > 0 || !!((_g = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _g === void 0 ? void 0 : _g.value)) ? (_jsx(ClearButton, {
|
|
746
|
+
(((_f = _value === null || _value === void 0 ? void 0 : _value.length) !== null && _f !== void 0 ? _f : 0) > 0 || !!((_g = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _g === void 0 ? void 0 : _g.value)) ? (_jsx(ClearButton, { onClick: handleClear, onMouseDown: (e) => {
|
|
598
747
|
e.preventDefault();
|
|
599
748
|
e.stopPropagation();
|
|
600
|
-
} })) : arrow ? (_jsx(ArrowButton, {
|
|
749
|
+
} })) : arrow ? (_jsx(ArrowButton, { onClick: (e) => {
|
|
601
750
|
e.preventDefault();
|
|
602
751
|
}, onMouseDown: (e) => {
|
|
603
752
|
e.preventDefault();
|
|
@@ -612,23 +761,32 @@ const TagBox = styled(({ className, data = [], placeholder = "Select tags", arro
|
|
|
612
761
|
maxHeight: DropDownProps.autoHeight
|
|
613
762
|
? (dropDownHeight || 250) - 10
|
|
614
763
|
: "",
|
|
615
|
-
}, variant: variant, "data-empty": filteredItems.length === 0 }, DropDownProps, { children: [loading && _jsx(Loader, {}), !loading &&
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
764
|
+
}, variant: variant, "data-empty": filteredItems.length === 0 }, DropDownProps, { children: [loading && _jsx(Loader, {}), !loading &&
|
|
765
|
+
filteredItems.length === 0 &&
|
|
766
|
+
!(enableSelectAll && selectableMatchingItems.length > 0) && (_jsx(EmptyComponent, { children: "No Items" })), !loading && (_jsxs(StyledInnerItemContainer, { ref: scrollContainerRef, "data-scroll-active": scrollActive, onScroll: onScroll, children: [enableSelectAll && selectableMatchingItems.length > 0 && (_jsx(SelectAllItem, { type: "button", size: size, onMouseDown: (e) => {
|
|
767
|
+
e.preventDefault();
|
|
768
|
+
e.stopPropagation();
|
|
769
|
+
}, onClick: (e) => {
|
|
770
|
+
e.preventDefault();
|
|
771
|
+
e.stopPropagation();
|
|
772
|
+
handleToggleSelectAll();
|
|
773
|
+
}, children: allMatchingSelected ? "Deselect all" : "Select all" })), grouped
|
|
774
|
+
? groups.map((group) => (_jsxs("div", { children: [_jsx(GroupTitle, { size: size, children: group.label }), group.items.map((item, index) => {
|
|
775
|
+
return (_jsx(Tooltip, { content: OptionTooltip ? (_jsx(OptionTooltip, { data: item.data })) : null, side: "left", children: _jsx(StyledItem, { className: "mfFloatingItem", onClick: (e) => {
|
|
776
|
+
e.preventDefault();
|
|
777
|
+
e.stopPropagation();
|
|
778
|
+
handleItemClick(item);
|
|
779
|
+
}, "data-highlighted": (preSelected === null || preSelected === void 0 ? void 0 : preSelected.value) === item.value, "data-disabled": item.disabled, size: size, children: (renderOption === null || renderOption === void 0 ? void 0 : renderOption(item)) || (_jsx(_Fragment, { children: typeof item === "string"
|
|
780
|
+
? item
|
|
781
|
+
: item === null || item === void 0 ? void 0 : item.label })) }, index) }, index));
|
|
782
|
+
})] }, group.label)))
|
|
783
|
+
: filteredItems.map((item, index) => {
|
|
784
|
+
return (_jsx(Tooltip, { content: OptionTooltip ? (_jsx(OptionTooltip, { data: item.data })) : null, side: "left", children: _jsx(StyledItem, { className: "mfFloatingItem", onClick: (e) => {
|
|
785
|
+
e.preventDefault();
|
|
786
|
+
e.stopPropagation();
|
|
787
|
+
handleItemClick(item);
|
|
788
|
+
}, "data-highlighted": (preSelected === null || preSelected === void 0 ? void 0 : preSelected.value) === item.value, "data-disabled": item.disabled, size: size, children: (renderOption === null || renderOption === void 0 ? void 0 : renderOption(item)) || _jsx(_Fragment, { children: item === null || item === void 0 ? void 0 : item.label }) }, index) }, index));
|
|
789
|
+
})] }))] })) }) }))] }));
|
|
632
790
|
}) `
|
|
633
791
|
position: relative;
|
|
634
792
|
cursor: pointer;
|
package/dist/TagBox/types.d.ts
CHANGED
|
@@ -22,6 +22,19 @@ export interface TagBoxProps {
|
|
|
22
22
|
allowCustomValue?: boolean;
|
|
23
23
|
searchable?: boolean;
|
|
24
24
|
clearable?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Adds a sticky "Select all" / "Deselect all" button at the top of the
|
|
27
|
+
* dropdown. The button operates on the currently visible (search-filtered,
|
|
28
|
+
* non-disabled) options — not the full dataset. When a search filter is
|
|
29
|
+
* active, only items matching the filter are toggled.
|
|
30
|
+
*/
|
|
31
|
+
enableSelectAll?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Maximum number of selected tags to render as Pills. When the selection
|
|
34
|
+
* exceeds this number, the overflow is summarized as a non-removable
|
|
35
|
+
* "+{count} more..." indicator. Omit to render every selected tag.
|
|
36
|
+
*/
|
|
37
|
+
maxDisplayed?: number;
|
|
25
38
|
label?: string;
|
|
26
39
|
description?: ReactNode;
|
|
27
40
|
required?: boolean;
|
|
@@ -32,7 +45,6 @@ export interface TagBoxProps {
|
|
|
32
45
|
debounceTime?: number;
|
|
33
46
|
sort?: boolean;
|
|
34
47
|
disabled?: boolean;
|
|
35
|
-
dynamicOptionHeight?: boolean;
|
|
36
48
|
renderOption?: (item: Option | string) => React.ReactNode;
|
|
37
49
|
renderTag?: (item: Option | string) => React.ReactNode;
|
|
38
50
|
OptionTooltip?: (props: {
|
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
2
|
import TextareaAutosize from "react-textarea-autosize";
|
|
3
|
-
import { getControlSizeTokens } from "../core";
|
|
4
3
|
const TextArea = styled(TextareaAutosize) `
|
|
5
4
|
outline: none;
|
|
6
5
|
resize: none;
|
|
7
|
-
padding:
|
|
6
|
+
padding: 10px;
|
|
8
7
|
width: 100%;
|
|
9
8
|
height: 100%;
|
|
10
9
|
box-sizing: border-box;
|
|
11
10
|
|
|
12
11
|
font-family: ${({ theme }) => theme.typography.fontFamily};
|
|
13
12
|
color: ${(props) => props.theme.palette.text.primary};
|
|
14
|
-
font-size: ${({ size }) =>
|
|
13
|
+
font-size: ${({ size }) => size === "xs"
|
|
14
|
+
? "11px"
|
|
15
|
+
: size === "sm"
|
|
16
|
+
? "13px"
|
|
17
|
+
: size === "md"
|
|
18
|
+
? "15px"
|
|
19
|
+
: size === "lg"
|
|
20
|
+
? "17px"
|
|
21
|
+
: size === "xl"
|
|
22
|
+
? "19px"
|
|
23
|
+
: "13px"};
|
|
15
24
|
|
|
16
25
|
background-color: ${({ theme, variant }) => {
|
|
17
26
|
switch (variant) {
|
|
@@ -50,13 +59,18 @@ const TextArea = styled(TextareaAutosize) `
|
|
|
50
59
|
border: 1px solid ${(props) => props.theme.palette.primary.main};
|
|
51
60
|
}
|
|
52
61
|
|
|
53
|
-
&[disabled] {
|
|
54
|
-
cursor: not-allowed;
|
|
55
|
-
opacity: 0.5;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
62
|
::placeholder {
|
|
59
|
-
font-size: ${({ size }) =>
|
|
63
|
+
font-size: ${({ size }) => size === "xs"
|
|
64
|
+
? "10px"
|
|
65
|
+
: size === "sm"
|
|
66
|
+
? "12px"
|
|
67
|
+
: size === "md"
|
|
68
|
+
? "14px"
|
|
69
|
+
: size === "lg"
|
|
70
|
+
? "16px"
|
|
71
|
+
: size === "xl"
|
|
72
|
+
? "18px"
|
|
73
|
+
: "12px"};
|
|
60
74
|
}
|
|
61
75
|
`;
|
|
62
76
|
export default TextArea;
|
|
@@ -13,7 +13,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import styled from "styled-components";
|
|
14
14
|
import { FieldLabel } from "..";
|
|
15
15
|
import Input from "../Input/Input";
|
|
16
|
-
import { getControlSizeTokens } from "../core";
|
|
17
16
|
import { forwardRef, useState } from "react";
|
|
18
17
|
import { Eye, EyeOff, X } from "lucide-react";
|
|
19
18
|
const StyledContainer = styled.div `
|
|
@@ -36,9 +35,7 @@ const InputContainer = styled.div `
|
|
|
36
35
|
`;
|
|
37
36
|
const InputButton = styled.button `
|
|
38
37
|
position: absolute;
|
|
39
|
-
right:
|
|
40
|
-
width: ${({ size }) => `${getControlSizeTokens(size).adornmentWidth}px`};
|
|
41
|
-
height: 100%;
|
|
38
|
+
right: 8px;
|
|
42
39
|
background: none;
|
|
43
40
|
border: none;
|
|
44
41
|
cursor: pointer;
|
|
@@ -61,8 +58,8 @@ const InputButton = styled.button `
|
|
|
61
58
|
}
|
|
62
59
|
|
|
63
60
|
svg {
|
|
64
|
-
width:
|
|
65
|
-
height:
|
|
61
|
+
width: 16px;
|
|
62
|
+
height: 16px;
|
|
66
63
|
}
|
|
67
64
|
`;
|
|
68
65
|
export const TextInput = forwardRef((_a, ref) => {
|
|
@@ -80,14 +77,11 @@ export const TextInput = forwardRef((_a, ref) => {
|
|
|
80
77
|
};
|
|
81
78
|
// Enhanced features: password or clearable functionality
|
|
82
79
|
const inputType = password && !passwordVisible ? "password" : type || "text";
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
? { paddingRight: `${adornmentWidth}px` }
|
|
86
|
-
: {}));
|
|
87
|
-
return (_jsxs(StyledContainer, { className: className, colSpan: colSpan, children: [label && (_jsx(FieldLabel, { error: error, asterisk: required, size: size, description: description, children: label })), _jsxs(InputContainer, { children: [_jsx(Input, Object.assign({ ref: ref, value: value, size: size, type: inputType, style: inputStyle }, inputProps, rest)), password ? (_jsx(InputButton, { size: size, onClick: handlePasswordToggle, onMouseDown: (e) => {
|
|
80
|
+
const inputStyle = Object.assign(Object.assign({}, style), (password || (clearable && value) ? { paddingRight: "36px" } : {}));
|
|
81
|
+
return (_jsxs(StyledContainer, { className: className, colSpan: colSpan, children: [label && (_jsx(FieldLabel, { error: error, asterisk: required, size: size, description: description, children: label })), _jsxs(InputContainer, { children: [_jsx(Input, Object.assign({ ref: ref, value: value, size: size, type: inputType, style: inputStyle }, inputProps, rest)), password ? (_jsx(InputButton, { onClick: handlePasswordToggle, onMouseDown: (e) => {
|
|
88
82
|
e.preventDefault();
|
|
89
83
|
e.stopPropagation();
|
|
90
|
-
}, tabIndex: -1, type: "button", children: passwordVisible ? _jsx(Eye, {}) : _jsx(EyeOff, {}) })) : clearable && value ? (_jsx(InputButton, {
|
|
84
|
+
}, tabIndex: -1, type: "button", children: passwordVisible ? _jsx(Eye, {}) : _jsx(EyeOff, {}) })) : clearable && value ? (_jsx(InputButton, { onClick: handleClear, onMouseDown: (e) => {
|
|
91
85
|
e.preventDefault();
|
|
92
86
|
e.stopPropagation();
|
|
93
87
|
}, tabIndex: -1, type: "button", children: _jsx(X, {}) })) : null] })] }));
|
|
@@ -7,7 +7,6 @@ import moment from "moment";
|
|
|
7
7
|
// When `timestamp` is empty, segment values fall back to placeholders so the
|
|
8
8
|
// DateInput can still render an editable structure.
|
|
9
9
|
export default function parseTimestamp(timestamp, format, utc = false) {
|
|
10
|
-
var _a;
|
|
11
10
|
// Supported format tokens and how each token maps to a segment type.
|
|
12
11
|
// `momentType` is used by consumers that need to know which unit the
|
|
13
12
|
// segment represents in Moment's terminology.
|
|
@@ -41,7 +40,7 @@ export default function parseTimestamp(timestamp, format, utc = false) {
|
|
|
41
40
|
// Break the format into ordered parts while keeping separators.
|
|
42
41
|
// Example: "MM/DD/YYYY HH:mm" => ["MM", "/", "DD", "/", "YYYY", " ", "HH", ":", "mm"]
|
|
43
42
|
function splitFormat(format) {
|
|
44
|
-
return format.split(/(YYYY|MM|DD|HH|h|mm|ss|SSS|
|
|
43
|
+
return format.split(/(YYYY|MM|DD|HH|h|mm|ss|SSS|Z)/).filter((s) => s);
|
|
45
44
|
}
|
|
46
45
|
// Convert each format part into a known token descriptor.
|
|
47
46
|
// Unknown parts are treated as literal separators.
|
|
@@ -58,19 +57,15 @@ export default function parseTimestamp(timestamp, format, utc = false) {
|
|
|
58
57
|
index: -1,
|
|
59
58
|
};
|
|
60
59
|
}
|
|
61
|
-
const parsedTimestamp = timestamp
|
|
62
|
-
? utc === true
|
|
63
|
-
? moment.utc(timestamp)
|
|
64
|
-
: moment(timestamp)
|
|
65
|
-
: null;
|
|
66
|
-
const hasValidTimestamp = (_a = parsedTimestamp === null || parsedTimestamp === void 0 ? void 0 : parsedTimestamp.isValid()) !== null && _a !== void 0 ? _a : false;
|
|
67
60
|
// Build the final Segment[] in format order.
|
|
68
61
|
// For date/time tokens, format the timestamp using local or UTC mode.
|
|
69
|
-
// For separators (or empty
|
|
62
|
+
// For separators (or empty timestamp), use the placeholder as the value.
|
|
70
63
|
const segments = splitFormat(format).map((segment, i) => {
|
|
71
64
|
const { pattern, placeholder, type, momentType } = matchSegment(segment);
|
|
72
|
-
const value =
|
|
73
|
-
?
|
|
65
|
+
const value = timestamp
|
|
66
|
+
? utc === true
|
|
67
|
+
? moment.utc(timestamp).format(pattern)
|
|
68
|
+
: moment(timestamp).format(pattern)
|
|
74
69
|
: placeholder;
|
|
75
70
|
return {
|
|
76
71
|
value,
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import Size from "./Types/Size";
|
|
2
1
|
interface ArrowButtonProps {
|
|
3
2
|
className?: string;
|
|
4
|
-
size?: Size;
|
|
5
3
|
[key: string]: React.ButtonHTMLAttributes<HTMLButtonElement> | any;
|
|
6
4
|
}
|
|
7
5
|
declare const ArrowButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<ArrowButtonProps, never>> & string & Omit<({ className, ...props }: ArrowButtonProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
|
package/dist/core/ArrowButton.js
CHANGED
|
@@ -12,10 +12,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { ChevronDownIcon } from "lucide-react";
|
|
14
14
|
import styled from "styled-components";
|
|
15
|
-
import { DEFAULT_CONTROL_SIZE, getControlSizeTokens } from "./controlSizes";
|
|
16
15
|
const ArrowIcon = styled((_a) => {
|
|
17
16
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
18
|
-
return (_jsx("div", Object.assign({ className: className }, props, { children: _jsx(ChevronDownIcon, { size:
|
|
17
|
+
return (_jsx("div", Object.assign({ className: className }, props, { children: _jsx(ChevronDownIcon, { size: 16 }) })));
|
|
19
18
|
}) `
|
|
20
19
|
color: ${(props) => props.theme.palette.text.secondary};
|
|
21
20
|
transition: transform 0.2s ease-in-out;
|
|
@@ -29,19 +28,16 @@ const ArrowIcon = styled((_a) => {
|
|
|
29
28
|
`;
|
|
30
29
|
const ArrowButton = styled((_a) => {
|
|
31
30
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
32
|
-
return (_jsx("button", Object.assign({ className: className }, props, { tabIndex: -1, "data-default-btn": true, children: _jsx(ArrowIcon, {
|
|
31
|
+
return (_jsx("button", Object.assign({ className: className }, props, { tabIndex: -1, "data-default-btn": true, children: _jsx(ArrowIcon, {}) })));
|
|
33
32
|
}) `
|
|
34
33
|
position: absolute;
|
|
35
34
|
right: 0;
|
|
36
35
|
height: 100%;
|
|
37
|
-
|
|
36
|
+
padding-inline: 10px;
|
|
38
37
|
background: none;
|
|
39
38
|
border: none;
|
|
40
39
|
cursor: pointer;
|
|
41
40
|
margin: 0;
|
|
42
41
|
outline: none;
|
|
43
|
-
display: flex;
|
|
44
|
-
align-items: center;
|
|
45
|
-
justify-content: center;
|
|
46
42
|
`;
|
|
47
43
|
export default ArrowButton;
|