nuance-ui 0.3.0 → 0.3.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.
Files changed (46) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/components/accordion/accordion-header.d.vue.ts +28 -0
  3. package/dist/runtime/components/accordion/accordion-header.vue +79 -0
  4. package/dist/runtime/components/accordion/accordion-header.vue.d.ts +28 -0
  5. package/dist/runtime/components/accordion/accordion-item.d.vue.ts +18 -0
  6. package/dist/runtime/components/accordion/accordion-item.vue +44 -0
  7. package/dist/runtime/components/accordion/accordion-item.vue.d.ts +18 -0
  8. package/dist/runtime/components/accordion/accordion-panel.d.vue.ts +18 -0
  9. package/dist/runtime/components/accordion/accordion-panel.vue +40 -0
  10. package/dist/runtime/components/accordion/accordion-panel.vue.d.ts +18 -0
  11. package/dist/runtime/components/accordion/accordion.d.vue.ts +61 -0
  12. package/dist/runtime/components/accordion/accordion.module.css +1 -0
  13. package/dist/runtime/components/accordion/accordion.vue +91 -0
  14. package/dist/runtime/components/accordion/accordion.vue.d.ts +61 -0
  15. package/dist/runtime/components/accordion/index.d.ts +6 -0
  16. package/dist/runtime/components/accordion/index.js +4 -0
  17. package/dist/runtime/components/accordion/lib/context.d.ts +34 -0
  18. package/dist/runtime/components/accordion/lib/context.js +9 -0
  19. package/dist/runtime/components/collapse.d.vue.ts +65 -0
  20. package/dist/runtime/components/collapse.vue +144 -0
  21. package/dist/runtime/components/collapse.vue.d.ts +65 -0
  22. package/dist/runtime/components/date-time-picker.d.vue.ts +2 -2
  23. package/dist/runtime/components/date-time-picker.vue.d.ts +2 -2
  24. package/dist/runtime/components/index.d.ts +2 -2
  25. package/dist/runtime/components/index.js +1 -1
  26. package/dist/runtime/components/input/date-picker.d.vue.ts +2 -2
  27. package/dist/runtime/components/input/date-picker.vue.d.ts +2 -2
  28. package/dist/runtime/components/link/lib.d.ts +2 -2
  29. package/dist/runtime/components/tabs/tabs-root.d.vue.ts +1 -1
  30. package/dist/runtime/components/tabs/tabs-root.vue.d.ts +1 -1
  31. package/dist/runtime/components/text.vue +1 -1
  32. package/package.json +2 -2
  33. package/dist/runtime/components/accordion.d.vue.ts +0 -79
  34. package/dist/runtime/components/accordion.vue +0 -44
  35. package/dist/runtime/components/accordion.vue.d.ts +0 -79
  36. package/dist/runtime/components/collapsible/collapsible-content.d.vue.ts +0 -18
  37. package/dist/runtime/components/collapsible/collapsible-content.vue +0 -76
  38. package/dist/runtime/components/collapsible/collapsible-content.vue.d.ts +0 -18
  39. package/dist/runtime/components/collapsible/collapsible-root.d.vue.ts +0 -42
  40. package/dist/runtime/components/collapsible/collapsible-root.vue +0 -41
  41. package/dist/runtime/components/collapsible/collapsible-root.vue.d.ts +0 -42
  42. package/dist/runtime/components/collapsible/collapsible-trigger.d.vue.ts +0 -13
  43. package/dist/runtime/components/collapsible/collapsible-trigger.vue +0 -20
  44. package/dist/runtime/components/collapsible/collapsible-trigger.vue.d.ts +0 -13
  45. package/dist/runtime/components/collapsible/index.d.ts +0 -3
  46. package/dist/runtime/components/collapsible/index.js +0 -1
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^4.0.0"
6
6
  },
7
- "version": "0.3.0",
7
+ "version": "0.3.1",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
@@ -0,0 +1,28 @@
1
+ export interface AccordionHeaderProps {
2
+ /** Leading icon name shown before the label */
3
+ icon?: string;
4
+ /** Overrides the accordion-level chevron icon for this item */
5
+ chevron?: string;
6
+ }
7
+ export interface AccordionHeaderSlots {
8
+ /** Header label */
9
+ default?: (props: {
10
+ open: boolean;
11
+ }) => any;
12
+ /** Leading content, replaces the `icon` prop */
13
+ icon?: (props: {
14
+ open: boolean;
15
+ }) => any;
16
+ /** Trailing content, replaces the chevron */
17
+ chevron?: (props: {
18
+ open: boolean;
19
+ }) => any;
20
+ }
21
+ declare const _default: typeof __VLS_export;
22
+ export default _default;
23
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<AccordionHeaderProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<AccordionHeaderProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, AccordionHeaderSlots>;
24
+ type __VLS_WithSlots<T, S> = T & {
25
+ new (): {
26
+ $slots: S;
27
+ };
28
+ };
@@ -0,0 +1,79 @@
1
+ <script>
2
+
3
+ </script>
4
+
5
+ <script setup>
6
+ import { useConfig } from "@nui/composables";
7
+ import { computed } from "vue";
8
+ import Box from "../box.vue";
9
+ import UnstyledButton from "../button/unstyled-button.vue";
10
+ import Title from "../title.vue";
11
+ import css from "./accordion.module.css";
12
+ import { useAccordionItemState, useAccordionRootState } from "./lib/context";
13
+ const { icon, chevron } = defineProps({
14
+ icon: { type: String, required: false },
15
+ chevron: { type: String, required: false }
16
+ });
17
+ defineSlots();
18
+ const { icons } = useConfig();
19
+ const root = useAccordionRootState();
20
+ const item = useAccordionItemState();
21
+ const headerId = computed(() => root.getHeaderId(item.value.value));
22
+ const panelId = computed(() => root.getPanelId(item.value.value));
23
+ const chevronIcon = computed(() => chevron ?? root.chevron.value ?? icons.chevronDown);
24
+ const rotate = computed(() => item.open.value && !root.disableChevronRotation.value);
25
+ function onClick() {
26
+ if (item.disabled.value)
27
+ return;
28
+ root.toggleItem(item.value.value);
29
+ }
30
+ </script>
31
+
32
+ <template>
33
+ <Box
34
+ :is='root.order.value ? Title : "div"'
35
+ v-bind='root.order.value ? { order: root.order.value } : {}'
36
+ :class='[css.header, root.classes.value?.header]'
37
+ >
38
+ <UnstyledButton
39
+ :id='headerId'
40
+ type='button'
41
+ :disabled='item.disabled.value'
42
+ :aria-expanded='item.open.value'
43
+ :aria-controls='panelId'
44
+ :mod='{
45
+ "state": item.dataState.value,
46
+ "variant": root.variant.value,
47
+ "disabled": item.disabled.value,
48
+ "chevron-position": root.chevronPosition.value
49
+ }'
50
+ :class='[css.control, root.classes.value?.control]'
51
+ @click='onClick'
52
+ >
53
+ <Box
54
+ is='span'
55
+ v-if='$slots.icon || icon'
56
+ :mod='{ "chevron-position": root.chevronPosition.value }'
57
+ :class='[css.icon, root.classes.value?.icon]'
58
+ >
59
+ <slot name='icon' :open='item.open.value'>
60
+ <Icon v-if='icon' :name='icon' />
61
+ </slot>
62
+ </Box>
63
+
64
+ <span :class='[css.label, root.classes.value?.label]'>
65
+ <slot :open='item.open.value' />
66
+ </span>
67
+
68
+ <Box
69
+ is='span'
70
+ :mod='{ rotate, position: root.chevronPosition.value }'
71
+ :class='[css.chevron, root.classes.value?.chevron]'
72
+ >
73
+ <slot name='chevron' :open='item.open.value'>
74
+ <Icon :name='chevronIcon' />
75
+ </slot>
76
+ </Box>
77
+ </UnstyledButton>
78
+ </Box>
79
+ </template>
@@ -0,0 +1,28 @@
1
+ export interface AccordionHeaderProps {
2
+ /** Leading icon name shown before the label */
3
+ icon?: string;
4
+ /** Overrides the accordion-level chevron icon for this item */
5
+ chevron?: string;
6
+ }
7
+ export interface AccordionHeaderSlots {
8
+ /** Header label */
9
+ default?: (props: {
10
+ open: boolean;
11
+ }) => any;
12
+ /** Leading content, replaces the `icon` prop */
13
+ icon?: (props: {
14
+ open: boolean;
15
+ }) => any;
16
+ /** Trailing content, replaces the chevron */
17
+ chevron?: (props: {
18
+ open: boolean;
19
+ }) => any;
20
+ }
21
+ declare const _default: typeof __VLS_export;
22
+ export default _default;
23
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<AccordionHeaderProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<AccordionHeaderProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, AccordionHeaderSlots>;
24
+ type __VLS_WithSlots<T, S> = T & {
25
+ new (): {
26
+ $slots: S;
27
+ };
28
+ };
@@ -0,0 +1,18 @@
1
+ export interface AccordionItemProps {
2
+ /** Unique value used to manage the open state. Must be unique within the accordion. */
3
+ value: string;
4
+ /** Disables this item */
5
+ disabled?: boolean;
6
+ }
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
9
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<AccordionItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<AccordionItemProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
10
+ default?: (props: {
11
+ open: boolean;
12
+ }) => any;
13
+ }>;
14
+ type __VLS_WithSlots<T, S> = T & {
15
+ new (): {
16
+ $slots: S;
17
+ };
18
+ };
@@ -0,0 +1,44 @@
1
+ <script>
2
+
3
+ </script>
4
+
5
+ <script setup>
6
+ import { computed } from "vue";
7
+ import Box from "../box.vue";
8
+ import css from "./accordion.module.css";
9
+ import {
10
+ provideAccordionItemState,
11
+ useAccordionRootState
12
+ } from "./lib/context";
13
+ const { value, disabled } = defineProps({
14
+ value: { type: String, required: true },
15
+ disabled: { type: Boolean, required: false }
16
+ });
17
+ const root = useAccordionRootState();
18
+ const open = computed(() => root.isItemActive(value));
19
+ const itemDisabled = computed(() => root.disabled.value || disabled);
20
+ const dataState = computed(() => open.value ? "open" : "closed");
21
+ provideAccordionItemState({
22
+ value: computed(() => value),
23
+ open,
24
+ disabled: itemDisabled,
25
+ dataState
26
+ });
27
+ </script>
28
+
29
+ <template>
30
+ <Box
31
+ :mod='{
32
+ active: open,
33
+ disabled: itemDisabled,
34
+ state: dataState,
35
+ variant: root.variant.value
36
+ }'
37
+ :class='[
38
+ css.item,
39
+ root.classes.value?.item
40
+ ]'
41
+ >
42
+ <slot :open='open' />
43
+ </Box>
44
+ </template>
@@ -0,0 +1,18 @@
1
+ export interface AccordionItemProps {
2
+ /** Unique value used to manage the open state. Must be unique within the accordion. */
3
+ value: string;
4
+ /** Disables this item */
5
+ disabled?: boolean;
6
+ }
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
9
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<AccordionItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<AccordionItemProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
10
+ default?: (props: {
11
+ open: boolean;
12
+ }) => any;
13
+ }>;
14
+ type __VLS_WithSlots<T, S> = T & {
15
+ new (): {
16
+ $slots: S;
17
+ };
18
+ };
@@ -0,0 +1,18 @@
1
+ export interface AccordionPanelProps {
2
+ /** Overrides the accordion-level `keepMounted`. When unset, inherits from the accordion. */
3
+ keepMounted?: boolean;
4
+ /** Overrides the accordion-level `transitionDuration` */
5
+ transitionDuration?: number;
6
+ }
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
9
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<AccordionPanelProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<AccordionPanelProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
10
+ default?: (props: {
11
+ open: boolean;
12
+ }) => any;
13
+ }>;
14
+ type __VLS_WithSlots<T, S> = T & {
15
+ new (): {
16
+ $slots: S;
17
+ };
18
+ };
@@ -0,0 +1,40 @@
1
+ <script>
2
+
3
+ </script>
4
+
5
+ <script setup>
6
+ import { computed } from "vue";
7
+ import Collapse from "../collapse.vue";
8
+ import css from "./accordion.module.css";
9
+ import { useAccordionItemState, useAccordionRootState } from "./lib/context";
10
+ const { keepMounted, transitionDuration } = defineProps({
11
+ keepMounted: { type: Boolean, required: false },
12
+ transitionDuration: { type: Number, required: false }
13
+ });
14
+ const root = useAccordionRootState();
15
+ const item = useAccordionItemState();
16
+ const open = computed({
17
+ get: () => item.open.value,
18
+ set: (v) => v !== item.open.value && root.toggleItem(item.value.value)
19
+ });
20
+ const panelId = computed(() => root.getPanelId(item.value.value));
21
+ const headerId = computed(() => root.getHeaderId(item.value.value));
22
+ </script>
23
+
24
+ <template>
25
+ <Collapse
26
+ v-model:open='open'
27
+ :keep-mounted='keepMounted ?? root.keepMounted.value'
28
+ :transition-duration='transitionDuration ?? root.transitionDuration.value'
29
+ :class='[css.panel, root.classes.value?.panel]'
30
+ >
31
+ <div
32
+ :id='panelId'
33
+ role='region'
34
+ :aria-labelledby='headerId'
35
+ :class='[css.content, root.classes.value?.content]'
36
+ >
37
+ <slot :open='item.open.value' />
38
+ </div>
39
+ </Collapse>
40
+ </template>
@@ -0,0 +1,18 @@
1
+ export interface AccordionPanelProps {
2
+ /** Overrides the accordion-level `keepMounted`. When unset, inherits from the accordion. */
3
+ keepMounted?: boolean;
4
+ /** Overrides the accordion-level `transitionDuration` */
5
+ transitionDuration?: number;
6
+ }
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
9
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<AccordionPanelProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<AccordionPanelProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
10
+ default?: (props: {
11
+ open: boolean;
12
+ }) => any;
13
+ }>;
14
+ type __VLS_WithSlots<T, S> = T & {
15
+ new (): {
16
+ $slots: S;
17
+ };
18
+ };
@@ -0,0 +1,61 @@
1
+ import type { AnyString, NuanceRadius } from '@nui/types';
2
+ import type { TitleProps } from '../title.vue.js';
3
+ import type { AccordionChevronPosition, AccordionClasses, AccordionVariant } from './lib/context.js';
4
+ export interface AccordionProps<Multiple extends boolean = false> {
5
+ /** If set, multiple items can be opened at the same time @default false */
6
+ multiple?: Multiple;
7
+ /** Uncontrolled default open value(s) */
8
+ defaultValue?: Multiple extends true ? string[] : string | null;
9
+ /** If set, arrow keys loop through item headers @default true */
10
+ loop?: boolean;
11
+ /** Visual variant @default 'default' */
12
+ variant?: AccordionVariant;
13
+ /** Transition duration in ms @default 200 */
14
+ transitionDuration?: number;
15
+ /** If set, chevron rotation is disabled @default false */
16
+ disableChevronRotation?: boolean;
17
+ /** Position of the chevron relative to the item label @default 'right' */
18
+ chevronPosition?: AccordionChevronPosition;
19
+ /** Size of the chevron icon container @default auto */
20
+ chevronSize?: number | string;
21
+ /** Custom chevron icon name */
22
+ chevron?: string;
23
+ /** Disables the component */
24
+ disabled?: boolean;
25
+ /**
26
+ * Sets heading level (h1-h6) for item headers, wrapping each in the matching heading tag.
27
+ * Recommended to meet WAI-ARIA requirements. Has no visual effect.
28
+ */
29
+ order?: TitleProps['order'];
30
+ /** Border radius @default theme.defaultRadius */
31
+ radius?: NuanceRadius | AnyString;
32
+ /** If `false`, panels are unmounted when collapsed @default true */
33
+ keepMounted?: boolean;
34
+ /** Styles API */
35
+ classes?: AccordionClasses;
36
+ }
37
+ export type AccordionValue<Multiple extends boolean> = Multiple extends true ? string[] : string | null;
38
+ declare const _default: typeof __VLS_export;
39
+ export default _default;
40
+ declare const __VLS_export: <Multiple extends boolean = false>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
41
+ props: import("vue").PublicProps & __VLS_PrettifyLocal<(AccordionProps<Multiple> & {
42
+ modelValue?: AccordionValue<Multiple>;
43
+ }) & {
44
+ "onUpdate:modelValue"?: ((value: AccordionValue<Multiple>) => any) | undefined;
45
+ }> & (typeof globalThis extends {
46
+ __VLS_PROPS_FALLBACK: infer P;
47
+ } ? P : {});
48
+ expose: (exposed: {}) => void;
49
+ attrs: any;
50
+ slots: {
51
+ default?: (props: {}) => any;
52
+ };
53
+ emit: (event: "update:modelValue", value: AccordionValue<Multiple>) => void;
54
+ }>) => import("vue").VNode & {
55
+ __ctx?: Awaited<typeof __VLS_setup>;
56
+ };
57
+ type __VLS_PrettifyLocal<T> = (T extends any ? {
58
+ [K in keyof T]: T[K];
59
+ } : {
60
+ [K in keyof T as K]: T[K];
61
+ }) & {};
@@ -0,0 +1 @@
1
+ .root{--accordion-radius:var(--radius-default)}.panel{overflow-wrap:break-word}.content{padding:var(--spacing-md);padding-top:calc(var(--spacing-xs)/2)}.header{margin:0;padding:0;width:100%}.control{align-items:center;background-color:transparent;color:var(--color-bright);cursor:pointer;display:flex;flex-direction:row;opacity:1;padding-inline:var(--spacing-md);width:100%}.control:where([data-chevron-position=left]){flex-direction:row-reverse;padding-inline-start:0}.control:where(:disabled,[data-disabled]){cursor:not-allowed;opacity:.4}.control:where([data-variant=default],[data-variant=contained]):where(:not(:disabled,[data-disabled])){@mixin hover{@mixin where-light{background-color:var(--color-gray-1)}@mixin where-dark{background-color:var(--color-dark-6)}}}.label{color:inherit;flex:1;font-weight:400;overflow:hidden;padding-bottom:var(--spacing-sm);padding-top:var(--spacing-sm);text-overflow:ellipsis}.chevron{align-items:center;display:flex;justify-content:flex-start;min-width:var(--accordion-chevron-size,rem(15px));transform:rotate(0deg);transition:transform var(--accordion-transition-duration,.2s) ease;width:var(--accordion-chevron-size,rem(15px))}.chevron:where([data-rotate]){transform:rotate(180deg)}.chevron:where([data-position=left]){margin-inline-end:var(--spacing-md);margin-inline-start:var(--spacing-md)}.icon{align-items:center;display:flex;justify-content:center;margin-inline-end:var(--spacing-sm)}.icon:where([data-chevron-position=left]){margin-inline-end:0;margin-inline-start:var(--spacing-lg)}.item{@mixin where-light{--item-border-color:var(--color-gray-3);--item-filled-color:var(--color-gray-2)}@mixin where-dark{--item-border-color:var(--color-dark-4);--item-filled-color:var(--color-dark-6)}}.item:where([data-variant=default]){border-bottom:1px solid var(--item-border-color)}.item:where([data-variant=contained]){border:1px solid var(--item-border-color);transition:background-color .15s ease}.item:where([data-variant=contained]):where([data-active]){background-color:var(--item-filled-color)}.item:where([data-variant=contained]):first-of-type{border-start-end-radius:var(--accordion-radius);border-start-start-radius:var(--accordion-radius)}.item:where([data-variant=contained]):first-of-type>[data-state]{border-start-end-radius:var(--accordion-radius);border-start-start-radius:var(--accordion-radius)}.item:where([data-variant=contained]):last-of-type{border-end-end-radius:var(--accordion-radius);border-end-start-radius:var(--accordion-radius)}.item:where([data-variant=contained]):last-of-type>[data-state]{border-end-end-radius:var(--accordion-radius);border-end-start-radius:var(--accordion-radius)}.item:where([data-variant=contained])+.item:where([data-variant=contained]){border-top:0}.item:where([data-variant=filled]){border-radius:var(--accordion-radius)}.item:where([data-variant=filled]):where([data-active]){background-color:var(--item-filled-color)}.item:where([data-variant=separated]){background-color:var(--item-filled-color);border:1px solid transparent;border-radius:var(--accordion-radius);transition:background-color .15s ease}.item:where([data-variant=separated])[data-active]{border-color:var(--item-border-color);@mixin where-light{background-color:var(--color-white)}@mixin where-dark{background-color:var(--color-dark-7)}}.item:where([data-variant=separated])+.item:where([data-variant=separated]){margin-top:var(--spacing-md)}
@@ -0,0 +1,91 @@
1
+ <script>
2
+ import { useVarsResolver } from "#imports";
3
+ </script>
4
+
5
+ <script setup>
6
+ import { getRadius, getSize } from "@nui/utils";
7
+ import { toRefs, useId } from "vue";
8
+ import Box from "../box.vue";
9
+ import css from "./accordion.module.css";
10
+ import { provideAccordionRootState } from "./lib/context";
11
+ const {
12
+ loop = true,
13
+ variant = "default",
14
+ transitionDuration = 200,
15
+ disableChevronRotation,
16
+ chevronPosition = "right",
17
+ chevronSize,
18
+ chevron,
19
+ disabled,
20
+ order,
21
+ radius,
22
+ keepMounted = true,
23
+ classes
24
+ } = defineProps({
25
+ multiple: { type: null, required: false },
26
+ defaultValue: { type: null, required: false },
27
+ loop: { type: Boolean, required: false },
28
+ variant: { type: String, required: false },
29
+ transitionDuration: { type: Number, required: false },
30
+ disableChevronRotation: { type: Boolean, required: false },
31
+ chevronPosition: { type: String, required: false },
32
+ chevronSize: { type: [Number, String], required: false },
33
+ chevron: { type: String, required: false },
34
+ disabled: { type: Boolean, required: false },
35
+ order: { type: String, required: false },
36
+ radius: { type: [String, Number, Object], required: false },
37
+ keepMounted: { type: Boolean, required: false },
38
+ classes: { type: Object, required: false }
39
+ });
40
+ const value = defineModel({ type: null, ...{
41
+ default: (p) => p.multiple ? [] : null
42
+ } });
43
+ const uid = useId();
44
+ function isItemActive(itemValue) {
45
+ return Array.isArray(value.value) ? value.value.includes(itemValue) : value.value === itemValue;
46
+ }
47
+ function toggleItem(itemValue) {
48
+ if (Array.isArray(value.value)) {
49
+ value.value = value.value.includes(itemValue) ? value.value.filter((v) => v !== itemValue) : [...value.value, itemValue];
50
+ } else {
51
+ value.value = value.value === itemValue ? null : itemValue;
52
+ }
53
+ }
54
+ const rest = toRefs({
55
+ classes,
56
+ disabled,
57
+ variant,
58
+ transitionDuration,
59
+ disableChevronRotation,
60
+ chevronPosition,
61
+ chevron,
62
+ order,
63
+ loop,
64
+ keepMounted
65
+ });
66
+ provideAccordionRootState({
67
+ isItemActive,
68
+ toggleItem,
69
+ getHeaderId: (v) => `${uid}-header-${v}`,
70
+ getPanelId: (v) => `${uid}-panel-${v}`,
71
+ ...rest
72
+ });
73
+ const style = useVarsResolver(() => ({
74
+ root: {
75
+ "--accordion-transition-duration": `${transitionDuration}ms`,
76
+ "--accordion-chevron-size": chevronSize === void 0 ? void 0 : getSize(chevronSize),
77
+ "--accordion-radius": radius === void 0 ? void 0 : getRadius(radius)
78
+ }
79
+ }));
80
+ </script>
81
+
82
+ <template>
83
+ <Box
84
+ :id='uid'
85
+ :style='style.root'
86
+ :mod='{ variant }'
87
+ :class='[css.root, classes?.root]'
88
+ >
89
+ <slot />
90
+ </Box>
91
+ </template>
@@ -0,0 +1,61 @@
1
+ import type { AnyString, NuanceRadius } from '@nui/types';
2
+ import type { TitleProps } from '../title.vue.js';
3
+ import type { AccordionChevronPosition, AccordionClasses, AccordionVariant } from './lib/context.js';
4
+ export interface AccordionProps<Multiple extends boolean = false> {
5
+ /** If set, multiple items can be opened at the same time @default false */
6
+ multiple?: Multiple;
7
+ /** Uncontrolled default open value(s) */
8
+ defaultValue?: Multiple extends true ? string[] : string | null;
9
+ /** If set, arrow keys loop through item headers @default true */
10
+ loop?: boolean;
11
+ /** Visual variant @default 'default' */
12
+ variant?: AccordionVariant;
13
+ /** Transition duration in ms @default 200 */
14
+ transitionDuration?: number;
15
+ /** If set, chevron rotation is disabled @default false */
16
+ disableChevronRotation?: boolean;
17
+ /** Position of the chevron relative to the item label @default 'right' */
18
+ chevronPosition?: AccordionChevronPosition;
19
+ /** Size of the chevron icon container @default auto */
20
+ chevronSize?: number | string;
21
+ /** Custom chevron icon name */
22
+ chevron?: string;
23
+ /** Disables the component */
24
+ disabled?: boolean;
25
+ /**
26
+ * Sets heading level (h1-h6) for item headers, wrapping each in the matching heading tag.
27
+ * Recommended to meet WAI-ARIA requirements. Has no visual effect.
28
+ */
29
+ order?: TitleProps['order'];
30
+ /** Border radius @default theme.defaultRadius */
31
+ radius?: NuanceRadius | AnyString;
32
+ /** If `false`, panels are unmounted when collapsed @default true */
33
+ keepMounted?: boolean;
34
+ /** Styles API */
35
+ classes?: AccordionClasses;
36
+ }
37
+ export type AccordionValue<Multiple extends boolean> = Multiple extends true ? string[] : string | null;
38
+ declare const _default: typeof __VLS_export;
39
+ export default _default;
40
+ declare const __VLS_export: <Multiple extends boolean = false>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
41
+ props: import("vue").PublicProps & __VLS_PrettifyLocal<(AccordionProps<Multiple> & {
42
+ modelValue?: AccordionValue<Multiple>;
43
+ }) & {
44
+ "onUpdate:modelValue"?: ((value: AccordionValue<Multiple>) => any) | undefined;
45
+ }> & (typeof globalThis extends {
46
+ __VLS_PROPS_FALLBACK: infer P;
47
+ } ? P : {});
48
+ expose: (exposed: {}) => void;
49
+ attrs: any;
50
+ slots: {
51
+ default?: (props: {}) => any;
52
+ };
53
+ emit: (event: "update:modelValue", value: AccordionValue<Multiple>) => void;
54
+ }>) => import("vue").VNode & {
55
+ __ctx?: Awaited<typeof __VLS_setup>;
56
+ };
57
+ type __VLS_PrettifyLocal<T> = (T extends any ? {
58
+ [K in keyof T]: T[K];
59
+ } : {
60
+ [K in keyof T as K]: T[K];
61
+ }) & {};
@@ -0,0 +1,6 @@
1
+ export type * from './accordion-header.vue';
2
+ export type * from './accordion-item.vue';
3
+ export type * from './accordion-panel.vue';
4
+ export type * from './accordion.vue';
5
+ export { useAccordionItemState as useAccordionItemContext, useAccordionRootState as useAccordionRootContext, } from './lib/context.js';
6
+ export type * from './lib/context';
@@ -0,0 +1,4 @@
1
+ export {
2
+ useAccordionItemState as useAccordionItemContext,
3
+ useAccordionRootState as useAccordionRootContext
4
+ } from "./lib/context.js";
@@ -0,0 +1,34 @@
1
+ import type { Classes } from '@nui/types';
2
+ import type { ComputedRef, Ref } from 'vue';
3
+ export type AccordionVariant = 'default' | 'contained' | 'filled' | 'separated';
4
+ export type AccordionChevronPosition = 'left' | 'right';
5
+ export type AccordionClasses = Classes<'root' | 'item' | 'header' | 'control' | 'label' | 'icon' | 'chevron' | 'panel' | 'content'>;
6
+ export interface AccordionRootContext {
7
+ /** User-provided class names per styles-API part */
8
+ classes: Ref<AccordionClasses | undefined>;
9
+ /** Whether the item with the given value is currently open */
10
+ isItemActive: (value: string) => boolean;
11
+ /** Toggle the item with the given value */
12
+ toggleItem: (value: string) => void;
13
+ /** Build the accessible id for an item header */
14
+ getHeaderId: (value: string) => string;
15
+ /** Build the accessible id for an item panel */
16
+ getPanelId: (value: string) => string;
17
+ disabled: Ref<boolean | undefined>;
18
+ variant: Ref<AccordionVariant>;
19
+ transitionDuration: Ref<number>;
20
+ disableChevronRotation: Ref<boolean | undefined>;
21
+ chevronPosition: Ref<AccordionChevronPosition>;
22
+ chevron: Ref<string | undefined>;
23
+ order: Ref<'1' | '2' | '3' | '4' | '5' | '6' | undefined>;
24
+ loop: Ref<boolean>;
25
+ keepMounted: Ref<boolean>;
26
+ }
27
+ export interface AccordionItemContext {
28
+ value: ComputedRef<string>;
29
+ open: ComputedRef<boolean>;
30
+ disabled: ComputedRef<boolean | undefined>;
31
+ dataState: ComputedRef<'open' | 'closed'>;
32
+ }
33
+ export declare const provideAccordionRootState: (state: AccordionRootContext) => AccordionRootContext, useAccordionRootState: () => AccordionRootContext;
34
+ export declare const provideAccordionItemState: (state: AccordionItemContext) => AccordionItemContext, useAccordionItemState: () => AccordionItemContext;
@@ -0,0 +1,9 @@
1
+ import { createStrictInjection } from "@nui/composables";
2
+ export const [provideAccordionRootState, useAccordionRootState] = createStrictInjection(
3
+ (state) => state,
4
+ { name: "AccordionRoot", injectionKey: Symbol("accordion-root") }
5
+ );
6
+ export const [provideAccordionItemState, useAccordionItemState] = createStrictInjection(
7
+ (state) => state,
8
+ { name: "AccordionItem", injectionKey: Symbol("accordion-item") }
9
+ );
@@ -0,0 +1,65 @@
1
+ import type { Classes } from '@nui/types';
2
+ import type { BoxProps } from './box.vue.js';
3
+ export type CollapseClasses = 'root' | 'trigger' | 'content';
4
+ /** Props passed to the trigger slot, spread onto a custom toggle element for a11y. */
5
+ export interface CollapseTriggerProps {
6
+ 'aria-controls': string;
7
+ 'aria-expanded': boolean;
8
+ 'disabled': boolean | undefined;
9
+ 'data-state': 'open' | 'closed';
10
+ 'data-disabled': '' | undefined;
11
+ }
12
+ export interface CollapseProps {
13
+ /**
14
+ * The open state of the collapsible when it is initially rendered.
15
+ * Use when you do not need to control its open state.
16
+ * @default false
17
+ */
18
+ defaultOpen?: boolean;
19
+ /** Disables the component */
20
+ disabled?: boolean;
21
+ /**
22
+ * If set, the content stays mounted when collapsed.
23
+ * When `false`, content is unmounted after the exit transition.
24
+ * @default true
25
+ */
26
+ keepMounted?: boolean;
27
+ /** Transition duration in ms @default 200 */
28
+ transitionDuration?: number;
29
+ /** Transition timing function @default 'ease' */
30
+ transitionTimingFunction?: string;
31
+ /** If set, opacity is animated alongside height @default true */
32
+ animateOpacity?: boolean;
33
+ /** Element modifiers transformed into `data-` attributes, falsy values are removed */
34
+ mod?: BoxProps['mod'];
35
+ /** Styles API */
36
+ classes?: Classes<CollapseClasses>;
37
+ }
38
+ export interface CollapseSlots {
39
+ /** Collapsible content */
40
+ default?: (props: {
41
+ open: boolean;
42
+ }) => any;
43
+ /** Toggle control. Spread `props` onto a button to get a11y wiring. */
44
+ trigger?: (props: {
45
+ open: boolean;
46
+ toggle: () => void;
47
+ props: CollapseTriggerProps;
48
+ }) => any;
49
+ }
50
+ declare const _default: typeof __VLS_export;
51
+ export default _default;
52
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<CollapseProps & {
53
+ open?: boolean;
54
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
55
+ "update:open": (value: boolean) => any;
56
+ }, string, import("vue").PublicProps, Readonly<CollapseProps & {
57
+ open?: boolean;
58
+ }> & Readonly<{
59
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
60
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, CollapseSlots>;
61
+ type __VLS_WithSlots<T, S> = T & {
62
+ new (): {
63
+ $slots: S;
64
+ };
65
+ };