@monolith-forensics/monolith-ui 1.8.0 → 1.8.1-dev.1
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 +9 -58
- package/dist/Calendar/Calendar.d.ts +3 -1
- package/dist/Calendar/Calendar.js +134 -33
- package/dist/Calendar/CalendarStyles.d.ts +3 -0
- package/dist/Calendar/CalendarStyles.js +92 -14
- package/dist/Calendar/calendarHelpers.d.ts +5 -1
- package/dist/Calendar/calendarHelpers.js +13 -5
- package/dist/Charts/BarChart/BarChart.d.ts +5 -0
- package/dist/Charts/BarChart/BarChart.js +549 -0
- package/dist/Charts/BarChart/BarChart.lib.d.ts +31 -0
- package/dist/Charts/BarChart/BarChart.lib.js +136 -0
- package/dist/Charts/BarChart/BarChart.styled.d.ts +51 -0
- package/dist/Charts/BarChart/BarChart.styled.js +115 -0
- package/dist/Charts/BarChart/BarChart.types.d.ts +171 -0
- package/dist/Charts/BarChart/BarChart.types.js +1 -0
- package/dist/Charts/BarChart/index.d.ts +3 -0
- package/dist/Charts/BarChart/index.js +2 -0
- package/dist/Charts/ChartPrimitives/ChartExportControl.d.ts +11 -0
- package/dist/Charts/ChartPrimitives/ChartExportControl.js +29 -0
- package/dist/Charts/ChartPrimitives/chartActions.styled.d.ts +1 -0
- package/dist/Charts/ChartPrimitives/chartActions.styled.js +8 -0
- package/dist/Charts/ChartPrimitives/chartLegend.styled.d.ts +12 -0
- package/dist/Charts/ChartPrimitives/chartLegend.styled.js +52 -0
- package/dist/Charts/ChartPrimitives/chartTooltip.styled.d.ts +19 -0
- package/dist/Charts/ChartPrimitives/chartTooltip.styled.js +61 -0
- package/dist/Charts/ChartPrimitives/index.d.ts +4 -0
- package/dist/Charts/ChartPrimitives/index.js +4 -0
- package/dist/Charts/ChartUtils/chartColors.d.ts +8 -0
- package/dist/Charts/ChartUtils/chartColors.js +65 -0
- package/dist/Charts/ChartUtils/chartExport.d.ts +47 -0
- package/dist/Charts/ChartUtils/chartExport.js +311 -0
- package/dist/Charts/ChartUtils/chartMath.d.ts +3 -0
- package/dist/Charts/ChartUtils/chartMath.js +3 -0
- package/dist/Charts/ChartUtils/index.d.ts +3 -0
- package/dist/Charts/ChartUtils/index.js +3 -0
- package/dist/Charts/HeatMap/HeatMap.d.ts +5 -0
- package/dist/Charts/HeatMap/HeatMap.js +212 -0
- package/dist/Charts/HeatMap/HeatMap.lib.d.ts +30 -0
- package/dist/Charts/HeatMap/HeatMap.lib.js +115 -0
- package/dist/Charts/HeatMap/HeatMap.styled.d.ts +37 -0
- package/dist/Charts/HeatMap/HeatMap.styled.js +91 -0
- package/dist/Charts/HeatMap/HeatMap.types.d.ts +80 -0
- package/dist/Charts/HeatMap/HeatMap.types.js +1 -0
- package/dist/Charts/HeatMap/index.d.ts +3 -0
- package/dist/Charts/HeatMap/index.js +2 -0
- package/dist/Charts/LineChart/LineChart.d.ts +5 -0
- package/dist/Charts/LineChart/LineChart.js +529 -0
- package/dist/Charts/LineChart/LineChart.lib.d.ts +24 -0
- package/dist/Charts/LineChart/LineChart.lib.js +132 -0
- package/dist/Charts/LineChart/LineChart.styled.d.ts +59 -0
- package/dist/Charts/LineChart/LineChart.styled.js +147 -0
- package/dist/Charts/LineChart/LineChart.types.d.ts +193 -0
- package/dist/Charts/LineChart/LineChart.types.js +1 -0
- package/dist/Charts/LineChart/index.d.ts +3 -0
- package/dist/Charts/LineChart/index.js +2 -0
- package/dist/Charts/PieChart/PieChart.d.ts +4 -0
- package/dist/Charts/PieChart/PieChart.js +199 -0
- package/dist/Charts/PieChart/PieChart.lib.d.ts +5 -0
- package/dist/Charts/PieChart/PieChart.lib.js +19 -0
- package/dist/Charts/PieChart/PieChart.styled.d.ts +51 -0
- package/dist/Charts/PieChart/PieChart.styled.js +163 -0
- package/dist/Charts/PieChart/PieChart.types.d.ts +100 -0
- package/dist/Charts/PieChart/PieChart.types.js +1 -0
- package/dist/Charts/PieChart/index.d.ts +2 -0
- package/dist/Charts/PieChart/index.js +1 -0
- package/dist/Charts/index.d.ts +5 -0
- package/dist/Charts/index.js +4 -0
- package/dist/CheckBox/CheckBox.js +2 -16
- package/dist/DateInput/DateInput.js +198 -143
- package/dist/DropDownMenu/components/MenuComponent.js +2 -1
- package/dist/DropDownMenu/components/MenuItem.js +5 -14
- package/dist/DropDownMenu/components/MenuItemList.js +7 -24
- package/dist/DropDownMenu/components/StyledFloatContainer.js +1 -1
- package/dist/FieldLabel/FieldLabel.js +4 -12
- package/dist/FileInputField/FileInputField.js +4 -23
- package/dist/FormSection/FormSection.js +5 -25
- package/dist/IconButton/IconButton.js +2 -16
- package/dist/Input/Input.js +7 -56
- package/dist/Pill/Pill.js +8 -79
- package/dist/Popover/Popover.context.d.ts +2 -1
- package/dist/Popover/Popover.js +5 -2
- package/dist/Popover/Popover.styles.d.ts +1 -6
- package/dist/Popover/Popover.styles.js +11 -28
- package/dist/Popover/Popover.transitions.d.ts +4 -2
- package/dist/Popover/Popover.transitions.js +23 -49
- package/dist/Popover/PopoverDropdown.js +6 -8
- package/dist/Popover/PopoverTarget.js +6 -3
- package/dist/SegmentedControl/SegmentedControl.utils.d.ts +2 -2
- package/dist/SegmentedControl/SegmentedControl.utils.js +3 -30
- package/dist/SelectBox/SelectBox.js +5 -5
- package/dist/SelectBox/select-box.styled-components.d.ts +4 -1
- package/dist/SelectBox/select-box.styled-components.js +11 -48
- package/dist/SelectBox/types.d.ts +1 -0
- package/dist/Switch/Switch.d.ts +2 -2
- package/dist/Switch/Switch.js +18 -83
- package/dist/Table/StateStorage.d.ts +4 -0
- package/dist/Table/StateStorage.js +13 -0
- package/dist/Table/Table.js +160 -12
- package/dist/Table/TableComponents.d.ts +10 -0
- package/dist/Table/TableComponents.js +57 -0
- package/dist/Table/TableDefaults.d.ts +7 -0
- package/dist/Table/TableDefaults.js +7 -0
- package/dist/Table/TableProvider.js +263 -71
- package/dist/Table/TableRow.js +15 -10
- package/dist/Table/types.d.ts +64 -0
- package/dist/TagBox/TagBox.js +18 -76
- package/dist/TextArea/TextArea.js +4 -23
- package/dist/TextInput/TextInput.js +12 -6
- package/dist/Utilities/parseTimestamp.js +11 -6
- package/dist/core/ArrowButton.d.ts +2 -0
- package/dist/core/ArrowButton.js +7 -3
- package/dist/core/ClearButton.d.ts +2 -0
- package/dist/core/ClearButton.js +7 -3
- package/dist/core/controlSizes.d.ts +34 -0
- package/dist/core/controlSizes.js +190 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +5 -1
package/dist/Table/types.d.ts
CHANGED
|
@@ -10,6 +10,42 @@ export type StateStorage = {
|
|
|
10
10
|
type: "localStorage";
|
|
11
11
|
key: string;
|
|
12
12
|
};
|
|
13
|
+
export type TreeMode = "nested" | "flat";
|
|
14
|
+
export type TreeOptions = {
|
|
15
|
+
/** Enable tree-row behavior. Default: false */
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
/** Input shape. Default: "nested" */
|
|
18
|
+
mode?: TreeMode;
|
|
19
|
+
/** For mode="nested": field name that holds child array. Default: "children" */
|
|
20
|
+
childrenField?: string;
|
|
21
|
+
/** For mode="flat": field name that holds parent id. Default: "parentId" */
|
|
22
|
+
parentIdField?: string;
|
|
23
|
+
/** For mode="flat": field name that holds the row's stable id. Falls back to keyField. */
|
|
24
|
+
idField?: string;
|
|
25
|
+
/** Pixel width of one indentation level. Default: 16 */
|
|
26
|
+
indentPx?: number;
|
|
27
|
+
/** If a descendant matches search/filter, auto-expand its ancestors for the effective view. Default: true */
|
|
28
|
+
autoExpandOnMatch?: boolean;
|
|
29
|
+
};
|
|
30
|
+
export type ResolvedTreeOptions = {
|
|
31
|
+
enabled: boolean;
|
|
32
|
+
mode: TreeMode;
|
|
33
|
+
childrenField: string;
|
|
34
|
+
parentIdField: string;
|
|
35
|
+
idField?: string;
|
|
36
|
+
indentPx: number;
|
|
37
|
+
autoExpandOnMatch: boolean;
|
|
38
|
+
};
|
|
39
|
+
export type ExpandedKeysState = string[];
|
|
40
|
+
export type OnExpandedChangeFn = (keys: string[]) => void;
|
|
41
|
+
export type TreeMeta = {
|
|
42
|
+
/** Map of row key -> parent row key (undefined for roots) */
|
|
43
|
+
parentKeyMap: Map<string, string | undefined>;
|
|
44
|
+
/** Map of parent key -> ordered list of direct child keys */
|
|
45
|
+
childrenKeyMap: Map<string | undefined, string[]>;
|
|
46
|
+
/** All row keys that have children (eligible for expansion) */
|
|
47
|
+
expandableKeys: string[];
|
|
48
|
+
};
|
|
13
49
|
export type RenderOptions = {
|
|
14
50
|
rowData: any;
|
|
15
51
|
onRowUpdated?: (context: {
|
|
@@ -55,6 +91,7 @@ export type TableState = {
|
|
|
55
91
|
sortState?: SortState;
|
|
56
92
|
filterState?: Query;
|
|
57
93
|
searchState?: string;
|
|
94
|
+
expandedKeys?: ExpandedKeysState;
|
|
58
95
|
};
|
|
59
96
|
export interface onResizeFinishedProps {
|
|
60
97
|
column: ColumnState;
|
|
@@ -103,6 +140,17 @@ export type TableContextType = {
|
|
|
103
140
|
data: any[];
|
|
104
141
|
totalRecords?: number;
|
|
105
142
|
keyField?: string;
|
|
143
|
+
treeOptions: ResolvedTreeOptions;
|
|
144
|
+
firstVisibleDataField?: string;
|
|
145
|
+
expandedKeys: string[];
|
|
146
|
+
effectiveExpandedKeys: Set<string>;
|
|
147
|
+
isRowExpanded: (row: any) => boolean;
|
|
148
|
+
toggleRowExpanded: (row: any) => void;
|
|
149
|
+
expandRow: (row: any) => void;
|
|
150
|
+
collapseRow: (row: any) => void;
|
|
151
|
+
expandAllRows: () => void;
|
|
152
|
+
collapseAllRows: () => void;
|
|
153
|
+
onExpandedChange?: OnExpandedChangeFn;
|
|
106
154
|
tableHeight?: number;
|
|
107
155
|
tableMaxHeight?: number;
|
|
108
156
|
tableMinHeight?: number;
|
|
@@ -214,6 +262,11 @@ export interface TableProviderProps {
|
|
|
214
262
|
defaultFilterState?: Query;
|
|
215
263
|
filterState?: Query;
|
|
216
264
|
onFilterChange?: (e: Query) => void;
|
|
265
|
+
treeOptions?: ResolvedTreeOptions;
|
|
266
|
+
defaultExpandedKeys?: ExpandedKeysState;
|
|
267
|
+
expandedKeys?: ExpandedKeysState;
|
|
268
|
+
onExpandedChange?: OnExpandedChangeFn;
|
|
269
|
+
treeMeta?: TreeMeta;
|
|
217
270
|
}
|
|
218
271
|
export interface TableRowProps {
|
|
219
272
|
rowData: {
|
|
@@ -335,6 +388,10 @@ export interface TableProps {
|
|
|
335
388
|
defaultFilterState?: Query;
|
|
336
389
|
filterState?: Query;
|
|
337
390
|
onFilterChange?: (e: Query) => void;
|
|
391
|
+
treeOptions?: TreeOptions;
|
|
392
|
+
defaultExpandedKeys?: ExpandedKeysState;
|
|
393
|
+
expandedKeys?: ExpandedKeysState;
|
|
394
|
+
onExpandedChange?: OnExpandedChangeFn;
|
|
338
395
|
}
|
|
339
396
|
export type TableInstance = {
|
|
340
397
|
columnState: ColumnState[];
|
|
@@ -355,4 +412,11 @@ export type TableInstance = {
|
|
|
355
412
|
clearSearch: () => void;
|
|
356
413
|
clearSelections: () => void;
|
|
357
414
|
getTableState: () => TableState;
|
|
415
|
+
expandRow: (row: any) => void;
|
|
416
|
+
collapseRow: (row: any) => void;
|
|
417
|
+
toggleRowExpanded: (row: any) => void;
|
|
418
|
+
isRowExpanded: (row: any) => boolean;
|
|
419
|
+
expandAllRows: () => void;
|
|
420
|
+
collapseAllRows: () => void;
|
|
421
|
+
getExpandedRowKeys: () => string[];
|
|
358
422
|
};
|
package/dist/TagBox/TagBox.js
CHANGED
|
@@ -14,7 +14,7 @@ import styled from "styled-components";
|
|
|
14
14
|
import { useFloating, flip, offset, autoUpdate, FloatingPortal, } from "@floating-ui/react";
|
|
15
15
|
import { useCallback, useEffect, useRef, useState, } from "react";
|
|
16
16
|
import { Input, Tooltip, FieldLabel, Pill, Loader } from "..";
|
|
17
|
-
import { ArrowButton, ClearButton, StyledFloatContainer, StyledContent, } from "../core";
|
|
17
|
+
import { ArrowButton, ClearButton, StyledFloatContainer, StyledContent, getControlSizeTokens, } from "../core";
|
|
18
18
|
const StyledInputContainer = styled.div `
|
|
19
19
|
position: relative;
|
|
20
20
|
cursor: pointer;
|
|
@@ -29,17 +29,7 @@ const StyledInputContainer = styled.div `
|
|
|
29
29
|
pointer-events: all;
|
|
30
30
|
outline: none;
|
|
31
31
|
|
|
32
|
-
padding: ${({ size }) => size
|
|
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"};
|
|
32
|
+
padding: ${({ size }) => `0px ${getControlSizeTokens(size).inputPaddingX}px`};
|
|
43
33
|
|
|
44
34
|
border-radius: 5px;
|
|
45
35
|
transition: border 0.1s ease-in-out;
|
|
@@ -58,33 +48,13 @@ const StyledInputContainer = styled.div `
|
|
|
58
48
|
}};
|
|
59
49
|
font-weight: 500;
|
|
60
50
|
color: ${(props) => props.theme.palette.text.primary};
|
|
61
|
-
font-size: ${({ size }) => size
|
|
62
|
-
? "12px"
|
|
63
|
-
: size === "sm"
|
|
64
|
-
? "14px"
|
|
65
|
-
: size === "md"
|
|
66
|
-
? "16px"
|
|
67
|
-
: size === "lg"
|
|
68
|
-
? "18px"
|
|
69
|
-
: size === "xl"
|
|
70
|
-
? "20px"
|
|
71
|
-
: "12px"};
|
|
51
|
+
font-size: ${({ size }) => `${getControlSizeTokens(size).fontSize}px`};
|
|
72
52
|
|
|
73
53
|
width: 100%;
|
|
74
|
-
min-height: ${({ size }) => size
|
|
75
|
-
? "26px"
|
|
76
|
-
: size === "sm"
|
|
77
|
-
? "30px"
|
|
78
|
-
: size === "md"
|
|
79
|
-
? "36px"
|
|
80
|
-
: size === "lg"
|
|
81
|
-
? "42px"
|
|
82
|
-
: size === "xl"
|
|
83
|
-
? "50px"
|
|
84
|
-
: "26px"};
|
|
54
|
+
min-height: ${({ size }) => `${getControlSizeTokens(size).height}px`};
|
|
85
55
|
|
|
86
56
|
&[data-button-right="true"] {
|
|
87
|
-
padding-right:
|
|
57
|
+
padding-right: ${({ size }) => `${getControlSizeTokens(size).adornmentWidth}px`};
|
|
88
58
|
}
|
|
89
59
|
|
|
90
60
|
background-color: ${({ theme, variant }) => {
|
|
@@ -199,17 +169,8 @@ const GroupTitle = styled((_a) => {
|
|
|
199
169
|
|
|
200
170
|
color: ${(props) => props.theme.palette.text.secondary};
|
|
201
171
|
|
|
202
|
-
|
|
203
|
-
|
|
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"};
|
|
172
|
+
min-height: ${({ size }) => `${getControlSizeTokens(size).menuRowHeight}px`};
|
|
173
|
+
padding: ${({ size }) => `0px ${getControlSizeTokens(size).menuItemPaddingX}px`};
|
|
213
174
|
|
|
214
175
|
.group-label {
|
|
215
176
|
white-space: nowrap;
|
|
@@ -220,17 +181,7 @@ const GroupTitle = styled((_a) => {
|
|
|
220
181
|
|
|
221
182
|
font-weight: 500;
|
|
222
183
|
|
|
223
|
-
font-size: ${({ size }) => size
|
|
224
|
-
? "11px"
|
|
225
|
-
: size === "sm"
|
|
226
|
-
? "13px"
|
|
227
|
-
: size === "md"
|
|
228
|
-
? "15px"
|
|
229
|
-
: size === "lg"
|
|
230
|
-
? "17px"
|
|
231
|
-
: size === "xl"
|
|
232
|
-
? "19px"
|
|
233
|
-
: "11px"};
|
|
184
|
+
font-size: ${({ size }) => `${getControlSizeTokens(size).menuGroupFontSize}px`};
|
|
234
185
|
}
|
|
235
186
|
|
|
236
187
|
.group-line {
|
|
@@ -241,7 +192,7 @@ const GroupTitle = styled((_a) => {
|
|
|
241
192
|
const PillContainer = styled.div `
|
|
242
193
|
display: flex;
|
|
243
194
|
align-items: center;
|
|
244
|
-
gap:
|
|
195
|
+
gap: ${({ size }) => `${getControlSizeTokens(size).iconGap}px`};
|
|
245
196
|
flex-wrap: wrap;
|
|
246
197
|
flex-grow: 1;
|
|
247
198
|
|
|
@@ -255,7 +206,7 @@ const StyledInnerContainer = styled.div `
|
|
|
255
206
|
width: 100%;
|
|
256
207
|
|
|
257
208
|
&[data-button-right="true"] {
|
|
258
|
-
padding-right:
|
|
209
|
+
padding-right: ${({ size }) => `${getControlSizeTokens(size).adornmentWidth}px`};
|
|
259
210
|
}
|
|
260
211
|
`;
|
|
261
212
|
const StyledItem = styled.div `
|
|
@@ -264,26 +215,17 @@ const StyledItem = styled.div `
|
|
|
264
215
|
border-radius: 3px;
|
|
265
216
|
display: flex;
|
|
266
217
|
align-items: center;
|
|
267
|
-
min-height:
|
|
268
|
-
|
|
218
|
+
min-height: ${({ size }) => `${getControlSizeTokens(size).menuRowHeight}px`};
|
|
219
|
+
height: ${({ size }) => `${getControlSizeTokens(size).menuRowHeight}px`};
|
|
269
220
|
position: relative;
|
|
270
221
|
user-select: none;
|
|
271
222
|
outline: none;
|
|
272
223
|
|
|
273
224
|
cursor: pointer;
|
|
274
225
|
|
|
275
|
-
font-family:
|
|
276
|
-
font-size: ${({ size }) => size
|
|
277
|
-
|
|
278
|
-
: size === "sm"
|
|
279
|
-
? "13px"
|
|
280
|
-
: size === "md"
|
|
281
|
-
? "15px"
|
|
282
|
-
: size === "lg"
|
|
283
|
-
? "17px"
|
|
284
|
-
: size === "xl"
|
|
285
|
-
? "19px"
|
|
286
|
-
: "11px"};
|
|
226
|
+
font-family: ${({ theme }) => theme.typography.fontFamily};
|
|
227
|
+
font-size: ${({ size }) => `${getControlSizeTokens(size).fontSize}px`};
|
|
228
|
+
padding: ${({ size }) => `0px ${getControlSizeTokens(size).menuItemPaddingX}px`};
|
|
287
229
|
|
|
288
230
|
&:hover {
|
|
289
231
|
background-color: ${(props) => props.theme.palette.action.hover};
|
|
@@ -642,7 +584,7 @@ const TagBox = styled(({ className, data = [], placeholder = "Select tags", arro
|
|
|
642
584
|
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: () => {
|
|
643
585
|
setIsOpen(true);
|
|
644
586
|
handleFocus();
|
|
645
|
-
}, 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: [_value === null || _value === void 0 ? void 0 : _value.map((item, index) => (_jsx(Pill, { size:
|
|
587
|
+
}, 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: [_value === null || _value === void 0 ? void 0 : _value.map((item, index) => (_jsx(Pill, { size: size, 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))), (searchable || allowCustomValue || (_value === null || _value === void 0 ? void 0 : _value.length) === 0) && (_jsx(StyledInput, { inputRef: inputRef, onChange: (e) => {
|
|
646
588
|
if (searchFn !== undefined) {
|
|
647
589
|
searchFn === null || searchFn === void 0 ? void 0 : searchFn(e.target.value);
|
|
648
590
|
}
|
|
@@ -651,10 +593,10 @@ const TagBox = styled(({ className, data = [], placeholder = "Select tags", arro
|
|
|
651
593
|
}
|
|
652
594
|
update();
|
|
653
595
|
}, placeholder: placeholder, size: size, readOnly: !(searchable || allowCustomValue), "data-disabled": disabled }))] }) }), clearable &&
|
|
654
|
-
(((_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) => {
|
|
596
|
+
(((_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, { size: size, onClick: handleClear, onMouseDown: (e) => {
|
|
655
597
|
e.preventDefault();
|
|
656
598
|
e.stopPropagation();
|
|
657
|
-
} })) : arrow ? (_jsx(ArrowButton, { onClick: (e) => {
|
|
599
|
+
} })) : arrow ? (_jsx(ArrowButton, { size: size, onClick: (e) => {
|
|
658
600
|
e.preventDefault();
|
|
659
601
|
}, onMouseDown: (e) => {
|
|
660
602
|
e.preventDefault();
|
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
2
|
import TextareaAutosize from "react-textarea-autosize";
|
|
3
|
+
import { getControlSizeTokens } from "../core";
|
|
3
4
|
const TextArea = styled(TextareaAutosize) `
|
|
4
5
|
outline: none;
|
|
5
6
|
resize: none;
|
|
6
|
-
padding:
|
|
7
|
+
padding: ${({ size }) => `${getControlSizeTokens(size).inputPaddingX}px`};
|
|
7
8
|
width: 100%;
|
|
8
9
|
height: 100%;
|
|
9
10
|
box-sizing: border-box;
|
|
10
11
|
|
|
11
12
|
font-family: ${({ theme }) => theme.typography.fontFamily};
|
|
12
13
|
color: ${(props) => props.theme.palette.text.primary};
|
|
13
|
-
font-size: ${({ size }) => size
|
|
14
|
-
? "11px"
|
|
15
|
-
: size === "sm"
|
|
16
|
-
? "13px"
|
|
17
|
-
: size === "md"
|
|
18
|
-
? "15px"
|
|
19
|
-
: size === "lg"
|
|
20
|
-
? "17px"
|
|
21
|
-
: size === "xl"
|
|
22
|
-
? "19px"
|
|
23
|
-
: "13px"};
|
|
14
|
+
font-size: ${({ size }) => `${getControlSizeTokens(size).fontSize}px`};
|
|
24
15
|
|
|
25
16
|
background-color: ${({ theme, variant }) => {
|
|
26
17
|
switch (variant) {
|
|
@@ -60,17 +51,7 @@ const TextArea = styled(TextareaAutosize) `
|
|
|
60
51
|
}
|
|
61
52
|
|
|
62
53
|
::placeholder {
|
|
63
|
-
font-size: ${({ size }) => size
|
|
64
|
-
? "10px"
|
|
65
|
-
: size === "sm"
|
|
66
|
-
? "12px"
|
|
67
|
-
: size === "md"
|
|
68
|
-
? "14px"
|
|
69
|
-
: size === "lg"
|
|
70
|
-
? "16px"
|
|
71
|
-
: size === "xl"
|
|
72
|
-
? "18px"
|
|
73
|
-
: "12px"};
|
|
54
|
+
font-size: ${({ size }) => `${getControlSizeTokens(size).placeholderFontSize}px`};
|
|
74
55
|
}
|
|
75
56
|
`;
|
|
76
57
|
export default TextArea;
|
|
@@ -13,6 +13,7 @@ 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";
|
|
16
17
|
import { forwardRef, useState } from "react";
|
|
17
18
|
import { Eye, EyeOff, X } from "lucide-react";
|
|
18
19
|
const StyledContainer = styled.div `
|
|
@@ -35,7 +36,9 @@ const InputContainer = styled.div `
|
|
|
35
36
|
`;
|
|
36
37
|
const InputButton = styled.button `
|
|
37
38
|
position: absolute;
|
|
38
|
-
right:
|
|
39
|
+
right: 0;
|
|
40
|
+
width: ${({ size }) => `${getControlSizeTokens(size).adornmentWidth}px`};
|
|
41
|
+
height: 100%;
|
|
39
42
|
background: none;
|
|
40
43
|
border: none;
|
|
41
44
|
cursor: pointer;
|
|
@@ -58,8 +61,8 @@ const InputButton = styled.button `
|
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
svg {
|
|
61
|
-
width:
|
|
62
|
-
height:
|
|
64
|
+
width: ${({ size }) => `${getControlSizeTokens(size).iconSize}px`};
|
|
65
|
+
height: ${({ size }) => `${getControlSizeTokens(size).iconSize}px`};
|
|
63
66
|
}
|
|
64
67
|
`;
|
|
65
68
|
export const TextInput = forwardRef((_a, ref) => {
|
|
@@ -77,11 +80,14 @@ export const TextInput = forwardRef((_a, ref) => {
|
|
|
77
80
|
};
|
|
78
81
|
// Enhanced features: password or clearable functionality
|
|
79
82
|
const inputType = password && !passwordVisible ? "password" : type || "text";
|
|
80
|
-
const
|
|
81
|
-
|
|
83
|
+
const adornmentWidth = getControlSizeTokens(size).adornmentWidth;
|
|
84
|
+
const inputStyle = Object.assign(Object.assign({}, style), (password || (clearable && value)
|
|
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) => {
|
|
82
88
|
e.preventDefault();
|
|
83
89
|
e.stopPropagation();
|
|
84
|
-
}, tabIndex: -1, type: "button", children: passwordVisible ? _jsx(Eye, {}) : _jsx(EyeOff, {}) })) : clearable && value ? (_jsx(InputButton, { onClick: handleClear, onMouseDown: (e) => {
|
|
90
|
+
}, tabIndex: -1, type: "button", children: passwordVisible ? _jsx(Eye, {}) : _jsx(EyeOff, {}) })) : clearable && value ? (_jsx(InputButton, { size: size, onClick: handleClear, onMouseDown: (e) => {
|
|
85
91
|
e.preventDefault();
|
|
86
92
|
e.stopPropagation();
|
|
87
93
|
}, tabIndex: -1, type: "button", children: _jsx(X, {}) })) : null] })] }));
|
|
@@ -7,6 +7,7 @@ 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;
|
|
10
11
|
// Supported format tokens and how each token maps to a segment type.
|
|
11
12
|
// `momentType` is used by consumers that need to know which unit the
|
|
12
13
|
// segment represents in Moment's terminology.
|
|
@@ -40,7 +41,7 @@ export default function parseTimestamp(timestamp, format, utc = false) {
|
|
|
40
41
|
// Break the format into ordered parts while keeping separators.
|
|
41
42
|
// Example: "MM/DD/YYYY HH:mm" => ["MM", "/", "DD", "/", "YYYY", " ", "HH", ":", "mm"]
|
|
42
43
|
function splitFormat(format) {
|
|
43
|
-
return format.split(/(YYYY|MM|DD|HH|h|mm|ss|SSS|Z)/).filter((s) => s);
|
|
44
|
+
return format.split(/(YYYY|MM|DD|HH|h|mm|ss|SSS|A|Z)/).filter((s) => s);
|
|
44
45
|
}
|
|
45
46
|
// Convert each format part into a known token descriptor.
|
|
46
47
|
// Unknown parts are treated as literal separators.
|
|
@@ -57,15 +58,19 @@ export default function parseTimestamp(timestamp, format, utc = false) {
|
|
|
57
58
|
index: -1,
|
|
58
59
|
};
|
|
59
60
|
}
|
|
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;
|
|
60
67
|
// Build the final Segment[] in format order.
|
|
61
68
|
// For date/time tokens, format the timestamp using local or UTC mode.
|
|
62
|
-
// For separators (or empty
|
|
69
|
+
// For separators (or empty/invalid timestamps), use the placeholder as the value.
|
|
63
70
|
const segments = splitFormat(format).map((segment, i) => {
|
|
64
71
|
const { pattern, placeholder, type, momentType } = matchSegment(segment);
|
|
65
|
-
const value =
|
|
66
|
-
?
|
|
67
|
-
? moment.utc(timestamp).format(pattern)
|
|
68
|
-
: moment(timestamp).format(pattern)
|
|
72
|
+
const value = hasValidTimestamp && parsedTimestamp
|
|
73
|
+
? parsedTimestamp.format(pattern)
|
|
69
74
|
: placeholder;
|
|
70
75
|
return {
|
|
71
76
|
value,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import Size from "./Types/Size";
|
|
1
2
|
interface ArrowButtonProps {
|
|
2
3
|
className?: string;
|
|
4
|
+
size?: Size;
|
|
3
5
|
[key: string]: React.ButtonHTMLAttributes<HTMLButtonElement> | any;
|
|
4
6
|
}
|
|
5
7
|
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,9 +12,10 @@ 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";
|
|
15
16
|
const ArrowIcon = styled((_a) => {
|
|
16
17
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
17
|
-
return (_jsx("div", Object.assign({ className: className }, props, { children: _jsx(ChevronDownIcon, { size:
|
|
18
|
+
return (_jsx("div", Object.assign({ className: className }, props, { children: _jsx(ChevronDownIcon, { size: getControlSizeTokens(props.size).iconSize }) })));
|
|
18
19
|
}) `
|
|
19
20
|
color: ${(props) => props.theme.palette.text.secondary};
|
|
20
21
|
transition: transform 0.2s ease-in-out;
|
|
@@ -28,16 +29,19 @@ const ArrowIcon = styled((_a) => {
|
|
|
28
29
|
`;
|
|
29
30
|
const ArrowButton = styled((_a) => {
|
|
30
31
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
31
|
-
return (_jsx("button", Object.assign({ className: className }, props, { tabIndex: -1, "data-default-btn": true, children: _jsx(ArrowIcon, {}) })));
|
|
32
|
+
return (_jsx("button", Object.assign({ className: className }, props, { tabIndex: -1, "data-default-btn": true, children: _jsx(ArrowIcon, { size: props.size }) })));
|
|
32
33
|
}) `
|
|
33
34
|
position: absolute;
|
|
34
35
|
right: 0;
|
|
35
36
|
height: 100%;
|
|
36
|
-
|
|
37
|
+
width: ${({ size = DEFAULT_CONTROL_SIZE }) => `${getControlSizeTokens(size).adornmentWidth}px`};
|
|
37
38
|
background: none;
|
|
38
39
|
border: none;
|
|
39
40
|
cursor: pointer;
|
|
40
41
|
margin: 0;
|
|
41
42
|
outline: none;
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
justify-content: center;
|
|
42
46
|
`;
|
|
43
47
|
export default ArrowButton;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import Size from "./Types/Size";
|
|
1
2
|
interface ClearButtonProps {
|
|
2
3
|
className?: string;
|
|
4
|
+
size?: Size;
|
|
3
5
|
[key: string]: React.ButtonHTMLAttributes<HTMLButtonElement> | any;
|
|
4
6
|
}
|
|
5
7
|
declare const ClearButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<ClearButtonProps, never>> & string & Omit<({ className, ...props }: ClearButtonProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
|
package/dist/core/ClearButton.js
CHANGED
|
@@ -12,9 +12,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { X } from "lucide-react";
|
|
14
14
|
import styled from "styled-components";
|
|
15
|
+
import { DEFAULT_CONTROL_SIZE, getControlSizeTokens } from "./controlSizes";
|
|
15
16
|
const ClearIcon = styled((_a) => {
|
|
16
17
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
17
|
-
return (_jsx("div", Object.assign({ className: className }, props, { children: _jsx(X, { size:
|
|
18
|
+
return (_jsx("div", Object.assign({ className: className }, props, { children: _jsx(X, { size: getControlSizeTokens(props.size).iconSize }) })));
|
|
18
19
|
}) `
|
|
19
20
|
color: ${(props) => props.theme.palette.text.secondary};
|
|
20
21
|
transition: transform 0.2s ease-in-out;
|
|
@@ -28,16 +29,19 @@ const ClearIcon = styled((_a) => {
|
|
|
28
29
|
`;
|
|
29
30
|
const ClearButton = styled((_a) => {
|
|
30
31
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
31
|
-
return (_jsx("button", Object.assign({ className: className }, props, { tabIndex: -1, "data-default-btn": true, children: _jsx(ClearIcon, {}) })));
|
|
32
|
+
return (_jsx("button", Object.assign({ className: className }, props, { tabIndex: -1, "data-default-btn": true, children: _jsx(ClearIcon, { size: props.size }) })));
|
|
32
33
|
}) `
|
|
33
34
|
position: absolute;
|
|
34
35
|
right: 0;
|
|
35
36
|
height: 100%;
|
|
36
|
-
|
|
37
|
+
width: ${({ size = DEFAULT_CONTROL_SIZE }) => `${getControlSizeTokens(size).adornmentWidth}px`};
|
|
37
38
|
background: none;
|
|
38
39
|
border: none;
|
|
39
40
|
cursor: pointer;
|
|
40
41
|
margin: 0;
|
|
41
42
|
outline: none;
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
justify-content: center;
|
|
42
46
|
`;
|
|
43
47
|
export default ClearButton;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import Size from "./Types/Size";
|
|
2
|
+
export declare const DEFAULT_CONTROL_SIZE: Size;
|
|
3
|
+
export type ControlSizeTokens = {
|
|
4
|
+
height: number;
|
|
5
|
+
fontSize: number;
|
|
6
|
+
labelFontSize: number;
|
|
7
|
+
supportingFontSize: number;
|
|
8
|
+
placeholderFontSize: number;
|
|
9
|
+
inputPaddingX: number;
|
|
10
|
+
buttonPaddingX: number;
|
|
11
|
+
iconSize: number;
|
|
12
|
+
iconGap: number;
|
|
13
|
+
adornmentWidth: number;
|
|
14
|
+
menuRowHeight: number;
|
|
15
|
+
menuItemPaddingX: number;
|
|
16
|
+
menuGroupFontSize: number;
|
|
17
|
+
switchTrackWidth: number;
|
|
18
|
+
switchTrackHeight: number;
|
|
19
|
+
switchThumbSize: number;
|
|
20
|
+
switchPadding: number;
|
|
21
|
+
switchGap: number;
|
|
22
|
+
checkboxIconSize: number;
|
|
23
|
+
iconButtonPaddingX: number;
|
|
24
|
+
pillHeight: number;
|
|
25
|
+
pillFontSize: number;
|
|
26
|
+
pillPaddingX: number;
|
|
27
|
+
pillIconSize: number;
|
|
28
|
+
pillGap: number;
|
|
29
|
+
segmentedHeight: number;
|
|
30
|
+
segmentedFontSize: number;
|
|
31
|
+
sectionTitleFontSize: number;
|
|
32
|
+
sectionIconSize: number;
|
|
33
|
+
};
|
|
34
|
+
export declare const getControlSizeTokens: (size?: Size) => ControlSizeTokens;
|