@code-coaching/vuetiful 0.21.4 → 0.22.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-coaching/vuetiful",
3
- "version": "0.21.4",
3
+ "version": "0.22.0",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "dev": "onchange 'src/**/*.vue' 'src/**/*.ts' 'src/**/*.css' -- npm run build",
@@ -25,7 +25,7 @@ const props = defineProps({
25
25
  },
26
26
  hover: {
27
27
  type: String,
28
- default: "hover:variant-ghost",
28
+ default: "hover:variant-ghost hover:text-surface-900 dark:hover:text-surface-50",
29
29
  },
30
30
 
31
31
  background: {
@@ -36,6 +36,11 @@ const props = defineProps({
36
36
  type: String,
37
37
  default: "text-surface-900 dark:text-surface-50",
38
38
  },
39
+
40
+ unstyled: {
41
+ type: Boolean,
42
+ default: false,
43
+ },
39
44
  });
40
45
 
41
46
  const parentModelValue = ref(props.modelValue);
@@ -63,7 +68,11 @@ l
63
68
  :as="as"
64
69
  :disabled="disabled"
65
70
  :by="by"
66
- :class="`radio-group inline-flex gap-1 p-1 ${background} ${text} border-token border-surface-400-500-token rounded-container-token`"
71
+ :class="`${
72
+ unstyled
73
+ ? ''
74
+ : `radio-group ${background} ${text} inline-flex gap-1 p-1 border-token border-surface-400-500-token rounded-container-token`
75
+ }`"
67
76
  v-model="parentModelValue"
68
77
  >
69
78
  <slot></slot>
@@ -7,6 +7,10 @@ defineProps({
7
7
  type: [String, Number, Boolean, Object],
8
8
  required: true,
9
9
  },
10
+ unstyled: {
11
+ type: Boolean,
12
+ default: false,
13
+ },
10
14
  });
11
15
 
12
16
  const active = inject("active") as string;
@@ -17,9 +21,13 @@ const hover = inject("hover") as string;
17
21
  <RadioGroupOption v-slot="{ checked, disabled }" :value="value">
18
22
  <div
19
23
  data-test="radio-item"
20
- :class="`radio-item px-4 py-1 text-center text-base rounded-token ${
21
- checked ? active : hover
22
- } ${disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer'}`"
24
+ :class="`radio-item ${
25
+ unstyled
26
+ ? ''
27
+ : `px-4 py-1 text-center text-base rounded-token ${checked ? active : hover} ${
28
+ disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer'
29
+ }`
30
+ }`"
23
31
  >
24
32
  <slot />
25
33
  </div>
@@ -1,28 +1,18 @@
1
1
  <script setup lang="ts">
2
2
  import type { CssClasses } from "@/index";
3
+ import { VRadioGroup, useRail } from "@/index";
3
4
  import { provide } from "vue";
4
5
 
6
+ const { selectedRailTile } = useRail();
7
+
5
8
  const props = defineProps({
6
9
  active: {
7
10
  type: String as () => CssClasses,
8
- default: "bg-secondary-active-token",
11
+ default: "variant-filled",
9
12
  },
10
13
  hover: {
11
14
  type: String as () => CssClasses,
12
- default: "hover:bg-secondary-hover-token",
13
- },
14
-
15
- regionLead: {
16
- type: String as () => CssClasses,
17
- default: "",
18
- },
19
- regionDefault: {
20
- type: String as () => CssClasses,
21
- default: "",
22
- },
23
- regionTrail: {
24
- type: String as () => CssClasses,
25
- default: "",
15
+ default: "hover:variant-ghost hover:text-surface-900 dark:hover:text-surface-50",
26
16
  },
27
17
  });
28
18
 
@@ -31,9 +21,13 @@ provide("hover", props.hover);
31
21
  </script>
32
22
 
33
23
  <template>
34
- <div class="v-rail grid h-full w-[70px] grid-rows-[auto_1fr_auto] gap-0 overflow-y-auto sm:w-20">
35
- <div class="v-bar-lead" :class="regionLead"><slot name="lead" /></div>
36
- <div class="v-bar-default" :class="regionDefault"><slot /></div>
37
- <div class="v-bar-trail" :class="regionTrail"><slot name="trail" /></div>
38
- </div>
24
+ <v-radio-group
25
+ unstyled
26
+ :active="active"
27
+ :hover="hover"
28
+ v-model="selectedRailTile"
29
+ class="vuetiful-rail flex h-full w-[70px] flex-col overflow-y-auto sm:w-20"
30
+ >
31
+ <slot />
32
+ </v-radio-group>
39
33
  </template>
@@ -1,21 +1,14 @@
1
1
  <script setup lang="ts">
2
2
  import type { CssClasses } from "@/index";
3
+ import { VRadioItem } from "@/index";
3
4
  import { useRail } from "@/services";
4
- import { inject, useAttrs } from "vue";
5
+ import { inject } from "vue";
5
6
 
6
- const emit = defineEmits<{
7
- (event: "click"): void;
8
- }>();
9
-
10
- const props = defineProps({
7
+ defineProps({
11
8
  value: {
12
9
  type: String,
13
10
  default: "",
14
11
  },
15
- tag: {
16
- type: String as () => string,
17
- default: "button",
18
- },
19
12
  label: {
20
13
  type: String as () => string,
21
14
  default: "",
@@ -31,53 +24,26 @@ const props = defineProps({
31
24
  },
32
25
  });
33
26
 
34
- const attrs = useAttrs();
35
-
36
27
  const { selectedRailTile } = useRail();
37
28
  const active = inject("active");
38
29
  const hover = inject("hover");
39
-
40
- const activate = () => {
41
- selectedRailTile.value = props.value;
42
- emit("click");
43
- };
44
-
45
- const clickHandler = (event: MouseEvent) => {
46
- event.preventDefault();
47
- activate();
48
- };
49
-
50
- const keydownHandler = (event: KeyboardEvent) => {
51
- if (["Enter", " "].includes(event.key)) event.preventDefault();
52
- if (event.key === "Enter") activate();
53
- };
54
-
55
- const keyupHandler = (event: KeyboardEvent) => {
56
- if (event.key === " ") {
57
- event.preventDefault();
58
- activate();
59
- }
60
- };
61
30
  </script>
62
31
 
63
32
  <template>
64
- <component
65
- @click="clickHandler"
66
- @keydown="keydownHandler"
67
- @keyup="keyupHandler"
68
- :is="tag"
69
- v-bind="attrs"
70
- :class="`app-rail-tile unstyled grid aspect-square w-full cursor-pointer place-content-center place-items-center space-y-1.5 ${hover} ${
33
+ <v-radio-item
34
+ :value="value"
35
+ unstyled
36
+ :class="`vuetiful-rail-tile grid aspect-square w-full cursor-pointer place-content-center place-items-center space-y-1.5 ${hover} ${
71
37
  selectedRailTile === value ? `${active}` : ''
72
38
  }`"
73
39
  >
74
40
  <template v-if="$slots.default">
75
- <div :class="`app-rail-tile-icon ${regionIcon}`"><slot /></div>
41
+ <div :class="`vuetiful-rail-tile-icon ${regionIcon}`"><slot /></div>
76
42
  </template>
77
43
  <template v-if="label">
78
- <div :class="`app-rail-tile-label text-center text-xs font-bold ${regionLabel}`">
44
+ <div :class="`vuetiful-rail-tile-label text-center text-xs font-bold ${regionLabel}`">
79
45
  {{ label }}
80
46
  </div>
81
47
  </template>
82
- </component>
48
+ </v-radio-item>
83
49
  </template>