@particle-network/ui-react 0.5.0-beta.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/UXButton/button-theme.d.ts +3 -0
- package/dist/components/UXButton/button-theme.js +36 -9
- package/dist/components/UXButton/use-button.js +2 -1
- package/dist/components/UXChip/chip.extend.d.ts +1 -1
- package/dist/components/UXChip/chip.extend.js +17 -2
- package/dist/components/UXChip/index.d.ts +1 -1
- package/dist/components/UXCopy/index.d.ts +2 -0
- package/dist/components/UXCopy/index.js +4 -3
- package/dist/components/UXDivider/divider.extend.d.ts +7 -283
- package/dist/components/UXInput/index.d.ts +24 -333
- package/dist/components/UXInput/input.extend.d.ts +24 -333
- package/dist/components/UXModal/index.js +2 -5
- package/dist/components/UXNumberInput/number-input.extend.d.ts +1 -0
- package/dist/components/UXSlider/index.d.ts +5 -0
- package/dist/components/UXSlider/index.js +3 -0
- package/dist/components/UXSlider/slider-theme.d.ts +521 -0
- package/dist/components/UXSlider/slider-theme.js +464 -0
- package/dist/components/UXSlider/slider-thumb.d.ts +4 -0
- package/dist/components/UXSlider/slider-thumb.js +33 -0
- package/dist/components/UXSlider/slider.d.ts +4 -0
- package/dist/components/UXSlider/slider.js +77 -0
- package/dist/components/UXSlider/use-slider-thumb.d.ts +61 -0
- package/dist/components/UXSlider/use-slider-thumb.js +79 -0
- package/dist/components/UXSlider/use-slider.d.ts +182 -0
- package/dist/components/UXSlider/use-slider.js +277 -0
- package/dist/components/UXSwitch/index.d.ts +11 -323
- package/dist/components/UXSwitch/switch.extend.d.ts +11 -323
- package/dist/components/UXTabSwitch/index.d.ts +16 -0
- package/dist/components/UXTabSwitch/index.js +30 -0
- package/dist/components/UXTable/index.d.ts +23 -336
- package/dist/components/UXTable/table.extend.d.ts +23 -336
- package/dist/components/UXTabs/tabs.classes.js +4 -4
- package/dist/components/UXThemeSwitch/theme-switch.d.ts +6 -2
- package/dist/components/UXThemeSwitch/theme-switch.js +16 -9
- package/dist/components/UXThemeSwitch/use-theme-color.d.ts +22 -1
- package/dist/components/UXThemeSwitch/use-theme-color.js +5 -1
- package/dist/components/UXThemeSwitch/use-theme.js +12 -6
- package/dist/components/UXToast/index.js +2 -2
- package/dist/components/UXTooltip/index.d.ts +2 -2
- package/dist/components/UXTooltip/tooltip.extend.d.ts +9 -311
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/typography/Text.type.d.ts +0 -14
- package/dist/hooks/useI18n.d.ts +4 -0
- package/dist/hooks/useI18n.js +8 -0
- package/dist/utils/classes.d.ts +11 -0
- package/dist/utils/classes.js +12 -1
- package/dist/utils/input-classes.d.ts +37 -2
- package/dist/utils/input-classes.js +65 -6
- package/package.json +7 -7
- package/tailwind-preset.js +108 -29
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
import { tv } from "@heroui/theme";
|
|
2
|
+
import { dataFocusVisibleClasses } from "../../utils/index.js";
|
|
3
|
+
const slider = tv({
|
|
4
|
+
slots: {
|
|
5
|
+
base: 'flex flex-col w-full gap-1',
|
|
6
|
+
labelWrapper: 'w-full flex justify-between items-center',
|
|
7
|
+
label: '',
|
|
8
|
+
value: '',
|
|
9
|
+
step: [
|
|
10
|
+
'absolute',
|
|
11
|
+
'rounded-full',
|
|
12
|
+
'bg-default-300/50',
|
|
13
|
+
'data-[in-range=true]:bg-background/50'
|
|
14
|
+
],
|
|
15
|
+
mark: [
|
|
16
|
+
'absolute',
|
|
17
|
+
'text-small',
|
|
18
|
+
'cursor-default',
|
|
19
|
+
'opacity-50',
|
|
20
|
+
'data-[in-range=true]:opacity-100'
|
|
21
|
+
],
|
|
22
|
+
trackWrapper: 'relative flex gap-2',
|
|
23
|
+
track: [
|
|
24
|
+
'flex',
|
|
25
|
+
'w-full',
|
|
26
|
+
'relative',
|
|
27
|
+
'rounded-full',
|
|
28
|
+
'bg-background-200'
|
|
29
|
+
],
|
|
30
|
+
filler: 'h-full absolute',
|
|
31
|
+
thumb: [
|
|
32
|
+
'flex',
|
|
33
|
+
'justify-center',
|
|
34
|
+
'items-center',
|
|
35
|
+
'before:absolute',
|
|
36
|
+
'before:w-11',
|
|
37
|
+
'before:h-11',
|
|
38
|
+
'before:rounded-full',
|
|
39
|
+
'after:bg-background',
|
|
40
|
+
'data-[focused=true]:z-10',
|
|
41
|
+
'shadow-none',
|
|
42
|
+
dataFocusVisibleClasses
|
|
43
|
+
],
|
|
44
|
+
startContent: [],
|
|
45
|
+
endContent: []
|
|
46
|
+
},
|
|
47
|
+
variants: {
|
|
48
|
+
size: {
|
|
49
|
+
sm: {
|
|
50
|
+
label: 'text-small',
|
|
51
|
+
value: 'text-small',
|
|
52
|
+
thumb: 'w-3 h-3 after:w-0 after:h-0',
|
|
53
|
+
step: 'h-1 w-1 data-[in-range=false]:bg-default-200',
|
|
54
|
+
mark: 'text-[10px]'
|
|
55
|
+
},
|
|
56
|
+
md: {
|
|
57
|
+
thumb: 'w-6 h-6 after:w-5 after:h-5',
|
|
58
|
+
label: 'text-small',
|
|
59
|
+
value: 'text-small',
|
|
60
|
+
step: 'h-1.5 w-1.5'
|
|
61
|
+
},
|
|
62
|
+
lg: {
|
|
63
|
+
thumb: 'h-7 w-7 after:w-5 after:h-5',
|
|
64
|
+
step: 'w-2 h-2',
|
|
65
|
+
label: 'text-medium',
|
|
66
|
+
value: 'text-medium',
|
|
67
|
+
mark: 'mt-2'
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
radius: {
|
|
71
|
+
none: {
|
|
72
|
+
thumb: 'rounded-none after:rounded-none'
|
|
73
|
+
},
|
|
74
|
+
sm: {
|
|
75
|
+
thumb: 'rounded-[calc(var(--heroui-radius-small)/2)] after:rounded-[calc(var(--heroui-radius-small)/3)]'
|
|
76
|
+
},
|
|
77
|
+
md: {
|
|
78
|
+
thumb: 'rounded-[calc(var(--heroui-radius-medium)/2)] after:rounded-[calc(var(--heroui-radius-medium)/3)]'
|
|
79
|
+
},
|
|
80
|
+
lg: {
|
|
81
|
+
thumb: 'rounded-[calc(var(--heroui-radius-large)/1.5)] after:rounded-[calc(var(--heroui-radius-large)/2)]'
|
|
82
|
+
},
|
|
83
|
+
full: {
|
|
84
|
+
thumb: 'rounded-full after:rounded-full'
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
color: {
|
|
88
|
+
foreground: {
|
|
89
|
+
filler: 'bg-foreground',
|
|
90
|
+
thumb: 'bg-foreground'
|
|
91
|
+
},
|
|
92
|
+
primary: {
|
|
93
|
+
filler: 'bg-primary',
|
|
94
|
+
thumb: 'bg-primary'
|
|
95
|
+
},
|
|
96
|
+
secondary: {
|
|
97
|
+
filler: 'bg-secondary',
|
|
98
|
+
thumb: 'bg-secondary'
|
|
99
|
+
},
|
|
100
|
+
success: {
|
|
101
|
+
filler: 'bg-success',
|
|
102
|
+
thumb: 'bg-success'
|
|
103
|
+
},
|
|
104
|
+
warning: {
|
|
105
|
+
filler: 'bg-warning',
|
|
106
|
+
thumb: 'bg-warning'
|
|
107
|
+
},
|
|
108
|
+
danger: {
|
|
109
|
+
filler: 'bg-danger',
|
|
110
|
+
thumb: 'bg-danger'
|
|
111
|
+
},
|
|
112
|
+
alert: {
|
|
113
|
+
filler: 'bg-alert',
|
|
114
|
+
thumb: 'bg-alert'
|
|
115
|
+
},
|
|
116
|
+
bullish: {
|
|
117
|
+
filler: 'bg-bullish',
|
|
118
|
+
thumb: 'bg-bullish'
|
|
119
|
+
},
|
|
120
|
+
bearish: {
|
|
121
|
+
filler: 'bg-bearish',
|
|
122
|
+
thumb: 'bg-bearish'
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
isVertical: {
|
|
126
|
+
true: {
|
|
127
|
+
base: 'w-auto h-full flex-col-reverse items-center',
|
|
128
|
+
trackWrapper: 'flex-col h-full justify-center items-center',
|
|
129
|
+
filler: 'w-full h-auto',
|
|
130
|
+
thumb: 'left-1/2',
|
|
131
|
+
track: 'h-full border-y-transparent',
|
|
132
|
+
labelWrapper: 'flex-col justify-center items-center',
|
|
133
|
+
step: [
|
|
134
|
+
'left-1/2',
|
|
135
|
+
'-translate-x-1/2',
|
|
136
|
+
'translate-y-1/2'
|
|
137
|
+
],
|
|
138
|
+
mark: [
|
|
139
|
+
'left-1/2',
|
|
140
|
+
'ml-1',
|
|
141
|
+
'translate-x-1/2',
|
|
142
|
+
'translate-y-1/2'
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
false: {
|
|
146
|
+
thumb: 'top-1/2',
|
|
147
|
+
trackWrapper: 'items-center',
|
|
148
|
+
track: 'border-x-transparent',
|
|
149
|
+
step: [
|
|
150
|
+
'top-1/2',
|
|
151
|
+
'-translate-x-1/2',
|
|
152
|
+
'-translate-y-1/2'
|
|
153
|
+
],
|
|
154
|
+
mark: [
|
|
155
|
+
'top-1/2',
|
|
156
|
+
'mt-1',
|
|
157
|
+
'-translate-x-1/2',
|
|
158
|
+
'translate-y-1/2'
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
isDisabled: {
|
|
163
|
+
false: {
|
|
164
|
+
thumb: [
|
|
165
|
+
'cursor-grab',
|
|
166
|
+
'data-[dragging=true]:cursor-grabbing'
|
|
167
|
+
]
|
|
168
|
+
},
|
|
169
|
+
true: {
|
|
170
|
+
base: 'opacity-disabled',
|
|
171
|
+
thumb: 'cursor-default'
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
hasMarks: {
|
|
175
|
+
true: {
|
|
176
|
+
base: 'mb-5',
|
|
177
|
+
mark: 'cursor-pointer'
|
|
178
|
+
},
|
|
179
|
+
false: {}
|
|
180
|
+
},
|
|
181
|
+
showOutline: {
|
|
182
|
+
true: {
|
|
183
|
+
thumb: 'ring-2 ring-background'
|
|
184
|
+
},
|
|
185
|
+
false: {
|
|
186
|
+
thumb: 'ring-transparent border-0'
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
hideValue: {
|
|
190
|
+
true: {
|
|
191
|
+
value: 'sr-only'
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
hideThumb: {
|
|
195
|
+
true: {
|
|
196
|
+
thumb: 'sr-only',
|
|
197
|
+
track: 'cursor-pointer'
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
hasSingleThumb: {
|
|
201
|
+
true: {},
|
|
202
|
+
false: {}
|
|
203
|
+
},
|
|
204
|
+
disableAnimation: {
|
|
205
|
+
true: {
|
|
206
|
+
thumb: 'data-[dragging=true]:after:scale-100'
|
|
207
|
+
},
|
|
208
|
+
false: {
|
|
209
|
+
thumb: 'after:transition-all motion-reduce:after:transition-none',
|
|
210
|
+
mark: 'transition-opacity motion-reduce:transition-none'
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
disableThumbScale: {
|
|
214
|
+
true: {},
|
|
215
|
+
false: {
|
|
216
|
+
thumb: 'data-[dragging=true]:after:scale-80'
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
compoundVariants: [
|
|
221
|
+
{
|
|
222
|
+
size: 'sm',
|
|
223
|
+
color: 'foreground',
|
|
224
|
+
class: {
|
|
225
|
+
step: 'data-[in-range=true]:bg-foreground'
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
size: 'sm',
|
|
230
|
+
color: 'primary',
|
|
231
|
+
class: {
|
|
232
|
+
step: 'data-[in-range=true]:bg-primary'
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
size: 'sm',
|
|
237
|
+
color: 'secondary',
|
|
238
|
+
class: {
|
|
239
|
+
step: 'data-[in-range=true]:bg-secondary'
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
size: 'sm',
|
|
244
|
+
color: 'alert',
|
|
245
|
+
class: {
|
|
246
|
+
step: 'data-[in-range=true]:bg-alert'
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
size: 'sm',
|
|
251
|
+
color: 'success',
|
|
252
|
+
class: {
|
|
253
|
+
step: 'data-[in-range=true]:bg-success'
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
size: 'sm',
|
|
258
|
+
color: 'warning',
|
|
259
|
+
class: {
|
|
260
|
+
step: 'data-[in-range=true]:bg-warning'
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
size: 'sm',
|
|
265
|
+
color: 'danger',
|
|
266
|
+
class: {
|
|
267
|
+
step: 'data-[in-range=true]:bg-danger'
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
size: 'sm',
|
|
272
|
+
color: 'bullish',
|
|
273
|
+
class: {
|
|
274
|
+
step: 'data-[in-range=true]:bg-bullish'
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
size: 'sm',
|
|
279
|
+
color: 'bearish',
|
|
280
|
+
class: {
|
|
281
|
+
step: 'data-[in-range=true]:bg-bearish'
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
size: 'sm',
|
|
286
|
+
isVertical: false,
|
|
287
|
+
class: {
|
|
288
|
+
track: 'h-0.5'
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
size: 'md',
|
|
293
|
+
isVertical: false,
|
|
294
|
+
class: {
|
|
295
|
+
track: 'h-3 my-[calc((theme(spacing.6)-theme(spacing.3))/2)] border-x-[calc(theme(spacing.6)/2)]'
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
size: 'lg',
|
|
300
|
+
isVertical: false,
|
|
301
|
+
class: {
|
|
302
|
+
track: 'h-7 my-[calc((theme(spacing.7)-theme(spacing.5))/2)] border-x-[calc(theme(spacing.7)/2)]'
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
size: 'sm',
|
|
307
|
+
isVertical: true,
|
|
308
|
+
class: {
|
|
309
|
+
track: 'w-0.5 mx-[calc((theme(spacing.5)-theme(spacing.1))/2)] border-y-[calc(theme(spacing.5)/2)]'
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
size: 'md',
|
|
314
|
+
isVertical: true,
|
|
315
|
+
class: {
|
|
316
|
+
track: 'w-3 mx-[calc((theme(spacing.6)-theme(spacing.3))/2)] border-y-[calc(theme(spacing.6)/2)]'
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
size: 'lg',
|
|
321
|
+
isVertical: true,
|
|
322
|
+
class: {
|
|
323
|
+
track: 'w-7 mx-[calc((theme(spacing.7)-theme(spacing.5))/2)] border-y-[calc(theme(spacing.7)/2)]'
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
color: 'foreground',
|
|
328
|
+
isVertical: false,
|
|
329
|
+
class: {
|
|
330
|
+
track: 'data-[fill-start=true]:border-s-foreground data-[fill-end=true]:border-e-foreground'
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
color: 'primary',
|
|
335
|
+
isVertical: false,
|
|
336
|
+
class: {
|
|
337
|
+
track: 'data-[fill-start=true]:border-s-primary data-[fill-end=true]:border-e-primary'
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
color: 'secondary',
|
|
342
|
+
isVertical: false,
|
|
343
|
+
class: {
|
|
344
|
+
track: 'data-[fill-start=true]:border-s-secondary data-[fill-end=true]:border-e-secondary'
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
color: 'alert',
|
|
349
|
+
isVertical: false,
|
|
350
|
+
class: {
|
|
351
|
+
track: 'data-[fill-start=true]:border-s-alert data-[fill-end=true]:border-e-alert'
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
color: 'success',
|
|
356
|
+
isVertical: false,
|
|
357
|
+
class: {
|
|
358
|
+
track: 'data-[fill-start=true]:border-s-success data-[fill-end=true]:border-e-success'
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
color: 'warning',
|
|
363
|
+
isVertical: false,
|
|
364
|
+
class: {
|
|
365
|
+
track: 'data-[fill-start=true]:border-s-warning data-[fill-end=true]:border-e-warning'
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
color: 'danger',
|
|
370
|
+
isVertical: false,
|
|
371
|
+
class: {
|
|
372
|
+
track: 'data-[fill-start=true]:border-s-danger data-[fill-end=true]:border-e-danger'
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
color: 'bullish',
|
|
377
|
+
isVertical: false,
|
|
378
|
+
class: {
|
|
379
|
+
track: 'data-[fill-start=true]:border-s-bullish data-[fill-end=true]:border-e-bullish'
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
color: 'bearish',
|
|
384
|
+
isVertical: false,
|
|
385
|
+
class: {
|
|
386
|
+
track: 'data-[fill-start=true]:border-s-bearish data-[fill-end=true]:border-e-bearish'
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
color: 'foreground',
|
|
391
|
+
isVertical: true,
|
|
392
|
+
class: {
|
|
393
|
+
track: 'data-[fill-start=true]:border-b-foreground data-[fill-end=true]:border-t-foreground'
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
color: 'primary',
|
|
398
|
+
isVertical: true,
|
|
399
|
+
class: {
|
|
400
|
+
track: 'data-[fill-start=true]:border-b-primary data-[fill-end=true]:border-t-primary'
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
color: 'secondary',
|
|
405
|
+
isVertical: true,
|
|
406
|
+
class: {
|
|
407
|
+
track: 'data-[fill-start=true]:border-b-secondary data-[fill-end=true]:border-t-secondary'
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
color: 'alert',
|
|
412
|
+
isVertical: true,
|
|
413
|
+
class: {
|
|
414
|
+
track: 'data-[fill-start=true]:border-b-alert data-[fill-end=true]:border-t-alert'
|
|
415
|
+
}
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
color: 'success',
|
|
419
|
+
isVertical: true,
|
|
420
|
+
class: {
|
|
421
|
+
track: 'data-[fill-start=true]:border-b-success data-[fill-end=true]:border-t-success'
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
color: 'warning',
|
|
426
|
+
isVertical: true,
|
|
427
|
+
class: {
|
|
428
|
+
track: 'data-[fill-start=true]:border-b-warning data-[fill-end=true]:border-t-warning'
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
color: 'danger',
|
|
433
|
+
isVertical: true,
|
|
434
|
+
class: {
|
|
435
|
+
track: 'data-[fill-start=true]:border-b-danger data-[fill-end=true]:border-t-danger'
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
color: 'bullish',
|
|
440
|
+
isVertical: true,
|
|
441
|
+
class: {
|
|
442
|
+
track: 'data-[fill-start=true]:border-b-bullish data-[fill-end=true]:border-t-bullish'
|
|
443
|
+
}
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
color: 'bearish',
|
|
447
|
+
isVertical: true,
|
|
448
|
+
class: {
|
|
449
|
+
track: 'data-[fill-start=true]:border-b-bearish data-[fill-end=true]:border-t-bearish'
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
],
|
|
453
|
+
defaultVariants: {
|
|
454
|
+
size: 'md',
|
|
455
|
+
color: 'primary',
|
|
456
|
+
radius: 'full',
|
|
457
|
+
hideValue: false,
|
|
458
|
+
hideThumb: false,
|
|
459
|
+
isDisabled: false,
|
|
460
|
+
disableThumbScale: false,
|
|
461
|
+
showOutline: false
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
export { slider };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { renderFn } from "@heroui/react-utils";
|
|
3
|
+
import { forwardRef } from "@heroui/system";
|
|
4
|
+
import { Tooltip } from "@heroui/tooltip";
|
|
5
|
+
import { VisuallyHidden } from "@react-aria/visually-hidden";
|
|
6
|
+
import { useSliderThumb } from "./use-slider-thumb.js";
|
|
7
|
+
const SliderThumb = forwardRef((props, ref)=>{
|
|
8
|
+
const { Component, index, renderThumb, showTooltip, getTooltipProps, getThumbProps, getInputProps } = useSliderThumb({
|
|
9
|
+
...props,
|
|
10
|
+
ref
|
|
11
|
+
});
|
|
12
|
+
const thumbProps = {
|
|
13
|
+
...getThumbProps(),
|
|
14
|
+
index,
|
|
15
|
+
children: /*#__PURE__*/ jsx(VisuallyHidden, {
|
|
16
|
+
children: /*#__PURE__*/ jsx("input", {
|
|
17
|
+
...getInputProps()
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
};
|
|
21
|
+
const content = renderFn({
|
|
22
|
+
Component,
|
|
23
|
+
props: thumbProps,
|
|
24
|
+
renderCustom: renderThumb
|
|
25
|
+
});
|
|
26
|
+
return showTooltip ? /*#__PURE__*/ jsx(Tooltip, {
|
|
27
|
+
...getTooltipProps(),
|
|
28
|
+
children: content
|
|
29
|
+
}) : content;
|
|
30
|
+
});
|
|
31
|
+
SliderThumb.displayName = 'HeroUI.SliderThumb';
|
|
32
|
+
const slider_thumb = SliderThumb;
|
|
33
|
+
export { slider_thumb as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { UseSliderProps } from './use-slider';
|
|
2
|
+
export type SliderProps = Omit<UseSliderProps, 'isVertical' | 'hasMarks' | 'hasSingleThumb'>;
|
|
3
|
+
declare const Slider: import("@heroui/system-rsc").InternalForwardRefRenderFunction<"div", SliderProps, never>;
|
|
4
|
+
export default Slider;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { renderFn } from "@heroui/react-utils";
|
|
3
|
+
import { forwardRef } from "@heroui/system";
|
|
4
|
+
import slider_thumb from "./slider-thumb.js";
|
|
5
|
+
import { useSlider } from "./use-slider.js";
|
|
6
|
+
const Slider = forwardRef((props, ref)=>{
|
|
7
|
+
const { Component, state, label, steps, marks, startContent, endContent, showMarksSteps, minValue, step, getStepProps, getBaseProps, renderValue, renderLabel, getTrackWrapperProps, getLabelWrapperProps, getLabelProps, getValueProps, getTrackProps, getFillerProps, getThumbProps, getMarkProps, getStartContentProps, getEndContentProps } = useSlider({
|
|
8
|
+
...props,
|
|
9
|
+
ref
|
|
10
|
+
});
|
|
11
|
+
return /*#__PURE__*/ jsxs(Component, {
|
|
12
|
+
...getBaseProps(),
|
|
13
|
+
children: [
|
|
14
|
+
label && /*#__PURE__*/ jsxs("div", {
|
|
15
|
+
...getLabelWrapperProps(),
|
|
16
|
+
children: [
|
|
17
|
+
renderFn({
|
|
18
|
+
Component: 'label',
|
|
19
|
+
props: getLabelProps(),
|
|
20
|
+
renderCustom: renderLabel
|
|
21
|
+
}),
|
|
22
|
+
renderFn({
|
|
23
|
+
Component: 'output',
|
|
24
|
+
props: getValueProps(),
|
|
25
|
+
renderCustom: renderValue
|
|
26
|
+
})
|
|
27
|
+
]
|
|
28
|
+
}),
|
|
29
|
+
/*#__PURE__*/ jsxs("div", {
|
|
30
|
+
...getTrackWrapperProps(),
|
|
31
|
+
children: [
|
|
32
|
+
startContent && /*#__PURE__*/ jsx("div", {
|
|
33
|
+
...getStartContentProps(),
|
|
34
|
+
children: startContent
|
|
35
|
+
}),
|
|
36
|
+
/*#__PURE__*/ jsxs("div", {
|
|
37
|
+
...getTrackProps(),
|
|
38
|
+
children: [
|
|
39
|
+
/*#__PURE__*/ jsx("div", {
|
|
40
|
+
...getFillerProps()
|
|
41
|
+
}),
|
|
42
|
+
Number.isFinite(steps) && Array.from({
|
|
43
|
+
length: steps
|
|
44
|
+
}, (_, index)=>/*#__PURE__*/ jsx("div", {
|
|
45
|
+
...getStepProps(index)
|
|
46
|
+
}, index)),
|
|
47
|
+
state.values.map((_, index)=>/*#__PURE__*/ jsx(slider_thumb, {
|
|
48
|
+
...getThumbProps(index)
|
|
49
|
+
}, index)),
|
|
50
|
+
marks?.length > 0 && marks.map((mark, index)=>{
|
|
51
|
+
const isMarkAtThumbPosition = state.values.some((value)=>value === mark.value);
|
|
52
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
53
|
+
children: [
|
|
54
|
+
showMarksSteps && !isMarkAtThumbPosition && /*#__PURE__*/ jsx("div", {
|
|
55
|
+
...getStepProps(Math.round((mark.value - minValue) / step))
|
|
56
|
+
}, `step-${index}`),
|
|
57
|
+
/*#__PURE__*/ jsx("div", {
|
|
58
|
+
...getMarkProps(mark),
|
|
59
|
+
children: mark.label
|
|
60
|
+
}, `mark-${index}`)
|
|
61
|
+
]
|
|
62
|
+
});
|
|
63
|
+
})
|
|
64
|
+
]
|
|
65
|
+
}),
|
|
66
|
+
endContent && /*#__PURE__*/ jsx("div", {
|
|
67
|
+
...getEndContentProps(),
|
|
68
|
+
children: endContent
|
|
69
|
+
})
|
|
70
|
+
]
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
Slider.displayName = 'HeroUI.Slider';
|
|
76
|
+
const slider = Slider;
|
|
77
|
+
export { slider as default };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { RefObject } from 'react';
|
|
2
|
+
import type { ReactRef } from '@heroui/react-utils';
|
|
3
|
+
import type { HTMLHeroUIProps, PropGetter } from '@heroui/system';
|
|
4
|
+
import type { SliderVariantProps } from '@heroui/theme';
|
|
5
|
+
import type { TooltipProps } from '@heroui/tooltip';
|
|
6
|
+
import type { AriaSliderThumbProps } from '@react-aria/slider';
|
|
7
|
+
import type { SliderState } from '@react-stately/slider';
|
|
8
|
+
import type { SliderValue, UseSliderProps } from './use-slider';
|
|
9
|
+
interface Props extends HTMLHeroUIProps {
|
|
10
|
+
/**
|
|
11
|
+
* Ref to the DOM node.
|
|
12
|
+
*/
|
|
13
|
+
ref?: ReactRef<HTMLElement | null>;
|
|
14
|
+
/**
|
|
15
|
+
* slider state, created via `useSliderState`.
|
|
16
|
+
*/
|
|
17
|
+
state: SliderState;
|
|
18
|
+
/**
|
|
19
|
+
* A ref to the track element.
|
|
20
|
+
*/
|
|
21
|
+
trackRef: RefObject<HTMLDivElement>;
|
|
22
|
+
/**
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
isVertical: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
showTooltip?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
formatOptions?: Intl.NumberFormatOptions;
|
|
34
|
+
/**
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
tooltipProps?: UseSliderProps['tooltipProps'];
|
|
38
|
+
/**
|
|
39
|
+
* A function that returns the content to display as the tooltip label. (in analogy to getValue)
|
|
40
|
+
* @param value - The value of the slider, array or single number.
|
|
41
|
+
* @param index - The index of the thumb, if multiple thumbs are used.
|
|
42
|
+
* In addition to formatting with tooltipValueFormatOptions if number is returned.
|
|
43
|
+
*/
|
|
44
|
+
getTooltipValue?: (value: SliderValue, index?: number) => string | number;
|
|
45
|
+
/**
|
|
46
|
+
* Function to render the thumb. It can be used to add a tooltip or custom icon.
|
|
47
|
+
*/
|
|
48
|
+
renderThumb?: UseSliderProps['renderThumb'];
|
|
49
|
+
}
|
|
50
|
+
export type UseSliderThumbProps = Props & AriaSliderThumbProps & SliderVariantProps;
|
|
51
|
+
export declare function useSliderThumb(props: UseSliderThumbProps): {
|
|
52
|
+
Component: import("@heroui/system-rsc").As<any>;
|
|
53
|
+
index: number | undefined;
|
|
54
|
+
showTooltip: boolean | undefined;
|
|
55
|
+
renderThumb: ((props: import("./use-slider").SliderRenderThumbProps) => React.ReactNode) | undefined;
|
|
56
|
+
getThumbProps: PropGetter;
|
|
57
|
+
getTooltipProps: () => TooltipProps;
|
|
58
|
+
getInputProps: PropGetter;
|
|
59
|
+
};
|
|
60
|
+
export type UseSliderThumbReturn = ReturnType<typeof useSliderThumb>;
|
|
61
|
+
export {};
|