@aleph-alpha/ui-library 1.16.1 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/system/index-DWkO1UL8.js +8 -0
- package/dist/system/index-gkRbLfbP.js +8 -0
- package/dist/system/index.d.ts +585 -402
- package/dist/system/lib.js +14146 -13574
- package/package.json +2 -2
- package/src/components/UiChip/UiChip.stories.ts +239 -0
- package/src/components/UiChip/UiChip.vue +128 -0
- package/src/components/UiChip/__tests__/UiChip.test.ts +102 -0
- package/src/components/UiChip/index.ts +2 -0
- package/src/components/UiChip/types.ts +50 -0
- package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +259 -1
- package/src/components/UiDropdownMenu/UiDropdownMenuRadioGroup.vue +1 -1
- package/src/components/UiField/UiField.stories.ts +589 -249
- package/src/components/UiField/UiField.vue +87 -2
- package/src/components/UiField/UiFieldDescription.vue +22 -1
- package/src/components/UiField/UiFieldLabel.vue +2 -0
- package/src/components/UiField/UiFieldLabelInfo.vue +22 -0
- package/src/components/UiField/index.ts +1 -0
- package/src/components/UiField/keys.ts +5 -0
- package/src/components/UiField/types.ts +86 -1
- package/src/components/UiSelect/__tests__/UiSelectTrigger.test.ts +47 -2
- package/src/components/UiToggle/UiToggle.stories.ts +54 -1
- package/src/components/UiToggle/__tests__/UiToggle.test.ts +15 -0
- package/src/components/UiToggle/types.ts +1 -1
- package/src/components/UiToggleGroup/__tests__/UiToggleGroup.test.ts +21 -0
- package/src/components/UiToggleGroup/types.ts +2 -2
- package/src/components/core/button/index.ts +5 -0
- package/src/components/core/field/FieldLabel.vue +1 -1
- package/src/components/core/field/index.ts +5 -5
- package/src/components/core/select/SelectTrigger.vue +1 -1
- package/src/components/core/toggle/Toggle.vue +3 -3
- package/src/components/core/toggle/index.ts +6 -3
- package/src/components/core/toggle-group/index.ts +6 -3
- package/src/components/index.ts +1 -0
- package/dist/system/index-CkH7HQaa.js +0 -7
- package/dist/system/index-CuHwEAQ_.js +0 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
|
-
import { ref, watch } from 'vue';
|
|
2
|
+
import { computed, ref, watch } from 'vue';
|
|
3
3
|
import {
|
|
4
4
|
UiDropdownMenu,
|
|
5
5
|
UiDropdownMenuTrigger,
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
} from './index';
|
|
19
19
|
import UiButton from '../UiButton/UiButton.vue';
|
|
20
20
|
import UiIconButton from '../UiIconButton/UiIconButton.vue';
|
|
21
|
+
import UiToggle from '../UiToggle/UiToggle.vue';
|
|
21
22
|
import { UiIcon } from '../UiIcon';
|
|
22
23
|
|
|
23
24
|
const meta: Meta<typeof UiDropdownMenu> = {
|
|
@@ -758,3 +759,260 @@ export const WithIconButton: Story = {
|
|
|
758
759
|
},
|
|
759
760
|
},
|
|
760
761
|
};
|
|
762
|
+
|
|
763
|
+
const softToggleTriggerTemplateSource = `<script setup lang="ts">
|
|
764
|
+
import { computed, ref } from 'vue'
|
|
765
|
+
import {
|
|
766
|
+
UiDropdownMenu,
|
|
767
|
+
UiDropdownMenuTrigger,
|
|
768
|
+
UiDropdownMenuContent,
|
|
769
|
+
UiDropdownMenuItem,
|
|
770
|
+
UiDropdownMenuSeparator,
|
|
771
|
+
UiToggle,
|
|
772
|
+
UiIcon,
|
|
773
|
+
} from '@aleph-alpha/ui-library'
|
|
774
|
+
|
|
775
|
+
const open = ref(false)
|
|
776
|
+
const activeFilter = ref('')
|
|
777
|
+
const hasFilter = computed(() => !!activeFilter.value)
|
|
778
|
+
const toggleVariant = computed(() => {
|
|
779
|
+
if (open.value) return 'soft'
|
|
780
|
+
if (hasFilter.value) return 'outline'
|
|
781
|
+
return 'default'
|
|
782
|
+
})
|
|
783
|
+
const toggleActive = computed({
|
|
784
|
+
get: () => open.value,
|
|
785
|
+
set: () => {},
|
|
786
|
+
})
|
|
787
|
+
</script>
|
|
788
|
+
|
|
789
|
+
<template>
|
|
790
|
+
<UiDropdownMenu v-model:open="open">
|
|
791
|
+
<UiDropdownMenuTrigger as-child>
|
|
792
|
+
<UiToggle v-model="toggleActive" :variant="toggleVariant" aria-label="Filter options">
|
|
793
|
+
<UiIcon name="filter" />
|
|
794
|
+
</UiToggle>
|
|
795
|
+
</UiDropdownMenuTrigger>
|
|
796
|
+
<UiDropdownMenuContent>
|
|
797
|
+
<UiDropdownMenuItem @select="activeFilter = 'name'">By Name</UiDropdownMenuItem>
|
|
798
|
+
<UiDropdownMenuItem @select="activeFilter = 'date'">By Date</UiDropdownMenuItem>
|
|
799
|
+
<UiDropdownMenuItem @select="activeFilter = 'size'">By Size</UiDropdownMenuItem>
|
|
800
|
+
<UiDropdownMenuSeparator />
|
|
801
|
+
<UiDropdownMenuItem @select="activeFilter = ''">Clear Filters</UiDropdownMenuItem>
|
|
802
|
+
</UiDropdownMenuContent>
|
|
803
|
+
</UiDropdownMenu>
|
|
804
|
+
</template>`;
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* Dropdown menu with a soft toggle trigger. Switches to outline variant
|
|
808
|
+
* when a filter is selected, and back to default when filters are cleared.
|
|
809
|
+
*/
|
|
810
|
+
export const WithSoftToggleTrigger: Story = {
|
|
811
|
+
render: (args) => ({
|
|
812
|
+
components: {
|
|
813
|
+
UiDropdownMenu,
|
|
814
|
+
UiDropdownMenuTrigger,
|
|
815
|
+
UiDropdownMenuContent,
|
|
816
|
+
UiDropdownMenuItem,
|
|
817
|
+
UiDropdownMenuSeparator,
|
|
818
|
+
UiToggle,
|
|
819
|
+
UiIcon,
|
|
820
|
+
},
|
|
821
|
+
setup() {
|
|
822
|
+
const open = ref(args.open);
|
|
823
|
+
const modal = ref(args.modal);
|
|
824
|
+
const activeFilter = ref('');
|
|
825
|
+
const hasFilter = computed(() => !!activeFilter.value);
|
|
826
|
+
const toggleVariant = computed(() => {
|
|
827
|
+
if (open.value) return 'soft';
|
|
828
|
+
if (hasFilter.value) return 'outline';
|
|
829
|
+
return 'default';
|
|
830
|
+
});
|
|
831
|
+
const toggleActive = computed({
|
|
832
|
+
get: () => open.value,
|
|
833
|
+
set: (value: boolean) => {
|
|
834
|
+
open.value = value;
|
|
835
|
+
},
|
|
836
|
+
});
|
|
837
|
+
watch(
|
|
838
|
+
() => args.open,
|
|
839
|
+
(v) => {
|
|
840
|
+
open.value = v;
|
|
841
|
+
},
|
|
842
|
+
);
|
|
843
|
+
watch(
|
|
844
|
+
() => args.modal,
|
|
845
|
+
(v) => {
|
|
846
|
+
modal.value = v;
|
|
847
|
+
},
|
|
848
|
+
);
|
|
849
|
+
return { open, modal, activeFilter, hasFilter, toggleVariant, toggleActive };
|
|
850
|
+
},
|
|
851
|
+
template: `<UiDropdownMenu v-model:open="open" :modal="modal">
|
|
852
|
+
<UiDropdownMenuTrigger as-child>
|
|
853
|
+
<UiToggle v-model="toggleActive" :variant="toggleVariant" aria-label="Filter options">
|
|
854
|
+
<UiIcon name="filter" />
|
|
855
|
+
</UiToggle>
|
|
856
|
+
</UiDropdownMenuTrigger>
|
|
857
|
+
<UiDropdownMenuContent>
|
|
858
|
+
<UiDropdownMenuItem @select="activeFilter = 'name'">By Name</UiDropdownMenuItem>
|
|
859
|
+
<UiDropdownMenuItem @select="activeFilter = 'date'">By Date</UiDropdownMenuItem>
|
|
860
|
+
<UiDropdownMenuItem @select="activeFilter = 'size'">By Size</UiDropdownMenuItem>
|
|
861
|
+
<UiDropdownMenuSeparator />
|
|
862
|
+
<UiDropdownMenuItem @select="activeFilter = ''">Clear Filters</UiDropdownMenuItem>
|
|
863
|
+
</UiDropdownMenuContent>
|
|
864
|
+
</UiDropdownMenu>`,
|
|
865
|
+
}),
|
|
866
|
+
parameters: {
|
|
867
|
+
docs: {
|
|
868
|
+
source: {
|
|
869
|
+
code: softToggleTriggerTemplateSource,
|
|
870
|
+
},
|
|
871
|
+
},
|
|
872
|
+
},
|
|
873
|
+
};
|
|
874
|
+
|
|
875
|
+
const softToggleTriggerWithTextTemplateSource = `<script setup lang="ts">
|
|
876
|
+
import { computed, ref } from 'vue'
|
|
877
|
+
import {
|
|
878
|
+
UiDropdownMenu,
|
|
879
|
+
UiDropdownMenuTrigger,
|
|
880
|
+
UiDropdownMenuContent,
|
|
881
|
+
UiDropdownMenuLabel,
|
|
882
|
+
UiDropdownMenuSeparator,
|
|
883
|
+
UiDropdownMenuCheckboxItem,
|
|
884
|
+
UiToggle,
|
|
885
|
+
UiIcon,
|
|
886
|
+
} from '@aleph-alpha/ui-library'
|
|
887
|
+
|
|
888
|
+
const open = ref(false)
|
|
889
|
+
const showPreview = ref(false)
|
|
890
|
+
const showMetadata = ref(false)
|
|
891
|
+
const showTimestamps = ref(false)
|
|
892
|
+
const hasSelection = computed(() => showPreview.value || showMetadata.value || showTimestamps.value)
|
|
893
|
+
const toggleVariant = computed(() => {
|
|
894
|
+
if (open.value) return 'soft'
|
|
895
|
+
if (hasSelection.value) return 'outline'
|
|
896
|
+
return 'default'
|
|
897
|
+
})
|
|
898
|
+
const toggleActive = computed({
|
|
899
|
+
get: () => open.value,
|
|
900
|
+
set: () => {},
|
|
901
|
+
})
|
|
902
|
+
</script>
|
|
903
|
+
|
|
904
|
+
<template>
|
|
905
|
+
<UiDropdownMenu v-model:open="open">
|
|
906
|
+
<UiDropdownMenuTrigger as-child>
|
|
907
|
+
<UiToggle v-model="toggleActive" :variant="toggleVariant" aria-label="View settings">
|
|
908
|
+
<UiIcon name="settings" />
|
|
909
|
+
View
|
|
910
|
+
<UiIcon name="chevron-down" class="size-3" />
|
|
911
|
+
</UiToggle>
|
|
912
|
+
</UiDropdownMenuTrigger>
|
|
913
|
+
<UiDropdownMenuContent class="w-48">
|
|
914
|
+
<UiDropdownMenuLabel>Display Options</UiDropdownMenuLabel>
|
|
915
|
+
<UiDropdownMenuSeparator />
|
|
916
|
+
<UiDropdownMenuCheckboxItem v-model:checked="showPreview">
|
|
917
|
+
Show Preview
|
|
918
|
+
</UiDropdownMenuCheckboxItem>
|
|
919
|
+
<UiDropdownMenuCheckboxItem v-model:checked="showMetadata">
|
|
920
|
+
Show Metadata
|
|
921
|
+
</UiDropdownMenuCheckboxItem>
|
|
922
|
+
<UiDropdownMenuCheckboxItem v-model:checked="showTimestamps">
|
|
923
|
+
Show Timestamps
|
|
924
|
+
</UiDropdownMenuCheckboxItem>
|
|
925
|
+
</UiDropdownMenuContent>
|
|
926
|
+
</UiDropdownMenu>
|
|
927
|
+
</template>`;
|
|
928
|
+
|
|
929
|
+
/**
|
|
930
|
+
* Dropdown menu with a toggle trigger that switches to outline variant
|
|
931
|
+
* when any checkbox option is selected. Unchecking all reverts to default.
|
|
932
|
+
*/
|
|
933
|
+
export const WithSoftToggleTriggerAndText: Story = {
|
|
934
|
+
render: (args) => ({
|
|
935
|
+
components: {
|
|
936
|
+
UiDropdownMenu,
|
|
937
|
+
UiDropdownMenuTrigger,
|
|
938
|
+
UiDropdownMenuContent,
|
|
939
|
+
UiDropdownMenuLabel,
|
|
940
|
+
UiDropdownMenuSeparator,
|
|
941
|
+
UiDropdownMenuCheckboxItem,
|
|
942
|
+
UiToggle,
|
|
943
|
+
UiIcon,
|
|
944
|
+
},
|
|
945
|
+
setup() {
|
|
946
|
+
const open = ref(args.open);
|
|
947
|
+
const modal = ref(args.modal);
|
|
948
|
+
const showPreview = ref(false);
|
|
949
|
+
const showMetadata = ref(false);
|
|
950
|
+
const showTimestamps = ref(false);
|
|
951
|
+
const hasSelection = computed(
|
|
952
|
+
() => showPreview.value || showMetadata.value || showTimestamps.value,
|
|
953
|
+
);
|
|
954
|
+
const toggleVariant = computed(() => {
|
|
955
|
+
if (open.value) return 'soft';
|
|
956
|
+
if (hasSelection.value) return 'outline';
|
|
957
|
+
return 'default';
|
|
958
|
+
});
|
|
959
|
+
const toggleActive = computed({
|
|
960
|
+
get: () => open.value,
|
|
961
|
+
set: (value: boolean) => {
|
|
962
|
+
open.value = value;
|
|
963
|
+
},
|
|
964
|
+
});
|
|
965
|
+
watch(
|
|
966
|
+
() => args.open,
|
|
967
|
+
(v) => {
|
|
968
|
+
open.value = v;
|
|
969
|
+
},
|
|
970
|
+
);
|
|
971
|
+
watch(
|
|
972
|
+
() => args.modal,
|
|
973
|
+
(v) => {
|
|
974
|
+
modal.value = v;
|
|
975
|
+
},
|
|
976
|
+
);
|
|
977
|
+
return {
|
|
978
|
+
open,
|
|
979
|
+
modal,
|
|
980
|
+
showPreview,
|
|
981
|
+
showMetadata,
|
|
982
|
+
showTimestamps,
|
|
983
|
+
hasSelection,
|
|
984
|
+
toggleVariant,
|
|
985
|
+
toggleActive,
|
|
986
|
+
};
|
|
987
|
+
},
|
|
988
|
+
template: `<UiDropdownMenu v-model:open="open" :modal="modal">
|
|
989
|
+
<UiDropdownMenuTrigger as-child>
|
|
990
|
+
<UiToggle v-model="toggleActive" :variant="toggleVariant" aria-label="View settings">
|
|
991
|
+
<UiIcon name="settings" />
|
|
992
|
+
View
|
|
993
|
+
<UiIcon name="chevron-down" class="size-3" />
|
|
994
|
+
</UiToggle>
|
|
995
|
+
</UiDropdownMenuTrigger>
|
|
996
|
+
<UiDropdownMenuContent class="w-48">
|
|
997
|
+
<UiDropdownMenuLabel>Display Options</UiDropdownMenuLabel>
|
|
998
|
+
<UiDropdownMenuSeparator />
|
|
999
|
+
<UiDropdownMenuCheckboxItem v-model:checked="showPreview">
|
|
1000
|
+
Show Preview
|
|
1001
|
+
</UiDropdownMenuCheckboxItem>
|
|
1002
|
+
<UiDropdownMenuCheckboxItem v-model:checked="showMetadata">
|
|
1003
|
+
Show Metadata
|
|
1004
|
+
</UiDropdownMenuCheckboxItem>
|
|
1005
|
+
<UiDropdownMenuCheckboxItem v-model:checked="showTimestamps">
|
|
1006
|
+
Show Timestamps
|
|
1007
|
+
</UiDropdownMenuCheckboxItem>
|
|
1008
|
+
</UiDropdownMenuContent>
|
|
1009
|
+
</UiDropdownMenu>`,
|
|
1010
|
+
}),
|
|
1011
|
+
parameters: {
|
|
1012
|
+
docs: {
|
|
1013
|
+
source: {
|
|
1014
|
+
code: softToggleTriggerWithTextTemplateSource,
|
|
1015
|
+
},
|
|
1016
|
+
},
|
|
1017
|
+
},
|
|
1018
|
+
};
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<template>
|
|
14
14
|
<ShadcnDropdownMenuRadioGroup
|
|
15
15
|
:model-value="props.modelValue"
|
|
16
|
-
@update:model-value="emit('update:modelValue', $event)"
|
|
16
|
+
@update:model-value="emit('update:modelValue', $event as string)"
|
|
17
17
|
>
|
|
18
18
|
<slot />
|
|
19
19
|
</ShadcnDropdownMenuRadioGroup>
|