aplance-ui 1.0.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 +21 -0
- package/README.md +29 -0
- package/dist/api.d.ts +175 -0
- package/dist/api.js +1954 -0
- package/dist/api.js.map +1 -0
- package/dist/frameworks/astro/astro.config.snippet.md +23 -0
- package/dist/frameworks/astro/postcss.config.mjs.template +20 -0
- package/dist/frameworks/astro/vite-inline.snippet.md +22 -0
- package/dist/frameworks/electron-vite/vite.config.snippet.md +44 -0
- package/dist/frameworks/next/layout-import.snippet.md +19 -0
- package/dist/frameworks/next/next.config.snippet.md +15 -0
- package/dist/frameworks/next/postcss.config.js.template +16 -0
- package/dist/frameworks/tanstack-start/postcss.config.ts.template +17 -0
- package/dist/frameworks/tanstack-start/vite-inline.snippet.md +22 -0
- package/dist/frameworks/vite-react/postcss.config.ts.template +16 -0
- package/dist/frameworks/vite-react/vite-inline.snippet.md +20 -0
- package/dist/frameworks/vite-react/vite.config.ts.template +48 -0
- package/dist/index.js +2047 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -0
- package/registry/components/primitives/icon/icon.module.css +63 -0
- package/registry/components/primitives/icon/icon.tsx +53 -0
- package/registry/components/primitives/modal/modal-context.ts +19 -0
- package/registry/components/primitives/modal/modal.module.css +415 -0
- package/registry/components/primitives/modal/modal.tsx +550 -0
- package/registry/components/primitives/popover/popover-context.ts +28 -0
- package/registry/components/primitives/popover/popover.module.css +28 -0
- package/registry/components/primitives/popover/popover.tsx +465 -0
- package/registry/components/ui/accordion/accordion.module.css +208 -0
- package/registry/components/ui/accordion/accordion.tsx +327 -0
- package/registry/components/ui/avatar/avatar.module.css +32 -0
- package/registry/components/ui/avatar/avatar.tsx +37 -0
- package/registry/components/ui/badge/badge.module.css +103 -0
- package/registry/components/ui/badge/badge.tsx +29 -0
- package/registry/components/ui/button/button.module.css +216 -0
- package/registry/components/ui/button/button.tsx +133 -0
- package/registry/components/ui/chart/chart.module.css +168 -0
- package/registry/components/ui/chart/chart.tsx +1293 -0
- package/registry/components/ui/chart/types.ts +210 -0
- package/registry/components/ui/chart/utils.ts +59 -0
- package/registry/components/ui/copy-button/copy-button.module.css +21 -0
- package/registry/components/ui/copy-button/copy-button.tsx +123 -0
- package/registry/components/ui/countdown/countdown.module.css +5 -0
- package/registry/components/ui/countdown/countdown.tsx +152 -0
- package/registry/components/ui/data-table/checkbox-column.tsx +59 -0
- package/registry/components/ui/data-table/data-table.module.css +594 -0
- package/registry/components/ui/data-table/data-table.tsx +1109 -0
- package/registry/components/ui/data-table/filter-bar.tsx +33 -0
- package/registry/components/ui/data-table/pagination-bar.tsx +125 -0
- package/registry/components/ui/data-table/types.ts +594 -0
- package/registry/components/ui/data-table/useDataTable.tsx +573 -0
- package/registry/components/ui/data-table/utils.ts +445 -0
- package/registry/components/ui/empty-state/empty-state.module.css +26 -0
- package/registry/components/ui/empty-state/empty-state.tsx +32 -0
- package/registry/components/ui/input-fields/color-picker/color-palette.module.css +102 -0
- package/registry/components/ui/input-fields/color-picker/color-palette.tsx +92 -0
- package/registry/components/ui/input-fields/color-picker/color-picker.module.css +29 -0
- package/registry/components/ui/input-fields/color-picker/color-picker.tsx +168 -0
- package/registry/components/ui/input-fields/common/field-message/field-message.module.css +28 -0
- package/registry/components/ui/input-fields/common/field-message/field-message.tsx +39 -0
- package/registry/components/ui/input-fields/common/input-field-common.module.css +318 -0
- package/registry/components/ui/input-fields/common/input-field-native.module.css +267 -0
- package/registry/components/ui/input-fields/common/picker-popover-common.module.css +40 -0
- package/registry/components/ui/input-fields/common/select-button/select-button.module.css +9 -0
- package/registry/components/ui/input-fields/common/select-button/select-button.tsx +171 -0
- package/registry/components/ui/input-fields/common/types.ts +38 -0
- package/registry/components/ui/input-fields/custom-select/custom-select.module.css +56 -0
- package/registry/components/ui/input-fields/custom-select/custom-select.tsx +403 -0
- package/registry/components/ui/input-fields/date-picker/calendar.module.css +311 -0
- package/registry/components/ui/input-fields/date-picker/calendar.tsx +186 -0
- package/registry/components/ui/input-fields/date-picker/date-picker.module.css +57 -0
- package/registry/components/ui/input-fields/date-picker/date-picker.tsx +945 -0
- package/registry/components/ui/input-fields/date-picker/types.ts +102 -0
- package/registry/components/ui/input-fields/date-picker/utils.ts +236 -0
- package/registry/components/ui/input-fields/emoji-picker/emoji-palette.module.css +90 -0
- package/registry/components/ui/input-fields/emoji-picker/emoji-palette.tsx +168 -0
- package/registry/components/ui/input-fields/emoji-picker/emoji-picker.module.css +8 -0
- package/registry/components/ui/input-fields/emoji-picker/emoji-picker.tsx +102 -0
- package/registry/components/ui/input-fields/emoji-picker/utils.ts +505 -0
- package/registry/components/ui/input-fields/field-group/field-group.module.css +86 -0
- package/registry/components/ui/input-fields/field-group/field-group.tsx +86 -0
- package/registry/components/ui/input-fields/input/input.tsx +319 -0
- package/registry/components/ui/input-fields/media-input/kind-icons.tsx +62 -0
- package/registry/components/ui/input-fields/media-input/media-input.module.css +294 -0
- package/registry/components/ui/input-fields/media-input/media-input.tsx +327 -0
- package/registry/components/ui/input-fields/media-input/media-preview.tsx +101 -0
- package/registry/components/ui/input-fields/media-input/types.ts +129 -0
- package/registry/components/ui/input-fields/media-input/useMediaUpload.tsx +302 -0
- package/registry/components/ui/input-fields/media-input/utils.ts +325 -0
- package/registry/components/ui/input-fields/otp-input/otp-input.module.css +24 -0
- package/registry/components/ui/input-fields/otp-input/otp-input.tsx +291 -0
- package/registry/components/ui/input-fields/select/select.tsx +118 -0
- package/registry/components/ui/input-fields/switch/switch.module.css +70 -0
- package/registry/components/ui/input-fields/switch/switch.tsx +59 -0
- package/registry/components/ui/input-fields/textarea/textarea.tsx +133 -0
- package/registry/components/ui/input-fields/time-picker/time-picker.module.css +57 -0
- package/registry/components/ui/input-fields/time-picker/time-picker.tsx +437 -0
- package/registry/components/ui/loader/loader.module.css +156 -0
- package/registry/components/ui/loader/loader.tsx +102 -0
- package/registry/components/ui/stepper/stepper.module.css +294 -0
- package/registry/components/ui/stepper/stepper.tsx +197 -0
- package/registry/components/ui/tabs/tabs.module.css +150 -0
- package/registry/components/ui/tabs/tabs.tsx +134 -0
- package/registry/components/ui/toast/toast.module.css +159 -0
- package/registry/components/ui/toast/toast.tsx +104 -0
- package/registry/components/ui/tooltip/tooltip.module.css +82 -0
- package/registry/components/ui/tooltip/tooltip.tsx +72 -0
- package/registry/global.d.ts +4 -0
- package/registry/hooks/useFocusOutside.tsx +33 -0
- package/registry/hooks/useResizeObserver.tsx +32 -0
- package/registry/lib/dom.ts +25 -0
- package/registry/lib/string.ts +23 -0
- package/registry/registry.json +719 -0
- package/registry/styles/app.css +240 -0
- package/registry/styles/components.css +78 -0
- package/registry/styles/fonts/geist-regular.woff2 +0 -0
- package/registry/styles/globals.css +7 -0
- package/registry/styles/media.css +25 -0
- package/registry/styles/utilities.css +90 -0
- package/registry/themes/colors/blue.css +37 -0
- package/registry/themes/colors/green.css +37 -0
- package/registry/themes/colors/rose.css +37 -0
- package/registry/themes/colors/slate.css +37 -0
- package/registry/themes/colors/stone.css +37 -0
- package/registry/themes/colors/violet.css +37 -0
- package/registry/themes/colors/zinc.css +37 -0
- package/registry/themes/radius/pill.css +8 -0
- package/registry/themes/radius/rounded.css +8 -0
- package/registry/themes/radius/sharp.css +8 -0
- package/registry/themes/spacing/compact.css +17 -0
- package/registry/themes/spacing/spacious.css +17 -0
- package/registry/tsconfig.json +25 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/* uses input-field-common (.container and all)
|
|
2
|
+
+ extends .wrapper (from input-field-common) with
|
|
3
|
+
.native_field_wrapper (styling defalut input types)
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
.native_field_wrapper {
|
|
7
|
+
/* input-specific overrides & browser fixes */
|
|
8
|
+
input[type="search"]::-webkit-search-cancel-button {
|
|
9
|
+
appearance: none;
|
|
10
|
+
display: none;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* remove password reveal */
|
|
14
|
+
input[type="password"] {
|
|
15
|
+
&::-ms-reveal,
|
|
16
|
+
&::-webkit-reveal {
|
|
17
|
+
display: none;
|
|
18
|
+
width: 0;
|
|
19
|
+
height: 0;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* calendar and time picker override */
|
|
24
|
+
input[type="date"],
|
|
25
|
+
input[type="month"],
|
|
26
|
+
input[type="week"],
|
|
27
|
+
input[type="time"],
|
|
28
|
+
input[type="datetime-local"] {
|
|
29
|
+
&::-webkit-calendar-picker-indicator {
|
|
30
|
+
display: none;
|
|
31
|
+
-webkit-appearance: none;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* Base control styles (checkbox, radio, range thumb, color) */
|
|
36
|
+
input[type="checkbox"],
|
|
37
|
+
input[type="radio"],
|
|
38
|
+
input[type="color"] {
|
|
39
|
+
appearance: none;
|
|
40
|
+
-webkit-appearance: none;
|
|
41
|
+
background-color: var(--color-background);
|
|
42
|
+
border: 1.5px solid var(--color-border);
|
|
43
|
+
transition: all var(--transition-fast);
|
|
44
|
+
|
|
45
|
+
&:not(:disabled):focus {
|
|
46
|
+
box-shadow: var(--shadow-ring);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* radio */
|
|
51
|
+
input[type="radio"] {
|
|
52
|
+
width: 1.2rem;
|
|
53
|
+
height: 1.2rem;
|
|
54
|
+
border-radius: var(--radius-full);
|
|
55
|
+
position: relative;
|
|
56
|
+
|
|
57
|
+
&:checked::after {
|
|
58
|
+
content: "";
|
|
59
|
+
position: absolute;
|
|
60
|
+
inset: 4px;
|
|
61
|
+
border-radius: var(--radius-full);
|
|
62
|
+
background-color: var(--color-primary);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* checkbox */
|
|
67
|
+
input[type="checkbox"] {
|
|
68
|
+
width: 1.2rem;
|
|
69
|
+
height: 1.2rem;
|
|
70
|
+
border-radius: var(--radius-sm);
|
|
71
|
+
position: relative;
|
|
72
|
+
appearance: none;
|
|
73
|
+
|
|
74
|
+
&:checked {
|
|
75
|
+
background-color: var(--color-primary);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&:checked::after {
|
|
79
|
+
content: "";
|
|
80
|
+
position: absolute;
|
|
81
|
+
left: 50%;
|
|
82
|
+
top: 45%;
|
|
83
|
+
width: 0.35rem;
|
|
84
|
+
height: 0.7rem;
|
|
85
|
+
border: solid var(--color-primary-foreground);
|
|
86
|
+
border-width: 0 2.5px 2.5px 0;
|
|
87
|
+
transform: translate(-50%, -50%) rotate(45deg);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* number */
|
|
92
|
+
input[type="number"] {
|
|
93
|
+
appearance: textfield;
|
|
94
|
+
-webkit-appearance: textfield;
|
|
95
|
+
position: relative;
|
|
96
|
+
|
|
97
|
+
&::-webkit-inner-spin-button,
|
|
98
|
+
&::-webkit-outer-spin-button {
|
|
99
|
+
appearance: none;
|
|
100
|
+
-webkit-appearance: none;
|
|
101
|
+
margin: 0;
|
|
102
|
+
padding: 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&::-webkit-inner-spin-button {
|
|
106
|
+
position: absolute;
|
|
107
|
+
right: var(--spacing-4);
|
|
108
|
+
top: 50%;
|
|
109
|
+
transform: translateY(-50%);
|
|
110
|
+
width: 14px;
|
|
111
|
+
height: 28px;
|
|
112
|
+
display: block;
|
|
113
|
+
cursor: pointer;
|
|
114
|
+
background-repeat: no-repeat;
|
|
115
|
+
background-position: center;
|
|
116
|
+
background-size: 14px 28px;
|
|
117
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 28' fill='none' stroke='%23181818' stroke-width='1.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 10l2.5-2.5 2.5 2.5'/%3E%3Cpath d='M4.5 18l2.5 2.5 2.5-2.5'/%3E%3C/svg%3E");
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* dark theme */
|
|
122
|
+
[data-theme="dark"] & {
|
|
123
|
+
input[type="number"] {
|
|
124
|
+
&::-webkit-inner-spin-button {
|
|
125
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 28' fill='none' stroke='%23ffffff' stroke-width='1.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 10l2.5-2.5 2.5 2.5'/%3E%3Cpath d='M4.5 18l2.5 2.5 2.5-2.5'/%3E%3C/svg%3E");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* range */
|
|
131
|
+
input[type="range"] {
|
|
132
|
+
appearance: none;
|
|
133
|
+
width: 100%;
|
|
134
|
+
height: var(--spacing-2);
|
|
135
|
+
border-radius: var(--radius-full);
|
|
136
|
+
background-color: var(--color-border);
|
|
137
|
+
cursor: pointer;
|
|
138
|
+
transition: background-color var(--transition-fast);
|
|
139
|
+
outline: none;
|
|
140
|
+
margin: var(--spacing-2) 0;
|
|
141
|
+
|
|
142
|
+
&:not(:disabled):hover {
|
|
143
|
+
background-color: var(--color-ring);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* hover affects thumb */
|
|
147
|
+
&:hover::-webkit-slider-thumb {
|
|
148
|
+
background-color: var(--color-primary);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
&:hover::-moz-range-thumb {
|
|
152
|
+
background-color: var(--color-primary);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/* thumb base */
|
|
156
|
+
&::-webkit-slider-thumb,
|
|
157
|
+
&::-moz-range-thumb {
|
|
158
|
+
width: 1.1rem;
|
|
159
|
+
height: 1.1rem;
|
|
160
|
+
border-radius: var(--radius-full);
|
|
161
|
+
background-color: var(--color-background);
|
|
162
|
+
border: 1.5px solid var(--color-border);
|
|
163
|
+
transition: all var(--transition-fast);
|
|
164
|
+
cursor: pointer;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
&::-webkit-slider-thumb {
|
|
168
|
+
-webkit-appearance: none;
|
|
169
|
+
appearance: none;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
&:active::-webkit-slider-thumb,
|
|
173
|
+
&:active::-moz-range-thumb {
|
|
174
|
+
transform: scale(1.1);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
&::-moz-range-track {
|
|
178
|
+
height: var(--spacing-2);
|
|
179
|
+
border-radius: var(--radius-full);
|
|
180
|
+
background-color: var(--color-border);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
&:disabled {
|
|
184
|
+
cursor: not-allowed;
|
|
185
|
+
opacity: 0.6;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/* color */
|
|
190
|
+
input[type="color"] {
|
|
191
|
+
width: 2.5rem;
|
|
192
|
+
height: 2.5rem;
|
|
193
|
+
padding: 0;
|
|
194
|
+
border-radius: var(--radius-md);
|
|
195
|
+
|
|
196
|
+
&::-webkit-color-swatch-wrapper {
|
|
197
|
+
padding: var(--spacing-2);
|
|
198
|
+
border-radius: var(--radius-md);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
&::-webkit-color-swatch,
|
|
202
|
+
&::-moz-color-swatch {
|
|
203
|
+
border-radius: var(--radius-md);
|
|
204
|
+
border: none;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/* select - single */
|
|
209
|
+
select:not([multiple]) {
|
|
210
|
+
appearance: none;
|
|
211
|
+
|
|
212
|
+
option {
|
|
213
|
+
padding: var(--spacing-2) var(--spacing-3);
|
|
214
|
+
background-color: var(--color-background);
|
|
215
|
+
color: var(--color-foreground);
|
|
216
|
+
|
|
217
|
+
&:hover {
|
|
218
|
+
background-color: var(--color-muted);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
&:checked {
|
|
222
|
+
background-color: var(--color-primary);
|
|
223
|
+
color: var(--color-primary-foreground);
|
|
224
|
+
font-weight: 500;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
option:checked {
|
|
229
|
+
background-color: var(--color-primary);
|
|
230
|
+
color: var(--color-primary-foreground);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* native select chevron rotation */
|
|
235
|
+
.native_select_chevron {
|
|
236
|
+
transition: transform var(--transition-fast) ease-in-out;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
&:focus-within .native_select_chevron,
|
|
240
|
+
&:active .native_select_chevron {
|
|
241
|
+
transform: rotate(180deg) !important;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/* select - multiple */
|
|
245
|
+
select[multiple] {
|
|
246
|
+
height: fit-content;
|
|
247
|
+
min-height: 8rem;
|
|
248
|
+
appearance: none;
|
|
249
|
+
overflow-y: auto;
|
|
250
|
+
padding: var(--spacing-2) var(--spacing-1);
|
|
251
|
+
background-image: none;
|
|
252
|
+
|
|
253
|
+
option {
|
|
254
|
+
margin: var(--spacing-2);
|
|
255
|
+
background-color: var(--color-background);
|
|
256
|
+
border: 1px solid var(--color-border);
|
|
257
|
+
padding: var(--spacing-2) var(--spacing-3);
|
|
258
|
+
border-radius: var(--radius-md);
|
|
259
|
+
|
|
260
|
+
&:hover,
|
|
261
|
+
&:checked {
|
|
262
|
+
background-color: var(--color-primary);
|
|
263
|
+
color: var(--color-primary-foreground);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Shared popover-picker primitives for input-field components.
|
|
3
|
+
* Keep names generic so future pickers (date/time/color/etc.) can reuse these
|
|
4
|
+
* shell styles without duplicating visual frame and action-footer rules.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
.picker_popover {
|
|
8
|
+
width: 100%;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.picker_popover_trigger {
|
|
12
|
+
width: 100%;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.picker_popover_menu_base {
|
|
16
|
+
width: var(--picker-popover-menu-width, auto) !important;
|
|
17
|
+
background-color: var(--color-background);
|
|
18
|
+
border: var(--border-1) solid var(--color-border);
|
|
19
|
+
border-radius: var(--radius-lg);
|
|
20
|
+
box-shadow: var(--shadow-lg);
|
|
21
|
+
padding: 0;
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.picker_actions_footer {
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
justify-content: space-between;
|
|
29
|
+
gap: var(--spacing-4);
|
|
30
|
+
padding: var(--spacing-4);
|
|
31
|
+
border-top: var(--border-1) solid var(--color-border);
|
|
32
|
+
border-radius: 0 0 var(--radius-lg) var(--radius-lg);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.picker_value_placeholder {
|
|
36
|
+
color: var(
|
|
37
|
+
--field-placeholder-color,
|
|
38
|
+
var(--button-placeholder, var(--color-muted-foreground))
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SelectButton has no module-scoped styles of its own. It composes the
|
|
3
|
+
* shared field-wrapper contracts from `../input-field-common.module.css`
|
|
4
|
+
* and the tone classes from `../../../button/button.module.css` so every
|
|
5
|
+
* popover-driven trigger (CustomSelect, DatePicker, TimePicker, ColorPicker,
|
|
6
|
+
* MediaInput) renders with the same chrome as a native input.
|
|
7
|
+
*
|
|
8
|
+
* Kept empty for co-location consistency with the rest of the family.
|
|
9
|
+
*/
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type CSSProperties,
|
|
3
|
+
type FC,
|
|
4
|
+
type ReactNode,
|
|
5
|
+
} from "react";
|
|
6
|
+
import clsx from "clsx";
|
|
7
|
+
import { IconChevronDown, IconChevronRight, IconX } from "@tabler/icons-react";
|
|
8
|
+
import {
|
|
9
|
+
Button,
|
|
10
|
+
type ButtonSize,
|
|
11
|
+
type ButtonVariant,
|
|
12
|
+
} from "../../../button/button";
|
|
13
|
+
import sButton from "../../../button/button.module.css";
|
|
14
|
+
import { Icon } from "../../../../primitives/icon/icon";
|
|
15
|
+
import { Tooltip } from "../../../tooltip/tooltip";
|
|
16
|
+
import type { Position } from "../../../../primitives/popover/popover";
|
|
17
|
+
import { usePopover } from "../../../../primitives/popover/popover-context";
|
|
18
|
+
import sCommon from "../input-field-common.module.css";
|
|
19
|
+
|
|
20
|
+
export type SelectButtonProps = {
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
required?: boolean;
|
|
23
|
+
className?: string;
|
|
24
|
+
style?: CSSProperties;
|
|
25
|
+
id?: string;
|
|
26
|
+
buttonVariant?: ButtonVariant | "none";
|
|
27
|
+
buttonSize?: ButtonSize;
|
|
28
|
+
tooltip?: string;
|
|
29
|
+
tooltipPosition?: Position;
|
|
30
|
+
showClear?: boolean;
|
|
31
|
+
showChevron?: boolean;
|
|
32
|
+
isSubmenu?: boolean;
|
|
33
|
+
onClear?: (e: React.MouseEvent) => void;
|
|
34
|
+
iconStart?: ReactNode;
|
|
35
|
+
iconEnd?: ReactNode;
|
|
36
|
+
children?: ReactNode;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Shared trigger surface for popover-based input fields (CustomSelect,
|
|
41
|
+
* DatePicker, TimePicker, ColorPicker, MediaInput). Mirrors the visual
|
|
42
|
+
* contract of `Input`: same wrapper paddings, focus ring, and start/end
|
|
43
|
+
* action slots - but rendered as a button so it can drive a popover.
|
|
44
|
+
*
|
|
45
|
+
* Must be rendered inside a `<Popover>` - it reads open state via
|
|
46
|
+
* `usePopover` to flip `isActive` and chevron rotation.
|
|
47
|
+
*/
|
|
48
|
+
export const SelectButton: FC<SelectButtonProps> = ({
|
|
49
|
+
disabled = false,
|
|
50
|
+
required = false,
|
|
51
|
+
className,
|
|
52
|
+
style,
|
|
53
|
+
id,
|
|
54
|
+
buttonVariant = "bordered",
|
|
55
|
+
buttonSize = "default",
|
|
56
|
+
showClear = false,
|
|
57
|
+
isSubmenu = false,
|
|
58
|
+
showChevron = true,
|
|
59
|
+
tooltip,
|
|
60
|
+
tooltipPosition = "bottom",
|
|
61
|
+
onClear,
|
|
62
|
+
iconStart,
|
|
63
|
+
iconEnd,
|
|
64
|
+
children,
|
|
65
|
+
}) => {
|
|
66
|
+
const { isOpen } = usePopover();
|
|
67
|
+
const isButtonVariant = buttonVariant !== "none";
|
|
68
|
+
const buttonToneClass = isButtonVariant
|
|
69
|
+
? sButton[`tone_${buttonVariant}`]
|
|
70
|
+
: undefined;
|
|
71
|
+
|
|
72
|
+
const endActionCount = [showClear, showChevron, iconEnd].filter(
|
|
73
|
+
Boolean,
|
|
74
|
+
).length;
|
|
75
|
+
|
|
76
|
+
const buttonContent = (
|
|
77
|
+
<span className={clsx(sCommon.truncate_text)}>{children}</span>
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const button = (
|
|
81
|
+
<div
|
|
82
|
+
className={clsx(
|
|
83
|
+
sCommon.field_wrapper,
|
|
84
|
+
isButtonVariant && sCommon.field_wrapper_variant,
|
|
85
|
+
isButtonVariant && buttonToneClass,
|
|
86
|
+
)}
|
|
87
|
+
data-start-actions={iconStart ? 1 : undefined}
|
|
88
|
+
data-end-actions={endActionCount > 0 ? Math.min(3, endActionCount) : undefined}
|
|
89
|
+
>
|
|
90
|
+
{iconStart && <div className={sCommon.icon_start}>{iconStart}</div>}
|
|
91
|
+
{buttonVariant === "none" ? (
|
|
92
|
+
<button
|
|
93
|
+
className={clsx(
|
|
94
|
+
sCommon.field_default,
|
|
95
|
+
sCommon.field_cursor_default,
|
|
96
|
+
className,
|
|
97
|
+
)}
|
|
98
|
+
disabled={disabled}
|
|
99
|
+
aria-required={required || undefined}
|
|
100
|
+
style={style}
|
|
101
|
+
type="button"
|
|
102
|
+
id={id}
|
|
103
|
+
data-active={isOpen}
|
|
104
|
+
>
|
|
105
|
+
{buttonContent}
|
|
106
|
+
</button>
|
|
107
|
+
) : (
|
|
108
|
+
<Button
|
|
109
|
+
className={clsx(
|
|
110
|
+
sCommon.field_full_width,
|
|
111
|
+
sCommon.field_justify_start,
|
|
112
|
+
sCommon.field_cursor_default,
|
|
113
|
+
sCommon.field_button_variant,
|
|
114
|
+
sButton.input_focus,
|
|
115
|
+
buttonToneClass,
|
|
116
|
+
className,
|
|
117
|
+
)}
|
|
118
|
+
variant={buttonVariant as ButtonVariant}
|
|
119
|
+
isActive={isOpen}
|
|
120
|
+
size={buttonSize}
|
|
121
|
+
disabled={disabled}
|
|
122
|
+
aria-required={required || undefined}
|
|
123
|
+
style={style}
|
|
124
|
+
type="button"
|
|
125
|
+
id={id}
|
|
126
|
+
>
|
|
127
|
+
{buttonContent}
|
|
128
|
+
</Button>
|
|
129
|
+
)}
|
|
130
|
+
{endActionCount > 0 && (
|
|
131
|
+
<div className={sCommon.action_end_wrapper}>
|
|
132
|
+
{showClear && (
|
|
133
|
+
<Icon
|
|
134
|
+
onClick={onClear}
|
|
135
|
+
clickable
|
|
136
|
+
data-disabled={disabled}
|
|
137
|
+
aria-label="Clear selection"
|
|
138
|
+
>
|
|
139
|
+
<IconX />
|
|
140
|
+
</Icon>
|
|
141
|
+
)}
|
|
142
|
+
{!isSubmenu && showChevron && (
|
|
143
|
+
<Icon disabled={disabled} rotate={isOpen} clickable>
|
|
144
|
+
<IconChevronDown />
|
|
145
|
+
</Icon>
|
|
146
|
+
)}
|
|
147
|
+
{isSubmenu && showChevron && (
|
|
148
|
+
<Icon disabled={disabled} rotateSub={isOpen} clickable>
|
|
149
|
+
<IconChevronRight />
|
|
150
|
+
</Icon>
|
|
151
|
+
)}
|
|
152
|
+
{iconEnd}
|
|
153
|
+
</div>
|
|
154
|
+
)}
|
|
155
|
+
</div>
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
if (tooltip) {
|
|
159
|
+
return (
|
|
160
|
+
<Tooltip
|
|
161
|
+
content={tooltip}
|
|
162
|
+
position={tooltipPosition}
|
|
163
|
+
popoverMenu={{ style: { display: isOpen ? "none" : undefined } }}
|
|
164
|
+
>
|
|
165
|
+
{button}
|
|
166
|
+
</Tooltip>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return button;
|
|
171
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ButtonVariant } from "../../button/button";
|
|
2
|
+
import type { CSSProperties, ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
export const layoutTypes = [
|
|
5
|
+
"default",
|
|
6
|
+
"inline",
|
|
7
|
+
"inline_justify",
|
|
8
|
+
"centered",
|
|
9
|
+
] as const;
|
|
10
|
+
export type LayoutType = (typeof layoutTypes)[number];
|
|
11
|
+
|
|
12
|
+
export type InputFieldButtonStyle = "none" | ButtonVariant;
|
|
13
|
+
|
|
14
|
+
export type InputFieldMessageProps = {
|
|
15
|
+
errors?: readonly string[];
|
|
16
|
+
info?: readonly string[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type InputFieldInteractionProps = {
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
readOnly?: boolean;
|
|
22
|
+
required?: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type BaseInputFieldProps =
|
|
26
|
+
InputFieldMessageProps &
|
|
27
|
+
InputFieldInteractionProps & {
|
|
28
|
+
label?: string;
|
|
29
|
+
style?: CSSProperties;
|
|
30
|
+
className?: string;
|
|
31
|
+
id?: string;
|
|
32
|
+
name?: string;
|
|
33
|
+
layout?: LayoutType;
|
|
34
|
+
layoutDirection?: "default" | "rev"; // for inline layouts
|
|
35
|
+
buttonStyle?: InputFieldButtonStyle; // to use button variant styles
|
|
36
|
+
iconStart?: ReactNode;
|
|
37
|
+
iconEnd?: ReactNode;
|
|
38
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* uses input-field-common (.container and all)
|
|
2
|
+
+ popover related stuff
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/* actual menu selector */
|
|
6
|
+
.popover_menu {
|
|
7
|
+
--picker-popover-menu-width: 100%;
|
|
8
|
+
width: 100%;
|
|
9
|
+
border-radius: calc(var(--radius-md) + var(--spacing-2));
|
|
10
|
+
|
|
11
|
+
/* Search container */
|
|
12
|
+
.search_container {
|
|
13
|
+
padding: var(--spacing-4);
|
|
14
|
+
border-bottom: 1px solid var(--color-border);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* Options container */
|
|
18
|
+
.options_container {
|
|
19
|
+
width: 100%;
|
|
20
|
+
max-height: 16rem;
|
|
21
|
+
overflow-y: auto;
|
|
22
|
+
padding: var(--spacing-2);
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
gap: var(--spacing-2);
|
|
26
|
+
|
|
27
|
+
.no_options {
|
|
28
|
+
padding: var(--spacing-4);
|
|
29
|
+
text-align: center;
|
|
30
|
+
color: var(--color-muted-foreground);
|
|
31
|
+
font-size: var(--font-size-sm);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* Option button */
|
|
35
|
+
.option {
|
|
36
|
+
width: 100%;
|
|
37
|
+
/* button has justify-content: space-between */
|
|
38
|
+
justify-content: flex-start;
|
|
39
|
+
/* modifying padding of actual button variant for consistency */
|
|
40
|
+
padding: var(--spacing-3) var(--spacing-4);
|
|
41
|
+
border-radius: var(--radius-md);
|
|
42
|
+
|
|
43
|
+
/* > icon */
|
|
44
|
+
|
|
45
|
+
.option_label {
|
|
46
|
+
max-width: 100% !important;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.option_label {
|
|
53
|
+
max-width: 100% !important;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|