nuance-ui 0.2.36 → 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.
- package/dist/module.d.mts +3 -0
- package/dist/module.d.ts +3 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +5 -3
- package/dist/runtime/app-config.d.ts +4 -0
- package/dist/runtime/components/accordion/accordion-header.d.vue.ts +28 -0
- package/dist/runtime/components/accordion/accordion-header.vue +79 -0
- package/dist/runtime/components/accordion/accordion-header.vue.d.ts +28 -0
- package/dist/runtime/components/accordion/accordion-item.d.vue.ts +18 -0
- package/dist/runtime/components/accordion/accordion-item.vue +44 -0
- package/dist/runtime/components/accordion/accordion-item.vue.d.ts +18 -0
- package/dist/runtime/components/accordion/accordion-panel.d.vue.ts +18 -0
- package/dist/runtime/components/accordion/accordion-panel.vue +40 -0
- package/dist/runtime/components/accordion/accordion-panel.vue.d.ts +18 -0
- package/dist/runtime/components/accordion/accordion.d.vue.ts +61 -0
- package/dist/runtime/components/accordion/accordion.module.css +1 -0
- package/dist/runtime/components/accordion/accordion.vue +91 -0
- package/dist/runtime/components/accordion/accordion.vue.d.ts +61 -0
- package/dist/runtime/components/accordion/index.d.ts +6 -0
- package/dist/runtime/components/accordion/index.js +4 -0
- package/dist/runtime/components/accordion/lib/context.d.ts +34 -0
- package/dist/runtime/components/accordion/lib/context.js +9 -0
- package/dist/runtime/components/action-icon/action-icon.d.vue.ts +11 -1
- package/dist/runtime/components/action-icon/action-icon.module.css +1 -1
- package/dist/runtime/components/action-icon/action-icon.vue +20 -5
- package/dist/runtime/components/action-icon/action-icon.vue.d.ts +11 -1
- package/dist/runtime/components/button/button.d.vue.ts +8 -0
- package/dist/runtime/components/button/button.module.css +1 -1
- package/dist/runtime/components/button/button.vue +17 -4
- package/dist/runtime/components/button/button.vue.d.ts +8 -0
- package/dist/runtime/components/collapse.d.vue.ts +65 -0
- package/dist/runtime/components/collapse.vue +144 -0
- package/dist/runtime/components/collapse.vue.d.ts +65 -0
- package/dist/runtime/components/date-time-picker.d.vue.ts +2 -2
- package/dist/runtime/components/date-time-picker.vue.d.ts +2 -2
- package/dist/runtime/components/dialog/ui/dialog-close-button.vue +5 -0
- package/dist/runtime/components/drawer/drawer-close-button.vue +5 -0
- package/dist/runtime/components/files/file-upload-button.vue +4 -0
- package/dist/runtime/components/files/file-upload-icon.vue +5 -0
- package/dist/runtime/components/index.d.ts +2 -2
- package/dist/runtime/components/index.js +1 -1
- package/dist/runtime/components/input/date-picker.d.vue.ts +2 -2
- package/dist/runtime/components/input/date-picker.vue.d.ts +2 -2
- package/dist/runtime/components/link/lib.d.ts +2 -2
- package/dist/runtime/components/link/link-button.vue +4 -0
- package/dist/runtime/components/modal/modal-close-button.vue +5 -0
- package/dist/runtime/components/nav-link/nav-icon-link.d.vue.ts +5 -11
- package/dist/runtime/components/nav-link/nav-icon-link.vue +12 -8
- package/dist/runtime/components/nav-link/nav-icon-link.vue.d.ts +5 -11
- package/dist/runtime/components/table/ui/table-sortable-header.vue +4 -0
- package/dist/runtime/components/tabs/tabs-root.d.vue.ts +1 -1
- package/dist/runtime/components/tabs/tabs-root.vue.d.ts +1 -1
- package/dist/runtime/components/text.vue +1 -1
- package/dist/runtime/components/theme-toggle.vue +5 -0
- package/dist/runtime/composables/use-config.d.ts +1 -0
- package/dist/runtime/composables/use-config.js +2 -1
- package/dist/runtime/utils/const/active-variants.d.ts +11 -0
- package/dist/runtime/utils/const/active-variants.js +9 -0
- package/dist/runtime/utils/const/index.d.ts +1 -0
- package/dist/runtime/utils/const/index.js +1 -0
- package/package.json +1 -1
- package/dist/runtime/components/accordion.d.vue.ts +0 -79
- package/dist/runtime/components/accordion.vue +0 -44
- package/dist/runtime/components/accordion.vue.d.ts +0 -79
- package/dist/runtime/components/collapsible/collapsible-content.d.vue.ts +0 -18
- package/dist/runtime/components/collapsible/collapsible-content.vue +0 -76
- package/dist/runtime/components/collapsible/collapsible-content.vue.d.ts +0 -18
- package/dist/runtime/components/collapsible/collapsible-root.d.vue.ts +0 -42
- package/dist/runtime/components/collapsible/collapsible-root.vue +0 -41
- package/dist/runtime/components/collapsible/collapsible-root.vue.d.ts +0 -42
- package/dist/runtime/components/collapsible/collapsible-trigger.d.vue.ts +0 -13
- package/dist/runtime/components/collapsible/collapsible-trigger.vue +0 -20
- package/dist/runtime/components/collapsible/collapsible-trigger.vue.d.ts +0 -13
- package/dist/runtime/components/collapsible/index.d.ts +0 -3
- package/dist/runtime/components/collapsible/index.js +0 -1
package/dist/module.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
import { NuanceDefaultThemeColor, NuanceGradient, NuanceIcons } from '../dist/runtime/types/index.js';
|
|
3
|
+
import { ActiveVariantsMap } from '../dist/runtime/utils/index.js';
|
|
3
4
|
|
|
4
5
|
/** Primary color: a theme palette name or an array of 10 shade values (0..9). */
|
|
5
6
|
type PrimaryColor = NuanceDefaultThemeColor | string[];
|
|
@@ -30,6 +31,8 @@ interface ModuleOptions {
|
|
|
30
31
|
gradient?: NuanceGradient;
|
|
31
32
|
/** Icon registry overrides */
|
|
32
33
|
icons?: Partial<NuanceIcons>;
|
|
34
|
+
/** Variant an ActionIcon switches to when `active`, keyed by its base variant */
|
|
35
|
+
activeVariants?: Partial<ActiveVariantsMap>;
|
|
33
36
|
}
|
|
34
37
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
35
38
|
|
package/dist/module.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
import { NuanceDefaultThemeColor, NuanceGradient, NuanceIcons } from '../dist/runtime/types/index.js';
|
|
3
|
+
import { ActiveVariantsMap } from '../dist/runtime/utils/index.js';
|
|
3
4
|
|
|
4
5
|
/** Primary color: a theme palette name or an array of 10 shade values (0..9). */
|
|
5
6
|
type PrimaryColor = NuanceDefaultThemeColor | string[];
|
|
@@ -30,6 +31,8 @@ interface ModuleOptions {
|
|
|
30
31
|
gradient?: NuanceGradient;
|
|
31
32
|
/** Icon registry overrides */
|
|
32
33
|
icons?: Partial<NuanceIcons>;
|
|
34
|
+
/** Variant an ActionIcon switches to when `active`, keyed by its base variant */
|
|
35
|
+
activeVariants?: Partial<ActiveVariantsMap>;
|
|
33
36
|
}
|
|
34
37
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
35
38
|
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineNuxtModule, createResolver, addTypeTemplate, addComponentsDir, addImportsDir, addTemplate } from '@nuxt/kit';
|
|
2
2
|
import { defu } from 'defu';
|
|
3
|
-
import { DEFAULT_ICONS, DEFAULT_GRADIENT } from '../dist/runtime/utils/index.js';
|
|
3
|
+
import { DEFAULT_ACTIVE_VARIANTS, DEFAULT_ICONS, DEFAULT_GRADIENT } from '../dist/runtime/utils/index.js';
|
|
4
4
|
|
|
5
5
|
const SHADES = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
6
6
|
function fromName(name) {
|
|
@@ -73,7 +73,8 @@ const defaultConfig = {
|
|
|
73
73
|
prefix: "N",
|
|
74
74
|
primaryColor: "blue",
|
|
75
75
|
gradient: DEFAULT_GRADIENT,
|
|
76
|
-
icons: DEFAULT_ICONS
|
|
76
|
+
icons: DEFAULT_ICONS,
|
|
77
|
+
activeVariants: DEFAULT_ACTIVE_VARIANTS
|
|
77
78
|
};
|
|
78
79
|
const module$1 = defineNuxtModule({
|
|
79
80
|
meta: {
|
|
@@ -114,7 +115,8 @@ const module$1 = defineNuxtModule({
|
|
|
114
115
|
}
|
|
115
116
|
nuxt.options.appConfig.nui = defu(nuxt.options.appConfig.nui, {
|
|
116
117
|
gradient: options.gradient,
|
|
117
|
-
icons: options.icons
|
|
118
|
+
icons: options.icons,
|
|
119
|
+
activeVariants: options.activeVariants
|
|
118
120
|
});
|
|
119
121
|
addTypeTemplate({
|
|
120
122
|
filename: "types/nui-app-config.d.ts",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { NuanceGradient, NuanceIcons } from './types'
|
|
2
|
+
import type { ActiveVariantsMap } from './utils'
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
declare module '@nuxt/schema' {
|
|
@@ -8,6 +9,8 @@ declare module '@nuxt/schema' {
|
|
|
8
9
|
gradient?: NuanceGradient
|
|
9
10
|
/** Icon registry overrides */
|
|
10
11
|
icons?: Partial<NuanceIcons>
|
|
12
|
+
/** Variant an ActionIcon switches to when `active`, keyed by its base variant */
|
|
13
|
+
activeVariants?: Partial<ActiveVariantsMap>
|
|
11
14
|
}
|
|
12
15
|
}
|
|
13
16
|
|
|
@@ -15,6 +18,7 @@ declare module '@nuxt/schema' {
|
|
|
15
18
|
nui: {
|
|
16
19
|
gradient: NuanceGradient
|
|
17
20
|
icons: NuanceIcons
|
|
21
|
+
activeVariants: ActiveVariantsMap
|
|
18
22
|
}
|
|
19
23
|
}
|
|
20
24
|
}
|
|
@@ -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';
|