@proj-airi/ui 0.4.23 → 0.4.26-beta.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.
@@ -31,6 +31,10 @@ function updateTrackColor() {
31
31
  sliderRef.value.style.setProperty("--min", !sliderRef.value.min ? props.min.toString() : sliderRef.value.min);
32
32
  sliderRef.value.style.setProperty("--max", !sliderRef.value.max ? props.max.toString() : sliderRef.value.max);
33
33
  }
34
+ function handleInput(e) {
35
+ const target = e.target;
36
+ target.style.setProperty("--value", target.value);
37
+ }
34
38
  </script>
35
39
 
36
40
  <template>
@@ -42,9 +46,7 @@ function updateTrackColor() {
42
46
  :max="scaledMax"
43
47
  :step="scaledStep"
44
48
  class="slider-progress form_input-range"
45
- @input="(e) => {
46
- (e.target as HTMLInputElement).style.setProperty('--value', (e.target as HTMLInputElement).value)
47
- }"
49
+ @input="handleInput"
48
50
  >
49
51
  </template>
50
52
 
@@ -0,0 +1,98 @@
1
+ <script setup>
2
+ import { Dropdown as VDropdown } from "floating-vue";
3
+ import { computed } from "vue";
4
+ const props = defineProps({
5
+ options: { type: Array, required: true },
6
+ placeholder: { type: String, required: false },
7
+ disabled: { type: Boolean, required: false },
8
+ title: { type: String, required: false }
9
+ });
10
+ const modelValue = defineModel({ type: [String, Number], ...{ required: true } });
11
+ const selectedLabel = computed(() => {
12
+ const selected = props.options.find((opt) => opt.value === modelValue.value);
13
+ return selected ? selected.label : props.placeholder;
14
+ });
15
+ function selectOption(value) {
16
+ modelValue.value = value;
17
+ }
18
+ </script>
19
+
20
+ <template>
21
+ <VDropdown
22
+ auto-size
23
+ auto-boundary-max-size
24
+ >
25
+ <div
26
+ class="min-w-[160px] flex cursor-pointer items-center justify-between gap-2 border rounded-lg bg-white p-2.5 text-xs text-neutral-700 shadow-sm outline-none transition-colors disabled:cursor-not-allowed dark:border-neutral-800 dark:bg-neutral-900 disabled:bg-neutral-100 hover:bg-neutral-50 dark:text-neutral-200 disabled:text-neutral-400 focus:ring-2 focus:ring-black/10 dark:disabled:bg-neutral-800 dark:hover:bg-neutral-800 dark:disabled:text-neutral-600"
27
+ :class="{ 'pointer-events-none': props.disabled }"
28
+ >
29
+ <div class="flex-1 truncate">
30
+ <slot :label="selectedLabel">
31
+ {{ selectedLabel }}
32
+ </slot>
33
+ </div>
34
+ <div i-solar:alt-arrow-down-bold-duotone class="h-3.5 w-3.5 text-neutral-500 dark:text-neutral-400" />
35
+ </div>
36
+
37
+ <template #popper="{ hide }">
38
+ <div class="min-w-[160px] flex flex-col gap-0.5 border border-neutral-200 rounded-lg bg-white p-1 shadow-lg dark:border-neutral-800 dark:bg-neutral-900">
39
+ <div
40
+ v-for="option of props.options"
41
+ v-bind="{ ...$attrs, class: null, style: null }"
42
+ :key="option.value"
43
+ class="cursor-pointer rounded px-2 py-1.5 text-sm text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800"
44
+ :class="{
45
+ 'bg-neutral-100 dark:bg-neutral-800': modelValue === option.value,
46
+ }"
47
+ @click="selectOption(option.value); hide()"
48
+ >
49
+ {{ option.label }}
50
+ </div>
51
+ </div>
52
+ </template>
53
+ </VDropdown>
54
+ </template>
55
+
56
+ <style>
57
+ .resize-observer[data-v-b329ee4c] {
58
+ position: absolute;
59
+ top: 0;
60
+ left: 0;
61
+ z-index: -1;
62
+ width: 100%;
63
+ height: 100%;
64
+ border: none;
65
+ background-color: transparent;
66
+ pointer-events: none;
67
+ display: block;
68
+ overflow: hidden;
69
+ opacity: 0;
70
+ }
71
+
72
+ .resize-observer[data-v-b329ee4c] object {
73
+ display: block;
74
+ position: absolute;
75
+ top: 0;
76
+ left: 0;
77
+ height: 100%;
78
+ width: 100%;
79
+ overflow: hidden;
80
+ pointer-events: none;
81
+ z-index: -1;
82
+ }
83
+
84
+ .v-popper__popper {
85
+ z-index: 10000;
86
+ top: 0;
87
+ left: 0;
88
+ outline: none;
89
+ }
90
+
91
+ .v-popper__arrow-container {
92
+ display: none;
93
+ }
94
+
95
+ .v-popper__inner {
96
+ border: none !important;
97
+ }
98
+ </style>
@@ -0,0 +1 @@
1
+ export { default as Select } from './Select.vue';
@@ -0,0 +1 @@
1
+ export { default as Select } from "./Select.vue";
@@ -6,9 +6,12 @@ const modelValue = defineModel({ type: String, ...{ default: "" } });
6
6
  <template>
7
7
  <BasicTextarea
8
8
  v-model="modelValue"
9
- border="neutral-100 dark:neutral-800 solid 2 focus:neutral-200 dark:focus:neutral-700"
10
- transition="all duration-250 ease-in-out"
11
- bg="neutral-100 dark:neutral-800 focus:neutral-50 dark:focus:neutral-900"
12
- rounded-lg px-3 py-2 text-sm outline-none
9
+ border="focus:primary-300 dark:focus:primary-400/50 2 solid neutral-100 dark:neutral-900"
10
+ transition="all duration-200 ease-in-out"
11
+ text="disabled:neutral-400 dark:disabled:neutral-600"
12
+ cursor="disabled:not-allowed"
13
+ w-full rounded-lg px-3 py-2 text-sm outline-none
14
+ shadow="sm"
15
+ bg="neutral-50 dark:neutral-950 focus:neutral-50 dark:focus:neutral-900"
13
16
  />
14
17
  </template>
@@ -3,4 +3,5 @@ export * from './Field';
3
3
  export * from './Input';
4
4
  export * from './Radio';
5
5
  export * from './Range';
6
+ export * from './Select';
6
7
  export * from './Textarea';
@@ -3,4 +3,5 @@ export * from "./Field/index.mjs";
3
3
  export * from "./Input/index.mjs";
4
4
  export * from "./Radio/index.mjs";
5
5
  export * from "./Range/index.mjs";
6
+ export * from "./Select/index.mjs";
6
7
  export * from "./Textarea/index.mjs";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@proj-airi/ui",
3
3
  "type": "module",
4
- "version": "0.4.23",
4
+ "version": "0.4.26-beta.1",
5
5
  "description": "A collection of UI components that used by Project AIRI",
6
6
  "author": {
7
7
  "name": "Neko Ayaka",
@@ -30,6 +30,7 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@vueuse/core": "^13.1.0",
33
+ "floating-vue": "^5.2.2",
33
34
  "reka-ui": "^2.2.0",
34
35
  "vue": "^3.5.13"
35
36
  },
@@ -46,6 +46,11 @@ function updateTrackColor() {
46
46
  sliderRef.value.style.setProperty('--min', !sliderRef.value.min ? props.min.toString() : sliderRef.value.min)
47
47
  sliderRef.value.style.setProperty('--max', !sliderRef.value.max ? props.max.toString() : sliderRef.value.max)
48
48
  }
49
+
50
+ function handleInput(e: Event) {
51
+ const target = e.target as HTMLInputElement
52
+ target.style.setProperty('--value', target.value)
53
+ }
49
54
  </script>
50
55
 
51
56
  <template>
@@ -57,9 +62,7 @@ function updateTrackColor() {
57
62
  :max="scaledMax"
58
63
  :step="scaledStep"
59
64
  class="slider-progress form_input-range"
60
- @input="(e) => {
61
- (e.target as HTMLInputElement).style.setProperty('--value', (e.target as HTMLInputElement).value)
62
- }"
65
+ @input="handleInput"
63
66
  >
64
67
  </template>
65
68
 
@@ -0,0 +1,102 @@
1
+ <script setup lang="ts">
2
+ import { Dropdown as VDropdown } from 'floating-vue'
3
+ import { computed } from 'vue'
4
+
5
+ const props = defineProps<{
6
+ options: { label: string, value: string | number }[]
7
+ placeholder?: string
8
+ disabled?: boolean
9
+ title?: string
10
+ }>()
11
+
12
+ const modelValue = defineModel<string | number>({ required: true })
13
+
14
+ const selectedLabel = computed(() => {
15
+ const selected = props.options.find(opt => opt.value === modelValue.value)
16
+ return selected ? selected.label : props.placeholder
17
+ })
18
+
19
+ function selectOption(value: string | number) {
20
+ modelValue.value = value
21
+ }
22
+ </script>
23
+
24
+ <template>
25
+ <VDropdown
26
+ auto-size
27
+ auto-boundary-max-size
28
+ >
29
+ <div
30
+ class="min-w-[160px] flex cursor-pointer items-center justify-between gap-2 border rounded-lg bg-white p-2.5 text-xs text-neutral-700 shadow-sm outline-none transition-colors disabled:cursor-not-allowed dark:border-neutral-800 dark:bg-neutral-900 disabled:bg-neutral-100 hover:bg-neutral-50 dark:text-neutral-200 disabled:text-neutral-400 focus:ring-2 focus:ring-black/10 dark:disabled:bg-neutral-800 dark:hover:bg-neutral-800 dark:disabled:text-neutral-600"
31
+ :class="{ 'pointer-events-none': props.disabled }"
32
+ >
33
+ <div class="flex-1 truncate">
34
+ <slot :label="selectedLabel">
35
+ {{ selectedLabel }}
36
+ </slot>
37
+ </div>
38
+ <div i-solar:alt-arrow-down-bold-duotone class="h-3.5 w-3.5 text-neutral-500 dark:text-neutral-400" />
39
+ </div>
40
+
41
+ <template #popper="{ hide }">
42
+ <div class="min-w-[160px] flex flex-col gap-0.5 border border-neutral-200 rounded-lg bg-white p-1 shadow-lg dark:border-neutral-800 dark:bg-neutral-900">
43
+ <div
44
+ v-for="option of props.options"
45
+ v-bind="{ ...$attrs, class: null, style: null }"
46
+ :key="option.value"
47
+ class="cursor-pointer rounded px-2 py-1.5 text-sm text-neutral-700 hover:bg-neutral-100 dark:text-neutral-200 dark:hover:bg-neutral-800"
48
+ :class="{
49
+ 'bg-neutral-100 dark:bg-neutral-800': modelValue === option.value,
50
+ }"
51
+ @click="selectOption(option.value); hide()"
52
+ >
53
+ {{ option.label }}
54
+ </div>
55
+ </div>
56
+ </template>
57
+ </VDropdown>
58
+ </template>
59
+
60
+ <style>
61
+ .resize-observer[data-v-b329ee4c] {
62
+ position: absolute;
63
+ top: 0;
64
+ left: 0;
65
+ z-index: -1;
66
+ width: 100%;
67
+ height: 100%;
68
+ border: none;
69
+ background-color: transparent;
70
+ pointer-events: none;
71
+ display: block;
72
+ overflow: hidden;
73
+ opacity: 0;
74
+ }
75
+
76
+ .resize-observer[data-v-b329ee4c] object {
77
+ display: block;
78
+ position: absolute;
79
+ top: 0;
80
+ left: 0;
81
+ height: 100%;
82
+ width: 100%;
83
+ overflow: hidden;
84
+ pointer-events: none;
85
+ z-index: -1;
86
+ }
87
+
88
+ .v-popper__popper {
89
+ z-index: 10000;
90
+ top: 0;
91
+ left: 0;
92
+ outline: none;
93
+ }
94
+
95
+ .v-popper__arrow-container {
96
+ display: none;
97
+ }
98
+
99
+ .v-popper__inner {
100
+ border: none !important;
101
+ }
102
+ </style>
@@ -0,0 +1 @@
1
+ export { default as Select } from './Select.vue'
@@ -7,9 +7,12 @@ const modelValue = defineModel<string>({ default: '' })
7
7
  <template>
8
8
  <BasicTextarea
9
9
  v-model="modelValue"
10
- border="neutral-100 dark:neutral-800 solid 2 focus:neutral-200 dark:focus:neutral-700"
11
- transition="all duration-250 ease-in-out"
12
- bg="neutral-100 dark:neutral-800 focus:neutral-50 dark:focus:neutral-900"
13
- rounded-lg px-3 py-2 text-sm outline-none
10
+ border="focus:primary-300 dark:focus:primary-400/50 2 solid neutral-100 dark:neutral-900"
11
+ transition="all duration-200 ease-in-out"
12
+ text="disabled:neutral-400 dark:disabled:neutral-600"
13
+ cursor="disabled:not-allowed"
14
+ w-full rounded-lg px-3 py-2 text-sm outline-none
15
+ shadow="sm"
16
+ bg="neutral-50 dark:neutral-950 focus:neutral-50 dark:focus:neutral-900"
14
17
  />
15
18
  </template>
@@ -3,4 +3,5 @@ export * from './Field'
3
3
  export * from './Input'
4
4
  export * from './Radio'
5
5
  export * from './Range'
6
+ export * from './Select'
6
7
  export * from './Textarea'