@auronui/vue 1.1.1 → 1.2.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/cjs/index.cjs +759 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/composables/useAccordion.js +58 -0
- package/dist/composables/useAccordion.js.map +1 -0
- package/dist/composables/useCalendar.js +47 -0
- package/dist/composables/useCalendar.js.map +1 -0
- package/dist/composables/useCheckboxGroup.js +64 -0
- package/dist/composables/useCheckboxGroup.js.map +1 -0
- package/dist/composables/useColorPicker.js +68 -0
- package/dist/composables/useColorPicker.js.map +1 -0
- package/dist/composables/useDisclosure.js +43 -0
- package/dist/composables/useDisclosure.js.map +1 -0
- package/dist/composables/useListBox.js +61 -0
- package/dist/composables/useListBox.js.map +1 -0
- package/dist/composables/useOTP.js +29 -0
- package/dist/composables/useOTP.js.map +1 -0
- package/dist/composables/usePagination.js +54 -0
- package/dist/composables/usePagination.js.map +1 -0
- package/dist/composables/useRadioGroup.js +38 -0
- package/dist/composables/useRadioGroup.js.map +1 -0
- package/dist/composables/useRangeCalendar.js +51 -0
- package/dist/composables/useRangeCalendar.js.map +1 -0
- package/dist/composables/useSlider.js +46 -0
- package/dist/composables/useSlider.js.map +1 -0
- package/dist/composables/useSplitter.js +39 -0
- package/dist/composables/useSplitter.js.map +1 -0
- package/dist/composables/useStepper.js +58 -0
- package/dist/composables/useStepper.js.map +1 -0
- package/dist/composables/useSwatchPicker.js +31 -0
- package/dist/composables/useSwatchPicker.js.map +1 -0
- package/dist/composables/useTabs.js +34 -0
- package/dist/composables/useTabs.js.map +1 -0
- package/dist/composables/useTree.js +88 -0
- package/dist/composables/useTree.js.map +1 -0
- package/dist/index.d.ts +786 -64
- package/dist/index.js +17 -1
- package/package.json +4 -4
package/dist/cjs/index.cjs
CHANGED
|
@@ -249,6 +249,635 @@ function useListData(options) {
|
|
|
249
249
|
};
|
|
250
250
|
}
|
|
251
251
|
//#endregion
|
|
252
|
+
//#region src/composables/useDisclosure.ts
|
|
253
|
+
/**
|
|
254
|
+
* Manages programmatic open/close state for overlay components.
|
|
255
|
+
*
|
|
256
|
+
* Wire the returned refs and handlers directly into the component:
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```ts
|
|
260
|
+
* const modal = useDisclosure()
|
|
261
|
+
* await saveData()
|
|
262
|
+
* modal.open()
|
|
263
|
+
* ```
|
|
264
|
+
* ```html
|
|
265
|
+
* <Modal :open="modal.isOpen" @update:open="modal.onOpenChange">...</Modal>
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
function useDisclosure(defaultOpen = false) {
|
|
269
|
+
const _isOpen = (0, vue.ref)(defaultOpen);
|
|
270
|
+
function open() {
|
|
271
|
+
_isOpen.value = true;
|
|
272
|
+
}
|
|
273
|
+
function close() {
|
|
274
|
+
_isOpen.value = false;
|
|
275
|
+
}
|
|
276
|
+
function toggle() {
|
|
277
|
+
_isOpen.value = !_isOpen.value;
|
|
278
|
+
}
|
|
279
|
+
function onOpenChange(value) {
|
|
280
|
+
_isOpen.value = value;
|
|
281
|
+
}
|
|
282
|
+
return {
|
|
283
|
+
isOpen: (0, vue.readonly)(_isOpen),
|
|
284
|
+
open,
|
|
285
|
+
close,
|
|
286
|
+
toggle,
|
|
287
|
+
onOpenChange
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/composables/usePagination.ts
|
|
292
|
+
/**
|
|
293
|
+
* Manages pagination state for the Pagination component.
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* ```ts
|
|
297
|
+
* const pagination = usePagination({ totalItems: 200, pageSize: 20 })
|
|
298
|
+
* ```
|
|
299
|
+
* ```html
|
|
300
|
+
* <Pagination
|
|
301
|
+
* :page="pagination.page"
|
|
302
|
+
* :total-items="pagination.totalItems"
|
|
303
|
+
* :items-per-page="pagination.pageSize"
|
|
304
|
+
* @update:page="pagination.onPageChange"
|
|
305
|
+
* />
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
function usePagination(options = {}) {
|
|
309
|
+
const page = (0, vue.ref)(options.defaultPage ?? 1);
|
|
310
|
+
const pageSize = (0, vue.ref)(options.pageSize ?? 10);
|
|
311
|
+
const totalItems = (0, vue.ref)(options.totalItems ?? 0);
|
|
312
|
+
const totalPages = (0, vue.computed)(() => Math.max(1, Math.ceil(totalItems.value / pageSize.value)));
|
|
313
|
+
const isFirst = (0, vue.computed)(() => page.value <= 1);
|
|
314
|
+
const isLast = (0, vue.computed)(() => page.value >= totalPages.value);
|
|
315
|
+
function goToPage(p) {
|
|
316
|
+
page.value = Math.max(1, Math.min(p, totalPages.value));
|
|
317
|
+
}
|
|
318
|
+
function nextPage() {
|
|
319
|
+
if (!isLast.value) goToPage(page.value + 1);
|
|
320
|
+
}
|
|
321
|
+
function prevPage() {
|
|
322
|
+
if (!isFirst.value) goToPage(page.value - 1);
|
|
323
|
+
}
|
|
324
|
+
function onPageChange(p) {
|
|
325
|
+
goToPage(p);
|
|
326
|
+
}
|
|
327
|
+
return {
|
|
328
|
+
page,
|
|
329
|
+
pageSize,
|
|
330
|
+
totalItems,
|
|
331
|
+
totalPages,
|
|
332
|
+
isFirst,
|
|
333
|
+
isLast,
|
|
334
|
+
goToPage,
|
|
335
|
+
nextPage,
|
|
336
|
+
prevPage,
|
|
337
|
+
onPageChange
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
//#endregion
|
|
341
|
+
//#region src/composables/useStepper.ts
|
|
342
|
+
/**
|
|
343
|
+
* Manages step navigation state for the Stepper component.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```ts
|
|
347
|
+
* const stepper = useStepper({ totalSteps: 4 })
|
|
348
|
+
* ```
|
|
349
|
+
* ```html
|
|
350
|
+
* <Stepper :model-value="stepper.step" :total-steps="stepper.totalSteps" @update:model-value="stepper.onStepChange">
|
|
351
|
+
* ...
|
|
352
|
+
* </Stepper>
|
|
353
|
+
* ```
|
|
354
|
+
*/
|
|
355
|
+
function useStepper(options = {}) {
|
|
356
|
+
const step = (0, vue.ref)(options.defaultStep ?? 1);
|
|
357
|
+
const totalSteps = (0, vue.computed)(() => options.steps ? options.steps.length : options.totalSteps ?? 0);
|
|
358
|
+
const isFirst = (0, vue.computed)(() => step.value <= 1);
|
|
359
|
+
const isLast = (0, vue.computed)(() => totalSteps.value > 0 && step.value >= totalSteps.value);
|
|
360
|
+
function goToStep(n) {
|
|
361
|
+
const max = totalSteps.value || Infinity;
|
|
362
|
+
step.value = Math.max(1, Math.min(n, max));
|
|
363
|
+
}
|
|
364
|
+
function nextStep() {
|
|
365
|
+
if (!isLast.value) goToStep(step.value + 1);
|
|
366
|
+
}
|
|
367
|
+
function prevStep() {
|
|
368
|
+
if (!isFirst.value) goToStep(step.value - 1);
|
|
369
|
+
}
|
|
370
|
+
function reset() {
|
|
371
|
+
goToStep(1);
|
|
372
|
+
}
|
|
373
|
+
function getStepStatus(n) {
|
|
374
|
+
if (n < step.value) return "completed";
|
|
375
|
+
if (n === step.value) return "current";
|
|
376
|
+
return "pending";
|
|
377
|
+
}
|
|
378
|
+
function onStepChange(n) {
|
|
379
|
+
goToStep(n);
|
|
380
|
+
}
|
|
381
|
+
return {
|
|
382
|
+
step,
|
|
383
|
+
totalSteps,
|
|
384
|
+
isFirst,
|
|
385
|
+
isLast,
|
|
386
|
+
goToStep,
|
|
387
|
+
nextStep,
|
|
388
|
+
prevStep,
|
|
389
|
+
reset,
|
|
390
|
+
getStepStatus,
|
|
391
|
+
onStepChange
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
//#endregion
|
|
395
|
+
//#region src/composables/useTabs.ts
|
|
396
|
+
/**
|
|
397
|
+
* Manages active tab state for the Tabs component.
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* ```ts
|
|
401
|
+
* const tabs = useTabs({ defaultTab: 'overview' })
|
|
402
|
+
* ```
|
|
403
|
+
* ```html
|
|
404
|
+
* <Tabs :model-value="tabs.activeTab" @update:model-value="tabs.onTabChange">
|
|
405
|
+
* <Tab value="overview">Overview</Tab>
|
|
406
|
+
* <Tab value="settings">Settings</Tab>
|
|
407
|
+
* </Tabs>
|
|
408
|
+
* ```
|
|
409
|
+
*/
|
|
410
|
+
function useTabs(options = {}) {
|
|
411
|
+
const activeTab = (0, vue.ref)(options.defaultTab);
|
|
412
|
+
function setTab(value) {
|
|
413
|
+
activeTab.value = value;
|
|
414
|
+
}
|
|
415
|
+
function onTabChange(value) {
|
|
416
|
+
activeTab.value = value;
|
|
417
|
+
}
|
|
418
|
+
return {
|
|
419
|
+
activeTab,
|
|
420
|
+
setTab,
|
|
421
|
+
onTabChange
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
//#endregion
|
|
425
|
+
//#region src/composables/useAccordion.ts
|
|
426
|
+
/**
|
|
427
|
+
* Manages expanded item state for the Accordion component.
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```ts
|
|
431
|
+
* const accordion = useAccordion({ type: 'single', collapsible: true })
|
|
432
|
+
* ```
|
|
433
|
+
* ```html
|
|
434
|
+
* <Accordion :type="'single'" :model-value="accordion.expanded" @update:model-value="accordion.onValueChange">
|
|
435
|
+
* ...
|
|
436
|
+
* </Accordion>
|
|
437
|
+
* ```
|
|
438
|
+
*/
|
|
439
|
+
function useAccordion(options = {}) {
|
|
440
|
+
const type = options.type ?? "single";
|
|
441
|
+
const collapsible = options.collapsible ?? false;
|
|
442
|
+
const expanded = (0, vue.ref)(options.defaultExpanded ?? (type === "multiple" ? [] : void 0));
|
|
443
|
+
function isExpanded(key) {
|
|
444
|
+
if (type === "multiple") return expanded.value.includes(key);
|
|
445
|
+
return expanded.value === key;
|
|
446
|
+
}
|
|
447
|
+
function expand(key) {
|
|
448
|
+
if (type === "multiple") {
|
|
449
|
+
const current = expanded.value;
|
|
450
|
+
if (!current.includes(key)) expanded.value = [...current, key];
|
|
451
|
+
} else expanded.value = key;
|
|
452
|
+
}
|
|
453
|
+
function collapse(key) {
|
|
454
|
+
if (type === "multiple") expanded.value = expanded.value.filter((k) => k !== key);
|
|
455
|
+
else if (collapsible && expanded.value === key) expanded.value = void 0;
|
|
456
|
+
}
|
|
457
|
+
function toggle(key) {
|
|
458
|
+
if (isExpanded(key)) collapse(key);
|
|
459
|
+
else expand(key);
|
|
460
|
+
}
|
|
461
|
+
function collapseAll() {
|
|
462
|
+
if (type === "multiple") expanded.value = [];
|
|
463
|
+
else if (collapsible) expanded.value = void 0;
|
|
464
|
+
}
|
|
465
|
+
function onValueChange(value) {
|
|
466
|
+
expanded.value = value;
|
|
467
|
+
}
|
|
468
|
+
return {
|
|
469
|
+
expanded,
|
|
470
|
+
isExpanded,
|
|
471
|
+
expand,
|
|
472
|
+
collapse,
|
|
473
|
+
toggle,
|
|
474
|
+
collapseAll,
|
|
475
|
+
onValueChange
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
//#endregion
|
|
479
|
+
//#region src/composables/useSlider.ts
|
|
480
|
+
/**
|
|
481
|
+
* Manages value state for the Slider component.
|
|
482
|
+
*
|
|
483
|
+
* @example
|
|
484
|
+
* ```ts
|
|
485
|
+
* // Single thumb
|
|
486
|
+
* const slider = useSlider({ defaultValue: 40, min: 0, max: 100 })
|
|
487
|
+
*
|
|
488
|
+
* // Range (two thumbs)
|
|
489
|
+
* const range = useSlider({ defaultValue: [20, 80], min: 0, max: 100 })
|
|
490
|
+
* ```
|
|
491
|
+
* ```html
|
|
492
|
+
* <Slider :model-value="slider.value" :min="slider.min" :max="slider.max" @update:model-value="slider.onValueChange" />
|
|
493
|
+
* ```
|
|
494
|
+
*/
|
|
495
|
+
function useSlider(options = {}) {
|
|
496
|
+
const min = options.min ?? 0;
|
|
497
|
+
const max = options.max ?? 100;
|
|
498
|
+
const step = options.step ?? 1;
|
|
499
|
+
const value = (0, vue.ref)(options.defaultValue ?? min);
|
|
500
|
+
function clamp(v) {
|
|
501
|
+
if (Array.isArray(v)) return v.map((n) => Math.min(Math.max(n, min), max));
|
|
502
|
+
return Math.min(Math.max(v, min), max);
|
|
503
|
+
}
|
|
504
|
+
function setValue(v) {
|
|
505
|
+
value.value = v;
|
|
506
|
+
}
|
|
507
|
+
function onValueChange(v) {
|
|
508
|
+
value.value = v;
|
|
509
|
+
}
|
|
510
|
+
return {
|
|
511
|
+
value,
|
|
512
|
+
min,
|
|
513
|
+
max,
|
|
514
|
+
step,
|
|
515
|
+
setValue,
|
|
516
|
+
clamp,
|
|
517
|
+
onValueChange
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
//#endregion
|
|
521
|
+
//#region src/composables/useListBox.ts
|
|
522
|
+
/**
|
|
523
|
+
* Manages selection state for the ListBox component.
|
|
524
|
+
*
|
|
525
|
+
* @example
|
|
526
|
+
* ```ts
|
|
527
|
+
* const listBox = useListBox({ multiple: true, defaultSelected: ['apple'] })
|
|
528
|
+
* ```
|
|
529
|
+
* ```html
|
|
530
|
+
* <ListBox :model-value="listBox.selected" @update:model-value="listBox.onSelectionChange">
|
|
531
|
+
* <ListBoxItem value="apple">Apple</ListBoxItem>
|
|
532
|
+
* <ListBoxItem value="banana">Banana</ListBoxItem>
|
|
533
|
+
* </ListBox>
|
|
534
|
+
* ```
|
|
535
|
+
*/
|
|
536
|
+
function useListBox(options = {}) {
|
|
537
|
+
const multiple = options.multiple ?? false;
|
|
538
|
+
const selected = (0, vue.ref)(options.defaultSelected ?? (multiple ? [] : void 0));
|
|
539
|
+
function isSelected(key) {
|
|
540
|
+
if (Array.isArray(selected.value)) return selected.value.includes(key);
|
|
541
|
+
return selected.value === key;
|
|
542
|
+
}
|
|
543
|
+
function select(key) {
|
|
544
|
+
if (multiple) {
|
|
545
|
+
const current = selected.value ?? [];
|
|
546
|
+
if (!current.includes(key)) selected.value = [...current, key];
|
|
547
|
+
} else selected.value = key;
|
|
548
|
+
}
|
|
549
|
+
function deselect(key) {
|
|
550
|
+
if (multiple) selected.value = (selected.value ?? []).filter((k) => k !== key);
|
|
551
|
+
else if (selected.value === key) selected.value = void 0;
|
|
552
|
+
}
|
|
553
|
+
function toggle(key) {
|
|
554
|
+
if (isSelected(key)) deselect(key);
|
|
555
|
+
else select(key);
|
|
556
|
+
}
|
|
557
|
+
function selectAll(keys) {
|
|
558
|
+
if (multiple) selected.value = [...new Set(keys)];
|
|
559
|
+
}
|
|
560
|
+
function deselectAll() {
|
|
561
|
+
selected.value = multiple ? [] : void 0;
|
|
562
|
+
}
|
|
563
|
+
function onSelectionChange(value) {
|
|
564
|
+
selected.value = value;
|
|
565
|
+
}
|
|
566
|
+
return {
|
|
567
|
+
selected,
|
|
568
|
+
isSelected,
|
|
569
|
+
select,
|
|
570
|
+
deselect,
|
|
571
|
+
toggle,
|
|
572
|
+
selectAll,
|
|
573
|
+
deselectAll,
|
|
574
|
+
onSelectionChange
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
//#endregion
|
|
578
|
+
//#region src/composables/useCheckboxGroup.ts
|
|
579
|
+
/**
|
|
580
|
+
* Manages checked state for a CheckboxGroup.
|
|
581
|
+
*
|
|
582
|
+
* @example
|
|
583
|
+
* ```ts
|
|
584
|
+
* const group = useCheckboxGroup({
|
|
585
|
+
* options: ['apple', 'banana', 'cherry'],
|
|
586
|
+
* defaultValues: ['apple'],
|
|
587
|
+
* })
|
|
588
|
+
* ```
|
|
589
|
+
* ```html
|
|
590
|
+
* <CheckboxGroup :model-value="group.values" @update:model-value="group.onValueChange">
|
|
591
|
+
* <Checkbox value="apple">Apple</Checkbox>
|
|
592
|
+
* <Checkbox value="banana">Banana</Checkbox>
|
|
593
|
+
* <Checkbox value="cherry">Cherry</Checkbox>
|
|
594
|
+
* </CheckboxGroup>
|
|
595
|
+
* ```
|
|
596
|
+
*/
|
|
597
|
+
function useCheckboxGroup(options = {}) {
|
|
598
|
+
const values = (0, vue.ref)(options.defaultValues ? [...options.defaultValues] : []);
|
|
599
|
+
function isChecked(value) {
|
|
600
|
+
return values.value.includes(value);
|
|
601
|
+
}
|
|
602
|
+
function toggle(value) {
|
|
603
|
+
if (isChecked(value)) values.value = values.value.filter((v) => v !== value);
|
|
604
|
+
else values.value = [...values.value, value];
|
|
605
|
+
}
|
|
606
|
+
function checkAll(keys) {
|
|
607
|
+
values.value = [...new Set([...values.value, ...keys])];
|
|
608
|
+
}
|
|
609
|
+
function uncheckAll() {
|
|
610
|
+
values.value = [];
|
|
611
|
+
}
|
|
612
|
+
function setValues(next) {
|
|
613
|
+
values.value = [...next];
|
|
614
|
+
}
|
|
615
|
+
function onValueChange(next) {
|
|
616
|
+
values.value = [...next];
|
|
617
|
+
}
|
|
618
|
+
return {
|
|
619
|
+
values,
|
|
620
|
+
isChecked,
|
|
621
|
+
toggle,
|
|
622
|
+
checkAll,
|
|
623
|
+
uncheckAll,
|
|
624
|
+
setValues,
|
|
625
|
+
isIndeterminate: (0, vue.computed)(() => {
|
|
626
|
+
if (!options.options || options.options.length === 0) return false;
|
|
627
|
+
const count = values.value.filter((v) => options.options.includes(v)).length;
|
|
628
|
+
return count > 0 && count < options.options.length;
|
|
629
|
+
}),
|
|
630
|
+
isAllChecked: (0, vue.computed)(() => {
|
|
631
|
+
if (!options.options || options.options.length === 0) return false;
|
|
632
|
+
return options.options.every((k) => values.value.includes(k));
|
|
633
|
+
}),
|
|
634
|
+
onValueChange
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
//#endregion
|
|
638
|
+
//#region src/composables/useRadioGroup.ts
|
|
639
|
+
/**
|
|
640
|
+
* Manages selection state for the RadioGroup component.
|
|
641
|
+
*
|
|
642
|
+
* @example
|
|
643
|
+
* ```ts
|
|
644
|
+
* const radio = useRadioGroup({ defaultValue: 'option-a' })
|
|
645
|
+
* ```
|
|
646
|
+
* ```html
|
|
647
|
+
* <RadioGroup :model-value="radio.value" @update:model-value="radio.onValueChange">
|
|
648
|
+
* <Radio value="option-a">Option A</Radio>
|
|
649
|
+
* <Radio value="option-b">Option B</Radio>
|
|
650
|
+
* </RadioGroup>
|
|
651
|
+
* ```
|
|
652
|
+
*/
|
|
653
|
+
function useRadioGroup(options = {}) {
|
|
654
|
+
const value = (0, vue.ref)(options.defaultValue);
|
|
655
|
+
function setValue(v) {
|
|
656
|
+
value.value = v;
|
|
657
|
+
}
|
|
658
|
+
function clear() {
|
|
659
|
+
value.value = void 0;
|
|
660
|
+
}
|
|
661
|
+
function onValueChange(v) {
|
|
662
|
+
value.value = v;
|
|
663
|
+
}
|
|
664
|
+
return {
|
|
665
|
+
value,
|
|
666
|
+
setValue,
|
|
667
|
+
clear,
|
|
668
|
+
onValueChange
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
//#endregion
|
|
672
|
+
//#region src/composables/useCalendar.ts
|
|
673
|
+
/**
|
|
674
|
+
* Manages selected date state for the Calendar component.
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
* ```ts
|
|
678
|
+
* const calendar = useCalendar()
|
|
679
|
+
* ```
|
|
680
|
+
* ```html
|
|
681
|
+
* <Calendar v-model="calendar.value" />
|
|
682
|
+
* ```
|
|
683
|
+
*/
|
|
684
|
+
function useCalendar(options = {}) {
|
|
685
|
+
const value = (0, vue.shallowRef)(options.defaultValue);
|
|
686
|
+
const hasValue = (0, vue.computed)(() => value.value !== void 0);
|
|
687
|
+
function setValue(date) {
|
|
688
|
+
value.value = date;
|
|
689
|
+
}
|
|
690
|
+
function clear() {
|
|
691
|
+
value.value = void 0;
|
|
692
|
+
}
|
|
693
|
+
function isDisabled(date) {
|
|
694
|
+
if (options.minValue && date.compare(options.minValue) < 0) return true;
|
|
695
|
+
if (options.maxValue && date.compare(options.maxValue) > 0) return true;
|
|
696
|
+
return options.isDateDisabled?.(date) ?? false;
|
|
697
|
+
}
|
|
698
|
+
function isUnavailable(date) {
|
|
699
|
+
return options.isDateUnavailable?.(date) ?? false;
|
|
700
|
+
}
|
|
701
|
+
function onValueChange(date) {
|
|
702
|
+
value.value = date;
|
|
703
|
+
}
|
|
704
|
+
return {
|
|
705
|
+
value,
|
|
706
|
+
hasValue,
|
|
707
|
+
setValue,
|
|
708
|
+
clear,
|
|
709
|
+
isDisabled,
|
|
710
|
+
isUnavailable,
|
|
711
|
+
onValueChange
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
//#endregion
|
|
715
|
+
//#region src/composables/useRangeCalendar.ts
|
|
716
|
+
/**
|
|
717
|
+
* Manages selected date range state for the RangeCalendar component.
|
|
718
|
+
*
|
|
719
|
+
* @example
|
|
720
|
+
* ```ts
|
|
721
|
+
* const range = useRangeCalendar()
|
|
722
|
+
* ```
|
|
723
|
+
* ```html
|
|
724
|
+
* <RangeCalendar v-model="range.value" />
|
|
725
|
+
* ```
|
|
726
|
+
*/
|
|
727
|
+
function useRangeCalendar(options = {}) {
|
|
728
|
+
const value = (0, vue.shallowRef)(options.defaultValue ?? null);
|
|
729
|
+
const start = (0, vue.computed)(() => value.value?.start ?? null);
|
|
730
|
+
const end = (0, vue.computed)(() => value.value?.end ?? null);
|
|
731
|
+
const isComplete = (0, vue.computed)(() => value.value !== null && !!value.value?.start && !!value.value?.end);
|
|
732
|
+
function setRange(range) {
|
|
733
|
+
value.value = range;
|
|
734
|
+
}
|
|
735
|
+
function clearRange() {
|
|
736
|
+
value.value = null;
|
|
737
|
+
}
|
|
738
|
+
function isDisabled(date) {
|
|
739
|
+
if (options.minValue && date.compare(options.minValue) < 0) return true;
|
|
740
|
+
if (options.maxValue && date.compare(options.maxValue) > 0) return true;
|
|
741
|
+
return options.isDateDisabled?.(date) ?? false;
|
|
742
|
+
}
|
|
743
|
+
function isUnavailable(date) {
|
|
744
|
+
return options.isDateUnavailable?.(date) ?? false;
|
|
745
|
+
}
|
|
746
|
+
function onValueChange(range) {
|
|
747
|
+
value.value = range;
|
|
748
|
+
}
|
|
749
|
+
return {
|
|
750
|
+
value,
|
|
751
|
+
start,
|
|
752
|
+
end,
|
|
753
|
+
isComplete,
|
|
754
|
+
setRange,
|
|
755
|
+
clearRange,
|
|
756
|
+
isDisabled,
|
|
757
|
+
isUnavailable,
|
|
758
|
+
onValueChange
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
//#endregion
|
|
762
|
+
//#region src/composables/useTree.ts
|
|
763
|
+
/**
|
|
764
|
+
* Manages selection and expansion state for the Tree component.
|
|
765
|
+
*
|
|
766
|
+
* @example
|
|
767
|
+
* ```ts
|
|
768
|
+
* const tree = useTree({ multiple: false, defaultExpanded: ['root'] })
|
|
769
|
+
* ```
|
|
770
|
+
* ```html
|
|
771
|
+
* <Tree
|
|
772
|
+
* :model-value="tree.selected"
|
|
773
|
+
* :expanded="tree.expanded"
|
|
774
|
+
* @update:model-value="tree.onSelectionChange"
|
|
775
|
+
* @update:expanded="tree.onExpandedChange"
|
|
776
|
+
* >
|
|
777
|
+
* ...
|
|
778
|
+
* </Tree>
|
|
779
|
+
* ```
|
|
780
|
+
*/
|
|
781
|
+
function useTree(options = {}) {
|
|
782
|
+
const multiple = options.multiple ?? false;
|
|
783
|
+
const selected = (0, vue.ref)(options.defaultSelected ?? (multiple ? [] : void 0));
|
|
784
|
+
const expanded = (0, vue.ref)(options.defaultExpanded ? [...options.defaultExpanded] : []);
|
|
785
|
+
function isSelected(key) {
|
|
786
|
+
if (Array.isArray(selected.value)) return selected.value.includes(key);
|
|
787
|
+
return selected.value === key;
|
|
788
|
+
}
|
|
789
|
+
function select(key) {
|
|
790
|
+
if (multiple) {
|
|
791
|
+
const current = selected.value ?? [];
|
|
792
|
+
if (!current.includes(key)) selected.value = [...current, key];
|
|
793
|
+
} else selected.value = key;
|
|
794
|
+
}
|
|
795
|
+
function deselect(key) {
|
|
796
|
+
if (multiple) selected.value = (selected.value ?? []).filter((k) => k !== key);
|
|
797
|
+
else if (selected.value === key) selected.value = void 0;
|
|
798
|
+
}
|
|
799
|
+
function toggle(key) {
|
|
800
|
+
if (isSelected(key)) deselect(key);
|
|
801
|
+
else select(key);
|
|
802
|
+
}
|
|
803
|
+
function isExpanded(key) {
|
|
804
|
+
return expanded.value.includes(key);
|
|
805
|
+
}
|
|
806
|
+
function expand(key) {
|
|
807
|
+
if (!isExpanded(key)) expanded.value = [...expanded.value, key];
|
|
808
|
+
}
|
|
809
|
+
function collapse(key) {
|
|
810
|
+
expanded.value = expanded.value.filter((k) => k !== key);
|
|
811
|
+
}
|
|
812
|
+
function toggleExpand(key) {
|
|
813
|
+
if (isExpanded(key)) collapse(key);
|
|
814
|
+
else expand(key);
|
|
815
|
+
}
|
|
816
|
+
function expandAll(keys) {
|
|
817
|
+
expanded.value = [...new Set([...expanded.value, ...keys])];
|
|
818
|
+
}
|
|
819
|
+
function collapseAll() {
|
|
820
|
+
expanded.value = [];
|
|
821
|
+
}
|
|
822
|
+
function onSelectionChange(value) {
|
|
823
|
+
selected.value = value;
|
|
824
|
+
}
|
|
825
|
+
function onExpandedChange(keys) {
|
|
826
|
+
expanded.value = keys;
|
|
827
|
+
}
|
|
828
|
+
return {
|
|
829
|
+
selected,
|
|
830
|
+
expanded,
|
|
831
|
+
isSelected,
|
|
832
|
+
select,
|
|
833
|
+
deselect,
|
|
834
|
+
toggle,
|
|
835
|
+
isExpanded,
|
|
836
|
+
expand,
|
|
837
|
+
collapse,
|
|
838
|
+
toggleExpand,
|
|
839
|
+
expandAll,
|
|
840
|
+
collapseAll,
|
|
841
|
+
onSelectionChange,
|
|
842
|
+
onExpandedChange
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
//#endregion
|
|
846
|
+
//#region src/composables/useSplitter.ts
|
|
847
|
+
/**
|
|
848
|
+
* Tracks panel layout state for the SplitterGroup component.
|
|
849
|
+
*
|
|
850
|
+
* @example
|
|
851
|
+
* ```ts
|
|
852
|
+
* const splitter = useSplitter({ defaultSizes: [30, 70] })
|
|
853
|
+
* ```
|
|
854
|
+
* ```html
|
|
855
|
+
* <SplitterGroup @layout="splitter.onLayout">
|
|
856
|
+
* <SplitterPanel :default-size="splitter.sizes[0] ?? 30" />
|
|
857
|
+
* <SplitterResizeHandle />
|
|
858
|
+
* <SplitterPanel :default-size="splitter.sizes[1] ?? 70" />
|
|
859
|
+
* </SplitterGroup>
|
|
860
|
+
* ```
|
|
861
|
+
*/
|
|
862
|
+
function useSplitter(options = {}) {
|
|
863
|
+
const sizes = (0, vue.ref)(options.defaultSizes ? [...options.defaultSizes] : []);
|
|
864
|
+
function setSizes(next) {
|
|
865
|
+
sizes.value = [...next];
|
|
866
|
+
}
|
|
867
|
+
function resetSizes() {
|
|
868
|
+
sizes.value = options.defaultSizes ? [...options.defaultSizes] : [];
|
|
869
|
+
}
|
|
870
|
+
function onLayout(next) {
|
|
871
|
+
sizes.value = next;
|
|
872
|
+
}
|
|
873
|
+
return {
|
|
874
|
+
sizes,
|
|
875
|
+
setSizes,
|
|
876
|
+
resetSizes,
|
|
877
|
+
onLayout
|
|
878
|
+
};
|
|
879
|
+
}
|
|
880
|
+
//#endregion
|
|
252
881
|
//#region src/utils/composeClassName.ts
|
|
253
882
|
/**
|
|
254
883
|
* Merges Tailwind CSS classes, resolving conflicts via tailwind-merge.
|
|
@@ -31694,6 +32323,120 @@ var ColorPicker_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
31694
32323
|
}
|
|
31695
32324
|
});
|
|
31696
32325
|
//#endregion
|
|
32326
|
+
//#region src/composables/useColorPicker.ts
|
|
32327
|
+
/**
|
|
32328
|
+
* High-level composable for controlling the ColorPicker component.
|
|
32329
|
+
*
|
|
32330
|
+
* Wraps `useColorState` with computed channel accessors and format conversion helpers.
|
|
32331
|
+
*
|
|
32332
|
+
* @example
|
|
32333
|
+
* ```ts
|
|
32334
|
+
* const picker = useColorPicker({ defaultValue: '#3b82f6' })
|
|
32335
|
+
* console.log(picker.hue.value) // 217
|
|
32336
|
+
* console.log(picker.saturation.value) // 91
|
|
32337
|
+
* console.log(picker.brightness.value) // 96
|
|
32338
|
+
* ```
|
|
32339
|
+
* ```html
|
|
32340
|
+
* <ColorPicker v-model="picker.color" />
|
|
32341
|
+
* ```
|
|
32342
|
+
*/
|
|
32343
|
+
function useColorPicker(options = {}) {
|
|
32344
|
+
const state = useColorState({
|
|
32345
|
+
defaultValue: options.defaultValue,
|
|
32346
|
+
format: options.format ?? "hex",
|
|
32347
|
+
onChange: options.onChange
|
|
32348
|
+
});
|
|
32349
|
+
function setColor(value) {
|
|
32350
|
+
const parsed = typeof value === "string" ? (0, reka_ui.parseColor)(value) : value;
|
|
32351
|
+
state.color.value = parsed;
|
|
32352
|
+
options.onChange?.(state.toString(), parsed);
|
|
32353
|
+
}
|
|
32354
|
+
const hue = (0, vue.computed)(() => state.getChannel("hue"));
|
|
32355
|
+
const saturation = (0, vue.computed)(() => state.getChannel("saturation"));
|
|
32356
|
+
const brightness = (0, vue.computed)(() => state.getChannel("brightness"));
|
|
32357
|
+
const alpha = (0, vue.computed)(() => state.getChannel("alpha"));
|
|
32358
|
+
function toHex() {
|
|
32359
|
+
return state.toHex();
|
|
32360
|
+
}
|
|
32361
|
+
function toRgb() {
|
|
32362
|
+
return (0, reka_ui.colorToRgb)(state.color.value).toString();
|
|
32363
|
+
}
|
|
32364
|
+
function toHsl() {
|
|
32365
|
+
return (0, reka_ui.colorToHsl)(state.color.value).toString();
|
|
32366
|
+
}
|
|
32367
|
+
function toHsb() {
|
|
32368
|
+
return (0, reka_ui.colorToHsb)(state.color.value).toString();
|
|
32369
|
+
}
|
|
32370
|
+
function onColorChange(value) {
|
|
32371
|
+
setColor(value);
|
|
32372
|
+
}
|
|
32373
|
+
return {
|
|
32374
|
+
color: state.color,
|
|
32375
|
+
setColor,
|
|
32376
|
+
hue,
|
|
32377
|
+
saturation,
|
|
32378
|
+
brightness,
|
|
32379
|
+
alpha,
|
|
32380
|
+
toHex,
|
|
32381
|
+
toRgb,
|
|
32382
|
+
toHsl,
|
|
32383
|
+
toHsb,
|
|
32384
|
+
onColorChange
|
|
32385
|
+
};
|
|
32386
|
+
}
|
|
32387
|
+
//#endregion
|
|
32388
|
+
//#region src/composables/useOTP.ts
|
|
32389
|
+
function useOTP(options = {}) {
|
|
32390
|
+
const length = options.length ?? 6;
|
|
32391
|
+
const _value = (0, vue.ref)(options.defaultValue ?? "");
|
|
32392
|
+
const isComplete = (0, vue.computed)(() => _value.value.length === length);
|
|
32393
|
+
function reset() {
|
|
32394
|
+
_value.value = "";
|
|
32395
|
+
}
|
|
32396
|
+
function onValueChange(value) {
|
|
32397
|
+
_value.value = value;
|
|
32398
|
+
options.onChange?.(value);
|
|
32399
|
+
}
|
|
32400
|
+
function onOTPComplete(value) {
|
|
32401
|
+
_value.value = value;
|
|
32402
|
+
options.onComplete?.(value);
|
|
32403
|
+
}
|
|
32404
|
+
return {
|
|
32405
|
+
value: (0, vue.readonly)(_value),
|
|
32406
|
+
isComplete,
|
|
32407
|
+
reset,
|
|
32408
|
+
onValueChange,
|
|
32409
|
+
onOTPComplete
|
|
32410
|
+
};
|
|
32411
|
+
}
|
|
32412
|
+
//#endregion
|
|
32413
|
+
//#region src/composables/useSwatchPicker.ts
|
|
32414
|
+
function useSwatchPicker(options = {}) {
|
|
32415
|
+
const _selectedColor = (0, vue.ref)(options.defaultValue ?? "");
|
|
32416
|
+
const hasSelection = (0, vue.computed)(() => _selectedColor.value !== "");
|
|
32417
|
+
function setColor(hex) {
|
|
32418
|
+
_selectedColor.value = hex;
|
|
32419
|
+
options.onChange?.(hex);
|
|
32420
|
+
}
|
|
32421
|
+
function clearSelection() {
|
|
32422
|
+
_selectedColor.value = "";
|
|
32423
|
+
}
|
|
32424
|
+
function isSelected(hex) {
|
|
32425
|
+
return _selectedColor.value === hex;
|
|
32426
|
+
}
|
|
32427
|
+
function onColorChange(hex) {
|
|
32428
|
+
setColor(hex);
|
|
32429
|
+
}
|
|
32430
|
+
return {
|
|
32431
|
+
selectedColor: (0, vue.readonly)(_selectedColor),
|
|
32432
|
+
hasSelection,
|
|
32433
|
+
setColor,
|
|
32434
|
+
clearSelection,
|
|
32435
|
+
isSelected,
|
|
32436
|
+
onColorChange
|
|
32437
|
+
};
|
|
32438
|
+
}
|
|
32439
|
+
//#endregion
|
|
31697
32440
|
exports.Accordion = Accordion_default;
|
|
31698
32441
|
exports.AccordionContent = AccordionContent_default;
|
|
31699
32442
|
exports.AccordionHeader = AccordionHeader_default;
|
|
@@ -31908,32 +32651,48 @@ exports.surfaceContextKey = surfaceContextKey;
|
|
|
31908
32651
|
exports.switchGroupContextKey = switchGroupContextKey;
|
|
31909
32652
|
exports.tableContextKey = tableContextKey;
|
|
31910
32653
|
exports.treeContextKey = treeContextKey;
|
|
32654
|
+
exports.useAccordion = useAccordion;
|
|
31911
32655
|
exports.useAutocompleteInject = useAutocompleteInject;
|
|
31912
32656
|
exports.useAutocompleteProvide = useAutocompleteProvide;
|
|
31913
32657
|
exports.useCSSVariable = useCSSVariable;
|
|
32658
|
+
exports.useCalendar = useCalendar;
|
|
32659
|
+
exports.useCheckboxGroup = useCheckboxGroup;
|
|
31914
32660
|
exports.useCheckboxGroupInject = useCheckboxGroupInject;
|
|
31915
32661
|
exports.useCheckboxGroupProvide = useCheckboxGroupProvide;
|
|
32662
|
+
exports.useColorPicker = useColorPicker;
|
|
31916
32663
|
exports.useColorState = useColorState;
|
|
31917
32664
|
exports.useComboBoxInject = useComboBoxInject;
|
|
31918
32665
|
exports.useComboBoxProvide = useComboBoxProvide;
|
|
32666
|
+
exports.useDisclosure = useDisclosure;
|
|
31919
32667
|
exports.useDropdownInject = useDropdownInject;
|
|
31920
32668
|
exports.useDropdownProvide = useDropdownProvide;
|
|
31921
32669
|
exports.useIsHydrated = useIsHydrated;
|
|
31922
32670
|
exports.useIsMounted = useIsMounted;
|
|
32671
|
+
exports.useListBox = useListBox;
|
|
31923
32672
|
exports.useListData = useListData;
|
|
31924
32673
|
exports.useMeasuredHeight = useMeasuredHeight;
|
|
31925
32674
|
exports.useMediaQuery = useMediaQuery;
|
|
32675
|
+
exports.useOTP = useOTP;
|
|
31926
32676
|
exports.useOverlayState = useOverlayState;
|
|
32677
|
+
exports.usePagination = usePagination;
|
|
31927
32678
|
exports.usePaginationInject = usePaginationInject;
|
|
31928
32679
|
exports.usePaginationProvide = usePaginationProvide;
|
|
32680
|
+
exports.useRadioGroup = useRadioGroup;
|
|
31929
32681
|
exports.useRadioGroupInject = useRadioGroupInject;
|
|
31930
32682
|
exports.useRadioGroupProvide = useRadioGroupProvide;
|
|
32683
|
+
exports.useRangeCalendar = useRangeCalendar;
|
|
32684
|
+
exports.useSlider = useSlider;
|
|
32685
|
+
exports.useSplitter = useSplitter;
|
|
32686
|
+
exports.useStepper = useStepper;
|
|
31931
32687
|
exports.useSurfaceInject = useSurfaceInject;
|
|
32688
|
+
exports.useSwatchPicker = useSwatchPicker;
|
|
31932
32689
|
exports.useSwitchGroupInject = useSwitchGroupInject;
|
|
31933
32690
|
exports.useSwitchGroupProvide = useSwitchGroupProvide;
|
|
31934
32691
|
exports.useTableInject = useTableInject;
|
|
31935
32692
|
exports.useTableKeyboardNav = useTableKeyboardNav;
|
|
31936
32693
|
exports.useTableProvide = useTableProvide;
|
|
32694
|
+
exports.useTabs = useTabs;
|
|
31937
32695
|
exports.useToast = useToast;
|
|
32696
|
+
exports.useTree = useTree;
|
|
31938
32697
|
|
|
31939
32698
|
//# sourceMappingURL=index.cjs.map
|