@musecat/uikit 0.1.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/LICENSE +9 -0
- package/README.md +51 -0
- package/index.ts +78 -0
- package/package.json +103 -0
- package/packages/Components/Box/Box.tsx +173 -0
- package/packages/Components/Box/Box.types.ts +48 -0
- package/packages/Components/Button/Button.tsx +275 -0
- package/packages/Components/Button/Button.types.ts +44 -0
- package/packages/Components/Card/Card.default.tsx +180 -0
- package/packages/Components/Card/Card.foldable.tsx +383 -0
- package/packages/Components/Card/Card.module.scss +23 -0
- package/packages/Components/Card/Card.tsx +8 -0
- package/packages/Components/Card/Card.types.ts +91 -0
- package/packages/Components/Card/Card.utils.ts +66 -0
- package/packages/Components/Checkbox/Checkbox.module.scss +11 -0
- package/packages/Components/Checkbox/Checkbox.tsx +104 -0
- package/packages/Components/Checkbox/Checkbox.types.ts +24 -0
- package/packages/Components/CodeBox/CodeBox.copy.tsx +43 -0
- package/packages/Components/CodeBox/CodeBox.module.scss +72 -0
- package/packages/Components/CodeBox/CodeBox.tsx +91 -0
- package/packages/Components/CodeBox/CodeBox.types.ts +17 -0
- package/packages/Components/ContextMenu/ContextMenu.module.scss +8 -0
- package/packages/Components/ContextMenu/ContextMenu.options.tsx +126 -0
- package/packages/Components/ContextMenu/ContextMenu.tsx +381 -0
- package/packages/Components/ContextMenu/ContextMenu.types.ts +46 -0
- package/packages/Components/ContributionGraph/ContributionGraph.module.scss +42 -0
- package/packages/Components/ContributionGraph/ContributionGraph.tsx +454 -0
- package/packages/Components/ContributionGraph/ContributionGraph.types.ts +27 -0
- package/packages/Components/DatePicker/DatePicker.calendar.tsx +161 -0
- package/packages/Components/DatePicker/DatePicker.core.tsx +582 -0
- package/packages/Components/DatePicker/DatePicker.module.scss +26 -0
- package/packages/Components/DatePicker/DatePicker.tsx +786 -0
- package/packages/Components/DatePicker/DatePicker.types.ts +36 -0
- package/packages/Components/DatePicker/DatePicker.utils.ts +80 -0
- package/packages/Components/DatePicker/hooks/useCalendar.ts +61 -0
- package/packages/Components/DatePicker/hooks/useSelection.ts +208 -0
- package/packages/Components/Divider/Divider.tsx +46 -0
- package/packages/Components/Divider/Divider.types.ts +12 -0
- package/packages/Components/Header/Header.module.scss +74 -0
- package/packages/Components/Header/Header.tsx +47 -0
- package/packages/Components/Header/Header.types.ts +8 -0
- package/packages/Components/Icon/Icon.group.tsx +122 -0
- package/packages/Components/Icon/Icon.group.types.ts +20 -0
- package/packages/Components/Icon/Icon.tsx +341 -0
- package/packages/Components/Icon/Icon.types.ts +59 -0
- package/packages/Components/Icon/SVG/data.tsx +232 -0
- package/packages/Components/Input/Input.module.scss +5 -0
- package/packages/Components/Input/Input.tsx +87 -0
- package/packages/Components/Input/Input.types.ts +14 -0
- package/packages/Components/Label/Label.module.scss +19 -0
- package/packages/Components/Label/Label.tsx +115 -0
- package/packages/Components/Label/Label.types.ts +28 -0
- package/packages/Components/Layout/Layout.docs.module.scss +42 -0
- package/packages/Components/Layout/Layout.docs.tsx +150 -0
- package/packages/Components/Layout/Layout.docs.types.ts +18 -0
- package/packages/Components/Layout/Layout.module.scss +91 -0
- package/packages/Components/Layout/Layout.tsx +306 -0
- package/packages/Components/Layout/Layout.types.ts +71 -0
- package/packages/Components/Maps/OSM/MapOSM.module.scss +11 -0
- package/packages/Components/Maps/OSM/MapOSM.shared.ts +121 -0
- package/packages/Components/Maps/OSM/MapOSM.tsx +279 -0
- package/packages/Components/Maps/OSM/MapOSM.types.ts +18 -0
- package/packages/Components/Nav/Nav.module.scss +137 -0
- package/packages/Components/Nav/Nav.tsx +304 -0
- package/packages/Components/Nav/Nav.types.ts +32 -0
- package/packages/Components/Nav/hooks/useNavDrag.ts +374 -0
- package/packages/Components/Nav/hooks/useNavIndicator.ts +137 -0
- package/packages/Components/Pagination/Pagination.tsx +254 -0
- package/packages/Components/Pagination/Pagination.types.ts +18 -0
- package/packages/Components/Pill/Pill.tsx +127 -0
- package/packages/Components/Pill/Pill.types.ts +33 -0
- package/packages/Components/Profile/Profile.shared.ts +74 -0
- package/packages/Components/Profile/Profile.tsx +382 -0
- package/packages/Components/Profile/Profile.types.ts +55 -0
- package/packages/Components/Progress/Progress.module.scss +15 -0
- package/packages/Components/Progress/Progress.tsx +88 -0
- package/packages/Components/Progress/Progress.types.ts +22 -0
- package/packages/Components/Radio/Radio.module.scss +11 -0
- package/packages/Components/Radio/Radio.tsx +121 -0
- package/packages/Components/Radio/Radio.types.ts +20 -0
- package/packages/Components/Select/Select.keyboard.tsx +76 -0
- package/packages/Components/Select/Select.trigger.tsx +88 -0
- package/packages/Components/Select/Select.tsx +11 -0
- package/packages/Components/Select/Select.types.ts +38 -0
- package/packages/Components/Select/Select.utils.ts +84 -0
- package/packages/Components/Select/hooks/useSelectNavigation.ts +461 -0
- package/packages/Components/Select/hooks/useSelectSelection.ts +142 -0
- package/packages/Components/Select/hooks/useSelectState.ts +314 -0
- package/packages/Components/Select/select.control.tsx +228 -0
- package/packages/Components/Select/select.inner.tsx +312 -0
- package/packages/Components/Skeleton/Skeleton.tsx +30 -0
- package/packages/Components/Skeleton/Skeleton.types.ts +12 -0
- package/packages/Components/Spinner/Spinner.module.scss +78 -0
- package/packages/Components/Spinner/Spinner.tsx +125 -0
- package/packages/Components/Spinner/Spinner.types.ts +19 -0
- package/packages/Components/Text/Text.module.scss +7 -0
- package/packages/Components/Text/Text.tsx +49 -0
- package/packages/Components/Text/Text.types.ts +33 -0
- package/packages/Components/TimePicker/TimePicker.core.tsx +448 -0
- package/packages/Components/TimePicker/TimePicker.module.scss +30 -0
- package/packages/Components/TimePicker/TimePicker.tsx +511 -0
- package/packages/Components/TimePicker/TimePicker.types.ts +22 -0
- package/packages/Components/Timeline/Timeline.tsx +111 -0
- package/packages/Components/Timeline/Timeline.types.ts +23 -0
- package/packages/Components/Title/Title.tsx +305 -0
- package/packages/Components/Title/Title.types.ts +64 -0
- package/packages/Components/Toggle/Toggle.module.scss +32 -0
- package/packages/Components/Toggle/Toggle.tsx +272 -0
- package/packages/Components/Toggle/Toggle.types.ts +17 -0
- package/packages/Components/Tooltip/Tooltip.module.scss +44 -0
- package/packages/Components/Tooltip/Tooltip.tsx +340 -0
- package/packages/Components/Tooltip/Tooltip.types.ts +38 -0
- package/packages/Frameworks/Dialog/Dialog.background.tsx +88 -0
- package/packages/Frameworks/Dialog/Dialog.boot.tsx +32 -0
- package/packages/Frameworks/Dialog/Dialog.store.ts +199 -0
- package/packages/Frameworks/Dialog/Dialog.tsx +185 -0
- package/packages/Frameworks/Dialog/Dialog.types.ts +264 -0
- package/packages/Frameworks/Dialog/Dialog.utils.ts +22 -0
- package/packages/Frameworks/Dialog/contents/Dialog.footer.tsx +79 -0
- package/packages/Frameworks/Dialog/contents/Dialog.funnel.tsx +260 -0
- package/packages/Frameworks/Dialog/contents/Dialog.header.tsx +137 -0
- package/packages/Frameworks/Dialog/hooks/useDialogPosition.ts +298 -0
- package/packages/Frameworks/Dialog/hooks/useSheetDrag.ts +325 -0
- package/packages/Frameworks/Dialog/hooks/useSheetGeometry.ts +201 -0
- package/packages/Frameworks/Dialog/hooks/useSheetProgressive.ts +98 -0
- package/packages/Frameworks/Dialog/renderers/renderModal.tsx +228 -0
- package/packages/Frameworks/Dialog/renderers/renderPopover.tsx +220 -0
- package/packages/Frameworks/Dialog/renderers/renderSheet.tsx +571 -0
- package/packages/Frameworks/EdgeEffect/EdgeEffect.tsx +52 -0
- package/packages/Frameworks/EdgeEffect/EdgeEffect.types.ts +5 -0
- package/packages/Frameworks/Motion/Motion.presets.ts +49 -0
- package/packages/Frameworks/Pressable/Pressable.module.scss +19 -0
- package/packages/Frameworks/Pressable/Pressable.tsx +651 -0
- package/packages/Frameworks/Pressable/Pressable.types.ts +73 -0
- package/packages/Frameworks/Squircle/Squircle.tsx +263 -0
- package/packages/Frameworks/Squircle/Squircle.types.ts +15 -0
- package/packages/Frameworks/Theme/Radius.types.ts +55 -0
- package/packages/Frameworks/Theme/Theme.types.ts +325 -0
- package/packages/Frameworks/Toaster/Toaster.boot.tsx +47 -0
- package/packages/Frameworks/Toaster/Toaster.module.scss +168 -0
- package/packages/Frameworks/Toaster/Toaster.types.ts +13 -0
- package/packages/Frameworks/View/DNDView/DNDView.module.scss +8 -0
- package/packages/Frameworks/View/DNDView/DNDView.tsx +470 -0
- package/packages/Frameworks/View/DNDView/DNDView.types.ts +61 -0
- package/packages/Frameworks/View/HScrollView/HScrollView.module.scss +59 -0
- package/packages/Frameworks/View/HScrollView/HScrollView.tsx +386 -0
- package/packages/Frameworks/View/HScrollView/HScrollView.types.ts +46 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.counter.tsx +27 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.footer.tsx +76 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.header.tsx +49 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.list.tsx +74 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.slide.tsx +71 -0
- package/packages/Frameworks/View/ImageView/Dialog/ImageDialog.tsx +175 -0
- package/packages/Frameworks/View/ImageView/Image.controls.tsx +39 -0
- package/packages/Frameworks/View/ImageView/Image.hooks.ts +82 -0
- package/packages/Frameworks/View/ImageView/Image.module.scss +7 -0
- package/packages/Frameworks/View/ImageView/Image.tsx +375 -0
- package/packages/Frameworks/View/ImageView/Image.types.ts +71 -0
- package/packages/Frameworks/View/ImageView/Image.utils.ts +79 -0
- package/packages/Frameworks/View/View.module.scss +34 -0
- package/packages/Frameworks/View/View.tsx +200 -0
- package/packages/Frameworks/View/View.types.ts +36 -0
- package/packages/Frameworks/_shared/Padding.types.ts +52 -0
- package/packages/Frameworks/_shared/StopParentInteraction.tsx +45 -0
- package/packages/Frameworks/_shared/Wind.types.ts +17 -0
- package/packages/Frameworks/_shared/bodyScrollLock.ts +127 -0
- package/packages/Frameworks/_shared/layer.constants.ts +8 -0
- package/packages/Frameworks/_shared/normalize.ts +39 -0
- package/packages/Frameworks/_shared/sizing.ts +55 -0
- package/packages/Frameworks/_shared/useControllableState.ts +29 -0
- package/packages/Styles/_animation.scss +42 -0
- package/packages/Styles/_color.scss +131 -0
- package/packages/Styles/_font.scss +30 -0
- package/packages/Styles/_icon.scss +782 -0
- package/packages/Styles/_importer.scss +9 -0
- package/packages/Styles/_system.scss +69 -0
- package/packages/Styles/_textstyle.scss +111 -0
- package/packages/Styles/_theme.scss +452 -0
- package/packages/Styles/_viewport-global.scss +99 -0
- package/packages/Styles/_viewport.scss +108 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type ReactElement,
|
|
5
|
+
type MouseEvent as ReactMouseEvent,
|
|
6
|
+
useMemo,
|
|
7
|
+
} from "react";
|
|
8
|
+
import ContextMenu from "@/packages/Components/ContextMenu/ContextMenu";
|
|
9
|
+
import Icon from "@/packages/Components/Icon/Icon";
|
|
10
|
+
import Label from "@/packages/Components/Label/Label";
|
|
11
|
+
import { useSelectNavigation } from "@/packages/Components/Select/hooks/useSelectNavigation";
|
|
12
|
+
import { useSelectSelection } from "@/packages/Components/Select/hooks/useSelectSelection";
|
|
13
|
+
import { useSelectState } from "@/packages/Components/Select/hooks/useSelectState";
|
|
14
|
+
import type { SelectProps } from "@/packages/Components/Select/Select.types";
|
|
15
|
+
import { filterOptionsByQuery } from "@/packages/Components/Select/Select.utils";
|
|
16
|
+
import SelectControl from "@/packages/Components/Select/select.control";
|
|
17
|
+
import View from "@/packages/Frameworks/View/View";
|
|
18
|
+
|
|
19
|
+
export default function SelectInner(props: SelectProps<boolean>): ReactElement {
|
|
20
|
+
const state = useSelectState(props);
|
|
21
|
+
const isSheet = state.isMobileSheet;
|
|
22
|
+
const selection = useSelectSelection(state);
|
|
23
|
+
const navigation = useSelectNavigation(state, selection);
|
|
24
|
+
|
|
25
|
+
const {
|
|
26
|
+
t,
|
|
27
|
+
isMultiple,
|
|
28
|
+
isTypeableControl,
|
|
29
|
+
isInteractionDisabled,
|
|
30
|
+
open,
|
|
31
|
+
setOpen,
|
|
32
|
+
activeIndex,
|
|
33
|
+
setActiveIndex,
|
|
34
|
+
openSource,
|
|
35
|
+
setOpenSource,
|
|
36
|
+
selectedValues,
|
|
37
|
+
query,
|
|
38
|
+
inputValue,
|
|
39
|
+
selectId,
|
|
40
|
+
listId,
|
|
41
|
+
popoverOwnerId,
|
|
42
|
+
rootRef,
|
|
43
|
+
controlRef,
|
|
44
|
+
pointerDownInsidePopoverRef,
|
|
45
|
+
isPopoverSearchActive,
|
|
46
|
+
visibleOptions,
|
|
47
|
+
flatOptions,
|
|
48
|
+
getFirstEnabledIndex,
|
|
49
|
+
isInOwnPopover,
|
|
50
|
+
isOptionSelectionDisabled,
|
|
51
|
+
props: rawProps,
|
|
52
|
+
} = state;
|
|
53
|
+
|
|
54
|
+
const { onInputChange } = rawProps;
|
|
55
|
+
const {
|
|
56
|
+
selectOption,
|
|
57
|
+
removeSelectedOption,
|
|
58
|
+
clearSelection,
|
|
59
|
+
emitNativeChange,
|
|
60
|
+
} = selection;
|
|
61
|
+
|
|
62
|
+
const contextMenuContents = useMemo(
|
|
63
|
+
() =>
|
|
64
|
+
visibleOptions.map((option) => {
|
|
65
|
+
const value = String(option.value);
|
|
66
|
+
const isSelected = selectedValues.includes(value);
|
|
67
|
+
return {
|
|
68
|
+
type: "option" as const,
|
|
69
|
+
value: option.value,
|
|
70
|
+
label: option.label,
|
|
71
|
+
icon: option.icon,
|
|
72
|
+
description: option.description,
|
|
73
|
+
disabled: isOptionSelectionDisabled(option),
|
|
74
|
+
selected: isSelected,
|
|
75
|
+
onClick: () => selectOption(option),
|
|
76
|
+
};
|
|
77
|
+
}),
|
|
78
|
+
[visibleOptions, selectedValues, isOptionSelectionDisabled, selectOption],
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const searchInputContent = isPopoverSearchActive ? (
|
|
82
|
+
<label
|
|
83
|
+
style={{
|
|
84
|
+
width: "100%",
|
|
85
|
+
padding: isSheet ? "0 .8rem .8rem .8rem" : undefined,
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
88
|
+
<View
|
|
89
|
+
padding={isSheet ? [12, 16] : [6, 8]}
|
|
90
|
+
radius={isSheet ? "Circle" : undefined}
|
|
91
|
+
themePreset={isSheet ? "BaseFull" : undefined}
|
|
92
|
+
gap={8}
|
|
93
|
+
width="100%"
|
|
94
|
+
>
|
|
95
|
+
<Icon icon="iSearch" size={20} opacity={0.8} />
|
|
96
|
+
<input
|
|
97
|
+
ref={state.popoverInputRef}
|
|
98
|
+
type="text"
|
|
99
|
+
style={{ width: "100%" }}
|
|
100
|
+
className="Subheadline"
|
|
101
|
+
value={query}
|
|
102
|
+
placeholder={`${t.UIKit.ui.select}...`}
|
|
103
|
+
onFocus={() => {
|
|
104
|
+
if (isInteractionDisabled) return;
|
|
105
|
+
state.setOpenSource("keyboard");
|
|
106
|
+
}}
|
|
107
|
+
onChange={(e) => {
|
|
108
|
+
if (isInteractionDisabled) return;
|
|
109
|
+
const val = e.target.value;
|
|
110
|
+
state.setOpenSource("keyboard");
|
|
111
|
+
state.setQuery(val);
|
|
112
|
+
onInputChange?.(val);
|
|
113
|
+
const nextVisible = filterOptionsByQuery(flatOptions, val);
|
|
114
|
+
state.setActiveIndex(getFirstEnabledIndex(nextVisible));
|
|
115
|
+
}}
|
|
116
|
+
onKeyDown={(e) => {
|
|
117
|
+
if (e.key === "Escape") {
|
|
118
|
+
setOpen(false);
|
|
119
|
+
const triggerEl = isTypeableControl
|
|
120
|
+
? (controlRef.current?.querySelector(
|
|
121
|
+
'input[data-select-input="true"]',
|
|
122
|
+
) as HTMLElement | null)
|
|
123
|
+
: (controlRef.current?.querySelector(
|
|
124
|
+
'button[data-select-trigger="true"]',
|
|
125
|
+
) as HTMLElement | null);
|
|
126
|
+
triggerEl?.focus();
|
|
127
|
+
}
|
|
128
|
+
if (e.key === "Backspace" && !query && isMultiple) {
|
|
129
|
+
e.preventDefault();
|
|
130
|
+
removeSelectedOption(
|
|
131
|
+
selectedValues[selectedValues.length - 1] ?? "",
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
}}
|
|
135
|
+
/>
|
|
136
|
+
</View>
|
|
137
|
+
</label>
|
|
138
|
+
) : undefined;
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<Label
|
|
142
|
+
data-color-mode={rawProps["data-color-mode"]}
|
|
143
|
+
htmlFor={selectId}
|
|
144
|
+
title={rawProps.title}
|
|
145
|
+
required={rawProps.required}
|
|
146
|
+
hint={rawProps.hint}
|
|
147
|
+
disabled={rawProps.disabled}
|
|
148
|
+
readOnly={rawProps.readOnly}
|
|
149
|
+
themePreset={rawProps.themePreset}
|
|
150
|
+
background={rawProps.background}
|
|
151
|
+
color={rawProps.color}
|
|
152
|
+
themeInteractive={rawProps.themeInteractive}
|
|
153
|
+
selected={rawProps.selected}
|
|
154
|
+
border={rawProps.border}
|
|
155
|
+
radius={rawProps.radius}
|
|
156
|
+
className={rawProps.className}
|
|
157
|
+
style={rawProps.style}
|
|
158
|
+
cursor={isTypeableControl ? "text" : undefined}
|
|
159
|
+
>
|
|
160
|
+
<View
|
|
161
|
+
data-color-mode={rawProps["data-color-mode"]}
|
|
162
|
+
ref={rootRef}
|
|
163
|
+
onKeyDownCapture={(e) => {
|
|
164
|
+
if (e.key === "Tab") {
|
|
165
|
+
state.lastClosedByTabRef.current = true;
|
|
166
|
+
setTimeout(() => {
|
|
167
|
+
state.lastClosedByTabRef.current = false;
|
|
168
|
+
}, 100);
|
|
169
|
+
|
|
170
|
+
const ownerEl = document.querySelector(
|
|
171
|
+
`[data-popover-owner="${popoverOwnerId}"]`,
|
|
172
|
+
);
|
|
173
|
+
if (ownerEl) {
|
|
174
|
+
const focusable = Array.from(
|
|
175
|
+
ownerEl.querySelectorAll(
|
|
176
|
+
'input, button, select, textarea, [tabindex="0"], [role="option"]',
|
|
177
|
+
),
|
|
178
|
+
).filter((el) => {
|
|
179
|
+
const style = window.getComputedStyle(el);
|
|
180
|
+
return (
|
|
181
|
+
style.display !== "none" &&
|
|
182
|
+
style.visibility !== "hidden" &&
|
|
183
|
+
!(el as any).disabled
|
|
184
|
+
);
|
|
185
|
+
}) as HTMLElement[];
|
|
186
|
+
|
|
187
|
+
if (focusable.length > 0) {
|
|
188
|
+
const activeEl = document.activeElement as HTMLElement | null;
|
|
189
|
+
const index = focusable.indexOf(activeEl!);
|
|
190
|
+
|
|
191
|
+
if (e.shiftKey) {
|
|
192
|
+
if (index === 0 || index === -1) {
|
|
193
|
+
e.preventDefault();
|
|
194
|
+
setOpen(false);
|
|
195
|
+
const triggerEl = isTypeableControl
|
|
196
|
+
? (controlRef.current?.querySelector(
|
|
197
|
+
'input[data-select-input="true"]',
|
|
198
|
+
) as HTMLElement | null)
|
|
199
|
+
: (controlRef.current?.querySelector(
|
|
200
|
+
'button[data-select-trigger="true"]',
|
|
201
|
+
) as HTMLElement | null);
|
|
202
|
+
triggerEl?.focus();
|
|
203
|
+
}
|
|
204
|
+
} else {
|
|
205
|
+
if (index === focusable.length - 1) {
|
|
206
|
+
setOpen(false);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}}
|
|
213
|
+
onBlur={(e) => {
|
|
214
|
+
const next = e.relatedTarget as Node | null;
|
|
215
|
+
if (pointerDownInsidePopoverRef.current) return;
|
|
216
|
+
if (next && (rootRef.current?.contains(next) || isInOwnPopover(next)))
|
|
217
|
+
return;
|
|
218
|
+
setOpen(false);
|
|
219
|
+
}}
|
|
220
|
+
>
|
|
221
|
+
<View
|
|
222
|
+
data-color-mode={rawProps["data-color-mode"]}
|
|
223
|
+
ref={controlRef}
|
|
224
|
+
width="100%"
|
|
225
|
+
alignItems="flex-end"
|
|
226
|
+
justifyContent="space-between"
|
|
227
|
+
gap={6}
|
|
228
|
+
>
|
|
229
|
+
<SelectControl
|
|
230
|
+
state={state}
|
|
231
|
+
emitNativeChange={emitNativeChange}
|
|
232
|
+
removeSelectedOption={removeSelectedOption}
|
|
233
|
+
navigation={navigation}
|
|
234
|
+
/>
|
|
235
|
+
|
|
236
|
+
<View alignItems="center" gap={4} style={{ margin: "-.2rem" }}>
|
|
237
|
+
{(isTypeableControl || isMultiple) &&
|
|
238
|
+
!isInteractionDisabled &&
|
|
239
|
+
(selectedValues.length > 0 ||
|
|
240
|
+
query ||
|
|
241
|
+
(!isMultiple && inputValue)) && (
|
|
242
|
+
<Icon
|
|
243
|
+
icon="iClose"
|
|
244
|
+
size={16}
|
|
245
|
+
opacity={0.8}
|
|
246
|
+
box
|
|
247
|
+
boxOptions={{ padding: ".4rem" }}
|
|
248
|
+
pressable={{
|
|
249
|
+
onMouseDown: (e: ReactMouseEvent<Element>) => {
|
|
250
|
+
e?.preventDefault?.();
|
|
251
|
+
e?.stopPropagation?.();
|
|
252
|
+
},
|
|
253
|
+
onClick: (e: ReactMouseEvent<Element>) => {
|
|
254
|
+
e?.preventDefault?.();
|
|
255
|
+
e?.stopPropagation?.();
|
|
256
|
+
clearSelection();
|
|
257
|
+
},
|
|
258
|
+
}}
|
|
259
|
+
/>
|
|
260
|
+
)}
|
|
261
|
+
<Icon
|
|
262
|
+
icon="iArrowKeyDown"
|
|
263
|
+
opacity={0.8}
|
|
264
|
+
boxOptions={{ padding: ".4rem" }}
|
|
265
|
+
size={16}
|
|
266
|
+
/>
|
|
267
|
+
</View>
|
|
268
|
+
</View>
|
|
269
|
+
|
|
270
|
+
<ContextMenu
|
|
271
|
+
open={open}
|
|
272
|
+
onOpenChange={setOpen}
|
|
273
|
+
anchorRef={controlRef as React.RefObject<HTMLElement>}
|
|
274
|
+
popoverOwnerId={popoverOwnerId}
|
|
275
|
+
listId={listId}
|
|
276
|
+
isInteractionDisabled={isInteractionDisabled}
|
|
277
|
+
contents={contextMenuContents}
|
|
278
|
+
activeIndex={activeIndex}
|
|
279
|
+
onActiveIndexChange={setActiveIndex}
|
|
280
|
+
openSource={openSource}
|
|
281
|
+
onOpenSourceChange={setOpenSource}
|
|
282
|
+
showCheck
|
|
283
|
+
recalcKey={`${selectedValues.join("|")}|${visibleOptions.length}|${openSource}|${isMultiple}|${query}|${inputValue}`}
|
|
284
|
+
popoverConfig={{
|
|
285
|
+
matchAnchorWidth: true,
|
|
286
|
+
offset: { x: "-1.6rem", width: "3.2rem" },
|
|
287
|
+
strategy:
|
|
288
|
+
isTypeableControl || isPopoverSearchActive || isMultiple
|
|
289
|
+
? "anchored"
|
|
290
|
+
: "center-selected",
|
|
291
|
+
selectedItemSelector: '[data-selected="true"]',
|
|
292
|
+
gap: 2,
|
|
293
|
+
maxHeight: 380,
|
|
294
|
+
header: isPopoverSearchActive
|
|
295
|
+
? {
|
|
296
|
+
content: searchInputContent,
|
|
297
|
+
}
|
|
298
|
+
: undefined,
|
|
299
|
+
}}
|
|
300
|
+
sheetConfig={{
|
|
301
|
+
header: isPopoverSearchActive
|
|
302
|
+
? {
|
|
303
|
+
content: searchInputContent,
|
|
304
|
+
}
|
|
305
|
+
: undefined,
|
|
306
|
+
}}
|
|
307
|
+
mobileMode="sheet"
|
|
308
|
+
/>
|
|
309
|
+
</View>
|
|
310
|
+
</Label>
|
|
311
|
+
);
|
|
312
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { SkeletonProps } from "@/packages/Components/Skeleton/Skeleton.types";
|
|
2
|
+
import View from "@/packages/Frameworks/View/View";
|
|
3
|
+
|
|
4
|
+
export default function Skeleton({
|
|
5
|
+
className,
|
|
6
|
+
style,
|
|
7
|
+
width,
|
|
8
|
+
height,
|
|
9
|
+
count,
|
|
10
|
+
type,
|
|
11
|
+
"data-color-mode": dataTheme,
|
|
12
|
+
}: SkeletonProps) {
|
|
13
|
+
const autoHeight = type ? `var(--font-${type.toLowerCase()}-size)` : height;
|
|
14
|
+
const slots = Array.from({ length: count || 1 }, (_, index) => index + 1);
|
|
15
|
+
|
|
16
|
+
return slots.map((slot) => (
|
|
17
|
+
<View
|
|
18
|
+
key={`skeleton-${slot}`}
|
|
19
|
+
data-color-mode={dataTheme}
|
|
20
|
+
className={className}
|
|
21
|
+
width={width || "100%"}
|
|
22
|
+
height={autoHeight}
|
|
23
|
+
style={{
|
|
24
|
+
...style,
|
|
25
|
+
background:
|
|
26
|
+
"color-mix(in srgb, var(--color-base-light-2) 65%, transparent)",
|
|
27
|
+
}}
|
|
28
|
+
/>
|
|
29
|
+
));
|
|
30
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TextProps } from "@/packages/Components/Text/Text.types";
|
|
2
|
+
import type { UIKitSizeValue } from "@/packages/Frameworks/_shared/sizing";
|
|
3
|
+
|
|
4
|
+
export interface SkeletonProps {
|
|
5
|
+
"data-color-mode"?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
width?: UIKitSizeValue;
|
|
9
|
+
height?: UIKitSizeValue;
|
|
10
|
+
count?: number;
|
|
11
|
+
type?: TextProps["type"];
|
|
12
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
.Spinner {
|
|
2
|
+
display: block;
|
|
3
|
+
flex-shrink: 0;
|
|
4
|
+
width: var(--spinner-size, 1.5rem);
|
|
5
|
+
height: var(--spinner-size, 1.5rem);
|
|
6
|
+
animation: spinner-rotate var(--spinner-duration, 1s) steps(12, end) infinite;
|
|
7
|
+
transform-origin: center;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.Segment {
|
|
11
|
+
stroke: currentcolor;
|
|
12
|
+
stroke-width: var(--spinner-segment-width, 2.4);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.MaterialSpinner {
|
|
16
|
+
display: block;
|
|
17
|
+
flex-shrink: 0;
|
|
18
|
+
width: var(--spinner-size, 1.5rem);
|
|
19
|
+
height: var(--spinner-size, 1.5rem);
|
|
20
|
+
animation: spinner-rotate calc(var(--spinner-duration, 1s) * 4 / 3) linear
|
|
21
|
+
infinite;
|
|
22
|
+
transform-origin: center;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.MaterialTrack {
|
|
26
|
+
stroke: currentcolor;
|
|
27
|
+
animation: spinner-dash var(--spinner-duration, 1s) ease-in-out infinite;
|
|
28
|
+
transform-origin: center;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.WheelSpinner {
|
|
32
|
+
display: block;
|
|
33
|
+
flex-shrink: 0;
|
|
34
|
+
width: var(--spinner-size, 1.5rem);
|
|
35
|
+
height: var(--spinner-size, 1.5rem);
|
|
36
|
+
border-radius: 50%;
|
|
37
|
+
background: conic-gradient(from 0deg, transparent 20%, currentcolor 100%);
|
|
38
|
+
mask: radial-gradient(farthest-side, transparent 62%, black 64%);
|
|
39
|
+
-webkit-mask: radial-gradient(farthest-side, transparent 62%, black 64%);
|
|
40
|
+
animation: spinner-rotate var(--spinner-duration, 1s) linear infinite;
|
|
41
|
+
transform-origin: center;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@keyframes spinner-rotate {
|
|
45
|
+
from {
|
|
46
|
+
transform: rotate(0deg);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
to {
|
|
50
|
+
transform: rotate(360deg);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@keyframes spinner-dash {
|
|
55
|
+
0% {
|
|
56
|
+
stroke-dasharray: 1 200;
|
|
57
|
+
stroke-dashoffset: 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
50% {
|
|
61
|
+
stroke-dasharray: 89 200;
|
|
62
|
+
stroke-dashoffset: -35;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
100% {
|
|
66
|
+
stroke-dasharray: 89 200;
|
|
67
|
+
stroke-dashoffset: -124;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@media (prefers-reduced-motion: reduce) {
|
|
72
|
+
.Spinner,
|
|
73
|
+
.MaterialSpinner,
|
|
74
|
+
.WheelSpinner,
|
|
75
|
+
.MaterialTrack {
|
|
76
|
+
animation: none;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
import type { CSSProperties } from "react";
|
|
3
|
+
import styles from "@/packages/Components/Spinner/Spinner.module.scss";
|
|
4
|
+
import type { SpinnerProps } from "@/packages/Components/Spinner/Spinner.types";
|
|
5
|
+
import { Size } from "@/packages/Frameworks/_shared/sizing";
|
|
6
|
+
import { resolveThemeClasses } from "@/packages/Frameworks/Theme/Theme.types";
|
|
7
|
+
import View from "@/packages/Frameworks/View/View";
|
|
8
|
+
|
|
9
|
+
const SPINNER_SEGMENTS = 12;
|
|
10
|
+
const SPINNER_VISUAL_SCALE_BY_TYPE = {
|
|
11
|
+
apple: 0.78,
|
|
12
|
+
material: 0.82,
|
|
13
|
+
wheel: 0.86,
|
|
14
|
+
} as const;
|
|
15
|
+
|
|
16
|
+
export default function Spinner({
|
|
17
|
+
type,
|
|
18
|
+
className,
|
|
19
|
+
style,
|
|
20
|
+
size,
|
|
21
|
+
color,
|
|
22
|
+
opacity,
|
|
23
|
+
duration,
|
|
24
|
+
strokeWidth,
|
|
25
|
+
linecap,
|
|
26
|
+
role,
|
|
27
|
+
"aria-hidden": ariaHidden,
|
|
28
|
+
"aria-label": ariaLabel,
|
|
29
|
+
"data-color-mode": dataTheme,
|
|
30
|
+
}: SpinnerProps) {
|
|
31
|
+
const resolvedType = type ?? "wheel";
|
|
32
|
+
const resolvedSize = Size(size) ?? "1.8rem";
|
|
33
|
+
const resolvedStrokeWidth = strokeWidth || 2.4;
|
|
34
|
+
const resolvedDuration = duration || 1;
|
|
35
|
+
const resolvedVisualScale =
|
|
36
|
+
SPINNER_VISUAL_SCALE_BY_TYPE[resolvedType] ?? 0.86;
|
|
37
|
+
const resolvedAriaHidden =
|
|
38
|
+
ariaHidden ?? (role || ariaLabel ? undefined : true);
|
|
39
|
+
const themeClasses = resolveThemeClasses({ color: color ?? "Base1" });
|
|
40
|
+
const spinnerStyle = {
|
|
41
|
+
"--spinner-duration": `${resolvedDuration}s`,
|
|
42
|
+
"--spinner-size": `calc(${resolvedSize} * ${resolvedVisualScale})`,
|
|
43
|
+
"--spinner-segment-width": resolvedStrokeWidth,
|
|
44
|
+
opacity,
|
|
45
|
+
} as CSSProperties;
|
|
46
|
+
|
|
47
|
+
if (resolvedType === "material") {
|
|
48
|
+
const radius = 25 - resolvedStrokeWidth;
|
|
49
|
+
const circumference = 2 * Math.PI * radius;
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<svg
|
|
53
|
+
{...({ "data-color-mode": dataTheme } as Record<
|
|
54
|
+
string,
|
|
55
|
+
string | undefined
|
|
56
|
+
>)}
|
|
57
|
+
className={clsx(styles.MaterialSpinner, ...themeClasses, className)}
|
|
58
|
+
viewBox="0 0 50 50"
|
|
59
|
+
role={role}
|
|
60
|
+
aria-hidden={resolvedAriaHidden}
|
|
61
|
+
aria-label={ariaLabel}
|
|
62
|
+
style={{ ...spinnerStyle, ...style }}
|
|
63
|
+
>
|
|
64
|
+
<circle
|
|
65
|
+
className={styles.MaterialTrack}
|
|
66
|
+
fill="none"
|
|
67
|
+
strokeWidth={resolvedStrokeWidth}
|
|
68
|
+
strokeLinecap={linecap || "round"}
|
|
69
|
+
cx="25"
|
|
70
|
+
cy="25"
|
|
71
|
+
r={radius}
|
|
72
|
+
strokeDasharray={circumference}
|
|
73
|
+
strokeDashoffset={circumference * 0.75}
|
|
74
|
+
/>
|
|
75
|
+
</svg>
|
|
76
|
+
);
|
|
77
|
+
} else if (resolvedType === "apple") {
|
|
78
|
+
const segmentKeys = Array.from(
|
|
79
|
+
{ length: SPINNER_SEGMENTS },
|
|
80
|
+
(_, index) => `spinner-segment-${index}`,
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<svg
|
|
85
|
+
{...({ "data-color-mode": dataTheme } as Record<
|
|
86
|
+
string,
|
|
87
|
+
string | undefined
|
|
88
|
+
>)}
|
|
89
|
+
className={clsx(styles.Spinner, ...themeClasses, className)}
|
|
90
|
+
viewBox="0 0 24 24"
|
|
91
|
+
role={role}
|
|
92
|
+
aria-hidden={resolvedAriaHidden}
|
|
93
|
+
aria-label={ariaLabel}
|
|
94
|
+
style={{ ...spinnerStyle, ...style }}
|
|
95
|
+
>
|
|
96
|
+
{segmentKeys.map((key, index) => (
|
|
97
|
+
<line
|
|
98
|
+
key={key}
|
|
99
|
+
className={styles.Segment}
|
|
100
|
+
x1="12"
|
|
101
|
+
y1="1.5"
|
|
102
|
+
x2="12"
|
|
103
|
+
y2="6.75"
|
|
104
|
+
strokeLinecap={linecap || "round"}
|
|
105
|
+
transform={`rotate(${index * (360 / SPINNER_SEGMENTS)} 12 12)`}
|
|
106
|
+
style={{
|
|
107
|
+
opacity: (index + 1) / SPINNER_SEGMENTS,
|
|
108
|
+
}}
|
|
109
|
+
/>
|
|
110
|
+
))}
|
|
111
|
+
</svg>
|
|
112
|
+
);
|
|
113
|
+
} else {
|
|
114
|
+
return (
|
|
115
|
+
<View
|
|
116
|
+
data-color-mode={dataTheme}
|
|
117
|
+
role={role || "progressbar"}
|
|
118
|
+
aria-hidden={resolvedAriaHidden}
|
|
119
|
+
aria-label={ariaLabel}
|
|
120
|
+
className={clsx(styles.WheelSpinner, ...themeClasses, className)}
|
|
121
|
+
style={{ ...spinnerStyle, ...style }}
|
|
122
|
+
/>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AriaRole, CSSProperties, SVGAttributes } from "react";
|
|
2
|
+
import type { UIKitSizeValue } from "@/packages/Frameworks/_shared/sizing";
|
|
3
|
+
import type { ThemePaint } from "@/packages/Frameworks/Theme/Theme.types";
|
|
4
|
+
|
|
5
|
+
export interface SpinnerProps {
|
|
6
|
+
"data-color-mode"?: string;
|
|
7
|
+
"aria-hidden"?: boolean | "true" | "false";
|
|
8
|
+
"aria-label"?: string;
|
|
9
|
+
role?: AriaRole;
|
|
10
|
+
type?: "apple" | "material" | "wheel";
|
|
11
|
+
className?: string;
|
|
12
|
+
style?: CSSProperties;
|
|
13
|
+
size?: UIKitSizeValue;
|
|
14
|
+
strokeWidth?: number;
|
|
15
|
+
color?: ThemePaint;
|
|
16
|
+
opacity?: number;
|
|
17
|
+
duration?: number;
|
|
18
|
+
linecap?: SVGAttributes<SVGElement>["strokeLinecap"];
|
|
19
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
import styles from "@/packages/Components/Text/Text.module.scss";
|
|
3
|
+
import type { TextProps } from "@/packages/Components/Text/Text.types";
|
|
4
|
+
import { Size } from "@/packages/Frameworks/_shared/sizing";
|
|
5
|
+
|
|
6
|
+
export default function Text({
|
|
7
|
+
children,
|
|
8
|
+
type,
|
|
9
|
+
color,
|
|
10
|
+
textAlign,
|
|
11
|
+
lineHeight,
|
|
12
|
+
weight,
|
|
13
|
+
letterSpacing,
|
|
14
|
+
size,
|
|
15
|
+
style,
|
|
16
|
+
className,
|
|
17
|
+
verticalTrim,
|
|
18
|
+
fontType,
|
|
19
|
+
id,
|
|
20
|
+
opacity,
|
|
21
|
+
"data-color-mode": dataColorMode,
|
|
22
|
+
}: TextProps) {
|
|
23
|
+
return (
|
|
24
|
+
<span
|
|
25
|
+
id={id}
|
|
26
|
+
data-color-mode={dataColorMode}
|
|
27
|
+
className={clsx(
|
|
28
|
+
styles.Text,
|
|
29
|
+
type,
|
|
30
|
+
fontType === "serif" ? "FontSerif" : fontType === "code" && "FontCode",
|
|
31
|
+
className,
|
|
32
|
+
)}
|
|
33
|
+
style={{
|
|
34
|
+
lineHeight: verticalTrim ? 1 : lineHeight,
|
|
35
|
+
fontWeight: weight,
|
|
36
|
+
letterSpacing: letterSpacing,
|
|
37
|
+
fontSize: Size(size),
|
|
38
|
+
color: color,
|
|
39
|
+
opacity:
|
|
40
|
+
opacity === undefined ? undefined : Math.max(0, Math.min(opacity, 1)),
|
|
41
|
+
wordBreak: "break-word",
|
|
42
|
+
textAlign: textAlign,
|
|
43
|
+
...style,
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
{children}
|
|
47
|
+
</span>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { UIKitSizeValue } from "@/packages/Frameworks/_shared/sizing";
|
|
2
|
+
import type { ThemePaint } from "@/packages/Frameworks/Theme/Theme.types";
|
|
3
|
+
|
|
4
|
+
export interface TextProps {
|
|
5
|
+
"data-color-mode"?: string;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
type?:
|
|
10
|
+
| "LargeTitle"
|
|
11
|
+
| "Title1"
|
|
12
|
+
| "Title2"
|
|
13
|
+
| "Title3"
|
|
14
|
+
| "Headline"
|
|
15
|
+
| "Callout"
|
|
16
|
+
| "Body"
|
|
17
|
+
| "Subheadline"
|
|
18
|
+
| "Footnote"
|
|
19
|
+
| "Caption1"
|
|
20
|
+
| "Caption2"
|
|
21
|
+
| "Coding"
|
|
22
|
+
| "Pre";
|
|
23
|
+
color?: ThemePaint;
|
|
24
|
+
lineHeight?: number;
|
|
25
|
+
weight?: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
|
|
26
|
+
letterSpacing?: number;
|
|
27
|
+
size?: UIKitSizeValue;
|
|
28
|
+
verticalTrim?: boolean;
|
|
29
|
+
fontType?: "serif" | "code";
|
|
30
|
+
textAlign?: "left" | "center" | "right";
|
|
31
|
+
id?: string;
|
|
32
|
+
opacity?: number;
|
|
33
|
+
}
|