@namelivia/vue-components 4.5.1 → 4.7.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.
Files changed (48) hide show
  1. package/dist/index.esm.js +1074 -1076
  2. package/dist/index.esm.js.map +1 -1
  3. package/dist/index.js +1103 -1104
  4. package/dist/index.js.map +1 -1
  5. package/package.json +1 -1
  6. package/src/Badge/Badge.vue +3 -7
  7. package/src/Buttons/DangerButton/DangerButton.vue +5 -13
  8. package/src/Buttons/RegularButton/RegularButton.vue +24 -28
  9. package/src/Buttons/ResetButton/ResetButton.vue +3 -7
  10. package/src/Buttons/SecondaryButton/SecondaryButton.vue +5 -13
  11. package/src/Buttons/SubmitButton/SubmitButton.vue +4 -12
  12. package/src/Card/Card.vue +13 -19
  13. package/src/Card/CardBody.vue +4 -9
  14. package/src/Card/CardImage.vue +17 -24
  15. package/src/CardGrid/CardGrid.vue +2 -5
  16. package/src/Container/Container.vue +2 -5
  17. package/src/Icons/CalendarIcon/CalendarIcon.vue +10 -13
  18. package/src/Icons/CreateIcon/CreateIcon.vue +10 -13
  19. package/src/Icons/DropIcon/DropIcon.vue +10 -13
  20. package/src/Icons/SaveIcon/SaveIcon.vue +10 -13
  21. package/src/Icons/SkullIcon/SkullIcon.vue +10 -13
  22. package/src/InfiniteScroll/InfiniteScroll.cy.js +7 -0
  23. package/src/InfiniteScroll/InfiniteScroll.stories.js +38 -0
  24. package/src/InfiniteScroll/InfiniteScroll.vue +59 -0
  25. package/src/Inputs/CheckBoxInput/CheckBoxInput.vue +9 -27
  26. package/src/Inputs/ImageInput/ImageInput.vue +10 -30
  27. package/src/Inputs/NumberInput/NumberInput.vue +12 -37
  28. package/src/Inputs/ResizeImageUpload/ResizeImageUpload.vue +28 -50
  29. package/src/Inputs/Selector/Selector.vue +27 -52
  30. package/src/Inputs/TextInput/TextInput.vue +10 -31
  31. package/src/Loading/Loading.vue +3 -7
  32. package/src/Modal/Modal.vue +9 -16
  33. package/src/Navbar/MobileMenuButton.vue +5 -17
  34. package/src/Navbar/MobileNavigationLink.vue +9 -27
  35. package/src/Navbar/MobileNavigationLinks.vue +6 -19
  36. package/src/Navbar/Navbar.vue +22 -53
  37. package/src/Navbar/NavbarTitle.vue +7 -19
  38. package/src/Navbar/NavigationLink.vue +9 -27
  39. package/src/Navbar/NavigationLinks.vue +5 -15
  40. package/src/Navbar/RightContent.vue +9 -24
  41. package/src/Pagination/Pagination.vue +8 -14
  42. package/src/RangeView/RangeView.vue +3 -7
  43. package/src/SectionTitle/SectionTitle.vue +5 -9
  44. package/src/Spinner/Spinner.vue +2 -5
  45. package/src/StyledTable/StyledTable.vue +2 -5
  46. package/src/Temperature/Temperature.vue +11 -22
  47. package/src/index.js +1 -0
  48. package/styles/index.css +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@namelivia/vue-components",
3
- "version": "4.5.1",
3
+ "version": "4.7.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "peerDependencies": {
@@ -2,13 +2,9 @@
2
2
  span(class="badge")
3
3
  | {{text}}
4
4
  </template>
5
- <script lang="js">
6
- import { defineComponent } from 'vue'
7
- export default defineComponent({
8
- name: "Badge",
9
- props: {
10
- text: String,
11
- },
5
+ <script setup>
6
+ defineProps({
7
+ text: String,
12
8
  })
13
9
  </script>
14
10
  <style scoped>
@@ -3,20 +3,12 @@ button(v-on:click="onClick" class="danger-button")
3
3
  | {{text}}
4
4
  </template>
5
5
 
6
- <script lang="js">
7
- import { defineComponent } from 'vue';
8
- export default defineComponent({
9
- name: "DangerButton",
10
- props: {
11
- text: String,
12
- },
13
- emits: ['click'],
14
- methods: {
15
- onClick(evt) {
16
- this.$emit('click', evt);
17
- },
18
- },
6
+ <script setup>
7
+ defineProps({
8
+ text: String,
19
9
  });
10
+ const emit = defineEmits(['click']);
11
+ const onClick = (evt) => emit('click', evt);
20
12
  </script>
21
13
 
22
14
  <style scoped>
@@ -3,36 +3,33 @@ button(v-on:click="onClick" :class="cssClass" :disabled="loading")
3
3
  | {{ loading ? textWhileLoading : text }}
4
4
  </template>
5
5
 
6
- <script lang="js">
7
- import { defineComponent } from 'vue';
8
- export default defineComponent({
9
- name: "RegularButton",
10
- props: {
11
- text: String,
12
- loading: {
13
- type: Boolean,
14
- default: false,
15
- },
16
- textWhileLoading: {
17
- type: String,
18
- default: '...',
19
- },
20
- },
21
- emits: ['click'],
22
- computed: {
23
- cssClass: function () {
24
- if (this.loading) {
25
- return 'regular-button loading';
26
- }
27
- return 'regular-button'
28
- },
6
+ <script setup>
7
+ import { computed } from 'vue';
8
+
9
+ const props = defineProps({
10
+ text: String,
11
+ loading: {
12
+ type: Boolean,
13
+ default: false,
29
14
  },
30
- methods: {
31
- onClick(evt) {
32
- this.$emit('click', evt);
33
- },
15
+ textWhileLoading: {
16
+ type: String,
17
+ default: '...',
34
18
  },
35
19
  });
20
+
21
+ const emit = defineEmits(['click']);
22
+
23
+ const cssClass = computed(() => {
24
+ if (props.loading) {
25
+ return 'regular-button loading';
26
+ }
27
+ return 'regular-button';
28
+ });
29
+
30
+ const onClick = (evt) => {
31
+ emit('click', evt);
32
+ };
36
33
  </script>
37
34
 
38
35
  <style scoped>
@@ -60,4 +57,3 @@ export default defineComponent({
60
57
  background-color: var(--color-regular-disabled);
61
58
  }
62
59
  </style>
63
-
@@ -3,13 +3,9 @@ button(type="reset" class="reset-button")
3
3
  | {{text}}
4
4
  </template>
5
5
 
6
- <script lang="js">
7
- import { defineComponent } from 'vue';
8
- export default defineComponent({
9
- name: "ResetButton",
10
- props: {
11
- text: String,
12
- },
6
+ <script setup>
7
+ defineProps({
8
+ text: String,
13
9
  });
14
10
  </script>
15
11
 
@@ -3,20 +3,12 @@ button(v-on:click="onClick" class="secondary-button")
3
3
  | {{text}}
4
4
  </template>
5
5
 
6
- <script lang="js">
7
- import { defineComponent } from 'vue';
8
- export default defineComponent({
9
- name: "SecondaryButton",
10
- props: {
11
- text: String,
12
- },
13
- emits: ['click'],
14
- methods: {
15
- onClick(evt) {
16
- this.$emit('click', evt);
17
- },
18
- },
6
+ <script setup>
7
+ defineProps({
8
+ text: String,
19
9
  });
10
+ const emit = defineEmits(['click']);
11
+ const onClick = (evt) => emit('click', evt);
20
12
  </script>
21
13
 
22
14
  <style scoped>
@@ -7,18 +7,10 @@ button(
7
7
  | {{text}}
8
8
  </template>
9
9
 
10
- <script lang="js">
11
- import { defineComponent } from 'vue';
12
- export default defineComponent({
13
- name: "SubmitButton",
14
- props: {
15
- text: {
16
- type: String,
17
- },
18
- disabled: {
19
- type: Boolean,
20
- },
21
- },
10
+ <script setup>
11
+ defineProps({
12
+ text: String,
13
+ disabled: Boolean,
22
14
  });
23
15
  </script>
24
16
 
package/src/Card/Card.vue CHANGED
@@ -5,26 +5,20 @@ div(v-if="!dismissed" class="card-container")
5
5
  card-body(:title="title")
6
6
  slot
7
7
  </template>
8
- <script lang="js">
9
- import { default as CardImage } from './CardImage.vue'
10
- import { default as CardBody } from './CardBody.vue'
11
- import { defineComponent } from 'vue'
12
- export default defineComponent({
13
- name: "Card",
14
- props: {
15
- image: String,
16
- title: String,
17
- dismissed: {
18
- type: Boolean,
19
- default: false,
20
- },
21
- },
22
- components: {
23
- CardImage,
24
- CardBody,
8
+ <script setup>
9
+ import CardImage from './CardImage.vue'
10
+ import CardBody from './CardBody.vue'
11
+
12
+ defineProps({
13
+ image: String,
14
+ title: String,
15
+ dismissed: {
16
+ type: Boolean,
17
+ default: false,
25
18
  },
26
- emits: ['width']
27
- })
19
+ });
20
+
21
+ defineEmits(['width']);
28
22
  </script>
29
23
  <style scoped>
30
24
  .card-container {
@@ -5,14 +5,10 @@ div(class="card-body")
5
5
  p(class="card-text")
6
6
  slot
7
7
  </template>
8
- <script lang="js">
9
- import { defineComponent } from 'vue'
10
- export default defineComponent({
11
- name: "CardBody",
12
- props: {
13
- title: String,
14
- },
15
- })
8
+ <script setup>
9
+ defineProps({
10
+ title: String,
11
+ });
16
12
  </script>
17
13
  <style scoped>
18
14
  .card-body {
@@ -30,4 +26,3 @@ export default defineComponent({
30
26
  font-size: var(--font-size-base);
31
27
  }
32
28
  </style>
33
-
@@ -2,32 +2,25 @@
2
2
  img(:src="src" :alt="alt" ref="image")
3
3
  </template>
4
4
 
5
- <script lang="js">
6
- import { defineComponent } from 'vue'
7
- export default defineComponent({
8
- name: "CardImage",
9
- props: {
10
- src: String,
11
- alt: String,
12
- },
13
- data: function () {
14
- return {
15
- imageWidth: 0,
16
- }
17
- },
18
- methods: {
19
- calculateWidth() {
20
- return this.$refs.image.clientWidth
21
- },
22
- },
23
- emits: ['width'],
24
- mounted: function () {
25
- this.$emit('width', this.calculateWidth())
26
- },
27
- })
5
+ <script setup>
6
+ import { ref, onMounted } from 'vue';
7
+
8
+ defineProps({
9
+ src: String,
10
+ alt: String,
11
+ });
12
+
13
+ const emit = defineEmits(['width']);
14
+ const image = ref(null);
15
+
16
+ const calculateWidth = () => image.value.clientWidth;
17
+
18
+ onMounted(() => {
19
+ emit('width', calculateWidth());
20
+ });
28
21
  </script>
29
22
  <style scoped>
30
23
  img {
31
24
  width: 100%;
32
25
  }
33
- </style
26
+ </style>
@@ -2,11 +2,8 @@
2
2
  div(class="card-grid")
3
3
  slot
4
4
  </template>
5
- <script lang="js">
6
- import { defineComponent } from 'vue';
7
- export default defineComponent({
8
- name: "CardGrid"
9
- });
5
+ <script setup>
6
+ // No logic needed
10
7
  </script>
11
8
  <style scoped>
12
9
  .card-grid {
@@ -3,11 +3,8 @@ div(class="container")
3
3
  slot
4
4
  </template>
5
5
 
6
- <script lang="js">
7
- import { defineComponent } from 'vue';
8
- export default defineComponent({
9
- name: "Container"
10
- });
6
+ <script setup>
7
+ // No logic needed
11
8
  </script>
12
9
 
13
10
  <style scoped>
@@ -2,18 +2,15 @@
2
2
  <svg xmlns="http://www.w3.org/2000/svg" :width="size" :height="size" viewBox="0 0 24 24" fill="none" :stroke="color" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-calendar-icon lucide-calendar"><path d="M8 2v4"/><path d="M16 2v4"/><rect width="18" height="18" x="3" y="4" rx="2"/><path d="M3 10h18"/></svg>
3
3
  </template>
4
4
 
5
- <script>
6
- export default {
7
- name: 'CalendarIcon',
8
- props: {
9
- size: {
10
- type: [Number, String],
11
- default: 24
12
- },
13
- color: {
14
- type: String,
15
- default: 'currentColor'
16
- }
5
+ <script setup>
6
+ defineProps({
7
+ size: {
8
+ type: [Number, String],
9
+ default: 24
10
+ },
11
+ color: {
12
+ type: String,
13
+ default: 'currentColor'
17
14
  }
18
- }
15
+ });
19
16
  </script>
@@ -2,18 +2,15 @@
2
2
  <svg xmlns="http://www.w3.org/2000/svg" :width="size" :height="size" viewBox="0 0 24 24" fill="none" :stroke="color" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-badge-plus-icon lucide-badge-plus"><path d="M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z"/><line x1="12" x2="12" y1="8" y2="16"/><line x1="8" x2="16" y1="12" y2="12"/></svg>
3
3
  </template>
4
4
 
5
- <script>
6
- export default {
7
- name: 'CreateIcon',
8
- props: {
9
- size: {
10
- type: [Number, String],
11
- default: 24
12
- },
13
- color: {
14
- type: String,
15
- default: 'currentColor'
16
- }
5
+ <script setup>
6
+ defineProps({
7
+ size: {
8
+ type: [Number, String],
9
+ default: 24
10
+ },
11
+ color: {
12
+ type: String,
13
+ default: 'currentColor'
17
14
  }
18
- }
15
+ });
19
16
  </script>
@@ -16,18 +16,15 @@
16
16
  </svg>
17
17
  </template>
18
18
 
19
- <script>
20
- export default {
21
- name: 'DropIcon',
22
- props: {
23
- size: {
24
- type: [Number, String],
25
- default: 24
26
- },
27
- color: {
28
- type: String,
29
- default: 'currentColor'
30
- }
19
+ <script setup>
20
+ defineProps({
21
+ size: {
22
+ type: [Number, String],
23
+ default: 24
24
+ },
25
+ color: {
26
+ type: String,
27
+ default: 'currentColor'
31
28
  }
32
- }
29
+ });
33
30
  </script>
@@ -2,18 +2,15 @@
2
2
  <svg xmlns="http://www.w3.org/2000/svg" :width="size" :height="size" viewBox="0 0 24 24" fill="none" :stroke="color" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-save-icon lucide-save"><path d="M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"/><path d="M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"/><path d="M7 3v4a1 1 0 0 0 1 1h7"/></svg>
3
3
  </template>
4
4
 
5
- <script>
6
- export default {
7
- name: 'SaveIcon',
8
- props: {
9
- size: {
10
- type: [Number, String],
11
- default: 24
12
- },
13
- color: {
14
- type: String,
15
- default: 'currentColor'
16
- }
5
+ <script setup>
6
+ defineProps({
7
+ size: {
8
+ type: [Number, String],
9
+ default: 24
10
+ },
11
+ color: {
12
+ type: String,
13
+ default: 'currentColor'
17
14
  }
18
- }
15
+ });
19
16
  </script>
@@ -2,18 +2,15 @@
2
2
  <svg xmlns="http://www.w3.org/2000/svg" :width="size" :height="size" viewBox="0 0 24 24" fill="none" :stroke="color" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-skull-icon lucide-skull"><path d="m12.5 17-.5-1-.5 1h1z"/><path d="M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z"/><circle cx="15" cy="12" r="1"/><circle cx="9" cy="12" r="1"/></svg>
3
3
  </template>
4
4
 
5
- <script>
6
- export default {
7
- name: 'SkullIcon',
8
- props: {
9
- size: {
10
- type: [Number, String],
11
- default: 24
12
- },
13
- color: {
14
- type: String,
15
- default: 'currentColor'
16
- }
5
+ <script setup>
6
+ defineProps({
7
+ size: {
8
+ type: [Number, String],
9
+ default: 24
10
+ },
11
+ color: {
12
+ type: String,
13
+ default: 'currentColor'
17
14
  }
18
- }
15
+ });
19
16
  </script>
@@ -0,0 +1,7 @@
1
+ import InfiniteScroll from './InfiniteScroll.vue'
2
+
3
+ describe('<InfiniteScroll />', () => {
4
+ it.skip('emits load-more event when sentinel is visible', () => {
5
+ // TODO
6
+ })
7
+ })
@@ -0,0 +1,38 @@
1
+ import InfiniteScroll from './InfiniteScroll.vue';
2
+ import Card from '../Card/Card.vue';
3
+ import { ref } from 'vue';
4
+
5
+ export default {
6
+ title: 'Components/InfiniteScroll',
7
+ component: InfiniteScroll,
8
+ };
9
+
10
+ export const Default = {
11
+ render: (args) => ({
12
+ components: { InfiniteScroll, Card },
13
+ setup() {
14
+ const items = ref([1, 2, 3, 4, 5]);
15
+ const loadMore = () => {
16
+ const last = items.value[items.value.length - 1];
17
+ // Simulate API delay
18
+ setTimeout(() => {
19
+ for (let i = 1; i <= 5; i++) {
20
+ items.value.push(last + i);
21
+ }
22
+ }, 500);
23
+ };
24
+ return { args, items, loadMore };
25
+ },
26
+ template: `
27
+ <div style="height: 400px; overflow-y: auto; border: 1px solid #ccc;">
28
+ <InfiniteScroll v-bind="args" @load-more="loadMore">
29
+ <div v-for="item in items" :key="item" style="padding: 20px; border-bottom: 1px solid #eee;">
30
+ <Card :title="'Item ' + item">
31
+ <p>Scroll down to load more content...</p>
32
+ </Card>
33
+ </div>
34
+ </InfiniteScroll>
35
+ </div>
36
+ `,
37
+ }),
38
+ };
@@ -0,0 +1,59 @@
1
+ <template lang="pug">
2
+ div(class="infinite-scroll-container")
3
+ slot
4
+ div(ref="sentinel" class="sentinel")
5
+ </template>
6
+
7
+ <script setup>
8
+ import { ref, onMounted, onBeforeUnmount } from 'vue';
9
+
10
+ const props = defineProps({
11
+ threshold: {
12
+ type: Number,
13
+ default: 0.1
14
+ },
15
+ rootMargin: {
16
+ type: String,
17
+ default: '0px'
18
+ },
19
+ disabled: {
20
+ type: Boolean,
21
+ default: false
22
+ }
23
+ });
24
+
25
+ const emit = defineEmits(['load-more']);
26
+ const sentinel = ref(null);
27
+ let observer = null;
28
+
29
+ onMounted(() => {
30
+ observer = new IntersectionObserver(([entry]) => {
31
+ if (entry.isIntersecting && !props.disabled) {
32
+ emit('load-more');
33
+ }
34
+ }, {
35
+ rootMargin: props.rootMargin,
36
+ threshold: props.threshold
37
+ });
38
+
39
+ if (sentinel.value) {
40
+ observer.observe(sentinel.value);
41
+ }
42
+ });
43
+
44
+ onBeforeUnmount(() => {
45
+ if (observer) {
46
+ observer.disconnect();
47
+ }
48
+ });
49
+ </script>
50
+
51
+ <style scoped>
52
+ .infinite-scroll-container {
53
+ width: 100%;
54
+ }
55
+ .sentinel {
56
+ height: var(--infinite-scroll-sentinel-height, 1px);
57
+ width: 100%;
58
+ }
59
+ </style>
@@ -12,34 +12,16 @@ div(class="checkbox-container")
12
12
  label(class="checkbox-label" :for="id") {{ label }}
13
13
  </template>
14
14
 
15
- <script lang="js">
16
- import { defineComponent } from 'vue';
17
- export default defineComponent({
18
- name: "CheckBoxInput",
19
- props: {
20
- id: {
21
- type: String,
22
- },
23
- required: {
24
- type: Boolean,
25
- },
26
- placeholder: {
27
- type: String,
28
- },
29
- label: {
30
- type: String,
31
- },
32
- checked: {
33
- type: Boolean,
34
- },
35
- },
36
- emits: ['update'],
37
- methods: {
38
- onInput(event) {
39
- this.$emit('update', event.target.value);
40
- },
41
- },
15
+ <script setup>
16
+ defineProps({
17
+ id: String,
18
+ required: Boolean,
19
+ placeholder: String,
20
+ label: String,
21
+ checked: Boolean,
42
22
  });
23
+ const emit = defineEmits(['update']);
24
+ const onInput = (event) => emit('update', event.target.value);
43
25
  </script>
44
26
 
45
27
  <style scoped>