fluency-v8-components 1.4.7 → 1.4.9

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.
@@ -1,4 +1,4 @@
1
- import { c as Da, _ as Va, g as il } from "./index-bYQpvhTw.mjs";
1
+ import { c as Da, _ as Va, g as il } from "./index-RvcduEmd.mjs";
2
2
  var fn = {}, cn = {}, cr, vn;
3
3
  function Q() {
4
4
  if (vn) return cr;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluency-v8-components",
3
- "version": "1.4.7",
3
+ "version": "1.4.9",
4
4
  "main": "dist/fluency-v8-components.umd.js",
5
5
  "module": "dist/fluency-v8-components.es.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,90 @@
1
+ <template>
2
+ <Menu as="div" class="relative inline-block text-left">
3
+ <MenuButton
4
+ :class="[
5
+ `group inline-flex justify-center text-${size} font-medium`,
6
+ { 'std-btn std-btn-red': color === 'red' },
7
+ { 'std-btn std-btn-green': color === 'green' },
8
+ { 'std-btn std-btn-blue': color === 'blue' },
9
+ { 'px-3! py-1!': dense },
10
+ ]"
11
+ :disabled="disabled"
12
+ >
13
+ <slot name="btn" />
14
+ </MenuButton>
15
+
16
+ <transition
17
+ enter-active-class="transition ease-out duration-100"
18
+ enter-from-class="transform opacity-0 scale-95"
19
+ enter-to-class="transform opacity-100 scale-100"
20
+ leave-active-class="transition ease-in duration-75"
21
+ leave-from-class="transform opacity-100 scale-100"
22
+ leave-to-class="transform opacity-0 scale-95"
23
+ >
24
+ <MenuItems
25
+ :class="[
26
+ `std-white input-dropdown w-${optionsSize} origin-top-right shadow-lg max-h-96`,
27
+ direction === 'right' ? 'left-0 ' : 'right-0',
28
+ { 'std-red': color === 'red' },
29
+ { 'std-green': color === 'green' },
30
+ { 'std-blue': color === 'blue' },
31
+ { 'std-white': color !== 'red' && color !== 'blue' && color !== 'green' },
32
+ ]"
33
+ >
34
+ <div class="py-1">
35
+ <MenuItem v-for="option in options" :key="option" v-slot="{ active }">
36
+ <span
37
+ :class="[
38
+ { 'outline-hidden': active },
39
+ { 'white-bg-hover dark:dark-bg-hover': color !== 'red' && color !== 'blue' && color !== 'green' && (active || labelMatch(option)) },
40
+ { 'std-red-hover-light': color === 'red' && (active || labelMatch(option)) },
41
+ { 'std-blue-hover-light': color === 'blue' && (active || labelMatch(option)) },
42
+ { 'std-green-hover-light': color === 'green' && (active || labelMatch(option)) },
43
+ `group flex w-full items-center rounded-md px-2 py-2 text-${size} cursor-pointer`,
44
+ ]"
45
+ @click.stop="emits('select', option)"
46
+ >
47
+ {{ option?.label || option }}
48
+ </span>
49
+ </MenuItem>
50
+ </div>
51
+ </MenuItems>
52
+ </transition>
53
+ </Menu>
54
+ </template>
55
+ <script setup>
56
+ import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/vue";
57
+
58
+ // props and emits
59
+ const props = defineProps({
60
+ options: {
61
+ type: Array,
62
+ required: true,
63
+ },
64
+ direction: {
65
+ type: String,
66
+ default: "left",
67
+ },
68
+ optionsSize: {
69
+ type: String,
70
+ default: "40",
71
+ },
72
+ size: {
73
+ type: String,
74
+ default: "xs",
75
+ },
76
+ color: String,
77
+ current: {
78
+ type: String,
79
+ default: "",
80
+ },
81
+ disabled: Boolean,
82
+ dense: Boolean,
83
+ });
84
+ const emits = defineEmits(["select"]);
85
+
86
+ // function defs
87
+ function labelMatch(option) {
88
+ return props.current === option || props.current === option?.label
89
+ }
90
+ </script>
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <TransitionRoot as="template" :show="open">
3
- <Dialog as="div" class="relative z-40" @close="emits('hide')">
3
+ <Dialog as="div" class="relative z-40" @close="hideSlideout">
4
4
  <!--div class="fixed inset-0" /-->
5
5
  <TransitionChild
6
6
  as="template"
@@ -84,11 +84,23 @@ import {
84
84
  import { XMarkIcon } from "@heroicons/vue/24/outline";
85
85
  import { adjustText } from "@/constants/font-map";
86
86
 
87
+ // constants
88
+ const titleWidth = 2800;
89
+
90
+ // props and emits
87
91
  const props = defineProps({
88
92
  open: Boolean,
89
93
  title: String,
90
94
  });
91
95
  const emits = defineEmits(["close", "hide"]);
92
96
 
93
- const titleWidth = 2800;
97
+ // function defs
98
+ function hideSlideout() {
99
+ const dialogs = window.document.querySelectorAll("#headlessui-portal-root");
100
+ if (dialogs && dialogs.length > 0 && dialogs[0].childElementCount > 2) {
101
+ // another dialog is open
102
+ } else {
103
+ emits('hide')
104
+ }
105
+ }
94
106
  </script>
@@ -1,48 +1,21 @@
1
1
  <template>
2
- <Menu as="div" class="relative inline-block text-left">
3
- <MenuButton
4
- :class="`group inline-flex justify-center text-${size} font-medium`"
5
- >
2
+ <Select
3
+ :options="options"
4
+ :current="current.label"
5
+ :direction="direction"
6
+ :size="size"
7
+ @select="emits('sort', $event)"
8
+ >
9
+ <template #btn>
6
10
  <Bars3BottomLeftIcon :class="`${iconSize} mr-2`" />
7
11
  Sort By
8
12
  <ChevronDownIcon :class="`${iconSize} ml-2`" />
9
- </MenuButton>
10
-
11
- <transition
12
- enter-active-class="transition ease-out duration-100"
13
- enter-from-class="transform opacity-0 scale-95"
14
- enter-to-class="transform opacity-100 scale-100"
15
- leave-active-class="transition ease-in duration-75"
16
- leave-from-class="transform opacity-100 scale-100"
17
- leave-to-class="transform opacity-0 scale-95"
18
- >
19
- <MenuItems
20
- :class="[
21
- 'std-white input-dropdown w-40 origin-top-right shadow-lg max-h-96',
22
- direction === 'right' ? 'left-0 ' : 'right-0',
23
- ]"
24
- >
25
- <div class="py-1">
26
- <MenuItem v-for="option in options" :key="option" v-slot="{ active }">
27
- <span
28
- :class="[
29
- active ? 'outline-hidden white-bg-hover dark:dark-bg-hover' : '',
30
- { 'white-bg-hover dark:dark-bg-hover': current.label === option.label },
31
- `group flex w-full items-center rounded-md px-2 py-2 text-${size} cursor-pointer`,
32
- ]"
33
- @click.stop="emits('sort', option)"
34
- >
35
- {{ option.label }}
36
- </span>
37
- </MenuItem>
38
- </div>
39
- </MenuItems>
40
- </transition>
41
- </Menu>
13
+ </template>
14
+ </Select>
42
15
  </template>
43
16
  <script setup>
44
17
  import { computed } from "vue";
45
- import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/vue";
18
+ import Select from "./Select.vue"
46
19
  import {
47
20
  Bars3BottomLeftIcon,
48
21
  ChevronDownIcon,
@@ -49,8 +49,6 @@ export { default as ActionButtons } from "./buttons/ActionButtons.vue";
49
49
  export { default as TextButton } from "./buttons/TextButton.vue";
50
50
  export { default as IconButton } from "./buttons/IconButton.vue";
51
51
  export { default as ImageButton } from "./buttons/ImageButton.vue";
52
- export { default as DropdownButton } from "./buttons/DropdownButton.vue";
53
- export { default as MenuButton } from "./buttons/MenuButton.vue";
54
52
  export { default as SubmitButtons } from "./buttons/SubmitButtons.vue";
55
53
 
56
54
  // statuses
@@ -102,6 +100,7 @@ export { default as Feed } from "./common/Feed.vue";
102
100
  export { default as CategoryCard } from "./common/CategoryCard.vue";
103
101
  export { default as EditorHeading } from "./common/EditorHeading.vue";
104
102
  export { default as CodeEditor } from "./common/CodeEditor.vue";
103
+ export { default as Select } from "./common/Select.vue";
105
104
  export { default as Sort } from "./common/Sort.vue";
106
105
  export { default as Flag } from "./common/Flag.vue";
107
106
  export { default as ThreeHomePanel } from "./common/ThreeHomePanel.vue";
@@ -1,4 +1,3 @@
1
- <!-- TODO: dark mode -->
2
1
  <template>
3
2
  <TransitionRoot as="template" :show="open">
4
3
  <Dialog
@@ -34,7 +33,7 @@
34
33
  </div>
35
34
  <div class="ml-auto pl-3">
36
35
  <div class="-mx-1.5 -my-1.5">
37
- <IconButton :color="getColor()" @click="closeModal">
36
+ <IconButton :color="getColor()" @click.stop="closeModal">
38
37
  <XMarkIcon class="icon-md" aria-hidden="true" />
39
38
  </IconButton>
40
39
  </div>
@@ -72,7 +71,7 @@
72
71
  </div>
73
72
  <div class="ml-auto pl-3">
74
73
  <div class="-mx-1.5 -my-1.5">
75
- <IconButton :color="getColor()" @click="closeModal">
74
+ <IconButton :color="getColor()" @click.stop="closeModal">
76
75
  <XMarkIcon class="icon-md" aria-hidden="true" />
77
76
  </IconButton>
78
77
  </div>
@@ -1,104 +0,0 @@
1
- <template>
2
- <Menu as="div" class="relative">
3
- <div class="std-btn py-0">
4
- <div
5
- :class="[
6
- 'rounded-l-lg px-5 py-3 cursor-pointer',
7
- { 'std-btn-red': color === 'red' },
8
- { 'std-btn-green': color === 'green' },
9
- { 'std-btn-blue': color === 'blue' },
10
- ]"
11
- @click="loading ? null : emits('mainClick')"
12
- >
13
- <div v-if="loading" class="mx-2 inline-block spinner"></div>
14
- <div v-else class="flex">
15
- <slot />
16
- {{ props.text }}
17
- </div>
18
- </div>
19
- <MenuButton
20
- :class="[
21
- 'rounded-r-lg px-1 py-3 border-l-2 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50',
22
- { 'std-btn-red': color === 'red' },
23
- { 'std-btn-green': color === 'green' },
24
- { 'std-btn-blue': color === 'blue' },
25
- ]"
26
- :disabled="secondaryButtons.length === 0 || loading"
27
- @click="dropdown = !dropdown"
28
- >
29
- <ArrowDownIcon v-if="!dropdown" class="icon-md" />
30
- <ArrowUpIcon v-else class="icon-md" />
31
- </MenuButton>
32
- </div>
33
- <Transition
34
- enter="transition ease-out duration-75"
35
- enterFrom="opacity-0 scale-95"
36
- enterTo="opacity-100 scale-100"
37
- leave="transition ease-in duration-100"
38
- leaveFrom="opacity-100 scale-100"
39
- leaveTo="opacity-0 scale-95"
40
- >
41
- <MenuItems
42
- :class="[
43
- 'absolute right-0 z-50 mt-0.5 w-32 origin-top-right rounded-md py-2 shadow-lg text-white max-h-96 overflow-y-auto break-all',
44
- { 'std-red': color === 'red' },
45
- { 'std-green': color === 'green' },
46
- { 'std-blue': color === 'blue' },
47
- ]"
48
- >
49
- <MenuItem v-for="button in sortedButtons" v-slot="{ active }">
50
- <div
51
- :class="[
52
- active ? 'cursor-pointer' : '',
53
- 'block px-3 py-1 text-sm leading-6',
54
- { 'std-btn-red': color === 'red' },
55
- { 'std-btn-green': color === 'green' },
56
- { 'std-btn-blue': color === 'blue' },
57
- ]"
58
- @click="loading ? null : emits('secondaryClick', button)"
59
- >
60
- {{ button }}
61
- </div>
62
- </MenuItem>
63
- </MenuItems>
64
- </Transition>
65
- </Menu>
66
- </template>
67
-
68
- <script setup>
69
- import { ref, computed } from "vue";
70
- import { ArrowDownIcon, ArrowUpIcon } from "@heroicons/vue/20/solid";
71
- import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/vue";
72
-
73
- const props = defineProps({
74
- text: {
75
- type: String,
76
- required: true,
77
- },
78
- color: {
79
- type: String,
80
- default: "blue",
81
- validator: (value) => ["red", "green", "blue"].includes(value),
82
- },
83
- loading: {
84
- type: Boolean,
85
- default: false,
86
- },
87
- secondaryButtons: {
88
- type: Array,
89
- default: () => [],
90
- },
91
- sorted: {
92
- type: Boolean,
93
- default: false,
94
- },
95
- });
96
- const emits = defineEmits(["mainClick", "secondaryClick"]);
97
- const dropdown = ref(false);
98
-
99
- const sortedButtons = computed(() => {
100
- return props.sorted
101
- ? props.secondaryButtons.sort((a, b) => a.localeCompare(b))
102
- : props.secondaryButtons;
103
- });
104
- </script>
@@ -1,135 +0,0 @@
1
- <template>
2
- <Menu
3
- as="div"
4
- :class="[
5
- 'relative',
6
- { 'px-3 py-1': dense },
7
- { 'std-btn-red': color === 'red' },
8
- { 'std-btn-green': color === 'green' },
9
- { 'std-btn-blue': color === 'blue' },
10
- { 'std-btn': type === 'button' },
11
- { 'std-white-text': color === 'none' },
12
- { 'cursor-not-allowed': disabled },
13
- ]"
14
- >
15
- <MenuButton class="row" :disabled="disabled || loading">
16
- {{ props.text }}
17
- <ArrowDownIcon v-if="type === 'button'" class="icon-md" />
18
- <slot />
19
- </MenuButton>
20
- <Transition
21
- enter="transition ease-out duration-75"
22
- enterFrom="opacity-0 scale-95"
23
- enterTo="opacity-100 scale-100"
24
- leave="transition ease-in duration-100"
25
- leaveFrom="opacity-100 scale-100"
26
- leaveTo="opacity-0 scale-95"
27
- >
28
- <MenuItems
29
- :class="[
30
- 'absolute right-0 top-full z-50 mt-0.5 rounded-lg py-2 shadow-lg max-h-96 overflow-y-auto break-all',
31
- { 'std-red': color === 'red' },
32
- { 'std-green': color === 'green' },
33
- { 'std-blue': color === 'blue' },
34
- { 'std-white': color === 'none' },
35
- { 'right-0': anchor === 'right' },
36
- { 'left-0': anchor === 'left' },
37
- ]"
38
- anchor="bottom-start"
39
- >
40
- <MenuItem v-for="button in sortedButtons" v-slot="{ active }">
41
- <div
42
- :class="[
43
- active ? 'cursor-pointer' : '',
44
- 'block px-3 py-1 text-sm leading-6 min-w-44',
45
- { 'std-btn-red': color === 'red' },
46
- { 'std-btn-green': color === 'green' },
47
- { 'std-btn-blue': color === 'blue' },
48
- {
49
- 'std-btn-white': active && color === 'none',
50
- },
51
- ]"
52
- @click="secondaryClick(button)"
53
- >
54
- {{ button.name || button }}
55
- </div>
56
- </MenuItem>
57
- <slot name="items" />
58
- </MenuItems>
59
- </Transition>
60
- </Menu>
61
- </template>
62
-
63
- <script setup>
64
- import { computed } from "vue";
65
- import { ArrowDownIcon } from "@heroicons/vue/20/solid";
66
- import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/vue";
67
-
68
- const props = defineProps({
69
- text: {
70
- type: String,
71
- default: "",
72
- },
73
- color: {
74
- type: String,
75
- default: "blue",
76
- },
77
- disabled: {
78
- type: Boolean,
79
- default: false,
80
- },
81
- dense: {
82
- type: Boolean,
83
- default: false,
84
- },
85
- loading: {
86
- type: Boolean,
87
- default: false,
88
- },
89
- secondaryButtons: {
90
- type: Array,
91
- default: () => [],
92
- },
93
- anchor: {
94
- type: String,
95
- default: "right",
96
- },
97
- type: {
98
- type: String,
99
- default: "button",
100
- },
101
- emitValue: {
102
- type: Boolean,
103
- default: true,
104
- },
105
- sorted: {
106
- type: Boolean,
107
- default: false,
108
- },
109
- });
110
- const emits = defineEmits(["secondaryClick"]);
111
-
112
- const sortedButtons = computed(() => {
113
- if (props.sorted) {
114
- return props.secondaryButtons.sort((a, b) => {
115
- if (a.name && b.name) {
116
- return a.name.localeCompare(b.name);
117
- }
118
- return a.localeCompare(b);
119
- });
120
- }
121
- return props.secondaryButtons;
122
- });
123
-
124
- function secondaryClick(button) {
125
- if (props.disabled || props.loading) {
126
- return;
127
- }
128
-
129
- if (props.emitValue) {
130
- emits("secondaryClick", button.name || button);
131
- } else {
132
- emits("secondaryClick", button);
133
- }
134
- }
135
- </script>