@recursica/mui-adapter 0.19.1 → 0.21.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/CHANGELOG.md +28 -0
- package/dist/index.d.ts +2874 -2
- package/dist/mui-adapter.cjs +89 -58
- package/dist/mui-adapter.cjs.map +1 -1
- package/dist/mui-adapter.css +1 -1
- package/dist/mui-adapter.js +26163 -8727
- package/dist/mui-adapter.js.map +1 -1
- package/package.json +8 -2
- package/src/components/Box/USAGE.md +1 -1
- package/src/components/Button/BUTTON_IMPLEMENTATION_NOTES.md +22 -0
- package/src/components/Button/Button.module.css +10 -7
- package/src/components/Button/Button.tsx +4 -0
- package/src/components/Button/USAGE.md +1 -13
- package/src/components/Card/USAGE.md +1 -13
- package/src/components/Container/USAGE.md +1 -1
- package/src/components/Dropdown/BareDropdown.tsx +135 -0
- package/src/components/Dropdown/Dropdown.tsx +16 -0
- package/src/components/Grid/USAGE.md +6 -10
- package/src/components/Loader/USAGE.md +1 -23
- package/src/components/Menu/USAGE.md +0 -7
- package/src/components/Pagination/USAGE.md +0 -6
- package/src/components/Panel/USAGE.md +1 -58
- package/src/components/Stepper/USAGE.md +0 -7
- package/src/components/Tabs/USAGE.md +0 -7
- package/src/components/TimePicker/TIMEPICKER_IMPLEMENTATION_NOTES.md +68 -0
- package/src/components/TimePicker/TimePicker.module.css +213 -37
- package/src/components/TimePicker/TimePicker.stories.tsx +119 -4
- package/src/components/TimePicker/TimePicker.tsx +257 -8
- package/src/components/TimePicker/USAGE.md +27 -2
- package/src/components/Tree/IMPLEMENTATION_NOTES.md +28 -1
- package/src/components/Tree/Tree.module.css +114 -69
- package/src/components/Tree/Tree.stories.tsx +13 -0
- package/src/components/Tree/Tree.tsx +99 -32
- package/src/components/Tree/USAGE.md +18 -2
- package/src/index.ts +1 -0
- package/dist/src/OverStyling.d.ts +0 -1
- package/dist/src/Version.d.ts +0 -1
- package/dist/src/components/Accordion/Accordion.d.ts +0 -77
- package/dist/src/components/Accordion/index.d.ts +0 -1
- package/dist/src/components/AssistiveElement/AssistiveElement.d.ts +0 -7
- package/dist/src/components/AssistiveElement/index.d.ts +0 -1
- package/dist/src/components/Autocomplete/Autocomplete.d.ts +0 -24
- package/dist/src/components/Autocomplete/index.d.ts +0 -1
- package/dist/src/components/Avatar/Avatar.d.ts +0 -25
- package/dist/src/components/Avatar/index.d.ts +0 -1
- package/dist/src/components/Badge/Badge.d.ts +0 -25
- package/dist/src/components/Badge/index.d.ts +0 -1
- package/dist/src/components/Box/Box.d.ts +0 -8
- package/dist/src/components/Box/index.d.ts +0 -1
- package/dist/src/components/Breadcrumb/Breadcrumb.d.ts +0 -20
- package/dist/src/components/Breadcrumb/index.d.ts +0 -1
- package/dist/src/components/Button/Button.d.ts +0 -37
- package/dist/src/components/Button/index.d.ts +0 -1
- package/dist/src/components/Card/Card.d.ts +0 -81
- package/dist/src/components/Card/index.d.ts +0 -1
- package/dist/src/components/Checkbox/Checkbox.d.ts +0 -14
- package/dist/src/components/Checkbox/CheckboxGroup.d.ts +0 -29
- package/dist/src/components/Checkbox/index.d.ts +0 -5
- package/dist/src/components/Chip/Chip.d.ts +0 -21
- package/dist/src/components/Chip/index.d.ts +0 -1
- package/dist/src/components/Container/Container.d.ts +0 -5
- package/dist/src/components/Container/index.d.ts +0 -1
- package/dist/src/components/DatePicker/DatePicker.d.ts +0 -20
- package/dist/src/components/DatePicker/index.d.ts +0 -1
- package/dist/src/components/Dropdown/Dropdown.d.ts +0 -24
- package/dist/src/components/Dropdown/index.d.ts +0 -1
- package/dist/src/components/FileInput/FileInput.d.ts +0 -3
- package/dist/src/components/FileInput/index.d.ts +0 -1
- package/dist/src/components/FileUpload/FileUpload.d.ts +0 -3
- package/dist/src/components/FileUpload/index.d.ts +0 -1
- package/dist/src/components/Flex/Flex.d.ts +0 -5
- package/dist/src/components/Flex/index.d.ts +0 -1
- package/dist/src/components/FormControlLayout/FormControlLayout.d.ts +0 -6
- package/dist/src/components/FormControlLayout/index.d.ts +0 -1
- package/dist/src/components/FormControlWrapper/FormControlWrapper.d.ts +0 -11
- package/dist/src/components/FormControlWrapper/index.d.ts +0 -1
- package/dist/src/components/Grid/Grid.d.ts +0 -12
- package/dist/src/components/Grid/index.d.ts +0 -1
- package/dist/src/components/Group/Group.d.ts +0 -5
- package/dist/src/components/Group/index.d.ts +0 -1
- package/dist/src/components/HoverCard/HoverCard.d.ts +0 -29
- package/dist/src/components/HoverCard/index.d.ts +0 -1
- package/dist/src/components/Label/Label.d.ts +0 -7
- package/dist/src/components/Label/index.d.ts +0 -1
- package/dist/src/components/Link/Link.d.ts +0 -20
- package/dist/src/components/Link/index.d.ts +0 -1
- package/dist/src/components/Loader/Loader.d.ts +0 -5
- package/dist/src/components/Loader/index.d.ts +0 -1
- package/dist/src/components/Menu/Menu.d.ts +0 -54
- package/dist/src/components/Menu/index.d.ts +0 -1
- package/dist/src/components/Modal/Modal.d.ts +0 -78
- package/dist/src/components/Modal/index.d.ts +0 -1
- package/dist/src/components/NumberInput/NumberInput.d.ts +0 -24
- package/dist/src/components/NumberInput/index.d.ts +0 -1
- package/dist/src/components/Pagination/Pagination.d.ts +0 -23
- package/dist/src/components/Pagination/Pagination.icons.d.ts +0 -8
- package/dist/src/components/Pagination/index.d.ts +0 -1
- package/dist/src/components/Panel/Panel.d.ts +0 -52
- package/dist/src/components/Panel/index.d.ts +0 -1
- package/dist/src/components/Radio/Radio.d.ts +0 -13
- package/dist/src/components/Radio/RadioGroup.d.ts +0 -9
- package/dist/src/components/Radio/index.d.ts +0 -2
- package/dist/src/components/ReadOnlyField/ReadOnlyBooleanField.d.ts +0 -5
- package/dist/src/components/ReadOnlyField/ReadOnlyField.d.ts +0 -5
- package/dist/src/components/ReadOnlyField/ReadOnlySwitchField.d.ts +0 -5
- package/dist/src/components/ReadOnlyField/ReadOnlyTextField.d.ts +0 -8
- package/dist/src/components/ReadOnlyField/WithReadOnlyWrapper.d.ts +0 -28
- package/dist/src/components/ReadOnlyField/index.d.ts +0 -2
- package/dist/src/components/SegmentedControl/SegmentedControl.d.ts +0 -32
- package/dist/src/components/SegmentedControl/index.d.ts +0 -1
- package/dist/src/components/Slider/Slider.d.ts +0 -30
- package/dist/src/components/Slider/index.d.ts +0 -1
- package/dist/src/components/Stack/Stack.d.ts +0 -5
- package/dist/src/components/Stack/index.d.ts +0 -1
- package/dist/src/components/Stepper/Stepper.d.ts +0 -97
- package/dist/src/components/Stepper/index.d.ts +0 -1
- package/dist/src/components/Switch/Switch.d.ts +0 -10
- package/dist/src/components/Switch/SwitchGroup.d.ts +0 -24
- package/dist/src/components/Switch/index.d.ts +0 -2
- package/dist/src/components/Table/Table.d.ts +0 -154
- package/dist/src/components/Table/index.d.ts +0 -1
- package/dist/src/components/Tabs/Tabs.d.ts +0 -57
- package/dist/src/components/Tabs/index.d.ts +0 -1
- package/dist/src/components/Text/Text.d.ts +0 -20
- package/dist/src/components/Text/index.d.ts +0 -1
- package/dist/src/components/TextArea/TextArea.d.ts +0 -24
- package/dist/src/components/TextArea/index.d.ts +0 -1
- package/dist/src/components/TextField/TextField.d.ts +0 -24
- package/dist/src/components/TextField/index.d.ts +0 -1
- package/dist/src/components/TimePicker/TimePicker.d.ts +0 -4
- package/dist/src/components/TimePicker/index.d.ts +0 -1
- package/dist/src/components/Timeline/Timeline.d.ts +0 -16
- package/dist/src/components/Timeline/TimelineItem.d.ts +0 -29
- package/dist/src/components/Timeline/index.d.ts +0 -2
- package/dist/src/components/Title/Title.d.ts +0 -21
- package/dist/src/components/Title/index.d.ts +0 -1
- package/dist/src/components/Toast/Toast.d.ts +0 -32
- package/dist/src/components/Toast/index.d.ts +0 -1
- package/dist/src/components/Tooltip/Tooltip.d.ts +0 -28
- package/dist/src/components/Tooltip/index.d.ts +0 -1
- package/dist/src/components/TransferList/TransferList.d.ts +0 -4
- package/dist/src/components/TransferList/index.d.ts +0 -1
- package/dist/src/components/Tree/Tree.d.ts +0 -13
- package/dist/src/components/Tree/index.d.ts +0 -1
- package/dist/src/components/Typography/Typography.d.ts +0 -38
- package/dist/src/components/Typography/index.d.ts +0 -1
- package/dist/src/components/index.d.ts +0 -50
- package/dist/src/index.d.ts +0 -91
- package/dist/src/types/index.d.ts +0 -6
- package/dist/src/utils/ColorSchemeWrapper.d.ts +0 -3
- package/dist/src/utils/RequireAccessibleLabel.d.ts +0 -1
- package/dist/src/utils/copyToClipboard.d.ts +0 -8
- package/dist/src/utils/filterStylingProps.d.ts +0 -29
- package/dist/src/utils/index.d.ts +0 -1
- package/dist/vite.config.d.ts +0 -2
- package/dist/vitest.workspace.d.ts +0 -2
|
@@ -1,41 +1,217 @@
|
|
|
1
1
|
/* EXEMPTIONS:
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
- state-specific border-size variables are ignored because a uniform border-size is applied globally
|
|
3
|
+
to prevent unexpected layout shift or flickering during focus, disabled, or error state transitions.
|
|
4
|
+
- icon-size/icon-color/icon-text-gap have no equivalent here: the time field has no icon slot,
|
|
5
|
+
unlike TextField/DatePicker.
|
|
6
|
+
- placeholder-opacity has no equivalent here: MUI X's field renders empty sections via its own
|
|
7
|
+
internal placeholder styling, not a native ::placeholder pseudo-element we can target. */
|
|
8
|
+
/* recursica-ignore: --recursica_ui-kit_components_time-picker_variants_states_error_properties_border-size */
|
|
9
|
+
/* recursica-ignore: --recursica_ui-kit_components_time-picker_variants_states_disabled_properties_border-size */
|
|
7
10
|
/* recursica-ignore: --recursica_ui-kit_components_time-picker_properties_icon-size */
|
|
8
11
|
/* recursica-ignore: --recursica_ui-kit_components_time-picker_properties_icon-text-gap */
|
|
12
|
+
/* recursica-ignore: --recursica_ui-kit_components_time-picker_properties_colors_icon-color */
|
|
9
13
|
/* recursica-ignore: --recursica_ui-kit_components_time-picker_properties_placeholder-opacity */
|
|
10
|
-
/* recursica-ignore: --recursica_ui-kit_components_time-
|
|
11
|
-
/* recursica-ignore: --recursica_ui-kit_components_time-
|
|
12
|
-
|
|
13
|
-
/*
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/*
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
14
|
+
/* recursica-ignore: --recursica_ui-kit_components_time-picker_variants_states_disabled_properties_colors_icon-color */
|
|
15
|
+
/* recursica-ignore: --recursica_ui-kit_components_time-picker_variants_states_error_properties_colors_icon-color */
|
|
16
|
+
|
|
17
|
+
/* LAYOUT SPACING OVERRIDES:
|
|
18
|
+
- Sets the --form-control-margin-bottom spacing hook to map component-specific layout tokens. */
|
|
19
|
+
.layoutOverride {
|
|
20
|
+
--form-control-margin-bottom: var(
|
|
21
|
+
--recursica_ui-kit_components_time-picker_variants_layouts_stacked_properties_top-bottom-margin
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.layoutOverride[data-form-layout="side-by-side"] {
|
|
26
|
+
--form-control-margin-bottom: var(
|
|
27
|
+
--recursica_ui-kit_components_time-picker_variants_layouts_side-by-side_properties_top-bottom-margin
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* HARDCODED VALUES:
|
|
32
|
+
- border-style: solid. Native structural rendering rule.
|
|
33
|
+
- display: flex on .root — the time field and the AM/PM BareDropdown are two visually separate
|
|
34
|
+
controls sitting side by side, not merged into one shared box (BareDropdown draws its own
|
|
35
|
+
border/background from Dropdown.module.css). See TIMEPICKER_IMPLEMENTATION_NOTES.md.
|
|
36
|
+
- MUI X's field variant can't be forced from this component's public API (see
|
|
37
|
+
TIMEPICKER_IMPLEMENTATION_NOTES.md) — whichever native decoration it renders is suppressed
|
|
38
|
+
below, and our own border/background are applied to .field instead.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
.root {
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: flex-start;
|
|
44
|
+
gap: var(
|
|
45
|
+
--recursica_ui-kit_components_time-picker_properties_horizontal-padding
|
|
46
|
+
);
|
|
47
|
+
width: fit-content;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.field {
|
|
51
|
+
/* min-width, not width: the `width` token was authored for a single plain input (confirmed against
|
|
52
|
+
text-field's identical token shape); this is now only the time-entry half of the composite. */
|
|
53
|
+
min-width: var(--recursica_ui-kit_components_time-picker_properties_width);
|
|
54
|
+
width: fit-content;
|
|
55
|
+
border-radius: var(
|
|
56
|
+
--recursica_ui-kit_components_time-picker_properties_border-radius
|
|
57
|
+
);
|
|
58
|
+
border-width: var(
|
|
59
|
+
--recursica_ui-kit_components_time-picker_properties_border-size
|
|
60
|
+
);
|
|
61
|
+
border-style: solid;
|
|
62
|
+
border-color: var(
|
|
63
|
+
--recursica_ui-kit_components_time-picker_properties_colors_border-color
|
|
64
|
+
);
|
|
65
|
+
background-color: var(
|
|
66
|
+
--recursica_ui-kit_components_time-picker_properties_colors_background-color
|
|
67
|
+
);
|
|
68
|
+
color: var(
|
|
69
|
+
--recursica_ui-kit_components_time-picker_properties_colors_text-color
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Suppress whichever native field decoration MUI X renders by default (its public API doesn't
|
|
74
|
+
expose a variant prop to force "standard" in this version) — .field draws the border instead,
|
|
75
|
+
regardless of whether the field defaults to "outlined" or "standard". */
|
|
76
|
+
.field :global(.MuiPickersInputBase-root::before),
|
|
77
|
+
.field :global(.MuiPickersInputBase-root::after),
|
|
78
|
+
.field :global(.MuiInput-root::before),
|
|
79
|
+
.field :global(.MuiInput-root::after) {
|
|
80
|
+
border-bottom: none !important;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.field :global(.MuiPickersOutlinedInput-notchedOutline) {
|
|
84
|
+
border: none !important;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.field :global(.MuiPickersInputBase-sectionsContainer) {
|
|
88
|
+
/* MUI X computes and inline-sets a literal pixel width here based on the format string (e.g.
|
|
89
|
+
182px for "hh:mm"), sized generously to fit the widest possible rendered value — wider than
|
|
90
|
+
.field's own `width: fit-content` intends. Reset it so the field visually matches Mantine's
|
|
91
|
+
equally-compact time input; the section <span>s are real text content, so width: auto sizes to
|
|
92
|
+
them correctly (unlike the native-<input>-in-BareDropdown case elsewhere in this file, where
|
|
93
|
+
`auto` didn't help — no UA-default-sizing quirk here since these aren't native inputs). */
|
|
94
|
+
width: auto !important;
|
|
95
|
+
flex-grow: 0 !important;
|
|
96
|
+
padding-top: var(
|
|
97
|
+
--recursica_ui-kit_components_time-picker_properties_vertical-padding
|
|
98
|
+
);
|
|
99
|
+
padding-bottom: var(
|
|
100
|
+
--recursica_ui-kit_components_time-picker_properties_vertical-padding
|
|
101
|
+
);
|
|
102
|
+
padding-left: var(
|
|
103
|
+
--recursica_ui-kit_components_time-picker_properties_horizontal-padding
|
|
104
|
+
);
|
|
105
|
+
padding-right: var(
|
|
106
|
+
--recursica_ui-kit_components_time-picker_properties_horizontal-padding
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
font-family: var(
|
|
110
|
+
--recursica_ui-kit_components_time-picker_properties_text_font-family
|
|
111
|
+
);
|
|
112
|
+
font-size: var(
|
|
113
|
+
--recursica_ui-kit_components_time-picker_properties_text_font-size
|
|
114
|
+
);
|
|
115
|
+
font-style: var(
|
|
116
|
+
--recursica_ui-kit_components_time-picker_properties_text_font-style
|
|
117
|
+
);
|
|
118
|
+
font-weight: var(
|
|
119
|
+
--recursica_ui-kit_components_time-picker_properties_text_font-weight
|
|
120
|
+
);
|
|
121
|
+
letter-spacing: var(
|
|
122
|
+
--recursica_ui-kit_components_time-picker_properties_text_letter-spacing
|
|
123
|
+
);
|
|
124
|
+
line-height: var(
|
|
125
|
+
--recursica_ui-kit_components_time-picker_properties_text_line-height
|
|
126
|
+
);
|
|
127
|
+
text-decoration: var(
|
|
128
|
+
--recursica_ui-kit_components_time-picker_properties_text_text-decoration
|
|
129
|
+
);
|
|
130
|
+
text-transform: var(
|
|
131
|
+
--recursica_ui-kit_components_time-picker_properties_text_text-transform
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.field :global(.MuiPickersInputBase-input) {
|
|
136
|
+
color: inherit;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* The AM/PM BareDropdown reuses Dropdown.module.css's own border/background/padding entirely —
|
|
140
|
+
this only controls its size/alignment within the flex row. */
|
|
141
|
+
.amPmSelect {
|
|
142
|
+
flex: 0 0 auto;
|
|
143
|
+
align-self: flex-start;
|
|
144
|
+
width: auto;
|
|
145
|
+
min-width: 5.5rem;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* MUI's own generated class for the select's inner box (a compound selector, e.g.
|
|
149
|
+
`.css-xxx-...-MuiSelect-select`) has higher specificity than Dropdown.module.css's single-class
|
|
150
|
+
`.input` rule, so its own `min-height: 1.4375em` (~23px) silently wins over our 48px token —
|
|
151
|
+
this is a latent bug in the shared Dropdown.module.css itself (the standalone Dropdown
|
|
152
|
+
component has the exact same undersized box; flagged separately, not fixed here to avoid an
|
|
153
|
+
app-wide change outside TimePicker's scope). `!important` here only re-asserts the height
|
|
154
|
+
Dropdown was always supposed to have, scoped to this composite. MUI's outlined variant also
|
|
155
|
+
renders its own native `fieldset`/`notchedOutline` border *in addition to* `.input`'s own
|
|
156
|
+
Recursica border — suppressed the same way the time field already suppresses its own native
|
|
157
|
+
decoration above. See TIMEPICKER_IMPLEMENTATION_NOTES.md. */
|
|
158
|
+
.amPmSelect :global(.MuiSelect-select) {
|
|
159
|
+
min-height: var(
|
|
160
|
+
--recursica_ui-kit_globals_form_field_size_single-line-input-height
|
|
161
|
+
) !important;
|
|
162
|
+
box-sizing: border-box !important;
|
|
163
|
+
/* Forcing min-height above leaves real slack below the (block-flow, top-aligned) text once the
|
|
164
|
+
box is taller than its own padding + line-height — the value read as "not centered". Flex +
|
|
165
|
+
center distributes that slack evenly instead. */
|
|
166
|
+
display: flex !important;
|
|
167
|
+
align-items: center !important;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.amPmSelect :global(.MuiOutlinedInput-notchedOutline) {
|
|
171
|
+
border: none !important;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/* -------------------------------------
|
|
175
|
+
STATE CASCADE ARCHITECTURE
|
|
176
|
+
-------------------------------------- */
|
|
177
|
+
|
|
178
|
+
/* Focus State Mapping — applied to the time field only (the BareDropdown has its own via
|
|
179
|
+
Dropdown's own CSS module). */
|
|
180
|
+
.field:has(:global(.Mui-focused)) {
|
|
181
|
+
box-shadow:
|
|
182
|
+
0 0 0 var(--recursica_brand_states_focus_border-size)
|
|
183
|
+
var(--recursica_brand_states_focus_color),
|
|
184
|
+
0 0 var(--recursica_brand_states_focus_blur)
|
|
185
|
+
var(--recursica_brand_states_focus_margin)
|
|
186
|
+
var(--recursica_brand_states_focus_color);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/* Error State Mapping (data-error is set explicitly by TimePicker.tsx). */
|
|
190
|
+
.root[data-error="true"] .field {
|
|
191
|
+
border-color: var(
|
|
192
|
+
--recursica_ui-kit_components_time-picker_variants_states_error_properties_colors_border-color
|
|
193
|
+
) !important;
|
|
194
|
+
background-color: var(
|
|
195
|
+
--recursica_ui-kit_components_time-picker_variants_states_error_properties_colors_background-color
|
|
196
|
+
) !important;
|
|
197
|
+
color: var(
|
|
198
|
+
--recursica_ui-kit_components_time-picker_variants_states_error_properties_colors_text-color
|
|
199
|
+
) !important;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/* Disabled State Mapping */
|
|
203
|
+
.field:has(:global(.Mui-disabled)) {
|
|
204
|
+
border-color: var(
|
|
205
|
+
--recursica_ui-kit_components_time-picker_variants_states_disabled_properties_colors_border-color
|
|
206
|
+
) !important;
|
|
207
|
+
background-color: var(
|
|
208
|
+
--recursica_ui-kit_components_time-picker_variants_states_disabled_properties_colors_background-color
|
|
209
|
+
) !important;
|
|
210
|
+
color: var(
|
|
211
|
+
--recursica_ui-kit_components_time-picker_variants_states_disabled_properties_colors_text-color
|
|
212
|
+
) !important;
|
|
213
|
+
opacity: var(
|
|
214
|
+
--recursica_ui-kit_components_time-picker_variants_states_disabled_properties_opacity
|
|
215
|
+
) !important;
|
|
216
|
+
cursor: not-allowed;
|
|
217
|
+
}
|
|
@@ -1,12 +1,75 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
2
|
import { TimePicker } from "./TimePicker";
|
|
3
|
-
import {
|
|
3
|
+
import { formControlArgTypes } from "../../../.storybook/commonArgTypes";
|
|
4
4
|
|
|
5
5
|
const meta: Meta<typeof TimePicker> = {
|
|
6
|
-
title: "UI-Kit
|
|
6
|
+
title: "UI-Kit/TimePicker",
|
|
7
7
|
component: TimePicker,
|
|
8
8
|
tags: ["autodocs"],
|
|
9
|
-
|
|
9
|
+
parameters: {
|
|
10
|
+
controls: {
|
|
11
|
+
include: [
|
|
12
|
+
"value",
|
|
13
|
+
"defaultValue",
|
|
14
|
+
"disabled",
|
|
15
|
+
"error",
|
|
16
|
+
"required",
|
|
17
|
+
"label",
|
|
18
|
+
"assistiveText",
|
|
19
|
+
"readOnly",
|
|
20
|
+
"withSeconds",
|
|
21
|
+
"formLayout",
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
docs: {
|
|
25
|
+
description: {
|
|
26
|
+
component: `
|
|
27
|
+
The \`TimePicker\` primitive provides a 12-hour time field (via \`@mui/x-date-pickers\`) paired with a dedicated AM/PM \`Dropdown\`-style selector, integrated directly into the \`FormControlWrapper\` architecture. This composite is the only way this component operates — a Recursica-specific design, not a user-configurable option.
|
|
28
|
+
|
|
29
|
+
### Examples
|
|
30
|
+
Always structure horizontal architectures via the generic \`formLayout\` parameter.
|
|
31
|
+
\`\`\`tsx
|
|
32
|
+
<TimePicker
|
|
33
|
+
label="Start Time"
|
|
34
|
+
assistiveText="Select the deployment kick-off time."
|
|
35
|
+
formLayout="stacked"
|
|
36
|
+
/>
|
|
37
|
+
\`\`\`
|
|
38
|
+
`,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
argTypes: {
|
|
43
|
+
...formControlArgTypes,
|
|
44
|
+
disabled: {
|
|
45
|
+
control: "boolean",
|
|
46
|
+
description:
|
|
47
|
+
"Maps the formal disabled variable states structurally to the input core.",
|
|
48
|
+
},
|
|
49
|
+
error: {
|
|
50
|
+
control: "text",
|
|
51
|
+
description:
|
|
52
|
+
"Applies the strict error string boundary rendering invalid structures seamlessly.",
|
|
53
|
+
},
|
|
54
|
+
required: {
|
|
55
|
+
control: "boolean",
|
|
56
|
+
},
|
|
57
|
+
label: {
|
|
58
|
+
control: "text",
|
|
59
|
+
},
|
|
60
|
+
assistiveText: {
|
|
61
|
+
control: "text",
|
|
62
|
+
},
|
|
63
|
+
readOnly: {
|
|
64
|
+
control: "boolean",
|
|
65
|
+
description:
|
|
66
|
+
"Toggles structural read-only data presentation explicitly blocking standard component bindings.",
|
|
67
|
+
},
|
|
68
|
+
withSeconds: {
|
|
69
|
+
control: "boolean",
|
|
70
|
+
description: "Shows and allows editing the seconds segment.",
|
|
71
|
+
},
|
|
72
|
+
},
|
|
10
73
|
};
|
|
11
74
|
|
|
12
75
|
export default meta;
|
|
@@ -14,5 +77,57 @@ export default meta;
|
|
|
14
77
|
type Story = StoryObj<typeof TimePicker>;
|
|
15
78
|
|
|
16
79
|
export const Default: Story = {
|
|
17
|
-
|
|
80
|
+
args: {
|
|
81
|
+
disabled: false,
|
|
82
|
+
label: "Meeting Time",
|
|
83
|
+
assistiveText: "Choose the start time in your local timezone.",
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const FormsSideBySide: Story = {
|
|
88
|
+
args: {
|
|
89
|
+
label: "Incident Start Time",
|
|
90
|
+
assistiveText: "When did the incident originally occur?",
|
|
91
|
+
formLayout: "side-by-side",
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const WithSeconds: Story = {
|
|
96
|
+
args: {
|
|
97
|
+
label: "Precise Execution Time",
|
|
98
|
+
assistiveText: "Includes a seconds segment for exact scheduling.",
|
|
99
|
+
withSeconds: true,
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const Disabled: Story = {
|
|
104
|
+
args: {
|
|
105
|
+
label: "Disabled Time Slot",
|
|
106
|
+
disabled: true,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export const ErrorState: Story = {
|
|
111
|
+
args: {
|
|
112
|
+
label: "Deployment Window",
|
|
113
|
+
error: "The chosen time falls outside the allowed deployment window.",
|
|
114
|
+
required: true,
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const StaticReadOnly: Story = {
|
|
119
|
+
args: {
|
|
120
|
+
label: "Static ReadOnly Review",
|
|
121
|
+
value: "14:30",
|
|
122
|
+
readOnly: true,
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export const EditableReadOnly: Story = {
|
|
127
|
+
args: {
|
|
128
|
+
label: "Editable ReadOnly Review",
|
|
129
|
+
defaultValue: "09:00",
|
|
130
|
+
readOnly: true,
|
|
131
|
+
labelWithEditIcon: true,
|
|
132
|
+
},
|
|
18
133
|
};
|
|
@@ -1,10 +1,259 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import "
|
|
3
|
-
import {
|
|
1
|
+
import React, { forwardRef, useEffect, useState } from "react";
|
|
2
|
+
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
|
|
3
|
+
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
|
|
4
|
+
import {
|
|
5
|
+
TimePicker as MuiTimePicker,
|
|
6
|
+
type TimePickerProps as MuiTimePickerProps,
|
|
7
|
+
} from "@mui/x-date-pickers/TimePicker";
|
|
8
|
+
import dayjs, { type Dayjs } from "dayjs";
|
|
9
|
+
import customParseFormat from "dayjs/plugin/customParseFormat";
|
|
10
|
+
import { type ReadOnlyControlProps } from "@recursica/adapter-common";
|
|
11
|
+
import {
|
|
12
|
+
filterStylingProps,
|
|
13
|
+
type RecursicaOverStyled,
|
|
14
|
+
} from "../../utils/filterStylingProps";
|
|
15
|
+
import { type RecursicaFormControlWrapperProps } from "../FormControlWrapper/FormControlWrapper";
|
|
16
|
+
import { WithReadOnlyWrapper } from "../ReadOnlyField/WithReadOnlyWrapper";
|
|
17
|
+
import { BareDropdown } from "../Dropdown/BareDropdown";
|
|
18
|
+
import styles from "./TimePicker.module.css";
|
|
4
19
|
|
|
5
|
-
|
|
6
|
-
RecursicaTimePickerProps;
|
|
20
|
+
import { type RecursicaTimePickerProps as BaseRecursicaTimePickerProps } from "@recursica/adapter-common";
|
|
7
21
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
22
|
+
// Required for dayjs's 2-arg `dayjs(value, format)` string-parsing signature used by `toDayjs`
|
|
23
|
+
// below — without this, dayjs silently ignores the format string and falls back to native `Date`
|
|
24
|
+
// parsing, which fails on a bare "HH:mm" time string (no date component) and returns an Invalid
|
|
25
|
+
// Date. This went unnoticed until a real initial `value`/`defaultValue` needed parsing (every
|
|
26
|
+
// interactive test before that produced Dayjs objects directly from the field's own onChange,
|
|
27
|
+
// never exercising this path).
|
|
28
|
+
dayjs.extend(customParseFormat);
|
|
29
|
+
|
|
30
|
+
const TIME_FORMAT_SECONDS = "HH:mm:ss";
|
|
31
|
+
const TIME_FORMAT_MINUTES = "HH:mm";
|
|
32
|
+
const AM_PM_DATA = [
|
|
33
|
+
{ value: "AM", label: "AM" },
|
|
34
|
+
{ value: "PM", label: "PM" },
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
/** Parses a Recursica "HH:mm" / "HH:mm:ss" string into a Dayjs instance, or undefined if not set. */
|
|
38
|
+
function toDayjs(value: string | undefined): Dayjs | undefined {
|
|
39
|
+
if (!value) return undefined;
|
|
40
|
+
const format = value.length > 5 ? TIME_FORMAT_SECONDS : TIME_FORMAT_MINUTES;
|
|
41
|
+
return dayjs(value, format);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Formats an "HH:mm"/"HH:mm:ss" 24-hour value as a 12-hour + AM/PM string for read-only display
|
|
46
|
+
* (e.g. "14:30" -> "2:30 PM") — the raw 24-hour string was being shown as-is in read-only mode,
|
|
47
|
+
* with no AM/PM, unlike the interactive composite. Returns undefined if not parseable.
|
|
48
|
+
*/
|
|
49
|
+
function formatReadOnlyTime(value: string | undefined): string | undefined {
|
|
50
|
+
const parsed = toDayjs(value);
|
|
51
|
+
if (!parsed) return value;
|
|
52
|
+
return parsed.format(value && value.length > 5 ? "h:mm:ss A" : "h:mm A");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface RecursicaTimePickerProps
|
|
56
|
+
extends Omit<
|
|
57
|
+
MuiTimePickerProps,
|
|
58
|
+
| "value"
|
|
59
|
+
| "defaultValue"
|
|
60
|
+
| "onChange"
|
|
61
|
+
| "minTime"
|
|
62
|
+
| "maxTime"
|
|
63
|
+
| "views"
|
|
64
|
+
| "format"
|
|
65
|
+
| "style"
|
|
66
|
+
>,
|
|
67
|
+
Pick<
|
|
68
|
+
RecursicaFormControlWrapperProps,
|
|
69
|
+
| "label"
|
|
70
|
+
| "error"
|
|
71
|
+
| "required"
|
|
72
|
+
| "id"
|
|
73
|
+
| "assistiveText"
|
|
74
|
+
| "assistiveWithIcon"
|
|
75
|
+
| "formLayout"
|
|
76
|
+
| "labelSize"
|
|
77
|
+
| "labelAlignment"
|
|
78
|
+
| "labelOptionalText"
|
|
79
|
+
| "labelWithEditIcon"
|
|
80
|
+
| "onLabelEditClick"
|
|
81
|
+
>,
|
|
82
|
+
ReadOnlyControlProps,
|
|
83
|
+
BaseRecursicaTimePickerProps {
|
|
84
|
+
/** Selected time as an "HH:mm" (or "HH:mm:ss" with `withSeconds`) string, matching the mantine-adapter convention. */
|
|
85
|
+
value?: string;
|
|
86
|
+
/** Uncontrolled initial time as an "HH:mm" (or "HH:mm:ss" with `withSeconds`) string. */
|
|
87
|
+
defaultValue?: string;
|
|
88
|
+
/** Fires with the new time as an "HH:mm" (or "HH:mm:ss" with `withSeconds`) string, or `null` if cleared. */
|
|
89
|
+
onChange?: (value: string | null) => void;
|
|
90
|
+
/** Caller-provided inline style, passed through to the FormControlWrapper root. */
|
|
91
|
+
style?: React.CSSProperties;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export type TimePickerProps = RecursicaOverStyled<RecursicaTimePickerProps>;
|
|
95
|
+
|
|
96
|
+
export const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(
|
|
97
|
+
function TimePicker(props, ref) {
|
|
98
|
+
const {
|
|
99
|
+
overStyled = false,
|
|
100
|
+
formLayout = "stacked",
|
|
101
|
+
|
|
102
|
+
// Label & Wrapper Maps
|
|
103
|
+
labelSize,
|
|
104
|
+
labelAlignment,
|
|
105
|
+
labelOptionalText,
|
|
106
|
+
labelWithEditIcon,
|
|
107
|
+
onLabelEditClick,
|
|
108
|
+
|
|
109
|
+
label,
|
|
110
|
+
assistiveText,
|
|
111
|
+
assistiveWithIcon,
|
|
112
|
+
error,
|
|
113
|
+
required,
|
|
114
|
+
id,
|
|
115
|
+
className,
|
|
116
|
+
style,
|
|
117
|
+
disabled,
|
|
118
|
+
readOnly,
|
|
119
|
+
readOnlyComponent,
|
|
120
|
+
emptyValueComponent,
|
|
121
|
+
value,
|
|
122
|
+
defaultValue,
|
|
123
|
+
onChange,
|
|
124
|
+
withSeconds,
|
|
125
|
+
minTime,
|
|
126
|
+
maxTime,
|
|
127
|
+
...rest
|
|
128
|
+
} = props;
|
|
129
|
+
|
|
130
|
+
const sanitizedProps = filterStylingProps(rest, overStyled);
|
|
131
|
+
|
|
132
|
+
// Internal full 24-hour value. Needed (unlike every other component in this adapter) because
|
|
133
|
+
// the time field and the AM/PM BareDropdown both mutate the same conceptual value — see
|
|
134
|
+
// TIMEPICKER_IMPLEMENTATION_NOTES.md.
|
|
135
|
+
const [internalValue, setInternalValue] = useState<Dayjs | null>(
|
|
136
|
+
() => toDayjs(value) ?? toDayjs(defaultValue) ?? null,
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
if (value !== undefined) {
|
|
141
|
+
setInternalValue(toDayjs(value) ?? null);
|
|
142
|
+
}
|
|
143
|
+
}, [value]);
|
|
144
|
+
|
|
145
|
+
const isPM = internalValue ? internalValue.hour() >= 12 : false;
|
|
146
|
+
|
|
147
|
+
const wrapperClass = className
|
|
148
|
+
? `${styles.layoutOverride} ${className}`
|
|
149
|
+
: styles.layoutOverride;
|
|
150
|
+
|
|
151
|
+
const emitChange = (next: Dayjs | null) => {
|
|
152
|
+
setInternalValue(next);
|
|
153
|
+
onChange?.(
|
|
154
|
+
next
|
|
155
|
+
? next.format(withSeconds ? TIME_FORMAT_SECONDS : TIME_FORMAT_MINUTES)
|
|
156
|
+
: null,
|
|
157
|
+
);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const handleFieldChange = (next: Dayjs | null) => {
|
|
161
|
+
emitChange(next);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const handleMeridiemChange = (next: string | null) => {
|
|
165
|
+
if (!internalValue || !next) return;
|
|
166
|
+
const wantsPM = next === "PM";
|
|
167
|
+
const currentHour = internalValue.hour();
|
|
168
|
+
const currentlyPM = currentHour >= 12;
|
|
169
|
+
if (wantsPM === currentlyPM) return;
|
|
170
|
+
const nextHour = wantsPM ? currentHour + 12 : currentHour - 12;
|
|
171
|
+
emitChange(internalValue.hour(nextHour));
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
return (
|
|
175
|
+
<WithReadOnlyWrapper
|
|
176
|
+
ref={ref}
|
|
177
|
+
className={wrapperClass}
|
|
178
|
+
style={style as React.CSSProperties}
|
|
179
|
+
controlMaxWidth={undefined}
|
|
180
|
+
controlMinWidth={undefined}
|
|
181
|
+
overStyled={overStyled as true}
|
|
182
|
+
formLayout={formLayout}
|
|
183
|
+
labelSize={labelSize}
|
|
184
|
+
labelAlignment={labelAlignment}
|
|
185
|
+
labelOptionalText={labelOptionalText}
|
|
186
|
+
labelWithEditIcon={labelWithEditIcon}
|
|
187
|
+
onLabelEditClick={onLabelEditClick}
|
|
188
|
+
label={label}
|
|
189
|
+
assistiveText={assistiveText}
|
|
190
|
+
assistiveWithIcon={assistiveWithIcon}
|
|
191
|
+
error={error}
|
|
192
|
+
required={required}
|
|
193
|
+
id={id}
|
|
194
|
+
readOnly={readOnly}
|
|
195
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
196
|
+
readOnlyComponent={readOnlyComponent as any}
|
|
197
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
198
|
+
emptyValueComponent={(emptyValueComponent as any) || undefined}
|
|
199
|
+
readOnlyType="text"
|
|
200
|
+
readOnlyValue={formatReadOnlyTime(
|
|
201
|
+
value !== undefined ? value : defaultValue,
|
|
202
|
+
)}
|
|
203
|
+
readOnlyNativeProps={props}
|
|
204
|
+
activeComponent={
|
|
205
|
+
/* Naked field execution safely decoupled from MUI X's own label/error macro handling.
|
|
206
|
+
format="hh:mm" is always on (12-hour digits, no native meridiem section) — this is the
|
|
207
|
+
only way this component operates, not a user choice. The AM/PM BareDropdown next to it
|
|
208
|
+
is the only AM/PM control; see TIMEPICKER_IMPLEMENTATION_NOTES.md. */
|
|
209
|
+
<div className={styles.root} data-error={error ? "true" : undefined}>
|
|
210
|
+
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
|
211
|
+
<MuiTimePicker
|
|
212
|
+
value={internalValue}
|
|
213
|
+
onChange={handleFieldChange}
|
|
214
|
+
disabled={disabled}
|
|
215
|
+
format={`hh:${withSeconds ? "mm:ss" : "mm"}`}
|
|
216
|
+
views={
|
|
217
|
+
withSeconds
|
|
218
|
+
? ["hours", "minutes", "seconds"]
|
|
219
|
+
: ["hours", "minutes"]
|
|
220
|
+
}
|
|
221
|
+
minTime={toDayjs(minTime)}
|
|
222
|
+
maxTime={toDayjs(maxTime)}
|
|
223
|
+
// No icon/open-picker button: time-picker's own token schema has no icon slot (see
|
|
224
|
+
// EXEMPTIONS above), and the popup clock/list view this button opens isn't styled
|
|
225
|
+
// to Recursica tokens anyway (see TIMEPICKER_IMPLEMENTATION_NOTES.md) — showing an
|
|
226
|
+
// affordance to open an unstyled popup would be worse than not showing one. Typing
|
|
227
|
+
// directly into the field's masked hour/minute segments is the only interaction.
|
|
228
|
+
slots={{ openPickerButton: () => null }}
|
|
229
|
+
slotProps={{
|
|
230
|
+
field: {
|
|
231
|
+
className: styles.field,
|
|
232
|
+
},
|
|
233
|
+
}}
|
|
234
|
+
{...(sanitizedProps as unknown as Partial<MuiTimePickerProps>)}
|
|
235
|
+
/>
|
|
236
|
+
</LocalizationProvider>
|
|
237
|
+
<BareDropdown
|
|
238
|
+
overStyled
|
|
239
|
+
className={styles.amPmSelect}
|
|
240
|
+
// Dropdown.module.css's own .root sets width: 100% (correct for a standalone
|
|
241
|
+
// Dropdown filling its form-control column) — overStyled lets us override just the
|
|
242
|
+
// width via inline style, keeping every other Recursica style (border, colors,
|
|
243
|
+
// padding) intact. See TIMEPICKER_IMPLEMENTATION_NOTES.md.
|
|
244
|
+
style={{ width: "fit-content" }}
|
|
245
|
+
data={AM_PM_DATA}
|
|
246
|
+
value={isPM ? "PM" : "AM"}
|
|
247
|
+
onChange={handleMeridiemChange}
|
|
248
|
+
disabled={disabled}
|
|
249
|
+
error={!!error}
|
|
250
|
+
aria-label="AM or PM"
|
|
251
|
+
/>
|
|
252
|
+
</div>
|
|
253
|
+
}
|
|
254
|
+
/>
|
|
255
|
+
);
|
|
256
|
+
},
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
TimePicker.displayName = "TimePicker";
|