@auronui/vue 1.1.1 → 1.2.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/dist/cjs/index.cjs +772 -741
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/components/alert-dialog/AlertDialogBody.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/alert-dialog/AlertDialogContent.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/alert-dialog/AlertDialogFooter.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/alert-dialog/AlertDialogHeader.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/alert-dialog/AlertDialogIcon.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/alert-dialog/AlertDialogOverlay.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/alert-dialog/AlertDialogTitle.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/calendar/Calendar.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/components/calendar/Calendar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/date-time-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.js +6 -8
- package/dist/components/date-time-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/date-time-picker/DateTimePickerTimeScroller.vue_vue_type_script_setup_true_lang.js +1 -0
- package/dist/components/date-time-picker/DateTimePickerTimeScroller.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/drawer/Drawer.vue_vue_type_script_lang.js +1 -1
- package/dist/components/drawer/DrawerBody.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/drawer/DrawerClose.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/drawer/DrawerContent.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/drawer/DrawerFooter.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/drawer/DrawerHeader.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/drawer/DrawerMain.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/drawer/DrawerOverlay.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/drawer/DrawerTitle.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/modal/ModalBody.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/modal/ModalClose.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/modal/ModalContent.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/modal/ModalFooter.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/modal/ModalHeader.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/modal/ModalOverlay.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/modal/ModalTitle.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/popover/PopoverContent.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/range-calendar/RangeCalendar.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/components/range-calendar/RangeCalendar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/tooltip/TooltipArrow.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/tooltip/TooltipContent.vue_vue_type_script_setup_true_lang.js +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 +939 -217
- package/dist/index.js +17 -1
- package/dist/packages/styles/{src → dist}/components/alert-dialog/alert-dialog.styles.js +1 -1
- package/dist/packages/styles/dist/components/alert-dialog/alert-dialog.styles.js.map +1 -0
- package/dist/packages/styles/{src → dist}/components/drawer/drawer.styles.js +1 -1
- package/dist/packages/styles/dist/components/drawer/drawer.styles.js.map +1 -0
- package/dist/packages/styles/{src → dist}/components/modal/modal.styles.js +1 -1
- package/dist/packages/styles/dist/components/modal/modal.styles.js.map +1 -0
- package/dist/packages/styles/{src → dist}/components/popover/popover.styles.js +1 -1
- package/dist/packages/styles/dist/components/popover/popover.styles.js.map +1 -0
- package/dist/packages/styles/{src → dist}/components/tooltip/tooltip.styles.js +1 -1
- package/dist/packages/styles/dist/components/tooltip/tooltip.styles.js.map +1 -0
- package/package.json +5 -4
- package/dist/node_modules/.pnpm/@internationalized_date@3.12.1/node_modules/@internationalized/date/dist/private/CalendarDate.js +0 -172
- package/dist/node_modules/.pnpm/@internationalized_date@3.12.1/node_modules/@internationalized/date/dist/private/CalendarDate.js.map +0 -1
- package/dist/node_modules/.pnpm/@internationalized_date@3.12.1/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.js +0 -116
- package/dist/node_modules/.pnpm/@internationalized_date@3.12.1/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.js.map +0 -1
- package/dist/node_modules/.pnpm/@internationalized_date@3.12.1/node_modules/@internationalized/date/dist/private/conversion.js +0 -142
- package/dist/node_modules/.pnpm/@internationalized_date@3.12.1/node_modules/@internationalized/date/dist/private/conversion.js.map +0 -1
- package/dist/node_modules/.pnpm/@internationalized_date@3.12.1/node_modules/@internationalized/date/dist/private/manipulation.js +0 -264
- package/dist/node_modules/.pnpm/@internationalized_date@3.12.1/node_modules/@internationalized/date/dist/private/manipulation.js.map +0 -1
- package/dist/node_modules/.pnpm/@internationalized_date@3.12.1/node_modules/@internationalized/date/dist/private/queries.js +0 -33
- package/dist/node_modules/.pnpm/@internationalized_date@3.12.1/node_modules/@internationalized/date/dist/private/queries.js.map +0 -1
- package/dist/node_modules/.pnpm/@internationalized_date@3.12.1/node_modules/@internationalized/date/dist/private/string.js +0 -32
- package/dist/node_modules/.pnpm/@internationalized_date@3.12.1/node_modules/@internationalized/date/dist/private/string.js.map +0 -1
- package/dist/node_modules/.pnpm/@internationalized_date@3.12.1/node_modules/@internationalized/date/dist/private/utils.js +0 -8
- package/dist/node_modules/.pnpm/@internationalized_date@3.12.1/node_modules/@internationalized/date/dist/private/utils.js.map +0 -1
- package/dist/packages/styles/src/components/alert-dialog/alert-dialog.styles.js.map +0 -1
- package/dist/packages/styles/src/components/drawer/drawer.styles.js.map +0 -1
- package/dist/packages/styles/src/components/modal/modal.styles.js.map +0 -1
- package/dist/packages/styles/src/components/popover/popover.styles.js.map +0 -1
- package/dist/packages/styles/src/components/tooltip/tooltip.styles.js.map +0 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { computed, ref } from "vue";
|
|
2
|
+
//#region src/composables/usePagination.ts
|
|
3
|
+
/**
|
|
4
|
+
* Manages pagination state for the Pagination component.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const pagination = usePagination({ totalItems: 200, pageSize: 20 })
|
|
9
|
+
* ```
|
|
10
|
+
* ```html
|
|
11
|
+
* <Pagination
|
|
12
|
+
* :page="pagination.page"
|
|
13
|
+
* :total-items="pagination.totalItems"
|
|
14
|
+
* :items-per-page="pagination.pageSize"
|
|
15
|
+
* @update:page="pagination.onPageChange"
|
|
16
|
+
* />
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
function usePagination(options = {}) {
|
|
20
|
+
const page = ref(options.defaultPage ?? 1);
|
|
21
|
+
const pageSize = ref(options.pageSize ?? 10);
|
|
22
|
+
const totalItems = ref(options.totalItems ?? 0);
|
|
23
|
+
const totalPages = computed(() => Math.max(1, Math.ceil(totalItems.value / pageSize.value)));
|
|
24
|
+
const isFirst = computed(() => page.value <= 1);
|
|
25
|
+
const isLast = computed(() => page.value >= totalPages.value);
|
|
26
|
+
function goToPage(p) {
|
|
27
|
+
page.value = Math.max(1, Math.min(p, totalPages.value));
|
|
28
|
+
}
|
|
29
|
+
function nextPage() {
|
|
30
|
+
if (!isLast.value) goToPage(page.value + 1);
|
|
31
|
+
}
|
|
32
|
+
function prevPage() {
|
|
33
|
+
if (!isFirst.value) goToPage(page.value - 1);
|
|
34
|
+
}
|
|
35
|
+
function onPageChange(p) {
|
|
36
|
+
goToPage(p);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
page,
|
|
40
|
+
pageSize,
|
|
41
|
+
totalItems,
|
|
42
|
+
totalPages,
|
|
43
|
+
isFirst,
|
|
44
|
+
isLast,
|
|
45
|
+
goToPage,
|
|
46
|
+
nextPage,
|
|
47
|
+
prevPage,
|
|
48
|
+
onPageChange
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { usePagination };
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=usePagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePagination.js","names":[],"sources":["../../src/composables/usePagination.ts"],"sourcesContent":["import { ref, computed, type Ref, type ComputedRef } from 'vue'\n\nexport interface UsePaginationOptions {\n /** Total number of items across all pages. */\n totalItems?: number\n /** Number of items per page. Defaults to 10. */\n pageSize?: number\n /** Initial page for uncontrolled usage. Defaults to 1. */\n defaultPage?: number\n}\n\nexport interface UsePaginationReturn {\n /** Reactive current page number (1-based). */\n page: Ref<number>\n /** Reactive number of items per page. */\n pageSize: Ref<number>\n /** Reactive total item count. */\n totalItems: Ref<number>\n /** Computed total number of pages. Minimum 1. */\n totalPages: ComputedRef<number>\n /** Whether the current page is the first page. */\n isFirst: ComputedRef<boolean>\n /** Whether the current page is the last page. */\n isLast: ComputedRef<boolean>\n /** Navigate to a specific page number. Clamps to valid range. */\n goToPage: (page: number) => void\n /** Navigate to the next page. No-op on last page. */\n nextPage: () => void\n /** Navigate to the previous page. No-op on first page. */\n prevPage: () => void\n /**\n * Pass as `@update:page` handler on the Pagination component.\n * Keeps `page` in sync when the component navigates internally.\n */\n onPageChange: (page: number) => void\n}\n\n/**\n * Manages pagination state for the Pagination component.\n *\n * @example\n * ```ts\n * const pagination = usePagination({ totalItems: 200, pageSize: 20 })\n * ```\n * ```html\n * <Pagination\n * :page=\"pagination.page\"\n * :total-items=\"pagination.totalItems\"\n * :items-per-page=\"pagination.pageSize\"\n * @update:page=\"pagination.onPageChange\"\n * />\n * ```\n */\nexport function usePagination(options: UsePaginationOptions = {}): UsePaginationReturn {\n const page = ref(options.defaultPage ?? 1)\n const pageSize = ref(options.pageSize ?? 10)\n const totalItems = ref(options.totalItems ?? 0)\n\n const totalPages = computed(() =>\n Math.max(1, Math.ceil(totalItems.value / pageSize.value))\n )\n\n const isFirst = computed(() => page.value <= 1)\n const isLast = computed(() => page.value >= totalPages.value)\n\n function goToPage(p: number): void {\n page.value = Math.max(1, Math.min(p, totalPages.value))\n }\n\n function nextPage(): void {\n if (!isLast.value) goToPage(page.value + 1)\n }\n\n function prevPage(): void {\n if (!isFirst.value) goToPage(page.value - 1)\n }\n\n function onPageChange(p: number): void {\n goToPage(p)\n }\n\n return {\n page,\n pageSize,\n totalItems,\n totalPages,\n isFirst,\n isLast,\n goToPage,\n nextPage,\n prevPage,\n onPageChange,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqDA,SAAgB,cAAc,UAAgC,EAAE,EAAuB;CACrF,MAAM,OAAO,IAAI,QAAQ,eAAe,EAAE;CAC1C,MAAM,WAAW,IAAI,QAAQ,YAAY,GAAG;CAC5C,MAAM,aAAa,IAAI,QAAQ,cAAc,EAAE;CAE/C,MAAM,aAAa,eACjB,KAAK,IAAI,GAAG,KAAK,KAAK,WAAW,QAAQ,SAAS,MAAM,CAAC,CAC1D;CAED,MAAM,UAAU,eAAe,KAAK,SAAS,EAAE;CAC/C,MAAM,SAAS,eAAe,KAAK,SAAS,WAAW,MAAM;CAE7D,SAAS,SAAS,GAAiB;AACjC,OAAK,QAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,WAAW,MAAM,CAAC;;CAGzD,SAAS,WAAiB;AACxB,MAAI,CAAC,OAAO,MAAO,UAAS,KAAK,QAAQ,EAAE;;CAG7C,SAAS,WAAiB;AACxB,MAAI,CAAC,QAAQ,MAAO,UAAS,KAAK,QAAQ,EAAE;;CAG9C,SAAS,aAAa,GAAiB;AACrC,WAAS,EAAE;;AAGb,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
//#region src/composables/useRadioGroup.ts
|
|
3
|
+
/**
|
|
4
|
+
* Manages selection state for the RadioGroup component.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const radio = useRadioGroup({ defaultValue: 'option-a' })
|
|
9
|
+
* ```
|
|
10
|
+
* ```html
|
|
11
|
+
* <RadioGroup :model-value="radio.value" @update:model-value="radio.onValueChange">
|
|
12
|
+
* <Radio value="option-a">Option A</Radio>
|
|
13
|
+
* <Radio value="option-b">Option B</Radio>
|
|
14
|
+
* </RadioGroup>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
function useRadioGroup(options = {}) {
|
|
18
|
+
const value = ref(options.defaultValue);
|
|
19
|
+
function setValue(v) {
|
|
20
|
+
value.value = v;
|
|
21
|
+
}
|
|
22
|
+
function clear() {
|
|
23
|
+
value.value = void 0;
|
|
24
|
+
}
|
|
25
|
+
function onValueChange(v) {
|
|
26
|
+
value.value = v;
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
value,
|
|
30
|
+
setValue,
|
|
31
|
+
clear,
|
|
32
|
+
onValueChange
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { useRadioGroup };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=useRadioGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRadioGroup.js","names":[],"sources":["../../src/composables/useRadioGroup.ts"],"sourcesContent":["import { ref, type Ref } from 'vue'\n\nexport interface UseRadioGroupOptions {\n /** Initial selected value. */\n defaultValue?: string\n}\n\nexport interface UseRadioGroupReturn {\n /** Reactive selected radio value. */\n value: Ref<string | undefined>\n /** Set the selected value. */\n setValue: (value: string) => void\n /** Clear the selection. */\n clear: () => void\n /**\n * Pass as `@update:model-value` handler on the RadioGroup component.\n * Keeps `value` in sync when the component changes selection internally.\n */\n onValueChange: (value: string) => void\n}\n\n/**\n * Manages selection state for the RadioGroup component.\n *\n * @example\n * ```ts\n * const radio = useRadioGroup({ defaultValue: 'option-a' })\n * ```\n * ```html\n * <RadioGroup :model-value=\"radio.value\" @update:model-value=\"radio.onValueChange\">\n * <Radio value=\"option-a\">Option A</Radio>\n * <Radio value=\"option-b\">Option B</Radio>\n * </RadioGroup>\n * ```\n */\nexport function useRadioGroup(options: UseRadioGroupOptions = {}): UseRadioGroupReturn {\n const value = ref<string | undefined>(options.defaultValue)\n\n function setValue(v: string): void {\n value.value = v\n }\n\n function clear(): void {\n value.value = undefined\n }\n\n function onValueChange(v: string): void {\n value.value = v\n }\n\n return {\n value,\n setValue,\n clear,\n onValueChange,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmCA,SAAgB,cAAc,UAAgC,EAAE,EAAuB;CACrF,MAAM,QAAQ,IAAwB,QAAQ,aAAa;CAE3D,SAAS,SAAS,GAAiB;AACjC,QAAM,QAAQ;;CAGhB,SAAS,QAAc;AACrB,QAAM,QAAQ,KAAA;;CAGhB,SAAS,cAAc,GAAiB;AACtC,QAAM,QAAQ;;AAGhB,QAAO;EACL;EACA;EACA;EACA;EACD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { computed, shallowRef } from "vue";
|
|
2
|
+
//#region src/composables/useRangeCalendar.ts
|
|
3
|
+
/**
|
|
4
|
+
* Manages selected date range state for the RangeCalendar component.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const range = useRangeCalendar()
|
|
9
|
+
* ```
|
|
10
|
+
* ```html
|
|
11
|
+
* <RangeCalendar v-model="range.value" />
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
function useRangeCalendar(options = {}) {
|
|
15
|
+
const value = shallowRef(options.defaultValue ?? null);
|
|
16
|
+
const start = computed(() => value.value?.start ?? null);
|
|
17
|
+
const end = computed(() => value.value?.end ?? null);
|
|
18
|
+
const isComplete = computed(() => value.value !== null && !!value.value?.start && !!value.value?.end);
|
|
19
|
+
function setRange(range) {
|
|
20
|
+
value.value = range;
|
|
21
|
+
}
|
|
22
|
+
function clearRange() {
|
|
23
|
+
value.value = null;
|
|
24
|
+
}
|
|
25
|
+
function isDisabled(date) {
|
|
26
|
+
if (options.minValue && date.compare(options.minValue) < 0) return true;
|
|
27
|
+
if (options.maxValue && date.compare(options.maxValue) > 0) return true;
|
|
28
|
+
return options.isDateDisabled?.(date) ?? false;
|
|
29
|
+
}
|
|
30
|
+
function isUnavailable(date) {
|
|
31
|
+
return options.isDateUnavailable?.(date) ?? false;
|
|
32
|
+
}
|
|
33
|
+
function onValueChange(range) {
|
|
34
|
+
value.value = range;
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
value,
|
|
38
|
+
start,
|
|
39
|
+
end,
|
|
40
|
+
isComplete,
|
|
41
|
+
setRange,
|
|
42
|
+
clearRange,
|
|
43
|
+
isDisabled,
|
|
44
|
+
isUnavailable,
|
|
45
|
+
onValueChange
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { useRangeCalendar };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=useRangeCalendar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRangeCalendar.js","names":[],"sources":["../../src/composables/useRangeCalendar.ts"],"sourcesContent":["import { shallowRef, computed, type Ref, type ComputedRef } from 'vue'\nimport type { DateValue } from '@internationalized/date'\n\nexport interface DateRange {\n start: DateValue\n end: DateValue\n}\n\nexport interface UseRangeCalendarOptions {\n /** Initial selected date range for uncontrolled usage. */\n defaultValue?: DateRange | null\n /** Minimum selectable date. */\n minValue?: DateValue\n /** Maximum selectable date. */\n maxValue?: DateValue\n /** Returns true for dates that should be disabled. */\n isDateDisabled?: (date: DateValue) => boolean\n /** Returns true for dates that are unavailable. */\n isDateUnavailable?: (date: DateValue) => boolean\n}\n\nexport interface UseRangeCalendarReturn {\n /** Reactive selected date range (null when no selection). */\n value: Ref<DateRange | null>\n /** Reactive start date of the selected range. */\n start: ComputedRef<DateValue | null>\n /** Reactive end date of the selected range. */\n end: ComputedRef<DateValue | null>\n /** Whether a complete range (start and end) is selected. */\n isComplete: ComputedRef<boolean>\n /** Set the selected date range. */\n setRange: (range: DateRange) => void\n /** Clear the selected range. */\n clearRange: () => void\n /** Returns true if the given date is disabled per the `isDateDisabled` option. */\n isDisabled: (date: DateValue) => boolean\n /** Returns true if the given date is unavailable per the `isDateUnavailable` option. */\n isUnavailable: (date: DateValue) => boolean\n /**\n * Pass as `v-model` on the RangeCalendar component.\n * Keeps `value` in sync when the component changes selection internally.\n */\n onValueChange: (range: DateRange | null) => void\n}\n\n/**\n * Manages selected date range state for the RangeCalendar component.\n *\n * @example\n * ```ts\n * const range = useRangeCalendar()\n * ```\n * ```html\n * <RangeCalendar v-model=\"range.value\" />\n * ```\n */\nexport function useRangeCalendar(options: UseRangeCalendarOptions = {}): UseRangeCalendarReturn {\n const value = shallowRef<DateRange | null>(options.defaultValue ?? null)\n\n const start = computed(() => value.value?.start ?? null)\n const end = computed(() => value.value?.end ?? null)\n\n const isComplete = computed(\n () => value.value !== null && !!value.value?.start && !!value.value?.end\n )\n\n function setRange(range: DateRange): void {\n value.value = range\n }\n\n function clearRange(): void {\n value.value = null\n }\n\n function isDisabled(date: DateValue): boolean {\n if (options.minValue && date.compare(options.minValue) < 0) return true\n if (options.maxValue && date.compare(options.maxValue) > 0) return true\n return options.isDateDisabled?.(date) ?? false\n }\n\n function isUnavailable(date: DateValue): boolean {\n return options.isDateUnavailable?.(date) ?? false\n }\n\n function onValueChange(range: DateRange | null): void {\n value.value = range\n }\n\n return {\n value,\n start,\n end,\n isComplete,\n setRange,\n clearRange,\n isDisabled,\n isUnavailable,\n onValueChange,\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAwDA,SAAgB,iBAAiB,UAAmC,EAAE,EAA0B;CAC9F,MAAM,QAAQ,WAA6B,QAAQ,gBAAgB,KAAK;CAExE,MAAM,QAAQ,eAAe,MAAM,OAAO,SAAS,KAAK;CACxD,MAAM,MAAM,eAAe,MAAM,OAAO,OAAO,KAAK;CAEpD,MAAM,aAAa,eACX,MAAM,UAAU,QAAQ,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,IACtE;CAED,SAAS,SAAS,OAAwB;AACxC,QAAM,QAAQ;;CAGhB,SAAS,aAAmB;AAC1B,QAAM,QAAQ;;CAGhB,SAAS,WAAW,MAA0B;AAC5C,MAAI,QAAQ,YAAY,KAAK,QAAQ,QAAQ,SAAS,GAAG,EAAG,QAAO;AACnE,MAAI,QAAQ,YAAY,KAAK,QAAQ,QAAQ,SAAS,GAAG,EAAG,QAAO;AACnE,SAAO,QAAQ,iBAAiB,KAAK,IAAI;;CAG3C,SAAS,cAAc,MAA0B;AAC/C,SAAO,QAAQ,oBAAoB,KAAK,IAAI;;CAG9C,SAAS,cAAc,OAA+B;AACpD,QAAM,QAAQ;;AAGhB,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
//#region src/composables/useSlider.ts
|
|
3
|
+
/**
|
|
4
|
+
* Manages value state for the Slider component.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* // Single thumb
|
|
9
|
+
* const slider = useSlider({ defaultValue: 40, min: 0, max: 100 })
|
|
10
|
+
*
|
|
11
|
+
* // Range (two thumbs)
|
|
12
|
+
* const range = useSlider({ defaultValue: [20, 80], min: 0, max: 100 })
|
|
13
|
+
* ```
|
|
14
|
+
* ```html
|
|
15
|
+
* <Slider :model-value="slider.value" :min="slider.min" :max="slider.max" @update:model-value="slider.onValueChange" />
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
function useSlider(options = {}) {
|
|
19
|
+
const min = options.min ?? 0;
|
|
20
|
+
const max = options.max ?? 100;
|
|
21
|
+
const step = options.step ?? 1;
|
|
22
|
+
const value = ref(options.defaultValue ?? min);
|
|
23
|
+
function clamp(v) {
|
|
24
|
+
if (Array.isArray(v)) return v.map((n) => Math.min(Math.max(n, min), max));
|
|
25
|
+
return Math.min(Math.max(v, min), max);
|
|
26
|
+
}
|
|
27
|
+
function setValue(v) {
|
|
28
|
+
value.value = v;
|
|
29
|
+
}
|
|
30
|
+
function onValueChange(v) {
|
|
31
|
+
value.value = v;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
value,
|
|
35
|
+
min,
|
|
36
|
+
max,
|
|
37
|
+
step,
|
|
38
|
+
setValue,
|
|
39
|
+
clamp,
|
|
40
|
+
onValueChange
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { useSlider };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=useSlider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSlider.js","names":[],"sources":["../../src/composables/useSlider.ts"],"sourcesContent":["import { ref, type Ref } from 'vue'\n\nexport type SliderValue = number | number[]\n\nexport interface UseSliderOptions {\n /** Initial value. Use a number for a single thumb, number[] for range mode. Defaults to `min`. */\n defaultValue?: SliderValue\n /** Minimum allowed value. Defaults to 0. */\n min?: number\n /** Maximum allowed value. Defaults to 100. */\n max?: number\n /** Step increment. Defaults to 1. */\n step?: number\n}\n\nexport interface UseSliderReturn {\n /** Reactive slider value. Number in single mode, number[] in range mode. */\n value: Ref<SliderValue>\n /** Minimum value. */\n min: number\n /** Maximum value. */\n max: number\n /** Step increment. */\n step: number\n /** Set the slider value directly. */\n setValue: (value: SliderValue) => void\n /** Clamp a value (or array of values) to [min, max]. */\n clamp: (value: SliderValue) => SliderValue\n /**\n * Pass as `@update:model-value` handler on the Slider component.\n * Keeps `value` in sync when the component changes internally.\n */\n onValueChange: (value: SliderValue) => void\n}\n\n/**\n * Manages value state for the Slider component.\n *\n * @example\n * ```ts\n * // Single thumb\n * const slider = useSlider({ defaultValue: 40, min: 0, max: 100 })\n *\n * // Range (two thumbs)\n * const range = useSlider({ defaultValue: [20, 80], min: 0, max: 100 })\n * ```\n * ```html\n * <Slider :model-value=\"slider.value\" :min=\"slider.min\" :max=\"slider.max\" @update:model-value=\"slider.onValueChange\" />\n * ```\n */\nexport function useSlider(options: UseSliderOptions = {}): UseSliderReturn {\n const min = options.min ?? 0\n const max = options.max ?? 100\n const step = options.step ?? 1\n\n const value = ref<SliderValue>(options.defaultValue ?? min)\n\n function clamp(v: SliderValue): SliderValue {\n if (Array.isArray(v)) return v.map(n => Math.min(Math.max(n, min), max))\n return Math.min(Math.max(v, min), max)\n }\n\n function setValue(v: SliderValue): void {\n value.value = v\n }\n\n function onValueChange(v: SliderValue): void {\n value.value = v\n }\n\n return {\n value,\n min,\n max,\n step,\n setValue,\n clamp,\n onValueChange,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkDA,SAAgB,UAAU,UAA4B,EAAE,EAAmB;CACzE,MAAM,MAAM,QAAQ,OAAO;CAC3B,MAAM,MAAM,QAAQ,OAAO;CAC3B,MAAM,OAAO,QAAQ,QAAQ;CAE7B,MAAM,QAAQ,IAAiB,QAAQ,gBAAgB,IAAI;CAE3D,SAAS,MAAM,GAA6B;AAC1C,MAAI,MAAM,QAAQ,EAAE,CAAE,QAAO,EAAE,KAAI,MAAK,KAAK,IAAI,KAAK,IAAI,GAAG,IAAI,EAAE,IAAI,CAAC;AACxE,SAAO,KAAK,IAAI,KAAK,IAAI,GAAG,IAAI,EAAE,IAAI;;CAGxC,SAAS,SAAS,GAAsB;AACtC,QAAM,QAAQ;;CAGhB,SAAS,cAAc,GAAsB;AAC3C,QAAM,QAAQ;;AAGhB,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
//#region src/composables/useSplitter.ts
|
|
3
|
+
/**
|
|
4
|
+
* Tracks panel layout state for the SplitterGroup component.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const splitter = useSplitter({ defaultSizes: [30, 70] })
|
|
9
|
+
* ```
|
|
10
|
+
* ```html
|
|
11
|
+
* <SplitterGroup @layout="splitter.onLayout">
|
|
12
|
+
* <SplitterPanel :default-size="splitter.sizes[0] ?? 30" />
|
|
13
|
+
* <SplitterResizeHandle />
|
|
14
|
+
* <SplitterPanel :default-size="splitter.sizes[1] ?? 70" />
|
|
15
|
+
* </SplitterGroup>
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
function useSplitter(options = {}) {
|
|
19
|
+
const sizes = ref(options.defaultSizes ? [...options.defaultSizes] : []);
|
|
20
|
+
function setSizes(next) {
|
|
21
|
+
sizes.value = [...next];
|
|
22
|
+
}
|
|
23
|
+
function resetSizes() {
|
|
24
|
+
sizes.value = options.defaultSizes ? [...options.defaultSizes] : [];
|
|
25
|
+
}
|
|
26
|
+
function onLayout(next) {
|
|
27
|
+
sizes.value = next;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
sizes,
|
|
31
|
+
setSizes,
|
|
32
|
+
resetSizes,
|
|
33
|
+
onLayout
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { useSplitter };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=useSplitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSplitter.js","names":[],"sources":["../../src/composables/useSplitter.ts"],"sourcesContent":["import { ref, type Ref } from 'vue'\n\nexport interface UseSplitterOptions {\n /** Initial panel sizes as percentages (0–100). Should sum to 100. */\n defaultSizes?: number[]\n}\n\nexport interface UseSplitterReturn {\n /** Reactive array of panel sizes as percentages. */\n sizes: Ref<number[]>\n /** Set panel sizes directly. */\n setSizes: (sizes: number[]) => void\n /** Reset panel sizes to the values provided in `defaultSizes`. */\n resetSizes: () => void\n /**\n * Pass as `@layout` handler on the SplitterGroup component.\n * Keeps `sizes` in sync when the user drags the resize handle.\n */\n onLayout: (sizes: number[]) => void\n}\n\n/**\n * Tracks panel layout state for the SplitterGroup component.\n *\n * @example\n * ```ts\n * const splitter = useSplitter({ defaultSizes: [30, 70] })\n * ```\n * ```html\n * <SplitterGroup @layout=\"splitter.onLayout\">\n * <SplitterPanel :default-size=\"splitter.sizes[0] ?? 30\" />\n * <SplitterResizeHandle />\n * <SplitterPanel :default-size=\"splitter.sizes[1] ?? 70\" />\n * </SplitterGroup>\n * ```\n */\nexport function useSplitter(options: UseSplitterOptions = {}): UseSplitterReturn {\n const sizes = ref<number[]>(options.defaultSizes ? [...options.defaultSizes] : [])\n\n function setSizes(next: number[]): void {\n sizes.value = [...next]\n }\n\n function resetSizes(): void {\n sizes.value = options.defaultSizes ? [...options.defaultSizes] : []\n }\n\n function onLayout(next: number[]): void {\n sizes.value = next\n }\n\n return {\n sizes,\n setSizes,\n resetSizes,\n onLayout,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,SAAgB,YAAY,UAA8B,EAAE,EAAqB;CAC/E,MAAM,QAAQ,IAAc,QAAQ,eAAe,CAAC,GAAG,QAAQ,aAAa,GAAG,EAAE,CAAC;CAElF,SAAS,SAAS,MAAsB;AACtC,QAAM,QAAQ,CAAC,GAAG,KAAK;;CAGzB,SAAS,aAAmB;AAC1B,QAAM,QAAQ,QAAQ,eAAe,CAAC,GAAG,QAAQ,aAAa,GAAG,EAAE;;CAGrE,SAAS,SAAS,MAAsB;AACtC,QAAM,QAAQ;;AAGhB,QAAO;EACL;EACA;EACA;EACA;EACD"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { computed, ref } from "vue";
|
|
2
|
+
//#region src/composables/useStepper.ts
|
|
3
|
+
/**
|
|
4
|
+
* Manages step navigation state for the Stepper component.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const stepper = useStepper({ totalSteps: 4 })
|
|
9
|
+
* ```
|
|
10
|
+
* ```html
|
|
11
|
+
* <Stepper :model-value="stepper.step" :total-steps="stepper.totalSteps" @update:model-value="stepper.onStepChange">
|
|
12
|
+
* ...
|
|
13
|
+
* </Stepper>
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
function useStepper(options = {}) {
|
|
17
|
+
const step = ref(options.defaultStep ?? 1);
|
|
18
|
+
const totalSteps = computed(() => options.steps ? options.steps.length : options.totalSteps ?? 0);
|
|
19
|
+
const isFirst = computed(() => step.value <= 1);
|
|
20
|
+
const isLast = computed(() => totalSteps.value > 0 && step.value >= totalSteps.value);
|
|
21
|
+
function goToStep(n) {
|
|
22
|
+
const max = totalSteps.value || Infinity;
|
|
23
|
+
step.value = Math.max(1, Math.min(n, max));
|
|
24
|
+
}
|
|
25
|
+
function nextStep() {
|
|
26
|
+
if (!isLast.value) goToStep(step.value + 1);
|
|
27
|
+
}
|
|
28
|
+
function prevStep() {
|
|
29
|
+
if (!isFirst.value) goToStep(step.value - 1);
|
|
30
|
+
}
|
|
31
|
+
function reset() {
|
|
32
|
+
goToStep(1);
|
|
33
|
+
}
|
|
34
|
+
function getStepStatus(n) {
|
|
35
|
+
if (n < step.value) return "completed";
|
|
36
|
+
if (n === step.value) return "current";
|
|
37
|
+
return "pending";
|
|
38
|
+
}
|
|
39
|
+
function onStepChange(n) {
|
|
40
|
+
goToStep(n);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
step,
|
|
44
|
+
totalSteps,
|
|
45
|
+
isFirst,
|
|
46
|
+
isLast,
|
|
47
|
+
goToStep,
|
|
48
|
+
nextStep,
|
|
49
|
+
prevStep,
|
|
50
|
+
reset,
|
|
51
|
+
getStepStatus,
|
|
52
|
+
onStepChange
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { useStepper };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=useStepper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStepper.js","names":[],"sources":["../../src/composables/useStepper.ts"],"sourcesContent":["import { ref, computed, type Ref, type ComputedRef } from 'vue'\n\nexport type StepStatus = 'completed' | 'current' | 'pending'\n\nexport interface UseStepperOptions {\n /** Total number of steps. Ignored when `steps` array is provided. */\n totalSteps?: number\n /** Step items — `totalSteps` is derived from `steps.length` when provided. */\n steps?: unknown[]\n /** Initial step for uncontrolled usage. Defaults to 1. */\n defaultStep?: number\n}\n\nexport interface UseStepperReturn {\n /** Reactive current step (1-based). */\n step: Ref<number>\n /** Total number of steps. */\n totalSteps: ComputedRef<number>\n /** Whether the stepper is on the first step. */\n isFirst: ComputedRef<boolean>\n /** Whether the stepper is on the last step. */\n isLast: ComputedRef<boolean>\n /** Navigate to a specific step number. Clamps to valid range. */\n goToStep: (step: number) => void\n /** Advance to the next step. No-op on the last step. */\n nextStep: () => void\n /** Go back to the previous step. No-op on the first step. */\n prevStep: () => void\n /** Return to the first step. */\n reset: () => void\n /** Returns the display status for a given step number. */\n getStepStatus: (step: number) => StepStatus\n /**\n * Pass as `@update:model-value` handler on the Stepper component.\n * Keeps `step` in sync when the component changes step internally.\n */\n onStepChange: (step: number) => void\n}\n\n/**\n * Manages step navigation state for the Stepper component.\n *\n * @example\n * ```ts\n * const stepper = useStepper({ totalSteps: 4 })\n * ```\n * ```html\n * <Stepper :model-value=\"stepper.step\" :total-steps=\"stepper.totalSteps\" @update:model-value=\"stepper.onStepChange\">\n * ...\n * </Stepper>\n * ```\n */\nexport function useStepper(options: UseStepperOptions = {}): UseStepperReturn {\n const step = ref(options.defaultStep ?? 1)\n\n const totalSteps = computed(() =>\n options.steps ? options.steps.length : (options.totalSteps ?? 0)\n )\n\n const isFirst = computed(() => step.value <= 1)\n const isLast = computed(() => totalSteps.value > 0 && step.value >= totalSteps.value)\n\n function goToStep(n: number): void {\n const max = totalSteps.value || Infinity\n step.value = Math.max(1, Math.min(n, max))\n }\n\n function nextStep(): void {\n if (!isLast.value) goToStep(step.value + 1)\n }\n\n function prevStep(): void {\n if (!isFirst.value) goToStep(step.value - 1)\n }\n\n function reset(): void {\n goToStep(1)\n }\n\n function getStepStatus(n: number): StepStatus {\n if (n < step.value) return 'completed'\n if (n === step.value) return 'current'\n return 'pending'\n }\n\n function onStepChange(n: number): void {\n goToStep(n)\n }\n\n return {\n step,\n totalSteps,\n isFirst,\n isLast,\n goToStep,\n nextStep,\n prevStep,\n reset,\n getStepStatus,\n onStepChange,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoDA,SAAgB,WAAW,UAA6B,EAAE,EAAoB;CAC5E,MAAM,OAAO,IAAI,QAAQ,eAAe,EAAE;CAE1C,MAAM,aAAa,eACjB,QAAQ,QAAQ,QAAQ,MAAM,SAAU,QAAQ,cAAc,EAC/D;CAED,MAAM,UAAU,eAAe,KAAK,SAAS,EAAE;CAC/C,MAAM,SAAS,eAAe,WAAW,QAAQ,KAAK,KAAK,SAAS,WAAW,MAAM;CAErF,SAAS,SAAS,GAAiB;EACjC,MAAM,MAAM,WAAW,SAAS;AAChC,OAAK,QAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,IAAI,CAAC;;CAG5C,SAAS,WAAiB;AACxB,MAAI,CAAC,OAAO,MAAO,UAAS,KAAK,QAAQ,EAAE;;CAG7C,SAAS,WAAiB;AACxB,MAAI,CAAC,QAAQ,MAAO,UAAS,KAAK,QAAQ,EAAE;;CAG9C,SAAS,QAAc;AACrB,WAAS,EAAE;;CAGb,SAAS,cAAc,GAAuB;AAC5C,MAAI,IAAI,KAAK,MAAO,QAAO;AAC3B,MAAI,MAAM,KAAK,MAAO,QAAO;AAC7B,SAAO;;CAGT,SAAS,aAAa,GAAiB;AACrC,WAAS,EAAE;;AAGb,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { computed, readonly, ref } from "vue";
|
|
2
|
+
//#region src/composables/useSwatchPicker.ts
|
|
3
|
+
function useSwatchPicker(options = {}) {
|
|
4
|
+
const _selectedColor = ref(options.defaultValue ?? "");
|
|
5
|
+
const hasSelection = computed(() => _selectedColor.value !== "");
|
|
6
|
+
function setColor(hex) {
|
|
7
|
+
_selectedColor.value = hex;
|
|
8
|
+
options.onChange?.(hex);
|
|
9
|
+
}
|
|
10
|
+
function clearSelection() {
|
|
11
|
+
_selectedColor.value = "";
|
|
12
|
+
}
|
|
13
|
+
function isSelected(hex) {
|
|
14
|
+
return _selectedColor.value === hex;
|
|
15
|
+
}
|
|
16
|
+
function onColorChange(hex) {
|
|
17
|
+
setColor(hex);
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
selectedColor: readonly(_selectedColor),
|
|
21
|
+
hasSelection,
|
|
22
|
+
setColor,
|
|
23
|
+
clearSelection,
|
|
24
|
+
isSelected,
|
|
25
|
+
onColorChange
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { useSwatchPicker };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=useSwatchPicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSwatchPicker.js","names":[],"sources":["../../src/composables/useSwatchPicker.ts"],"sourcesContent":["import { ref, computed, readonly, type Ref, type ComputedRef } from 'vue'\n\nexport interface UseSwatchPickerOptions {\n /** Initial selected color as a hex string (e.g. '#ff0000'). */\n defaultValue?: string\n /** Fires when a swatch is selected with the new hex color. */\n onChange?: (hex: string) => void\n}\n\nexport interface UseSwatchPickerReturn {\n /** The currently selected color as a hex string. */\n selectedColor: Readonly<Ref<string>>\n /** True when a color is selected (non-empty). */\n hasSelection: ComputedRef<boolean>\n /** Select a color by hex string. */\n setColor: (hex: string) => void\n /** Clear the selection. */\n clearSelection: () => void\n /** Returns true if the given hex string is the currently selected color. */\n isSelected: (hex: string) => boolean\n /** Pass as `@update:model-value` on the ColorSwatchPicker component. */\n onColorChange: (hex: string) => void\n}\n\nexport function useSwatchPicker(options: UseSwatchPickerOptions = {}): UseSwatchPickerReturn {\n const _selectedColor = ref(options.defaultValue ?? '')\n\n const hasSelection = computed(() => _selectedColor.value !== '')\n\n function setColor(hex: string): void {\n _selectedColor.value = hex\n options.onChange?.(hex)\n }\n\n function clearSelection(): void {\n _selectedColor.value = ''\n }\n\n function isSelected(hex: string): boolean {\n return _selectedColor.value === hex\n }\n\n function onColorChange(hex: string): void {\n setColor(hex)\n }\n\n return {\n selectedColor: readonly(_selectedColor),\n hasSelection,\n setColor,\n clearSelection,\n isSelected,\n onColorChange,\n }\n}\n"],"mappings":";;AAwBA,SAAgB,gBAAgB,UAAkC,EAAE,EAAyB;CAC3F,MAAM,iBAAiB,IAAI,QAAQ,gBAAgB,GAAG;CAEtD,MAAM,eAAe,eAAe,eAAe,UAAU,GAAG;CAEhE,SAAS,SAAS,KAAmB;AACnC,iBAAe,QAAQ;AACvB,UAAQ,WAAW,IAAI;;CAGzB,SAAS,iBAAuB;AAC9B,iBAAe,QAAQ;;CAGzB,SAAS,WAAW,KAAsB;AACxC,SAAO,eAAe,UAAU;;CAGlC,SAAS,cAAc,KAAmB;AACxC,WAAS,IAAI;;AAGf,QAAO;EACL,eAAe,SAAS,eAAe;EACvC;EACA;EACA;EACA;EACA;EACD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
//#region src/composables/useTabs.ts
|
|
3
|
+
/**
|
|
4
|
+
* Manages active tab state for the Tabs component.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const tabs = useTabs({ defaultTab: 'overview' })
|
|
9
|
+
* ```
|
|
10
|
+
* ```html
|
|
11
|
+
* <Tabs :model-value="tabs.activeTab" @update:model-value="tabs.onTabChange">
|
|
12
|
+
* <Tab value="overview">Overview</Tab>
|
|
13
|
+
* <Tab value="settings">Settings</Tab>
|
|
14
|
+
* </Tabs>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
function useTabs(options = {}) {
|
|
18
|
+
const activeTab = ref(options.defaultTab);
|
|
19
|
+
function setTab(value) {
|
|
20
|
+
activeTab.value = value;
|
|
21
|
+
}
|
|
22
|
+
function onTabChange(value) {
|
|
23
|
+
activeTab.value = value;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
activeTab,
|
|
27
|
+
setTab,
|
|
28
|
+
onTabChange
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { useTabs };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=useTabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTabs.js","names":[],"sources":["../../src/composables/useTabs.ts"],"sourcesContent":["import { ref, type Ref } from 'vue'\n\nexport interface UseTabsOptions {\n /** Initial active tab value. */\n defaultTab?: string\n}\n\nexport interface UseTabsReturn {\n /** Reactive active tab value. */\n activeTab: Ref<string | undefined>\n /** Set the active tab. */\n setTab: (value: string) => void\n /**\n * Pass as `@update:model-value` handler on the Tabs component.\n * Keeps `activeTab` in sync when the component changes tabs internally.\n */\n onTabChange: (value: string) => void\n}\n\n/**\n * Manages active tab state for the Tabs component.\n *\n * @example\n * ```ts\n * const tabs = useTabs({ defaultTab: 'overview' })\n * ```\n * ```html\n * <Tabs :model-value=\"tabs.activeTab\" @update:model-value=\"tabs.onTabChange\">\n * <Tab value=\"overview\">Overview</Tab>\n * <Tab value=\"settings\">Settings</Tab>\n * </Tabs>\n * ```\n */\nexport function useTabs(options: UseTabsOptions = {}): UseTabsReturn {\n const activeTab = ref<string | undefined>(options.defaultTab)\n\n function setTab(value: string): void {\n activeTab.value = value\n }\n\n function onTabChange(value: string): void {\n activeTab.value = value\n }\n\n return {\n activeTab,\n setTab,\n onTabChange,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiCA,SAAgB,QAAQ,UAA0B,EAAE,EAAiB;CACnE,MAAM,YAAY,IAAwB,QAAQ,WAAW;CAE7D,SAAS,OAAO,OAAqB;AACnC,YAAU,QAAQ;;CAGpB,SAAS,YAAY,OAAqB;AACxC,YAAU,QAAQ;;AAGpB,QAAO;EACL;EACA;EACA;EACD"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
//#region src/composables/useTree.ts
|
|
3
|
+
/**
|
|
4
|
+
* Manages selection and expansion state for the Tree component.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const tree = useTree({ multiple: false, defaultExpanded: ['root'] })
|
|
9
|
+
* ```
|
|
10
|
+
* ```html
|
|
11
|
+
* <Tree
|
|
12
|
+
* :model-value="tree.selected"
|
|
13
|
+
* :expanded="tree.expanded"
|
|
14
|
+
* @update:model-value="tree.onSelectionChange"
|
|
15
|
+
* @update:expanded="tree.onExpandedChange"
|
|
16
|
+
* >
|
|
17
|
+
* ...
|
|
18
|
+
* </Tree>
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
function useTree(options = {}) {
|
|
22
|
+
const multiple = options.multiple ?? false;
|
|
23
|
+
const selected = ref(options.defaultSelected ?? (multiple ? [] : void 0));
|
|
24
|
+
const expanded = ref(options.defaultExpanded ? [...options.defaultExpanded] : []);
|
|
25
|
+
function isSelected(key) {
|
|
26
|
+
if (Array.isArray(selected.value)) return selected.value.includes(key);
|
|
27
|
+
return selected.value === key;
|
|
28
|
+
}
|
|
29
|
+
function select(key) {
|
|
30
|
+
if (multiple) {
|
|
31
|
+
const current = selected.value ?? [];
|
|
32
|
+
if (!current.includes(key)) selected.value = [...current, key];
|
|
33
|
+
} else selected.value = key;
|
|
34
|
+
}
|
|
35
|
+
function deselect(key) {
|
|
36
|
+
if (multiple) selected.value = (selected.value ?? []).filter((k) => k !== key);
|
|
37
|
+
else if (selected.value === key) selected.value = void 0;
|
|
38
|
+
}
|
|
39
|
+
function toggle(key) {
|
|
40
|
+
if (isSelected(key)) deselect(key);
|
|
41
|
+
else select(key);
|
|
42
|
+
}
|
|
43
|
+
function isExpanded(key) {
|
|
44
|
+
return expanded.value.includes(key);
|
|
45
|
+
}
|
|
46
|
+
function expand(key) {
|
|
47
|
+
if (!isExpanded(key)) expanded.value = [...expanded.value, key];
|
|
48
|
+
}
|
|
49
|
+
function collapse(key) {
|
|
50
|
+
expanded.value = expanded.value.filter((k) => k !== key);
|
|
51
|
+
}
|
|
52
|
+
function toggleExpand(key) {
|
|
53
|
+
if (isExpanded(key)) collapse(key);
|
|
54
|
+
else expand(key);
|
|
55
|
+
}
|
|
56
|
+
function expandAll(keys) {
|
|
57
|
+
expanded.value = [...new Set([...expanded.value, ...keys])];
|
|
58
|
+
}
|
|
59
|
+
function collapseAll() {
|
|
60
|
+
expanded.value = [];
|
|
61
|
+
}
|
|
62
|
+
function onSelectionChange(value) {
|
|
63
|
+
selected.value = value;
|
|
64
|
+
}
|
|
65
|
+
function onExpandedChange(keys) {
|
|
66
|
+
expanded.value = keys;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
selected,
|
|
70
|
+
expanded,
|
|
71
|
+
isSelected,
|
|
72
|
+
select,
|
|
73
|
+
deselect,
|
|
74
|
+
toggle,
|
|
75
|
+
isExpanded,
|
|
76
|
+
expand,
|
|
77
|
+
collapse,
|
|
78
|
+
toggleExpand,
|
|
79
|
+
expandAll,
|
|
80
|
+
collapseAll,
|
|
81
|
+
onSelectionChange,
|
|
82
|
+
onExpandedChange
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
export { useTree };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=useTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTree.js","names":[],"sources":["../../src/composables/useTree.ts"],"sourcesContent":["import { ref, type Ref } from 'vue'\n\nexport type TreeValue = string | string[] | undefined\n\nexport interface UseTreeOptions {\n /** Enable multi-selection. Defaults to false. */\n multiple?: boolean\n /** Initial selected node key(s). */\n defaultSelected?: TreeValue\n /** Initial expanded node keys. */\n defaultExpanded?: string[]\n}\n\nexport interface UseTreeReturn {\n /** Reactive selected node key(s). String in single mode, string[] in multiple mode. */\n selected: Ref<TreeValue>\n /** Reactive array of expanded node keys. */\n expanded: Ref<string[]>\n /** Whether a given node is currently selected. */\n isSelected: (key: string) => boolean\n /** Select a node. In single mode, replaces the current selection. */\n select: (key: string) => void\n /** Deselect a node. */\n deselect: (key: string) => void\n /** Toggle a node's selection state. */\n toggle: (key: string) => void\n /** Whether a given node is currently expanded. */\n isExpanded: (key: string) => boolean\n /** Expand a node. */\n expand: (key: string) => void\n /** Collapse a node. */\n collapse: (key: string) => void\n /** Toggle a node's expanded state. */\n toggleExpand: (key: string) => void\n /** Expand all provided node keys. */\n expandAll: (keys: string[]) => void\n /** Collapse all expanded nodes. */\n collapseAll: () => void\n /**\n * Pass as `@update:model-value` on the Tree component.\n * Keeps `selected` in sync when the component changes selection internally.\n */\n onSelectionChange: (value: TreeValue) => void\n /**\n * Pass as `@update:expanded` on the Tree component.\n * Keeps `expanded` in sync when the component changes expanded state internally.\n */\n onExpandedChange: (keys: string[]) => void\n}\n\n/**\n * Manages selection and expansion state for the Tree component.\n *\n * @example\n * ```ts\n * const tree = useTree({ multiple: false, defaultExpanded: ['root'] })\n * ```\n * ```html\n * <Tree\n * :model-value=\"tree.selected\"\n * :expanded=\"tree.expanded\"\n * @update:model-value=\"tree.onSelectionChange\"\n * @update:expanded=\"tree.onExpandedChange\"\n * >\n * ...\n * </Tree>\n * ```\n */\nexport function useTree(options: UseTreeOptions = {}): UseTreeReturn {\n const multiple = options.multiple ?? false\n\n const selected = ref<TreeValue>(\n options.defaultSelected ?? (multiple ? [] : undefined)\n )\n const expanded = ref<string[]>(options.defaultExpanded ? [...options.defaultExpanded] : [])\n\n function isSelected(key: string): boolean {\n if (Array.isArray(selected.value)) return selected.value.includes(key)\n return selected.value === key\n }\n\n function select(key: string): void {\n if (multiple) {\n const current = (selected.value as string[]) ?? []\n if (!current.includes(key)) selected.value = [...current, key]\n } else {\n selected.value = key\n }\n }\n\n function deselect(key: string): void {\n if (multiple) {\n selected.value = ((selected.value as string[]) ?? []).filter(k => k !== key)\n } else if (selected.value === key) {\n selected.value = undefined\n }\n }\n\n function toggle(key: string): void {\n if (isSelected(key)) deselect(key)\n else select(key)\n }\n\n function isExpanded(key: string): boolean {\n return expanded.value.includes(key)\n }\n\n function expand(key: string): void {\n if (!isExpanded(key)) expanded.value = [...expanded.value, key]\n }\n\n function collapse(key: string): void {\n expanded.value = expanded.value.filter(k => k !== key)\n }\n\n function toggleExpand(key: string): void {\n if (isExpanded(key)) collapse(key)\n else expand(key)\n }\n\n function expandAll(keys: string[]): void {\n expanded.value = [...new Set([...expanded.value, ...keys])]\n }\n\n function collapseAll(): void {\n expanded.value = []\n }\n\n function onSelectionChange(value: TreeValue): void {\n selected.value = value\n }\n\n function onExpandedChange(keys: string[]): void {\n expanded.value = keys\n }\n\n return {\n selected,\n expanded,\n isSelected,\n select,\n deselect,\n toggle,\n isExpanded,\n expand,\n collapse,\n toggleExpand,\n expandAll,\n collapseAll,\n onSelectionChange,\n onExpandedChange,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoEA,SAAgB,QAAQ,UAA0B,EAAE,EAAiB;CACnE,MAAM,WAAW,QAAQ,YAAY;CAErC,MAAM,WAAW,IACf,QAAQ,oBAAoB,WAAW,EAAE,GAAG,KAAA,GAC7C;CACD,MAAM,WAAW,IAAc,QAAQ,kBAAkB,CAAC,GAAG,QAAQ,gBAAgB,GAAG,EAAE,CAAC;CAE3F,SAAS,WAAW,KAAsB;AACxC,MAAI,MAAM,QAAQ,SAAS,MAAM,CAAE,QAAO,SAAS,MAAM,SAAS,IAAI;AACtE,SAAO,SAAS,UAAU;;CAG5B,SAAS,OAAO,KAAmB;AACjC,MAAI,UAAU;GACZ,MAAM,UAAW,SAAS,SAAsB,EAAE;AAClD,OAAI,CAAC,QAAQ,SAAS,IAAI,CAAE,UAAS,QAAQ,CAAC,GAAG,SAAS,IAAI;QAE9D,UAAS,QAAQ;;CAIrB,SAAS,SAAS,KAAmB;AACnC,MAAI,SACF,UAAS,SAAU,SAAS,SAAsB,EAAE,EAAE,QAAO,MAAK,MAAM,IAAI;WACnE,SAAS,UAAU,IAC5B,UAAS,QAAQ,KAAA;;CAIrB,SAAS,OAAO,KAAmB;AACjC,MAAI,WAAW,IAAI,CAAE,UAAS,IAAI;MAC7B,QAAO,IAAI;;CAGlB,SAAS,WAAW,KAAsB;AACxC,SAAO,SAAS,MAAM,SAAS,IAAI;;CAGrC,SAAS,OAAO,KAAmB;AACjC,MAAI,CAAC,WAAW,IAAI,CAAE,UAAS,QAAQ,CAAC,GAAG,SAAS,OAAO,IAAI;;CAGjE,SAAS,SAAS,KAAmB;AACnC,WAAS,QAAQ,SAAS,MAAM,QAAO,MAAK,MAAM,IAAI;;CAGxD,SAAS,aAAa,KAAmB;AACvC,MAAI,WAAW,IAAI,CAAE,UAAS,IAAI;MAC7B,QAAO,IAAI;;CAGlB,SAAS,UAAU,MAAsB;AACvC,WAAS,QAAQ,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,SAAS,OAAO,GAAG,KAAK,CAAC,CAAC;;CAG7D,SAAS,cAAoB;AAC3B,WAAS,QAAQ,EAAE;;CAGrB,SAAS,kBAAkB,OAAwB;AACjD,WAAS,QAAQ;;CAGnB,SAAS,iBAAiB,MAAsB;AAC9C,WAAS,QAAQ;;AAGnB,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
|